@witchcraft/nuxt-electron 0.0.1
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/README.md +299 -0
- package/dist/module.d.mts +117 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +362 -0
- package/dist/runtime/components/ElectronWindowControls.d.vue.ts +31 -0
- package/dist/runtime/components/ElectronWindowControls.vue +67 -0
- package/dist/runtime/components/ElectronWindowControls.vue.d.ts +31 -0
- package/dist/runtime/components/WindowControls/CloseButton.d.vue.ts +16 -0
- package/dist/runtime/components/WindowControls/CloseButton.vue +54 -0
- package/dist/runtime/components/WindowControls/CloseButton.vue.d.ts +16 -0
- package/dist/runtime/components/WindowControls/MaximizeButton.d.vue.ts +16 -0
- package/dist/runtime/components/WindowControls/MaximizeButton.vue +33 -0
- package/dist/runtime/components/WindowControls/MaximizeButton.vue.d.ts +16 -0
- package/dist/runtime/components/WindowControls/MinimizeButton.d.vue.ts +16 -0
- package/dist/runtime/components/WindowControls/MinimizeButton.vue +40 -0
- package/dist/runtime/components/WindowControls/MinimizeButton.vue.d.ts +16 -0
- package/dist/runtime/components/WindowControls/PinButton.d.vue.ts +27 -0
- package/dist/runtime/components/WindowControls/PinButton.vue +51 -0
- package/dist/runtime/components/WindowControls/PinButton.vue.d.ts +27 -0
- package/dist/runtime/electron/apiBuilder.d.ts +8 -0
- package/dist/runtime/electron/apiBuilder.js +9 -0
- package/dist/runtime/electron/createBroadcastHandlers.d.ts +4 -0
- package/dist/runtime/electron/createBroadcastHandlers.js +30 -0
- package/dist/runtime/electron/createBroadcaster.d.ts +2 -0
- package/dist/runtime/electron/createBroadcaster.js +7 -0
- package/dist/runtime/electron/createNuxtFileProtocolHandler.d.ts +14 -0
- package/dist/runtime/electron/createNuxtFileProtocolHandler.js +20 -0
- package/dist/runtime/electron/createWindowControlsApi.d.ts +19 -0
- package/dist/runtime/electron/createWindowControlsApi.js +6 -0
- package/dist/runtime/electron/createWindowControlsApiHandler.d.ts +4 -0
- package/dist/runtime/electron/createWindowControlsApiHandler.js +24 -0
- package/dist/runtime/electron/getEventWindow.d.ts +11 -0
- package/dist/runtime/electron/getEventWindow.js +8 -0
- package/dist/runtime/electron/getPaths.d.ts +27 -0
- package/dist/runtime/electron/getPaths.js +33 -0
- package/dist/runtime/electron/getPreloadMeta.d.ts +25 -0
- package/dist/runtime/electron/getPreloadMeta.js +7 -0
- package/dist/runtime/electron/index.d.ts +16 -0
- package/dist/runtime/electron/index.js +16 -0
- package/dist/runtime/electron/promisifyApi.d.ts +40 -0
- package/dist/runtime/electron/promisifyApi.js +41 -0
- package/dist/runtime/electron/promisifyReply.d.ts +8 -0
- package/dist/runtime/electron/promisifyReply.js +27 -0
- package/dist/runtime/electron/registerDevtoolsShortcuts.d.ts +2 -0
- package/dist/runtime/electron/registerDevtoolsShortcuts.js +10 -0
- package/dist/runtime/electron/static.d.ts +12 -0
- package/dist/runtime/electron/static.js +8 -0
- package/dist/runtime/electron/types.d.ts +1 -0
- package/dist/runtime/electron/types.js +0 -0
- package/dist/runtime/electron/useDevDataDir.d.ts +1 -0
- package/dist/runtime/electron/useDevDataDir.js +8 -0
- package/dist/runtime/electron/useNuxtRuntimeConfig.d.ts +2 -0
- package/dist/runtime/electron/useNuxtRuntimeConfig.js +4 -0
- package/dist/runtime/utils/isElectron.d.ts +9 -0
- package/dist/runtime/utils/isElectron.js +3 -0
- package/dist/types.d.mts +3 -0
- package/genDevDesktop.js +47 -0
- package/package.json +93 -0
- package/src/module.ts +549 -0
- package/src/runtime/components/ElectronWindowControls.vue +94 -0
- package/src/runtime/components/WindowControls/CloseButton.vue +56 -0
- package/src/runtime/components/WindowControls/MaximizeButton.vue +35 -0
- package/src/runtime/components/WindowControls/MinimizeButton.vue +42 -0
- package/src/runtime/components/WindowControls/PinButton.vue +56 -0
- package/src/runtime/electron/apiBuilder.ts +27 -0
- package/src/runtime/electron/createBroadcastHandlers.ts +36 -0
- package/src/runtime/electron/createBroadcaster.ts +11 -0
- package/src/runtime/electron/createNuxtFileProtocolHandler.ts +42 -0
- package/src/runtime/electron/createWindowControlsApi.ts +27 -0
- package/src/runtime/electron/createWindowControlsApiHandler.ts +34 -0
- package/src/runtime/electron/getEventWindow.ts +19 -0
- package/src/runtime/electron/getPaths.ts +68 -0
- package/src/runtime/electron/getPreloadMeta.ts +36 -0
- package/src/runtime/electron/index.ts +17 -0
- package/src/runtime/electron/promisifyApi.ts +102 -0
- package/src/runtime/electron/promisifyReply.ts +49 -0
- package/src/runtime/electron/registerDevtoolsShortcuts.ts +12 -0
- package/src/runtime/electron/static.ts +14 -0
- package/src/runtime/electron/types.ts +1 -0
- package/src/runtime/electron/useDevDataDir.ts +8 -0
- package/src/runtime/electron/useNuxtRuntimeConfig.ts +7 -0
- package/src/runtime/utils/isElectron.ts +11 -0
package/dist/types.d.mts
ADDED
package/genDevDesktop.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { run } from "@alanscodelog/utils/run"
|
|
2
|
+
import JSON5 from "json5"
|
|
3
|
+
import fs from "node:fs/promises"
|
|
4
|
+
import path from "node:path"
|
|
5
|
+
|
|
6
|
+
if (["darwin", "linux"].includes(process.platform)) {
|
|
7
|
+
// eslint-disable-next-line no-console
|
|
8
|
+
console.log("Generating dev desktop file.")
|
|
9
|
+
} else {
|
|
10
|
+
process.exit(0)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const electronBuilderConfigPath = path.join(process.cwd(), "electron-builder.json5")
|
|
14
|
+
const electronBuilderConfig = JSON5.parse(await fs.readFile(electronBuilderConfigPath, "utf8"))
|
|
15
|
+
|
|
16
|
+
const desktopFile = electronBuilderConfig.linux?.desktop
|
|
17
|
+
|
|
18
|
+
desktopFile.Path = process.cwd()
|
|
19
|
+
desktopFile.Exec = process.argv[3] ?? `npm run launch:electron "%u"`
|
|
20
|
+
// desktopFile.Exec = `bash -c 'cd ${process.cwd()} && ${process.argv[3] ?? `npm run launch:electron %u'`}`
|
|
21
|
+
const contents = `[Desktop Entry]\n${
|
|
22
|
+
Object.entries(desktopFile).map(([key, value]) => `${key}=${value}`).join("\n")}`
|
|
23
|
+
const appName = process.argv[2]
|
|
24
|
+
|
|
25
|
+
if (!appName) {
|
|
26
|
+
throw new Error("You must pass the app name as the first argument.")
|
|
27
|
+
}
|
|
28
|
+
if (!process.env.HOME) {
|
|
29
|
+
throw new Error("HOME environment variable is not set.")
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const filepath = path.resolve(process.env.HOME, `./.local/share/applications/dev-${appName}.desktop`)
|
|
33
|
+
|
|
34
|
+
await run(`xdg-desktop-menu uninstall ${filepath}`).promise
|
|
35
|
+
// eslint-disable-next-line no-console
|
|
36
|
+
.catch((err) => { console.log(err) })
|
|
37
|
+
|
|
38
|
+
await fs.writeFile(filepath, contents)
|
|
39
|
+
await fs.chmod(filepath, "755")
|
|
40
|
+
|
|
41
|
+
await run(`xdg-desktop-menu install ${filepath}`).promise
|
|
42
|
+
|
|
43
|
+
.catch((err) => {
|
|
44
|
+
// eslint-disable-next-line no-console
|
|
45
|
+
console.log(err)
|
|
46
|
+
process.exit(1)
|
|
47
|
+
})
|
package/package.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@witchcraft/nuxt-electron",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Nuxt module for working with electron.",
|
|
5
|
+
"repository": "witchcraftjs/nuxt-electron",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/types.d.mts",
|
|
12
|
+
"import": "./dist/module.mjs"
|
|
13
|
+
},
|
|
14
|
+
"./electron": {
|
|
15
|
+
"types": "./dist/runtime/electron/index.d.ts",
|
|
16
|
+
"import": "./dist/runtime/electron/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./genDevDesktop": {
|
|
19
|
+
"import": "./genDevDesktop.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"src",
|
|
24
|
+
"dist",
|
|
25
|
+
"genDevDesktop.js"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"prepare": "husky && cd playground && pnpm i",
|
|
29
|
+
"build": "nuxt-module-build prepare && nuxt-module-build build && nuxi build playground",
|
|
30
|
+
"build:only": "nuxt-module-build build",
|
|
31
|
+
"dev": "nuxi dev playground",
|
|
32
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
33
|
+
"lint": "eslint \"{src,test,playground/app}/**/*.{ts,vue}\" \"*.{js,cjs,mjs,ts}\"",
|
|
34
|
+
"lint:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"test:watch": "vitest watch"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@alanscodelog/utils": "^6.0.1",
|
|
40
|
+
"@nuxt/kit": "^4.0.3",
|
|
41
|
+
"@witchcraft/nuxt-utils": "^0.2.1",
|
|
42
|
+
"defu": "^6.1.4",
|
|
43
|
+
"es-toolkit": "^1.39.10",
|
|
44
|
+
"vite-plugin-electron": "^0.29.0",
|
|
45
|
+
"vite-plugin-externalize-deps": "^0.9.0"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@witchcraft/ui": "^0.2.1",
|
|
49
|
+
"unplugin-icons": "^22.1.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"unplugin-icons": {
|
|
53
|
+
"optional": true
|
|
54
|
+
},
|
|
55
|
+
"@witchcraft/ui": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@alanscodelog/eslint-config": "^6.3.0",
|
|
61
|
+
"@alanscodelog/semantic-release-config": "^5.0.4",
|
|
62
|
+
"@alanscodelog/tsconfigs": "^6.1.0",
|
|
63
|
+
"@nuxt/eslint-config": "^1.9.0",
|
|
64
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
65
|
+
"@nuxt/schema": "^4.0.3",
|
|
66
|
+
"@nuxt/test-utils": "^3.19.2",
|
|
67
|
+
"@types/node": "latest",
|
|
68
|
+
"@witchcraft/ui": "^0.2.1",
|
|
69
|
+
"changelogen": "^0.6.2",
|
|
70
|
+
"electron": "^34.5.8",
|
|
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.2.0",
|
|
77
|
+
"vitest": "^3.2.4",
|
|
78
|
+
"vue-tsc": "^3.0.6"
|
|
79
|
+
},
|
|
80
|
+
"release": {
|
|
81
|
+
"extends": [
|
|
82
|
+
"@alanscodelog/semantic-release-config"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
"commitlint": {
|
|
86
|
+
"extends": [
|
|
87
|
+
"@alanscodelog"
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
"publishConfig": {
|
|
91
|
+
"access": "public"
|
|
92
|
+
}
|
|
93
|
+
}
|