@witchcraft/nuxt-electron 0.0.8 → 0.0.9

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 (59) hide show
  1. package/README.md +1 -1
  2. package/dist/module.d.cts +2 -0
  3. package/dist/module.d.mts +2 -117
  4. package/dist/module.json +1 -1
  5. package/dist/module.mjs +13 -369
  6. package/dist/types.d.mts +12 -2
  7. package/package.json +28 -28
  8. package/src/module.ts +1 -1
  9. package/dist/runtime/components/ElectronWindowControls.d.vue.ts +0 -32
  10. package/dist/runtime/components/ElectronWindowControls.vue +0 -67
  11. package/dist/runtime/components/ElectronWindowControls.vue.d.ts +0 -32
  12. package/dist/runtime/components/WindowControls/CloseButton.d.vue.ts +0 -17
  13. package/dist/runtime/components/WindowControls/CloseButton.vue +0 -54
  14. package/dist/runtime/components/WindowControls/CloseButton.vue.d.ts +0 -17
  15. package/dist/runtime/components/WindowControls/MaximizeButton.d.vue.ts +0 -17
  16. package/dist/runtime/components/WindowControls/MaximizeButton.vue +0 -33
  17. package/dist/runtime/components/WindowControls/MaximizeButton.vue.d.ts +0 -17
  18. package/dist/runtime/components/WindowControls/MinimizeButton.d.vue.ts +0 -17
  19. package/dist/runtime/components/WindowControls/MinimizeButton.vue +0 -40
  20. package/dist/runtime/components/WindowControls/MinimizeButton.vue.d.ts +0 -17
  21. package/dist/runtime/components/WindowControls/PinButton.d.vue.ts +0 -28
  22. package/dist/runtime/components/WindowControls/PinButton.vue +0 -52
  23. package/dist/runtime/components/WindowControls/PinButton.vue.d.ts +0 -28
  24. package/dist/runtime/electron/apiBuilder.d.ts +0 -8
  25. package/dist/runtime/electron/apiBuilder.js +0 -9
  26. package/dist/runtime/electron/createBroadcastHandlers.d.ts +0 -4
  27. package/dist/runtime/electron/createBroadcastHandlers.js +0 -30
  28. package/dist/runtime/electron/createBroadcaster.d.ts +0 -2
  29. package/dist/runtime/electron/createBroadcaster.js +0 -7
  30. package/dist/runtime/electron/createNuxtFileProtocolHandler.d.ts +0 -14
  31. package/dist/runtime/electron/createNuxtFileProtocolHandler.js +0 -20
  32. package/dist/runtime/electron/createWindowControlsApi.d.ts +0 -19
  33. package/dist/runtime/electron/createWindowControlsApi.js +0 -6
  34. package/dist/runtime/electron/createWindowControlsApiHandler.d.ts +0 -4
  35. package/dist/runtime/electron/createWindowControlsApiHandler.js +0 -24
  36. package/dist/runtime/electron/getEventWindow.d.ts +0 -11
  37. package/dist/runtime/electron/getEventWindow.js +0 -8
  38. package/dist/runtime/electron/getPaths.d.ts +0 -27
  39. package/dist/runtime/electron/getPaths.js +0 -33
  40. package/dist/runtime/electron/getPreloadMeta.d.ts +0 -25
  41. package/dist/runtime/electron/getPreloadMeta.js +0 -7
  42. package/dist/runtime/electron/index.d.ts +0 -16
  43. package/dist/runtime/electron/index.js +0 -16
  44. package/dist/runtime/electron/promisifyApi.d.ts +0 -40
  45. package/dist/runtime/electron/promisifyApi.js +0 -41
  46. package/dist/runtime/electron/promisifyReply.d.ts +0 -8
  47. package/dist/runtime/electron/promisifyReply.js +0 -29
  48. package/dist/runtime/electron/registerDevtoolsShortcuts.d.ts +0 -2
  49. package/dist/runtime/electron/registerDevtoolsShortcuts.js +0 -10
  50. package/dist/runtime/electron/static.d.ts +0 -12
  51. package/dist/runtime/electron/static.js +0 -8
  52. package/dist/runtime/electron/types.d.ts +0 -1
  53. package/dist/runtime/electron/types.js +0 -0
  54. package/dist/runtime/electron/useDevDataDir.d.ts +0 -1
  55. package/dist/runtime/electron/useDevDataDir.js +0 -8
  56. package/dist/runtime/electron/useNuxtRuntimeConfig.d.ts +0 -2
  57. package/dist/runtime/electron/useNuxtRuntimeConfig.js +0 -4
  58. package/dist/runtime/utils/isElectron.d.ts +0 -9
  59. package/dist/runtime/utils/isElectron.js +0 -3
package/README.md CHANGED
@@ -260,7 +260,7 @@ Note we would ideally also remove "/" from the prerender, but this requires manu
260
260
 
261
261
  A `routeRules` redirect won't work, because it will trigger a request to electron's file protocol handler which we don't know what to do with.
262
262
 
263
- A redirect from a page (e.i. `if (process.client && isElectron) { navigateTo("/app") }`) works, but it takes a little big of time to navigate. This is still needed for development redirecting, but not in production.
263
+ A redirect from a page (e.i. `if (process.client && isElectron) { await navigateTo("/app") }`) works, but it takes a little big of time to navigate. This is still needed for development redirecting, but not in production.
264
264
 
265
265
  #### Build
266
266
 
@@ -0,0 +1,2 @@
1
+ export * from "/home/runner/work/nuxt-electron/nuxt-electron/src/module.js";
2
+ export { default } from "/home/runner/work/nuxt-electron/nuxt-electron/src/module.js";
package/dist/module.d.mts CHANGED
@@ -1,117 +1,2 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
- import { ElectronOptions } from 'vite-plugin-electron';
3
- import { notBundle } from 'vite-plugin-electron/plugin';
4
-
5
- interface ModuleOptions {
6
- srcDir: string;
7
- /**
8
- * The dir for building for electron. `.output` and `build` will be put in here, and also release (but that's left up to your electron packing configuration).
9
- *
10
- * @default ".dist/electron/"
11
- */
12
- electronBuildDir: string;
13
- /**
14
- * The nuxt output dir when not building electron.
15
- *
16
- * @default ".dist/web/.output"
17
- */
18
- nonElectronNuxtBuildDir: string;
19
- /**
20
- * The main route of the electron app. Electron will be pointed to this route.
21
- *
22
- * @default "/app"
23
- */
24
- electronRoute: string;
25
- /**
26
- * Additional routes to include in the electron build. Note that "/" is always included as not including it was causing issues.
27
- */
28
- additionalRoutes: string[];
29
- /** Extra cli arguments to launch electron with in dev mode */
30
- extraCliArgs: string[];
31
- /**
32
- * If set, adds `--dev-user-data-dir ${devUserDataDir}` to the cli arguments in development mode.
33
- *
34
- * You will then need to parse this in main.ts, a `useDevDataDir` function is provided for this. This does not do any advanced parsing, just takes the next argument after `--dev-user-data-dir` so the path must not contain spaces.
35
- * ```ts
36
- * const userDataDir = useDevDataDir() ?? app.getPath("userData")
37
- *
38
- * @default "~~/.user-data-dir"
39
- */
40
- devUserDataDir: string | null;
41
- /**
42
- * The script to run to build/pack the electron app.
43
- *
44
- * @default "npm run build:electron:pack"
45
- */
46
- electronBuildPackScript: string;
47
- /** Whether to enable the module. */
48
- enable: boolean;
49
- /**
50
- * Whether to auto-open electron. If undefined, is controlled by the AUTO_OPEN env variable instead (it should include the word `electron` to enable autoOpen).
51
- *
52
- * This only works in dev mode.
53
- *
54
- * @default undefined
55
- */
56
- autoOpen: boolean;
57
- /**
58
- * Pass public runtime config options only for electron.
59
- */
60
- electronOnlyRuntimeConfig: Record<string, any>;
61
- /**
62
- * Whether you're using a preload script.
63
- *
64
- * @default true
65
- */
66
- usePreloadScript: boolean;
67
- /**
68
- * Pass custom vite options to the electron vite builder (e.g. wasm()) as they are not copied over from nuxt's vite config.
69
- *
70
- * Note that `build.emptyOutDir` cannot be changed, it must be false for the reloading to work.
71
- */
72
- electronViteOptions: ElectronOptions["vite"];
73
- notBundleOptions: Parameters<typeof notBundle>[0];
74
- /**
75
- * Additional variables to "bake" into the electron build. Note these must be quoted if they are strings.
76
- *
77
- * You can set these as properties of STATIC, to make it clearer what they are.
78
- *
79
- * ```ts
80
- * import { STATIC } from "@witchcraft/nuxt-electron/electron"
81
- *
82
- * // assuming electron.additionalElectronVariables.someVariable = `"some-var"`
83
- *
84
- * STATIC.SOME_VARIABLE = process.env.SOME_VARIABLE
85
- *
86
- * // becomes
87
- * STATIC.SOME_VARIABLE = "some-var"
88
- * ```
89
- */
90
- additionalElectronVariables: Record<string, string>;
91
- /**
92
- * Additional vite defines to copy from the resolved vite config.
93
- *
94
- * The module copies the following defines from nuxt's vite config for the electron vite config:
95
- *
96
- * ```
97
- * __NUXT_VERSION__
98
- * process.dev
99
- * import.meta.dev
100
- * process.test
101
- * import.meta.test
102
- *```
103
- * And the following are also added:
104
- * ```
105
- * import.meta.electron (true from main, false elsewhere)
106
- * process.electron (true from main, false elsewhere)
107
- * ```
108
- *
109
- * They will only be true for files that might be imported by main only. For renderer/client side use `isElectron()` instead. We cannot define them on the client side because during dev they would be wrong (electorn is always pointing to the same page as the server).
110
- *
111
- */
112
- additionalViteDefinesToCopy: string[];
113
- }
114
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
115
-
116
- export { _default as default };
117
- export type { ModuleOptions };
1
+ export * from "/home/runner/work/nuxt-electron/nuxt-electron/src/module.js";
2
+ export { default } from "/home/runner/work/nuxt-electron/nuxt-electron/src/module.js";
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "electron",
3
3
  "configKey": "electron",
4
- "version": "0.0.8",
4
+ "version": "0.0.9",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,374 +1,18 @@
1
- import { crop } from '@alanscodelog/utils/crop';
2
- import { run } from '@alanscodelog/utils/run';
3
- import { defineNuxtModule, useLogger, createResolver, addComponentsDir, addTemplate, extendRouteRules, addImportsDir } from '@nuxt/kit';
4
- import { nuxtRemoveUneededPages, nuxtFileBasedRouting, nuxtRerouteOutputTo, createConstantCaseVariables } from '@witchcraft/nuxt-utils/utils';
5
- import { defu } from 'defu';
6
- import fs from 'node:fs/promises';
7
- import path from 'node:path';
8
- import { startup, build } from 'vite-plugin-electron';
9
- import { notBundle } from 'vite-plugin-electron/plugin';
10
- import { externalizeDeps } from 'vite-plugin-externalize-deps';
1
+ import { createJiti } from "file:///home/runner/work/nuxt-electron/nuxt-electron/node_modules/.pnpm/jiti@2.6.1/node_modules/jiti/lib/jiti.mjs";
11
2
 
12
- const dependencies = {
13
- "@witchcraft/ui": "^0.3.2"};
14
- const pkg = {
15
- dependencies: dependencies};
16
-
17
- startup.exit = async () => {
18
- if ("electronApp" in process) {
19
- try {
20
- const app = process.electronApp;
21
- app.removeAllListeners();
22
- process.kill(app.pid);
23
- } catch (e) {
24
- console.error("Could not kill electron instance/s.");
25
- console.error(e);
26
- }
27
- }
28
- };
29
- const module = defineNuxtModule({
30
- meta: {
31
- name: "electron",
32
- configKey: "electron"
33
- },
34
- // Default configuration options of the Nuxt module
35
- defaults: {
36
- srcDir: "~~/app-electron",
37
- electronBuildDir: "~~/.dist/electron",
38
- nonElectronNuxtBuildDir: "~~/.dist/web/.output",
39
- devUserDataDir: void 0,
40
- electronRoute: "/app",
41
- autoOpen: process.env.AUTO_OPEN?.includes("electron"),
42
- electronBuildPackScript: "npm run build:electron:pack",
43
- additionalRoutes: [],
44
- extraCliArgs: [],
45
- enable: true,
46
- electronOnlyRuntimeConfig: {},
47
- usePreloadScript: true,
48
- electronViteOptions: {},
49
- additionalElectronVariables: {},
50
- additionalViteDefinesToCopy: [],
51
- notBundleOptions: {}
52
- },
53
- moduleDependencies: {
54
- "@witchcraft/ui/nuxt": {
55
- version: pkg.dependencies["@witchcraft/ui"]
56
- }
3
+ const jiti = createJiti(import.meta.url, {
4
+ "interopDefault": true,
5
+ "alias": {
6
+ "@witchcraft/nuxt-electron": "/home/runner/work/nuxt-electron/nuxt-electron"
57
7
  },
58
- async setup(options, nuxt) {
59
- if (options.devUserDataDir === void 0) {
60
- options.devUserDataDir = "~~/.user-data-dir";
8
+ "transformOptions": {
9
+ "babel": {
10
+ "plugins": []
61
11
  }
62
- if (!options.enable) {
63
- return;
64
- }
65
- const moduleName = "@witchcraft/nuxt-electron";
66
- const logger = useLogger(moduleName);
67
- const { resolvePath, resolve } = createResolver(import.meta.url);
68
- addComponentsDir({
69
- global: true,
70
- path: resolve("runtime/components")
71
- });
72
- addTemplate({
73
- filename: "witchcraft-electron.css",
74
- write: true,
75
- getContents: () => crop`
76
- @source "${resolve("runtime/components")}";
77
- `
78
- });
79
- const isDev = nuxt.options.dev;
80
- const srcDir = await resolvePath(options.srcDir, nuxt.options.alias);
81
- const nonElectronNuxtBuildDir = await resolvePath(options.nonElectronNuxtBuildDir, nuxt.options.alias);
82
- const electronRootBuildDir = await resolvePath(options.electronBuildDir, nuxt.options.alias);
83
- const relativeElectronDir = path.relative(nuxt.options.rootDir, electronRootBuildDir);
84
- const electronNuxtDir = path.join(relativeElectronDir, ".output");
85
- const electronBuildDir = path.join(relativeElectronDir, "build");
86
- const electronProdUrl = `${options.electronRoute}/index.html`;
87
- const electronRoute = options.electronRoute;
88
- const electronNuxtPublicDir = path.join(electronNuxtDir, "public");
89
- const mainScriptPath = path.join(srcDir, "main.ts");
90
- const preloadScriptPath = path.join(srcDir, "preload.ts");
91
- const hasMainScript = await fs.stat(mainScriptPath).then(() => true).catch(() => false);
92
- const hasPreloadScript = !options.usePreloadScript || await fs.stat(preloadScriptPath).then(() => true).catch(() => false);
93
- const hasScripts = hasMainScript && hasPreloadScript;
94
- if (!hasScripts) {
95
- logger.warn(`Missing electron scripts: ${[hasMainScript ? "" : "main.ts", hasPreloadScript ? "" : "preload.ts"].join(", ")}. Skipping electron build.`);
96
- }
97
- const isElectronBuild = process.env.BUILD_ELECTRON === "true" && hasScripts;
98
- const skipElectronPack = process.env.SKIP_ELECTRON_PACK === "true";
99
- const autoOpen = !!(options.autoOpen && hasScripts && isDev);
100
- const useWatch = nuxt.options.dev;
101
- const devUserDataDir = options.devUserDataDir && await resolvePath(options.devUserDataDir, nuxt.options.alias);
102
- if (devUserDataDir) {
103
- if (!await fs.stat(devUserDataDir).then(() => true).catch(() => false)) {
104
- await fs.mkdir(devUserDataDir, {
105
- recursive: true
106
- });
107
- }
108
- }
109
- logger.debug({
110
- isDev,
111
- useWatch,
112
- srcDir,
113
- prodNonElectronNuxtDir: nonElectronNuxtBuildDir,
114
- electronRootBuildDir,
115
- relativeElectronDir,
116
- electronNuxtDir,
117
- electronBuildDir,
118
- electronProdUrl,
119
- electronRoute,
120
- electronNuxtPublicDir,
121
- mainScriptPath,
122
- preloadScriptPath,
123
- isElectronBuild,
124
- skipElectronPack,
125
- autoOpen,
126
- devUserDataDir
127
- });
128
- let resolveGetViteServer;
129
- const viteServerPromise = new Promise((resolve2) => {
130
- resolveGetViteServer = resolve2;
131
- });
132
- nuxt.hook("vite:serverCreated", (server) => {
133
- logger.info(`Resolved vite server.`);
134
- resolveGetViteServer(server);
135
- });
136
- const viteServerUrl = new Promise((resolve2) => {
137
- nuxt.hook("build:before", () => {
138
- resolve2(void 0);
139
- });
140
- nuxt.hook("listen", (_server, listener) => {
141
- logger.info(`Resolved server url.`, listener.url);
142
- resolve2(listener.url);
143
- });
144
- });
145
- const viteConfigPromise = new Promise((resolve2) => {
146
- nuxt.hook("vite:configResolved", (config) => {
147
- resolve2(config);
148
- });
149
- });
150
- let maybeWatchers;
151
- let started = false;
152
- nuxt.hook("vite:extendConfig", (config) => {
153
- config.define ??= {};
154
- config.define["import.meta.electron"] = "false";
155
- config.define["process.electron"] = "false";
156
- });
157
- const buildElectron = async () => {
158
- if (maybeWatchers || started) return;
159
- started = true;
160
- const viteConfig = await viteConfigPromise;
161
- const electronRuntimeConfig = defu(
162
- options.electronOnlyRuntimeConfig,
163
- nuxt.options.runtimeConfig.public
164
- );
165
- const additionalElectronVariables = defu(
166
- options.additionalElectronVariables,
167
- nuxt.options.electron.additionalElectronVariables
168
- );
169
- const additionalViteDefinesToCopy = [
170
- ...options.additionalViteDefinesToCopy,
171
- ...nuxt.options.electron.additionalViteDefinesToCopy ?? []
172
- ];
173
- const copyFromVite = [
174
- "__NUXT_VERSION__",
175
- "process.dev",
176
- "import.meta.dev",
177
- "process.test",
178
- "import.meta.test",
179
- ...additionalViteDefinesToCopy
180
- ];
181
- const electronVariables = {
182
- "process.electron": true,
183
- "import.meta.electron": true,
184
- ...Object.fromEntries(
185
- copyFromVite.map((v) => [v, viteConfig.define[v]])
186
- ),
187
- ...createConstantCaseVariables({
188
- electronRoute,
189
- electronProdUrl,
190
- electronNuxtDir,
191
- electronNuxtPublicDir,
192
- electronBuildDir,
193
- // ...options.additionalElectronVariables,
194
- // nuxt's runtimeConfig cannot be used in electron's main since it's built seperately
195
- // also we must stringify ourselves since escaped double quotes are not preserved in the final output :/
196
- electronRuntimeConfig: JSON.stringify(electronRuntimeConfig).replaceAll("\\", "\\\\")
197
- }, "process.env."),
198
- // wut am having issue with just using STATIC. directly ???
199
- ...createConstantCaseVariables(
200
- additionalElectronVariables,
201
- "process.env.",
202
- { autoquote: false }
203
- )
204
- };
205
- const electronViteOptions = defu(
206
- {
207
- build: {
208
- // must be false or preload can get deleted when vite rebuilds
209
- emptyOutDir: false
210
- }
211
- },
212
- options.electronViteOptions,
213
- {
214
- build: {
215
- outDir: electronBuildDir,
216
- minify: false
217
- },
218
- define: electronVariables,
219
- resolve: {
220
- alias: nuxt.options.alias,
221
- extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"]
222
- },
223
- plugins: [externalizeDeps()]
224
- }
225
- );
226
- const electronCliArgs = [
227
- ".",
228
- ...process.env.NODE_ENV !== "production" && devUserDataDir ? [
229
- "--dev-user-data-dir",
230
- devUserDataDir
231
- ] : [],
232
- ...options.extraCliArgs ?? []
233
- ];
234
- const builds = [
235
- {
236
- entry: mainScriptPath,
237
- onStart: autoOpen ? async () => {
238
- await startup([...electronCliArgs]);
239
- } : void 0
240
- },
241
- ...options.usePreloadScript ? [{
242
- entry: preloadScriptPath,
243
- onStart: async () => {
244
- (await viteServerPromise).hot.send({ type: "full-reload" });
245
- },
246
- build: {
247
- rollupOptions: {
248
- output: {
249
- inlineDynamicImports: true
250
- }
251
- }
252
- }
253
- }] : []
254
- ].map((entry) => ({
255
- vite: {
256
- mode: process.env.NODE_ENV,
257
- ...electronViteOptions,
258
- build: {
259
- watch: useWatch ? {
260
- include: [`${srcDir}/**/*`]
261
- } : null,
262
- lib: {
263
- entry: entry.entry,
264
- formats: entry.entry.includes("preload") ? ["cjs"] : ["es"],
265
- fileName: () => entry.entry.includes("preload") ? "[name].cjs" : "[name].mjs"
266
- },
267
- ...electronViteOptions.build
268
- },
269
- plugins: [
270
- autoOpen ? {
271
- name: "plugin-start-electron",
272
- async closeBundle() {
273
- void entry.onStart?.();
274
- }
275
- } : void 0,
276
- // not bundle breaks preload because it tries to required from node_modules
277
- // and sandboxed windows can't do that
278
- ...!isElectronBuild && !entry.entry.includes("preload") ? [notBundle(options.notBundleOptions)] : [],
279
- ...electronViteOptions.plugins ?? []
280
- ]
281
- }
282
- }));
283
- logger.debug(builds);
284
- const devUrl = await viteServerUrl;
285
- if (devUrl) {
286
- Object.assign(process.env, {
287
- VITE_DEV_SERVER_URL: devUrl.slice(0, -1)
288
- });
289
- }
290
- logger.debug({
291
- electronViteOptions,
292
- prodNonElectronNuxtDir: nonElectronNuxtBuildDir,
293
- electronVariables,
294
- electronRuntimeConfig,
295
- electronCliArgs,
296
- devUrl
297
- });
298
- maybeWatchers = await Promise.all(builds.map(
299
- async (config) => build(config).then((res) => {
300
- logger.info(`Build done.`);
301
- return res;
302
- }).catch((err) => {
303
- logger.error(`Build failed.`, err);
304
- process.exit(1);
305
- })
306
- ));
307
- if (useWatch) {
308
- for (const maybeWatcher of maybeWatchers) {
309
- if (maybeWatcher && "on" in maybeWatcher) {
310
- maybeWatcher.on("change", (e) => {
311
- logger.info(`Detected change in: ${e}`);
312
- });
313
- }
314
- }
315
- }
316
- };
317
- if (autoOpen) {
318
- nuxt.hook("close", async () => {
319
- logger.info(`Killing`);
320
- await startup?.exit();
321
- });
322
- nuxt.hook("restart", async () => {
323
- logger.info(`Killing and Restarting`);
324
- await startup?.exit();
325
- });
326
- }
327
- logger.info(`Building Electron: ${isElectronBuild}`);
328
- if (isElectronBuild) {
329
- nuxt.hook("build:manifest", (manifest) => {
330
- for (const key of Object.keys(manifest)) {
331
- manifest[key].dynamicImports = [];
332
- }
333
- });
334
- nuxtRemoveUneededPages(nuxt, ["/", electronRoute, ...options.additionalRoutes]);
335
- extendRouteRules(electronRoute, { ssr: false, prerender: true }, { override: true });
336
- nuxt.options.router = defu(
337
- nuxtFileBasedRouting().router,
338
- nuxt.options.router ?? {}
339
- );
340
- nuxtRerouteOutputTo(nuxt, electronNuxtDir);
341
- nuxt.hook("close", async () => {
342
- logger.info(`Building Electron`);
343
- await buildElectron();
344
- if (!skipElectronPack) {
345
- logger.info(`Packing Electron`);
346
- const buildCommand = run(options.electronBuildPackScript, {
347
- stdio: "inherit"
348
- });
349
- await buildCommand.promise.catch((err) => {
350
- logger.error("Error building electron.", err);
351
- process.exit(1);
352
- });
353
- } else {
354
- logger.info(`Skipping Electron Pack`);
355
- }
356
- logger.info(`Done Building Electron`);
357
- });
358
- } else {
359
- if (isDev) {
360
- nuxt.hook("ready", async () => {
361
- logger.info("electron - ready");
362
- void buildElectron();
363
- });
364
- logger.info(`Watching Electron`);
365
- } else {
366
- logger.info(`Skipping Electron Build`);
367
- }
368
- nuxtRerouteOutputTo(nuxt, nonElectronNuxtBuildDir);
369
- }
370
- addImportsDir(resolve("runtime/utils"));
371
12
  }
372
- });
13
+ })
14
+
15
+ /** @type {import("/home/runner/work/nuxt-electron/nuxt-electron/src/module.js")} */
16
+ const _module = await jiti.import("/home/runner/work/nuxt-electron/nuxt-electron/src/module.ts");
373
17
 
374
- export { module as default };
18
+ export default _module?.default ?? _module;
package/dist/types.d.mts CHANGED
@@ -1,3 +1,13 @@
1
- export { default } from './module.mjs'
1
+ import type { ModuleHooks, ModuleRuntimeHooks, ModuleRuntimeConfig, ModulePublicRuntimeConfig } from './module.mjs'
2
2
 
3
- export { type ModuleOptions } from './module.mjs'
3
+ declare module '#app' {
4
+ interface RuntimeNuxtHooks extends ModuleRuntimeHooks {}
5
+ }
6
+
7
+ declare module '@nuxt/schema' {
8
+ interface NuxtHooks extends ModuleHooks {}
9
+ interface RuntimeConfig extends ModuleRuntimeConfig {}
10
+ interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
11
+ }
12
+
13
+ export * from "./module.mjs"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@witchcraft/nuxt-electron",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "Nuxt module for working with electron.",
5
5
  "repository": "witchcraftjs/nuxt-electron",
6
6
  "license": "MIT",
@@ -25,7 +25,7 @@
25
25
  "genDevDesktop.js"
26
26
  ],
27
27
  "scripts": {
28
- "prepare": "husky && pnpm nuxt-module-build prepare && pnpm build:only && cd playground && pnpm i --ignore-scripts --ignore-workspace",
28
+ "prepare": "husky && pnpm dev:prepare",
29
29
  "build": "nuxt-module-build prepare && nuxt-module-build build && nuxi build playground",
30
30
  "build:only": "nuxt-module-build build",
31
31
  "dev": "nuxi dev playground",
@@ -36,18 +36,18 @@
36
36
  "test:watch": "vitest watch"
37
37
  },
38
38
  "dependencies": {
39
- "@alanscodelog/utils": "^6.0.2",
40
- "@nuxt/kit": "^4.0.3",
41
- "@witchcraft/nuxt-utils": "^0.3.2",
42
- "@witchcraft/ui": "^0.3.2",
43
- "defu": "^6.1.4",
44
- "es-toolkit": "^1.39.10",
45
- "vite-plugin-electron": "^0.29.0",
46
- "vite-plugin-externalize-deps": "^0.9.0"
39
+ "@alanscodelog/utils": "catalog:",
40
+ "@nuxt/kit": "catalog:",
41
+ "@witchcraft/nuxt-utils": "catalog:",
42
+ "@witchcraft/ui": "catalog:",
43
+ "defu": "catalog:",
44
+ "es-toolkit": "catalog:",
45
+ "vite-plugin-electron": "catalog:",
46
+ "vite-plugin-externalize-deps": "catalog:"
47
47
  },
48
48
  "peerDependencies": {
49
- "@witchcraft/ui": "^0.3.2",
50
- "unplugin-icons": "^22.1.0"
49
+ "@witchcraft/ui": "catalog:",
50
+ "unplugin-icons": "catalog:"
51
51
  },
52
52
  "peerDependenciesMeta": {
53
53
  "unplugin-icons": {
@@ -58,24 +58,24 @@
58
58
  }
59
59
  },
60
60
  "devDependencies": {
61
- "@alanscodelog/eslint-config": "^6.3.1",
62
- "@alanscodelog/semantic-release-config": "^5.0.4",
63
- "@alanscodelog/tsconfigs": "^6.2.0",
64
- "@nuxt/eslint-config": "^1.9.0",
65
- "@nuxt/module-builder": "^1.0.2",
66
- "@nuxt/schema": "^4.0.3",
67
- "@nuxt/test-utils": "^3.19.2",
61
+ "@alanscodelog/eslint-config": "catalog:",
62
+ "@alanscodelog/semantic-release-config": "catalog:",
63
+ "@alanscodelog/tsconfigs": "catalog:",
64
+ "@nuxt/eslint-config": "catalog:",
65
+ "@nuxt/module-builder": "catalog:",
66
+ "@nuxt/schema": "catalog:",
67
+ "@nuxt/test-utils": "catalog:",
68
68
  "@types/node": "latest",
69
- "changelogen": "^0.6.2",
69
+ "changelogen": "catalog:",
70
70
  "electron": "^38.0.0",
71
- "eslint": "^9.34.0",
72
- "husky": "^9.1.7",
73
- "json5": "^2.2.3",
74
- "nuxt": "^4.0.3",
75
- "typescript": "^5.8.3",
76
- "unplugin-icons": "^22.3.0",
77
- "vitest": "^3.2.4",
78
- "vue-tsc": "^3.0.6"
71
+ "eslint": "catalog:",
72
+ "husky": "catalog:",
73
+ "json5": "catalog:",
74
+ "nuxt": "catalog:",
75
+ "typescript": "catalog:",
76
+ "unplugin-icons": "catalog:",
77
+ "vitest": "catalog:",
78
+ "vue-tsc": "catalog:"
79
79
  },
80
80
  "release": {
81
81
  "extends": [
package/src/module.ts CHANGED
@@ -175,7 +175,7 @@ export default defineNuxtModule<ModuleOptions>({
175
175
  },
176
176
  moduleDependencies: {
177
177
  "@witchcraft/ui/nuxt": {
178
- version: pkg.dependencies["@witchcraft/ui"]
178
+ version: "^0.3.2"
179
179
  }
180
180
  },
181
181
  async setup(options, nuxt) {
@@ -1,32 +0,0 @@
1
- import { type Component } from "vue";
2
- import type { WindowControlsApi } from "../electron/types.js";
3
- type __VLS_Props = {
4
- borderWidth?: string;
5
- buttonSize?: string;
6
- borderRadius?: string;
7
- /**
8
- *
9
- * Replace any of the default buttons with your own components.
10
- *
11
- * Note that you can get the existing button components (import from `/components/WIndowControls/[name]`) and pass a slot to change the icon then pass your new component here.
12
- *
13
- * If using a completely custom component, it must emit an `action` event with the action name as the value.
14
- *
15
- * This wrapper component sets the following css variables if you need them:
16
- * `--electron-wc-size`
17
- * `--electron-wc-border`
18
- * `--electron-wc-rounded`
19
- * `--electron-wc-diagonal` (useful for creating the close cross)
20
- */
21
- components?: Partial<Record<"CloseButton" | "MinimizeButton" | "MaximizeButton" | "PinButton", Component>>;
22
- buttonsOrder?: ("CloseButton" | "MinimizeButton" | "MaximizeButton" | "PinButton")[];
23
- handler?: WindowControlsApi;
24
- };
25
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
26
- borderWidth: string;
27
- buttonSize: string;
28
- borderRadius: string;
29
- buttonsOrder: ("CloseButton" | "MinimizeButton" | "MaximizeButton" | "PinButton")[];
30
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
31
- declare const _default: typeof __VLS_export;
32
- export default _default;