@niyamulahsan/create-deskapp 1.2.5 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/template/.env.example +20 -13
- package/template/AGENTS.md +699 -0
- package/template/package.json +3 -0
- package/template/src/config/app.ts +26 -24
- package/template/src/config/winsetup.ts +93 -91
- package/template/src/core/api/binding-error.ts +57 -0
- package/template/src/core/api/bindings.generated.ts +2 -0
- package/template/src/core/api/generate.manifest.ts +84 -80
- package/template/src/core/api/registry.ts +58 -48
- package/template/src/core/config.ts +101 -99
- package/template/src/core/database/aggregate.ts +89 -85
- package/template/src/core/database/config.ts +50 -48
- package/template/src/core/database/connection.ts +116 -114
- package/template/src/core/database/migrate-hooks.ts +86 -84
- package/template/src/core/database/paginate.ts +226 -224
- package/template/src/core/database/reset.ts +21 -19
- package/template/src/core/database/seed.ts +169 -167
- package/template/src/core/database/status.ts +37 -35
- package/template/src/core/env.ts +108 -106
- package/template/src/core/facade.ts +63 -61
- package/template/src/core/maker/db/fresh.ts +10 -8
- package/template/src/core/maker/db/generate.ts +13 -11
- package/template/src/core/maker/db/helpers.ts +92 -96
- package/template/src/core/maker/db/migrate.ts +37 -35
- package/template/src/core/maker/db/mod.ts +93 -91
- package/template/src/core/maker/db/module-migrate.ts +56 -54
- package/template/src/core/maker/db/push.ts +23 -21
- package/template/src/core/maker/db/reset.ts +8 -6
- package/template/src/core/maker/db/seed.ts +9 -7
- package/template/src/core/maker/db/status.ts +8 -6
- package/template/src/core/maker/help.ts +59 -57
- package/template/src/core/maker/make/controller.ts +25 -22
- package/template/src/core/maker/make/helpers.ts +97 -91
- package/template/src/core/maker/make/mod.ts +69 -67
- package/template/src/core/maker/make/model.ts +16 -14
- package/template/src/core/maker/make/module.ts +53 -39
- package/template/src/core/maker/make/seeder.ts +23 -21
- package/template/src/core/maker/make/test.ts +33 -30
- package/template/src/core/maker/mod.ts +85 -83
- package/template/src/core/maker/run/mod.ts +134 -132
- package/template/src/core/maker/stub.ts +26 -24
- package/template/src/core/maker/stubs/controller/controller.controller.stub +57 -55
- package/template/src/core/maker/stubs/controller/controller.schema.stub +18 -13
- package/template/src/core/maker/stubs/facade/facade.stub +21 -0
- package/template/src/core/maker/stubs/model/model.stub +10 -8
- package/template/src/core/maker/stubs/seeder/seeder.stub +18 -16
- package/template/src/core/maker/stubs/test/test.stub +9 -7
- package/template/src/core/maker/sync-config.ts +93 -94
- package/template/src/core/utils/password.ts +29 -27
- package/template/src/core/utils/playwright.ts +123 -121
- package/template/src/core/utils/queue.ts +68 -66
- package/template/src/core/utils/scheduler.ts +62 -60
- package/template/src/core/utils/storage.ts +3 -1
- package/template/src/core/utils/validation.ts +37 -35
- package/template/src/database/schema.ts +2 -0
- package/template/src/main.ts +120 -118
- package/template/src/modules/app/__tests__/demo.controller.test.ts +75 -0
- package/template/src/modules/app/__tests__/net.controller.test.ts +65 -0
- package/template/src/modules/app/__tests__/playwright.controller.test.ts +50 -0
- package/template/src/modules/app/__tests__/storage.controller.test.ts +114 -0
- package/template/src/modules/app/__tests__/window.controller.test.ts +98 -0
- package/template/src/modules/app/controllers/demo.controller.ts +120 -118
- package/template/src/modules/app/controllers/net.controller.ts +50 -48
- package/template/src/modules/app/controllers/playwright.controller.ts +142 -140
- package/template/src/modules/app/controllers/storage.controller.ts +231 -229
- package/template/src/modules/app/controllers/window.controller.ts +2 -0
- package/template/src/modules/app/facade.ts +21 -0
- package/template/src/preload.ts +25 -2
- package/template/src/ui/src/App.vue +4 -2
- package/template/src/ui/src/app.ts +38 -23
- package/template/src/ui/src/bindings.d.ts +18 -16
- package/template/src/ui/src/components/Button.vue +34 -32
- package/template/src/ui/src/components/Checkbox.vue +26 -29
- package/template/src/ui/src/components/Input.vue +221 -227
- package/template/src/ui/src/components/InputGroup.vue +141 -0
- package/template/src/ui/src/components/InputPasswordToggle.vue +204 -0
- package/template/src/ui/src/components/Modal.vue +65 -55
- package/template/src/ui/src/components/Spinner.vue +44 -42
- package/template/src/ui/src/components/Switch.vue +62 -65
- package/template/src/ui/src/components/TextArea.vue +108 -121
- package/template/src/ui/src/components/Toast.vue +55 -56
- package/template/src/ui/src/components/datatable/DataTableSkeleton.vue +100 -98
- package/template/src/ui/src/components/datatable/Pagination.vue +153 -125
- package/template/src/ui/src/components/datatable/SelectOpption.vue +36 -35
- package/template/src/ui/src/components/datatable/index.vue +336 -258
- package/template/src/ui/src/env.d.ts +16 -13
- package/template/src/ui/src/global.d.ts +21 -2
- package/template/src/ui/src/helpers/nformatter.ts +12 -10
- package/template/src/ui/src/pages/dashboard/index.vue +690 -687
- package/template/src/ui/src/plugins/browserDetect.ts +57 -0
- package/template/src/ui/src/plugins/gum.ts +576 -549
- package/template/src/ui/src/plugins/pulse.ts +2 -0
- package/template/src/ui/src/plugins/routeProgress.ts +89 -0
- package/template/src/ui/src/router/index.ts +44 -25
- package/template/src/ui/src/stores/example.ts +2 -0
- package/template/src/ui/vite.config.ts +40 -38
- package/template/src/window/app-menu.ts +89 -87
- package/template/src/window/config.ts +14 -12
- package/template/src/window/context-menu.ts +23 -21
- package/template/src/window/dialogs.ts +92 -90
- package/template/src/window/manager.ts +2 -0
- package/template/src/window/native.ts +47 -45
- package/template/src/window/tray.ts +132 -130
|
@@ -1,94 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
pkg
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
pkg.
|
|
33
|
-
|
|
34
|
-
pkg.build
|
|
35
|
-
|
|
36
|
-
pkg.build.
|
|
37
|
-
|
|
38
|
-
pkg.build.nsis
|
|
39
|
-
pkg.build.nsis.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
pkg.build.protocols
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
` RMDir /r "$LOCALAPPDATA\\${f}"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
";
|
|
62
|
-
"
|
|
63
|
-
"",
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
main();
|
|
1
|
+
// ./src/core/maker/sync-config.ts
|
|
2
|
+
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { appConfig } from "@config/app";
|
|
7
|
+
|
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const root = path.resolve(__dirname, "..", "..", "..");
|
|
10
|
+
|
|
11
|
+
function readJson<T = any>(p: string): T {
|
|
12
|
+
return JSON.parse(fs.readFileSync(p, "utf-8")) as T;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function writeIfChanged(file: string, content: string): boolean {
|
|
16
|
+
const prev = fs.existsSync(file) ? fs.readFileSync(file, "utf-8") : "";
|
|
17
|
+
if (prev === content) {
|
|
18
|
+
console.log(`[config:sync] unchanged ${path.relative(root, file)}`);
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
22
|
+
fs.writeFileSync(file, content, "utf-8");
|
|
23
|
+
console.log(`[config:sync] updated ${path.relative(root, file)}`);
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function syncPackageJson(): boolean {
|
|
28
|
+
const pkgPath = path.join(root, "package.json");
|
|
29
|
+
const pkg = readJson<any>(pkgPath);
|
|
30
|
+
|
|
31
|
+
pkg.name = appConfig.name;
|
|
32
|
+
pkg.description = appConfig.description;
|
|
33
|
+
|
|
34
|
+
pkg.build = pkg.build ?? {};
|
|
35
|
+
pkg.build.appId = appConfig.appId;
|
|
36
|
+
pkg.build.productName = appConfig.productName;
|
|
37
|
+
|
|
38
|
+
pkg.build.nsis = pkg.build.nsis ?? {};
|
|
39
|
+
pkg.build.nsis.shortcutName = appConfig.productName;
|
|
40
|
+
pkg.build.nsis.uninstallDisplayName = appConfig.productName;
|
|
41
|
+
pkg.build.nsis.include = "scripts/installer.nsh";
|
|
42
|
+
|
|
43
|
+
// Keep protocols in sync if present; create a minimal one if missing.
|
|
44
|
+
const scheme = appConfig.protocol;
|
|
45
|
+
if (Array.isArray(pkg.build.protocols) && pkg.build.protocols.length > 0) {
|
|
46
|
+
pkg.build.protocols[0].name = appConfig.productName;
|
|
47
|
+
pkg.build.protocols[0].schemes = [scheme];
|
|
48
|
+
} else {
|
|
49
|
+
pkg.build.protocols = [{ name: appConfig.productName, schemes: [scheme] }];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return writeIfChanged(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function renderInstallerNsh(): string {
|
|
56
|
+
const product = appConfig.productName;
|
|
57
|
+
const folders = Array.from(new Set(appConfig.uninstallDataFolders.filter(Boolean)));
|
|
58
|
+
const rmLines = folders.flatMap((f) => [` RMDir /r "$APPDATA\\${f}"`, ` RMDir /r "$LOCALAPPDATA\\${f}"`]);
|
|
59
|
+
return [
|
|
60
|
+
"; Custom NSIS include for electron-builder (generated from src/config/app.ts via config:sync)",
|
|
61
|
+
"; Adds an uninstall choice: full uninstall (remove user data) or just uninstall (keep user data).",
|
|
62
|
+
"",
|
|
63
|
+
"!macro customUnInstall",
|
|
64
|
+
` MessageBox MB_YESNO|MB_ICONQUESTION "Do you want to completely remove all ${product} data and settings as well?$\\r$\\n$\\r$\\nYes = Full uninstall (remove app data)$\\r$\\nNo = Just uninstall (keep your data/settings)" /SD IDNO IDNO keepData`,
|
|
65
|
+
" ; Full uninstall: remove Electron user data and common app data locations",
|
|
66
|
+
...rmLines,
|
|
67
|
+
" keepData:",
|
|
68
|
+
"!macroend",
|
|
69
|
+
""
|
|
70
|
+
].join("\n");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function syncInstaller(): boolean {
|
|
74
|
+
const out = path.join(root, "scripts", "installer.nsh");
|
|
75
|
+
return writeIfChanged(out, renderInstallerNsh());
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function syncUiTitle(): boolean {
|
|
79
|
+
const file = path.join(root, "src", "ui", "index.html");
|
|
80
|
+
if (!fs.existsSync(file)) return false;
|
|
81
|
+
const prev = fs.readFileSync(file, "utf-8");
|
|
82
|
+
const next = prev.replace(/<title>[^<]*<\/title>/i, `<title>${appConfig.productName}</title>`);
|
|
83
|
+
return writeIfChanged(file, next);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function main() {
|
|
87
|
+
const a = syncPackageJson();
|
|
88
|
+
const b = syncInstaller();
|
|
89
|
+
const c = syncUiTitle();
|
|
90
|
+
if (!a && !b && !c) console.log("[config:sync] everything up to date");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
main();
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
// ./src/core/utils/password.ts
|
|
2
|
+
|
|
3
|
+
import bcrypt from "bcryptjs";
|
|
4
|
+
|
|
5
|
+
/** Number of bcrypt salt rounds. Higher is slower but more secure. */
|
|
6
|
+
const SALT_ROUNDS = 10;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Password hashing + verification, grouped under one namespace.
|
|
10
|
+
*
|
|
11
|
+
* Consumers import this from the facade:
|
|
12
|
+
* import { pass } from "@/core/facade.ts";
|
|
13
|
+
* await pass.hashPassword("secret");
|
|
14
|
+
*/
|
|
15
|
+
export const pass = {
|
|
16
|
+
/**
|
|
17
|
+
* Hash a plaintext password using bcrypt.
|
|
18
|
+
*/
|
|
19
|
+
hashPassword(password: string): Promise<string> {
|
|
20
|
+
return bcrypt.hash(password, SALT_ROUNDS);
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Check a plaintext password against a stored bcrypt hash.
|
|
25
|
+
*/
|
|
26
|
+
verifyPassword(password: string, hash: string): Promise<boolean> {
|
|
27
|
+
return bcrypt.compare(password, hash);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
@@ -1,121 +1,123 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (!
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
1
|
+
// ./src/core/utils/playwright.ts
|
|
2
|
+
|
|
3
|
+
import { execSync } from "node:child_process";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
import { dirname, join } from "node:path";
|
|
7
|
+
import { app } from "electron";
|
|
8
|
+
|
|
9
|
+
function getRequire(): NodeRequire {
|
|
10
|
+
// CJS bundles/runtime have `require`; ESM can derive it when needed.
|
|
11
|
+
if (typeof require !== "undefined") return require as unknown as NodeRequire;
|
|
12
|
+
// Fallback for ESM contexts (not used in the CJS bundle).
|
|
13
|
+
const url = typeof __filename !== "undefined" ? __filename : process.cwd();
|
|
14
|
+
return createRequire(url);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const chromium = {
|
|
18
|
+
exists(path: string): boolean {
|
|
19
|
+
return existsPath(path);
|
|
20
|
+
},
|
|
21
|
+
candidates(overrides?: { env?: string | null; execPath?: string; cwd?: string }): string[] {
|
|
22
|
+
return chromiumCandidates(overrides);
|
|
23
|
+
},
|
|
24
|
+
resolve(overrides?: { env?: string | null; execPath?: string; cwd?: string }): string | undefined {
|
|
25
|
+
return resolveChromium(overrides);
|
|
26
|
+
},
|
|
27
|
+
extensions(overrides?: { execPath?: string; cwd?: string }): string[] {
|
|
28
|
+
return extensionsCandidates(overrides);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export function existsPath(path: string): boolean {
|
|
33
|
+
try {
|
|
34
|
+
fs.statSync(path);
|
|
35
|
+
return true;
|
|
36
|
+
} catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function platformRelPaths(): string[][] {
|
|
42
|
+
if (process.platform === "win32") {
|
|
43
|
+
return [
|
|
44
|
+
["chrome-win64", "chrome.exe"],
|
|
45
|
+
["chrome-win", "chrome.exe"]
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
if (process.platform === "linux") {
|
|
49
|
+
return [["chrome-linux", "chrome"]];
|
|
50
|
+
}
|
|
51
|
+
if (process.platform === "darwin") {
|
|
52
|
+
const app = ["Google Chrome for Testing.app", "Contents", "MacOS", "Google Chrome for Testing"];
|
|
53
|
+
return [
|
|
54
|
+
["chrome-mac-arm64", ...app],
|
|
55
|
+
["chrome-mac", ...app]
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function chromiumCandidates(overrides?: { env?: string | null; execPath?: string; cwd?: string }): string[] {
|
|
62
|
+
const out: string[] = [];
|
|
63
|
+
const env = overrides?.env === undefined ? process.env.DESKAPP_CHROMIUM : overrides.env;
|
|
64
|
+
if (env) out.push(env);
|
|
65
|
+
|
|
66
|
+
const bases = [dirname(overrides?.execPath ?? app.getPath("exe")), overrides?.cwd ?? process.cwd()];
|
|
67
|
+
|
|
68
|
+
for (const base of bases) {
|
|
69
|
+
for (const rel of platformRelPaths()) {
|
|
70
|
+
out.push(join(base, "chromium", ...rel));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function resolveChromium(overrides?: { env?: string | null; execPath?: string; cwd?: string }): string | undefined {
|
|
77
|
+
return chromiumCandidates(overrides).find(existsPath);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function extensionsCandidates(overrides?: { execPath?: string; cwd?: string }): string[] {
|
|
81
|
+
const out: string[] = [];
|
|
82
|
+
const bases = [dirname(overrides?.execPath ?? app.getPath("exe")), overrides?.cwd ?? process.cwd()];
|
|
83
|
+
|
|
84
|
+
for (const base of bases) {
|
|
85
|
+
for (const rel of ["extensions", join("src", "extensions")]) {
|
|
86
|
+
const root = join(base, rel);
|
|
87
|
+
try {
|
|
88
|
+
for (const entry of fs.readdirSync(root, { withFileTypes: true })) {
|
|
89
|
+
if (!entry.isDirectory()) continue;
|
|
90
|
+
const full = join(root, entry.name);
|
|
91
|
+
if (!out.includes(full)) out.push(full);
|
|
92
|
+
}
|
|
93
|
+
} catch {
|
|
94
|
+
// no extensions folder at this base - skip
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function resolveExtensions(overrides?: { execPath?: string; cwd?: string }): string[] {
|
|
102
|
+
return extensionsCandidates(overrides);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export async function ensurePlaywrightBrowser(browser = "chromium"): Promise<void> {
|
|
106
|
+
try {
|
|
107
|
+
// In Node, resolve playwright's CLI if installed.
|
|
108
|
+
const req = getRequire();
|
|
109
|
+
const playwrightPkg = req.resolve("playwright/package.json");
|
|
110
|
+
const cliFile = join(dirname(playwrightPkg), "cli.js");
|
|
111
|
+
|
|
112
|
+
if (!existsPath(cliFile)) {
|
|
113
|
+
throw new Error(`playwright CLI not found at ${cliFile}; install the browser manually with 'npx playwright install ${browser}'.`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// In Electron, process.execPath is the Electron binary, not Node.
|
|
117
|
+
// We use the system's Node execution to run the playwright CLI.
|
|
118
|
+
execSync(`node "${cliFile}" install ${browser}`, { stdio: "inherit" });
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error("[playwright] Failed to ensure browser:", error);
|
|
121
|
+
throw new Error(`playwright install ${browser} failed; retry with 'npx playwright install ${browser}'.`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -1,66 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
entry
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
1
|
+
// ./src/core/utils/queue.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* queue.ts - reusable in-process async queue.
|
|
5
|
+
*
|
|
6
|
+
* Bounded concurrency; `add(task)` resolves with the task's own result and
|
|
7
|
+
* rejects only that caller when the task throws (other tasks unaffected).
|
|
8
|
+
* Import via the facade: `import { queue } from "@/core/facade.ts"`.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export type QueueTask<T> = () => Promise<T>;
|
|
12
|
+
|
|
13
|
+
interface Pending<T> {
|
|
14
|
+
task: QueueTask<T>;
|
|
15
|
+
resolve: (value: T) => void;
|
|
16
|
+
reject: (reason?: unknown) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface Queue<T> {
|
|
20
|
+
add(task: QueueTask<T>): Promise<T>;
|
|
21
|
+
readonly size: number;
|
|
22
|
+
readonly running: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Queue namespace - create bounded-concurrency async queues through the
|
|
27
|
+
* facade: `const q = queue.create({ concurrency: 3 })`.
|
|
28
|
+
*/
|
|
29
|
+
export const queue = {
|
|
30
|
+
create<T>(options?: { concurrency?: number }): Queue<T> {
|
|
31
|
+
return createQueue<T>(options);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function createQueue<T>(options?: { concurrency?: number }): Queue<T> {
|
|
36
|
+
const concurrency = Math.max(1, options?.concurrency ?? 1);
|
|
37
|
+
const pending: Pending<T>[] = [];
|
|
38
|
+
let running = 0;
|
|
39
|
+
|
|
40
|
+
const tick = (): void => {
|
|
41
|
+
while (running < concurrency && pending.length > 0) {
|
|
42
|
+
const entry = pending.shift()!;
|
|
43
|
+
running += 1;
|
|
44
|
+
entry
|
|
45
|
+
.task()
|
|
46
|
+
.then(entry.resolve, entry.reject)
|
|
47
|
+
.finally(() => {
|
|
48
|
+
running -= 1;
|
|
49
|
+
tick();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
add(task: QueueTask<T>): Promise<T> {
|
|
56
|
+
return new Promise<T>((resolve, reject) => {
|
|
57
|
+
pending.push({ task, resolve, reject });
|
|
58
|
+
tick();
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
get size() {
|
|
62
|
+
return pending.length;
|
|
63
|
+
},
|
|
64
|
+
get running() {
|
|
65
|
+
return running;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|