From fc5933fcfdc42a23c1fd268883496266ae570e7e Mon Sep 17 00:00:00 2001 From: Mauro Balades Date: Tue, 6 Aug 2024 10:57:17 +0200 Subject: [PATCH] Remove unused code and update types --- src/common/index.d.ts => @types/common.d.ts | 0 {src/common => @types}/gecko.d.ts | 0 @types/split-views.d.ts | 12 ++++++++++++ src/splitViews.mjs | 20 +++++++++++++++----- src/types.d.ts | 13 ------------- tsconfig.json | 9 ++++----- 6 files changed, 31 insertions(+), 23 deletions(-) rename src/common/index.d.ts => @types/common.d.ts (100%) rename {src/common => @types}/gecko.d.ts (100%) create mode 100644 @types/split-views.d.ts delete mode 100644 src/types.d.ts diff --git a/src/common/index.d.ts b/@types/common.d.ts similarity index 100% rename from src/common/index.d.ts rename to @types/common.d.ts diff --git a/src/common/gecko.d.ts b/@types/gecko.d.ts similarity index 100% rename from src/common/gecko.d.ts rename to @types/gecko.d.ts diff --git a/@types/split-views.d.ts b/@types/split-views.d.ts new file mode 100644 index 0000000..feaa0b0 --- /dev/null +++ b/@types/split-views.d.ts @@ -0,0 +1,12 @@ + +declare type SplitType = 'horizontal' | 'vertical' | 'grid'; + +declare interface SplitViewConfig extends Config { + keyIndicator: string; // e.g. "split-tab='true'" + defaultSplitView: SplitType; +}; + +declare interface SplitView { + type: SplitType; + tabs: MockedExports.BrowserTab[]; +}; diff --git a/src/splitViews.mjs b/src/splitViews.mjs index ecdc2a1..a54caf3 100644 --- a/src/splitViews.mjs +++ b/src/splitViews.mjs @@ -1,19 +1,29 @@ class SplitViewsBase { /** - * @param {SplitViewConfig} config - * @param {SplitViewData[]} data - * @param {number} currentView + * @type {SplitView[]} + */ + data; + + /** * @param {SplitViewConfig} config */ constructor(config) { - this.config = config.awd; + this.config = config; this.data = []; this.currentView = -1; this.addEventListeners(); this.log('SplitViewsBase initialized'); } + /** + * @param {string} message + * @protected + */ + log(message) { + console.log(`SplitViews: ${message}`); + } + addEventListeners() { window.addEventListener('TabClose', this); } @@ -92,7 +102,7 @@ export class SplitViews extends SplitViewsBase { * @param {SplitType} type * @private */ - createSplitView(tabs, type = this.viewConfig.defaultSplitView) { + createSplitView(tabs, type = this.config.defaultSplitView) { this.log('createSplitView'); } }; diff --git a/src/types.d.ts b/src/types.d.ts deleted file mode 100644 index db9c6a9..0000000 --- a/src/types.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Config } from "./common"; - -export type SplitType = 'horizontal' | 'vertical' | 'grid'; - -export interface SplitViewConfig { - keyIndicator: string; // e.g. "split-tab='true'" - defaultSplitView: SplitType; -}; - -export interface SplitView { - type: SplitType; - tabs: MockedExports.BrowserTab[]; -}; diff --git a/tsconfig.json b/tsconfig.json index 261548d..4db6c40 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -27,17 +27,16 @@ // Allow esnext syntax. Otherwise the default is ES5 only. "target": "esnext", "lib": ["esnext", "dom"], - "noEmit": true, /* Modules */ "module": "CommonJS", /* Specify what module code is generated. */ - //"rootDir": "./src", /* Specify the root folder within your source files. */ + "rootDir": "./src", /* Specify the root folder within your source files. */ // "moduleResolution": "NodeNext", /* Specify how TypeScript looks up a file from a given module specifier. */ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + "typeRoots": ["./@types"], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "resolveJsonModule": true, /* Enable importing .json files */ // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */ @@ -48,9 +47,9 @@ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */ /* Emit */ - // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ "sourceMap": true, /* Create source map files for emitted JavaScript files. */ // "outFile": "./dist/components.js", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ "outDir": "./dist", /* Specify an output folder for all emitted files. */