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 27, 2023
2 parents 43b33ad + 45f3380 commit 67729ab
Show file tree
Hide file tree
Showing 41 changed files with 451 additions and 173 deletions.
185 changes: 166 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,28 +92,135 @@ Run `npm run build`, and nextron outputs packaged bundles under the `dist` folde
}
```

### Build Options
## `nextron` or `nextron dev` Options

### `--renderer-port` (default: `8888`)

It specifies `next` dev server port:

```json
{
"scripts": {
"dev": "nextron --renderer-port 7777"
}
}
```

### `--run-only` (default: `undefined`)

It suppresses hot reloading of the main process:

```json
{
"scripts": {
"dev": "nextron --run-only"
}
}
```

### `--startup-delay` (default: `0`)

It waits until renderer process is ready (milliseconds):

```json
{
"scripts": {
"dev": "nextron --startup-delay 3000"
}
}
```

### `--electron-options` (default: `undefined`)

We can pass electron args via `--electron-options`:

```json
{
"scripts": {
"dev": "nextron --electron-options=\"--no-sandbox\""
}
}
```

## `nextron build` Options

**NOTE**:

- To build macOS binary, your host machine must be macOS!
- Please consider to use `electron-builder.yml` instead of these CLI options.
- [Command Line Interface (CLI) - electron-builder](https://www.electron.build/cli)
- [Common Configuration - electron-builder](https://www.electron.build/configuration/configuration)

To build Windows 32 bit version, run `npm run build:win32` like below:

```json
{
"scripts": {
"build": "nextron build",
"build:all": "nextron build --all",
"build:mac": "nextron build --mac",
"build:mac:universal": "nextron build --mac --universal",
"build:linux": "nextron build --linux",
"build:win32": "nextron build --win --ia32",
"build:win64": "nextron build --win --x64",
"build:mac": "nextron build --mac --x64",
"build:linux": "nextron build --linux"
"build:win64": "nextron build --win --x64"
}
}
```

### `--electron-builder-options` (default: `undefined`)

An example below builds NSIS 32-bit installer for Windows:

```json
{
"scripts": {
"build": "nextron build --electron-builder-options=\"--windows nsis:ia32\""
}
}
```

Next example builds deb and tar.xz for Linux:

```json
{
"scripts": {
"build": "nextron build --electron-builder-options=\"--linux deb tar.xz\""
}
}
```

**CAUTION**: To build macOS binary, your host machine must be macOS!
### `--config` (default: `./electron-builder.yml`)

### Build Configuration
```json
{
"scripts": {
"build": "nextron build --config ./configs/electron-builder.prod.yml"
}
}
```

Edit `electron-builder.yml` properties for custom build configuration.
### `--publish` (default: `undefined`)

**Note**

Highly recommend to use `electron-builder.yml`:

https://www.electron.build/configuration/publish

### `--no-pack` (default: `undefined`)

This option skips packaging by electron-builder:

```json
{
"scripts": {
"build": "nextron build --no-pack"
}
}
```

### Build Configuration: `electron-builder.yml`

Edit `electron-builder.yml` for custom build configurations:

```yml
appId: com.example.nextron
Expand All @@ -132,7 +239,7 @@ publish: null # see https://www.electron.build/configuration/publish
For more information, please check out [electron-builder official configuration documents](https://www.electron.build/configuration/configuration).
## nextron.config.js
## Custom Config: `nextron.config.js`

```js
module.exports = {
Expand All @@ -149,7 +256,7 @@ module.exports = {
}
```

## Custom Babel Config for the Main Process
## Custom Babel Config for Main Process

We can extends the default babel config of main process by putting `.babelrc` in our project root like this:

Expand All @@ -165,36 +272,72 @@ We can extends the default babel config of main process by putting `.babelrc` in

See [examples](./examples) folder for more information.

### [examples/basic-javascript](./examples/basic-javascript)
### [examples/basic-lang-javascript](./examples/basic-lang-javascript)

<p align="center"><img src="https://i.imgur.com/X7dSE68.png"></p>

```
# with npx
$ npx create-nextron-app my-app --example basic-javascript
$ npx create-nextron-app my-app --example basic-lang-javascript

# with yarn
$ yarn create nextron-app my-app --example basic-javascript
$ yarn create nextron-app my-app --example basic-lang-javascript

# with pnpm
$ pnpm dlx create-nextron-app my-app --example basic-javascript
$ pnpm dlx create-nextron-app my-app --example basic-lang-javascript
```
### [examples/basic-typescript](./examples/basic-typescript)
### [examples/basic-lang-typescript](./examples/basic-lang-typescript)
<p align="center"><img src="https://i.imgur.com/NZfsD1p.png"></p>
```
# with npx
$ npx create-nextron-app my-app --example basic-typescript
$ npx create-nextron-app my-app --example basic-lang-typescript

# with yarn
$ yarn create nextron-app my-app --example basic-lang-typescript

# with pnpm
$ pnpm dlx create-nextron-app my-app --example basic-lang-typescript
```
### [examples/basic-launch-app-from-url](./examples/basic-launch-app-from-url)
This example shows how to open your app from browser URL.
Note: this example works **only production build**!
<p align="center"><img src="https://i.imgur.com/WRuTxf8.gifv"></p>
```
# with npx
$ npx create-nextron-app my-app --example basic-launch-app-from-url

# with yarn
$ yarn create nextron-app my-app --example basic-typescript
$ yarn create nextron-app my-app --example basic-launch-app-from-url

# with pnpm
$ pnpm dlx create-nextron-app my-app --example basic-typescript
$ pnpm dlx create-nextron-app my-app --example basic-launch-app-from-url

# --------------------------------------------------------------

# Production build
$ yarn build (or `npm run build` or `pnpm run build`)
```
After production build, click [your-custom-protocol-scheme://open](your-custom-protocol-scheme://open) or open it in your browser, then the app will be shown like a magic!
If you want to change schema URL, please edit `electron-builder.yml#protocols`:
```yml
protocols:
name: Your App Name
schemes: [your-custom-protocol-scheme-edited]
```

Then, you can see the app from URL: `your-custom-protocol-scheme-edited://any-uri-here-include-any-data`.

### [examples/custom-build-options](./examples/custom-build-options)

<p align="center"><img src="https://i.imgur.com/QqQekRJ.png"></p>
Expand Down Expand Up @@ -356,7 +499,7 @@ $ pnpm dlx create-nextron-app my-app --example with-tailwindcss
$ git clone https://github.com/saltyshiomix/nextron.git
$ cd nextron
$ pnpm install
$ pnpm dev # default is examples/basic-javascript
$ pnpm dev # default is examples/basic-lang-javascript
```

### Developing `examples/*`
Expand Down Expand Up @@ -395,6 +538,10 @@ $ npm link nextron

For more information, please see [Looking for maintainers ⚡ #244](https://github.com/saltyshiomix/nextron/discussions/244).

## Community

You already create apps with nextron? Feel free to share your apps or services: https://github.com/saltyshiomix/nextron/discussions/406

## Related

- [create-nextron-app](https://github.com/saltyshiomix/create-nextron-app) - Create Nextron (Electron + Next.js) apps in one command ⚡
Expand Down
2 changes: 1 addition & 1 deletion dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function detectPackageManager() {
}

;(async () => {
let example = 'basic-javascript'
let example = 'basic-lang-javascript'
if (3 <= process.argv.length) {
const newExample = process.argv[2]
if (!fs.existsSync(path.join(cwd, `examples/${newExample}`))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

```
# with npx
$ npx create-nextron-app my-app --example basic-javascript
$ npx create-nextron-app my-app --example basic-lang-javascript
# with yarn
$ yarn create nextron-app my-app --example basic-javascript
$ yarn create nextron-app my-app --example basic-lang-javascript
# with pnpm
$ pnpm dlx create-nextron-app my-app --example basic-javascript
$ pnpm dlx create-nextron-app my-app --example basic-lang-javascript
```

### Install Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.10.0",
"nextron": "^8.11.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

```
# with npx
$ npx create-nextron-app my-app --example basic-typescript
$ npx create-nextron-app my-app --example basic-lang-typescript
# with yarn
$ yarn create nextron-app my-app --example basic-typescript
$ yarn create nextron-app my-app --example basic-lang-typescript
# with pnpm
$ pnpm dlx create-nextron-app my-app --example basic-typescript
$ pnpm dlx create-nextron-app my-app --example basic-lang-typescript
```

### Install Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.10.0",
"nextron": "^8.11.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^4.9.4"
Expand Down
File renamed without changes.
57 changes: 57 additions & 0 deletions examples/basic-launch-app-from-url/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<p align="center"><img src="https://i.imgur.com/WRuTxf8.gifv"></p>

## Usage

This example shows how to open your app from browser URL.

Note: this example works **only production build**!

### Create an App

```
# with npx
$ npx create-nextron-app my-app --example basic-typescript
# with yarn
$ yarn create nextron-app my-app --example basic-typescript
# with pnpm
$ pnpm dlx create-nextron-app my-app --example basic-typescript
```

### Install Dependencies

```
$ cd my-app
# using yarn or npm
$ yarn (or `npm install`)
# using pnpm
$ pnpm install --shamefully-hoist
```

### Build it (production mode)

```
# production build
$ yarn build (or `npm run build` or `pnpm run build`)
```

### Open your App

Click [your-custom-protocol-scheme://open](your-custom-protocol-scheme://open) or open it in your browser, then the app will be shown like a magic!

If you want to change schema URL, please edit `electron-builder.yml#protocols`:

```yml
protocols:
name: Your App Name
schemes: [your-custom-protocol-scheme-edited]
```
Then, you can see the app from URL: `your-custom-protocol-scheme-edited://any-uri-here-include-any-data`.

### Useful References

- https://www.electronjs.org/docs/latest/tutorial/launch-app-from-url-in-another-app
15 changes: 15 additions & 0 deletions examples/basic-launch-app-from-url/electron-builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
appId: com.example.nextron
productName: My Nextron App
copyright: Copyright © 2018 Yoshihide Shiono
directories:
output: dist
buildResources: resources
files:
- from: .
filter:
- package.json
- app
protocols:
name: My Nextron App
schemes: [your-custom-protocol-scheme]
publish: null
Loading

0 comments on commit 67729ab

Please sign in to comment.