Skip to content

Commit

Permalink
Merge branch 'release/v8'
Browse files Browse the repository at this point in the history
  • Loading branch information
saltyshiomix committed Sep 22, 2023
2 parents 7b033e6 + bc12abc commit f5fd6fa
Show file tree
Hide file tree
Showing 31 changed files with 531 additions and 634 deletions.
60 changes: 0 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,65 +161,6 @@ We can extends the default babel config of main process by putting `.babelrc` in
}
```

## Tips

### Next.js' Webpack Processes

There are two webpack processes: server process and client one.

If we want to use some libraries that don't support SSR, we should check if the current process is whether server or client:

```jsx
// pages/home.jsx

import electron from 'electron'

const Home = () => {
// we can't use `electron.ipcRenderer` directly!
const ipcRenderer = electron.ipcRenderer

// we should check it like this
const ipcRenderer = electron.ipcRenderer || false
if (ipcRenderer) {
// we can use `electron.ipcRenderer`
// because this scope is the client webpack process
}
}

export default Home
```

### The Basic of React Hooks :)

As mentioned above, we should check if the webpack process is a client because the renderer process is a web client:

```jsx
// pages/home.jsx

import electron from 'electron'
import React from 'react'

const Home = () => {
// In this scope, both of server and client processes are running
// So if the process is server, `window` object is undefined

React.useEffect(() => {
// componentDidMount() like

// In this scope, only the client process is running
window.alert('wow')

return () => {
// componentWillUnmount() like
}
}, [])

return <p>Hello Nextron</p>
}

export default Home
```

## Examples

See [examples](./examples) folder for more information.
Expand Down Expand Up @@ -439,7 +380,6 @@ $ npm link

```
$ cd your-project
$ npm install -D @babel/runtime-corejs3 # required for nextron
$ npm link nextron
```

Expand Down
4 changes: 2 additions & 2 deletions examples/_template/js/main/helpers/create-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ export const createWindow = (windowName, options) => {
...state,
...options,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
...options.webPreferences,
nodeIntegration: false,
contextIsolation: true,
},
})

Expand Down
9 changes: 4 additions & 5 deletions examples/_template/ts/main/helpers/create-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,15 @@ export const createWindow = (

state = ensureVisibleOnSomeDisplay(restore())

const browserOptions: BrowserWindowConstructorOptions = {
const win = new BrowserWindow({
...state,
...options,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
...options.webPreferences,
nodeIntegration: false,
contextIsolation: true,
},
}
const win = new BrowserWindow(browserOptions)
})

win.on('close', saveState)

Expand Down
6 changes: 3 additions & 3 deletions examples/basic-javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"electron-store": "^8.1.0"
},
"devDependencies": {
"electron": "^21.3.3",
"electron-builder": "^23.6.0",
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.8.0",
"nextron": "^8.9.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
7 changes: 2 additions & 5 deletions examples/basic-javascript/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/** @type {import('next').NextConfig} */
module.exports = {
trailingSlash: true,
images: {
unoptimized: true,
},
webpack: (config, { isServer }) => {
if (!isServer) {
config.target = 'electron-renderer'
}

webpack: (config) => {
return config
},
}
6 changes: 3 additions & 3 deletions examples/basic-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"devDependencies": {
"@types/node": "^18.11.18",
"@types/react": "^18.0.26",
"electron": "^21.3.3",
"electron-builder": "^23.6.0",
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.8.0",
"nextron": "^8.9.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^4.9.4"
Expand Down
7 changes: 2 additions & 5 deletions examples/basic-typescript/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/** @type {import('next').NextConfig} */
module.exports = {
trailingSlash: true,
images: {
unoptimized: true,
},
webpack: (config, { isServer }) => {
if (!isServer) {
config.target = 'electron-renderer'
}

webpack: (config) => {
return config
},
}
6 changes: 3 additions & 3 deletions examples/custom-build-options/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"electron-store": "^8.1.0"
},
"devDependencies": {
"electron": "^21.3.3",
"electron-builder": "^23.6.0",
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.8.0",
"nextron": "^8.9.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
7 changes: 2 additions & 5 deletions examples/custom-build-options/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/** @type {import('next').NextConfig} */
module.exports = {
trailingSlash: true,
images: {
unoptimized: true,
},
webpack: (config, { isServer }) => {
if (!isServer) {
config.target = 'electron-renderer'
}

webpack: (config) => {
return config
},
}
6 changes: 3 additions & 3 deletions examples/custom-main-entry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"electron-store": "^8.1.0"
},
"devDependencies": {
"electron": "^21.3.3",
"electron-builder": "^23.6.0",
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.8.0",
"nextron": "^8.9.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
7 changes: 2 additions & 5 deletions examples/custom-main-entry/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/** @type {import('next').NextConfig} */
module.exports = {
trailingSlash: true,
images: {
unoptimized: true,
},
webpack: (config, { isServer }) => {
if (!isServer) {
config.target = 'electron-renderer'
}

webpack: (config) => {
return config
},
}
6 changes: 3 additions & 3 deletions examples/custom-renderer-port/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"electron-store": "^8.1.0"
},
"devDependencies": {
"electron": "^21.3.3",
"electron-builder": "^23.6.0",
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.8.0",
"nextron": "^8.9.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
7 changes: 2 additions & 5 deletions examples/custom-renderer-port/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/** @type {import('next').NextConfig} */
module.exports = {
trailingSlash: true,
images: {
unoptimized: true,
},
webpack: (config, { isServer }) => {
if (!isServer) {
config.target = 'electron-renderer'
}

webpack: (config) => {
return config
},
}
6 changes: 3 additions & 3 deletions examples/ipc-communication/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"electron-store": "^8.1.0"
},
"devDependencies": {
"electron": "^21.3.3",
"electron-builder": "^23.6.0",
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.8.0",
"nextron": "^8.9.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
11 changes: 4 additions & 7 deletions examples/ipc-communication/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/** @type {import('next').NextConfig} */
module.exports = {
trailingSlash: true,
images: {
unoptimized: true,
},
webpack: (config, { isServer }) => {
if (!isServer) {
config.target = 'electron-renderer';
}

return config;
webpack: (config) => {
return config
},
};
}
6 changes: 3 additions & 3 deletions examples/store-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"electron-store": "^8.1.0"
},
"devDependencies": {
"electron": "^21.3.3",
"electron-builder": "^23.6.0",
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.8.0",
"nextron": "^8.9.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
7 changes: 2 additions & 5 deletions examples/store-data/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/** @type {import('next').NextConfig} */
module.exports = {
trailingSlash: true,
images: {
unoptimized: true,
},
webpack: (config, { isServer }) => {
if (!isServer) {
config.target = 'electron-renderer'
}

webpack: (config) => {
return config
},
}
6 changes: 3 additions & 3 deletions examples/with-ant-design/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"@types/node": "^18.11.18",
"@types/react": "^18.0.26",
"antd": "^4.22.8",
"electron": "^21.3.3",
"electron-builder": "^23.6.0",
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.8.0",
"nextron": "^8.9.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^4.9.4"
Expand Down
7 changes: 2 additions & 5 deletions examples/with-ant-design/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/** @type {import('next').NextConfig} */
module.exports = {
trailingSlash: true,
images: {
unoptimized: true,
},
webpack: (config, { isServer }) => {
if (!isServer) {
config.target = 'electron-renderer'
}

webpack: (config) => {
return config
},
}
6 changes: 3 additions & 3 deletions examples/with-chakra-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
"@types/node": "^18.0.0",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"electron": "^21.3.3",
"electron-builder": "^23.6.0",
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"framer-motion": "^6.5.1",
"next": "^12.3.4",
"nextron": "^8.8.0",
"nextron": "^8.9.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^4.9.5"
Expand Down
7 changes: 2 additions & 5 deletions examples/with-chakra-ui/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/** @type {import('next').NextConfig} */
module.exports = {
trailingSlash: true,
images: {
unoptimized: true,
},
webpack: (config, { isServer }) => {
if (!isServer) {
config.target = 'electron-renderer'
}

webpack: (config) => {
return config
},
}
Loading

0 comments on commit f5fd6fa

Please sign in to comment.