create-packer 1.45.19 → 1.45.20

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 (64) hide show
  1. package/package.json +1 -1
  2. package/template/electron-vue/.editorconfig +14 -0
  3. package/template/electron-vue/.env +3 -0
  4. package/template/electron-vue/.env.development +3 -0
  5. package/template/electron-vue/.gitignore +28 -0
  6. package/template/electron-vue/.husky/commit-msg +4 -0
  7. package/template/electron-vue/.husky/pre-commit +4 -0
  8. package/template/electron-vue/.prettierignore +6 -0
  9. package/template/electron-vue/.prettierrc +18 -0
  10. package/template/electron-vue/.stylelintignore +4 -0
  11. package/template/electron-vue/.stylelintrc +35 -0
  12. package/template/electron-vue/.vscode/extensions.json +9 -0
  13. package/template/electron-vue/README.md +14 -0
  14. package/template/electron-vue/assets/rspack.png +0 -0
  15. package/template/electron-vue/build.config.json +40 -0
  16. package/template/electron-vue/commitlint.config.cjs +1 -0
  17. package/template/electron-vue/configs/clean.ts +10 -0
  18. package/template/electron-vue/configs/config.ts +25 -0
  19. package/template/electron-vue/configs/createChunks.ts +26 -0
  20. package/template/electron-vue/configs/rsbuild.main.config.ts +54 -0
  21. package/template/electron-vue/configs/rsbuild.preload.config.ts +54 -0
  22. package/template/electron-vue/configs/rsbuild.renderer.config.ts +64 -0
  23. package/template/electron-vue/env.d.ts +18 -0
  24. package/template/electron-vue/eslint.config.mjs +115 -0
  25. package/template/electron-vue/main/main.ts +83 -0
  26. package/template/electron-vue/main/tools/html.ts +8 -0
  27. package/template/electron-vue/main/tools/index.ts +1 -0
  28. package/template/electron-vue/package.json +87 -0
  29. package/template/electron-vue/pnpm-lock.yaml +10158 -0
  30. package/template/electron-vue/postcss.config.cjs +9 -0
  31. package/template/electron-vue/preload/index.ts +1 -0
  32. package/template/electron-vue/preload/toolr.ts +26 -0
  33. package/template/electron-vue/renderer/domain/app/app.ts +4 -0
  34. package/template/electron-vue/renderer/domain/app/components/app.vue +18 -0
  35. package/template/electron-vue/renderer/domain/app/components/index.ts +1 -0
  36. package/template/electron-vue/renderer/domain/app/createComponentInstance.ts +43 -0
  37. package/template/electron-vue/renderer/domain/app/index.ts +3 -0
  38. package/template/electron-vue/renderer/domain/router/home/index.ts +2 -0
  39. package/template/electron-vue/renderer/domain/router/home/names.ts +3 -0
  40. package/template/electron-vue/renderer/domain/router/home/routes.ts +8 -0
  41. package/template/electron-vue/renderer/domain/router/index.ts +26 -0
  42. package/template/electron-vue/renderer/domain/router/names.ts +5 -0
  43. package/template/electron-vue/renderer/index.html +11 -0
  44. package/template/electron-vue/renderer/main.css +4 -0
  45. package/template/electron-vue/renderer/main.ts +6 -0
  46. package/template/electron-vue/renderer/pages/home/index.ts +1 -0
  47. package/template/electron-vue/renderer/pages/home/view.vue +12 -0
  48. package/template/electron-vue/renderer/pages/index.ts +1 -0
  49. package/template/electron-vue/renderer/pages/index.vue +3 -0
  50. package/template/electron-vue/renderer/pages/not-found.vue +3 -0
  51. package/template/electron-vue/renderer/public/vite.svg +1 -0
  52. package/template/electron-vue/renderer/shared/assets/vue.svg +1 -0
  53. package/template/electron-vue/renderer/shared/components/index.ts +0 -0
  54. package/template/electron-vue/renderer/shared/constant/index.ts +0 -0
  55. package/template/electron-vue/renderer/shared/hooks/index.ts +2 -0
  56. package/template/electron-vue/renderer/shared/hooks/useList.ts +86 -0
  57. package/template/electron-vue/renderer/shared/hooks/useVisible.ts +27 -0
  58. package/template/electron-vue/renderer/shared/service/api.ts +1 -0
  59. package/template/electron-vue/renderer/shared/service/home.ts +7 -0
  60. package/template/electron-vue/renderer/shared/service/index.ts +3 -0
  61. package/template/electron-vue/renderer/shared/service/request.ts +5 -0
  62. package/template/electron-vue/renderer/shared/tools/index.ts +0 -0
  63. package/template/electron-vue/tsconfig.json +25 -0
  64. package/template/electron-vue/tsconfig.node.json +10 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-packer",
3
- "version": "1.45.19",
3
+ "version": "1.45.20",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/kevily/create-packer",
6
6
  "author": "1k <bug_zero@163.com>",
@@ -0,0 +1,14 @@
1
+ # editorconfig.org
2
+
3
+ root = true
4
+
5
+ [*]
6
+ charset = utf-8
7
+ indent_size = 4
8
+ indent_style = space
9
+ insert_final_newline = true
10
+ trim_trailing_whitespace = true
11
+
12
+
13
+ [*.md]
14
+ trim_trailing_whitespace = false
@@ -0,0 +1,3 @@
1
+ PUBLIC_ENV_MODE=production
2
+ PUBLIC_BASE_URL=/
3
+ PUBLIC_API_HOST=/
@@ -0,0 +1,3 @@
1
+ PUBLIC_ENV_MODE=development
2
+ PUBLIC_BASE_URL=/dev
3
+ PUBLIC_API_HOST=/api
@@ -0,0 +1,28 @@
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ pnpm-debug.log*
8
+ lerna-debug.log*
9
+
10
+ node_modules
11
+ dist
12
+ build
13
+ dist-ssr
14
+ *.local
15
+ stats.html
16
+ vite.config.ts.*
17
+
18
+ # Editor directories and files
19
+ .vscode/*
20
+ !.vscode/extensions.json
21
+ .history
22
+ .idea
23
+ .DS_Store
24
+ *.suo
25
+ *.ntvs*
26
+ *.njsproj
27
+ *.sln
28
+ *.sw?
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npx --no -- commitlint --edit
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npm run lint
@@ -0,0 +1,6 @@
1
+ **/*.md
2
+ **/*.svg
3
+ **/*.ejs
4
+ **/*.html
5
+ .history
6
+ dist
@@ -0,0 +1,18 @@
1
+ {
2
+ "overrides": [
3
+ {
4
+ "files": ".prettierrc",
5
+ "options": { "parser": "json" }
6
+ }
7
+ ],
8
+ "printWidth": 100,
9
+ "tabWidth": 4,
10
+ "useTabs": false,
11
+ "semi": false,
12
+ "singleQuote": true,
13
+ "trailingComma": "none",
14
+ "bracketSpacing": true,
15
+ "bracketSameLine": false,
16
+ "arrowParens": "avoid",
17
+ "rangeStart": 0
18
+ }
@@ -0,0 +1,4 @@
1
+ node_modules
2
+ /dist
3
+ /.vscode
4
+ /.history
@@ -0,0 +1,35 @@
1
+ {
2
+ "extends": "stylelint-config-standard-scss",
3
+ "overrides": [
4
+ {
5
+ "files": ["*.html", "**/*.html", "*.vue", "**/*.vue"],
6
+ "customSyntax": "postcss-html"
7
+ }
8
+ ],
9
+ "rules": {
10
+ "comment-empty-line-before": "never",
11
+ "no-empty-source": null,
12
+ "alpha-value-notation": null,
13
+ "color-function-notation": null,
14
+ "at-rule-no-unknown": [
15
+ true,
16
+ {
17
+ "ignoreAtRules": ["tailwind", "apply", "use", "reference"]
18
+ }
19
+ ],
20
+ "declaration-block-no-redundant-longhand-properties": null,
21
+ "selector-pseudo-class-no-unknown": [
22
+ true,
23
+ {
24
+ "ignorePseudoClasses": ["global"]
25
+ }
26
+ ],
27
+ "selector-class-pattern": null,
28
+ "scss/at-rule-no-unknown": [
29
+ true,
30
+ {
31
+ "ignoreAtRules": ["tailwind", "apply", "reference"]
32
+ }
33
+ ]
34
+ }
35
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "recommendations": [
3
+ "vue.volar",
4
+ "vue.vscode-typescript-vue-plugin",
5
+ "dbaeumer.vscode-eslint",
6
+ "stylelint.vscode-stylelint",
7
+ "esbenp.prettier-vscode"
8
+ ]
9
+ }
@@ -0,0 +1,14 @@
1
+ ## Vite + Vue3.x + Typescript
2
+
3
+ ### Features
4
+
5
+ - Vite
6
+ - Vue
7
+ - Typescript
8
+ - vue-router
9
+ - pinia
10
+ - Tailwindcss
11
+ - Eslint
12
+ - Prettier
13
+ - axios
14
+ - Alias @ to <project_root>/src
@@ -0,0 +1,40 @@
1
+ {
2
+ "productName": "ElectronReact",
3
+ "appId": "org.erb.ElectronReact",
4
+ "asar": false,
5
+ "files": ["dist"],
6
+ "mac": {
7
+ "target": {
8
+ "target": "default",
9
+ "arch": ["arm64", "x64"]
10
+ },
11
+ "hardenedRuntime": true,
12
+ "gatekeeperAssess": true
13
+ },
14
+ "dmg": {
15
+ "contents": [
16
+ {
17
+ "x": 130,
18
+ "y": 220
19
+ },
20
+ {
21
+ "x": 410,
22
+ "y": 220,
23
+ "type": "link",
24
+ "path": "/Applications"
25
+ }
26
+ ]
27
+ },
28
+ "win": {
29
+ "target": ["nsis"]
30
+ },
31
+ "linux": {
32
+ "target": ["AppImage"],
33
+ "category": "Development"
34
+ },
35
+ "directories": {
36
+ "buildResources": "dist",
37
+ "output": "build"
38
+ },
39
+ "extraResources": ["./assets/**"]
40
+ }
@@ -0,0 +1 @@
1
+ module.exports = { extends: ['@commitlint/config-conventional'] }
@@ -0,0 +1,10 @@
1
+ import fs from 'fs'
2
+ import path from 'path'
3
+ import { rimrafSync } from 'rimraf'
4
+ import { OUTPUT_ROOT } from './config'
5
+
6
+ const foldersToRemove = [path.join(process.cwd(), OUTPUT_ROOT)]
7
+
8
+ foldersToRemove.forEach(folder => {
9
+ if (fs.existsSync(folder)) rimrafSync(folder)
10
+ })
@@ -0,0 +1,25 @@
1
+ import { ConfigParams } from '@rsbuild/core'
2
+ import { pluginEslint } from '@rsbuild/plugin-eslint'
3
+ import StylelintWebpackPlugin from 'stylelint-webpack-plugin'
4
+ import { pluginTypeCheck } from '@rsbuild/plugin-type-check'
5
+ import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin'
6
+
7
+ export function createPlugins({ command }: Pick<ConfigParams, 'command'>) {
8
+ return {
9
+ plugins: [
10
+ command !== 'build' && pluginTypeCheck(),
11
+ command !== 'build' &&
12
+ pluginEslint({
13
+ eslintPluginOptions: {
14
+ configType: 'flat'
15
+ }
16
+ })
17
+ ],
18
+ rspackPlugin: [
19
+ new StylelintWebpackPlugin(),
20
+ process.env.RSDOCTOR && new RsdoctorRspackPlugin()
21
+ ]
22
+ }
23
+ }
24
+
25
+ export const OUTPUT_ROOT = 'dist'
@@ -0,0 +1,26 @@
1
+ import { SplitChunks } from '@rsbuild/core'
2
+
3
+ export function createChunks(
4
+ chunks: Array<{ name: string; libs: string[] | RegExp; priority?: number }>
5
+ ) {
6
+ const result: Exclude<SplitChunks, false>['cacheGroups'] = {
7
+ vendors: {
8
+ test: /[\\/]node_modules[\\/]/,
9
+ chunks: 'all',
10
+ name: 'vendors',
11
+ priority: -1
12
+ }
13
+ }
14
+ chunks.forEach(({ name, libs, priority }) => {
15
+ result[name] = {
16
+ test: Array.isArray(libs)
17
+ ? new RegExp(`[\\\\/]node_modules[\\\\/](${libs.join('|')})[\\\\/]`)
18
+ : libs,
19
+ chunks: 'all',
20
+ name,
21
+ priority
22
+ }
23
+ return result
24
+ })
25
+ return result
26
+ }
@@ -0,0 +1,54 @@
1
+ import { defineConfig, loadEnv } from '@rsbuild/core'
2
+ import { createPlugins, OUTPUT_ROOT } from './config'
3
+
4
+ export default defineConfig(({ envMode, command }) => {
5
+ const { parsed: env } = loadEnv()
6
+ const { rspackPlugin, plugins } = createPlugins({ command })
7
+ return {
8
+ source: {
9
+ entry: {
10
+ main: './main/main.ts'
11
+ }
12
+ },
13
+ resolve: {
14
+ alias: {
15
+ '@': process.cwd()
16
+ }
17
+ },
18
+ output: {
19
+ distPath: { root: `${OUTPUT_ROOT}/main`, js: '' },
20
+ cleanDistPath: false,
21
+ filenameHash: false
22
+ },
23
+ dev: {
24
+ progressBar: command === 'build',
25
+ writeToDisk: true,
26
+ hmr: false,
27
+ liveReload: false
28
+ },
29
+ tools: {
30
+ htmlPlugin: false,
31
+ rspack: {
32
+ target: 'electron-main',
33
+ plugins: rspackPlugin
34
+ }
35
+ },
36
+ plugins,
37
+ performance: {
38
+ removeConsole: command === 'build' ? ['log'] : false,
39
+ bundleAnalyze: envMode === 'analyse' ? { openAnalyzer: true } : void 0
40
+ },
41
+ server: {
42
+ base: env.PUBLIC_BASE_URL,
43
+ host: '0.0.0.0',
44
+ port: 3001,
45
+ compress: false,
46
+ proxy: [
47
+ {
48
+ context: [env.PUBLIC_API_HOST],
49
+ target: 'http://127.0.0.1:3000'
50
+ }
51
+ ]
52
+ }
53
+ }
54
+ })
@@ -0,0 +1,54 @@
1
+ import { defineConfig, loadEnv } from '@rsbuild/core'
2
+ import { createPlugins, OUTPUT_ROOT } from './config'
3
+
4
+ export default defineConfig(({ envMode, command }) => {
5
+ const { parsed: env } = loadEnv()
6
+ const { rspackPlugin, plugins } = createPlugins({ command })
7
+ return {
8
+ source: {
9
+ entry: {
10
+ preload: './preload/index.ts'
11
+ }
12
+ },
13
+ resolve: {
14
+ alias: {
15
+ '@': process.cwd()
16
+ }
17
+ },
18
+ output: {
19
+ distPath: { root: OUTPUT_ROOT, js: '' },
20
+ cleanDistPath: false,
21
+ filenameHash: false
22
+ },
23
+ dev: {
24
+ progressBar: command === 'build',
25
+ writeToDisk: true,
26
+ hmr: false,
27
+ liveReload: false
28
+ },
29
+ tools: {
30
+ htmlPlugin: false,
31
+ rspack: {
32
+ target: 'electron-preload',
33
+ plugins: rspackPlugin
34
+ }
35
+ },
36
+ plugins,
37
+ performance: {
38
+ removeConsole: command === 'build' ? ['log'] : false,
39
+ bundleAnalyze: envMode === 'analyse' ? { openAnalyzer: true } : void 0
40
+ },
41
+ server: {
42
+ base: env.PUBLIC_BASE_URL,
43
+ host: '0.0.0.0',
44
+ port: 3002,
45
+ compress: false,
46
+ proxy: [
47
+ {
48
+ context: [env.PUBLIC_API_HOST],
49
+ target: 'http://127.0.0.1:3000'
50
+ }
51
+ ]
52
+ }
53
+ }
54
+ })
@@ -0,0 +1,64 @@
1
+ import path from 'node:path'
2
+ import { defineConfig, loadEnv } from '@rsbuild/core'
3
+ import { pluginVue } from '@rsbuild/plugin-vue'
4
+ import { createChunks } from './createChunks'
5
+ import { createPlugins, OUTPUT_ROOT } from './config'
6
+
7
+ export default defineConfig(({ envMode, command }) => {
8
+ const { parsed: env } = loadEnv()
9
+ const { rspackPlugin, plugins } = createPlugins({ command })
10
+ const resolveRendererPath = (p: string) => path.resolve('renderer', p)
11
+ return {
12
+ html: {
13
+ template: resolveRendererPath('index.html'),
14
+ title: 'Rsbuild + Vue + TS',
15
+ favicon: resolveRendererPath('shared/assets/vue.svg')
16
+ },
17
+ source: {
18
+ entry: {
19
+ index: resolveRendererPath('main.ts')
20
+ }
21
+ },
22
+ resolve: {
23
+ alias: {
24
+ '@': process.cwd()
25
+ }
26
+ },
27
+ output: {
28
+ distPath: { root: `${OUTPUT_ROOT}/renderer` },
29
+ assetPrefix: './',
30
+ cleanDistPath: false
31
+ },
32
+ dev: {
33
+ progressBar: command === 'build'
34
+ },
35
+ tools: {
36
+ rspack: {
37
+ plugins: rspackPlugin
38
+ }
39
+ },
40
+ plugins: [...plugins, pluginVue()],
41
+ performance: {
42
+ removeConsole: command === 'build' ? ['log'] : false,
43
+ chunkSplit: {
44
+ strategy: 'custom',
45
+ splitChunks: {
46
+ minChunks: 1,
47
+ cacheGroups: createChunks([{ libs: ['vue', 'vue-router'], name: 'vue' }])
48
+ }
49
+ },
50
+ bundleAnalyze: envMode === 'analyse' ? { openAnalyzer: true } : void 0
51
+ },
52
+ server: {
53
+ base: env.PUBLIC_BASE_URL,
54
+ host: '0.0.0.0',
55
+ compress: false,
56
+ proxy: [
57
+ {
58
+ context: [env.PUBLIC_API_HOST],
59
+ target: 'http://127.0.0.1:3000'
60
+ }
61
+ ]
62
+ }
63
+ }
64
+ })
@@ -0,0 +1,18 @@
1
+ /// <reference types="@rsbuild/core/types" />
2
+
3
+ declare module '*.vue' {
4
+ import { type DefineComponent } from 'vue'
5
+ const component: DefineComponent<Record<string, any>, Record<string, any>, any>
6
+ export default component
7
+ }
8
+
9
+ interface ImportMetaEnv {
10
+ readonly PUBLIC_BASE_URL: string
11
+ readonly PUBLIC_API_HOST: string
12
+ readonly PUBLIC_ENV_MODE: 'production' | 'development'
13
+ // 更多环境变量...
14
+ }
15
+
16
+ interface ImportMeta {
17
+ readonly env: ImportMetaEnv
18
+ }
@@ -0,0 +1,115 @@
1
+ import eslint from '@eslint/js'
2
+ import globals from 'globals'
3
+ import tseslint from 'typescript-eslint'
4
+ import importPlugin from 'eslint-plugin-import'
5
+ import pluginVue from 'eslint-plugin-vue'
6
+
7
+ const scriptExtensions = ['js', 'jsx', 'mjs', 'cjs', 'ts', 'tsx']
8
+ const files = [...scriptExtensions.map(ext => `**/*.${ext}`), '**/*.vue']
9
+
10
+ export default tseslint.config([
11
+ { ignores: ['**/node_modules/', 'dist/', '.history/', '.vscode'] },
12
+ eslint.configs.recommended,
13
+ importPlugin.flatConfigs.recommended,
14
+ tseslint.configs.recommended,
15
+ pluginVue.configs['flat/recommended'],
16
+ {
17
+ files,
18
+ languageOptions: {
19
+ ecmaVersion: 2018,
20
+ sourceType: 'module',
21
+ parserOptions: {
22
+ ecmaFeatures: {
23
+ jsx: true
24
+ },
25
+ useJSXTextNode: true,
26
+ parser: tseslint.parser
27
+ },
28
+ globals: {
29
+ ...globals.browser,
30
+ ...globals.node
31
+ }
32
+ },
33
+ settings: {
34
+ 'import/resolver': {
35
+ typescript: true,
36
+ node: true
37
+ }
38
+ },
39
+ rules: {
40
+ 'import/export': 'off',
41
+ 'import/namespace': 'off',
42
+ 'import/default': 'off',
43
+ 'import/consistent-type-specifier-style': ['error', 'prefer-inline'],
44
+ 'import/no-duplicates': ['error', { 'prefer-inline': true }],
45
+ 'import/no-named-as-default-member': 'off',
46
+ 'import/no-named-as-default': 'off',
47
+ 'import/order': [
48
+ 'error',
49
+ {
50
+ groups: [
51
+ 'builtin',
52
+ 'external',
53
+ 'internal',
54
+ 'parent',
55
+ 'sibling',
56
+ 'index',
57
+ 'object',
58
+ 'type'
59
+ ],
60
+ pathGroups: [
61
+ { pattern: 'vue', group: 'external', position: 'before' },
62
+ { pattern: 'vue-router', group: 'external', position: 'before' }
63
+ ],
64
+ pathGroupsExcludedImportTypes: ['builtin']
65
+ }
66
+ ],
67
+ 'no-case-declarations': 'off',
68
+ '@typescript-eslint/no-unused-expressions': 'off',
69
+ '@typescript-eslint/no-empty-object-type': 'off',
70
+ '@typescript-eslint/no-var-requires': 0,
71
+ '@typescript-eslint/explicit-function-return-type': 'off',
72
+ '@typescript-eslint/no-explicit-any': 0,
73
+ '@typescript-eslint/no-non-null-assertion': 'off',
74
+ '@typescript-eslint/no-inferrable-types': [
75
+ 'warn',
76
+ {
77
+ ignoreParameters: true
78
+ }
79
+ ],
80
+ '@typescript-eslint/no-unused-vars': [
81
+ 'warn',
82
+ {
83
+ argsIgnorePattern: '^_'
84
+ }
85
+ ],
86
+ '@typescript-eslint/member-delimiter-style': 0,
87
+ '@typescript-eslint/class-name-casing': 0,
88
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
89
+ '@typescript-eslint/ban-ts-comment': 'off',
90
+ '@typescript-eslint/no-empty-interface': 'off',
91
+ '@typescript-eslint/triple-slash-reference': 'off',
92
+ "@typescript-eslint/no-require-imports": 'off',
93
+ 'vue/multi-word-component-names': 0,
94
+ 'vue/html-indent': ['error', 4],
95
+ 'vue/require-default-prop': 'off',
96
+ 'vue/one-component-per-file': 'off',
97
+ 'vue/no-dupe-keys': 'off',
98
+ 'vue/html-self-closing': [
99
+ 'error',
100
+ {
101
+ html: {
102
+ void: 'always',
103
+ normal: 'always',
104
+ component: 'always'
105
+ },
106
+ svg: 'always',
107
+ math: 'always'
108
+ }
109
+ ],
110
+ 'vue/max-attributes-per-line': 'off',
111
+ 'vue/singleline-html-element-content-newline': 'off',
112
+ 'no-constant-condition': 'off'
113
+ }
114
+ }
115
+ ])
@@ -0,0 +1,83 @@
1
+ import path from 'path'
2
+ import { app, BrowserWindow, shell, ipcMain } from 'electron'
3
+ import { resolveHtmlPath } from './tools'
4
+
5
+ let mainWindow: BrowserWindow | null = null
6
+
7
+ ipcMain.on('ipc-example', async (event, arg) => {
8
+ const msgTemplate = (pingPong: string) => `IPC test: ${pingPong}`
9
+ console.log(msgTemplate(arg))
10
+ event.reply('ipc-example', msgTemplate('pong'))
11
+ })
12
+
13
+ const isDebug = process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true'
14
+
15
+ if (true) {
16
+ require('electron-debug').default()
17
+ }
18
+
19
+ const createWindow = async () => {
20
+ const RESOURCES_PATH = app.isPackaged
21
+ ? path.join(process.resourcesPath, 'assets')
22
+ : path.join(__dirname, '../../assets')
23
+
24
+ const getAssetPath = (...paths: string[]): string => {
25
+ return path.join(RESOURCES_PATH, ...paths)
26
+ }
27
+
28
+ mainWindow = new BrowserWindow({
29
+ show: false,
30
+ width: 1024,
31
+ height: 728,
32
+ icon: getAssetPath('icon.png'),
33
+ webPreferences: {
34
+ preload: path.join(__dirname, '../preload.js')
35
+ }
36
+ })
37
+
38
+ mainWindow.loadURL(resolveHtmlPath('index.html'))
39
+
40
+ mainWindow.on('ready-to-show', () => {
41
+ if (!mainWindow) {
42
+ throw new Error('"mainWindow" is not defined')
43
+ }
44
+ if (process.env.START_MINIMIZED) {
45
+ mainWindow.minimize()
46
+ } else {
47
+ mainWindow.show()
48
+ }
49
+ })
50
+
51
+ mainWindow.on('closed', () => {
52
+ mainWindow = null
53
+ })
54
+
55
+ // Open urls in the user's browser
56
+ mainWindow.webContents.setWindowOpenHandler(edata => {
57
+ shell.openExternal(edata.url)
58
+ return { action: 'deny' }
59
+ })
60
+ }
61
+
62
+ /**
63
+ * Add event listeners...
64
+ */
65
+
66
+ app.on('window-all-closed', () => {
67
+ // Respect the OSX convention of having the application in memory even
68
+ // after all windows have been closed
69
+ if (process.platform !== 'darwin') {
70
+ app.quit()
71
+ }
72
+ })
73
+
74
+ app.whenReady()
75
+ .then(() => {
76
+ createWindow()
77
+ app.on('activate', () => {
78
+ // On macOS it's common to re-create a window in the app when the
79
+ // dock icon is clicked and there are no other windows open.
80
+ if (mainWindow === null) createWindow()
81
+ })
82
+ })
83
+ .catch(console.log)