From cc664b23762ebfb8b0d730d5ba11bec848965450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jezer=20Mej=C3=ADa?= Date: Sun, 14 Jul 2024 01:16:15 -0600 Subject: [PATCH] Fix typescript errors --- vite.js => compile.js | 0 package-lock.json | 14 ++++++ package.json | 10 ++-- src/common/ldm_interfaces.ts | 31 ++++++++++++ src/global.d.ts | 2 +- src/main/bridge/bridge.ts | 2 +- src/main/bridge/bridge_objects.ts | 2 +- src/main/browser.ts | 2 +- src/main/index.ts | 2 +- src/preload/index.ts | 31 +----------- tsconfig.json | 83 +++++-------------------------- tsconfig.main.json | 24 +++++++++ tsconfig.preload.json | 27 ++++++++++ 13 files changed, 120 insertions(+), 110 deletions(-) rename vite.js => compile.js (100%) create mode 100644 tsconfig.main.json create mode 100644 tsconfig.preload.json diff --git a/vite.js b/compile.js similarity index 100% rename from vite.js rename to compile.js diff --git a/package-lock.json b/package-lock.json index 50cb9f1..8f39d3a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,8 @@ "devDependencies": { "@electron/asar": "^3.2.10", "@electron/rebuild": "^3.6.0", + "@tsconfig/node18": "^18.0.0", + "@tsconfig/recommended": "^1.0.7", "@types/js-yaml": "^4.0.2", "@types/yargs": "^17.0.10", "@typescript-eslint/eslint-plugin": "^7.16.0", @@ -999,6 +1001,18 @@ "node": ">= 10" } }, + "node_modules/@tsconfig/node18": { + "version": "18.2.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node18/-/node18-18.2.4.tgz", + "integrity": "sha512-5xxU8vVs9/FNcvm3gE07fPbn9tl6tqGGWA9tSlwsUEkBxtRnTsNmwrV8gasZ9F/EobaSv9+nu8AxUKccw77JpQ==", + "dev": true + }, + "node_modules/@tsconfig/recommended": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@tsconfig/recommended/-/recommended-1.0.7.tgz", + "integrity": "sha512-xiNMgCuoy4mCL4JTywk9XFs5xpRUcKxtWEcMR6FNMtsgewYTIgIR+nvlP4A4iRCAzRsHMnPhvTRrzp4AGcRTEA==", + "dev": true + }, "node_modules/@types/cacheable-request": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz", diff --git a/package.json b/package.json index cee034a..b846e2e 100644 --- a/package.json +++ b/package.json @@ -8,12 +8,12 @@ "scripts": { "start": "electron .", "rebuild": "electron-rebuild -w node-gtk", - "build": "npm run build:vite && node make build", - "build:vite": "node vite.js && npm run build:themes", + "build": "npm run build:compile && node make build", + "build:compile": "node compile.js && npm run build:themes", "build:theme:gruvbox": "tsc --build themes/themes/gruvbox", "build:theme:dracula": "tsc --build themes/themes/dracula", "build:themes": "npm run build:theme:gruvbox && npm run build:theme:dracula", - "type-check": "tsc --noEmit", + "type-check": "tsc -b", "lint": "eslint \"ts/**\"", "lint:fix": "eslint \"ts/**\" --fix", "lint:theme:gruvbox": "eslint \"themes/themes/gruvbox/ts/**\"", @@ -38,8 +38,10 @@ "license": "ISC", "homepage": "https://github.com/JezerM/nody-greeter", "devDependencies": { - "@electron/rebuild": "^3.6.0", "@electron/asar": "^3.2.10", + "@electron/rebuild": "^3.6.0", + "@tsconfig/node18": "^18.0.0", + "@tsconfig/recommended": "^1.0.7", "@types/js-yaml": "^4.0.2", "@types/yargs": "^17.0.10", "@typescript-eslint/eslint-plugin": "^7.16.0", diff --git a/src/common/ldm_interfaces.ts b/src/common/ldm_interfaces.ts index 00f32ab..b48a5b3 100644 --- a/src/common/ldm_interfaces.ts +++ b/src/common/ldm_interfaces.ts @@ -43,10 +43,41 @@ interface LightDMBattery { watt: number; } +/** + * Metadata that is sent to each window to handle more interesting multi-monitor + * functionality / themes. + */ +interface WindowMetadata { + // TODO: Remove this eslint-disable comment + /* eslint-disable @typescript-eslint/naming-convention */ + id: number; + is_primary: boolean; + position: { + x: number; + y: number; + }; + size: { + width: number; + height: number; + }; + /** + * The total real-estate across all screens, + * this can be used to assist in, for example, + * correctly positioning multi-monitor backgrounds. + */ + overallBoundary: { + minX: number; + maxX: number; + minY: number; + maxY: number; + }; +} + export { LightDMBattery, LightDMLanguage, LightDMLayout, LightDMSession, LightDMUser, + WindowMetadata, }; diff --git a/src/global.d.ts b/src/global.d.ts index b90c622..c6c15d2 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -1,4 +1,4 @@ -import { Greeter, GreeterConfig, ThemeUtils } from "./bridge/bridge"; +import { Greeter, GreeterConfig, ThemeUtils } from "./main/bridge/bridge"; declare global { /* eslint-disable no-var */ diff --git a/src/main/bridge/bridge.ts b/src/main/bridge/bridge.ts index 2efe5ed..c453652 100644 --- a/src/main/bridge/bridge.ts +++ b/src/main/bridge/bridge.ts @@ -28,7 +28,7 @@ import { LightDMLayout, LightDMSession, LightDMUser, -} from "../ldm_interfaces"; +} from "common/ldm_interfaces"; import { logger } from "../logger"; import { CONSTS } from "common/consts"; diff --git a/src/main/bridge/bridge_objects.ts b/src/main/bridge/bridge_objects.ts index 74fb6e1..b14a54f 100644 --- a/src/main/bridge/bridge_objects.ts +++ b/src/main/bridge/bridge_objects.ts @@ -4,7 +4,7 @@ import { LightDMLayout, LightDMSession, LightDMUser, -} from "../ldm_interfaces"; +} from "common/ldm_interfaces"; import { LightDM } from "node-gtk"; import { BatteryController } from "../utils/battery"; diff --git a/src/main/browser.ts b/src/main/browser.ts index 2ce5bf5..21c496d 100644 --- a/src/main/browser.ts +++ b/src/main/browser.ts @@ -19,7 +19,7 @@ import * as url from "url"; import { brightnessController } from "./utils/brightness"; import { logger } from "./logger"; import { setScreensaver, resetScreensaver } from "./utils/screensaver"; -import { WindowMetadata } from "../preload/index"; +import { WindowMetadata } from "common/ldm_interfaces"; interface NodyWindow { isPrimary: boolean; diff --git a/src/main/index.ts b/src/main/index.ts index 6c1a74e..ebe3b63 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -5,7 +5,7 @@ import * as path from "path"; import { ensureTheme, loadThemeConfig, globalNodyConfig } from "./config"; -const res = yargs +const res = yargs(process.argv) .scriptName("nody-greeter") .usage("$0 [args]") .option("mode", { diff --git a/src/preload/index.ts b/src/preload/index.ts index d008845..1ecc742 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -6,38 +6,9 @@ import { LightDMLayout, LightDMSession, LightDMUser, + WindowMetadata, } from "common/ldm_interfaces"; -/** - * Metadata that is sent to each window to handle more interesting multi-monitor - * functionality / themes. - */ -export interface WindowMetadata { - // TODO: Remove this eslint-disable comment - /* eslint-disable @typescript-eslint/naming-convention */ - id: number; - is_primary: boolean; - position: { - x: number; - y: number; - }; - size: { - width: number; - height: number; - }; - /** - * The total real-estate across all screens, - * this can be used to assist in, for example, - * correctly positioning multi-monitor backgrounds. - */ - overallBoundary: { - minX: number; - maxX: number; - minY: number; - maxY: number; - }; -} - /** * An event that is fired and dispatched when one browser window of a theme * sends a broadcast to all windows (which happens for multi-monitor setups) diff --git a/tsconfig.json b/tsconfig.json index e02b5cd..78bef66 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,74 +1,15 @@ { + "files": [], + "references": [ + { + "path": "./tsconfig.main.json" + }, + { + "path": "./tsconfig.preload.json" + } + ], "compilerOptions": { - /* Visit https://aka.ms/tsconfig.json to read more about this file */ - - /* Basic Options */ - // "incremental": true, /* Enable incremental compilation */ - "target": "es2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ - // "lib": [], /* Specify library files to be included in the compilation. */ - "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - "outDir": "./js", /* Redirect output structure to the directory. */ - "rootDir": "./ts", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "composite": true, /* Enable project compilation */ - // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - - /* Strict Type-Checking Options */ - "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitUseStrict": true, - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "strictFunctionTypes": true, /* Enable strict checking of function types. */ - // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ - // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ - - /* Module Resolution Options */ - "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ - // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - - /* Source Map Options */ - // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - - /* Advanced Options */ - "skipLibCheck": true, /* Skip type checking of declaration files. */ - "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ - }, - "include": [ - "./ts" - ] + "noImplicitAny": false, + "allowJs": true, + } } diff --git a/tsconfig.main.json b/tsconfig.main.json new file mode 100644 index 0000000..f90535a --- /dev/null +++ b/tsconfig.main.json @@ -0,0 +1,24 @@ +{ + "extends": "@tsconfig/node18/tsconfig.json", + "include": [ + "env.d.ts", + "src/global.d.ts", + "src/main/**/*", + "src/common/**/*" + ], + "compilerOptions": { + "composite": true, + "noEmit": true, + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.main.tsbuildinfo", + "module": "ESNext", + "moduleResolution": "bundler", + "types": [ + "node" + ], + "paths": { + "common/*": [ + "./src/common/*" + ] + } + } +} diff --git a/tsconfig.preload.json b/tsconfig.preload.json new file mode 100644 index 0000000..f045969 --- /dev/null +++ b/tsconfig.preload.json @@ -0,0 +1,27 @@ +{ + "extends": "@tsconfig/recommended/tsconfig.json", + "include": [ + "src/preload/**/*", + "src/common/**/*", + ], + "exclude": [ + "src/**/__tests__/*" + ], + "compilerOptions": { + "composite": true, + "noEmit": true, + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.preload.tsbuildinfo", + "module": "ES2020", + "moduleResolution": "bundler", + "lib": [ + "ES2020", + "DOM", + "DOM.Iterable" + ], + "paths": { + "common/*": [ + "./src/common/*" + ] + } + } +}