From 9bb1e1232f43726e0564e44256870e492abbbf93 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Mon, 23 Sep 2024 07:22:25 -0700 Subject: [PATCH] Don't build internal TS packages --- package.json | 2 +- plugin-runtime/package.json | 4 +-- plugin-runtime/src/index.worker.ts | 9 ++++-- src-tauri/yaak_models/.gitignore | 1 - src-tauri/yaak_models/package.json | 6 +--- src-tauri/yaak_models/tsconfig.json | 15 --------- src-tauri/yaak_plugin_runtime/.gitignore | 1 - .../yaak_plugin_runtime/bindings/events.js | 2 -- .../yaak_plugin_runtime/bindings/models.js | 3 -- src-tauri/yaak_plugin_runtime/package.json | 6 +--- src-tauri/yaak_plugin_runtime/tsconfig.json | 15 --------- src-tauri/yaak_templates/index.ts | 3 ++ src-tauri/yaak_templates/package.json | 6 +--- src-tauri/yaak_templates/tsconfig.json | 15 --------- src-web/hooks/useParseTemplate.ts | 2 +- tsconfig.json | 31 +++++++++++++++++++ tsconfig.node.json | 10 ++++++ 17 files changed, 57 insertions(+), 74 deletions(-) delete mode 100644 src-tauri/yaak_models/.gitignore delete mode 100644 src-tauri/yaak_models/tsconfig.json delete mode 100644 src-tauri/yaak_plugin_runtime/.gitignore delete mode 100644 src-tauri/yaak_plugin_runtime/bindings/events.js delete mode 100644 src-tauri/yaak_plugin_runtime/bindings/models.js delete mode 100644 src-tauri/yaak_plugin_runtime/tsconfig.json delete mode 100644 src-tauri/yaak_templates/tsconfig.json create mode 100644 tsconfig.json create mode 100644 tsconfig.node.json diff --git a/package.json b/package.json index f4c9d1ae..f2b1feed 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,6 @@ "nodejs-file-downloader": "^4.13.0", "npm-run-all": "^4.1.5", "prettier": "^3.3.3", - "typescript": "^5.6.0" + "typescript": "^5.6.2" } } diff --git a/plugin-runtime/package.json b/plugin-runtime/package.json index 2d584d6d..c3aac18b 100644 --- a/plugin-runtime/package.json +++ b/plugin-runtime/package.json @@ -17,9 +17,7 @@ "@types/intercept-stdout": "^0.1.3", "grpc-tools": "^1.12.4", "nodemon": "^3.1.4", - "npm-run-all": "^4.1.5", "ts-node": "^10.9.2", - "ts-proto": "^2.2.0", - "typescript": "^5.6.0" + "ts-proto": "^2.2.0" } } diff --git a/plugin-runtime/src/index.worker.ts b/plugin-runtime/src/index.worker.ts index 8e83f47b..c5496369 100644 --- a/plugin-runtime/src/index.worker.ts +++ b/plugin-runtime/src/index.worker.ts @@ -24,6 +24,7 @@ async function initialize() { const pathPkg = path.join(pluginDir, 'package.json'); const pathMod = path.posix.join(pluginDir, 'build', 'index.js'); + async function importModule() { const id = require.resolve(pathMod); delete require.cache[id]; @@ -247,7 +248,9 @@ async function initialize() { payload.type === 'call_http_request_action_request' && Array.isArray(mod.plugin?.httpRequestActions) ) { - const action = mod.plugin.httpRequestActions.find((a) => a.key === payload.key); + const action = mod.plugin.httpRequestActions.find( + (a: HttpRequestActionPlugin) => a.key === payload.key, + ); if (typeof action?.onSelect === 'function') { await action.onSelect(ctx, payload.args); sendEmpty(replyId); @@ -259,7 +262,9 @@ async function initialize() { payload.type === 'call_template_function_request' && Array.isArray(mod.plugin?.templateFunctions) ) { - const action = mod.plugin.templateFunctions.find((a) => a.name === payload.name); + const action = mod.plugin.templateFunctions.find( + (a: TemplateFunctionPlugin) => a.name === payload.name, + ); if (typeof action?.onRender === 'function') { const result = await action.onRender(ctx, payload.args); sendPayload({ type: 'call_template_function_response', value: result ?? null }, replyId); diff --git a/src-tauri/yaak_models/.gitignore b/src-tauri/yaak_models/.gitignore deleted file mode 100644 index a65b4177..00000000 --- a/src-tauri/yaak_models/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/src-tauri/yaak_models/package.json b/src-tauri/yaak_models/package.json index 1b99aa98..290cf741 100644 --- a/src-tauri/yaak_models/package.json +++ b/src-tauri/yaak_models/package.json @@ -2,9 +2,5 @@ "name": "@yaakapp-internal/models", "private": true, "version": "1.0.0", - "main": "lib/index.js", - "typings": "./lib/index.d.ts", - "scripts": { - "build": "tsc" - } + "main": "index.ts" } diff --git a/src-tauri/yaak_models/tsconfig.json b/src-tauri/yaak_models/tsconfig.json deleted file mode 100644 index 3d1f6ca9..00000000 --- a/src-tauri/yaak_models/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "compilerOptions": { - "module": "node16", - "target": "es6", - "lib": ["es2021"], - "declaration": true, - "declarationDir": "./lib", - "outDir": "./lib", - "strict": true, - "types": ["node"] - }, - "files": [ - "index.ts" - ] -} diff --git a/src-tauri/yaak_plugin_runtime/.gitignore b/src-tauri/yaak_plugin_runtime/.gitignore deleted file mode 100644 index a65b4177..00000000 --- a/src-tauri/yaak_plugin_runtime/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/src-tauri/yaak_plugin_runtime/bindings/events.js b/src-tauri/yaak_plugin_runtime/bindings/events.js deleted file mode 100644 index c8ad2e54..00000000 --- a/src-tauri/yaak_plugin_runtime/bindings/events.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/src-tauri/yaak_plugin_runtime/bindings/models.js b/src-tauri/yaak_plugin_runtime/bindings/models.js deleted file mode 100644 index ca914b0b..00000000 --- a/src-tauri/yaak_plugin_runtime/bindings/models.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/src-tauri/yaak_plugin_runtime/package.json b/src-tauri/yaak_plugin_runtime/package.json index 4d53d947..beb61b6b 100644 --- a/src-tauri/yaak_plugin_runtime/package.json +++ b/src-tauri/yaak_plugin_runtime/package.json @@ -2,9 +2,5 @@ "name": "@yaakapp-internal/plugin", "private": true, "version": "1.0.0", - "main": "lib/index.js", - "typings": "./lib/index.d.ts", - "scripts": { - "build": "tsc" - } + "main": "index.ts" } diff --git a/src-tauri/yaak_plugin_runtime/tsconfig.json b/src-tauri/yaak_plugin_runtime/tsconfig.json deleted file mode 100644 index 3d1f6ca9..00000000 --- a/src-tauri/yaak_plugin_runtime/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "compilerOptions": { - "module": "node16", - "target": "es6", - "lib": ["es2021"], - "declaration": true, - "declarationDir": "./lib", - "outDir": "./lib", - "strict": true, - "types": ["node"] - }, - "files": [ - "index.ts" - ] -} diff --git a/src-tauri/yaak_templates/index.ts b/src-tauri/yaak_templates/index.ts index 1aaf1968..19d62fe9 100644 --- a/src-tauri/yaak_templates/index.ts +++ b/src-tauri/yaak_templates/index.ts @@ -1 +1,4 @@ export * from './bindings/parser'; +export type COOL = { + bar: string; +}; diff --git a/src-tauri/yaak_templates/package.json b/src-tauri/yaak_templates/package.json index 5d813043..4155c122 100644 --- a/src-tauri/yaak_templates/package.json +++ b/src-tauri/yaak_templates/package.json @@ -2,9 +2,5 @@ "name": "@yaakapp-internal/template", "private": true, "version": "1.0.0", - "main": "lib/index.js", - "typings": "./lib/index.d.ts", - "scripts": { - "build": "tsc" - } + "main": "index.ts" } diff --git a/src-tauri/yaak_templates/tsconfig.json b/src-tauri/yaak_templates/tsconfig.json deleted file mode 100644 index 3d1f6ca9..00000000 --- a/src-tauri/yaak_templates/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "compilerOptions": { - "module": "node16", - "target": "es6", - "lib": ["es2021"], - "declaration": true, - "declarationDir": "./lib", - "outDir": "./lib", - "strict": true, - "types": ["node"] - }, - "files": [ - "index.ts" - ] -} diff --git a/src-web/hooks/useParseTemplate.ts b/src-web/hooks/useParseTemplate.ts index 201cc5aa..fce83036 100644 --- a/src-web/hooks/useParseTemplate.ts +++ b/src-web/hooks/useParseTemplate.ts @@ -1,6 +1,6 @@ import { useQuery } from '@tanstack/react-query'; -import { invokeCmd } from '../lib/tauri'; import type { Tokens } from '@yaakapp-internal/template'; +import { invokeCmd } from '../lib/tauri'; export function useParseTemplate(template: string) { return useQuery({ diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..8d6ab483 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,31 @@ +{ + "compilerOptions": { + "target": "es2021", + "lib": [ + "DOM", + "DOM.Iterable", + "ESNext" + ], + "useDefineForClassFields": true, + "allowJs": false, + "skipLibCheck": true, + "esModuleInterop": false, + "allowSyntheticDefaultImports": true, + "strict": true, + "noUncheckedIndexedAccess": true, + "forceConsistentCasingInFileNames": true, + "module": "ESNext", + "moduleResolution": "Node", + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx" + }, + "include": [ + "." + ], + "exclude": [ + "vite.config.ts" + ], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/tsconfig.node.json b/tsconfig.node.json new file mode 100644 index 00000000..c87264aa --- /dev/null +++ b/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "module": "ESNext", + "moduleResolution": "Node", + "allowSyntheticDefaultImports": true, + "noUncheckedIndexedAccess": true + }, + "include": ["vite.config.ts"] +}