@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,140 +1,142 @@
|
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
const
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
await
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
await
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
1
|
+
// ./src/modules/app/controllers/playwright.controller.ts
|
|
2
|
+
|
|
3
|
+
import { mkdtemp } from "node:fs/promises";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { basename, join } from "node:path";
|
|
6
|
+
import { chromium as chromiumApi } from "@/core/facade";
|
|
7
|
+
import { ensurePlaywrightBrowser, existsPath } from "@/core/utils/playwright";
|
|
8
|
+
|
|
9
|
+
const PW_SPEC = "playwright";
|
|
10
|
+
const NEED_PLAYWRIGHT = '"playwright" is not installed. Run "npm install playwright".';
|
|
11
|
+
|
|
12
|
+
interface PlaywrightPage {
|
|
13
|
+
goto(url: string, options?: Record<string, unknown>): Promise<unknown>;
|
|
14
|
+
title(): Promise<string>;
|
|
15
|
+
}
|
|
16
|
+
interface PlaywrightBrowser {
|
|
17
|
+
newPage(): Promise<PlaywrightPage>;
|
|
18
|
+
pages(): Promise<PlaywrightPage[]>;
|
|
19
|
+
close(): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
interface PlaywrightChromium {
|
|
22
|
+
executablePath(): string;
|
|
23
|
+
launch(options?: Record<string, unknown>): Promise<PlaywrightBrowser>;
|
|
24
|
+
launchPersistentContext(userDataDir: string, options: Record<string, unknown>): Promise<PlaywrightBrowser>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function loadChromium(): Promise<PlaywrightChromium> {
|
|
28
|
+
try {
|
|
29
|
+
const mod = (await import(PW_SPEC)) as { chromium?: PlaywrightChromium };
|
|
30
|
+
if (!mod.chromium) throw new Error(NEED_PLAYWRIGHT);
|
|
31
|
+
return mod.chromium;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
throw new Error(`${String(error)} - ${NEED_PLAYWRIGHT}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const EXAMPLE = "https://example.com";
|
|
38
|
+
const DEFAULT_SECONDS = 5;
|
|
39
|
+
|
|
40
|
+
function extensionArgs(extensions: string[]): string[] {
|
|
41
|
+
return [`--disable-extensions-except=${extensions.join(",")}`, ...extensions.map((e) => `--load-extension=${e}`)];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const play = async (opts?: {
|
|
45
|
+
url?: string;
|
|
46
|
+
seconds?: number;
|
|
47
|
+
headless?: boolean;
|
|
48
|
+
extensions?: string[];
|
|
49
|
+
}): Promise<Record<string, unknown>> => {
|
|
50
|
+
const url = opts?.url?.trim() || EXAMPLE;
|
|
51
|
+
const seconds = Math.min(Math.max(opts?.seconds ?? DEFAULT_SECONDS, 1), 60);
|
|
52
|
+
const started = Date.now();
|
|
53
|
+
|
|
54
|
+
let chromium: PlaywrightChromium;
|
|
55
|
+
try {
|
|
56
|
+
chromium = await loadChromium();
|
|
57
|
+
} catch (error) {
|
|
58
|
+
return { ok: false, url, chromium: "n/a", error: String(error) };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const chromiumPath = chromiumApi.resolve();
|
|
62
|
+
const extensionsInput = opts?.extensions && opts.extensions.length > 0 ? opts.extensions : chromiumApi.extensions();
|
|
63
|
+
const extensions = extensionsInput.filter(chromiumApi.exists);
|
|
64
|
+
const headless = (opts?.headless ?? false) && extensions.length === 0;
|
|
65
|
+
|
|
66
|
+
if (!chromiumPath) {
|
|
67
|
+
const registry = chromium.executablePath();
|
|
68
|
+
if (registry && !existsPath(registry)) {
|
|
69
|
+
try {
|
|
70
|
+
await ensurePlaywrightBrowser("chromium");
|
|
71
|
+
} catch (error) {
|
|
72
|
+
const msg = String(error);
|
|
73
|
+
return {
|
|
74
|
+
ok: false,
|
|
75
|
+
url,
|
|
76
|
+
chromium: "playwright-registry",
|
|
77
|
+
error: msg,
|
|
78
|
+
hint:
|
|
79
|
+
process.platform === "win32" && /spawn|Invalid handle/i.test(msg)
|
|
80
|
+
? "Windows blocked the browser. Run 'npx playwright install chromium' in your terminal."
|
|
81
|
+
: "Run in your terminal: npx playwright install chromium"
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
let browser: unknown;
|
|
88
|
+
try {
|
|
89
|
+
if (extensions.length > 0) {
|
|
90
|
+
// Create a temp dir using Node's os module
|
|
91
|
+
const profile = await mkdtemp(join(tmpdir(), "deskapp-ext-"));
|
|
92
|
+
const context = await chromium.launchPersistentContext(profile, {
|
|
93
|
+
headless: false,
|
|
94
|
+
executablePath: chromiumPath,
|
|
95
|
+
args: extensionArgs(extensions)
|
|
96
|
+
});
|
|
97
|
+
browser = context;
|
|
98
|
+
const page = context.pages()[0] ?? (await context.newPage());
|
|
99
|
+
await page.goto(url, { waitUntil: "domcontentloaded" });
|
|
100
|
+
const title = await page.title();
|
|
101
|
+
await new Promise((resolve) => setTimeout(resolve, seconds * 1000));
|
|
102
|
+
return {
|
|
103
|
+
ok: true,
|
|
104
|
+
url,
|
|
105
|
+
title,
|
|
106
|
+
seconds,
|
|
107
|
+
headless: false,
|
|
108
|
+
chromium: chromiumPath ?? "playwright-registry",
|
|
109
|
+
extensions: extensions.map((e) => basename(e)),
|
|
110
|
+
durationMs: Date.now() - started,
|
|
111
|
+
closed: true
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const launchBrowser = chromiumPath
|
|
116
|
+
? await chromium.launch({ headless, executablePath: chromiumPath })
|
|
117
|
+
: await chromium.launch({ headless });
|
|
118
|
+
browser = launchBrowser;
|
|
119
|
+
const page = await launchBrowser.newPage();
|
|
120
|
+
await page.goto(url, { waitUntil: "domcontentloaded" });
|
|
121
|
+
const title = await page.title();
|
|
122
|
+
await new Promise((resolve) => setTimeout(resolve, seconds * 1000));
|
|
123
|
+
return {
|
|
124
|
+
ok: true,
|
|
125
|
+
url,
|
|
126
|
+
title,
|
|
127
|
+
seconds,
|
|
128
|
+
headless,
|
|
129
|
+
chromium: chromiumPath ?? "playwright-registry",
|
|
130
|
+
extensions: [],
|
|
131
|
+
durationMs: Date.now() - started,
|
|
132
|
+
closed: true
|
|
133
|
+
};
|
|
134
|
+
} catch (error) {
|
|
135
|
+
return { ok: false, url, chromium: chromiumPath ?? "playwright-registry", error: String(error) };
|
|
136
|
+
} finally {
|
|
137
|
+
const b = browser as { close?: () => Promise<void> } | undefined;
|
|
138
|
+
await b?.close();
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const handlers = { play };
|