@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.
Files changed (104) hide show
  1. package/package.json +16 -16
  2. package/template/.env.example +20 -13
  3. package/template/AGENTS.md +699 -0
  4. package/template/package.json +3 -0
  5. package/template/src/config/app.ts +26 -24
  6. package/template/src/config/winsetup.ts +93 -91
  7. package/template/src/core/api/binding-error.ts +57 -0
  8. package/template/src/core/api/bindings.generated.ts +2 -0
  9. package/template/src/core/api/generate.manifest.ts +84 -80
  10. package/template/src/core/api/registry.ts +58 -48
  11. package/template/src/core/config.ts +101 -99
  12. package/template/src/core/database/aggregate.ts +89 -85
  13. package/template/src/core/database/config.ts +50 -48
  14. package/template/src/core/database/connection.ts +116 -114
  15. package/template/src/core/database/migrate-hooks.ts +86 -84
  16. package/template/src/core/database/paginate.ts +226 -224
  17. package/template/src/core/database/reset.ts +21 -19
  18. package/template/src/core/database/seed.ts +169 -167
  19. package/template/src/core/database/status.ts +37 -35
  20. package/template/src/core/env.ts +108 -106
  21. package/template/src/core/facade.ts +63 -61
  22. package/template/src/core/maker/db/fresh.ts +10 -8
  23. package/template/src/core/maker/db/generate.ts +13 -11
  24. package/template/src/core/maker/db/helpers.ts +92 -96
  25. package/template/src/core/maker/db/migrate.ts +37 -35
  26. package/template/src/core/maker/db/mod.ts +93 -91
  27. package/template/src/core/maker/db/module-migrate.ts +56 -54
  28. package/template/src/core/maker/db/push.ts +23 -21
  29. package/template/src/core/maker/db/reset.ts +8 -6
  30. package/template/src/core/maker/db/seed.ts +9 -7
  31. package/template/src/core/maker/db/status.ts +8 -6
  32. package/template/src/core/maker/help.ts +59 -57
  33. package/template/src/core/maker/make/controller.ts +25 -22
  34. package/template/src/core/maker/make/helpers.ts +97 -91
  35. package/template/src/core/maker/make/mod.ts +69 -67
  36. package/template/src/core/maker/make/model.ts +16 -14
  37. package/template/src/core/maker/make/module.ts +53 -39
  38. package/template/src/core/maker/make/seeder.ts +23 -21
  39. package/template/src/core/maker/make/test.ts +33 -30
  40. package/template/src/core/maker/mod.ts +85 -83
  41. package/template/src/core/maker/run/mod.ts +134 -132
  42. package/template/src/core/maker/stub.ts +26 -24
  43. package/template/src/core/maker/stubs/controller/controller.controller.stub +57 -55
  44. package/template/src/core/maker/stubs/controller/controller.schema.stub +18 -13
  45. package/template/src/core/maker/stubs/facade/facade.stub +21 -0
  46. package/template/src/core/maker/stubs/model/model.stub +10 -8
  47. package/template/src/core/maker/stubs/seeder/seeder.stub +18 -16
  48. package/template/src/core/maker/stubs/test/test.stub +9 -7
  49. package/template/src/core/maker/sync-config.ts +93 -94
  50. package/template/src/core/utils/password.ts +29 -27
  51. package/template/src/core/utils/playwright.ts +123 -121
  52. package/template/src/core/utils/queue.ts +68 -66
  53. package/template/src/core/utils/scheduler.ts +62 -60
  54. package/template/src/core/utils/storage.ts +3 -1
  55. package/template/src/core/utils/validation.ts +37 -35
  56. package/template/src/database/schema.ts +2 -0
  57. package/template/src/main.ts +120 -118
  58. package/template/src/modules/app/__tests__/demo.controller.test.ts +75 -0
  59. package/template/src/modules/app/__tests__/net.controller.test.ts +65 -0
  60. package/template/src/modules/app/__tests__/playwright.controller.test.ts +50 -0
  61. package/template/src/modules/app/__tests__/storage.controller.test.ts +114 -0
  62. package/template/src/modules/app/__tests__/window.controller.test.ts +98 -0
  63. package/template/src/modules/app/controllers/demo.controller.ts +120 -118
  64. package/template/src/modules/app/controllers/net.controller.ts +50 -48
  65. package/template/src/modules/app/controllers/playwright.controller.ts +142 -140
  66. package/template/src/modules/app/controllers/storage.controller.ts +231 -229
  67. package/template/src/modules/app/controllers/window.controller.ts +2 -0
  68. package/template/src/modules/app/facade.ts +21 -0
  69. package/template/src/preload.ts +25 -2
  70. package/template/src/ui/src/App.vue +4 -2
  71. package/template/src/ui/src/app.ts +38 -23
  72. package/template/src/ui/src/bindings.d.ts +18 -16
  73. package/template/src/ui/src/components/Button.vue +34 -32
  74. package/template/src/ui/src/components/Checkbox.vue +26 -29
  75. package/template/src/ui/src/components/Input.vue +221 -227
  76. package/template/src/ui/src/components/InputGroup.vue +141 -0
  77. package/template/src/ui/src/components/InputPasswordToggle.vue +204 -0
  78. package/template/src/ui/src/components/Modal.vue +65 -55
  79. package/template/src/ui/src/components/Spinner.vue +44 -42
  80. package/template/src/ui/src/components/Switch.vue +62 -65
  81. package/template/src/ui/src/components/TextArea.vue +108 -121
  82. package/template/src/ui/src/components/Toast.vue +55 -56
  83. package/template/src/ui/src/components/datatable/DataTableSkeleton.vue +100 -98
  84. package/template/src/ui/src/components/datatable/Pagination.vue +153 -125
  85. package/template/src/ui/src/components/datatable/SelectOpption.vue +36 -35
  86. package/template/src/ui/src/components/datatable/index.vue +336 -258
  87. package/template/src/ui/src/env.d.ts +16 -13
  88. package/template/src/ui/src/global.d.ts +21 -2
  89. package/template/src/ui/src/helpers/nformatter.ts +12 -10
  90. package/template/src/ui/src/pages/dashboard/index.vue +690 -687
  91. package/template/src/ui/src/plugins/browserDetect.ts +57 -0
  92. package/template/src/ui/src/plugins/gum.ts +576 -549
  93. package/template/src/ui/src/plugins/pulse.ts +181 -147
  94. package/template/src/ui/src/plugins/routeProgress.ts +89 -0
  95. package/template/src/ui/src/router/index.ts +44 -25
  96. package/template/src/ui/src/stores/example.ts +2 -0
  97. package/template/src/ui/vite.config.ts +40 -38
  98. package/template/src/window/app-menu.ts +89 -87
  99. package/template/src/window/config.ts +14 -12
  100. package/template/src/window/context-menu.ts +23 -21
  101. package/template/src/window/dialogs.ts +92 -90
  102. package/template/src/window/manager.ts +2 -0
  103. package/template/src/window/native.ts +47 -45
  104. package/template/src/window/tray.ts +132 -130
@@ -1,229 +1,231 @@
1
- /**
2
- * storage.controller.ts (app module) - real file operations, all native.
3
- *
4
- * Every handler uses the cross-platform native dialogs in
5
- * src/window/dialogs.ts (Windows WinForms, macOS AppKit, Linux zenity/kdialog)
6
- * to get a real disk path from the user, then operates on it with the storage
7
- * facade. One API, native on every OS:
8
- *
9
- * open -> pickers.open + files.readBinaryFile + files.fileMeta (text preview)
10
- * save -> pickers.save + files.writeTextFile (atomic)
11
- * upload -> pickers.open + files.uploadFile into app private uploads
12
- * download -> pickers.save + files.downloadFile (streamed + atomic)
13
- * remove -> pickers.open + files.removePath (missing-safe)
14
- * list -> pickers.folder + files.listFiles
15
- *
16
- * App-managed layer (private + tmp):
17
- * appSave/appLoad -> storage.put/get on samples/state.json
18
- * appList -> storage.files/directories
19
- * appExport -> generateForDownload + consumeGenerated (tmp, read-once)
20
- * appDelete -> storage.delete
21
- */
22
-
23
- import { files, pickers, storage } from "@/core/facade";
24
-
25
- const TEXT_EXTS = new Set([
26
- "txt",
27
- "md",
28
- "json",
29
- "csv",
30
- "ts",
31
- "tsx",
32
- "js",
33
- "jsx",
34
- "html",
35
- "css",
36
- "log",
37
- "xml",
38
- "yml",
39
- "yaml",
40
- "toml",
41
- "ini",
42
- "env",
43
- "vue",
44
- "sql",
45
- "deno"
46
- ]);
47
-
48
- function isTextLike(path: string): boolean {
49
- const ext = path.split(/[\\/]/).pop()?.split(".").pop()?.toLowerCase() ?? "";
50
- return TEXT_EXTS.has(ext);
51
- }
52
-
53
- function nameFromUrl(input: string): string {
54
- if (/^(https?|file):\/\//i.test(input)) {
55
- try {
56
- const name = decodeURIComponent(new URL(input).pathname.split("/").pop() || "");
57
- return name || "deskapp-download.bin";
58
- } catch {
59
- return "deskapp-download.bin";
60
- }
61
- }
62
- return input.split(/[\\/]/).pop() || "deskapp-download.bin";
63
- }
64
-
65
- /** Open any real file: native picker, then bytes + metadata (+ text preview). */
66
- export const open = async (): Promise<Record<string, unknown>> => {
67
- const path = await pickers.open({ title: "Open a file" });
68
- if (!path) return { ok: false, error: "cancelled", action: "open" };
69
- try {
70
- const meta = await files.fileMeta(path);
71
- if (!meta?.isFile) return { ok: false, action: "open", path, error: "not a file" };
72
- const bytes = await files.readBinaryFile(path);
73
- const preview = isTextLike(path) ? new TextDecoder().decode(bytes).slice(0, 2000) : null;
74
- return {
75
- ok: true,
76
- action: "open",
77
- path,
78
- size: meta.size,
79
- modifiedAt: meta.modifiedAt.toISOString(),
80
- preview
81
- };
82
- } catch (error) {
83
- return { ok: false, action: "open", path, error: String(error) };
84
- }
85
- };
86
-
87
- /** Save real content with a native Save As dialog (atomic write). */
88
- export const save = async (): Promise<Record<string, unknown>> => {
89
- const path = await pickers.save({
90
- title: "Save file as",
91
- defaultName: `deskapp-note-${Date.now()}.txt`,
92
- filter: "Text files (*.txt)|*.txt|All files (*.*)|*.*"
93
- });
94
- if (!path) return { ok: false, error: "cancelled", action: "save" };
95
- const content = `deskapp real save - ${new Date().toISOString()}\n`;
96
- try {
97
- await files.writeTextFile(path, content);
98
- const meta = await files.fileMeta(path);
99
- return { ok: true, action: "save", path, bytes: content.length, size: meta?.size ?? 0 };
100
- } catch (error) {
101
- return { ok: false, action: "save", path, error: String(error) };
102
- }
103
- };
104
-
105
- /** Upload (import) a real source file into the app's private store. */
106
- export const upload = async (): Promise<Record<string, unknown>> => {
107
- const source = await pickers.open({ title: "Choose a file to upload" });
108
- if (!source) return { ok: false, error: "cancelled", action: "upload" };
109
- try {
110
- const destDir = storage.disk("private").path("uploads");
111
- const dest = await files.uploadFile(source, destDir);
112
- const meta = await files.fileMeta(source);
113
- return { ok: true, action: "upload", source, dest, size: meta?.size ?? 0 };
114
- } catch (error) {
115
- return { ok: false, action: "upload", source, error: String(error) };
116
- }
117
- };
118
-
119
- /** Download a real URL to a real location chosen via Save As (atomic). */
120
- export const download = async (url: string | undefined): Promise<Record<string, unknown>> => {
121
- const clean = (url ?? "").trim();
122
- if (!clean) return { ok: false, error: "enter a URL first", action: "download" };
123
- const dest = await pickers.save({
124
- title: "Save downloaded file as",
125
- defaultName: nameFromUrl(clean)
126
- });
127
- if (!dest) return { ok: false, error: "cancelled", action: "download" };
128
- try {
129
- await files.downloadFile(clean, dest);
130
- const meta = await files.fileMeta(dest);
131
- return { ok: true, action: "download", url: clean, dest, size: meta?.size ?? 0 };
132
- } catch (error) {
133
- return { ok: false, action: "download", url: clean, dest, error: String(error) };
134
- }
135
- };
136
-
137
- /** Remove a real file (missing-safe). */
138
- export const remove = async (): Promise<Record<string, unknown>> => {
139
- const path = await pickers.open({ title: "Choose a file to remove" });
140
- if (!path) return { ok: false, error: "cancelled", action: "remove" };
141
- try {
142
- await files.removePath(path);
143
- return { ok: true, action: "remove", path, existsAfter: await files.pathExists(path) };
144
- } catch (error) {
145
- return { ok: false, action: "remove", path, error: String(error) };
146
- }
147
- };
148
-
149
- /** List the files inside a real folder chosen via the native picker. */
150
- export const list = async (): Promise<Record<string, unknown>> => {
151
- const path = await pickers.folder({ title: "Choose a folder to list" });
152
- if (!path) return { ok: false, error: "cancelled", action: "list" };
153
- try {
154
- return { ok: true, action: "list", path, files: await files.listFiles(path) };
155
- } catch (error) {
156
- return { ok: false, action: "list", path, error: String(error) };
157
- }
158
- };
159
-
160
- /* ---------------------------------------------------------------------------
161
- * App-managed layer (private disk + tmp generated artifacts)
162
- * ------------------------------------------------------------------------ */
163
-
164
- const STATE_FILE = "samples/state.json";
165
-
166
- /** Save app-owned state into the private disk (storage.put). */
167
- export const appSave = async (): Promise<Record<string, unknown>> => {
168
- const data = { theme: "dark", updatedAt: new Date().toISOString(), note: "app-managed private state" };
169
- await storage.put(STATE_FILE, JSON.stringify(data, null, 2));
170
- return { ok: true, action: "save (app state)", file: STATE_FILE, data };
171
- };
172
-
173
- /** Read app-owned state back (storage.get). */
174
- export const appLoad = async (): Promise<Record<string, unknown>> => {
175
- try {
176
- const raw = await storage.get(STATE_FILE);
177
- return { ok: true, action: "read (app state)", file: STATE_FILE, content: new TextDecoder().decode(raw) || null };
178
- } catch (error) {
179
- return { ok: false, action: "read (app state)", file: STATE_FILE, error: String(error) };
180
- }
181
- };
182
-
183
- /** List the private disk contents (storage.files / storage.directories). */
184
- export const appList = async (): Promise<Record<string, unknown>> => {
185
- return {
186
- ok: true,
187
- action: "list (app state)",
188
- disk: storage.disk("private").path("."),
189
- files: await storage.files(),
190
- directories: await storage.directories()
191
- };
192
- };
193
-
194
- /** Generate an ephemeral export in tmp, then consume it read-once. */
195
- export const appExport = async (): Promise<Record<string, unknown>> => {
196
- const file = await storage.generateForDownload({
197
- prefix: "report",
198
- extension: "csv",
199
- data: "name,value\nrows,2\n"
200
- });
201
- const bytes = await storage.consumeGenerated(file);
202
- return {
203
- ok: true,
204
- action: "generate + consume (tmp)",
205
- file,
206
- content: new TextDecoder().decode(bytes).trim()
207
- };
208
- };
209
-
210
- /** Delete app-owned state from the private disk (storage.delete). */
211
- export const appDelete = async (): Promise<Record<string, unknown>> => {
212
- await storage.delete(STATE_FILE);
213
- return { ok: true, action: "delete (app state)", file: STATE_FILE, existsAfter: await storage.exists(STATE_FILE) };
214
- };
215
-
216
- /** Handlers exposed to the frontend via the bindings registry. */
217
- export const handlers = {
218
- open,
219
- save,
220
- upload,
221
- download,
222
- remove,
223
- list,
224
- appSave,
225
- appLoad,
226
- appList,
227
- appExport,
228
- appDelete
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
+ };
@@ -1,3 +1,5 @@
1
+ // ./src/modules/app/controllers/window.controller.ts
2
+
1
3
  import { app } from "electron";
2
4
  import { config } from "@/core/config";
3
5
  import { chrome, type DesktopWindow, win } from "@/core/facade";
@@ -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";
@@ -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[]) => ipcRenderer.invoke(`deskapp:${name}`, ...args);
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[]) => ipcRenderer.invoke(`deskapp:${name}`, ...args);
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,3 +1,5 @@
1
- <template>
2
- <router-view />
1
+ <!-- ./src/ui/src/App.vue -->
2
+
3
+ <template>
4
+ <router-view />
3
5
  </template>
@@ -1,23 +1,38 @@
1
- import { createApp } from "vue";
2
- import App from "@/ui/App.vue";
3
- import faviconUrl from "@/ui/assets/images/favicon/favicon.ico";
4
- import { GumPlugin } from "@/ui/plugins/gum.ts";
5
- import { PulsePlugin, pulse } from "@/ui/plugins/pulse.ts";
6
- import router from "@/ui/router/index.ts";
7
-
8
- import "bootstrap/dist/css/bootstrap.min.css";
9
- import "bootstrap-icons/font/bootstrap-icons.css";
10
- import "bootstrap/dist/js/bootstrap.bundle.min.js";
11
- import "@/ui/assets/scss/custom.scss";
12
-
13
- let favicon = document.querySelector<HTMLLinkElement>('link[rel="icon"]');
14
- if (!favicon) {
15
- favicon = document.createElement("link");
16
- favicon.rel = "icon";
17
- document.head.appendChild(favicon);
18
- }
19
- favicon.href = faviconUrl;
20
-
21
- export { pulse };
22
-
23
- createApp(App).use(PulsePlugin).use(GumPlugin).use(router).mount("#app");
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");