refactor: make the ExtensionMetadata interface much less cluttered by having other interfaces extend off of it.
This commit is contained in:
parent
a05e112de9
commit
5fc3995257
5 changed files with 18 additions and 10 deletions
|
|
@ -15,7 +15,7 @@ module.exports = {
|
|||
"prefer-const": "error",
|
||||
"no-case-declarations": "off"
|
||||
},
|
||||
ignorePatterns: ["env.d.ts"],
|
||||
ignorePatterns: ["env.d.ts", "middleware/", "public/"],
|
||||
overrides: [
|
||||
{
|
||||
files: ["*.astro"],
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
// TODO: Get rid of this ugly type assertion!!
|
||||
const result = (event.target as IDBRequest).result;
|
||||
if (result) {
|
||||
result.forEach((extension: ExtensionMetadata) => {
|
||||
result.forEach((extension: ExtPageMetadata) => {
|
||||
if (extension.type === "page") {
|
||||
const decoder = new TextDecoder();
|
||||
const script = decoder.decode(extension.scriptCopy!);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
store.getAll().onsuccess = (event) => {
|
||||
const result = (event.target as IDBRequest).result;
|
||||
if (result) {
|
||||
result.forEach((extension: ExtensionMetadata) => {
|
||||
result.forEach((extension: ExtThemeMetadata) => {
|
||||
if (extension.type === "theme" && extension.themeName) {
|
||||
// Load theme CSS
|
||||
const decoder = new TextDecoder();
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ function applyInputListeners(inputs: HTMLInputElement[], localStorageItem: Alu.V
|
|||
// });
|
||||
// }
|
||||
|
||||
function addThemeToDropdown(extension: ExtensionMetadata) {
|
||||
function addThemeToDropdown(extension: ExtThemeMetadata) {
|
||||
const dropdown = document.getElementById("dropdown__selected-theme-menu");
|
||||
if (dropdown) {
|
||||
// TODO: Figure out why addThemeToDropdown is being called 6 times
|
||||
|
|
@ -230,7 +230,7 @@ function setupCustomizationSettings() {
|
|||
store.getAll().onsuccess = (event) => {
|
||||
const result = (event.target as IDBRequest).result;
|
||||
if (result) {
|
||||
result.forEach((extension: ExtensionMetadata) => {
|
||||
result.forEach((extension: ExtThemeMetadata) => {
|
||||
if (extension.type === "theme" && extension.themeName) {
|
||||
// Create a dropdown item for the theme
|
||||
addThemeToDropdown(extension);
|
||||
|
|
|
|||
18
src/types.d.ts
vendored
18
src/types.d.ts
vendored
|
|
@ -36,13 +36,21 @@ interface ExtensionMetadata {
|
|||
version: string;
|
||||
image: string;
|
||||
script: string;
|
||||
pages?: string[];
|
||||
entryNamespace?: string;
|
||||
entryFunc?: string;
|
||||
init?: string;
|
||||
scriptCopy?: Uint8Array | null;
|
||||
type: ExtType;
|
||||
themeName?: string;
|
||||
}
|
||||
|
||||
interface ExtServiceWorkerMetadata extends ExtensionMetadata {
|
||||
entryNamespace: string;
|
||||
entryFunc: string;
|
||||
}
|
||||
|
||||
interface ExtPageMetadata extends ExtensionMetadata {
|
||||
init: string;
|
||||
}
|
||||
|
||||
interface ExtThemeMetadata extends ExtensionMetadata {
|
||||
themeName: string;
|
||||
}
|
||||
|
||||
type ExtensionMetadataJSON = Record<string, ExtensionMetadata>;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue