@niyamulahsan/create-deskapp 1.2.4 → 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 +16 -16
- 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 +181 -147
- 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,229 +1,231 @@
|
|
|
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
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return "deskapp-download.bin";
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return { ok:
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return { ok:
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return { ok:
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return { ok:
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return { ok:
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return { ok:
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
1
|
+
// ./src/modules/app/controllers/storage.controller.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* storage.controller.ts (app module) - real file operations, all native.
|
|
5
|
+
*
|
|
6
|
+
* Every handler uses the cross-platform native dialogs in
|
|
7
|
+
* src/window/dialogs.ts (Windows WinForms, macOS AppKit, Linux zenity/kdialog)
|
|
8
|
+
* to get a real disk path from the user, then operates on it with the storage
|
|
9
|
+
* facade. One API, native on every OS:
|
|
10
|
+
*
|
|
11
|
+
* open -> pickers.open + files.readBinaryFile + files.fileMeta (text preview)
|
|
12
|
+
* save -> pickers.save + files.writeTextFile (atomic)
|
|
13
|
+
* upload -> pickers.open + files.uploadFile into app private uploads
|
|
14
|
+
* download -> pickers.save + files.downloadFile (streamed + atomic)
|
|
15
|
+
* remove -> pickers.open + files.removePath (missing-safe)
|
|
16
|
+
* list -> pickers.folder + files.listFiles
|
|
17
|
+
*
|
|
18
|
+
* App-managed layer (private + tmp):
|
|
19
|
+
* appSave/appLoad -> storage.put/get on samples/state.json
|
|
20
|
+
* appList -> storage.files/directories
|
|
21
|
+
* appExport -> generateForDownload + consumeGenerated (tmp, read-once)
|
|
22
|
+
* appDelete -> storage.delete
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { files, pickers, storage } from "@/core/facade";
|
|
26
|
+
|
|
27
|
+
const TEXT_EXTS = new Set([
|
|
28
|
+
"txt",
|
|
29
|
+
"md",
|
|
30
|
+
"json",
|
|
31
|
+
"csv",
|
|
32
|
+
"ts",
|
|
33
|
+
"tsx",
|
|
34
|
+
"js",
|
|
35
|
+
"jsx",
|
|
36
|
+
"html",
|
|
37
|
+
"css",
|
|
38
|
+
"log",
|
|
39
|
+
"xml",
|
|
40
|
+
"yml",
|
|
41
|
+
"yaml",
|
|
42
|
+
"toml",
|
|
43
|
+
"ini",
|
|
44
|
+
"env",
|
|
45
|
+
"vue",
|
|
46
|
+
"sql",
|
|
47
|
+
"deno"
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
function isTextLike(path: string): boolean {
|
|
51
|
+
const ext = path.split(/[\\/]/).pop()?.split(".").pop()?.toLowerCase() ?? "";
|
|
52
|
+
return TEXT_EXTS.has(ext);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function nameFromUrl(input: string): string {
|
|
56
|
+
if (/^(https?|file):\/\//i.test(input)) {
|
|
57
|
+
try {
|
|
58
|
+
const name = decodeURIComponent(new URL(input).pathname.split("/").pop() || "");
|
|
59
|
+
return name || "deskapp-download.bin";
|
|
60
|
+
} catch {
|
|
61
|
+
return "deskapp-download.bin";
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return input.split(/[\\/]/).pop() || "deskapp-download.bin";
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Open any real file: native picker, then bytes + metadata (+ text preview). */
|
|
68
|
+
export const open = async (): Promise<Record<string, unknown>> => {
|
|
69
|
+
const path = await pickers.open({ title: "Open a file" });
|
|
70
|
+
if (!path) return { ok: false, error: "cancelled", action: "open" };
|
|
71
|
+
try {
|
|
72
|
+
const meta = await files.fileMeta(path);
|
|
73
|
+
if (!meta?.isFile) return { ok: false, action: "open", path, error: "not a file" };
|
|
74
|
+
const bytes = await files.readBinaryFile(path);
|
|
75
|
+
const preview = isTextLike(path) ? new TextDecoder().decode(bytes).slice(0, 2000) : null;
|
|
76
|
+
return {
|
|
77
|
+
ok: true,
|
|
78
|
+
action: "open",
|
|
79
|
+
path,
|
|
80
|
+
size: meta.size,
|
|
81
|
+
modifiedAt: meta.modifiedAt.toISOString(),
|
|
82
|
+
preview
|
|
83
|
+
};
|
|
84
|
+
} catch (error) {
|
|
85
|
+
return { ok: false, action: "open", path, error: String(error) };
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/** Save real content with a native Save As dialog (atomic write). */
|
|
90
|
+
export const save = async (): Promise<Record<string, unknown>> => {
|
|
91
|
+
const path = await pickers.save({
|
|
92
|
+
title: "Save file as",
|
|
93
|
+
defaultName: `deskapp-note-${Date.now()}.txt`,
|
|
94
|
+
filter: "Text files (*.txt)|*.txt|All files (*.*)|*.*"
|
|
95
|
+
});
|
|
96
|
+
if (!path) return { ok: false, error: "cancelled", action: "save" };
|
|
97
|
+
const content = `deskapp real save - ${new Date().toISOString()}\n`;
|
|
98
|
+
try {
|
|
99
|
+
await files.writeTextFile(path, content);
|
|
100
|
+
const meta = await files.fileMeta(path);
|
|
101
|
+
return { ok: true, action: "save", path, bytes: content.length, size: meta?.size ?? 0 };
|
|
102
|
+
} catch (error) {
|
|
103
|
+
return { ok: false, action: "save", path, error: String(error) };
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/** Upload (import) a real source file into the app's private store. */
|
|
108
|
+
export const upload = async (): Promise<Record<string, unknown>> => {
|
|
109
|
+
const source = await pickers.open({ title: "Choose a file to upload" });
|
|
110
|
+
if (!source) return { ok: false, error: "cancelled", action: "upload" };
|
|
111
|
+
try {
|
|
112
|
+
const destDir = storage.disk("private").path("uploads");
|
|
113
|
+
const dest = await files.uploadFile(source, destDir);
|
|
114
|
+
const meta = await files.fileMeta(source);
|
|
115
|
+
return { ok: true, action: "upload", source, dest, size: meta?.size ?? 0 };
|
|
116
|
+
} catch (error) {
|
|
117
|
+
return { ok: false, action: "upload", source, error: String(error) };
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/** Download a real URL to a real location chosen via Save As (atomic). */
|
|
122
|
+
export const download = async (url: string | undefined): Promise<Record<string, unknown>> => {
|
|
123
|
+
const clean = (url ?? "").trim();
|
|
124
|
+
if (!clean) return { ok: false, error: "enter a URL first", action: "download" };
|
|
125
|
+
const dest = await pickers.save({
|
|
126
|
+
title: "Save downloaded file as",
|
|
127
|
+
defaultName: nameFromUrl(clean)
|
|
128
|
+
});
|
|
129
|
+
if (!dest) return { ok: false, error: "cancelled", action: "download" };
|
|
130
|
+
try {
|
|
131
|
+
await files.downloadFile(clean, dest);
|
|
132
|
+
const meta = await files.fileMeta(dest);
|
|
133
|
+
return { ok: true, action: "download", url: clean, dest, size: meta?.size ?? 0 };
|
|
134
|
+
} catch (error) {
|
|
135
|
+
return { ok: false, action: "download", url: clean, dest, error: String(error) };
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/** Remove a real file (missing-safe). */
|
|
140
|
+
export const remove = async (): Promise<Record<string, unknown>> => {
|
|
141
|
+
const path = await pickers.open({ title: "Choose a file to remove" });
|
|
142
|
+
if (!path) return { ok: false, error: "cancelled", action: "remove" };
|
|
143
|
+
try {
|
|
144
|
+
await files.removePath(path);
|
|
145
|
+
return { ok: true, action: "remove", path, existsAfter: await files.pathExists(path) };
|
|
146
|
+
} catch (error) {
|
|
147
|
+
return { ok: false, action: "remove", path, error: String(error) };
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/** List the files inside a real folder chosen via the native picker. */
|
|
152
|
+
export const list = async (): Promise<Record<string, unknown>> => {
|
|
153
|
+
const path = await pickers.folder({ title: "Choose a folder to list" });
|
|
154
|
+
if (!path) return { ok: false, error: "cancelled", action: "list" };
|
|
155
|
+
try {
|
|
156
|
+
return { ok: true, action: "list", path, files: await files.listFiles(path) };
|
|
157
|
+
} catch (error) {
|
|
158
|
+
return { ok: false, action: "list", path, error: String(error) };
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
/* ---------------------------------------------------------------------------
|
|
163
|
+
* App-managed layer (private disk + tmp generated artifacts)
|
|
164
|
+
* ------------------------------------------------------------------------ */
|
|
165
|
+
|
|
166
|
+
const STATE_FILE = "samples/state.json";
|
|
167
|
+
|
|
168
|
+
/** Save app-owned state into the private disk (storage.put). */
|
|
169
|
+
export const appSave = async (): Promise<Record<string, unknown>> => {
|
|
170
|
+
const data = { theme: "dark", updatedAt: new Date().toISOString(), note: "app-managed private state" };
|
|
171
|
+
await storage.put(STATE_FILE, JSON.stringify(data, null, 2));
|
|
172
|
+
return { ok: true, action: "save (app state)", file: STATE_FILE, data };
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/** Read app-owned state back (storage.get). */
|
|
176
|
+
export const appLoad = async (): Promise<Record<string, unknown>> => {
|
|
177
|
+
try {
|
|
178
|
+
const raw = await storage.get(STATE_FILE);
|
|
179
|
+
return { ok: true, action: "read (app state)", file: STATE_FILE, content: new TextDecoder().decode(raw) || null };
|
|
180
|
+
} catch (error) {
|
|
181
|
+
return { ok: false, action: "read (app state)", file: STATE_FILE, error: String(error) };
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/** List the private disk contents (storage.files / storage.directories). */
|
|
186
|
+
export const appList = async (): Promise<Record<string, unknown>> => {
|
|
187
|
+
return {
|
|
188
|
+
ok: true,
|
|
189
|
+
action: "list (app state)",
|
|
190
|
+
disk: storage.disk("private").path("."),
|
|
191
|
+
files: await storage.files(),
|
|
192
|
+
directories: await storage.directories()
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
/** Generate an ephemeral export in tmp, then consume it read-once. */
|
|
197
|
+
export const appExport = async (): Promise<Record<string, unknown>> => {
|
|
198
|
+
const file = await storage.generateForDownload({
|
|
199
|
+
prefix: "report",
|
|
200
|
+
extension: "csv",
|
|
201
|
+
data: "name,value\nrows,2\n"
|
|
202
|
+
});
|
|
203
|
+
const bytes = await storage.consumeGenerated(file);
|
|
204
|
+
return {
|
|
205
|
+
ok: true,
|
|
206
|
+
action: "generate + consume (tmp)",
|
|
207
|
+
file,
|
|
208
|
+
content: new TextDecoder().decode(bytes).trim()
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/** Delete app-owned state from the private disk (storage.delete). */
|
|
213
|
+
export const appDelete = async (): Promise<Record<string, unknown>> => {
|
|
214
|
+
await storage.delete(STATE_FILE);
|
|
215
|
+
return { ok: true, action: "delete (app state)", file: STATE_FILE, existsAfter: await storage.exists(STATE_FILE) };
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
/** Handlers exposed to the frontend via the bindings registry. */
|
|
219
|
+
export const handlers = {
|
|
220
|
+
open,
|
|
221
|
+
save,
|
|
222
|
+
upload,
|
|
223
|
+
download,
|
|
224
|
+
remove,
|
|
225
|
+
list,
|
|
226
|
+
appSave,
|
|
227
|
+
appLoad,
|
|
228
|
+
appList,
|
|
229
|
+
appExport,
|
|
230
|
+
appDelete
|
|
231
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// ./src/modules/app/facade.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Public API for the app module.
|
|
5
|
+
*
|
|
6
|
+
* The sample module ships five controllers and no model. Each controller is
|
|
7
|
+
* re-exported under its own namespace, so other modules can call it without
|
|
8
|
+
* reaching into `controllers/` directly:
|
|
9
|
+
*
|
|
10
|
+
* import { app } from "@/modules/app/facade";
|
|
11
|
+
* const rows = app.demo.table({ page: 1 });
|
|
12
|
+
*
|
|
13
|
+
* Rules: a module never imports its own facade; a facade never imports another
|
|
14
|
+
* facade.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export * as demo from "./controllers/demo.controller";
|
|
18
|
+
export * as net from "./controllers/net.controller";
|
|
19
|
+
export * as playwright from "./controllers/playwright.controller";
|
|
20
|
+
export * as storage from "./controllers/storage.controller";
|
|
21
|
+
export * as window from "./controllers/window.controller";
|
package/template/src/preload.ts
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
|
+
// ./src/preload.ts
|
|
2
|
+
|
|
1
3
|
import { contextBridge, ipcRenderer } from "electron";
|
|
4
|
+
import { isBindingErrorEnvelope } from "@/core/api/binding-error";
|
|
2
5
|
|
|
3
6
|
type BindingFn = (...args: unknown[]) => Promise<unknown>;
|
|
4
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Turn a resolved error envelope (see `@/core/api/binding-error`) back into a
|
|
10
|
+
* rejection, so `try/catch` keeps working and `gum` can read `err.response.data`.
|
|
11
|
+
*/
|
|
12
|
+
function unwrapBindingResult(result: unknown): unknown {
|
|
13
|
+
if (isBindingErrorEnvelope(result)) {
|
|
14
|
+
const error = new Error(
|
|
15
|
+
typeof result.message === "string" ? result.message : "Binding failed"
|
|
16
|
+
) as Error & { response?: { status?: number; data: unknown } };
|
|
17
|
+
error.response = {
|
|
18
|
+
status: typeof result.status === "number" ? result.status : undefined,
|
|
19
|
+
data: result
|
|
20
|
+
};
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
|
|
5
26
|
function setNested(root: Record<string, any>, path: string, fn: BindingFn) {
|
|
6
27
|
const parts = path.split(".");
|
|
7
28
|
let cur = root;
|
|
@@ -19,12 +40,14 @@ try {
|
|
|
19
40
|
const names = ipcRenderer.sendSync("deskapp:__list__") as string[];
|
|
20
41
|
const api: Record<string, any> = {};
|
|
21
42
|
for (const name of names) {
|
|
22
|
-
const fn: BindingFn = (...args: unknown[]) =>
|
|
43
|
+
const fn: BindingFn = async (...args: unknown[]) =>
|
|
44
|
+
unwrapBindingResult(await ipcRenderer.invoke(`deskapp:${name}`, ...args));
|
|
23
45
|
api[name] = fn; // flat, backward-compatible
|
|
24
46
|
setNested(api, name, fn); // nested short form
|
|
25
47
|
}
|
|
26
48
|
// Fallback invoker for any name not in the static list.
|
|
27
|
-
api.__invoke = (name: string, ...args: unknown[]) =>
|
|
49
|
+
api.__invoke = (name: string, ...args: unknown[]) =>
|
|
50
|
+
ipcRenderer.invoke(`deskapp:${name}`, ...args).then(unwrapBindingResult);
|
|
28
51
|
|
|
29
52
|
// `md` = module calls (short alias). `bindings` kept for compatibility.
|
|
30
53
|
contextBridge.exposeInMainWorld("md", api);
|
|
@@ -1,23 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import "
|
|
9
|
-
import "
|
|
10
|
-
import "
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
favicon
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
// ./src/ui/src/app.ts
|
|
2
|
+
|
|
3
|
+
import { createHead } from "@unhead/vue/client";
|
|
4
|
+
import { createPinia } from "pinia";
|
|
5
|
+
import { createApp } from "vue";
|
|
6
|
+
import App from "@/ui/App.vue";
|
|
7
|
+
import faviconUrl from "@/ui/assets/images/favicon/favicon.ico";
|
|
8
|
+
import { GumPlugin } from "@/ui/plugins/gum.ts";
|
|
9
|
+
import { PulsePlugin, pulse } from "@/ui/plugins/pulse.ts";
|
|
10
|
+
import router from "@/ui/router/index.ts";
|
|
11
|
+
|
|
12
|
+
import "bootstrap/dist/css/bootstrap.min.css";
|
|
13
|
+
import "bootstrap-icons/font/bootstrap-icons.css";
|
|
14
|
+
import "@/ui/assets/scss/custom.scss";
|
|
15
|
+
import "bootstrap/dist/js/bootstrap.bundle.min.js";
|
|
16
|
+
|
|
17
|
+
let favicon = document.querySelector<HTMLLinkElement>('link[rel="icon"]');
|
|
18
|
+
if (!favicon) {
|
|
19
|
+
favicon = document.createElement("link");
|
|
20
|
+
favicon.rel = "icon";
|
|
21
|
+
document.head.appendChild(favicon);
|
|
22
|
+
}
|
|
23
|
+
favicon.href = faviconUrl;
|
|
24
|
+
|
|
25
|
+
export { pulse };
|
|
26
|
+
|
|
27
|
+
const app = createApp(App);
|
|
28
|
+
const pinia = createPinia();
|
|
29
|
+
const head = createHead({
|
|
30
|
+
init: [{ titleTemplate: (title) => (title ? `${title} | deskapp` : "deskapp") }]
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
app.use(pinia);
|
|
34
|
+
app.use(router);
|
|
35
|
+
app.use(head);
|
|
36
|
+
app.use(GumPlugin);
|
|
37
|
+
app.use(PulsePlugin);
|
|
38
|
+
app.mount("#app");
|