From 35e04a80e30e88724b977b85aad4d8bcedb52c13 Mon Sep 17 00:00:00 2001 From: leejooy96 Date: Thu, 12 Oct 2023 09:13:44 +0900 Subject: [PATCH] docs: update documents category, add preload script document --- docs/package-lock.json | 8 ++--- docs/package.json | 2 +- docs/src/.vitepress/config.mts | 7 ++-- .../main-and-renderer-process.md | 0 docs/src/Electron How To/preload-script.md | 20 +++++++++++ .../automated-testing.md | 0 .../build-configuration.md | 33 ++++++++++++------- .../getting-started.md | 0 .../install-local-documentation.md | 0 .../npm-scripts.md | 0 .../pre-configured-components.md | 0 .../project-structure.md | 0 12 files changed, 49 insertions(+), 21 deletions(-) rename docs/src/{ => Electron How To}/main-and-renderer-process.md (100%) create mode 100644 docs/src/Electron How To/preload-script.md rename docs/src/{ => Installation and Build}/automated-testing.md (100%) rename docs/src/{ => Installation and Build}/build-configuration.md (87%) rename docs/src/{ => Installation and Build}/getting-started.md (100%) rename docs/src/{ => Installation and Build}/install-local-documentation.md (100%) rename docs/src/{ => Installation and Build}/npm-scripts.md (100%) rename docs/src/{ => Project Structures}/pre-configured-components.md (100%) rename docs/src/{ => Project Structures}/project-structure.md (100%) diff --git a/docs/package-lock.json b/docs/package-lock.json index 35e5d86..9355121 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "vitepress": "^1.0.0-rc.20", - "vitepress-sidebar": "^1.17.0", + "vitepress-sidebar": "^1.18.0", "vue": "^3.3.4" }, "engines": { @@ -1277,9 +1277,9 @@ } }, "node_modules/vitepress-sidebar": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/vitepress-sidebar/-/vitepress-sidebar-1.17.0.tgz", - "integrity": "sha512-/emot28rHICDkCeGbrEMQYe+lUErQ+NfOA33NPElhsq5Def72ifPYLb1UFj9YfuH9Pda4gnStzynUHF8jKnMuA==", + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/vitepress-sidebar/-/vitepress-sidebar-1.18.0.tgz", + "integrity": "sha512-Ki9ZpNa0CUNr7kovAbAEJ5v4MEZi+dte8Bz3OxkQcjFqrOGfQGEoGATRgf9m6N741epLLB3PFdaUCN6ZH0zmhg==", "dependencies": { "gray-matter": "^4.0.3" }, diff --git a/docs/package.json b/docs/package.json index 93bd768..c10556e 100644 --- a/docs/package.json +++ b/docs/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "vitepress": "^1.0.0-rc.20", - "vitepress-sidebar": "^1.17.0", + "vitepress-sidebar": "^1.18.0", "vue": "^3.3.4" } } diff --git a/docs/src/.vitepress/config.mts b/docs/src/.vitepress/config.mts index ccde74c..2336ce3 100644 --- a/docs/src/.vitepress/config.mts +++ b/docs/src/.vitepress/config.mts @@ -22,10 +22,9 @@ export default { collapsed: false, useTitleFromFileHeading: true, manualSortFileNameByPriority: [ - 'getting-started.md', - 'build-configuration.md', - 'project-structure.md', - 'npm-scripts.md' + 'Installation and Build', + 'Project Structures', + 'Electron How To' ] }), socialLinks: [{ icon: 'github', link: repository.url.replace('.git', '') }] diff --git a/docs/src/main-and-renderer-process.md b/docs/src/Electron How To/main-and-renderer-process.md similarity index 100% rename from docs/src/main-and-renderer-process.md rename to docs/src/Electron How To/main-and-renderer-process.md diff --git a/docs/src/Electron How To/preload-script.md b/docs/src/Electron How To/preload-script.md new file mode 100644 index 0000000..698facf --- /dev/null +++ b/docs/src/Electron How To/preload-script.md @@ -0,0 +1,20 @@ +# Preload Script + +The preload script in Electron.js is a secure area designed for communication between the main and renderer processes. It is typically used for **[IPC communication](https://www.electronjs.org/docs/latest/tutorial/ipc)**. + +For more information, see the following articles https://www.electronjs.org/docs/latest/tutorial/tutorial-preload + +For compatibility and security with the latest version of Electron, we do not recommend using the old `electron/remote` module. If you want to utilize system events or Node scripts, it is recommended to do so in the main process, not the renderer. + +Vutron's preload script is located in the `src/preload` folder. To create a new IPC communication channel, add the channel name to the following variable to whitelist it for communication. + +* `mainAvailChannels`: Send an event from main to renderer. (`window.mainApi.send('channelName'')`) +* `rendererAvailChannels`: Send an event from renderer to main. (`mainWindow.webContents.send('channelName')`) + +When sending events from renderer to main, you access the `window.mainApi` object instead of `ipcRenderer.send`. The `mainApi` is the name you set in your Vutron template and can be changed. + +Here are the supported functions for mainApi: (To change and modify this, you need to modify `exposeInMainWorld` in `src/preload/index.ts`). + +* `send`: Send an event to main. +* `receive`: A listener to receive events sent by main. +* `invoke`: Functions that can send events to main and receive data asynchronously. diff --git a/docs/src/automated-testing.md b/docs/src/Installation and Build/automated-testing.md similarity index 100% rename from docs/src/automated-testing.md rename to docs/src/Installation and Build/automated-testing.md diff --git a/docs/src/build-configuration.md b/docs/src/Installation and Build/build-configuration.md similarity index 87% rename from docs/src/build-configuration.md rename to docs/src/Installation and Build/build-configuration.md index 5c36bdb..a9847d8 100644 --- a/docs/src/build-configuration.md +++ b/docs/src/Installation and Build/build-configuration.md @@ -11,26 +11,21 @@ $ npm run build:mac # For Linux (.rpm, .deb, .snap) $ npm run build:linux + +# All platform (.exe, .appx, .dmg, .rpm, .deb, .snap) - see below description +$ npm run build:all ``` The built packages can be found in `release/{version}` location. -## Build settings for projects that use Native Node modules - -For projects that use the **Native Node Module**, add the following script to your `package.json`: When installing dependencies, `electron-builder` will take care of any modules that require rebuilding. - -```json -{ - "scripts": { - "postinstall": "electron-builder install-app-deps" - } -} -``` - For more information, please refer to the following article: https://webpack.electron.build/dependency-management#installing-native-node-modules ## What do I need to do for a multi-platform build? +To create a package for each OS, you must build it on the same OS. For example, a package for macOS must be built on a macOS machine. + +However, you can build packages for Windows, macOS, and Linux all at once on one OS. However, this might require some preparation. + **macOS** is recommended if you want to build multiple platforms simultaneously on one platform. Because it can be configured with just a few very simple settings. You can perform multi-platform builds at once with the following command. Alternatively, you can just do it for the OS you want via the individual build commands above. @@ -41,6 +36,8 @@ $ npm run build:all `Multipass` configuration may be required for Linux builds. Learn more about `Multipass` through the following link: https://multipass.run +To learn more about multiplatform builds, see the following articles: https://www.electron.build/multi-platform-build + ## Reduce bundle size by excluding development files You can exclude files you don't need at build time by adding a file pattern to the files property of `buildAssets/builder/config.ts`. This will save bundle capacity. @@ -69,3 +66,15 @@ Below is an unnecessary `node_modules` file pattern that can further save bundle "!**/node_modules/json-schema/!(package.json|lib)" ] ``` + +## Build settings for projects that use Native Node modules + +For projects that use the **Native Node Module**, add the following script to your `package.json`: When installing dependencies, `electron-builder` will take care of any modules that require rebuilding. + +```json +{ + "scripts": { + "postinstall": "electron-builder install-app-deps" + } +} +``` diff --git a/docs/src/getting-started.md b/docs/src/Installation and Build/getting-started.md similarity index 100% rename from docs/src/getting-started.md rename to docs/src/Installation and Build/getting-started.md diff --git a/docs/src/install-local-documentation.md b/docs/src/Installation and Build/install-local-documentation.md similarity index 100% rename from docs/src/install-local-documentation.md rename to docs/src/Installation and Build/install-local-documentation.md diff --git a/docs/src/npm-scripts.md b/docs/src/Installation and Build/npm-scripts.md similarity index 100% rename from docs/src/npm-scripts.md rename to docs/src/Installation and Build/npm-scripts.md diff --git a/docs/src/pre-configured-components.md b/docs/src/Project Structures/pre-configured-components.md similarity index 100% rename from docs/src/pre-configured-components.md rename to docs/src/Project Structures/pre-configured-components.md diff --git a/docs/src/project-structure.md b/docs/src/Project Structures/project-structure.md similarity index 100% rename from docs/src/project-structure.md rename to docs/src/Project Structures/project-structure.md