@tomjs/vite-plugin-electron 1.9.3 → 2.0.0
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 +55 -39
- package/README.zh_CN.md +55 -39
- package/dist/electron-BUQU2XNS.mjs +8 -0
- package/dist/electron.d.mts +7 -0
- package/dist/electron.mjs +3 -0
- package/dist/index.d.mts +107 -106
- package/dist/index.mjs +406 -444
- package/package.json +48 -59
- package/dist/index.d.ts +0 -135
- package/dist/index.js +0 -493
package/package.json
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomjs/vite-plugin-electron",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "2.0.0",
|
|
4
5
|
"description": "A simple vite plugin for electron, supports esm/cjs, support esm in electron v28+",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Tom Gao",
|
|
8
|
+
"email": "tom@tomgao.cc"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/tomjs/vite-plugin-electron.git"
|
|
14
|
+
},
|
|
5
15
|
"keywords": [
|
|
6
16
|
"vite",
|
|
7
17
|
"plugin",
|
|
@@ -10,89 +20,68 @@
|
|
|
10
20
|
"esm",
|
|
11
21
|
"cjs"
|
|
12
22
|
],
|
|
13
|
-
"author": {
|
|
14
|
-
"name": "Tom Gao",
|
|
15
|
-
"email": "tom@tomgao.cc"
|
|
16
|
-
},
|
|
17
|
-
"license": "MIT",
|
|
18
|
-
"main": "./dist/index.js",
|
|
19
|
-
"module": "./dist/index.mjs",
|
|
20
|
-
"types": "./dist/index.d.ts",
|
|
21
23
|
"exports": {
|
|
22
|
-
".":
|
|
23
|
-
|
|
24
|
-
"default": "./dist/index.js",
|
|
25
|
-
"types": "./dist/index.d.ts"
|
|
26
|
-
},
|
|
27
|
-
"import": {
|
|
28
|
-
"default": "./dist/index.mjs",
|
|
29
|
-
"types": "./dist/index.d.mts"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
24
|
+
".": "./dist/index.mjs",
|
|
25
|
+
"./electron": "./dist/electron.mjs"
|
|
32
26
|
},
|
|
27
|
+
"module": "./dist/index.mjs",
|
|
28
|
+
"types": "./dist/index.d.mts",
|
|
33
29
|
"files": [
|
|
34
30
|
"dist",
|
|
35
31
|
"env.d.ts"
|
|
36
32
|
],
|
|
37
33
|
"engines": {
|
|
38
|
-
"node": ">=
|
|
34
|
+
"node": ">=20.19.0"
|
|
39
35
|
},
|
|
40
36
|
"publishConfig": {
|
|
41
37
|
"access": "public",
|
|
42
38
|
"registry": "https://registry.npmjs.org/"
|
|
43
39
|
},
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"electron": ">=12.0.0",
|
|
42
|
+
"electron-builder": ">=24.2.0",
|
|
43
|
+
"vite": ">=2.9.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependenciesMeta": {
|
|
46
|
+
"electron-builder": {
|
|
47
|
+
"optional": true
|
|
48
|
+
}
|
|
47
49
|
},
|
|
48
50
|
"dependencies": {
|
|
49
|
-
"dayjs": "^1.11.
|
|
51
|
+
"dayjs": "^1.11.18",
|
|
52
|
+
"execa": "^8.0.1",
|
|
50
53
|
"kolorist": "^1.8.0",
|
|
51
54
|
"lodash.clonedeep": "^4.5.0",
|
|
52
55
|
"lodash.merge": "^4.6.2",
|
|
53
|
-
"shelljs": "^0.
|
|
54
|
-
"
|
|
55
|
-
"tsup": "7.2.0"
|
|
56
|
+
"shelljs": "^0.10.0",
|
|
57
|
+
"tsdown": "~0.16.4"
|
|
56
58
|
},
|
|
57
59
|
"devDependencies": {
|
|
58
|
-
"@commitlint/cli": "^19.
|
|
59
|
-
"@tomjs/commitlint": "^
|
|
60
|
-
"@tomjs/eslint": "^
|
|
61
|
-
"@tomjs/
|
|
62
|
-
"@tomjs/
|
|
63
|
-
"@tomjs/tsconfig": "^1.7.1",
|
|
60
|
+
"@commitlint/cli": "^19.8.1",
|
|
61
|
+
"@tomjs/commitlint": "^4.0.0",
|
|
62
|
+
"@tomjs/eslint": "^5.2.0",
|
|
63
|
+
"@tomjs/stylelint": "^6.0.0",
|
|
64
|
+
"@tomjs/tsconfig": "^2.0.0",
|
|
64
65
|
"@types/lodash.clonedeep": "^4.5.9",
|
|
65
66
|
"@types/lodash.merge": "^4.6.9",
|
|
66
|
-
"@types/node": "^
|
|
67
|
-
"@types/shelljs": "^0.8.
|
|
68
|
-
"eslint": "^
|
|
69
|
-
"
|
|
70
|
-
"lint-staged": "^15.2.7",
|
|
67
|
+
"@types/node": "^20.19.25",
|
|
68
|
+
"@types/shelljs": "^0.8.17",
|
|
69
|
+
"eslint": "^9.35.0",
|
|
70
|
+
"lint-staged": "^16.1.6",
|
|
71
71
|
"npm-run-all": "^4.1.5",
|
|
72
|
-
"
|
|
72
|
+
"publint": "^0.3.15",
|
|
73
73
|
"rimraf": "^6.0.1",
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"tsx": "^4.
|
|
77
|
-
"typescript": "~5.
|
|
78
|
-
|
|
79
|
-
"peerDependencies": {
|
|
80
|
-
"electron": ">=12.0.0",
|
|
81
|
-
"electron-builder": ">=24.2.0",
|
|
82
|
-
"vite": ">=2.9.0"
|
|
83
|
-
},
|
|
84
|
-
"peerDependenciesMeta": {
|
|
85
|
-
"electron-builder": {
|
|
86
|
-
"optional": true
|
|
87
|
-
}
|
|
74
|
+
"simple-git-hooks": "^2.13.1",
|
|
75
|
+
"stylelint": "^16.24.0",
|
|
76
|
+
"tsx": "^4.20.5",
|
|
77
|
+
"typescript": "~5.9.2",
|
|
78
|
+
"vite": "^6.3.6"
|
|
88
79
|
},
|
|
89
|
-
"packageManager": "pnpm@8.15.8",
|
|
90
80
|
"scripts": {
|
|
91
|
-
"dev": "
|
|
92
|
-
"build": "
|
|
93
|
-
"lint": "run-s lint:
|
|
94
|
-
"lint:eslint": "eslint \"{src,examples}/**/*.{js,cjs,ts,tsx,vue}\" *.{js,cjs,ts} --fix --cache",
|
|
81
|
+
"dev": "tsdown --watch",
|
|
82
|
+
"build": "tsdown",
|
|
83
|
+
"lint": "run-s lint:stylelint lint:eslint",
|
|
95
84
|
"lint:stylelint": "stylelint \"examples/**/*.{css,scss,less,vue,html}\" --fix --cache",
|
|
96
|
-
"lint:
|
|
85
|
+
"lint:eslint": "eslint --fix"
|
|
97
86
|
}
|
|
98
87
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { Plugin } from 'vite';
|
|
2
|
-
import { Configuration } from 'electron-builder';
|
|
3
|
-
import { Options } from 'tsup';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Electron main process options. See [tsup](https://tsup.egoist.dev/) and [API Doc](https://www.jsdocs.io/package/tsup) for more information.
|
|
7
|
-
* @see https://www.jsdocs.io/package/tsup
|
|
8
|
-
* @see https://unpkg.com/browse/tsup/dist/index.d.ts
|
|
9
|
-
*/
|
|
10
|
-
interface MainOptions extends Omit<Options, 'entry' | 'format' | 'outDir' | 'watch' | 'onSuccess'> {
|
|
11
|
-
/**
|
|
12
|
-
* The main process entry file.
|
|
13
|
-
*/
|
|
14
|
-
entry?: string;
|
|
15
|
-
/**
|
|
16
|
-
* The bundle format. If not specified, it will use the "type" field from package.json.
|
|
17
|
-
*/
|
|
18
|
-
format?: 'cjs' | 'esm';
|
|
19
|
-
/**
|
|
20
|
-
* The output directory for the main process files. Defaults to `"dist-electron/main"`.
|
|
21
|
-
* @default "dist-electron/main"
|
|
22
|
-
*/
|
|
23
|
-
outDir?: string;
|
|
24
|
-
/**
|
|
25
|
-
* A function that will be executed after the build succeeds.
|
|
26
|
-
*/
|
|
27
|
-
onSuccess?: () => Promise<void | undefined | (() => void | Promise<void>)>;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Electron preload process options. See [tsup](https://tsup.egoist.dev/) and [API Doc](https://www.jsdocs.io/package/tsup) for more information.
|
|
31
|
-
* @see https://www.jsdocs.io/package/tsup
|
|
32
|
-
* @see https://unpkg.com/browse/tsup/dist/index.d.ts
|
|
33
|
-
*/
|
|
34
|
-
interface PreloadOptions extends Omit<Options, 'entry' | 'format' | 'outDir' | 'watch' | 'onSuccess'> {
|
|
35
|
-
/**
|
|
36
|
-
* The preload process entry file
|
|
37
|
-
*/
|
|
38
|
-
entry?: string | string[] | Record<string, string>;
|
|
39
|
-
/**
|
|
40
|
-
* The bundle format. If not specified, it will use the "type" field from package.json.
|
|
41
|
-
*/
|
|
42
|
-
format?: 'cjs' | 'esm';
|
|
43
|
-
/**
|
|
44
|
-
* The output directory for the preload process files. Defaults is `"dist-electron/preload"`.
|
|
45
|
-
* @default "dist-electron/preload"
|
|
46
|
-
*/
|
|
47
|
-
outDir?: string;
|
|
48
|
-
/**
|
|
49
|
-
* A function that will be executed after the build succeeds.
|
|
50
|
-
*/
|
|
51
|
-
onSuccess?: () => Promise<void | undefined | (() => void | Promise<void>)>;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* When `recommended` and `builder.enable` are both `true`, use [electron-builder](https://www.electron.build) to package Electron applications.
|
|
55
|
-
*
|
|
56
|
-
* * In the `build.outDir` directory configured in vite, generate a new package.json based on the configuration and package.json, excluding non-dependencies.
|
|
57
|
-
* * Execute `npm install` and then package.
|
|
58
|
-
*/
|
|
59
|
-
interface BuilderOptions {
|
|
60
|
-
/**
|
|
61
|
-
* Whether to enable the [electron-builder](https://www.electron.build), the default is false.
|
|
62
|
-
* @default false
|
|
63
|
-
* @deprecated
|
|
64
|
-
*/
|
|
65
|
-
enable?: boolean;
|
|
66
|
-
/**
|
|
67
|
-
* The application id. Used as [CFBundleIdentifier](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102070) for MacOS and as
|
|
68
|
-
* [Application User Model ID](https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx) for Windows (NSIS target only, Squirrel.Windows not supported). It is strongly recommended that an explicit ID is set.
|
|
69
|
-
* @default com.electron.${name}
|
|
70
|
-
*/
|
|
71
|
-
appId?: string | null;
|
|
72
|
-
/**
|
|
73
|
-
* As [name](#Metadata-name), but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the [name property](https://docs.npmjs.com/files/package.json#name).
|
|
74
|
-
* If not specified inside of the `build` configuration, `productName` property defined at the top level of `package.json` is used. If not specified at the top level of `package.json`, [name property](https://docs.npmjs.com/files/package.json#name) is used.
|
|
75
|
-
*/
|
|
76
|
-
productName?: string | null;
|
|
77
|
-
/**
|
|
78
|
-
* The [electron-builder](https://www.electron.build/configuration/configuration) configuration.
|
|
79
|
-
*/
|
|
80
|
-
builderConfig?: Configuration;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* vite plugin options
|
|
84
|
-
*/
|
|
85
|
-
interface PluginOptions {
|
|
86
|
-
/**
|
|
87
|
-
* Recommended switch. Default is true.
|
|
88
|
-
* if true, will have the following default behavior:
|
|
89
|
-
* * will change the main/preload/renderer outDir to be parallel outDir;
|
|
90
|
-
* eg. if vite build.outDir is 'dist', will change main/preload/render to 'dist/main' and 'dist/preload' and 'dist/renderer'
|
|
91
|
-
* @default true
|
|
92
|
-
*/
|
|
93
|
-
recommended?: boolean;
|
|
94
|
-
/**
|
|
95
|
-
* Don't bundle these modules, but dependencies and peerDependencies in your package.json are always excluded. [See more](https://tsup.egoist.dev/#excluding-packages)
|
|
96
|
-
* @see https://tsup.egoist.dev/#excluding-packages
|
|
97
|
-
*/
|
|
98
|
-
external?: (string | RegExp)[];
|
|
99
|
-
/**
|
|
100
|
-
* electron main process options
|
|
101
|
-
*/
|
|
102
|
-
main?: MainOptions;
|
|
103
|
-
/**
|
|
104
|
-
* electron preload process options
|
|
105
|
-
*/
|
|
106
|
-
preload?: PreloadOptions;
|
|
107
|
-
/**
|
|
108
|
-
* When `recommended` and `builder.enable` are both `true`, use [electron-builder](https://www.electron.build) to package Electron applications.
|
|
109
|
-
*
|
|
110
|
-
* * In the `build.outDir` directory configured in vite, generate a new package.json based on the configuration and package.json, excluding non-dependencies.
|
|
111
|
-
* * Execute `npm install` and then package.
|
|
112
|
-
*/
|
|
113
|
-
builder?: boolean | BuilderOptions;
|
|
114
|
-
/**
|
|
115
|
-
* electron debug mode, don't startup electron. You can also use `process.env.VITE_ELECTRON_DEBUG`. Default is false.
|
|
116
|
-
* @default false
|
|
117
|
-
*/
|
|
118
|
-
debug?: boolean;
|
|
119
|
-
/**
|
|
120
|
-
* Electron will listen for V8 inspector protocol messages on the specified port, an external debugger will need to connect on this port.
|
|
121
|
-
* You can also use `process.env.VITE_ELECTRON_INSPECT`. See [debugging-main-process](https://www.electronjs.org/docs/latest/tutorial/debugging-main-process) for more information.
|
|
122
|
-
* The default port is false.
|
|
123
|
-
* @see https://www.electronjs.org/docs/latest/tutorial/debugging-main-process
|
|
124
|
-
* @default false
|
|
125
|
-
*/
|
|
126
|
-
inspect?: number | boolean;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* A simple vite plugin for electron
|
|
131
|
-
* @param options
|
|
132
|
-
*/
|
|
133
|
-
declare function useElectronPlugin(options?: PluginOptions): Plugin;
|
|
134
|
-
|
|
135
|
-
export { BuilderOptions, MainOptions, PluginOptions, PreloadOptions, useElectronPlugin as default, useElectronPlugin };
|