Skip to content

Commit 7224645

Browse files
authored
update dependecies and crates, add reload in webview, and add exit on app (#22)
* chore(deps): migrate to bun and upgrade napi-rs to v3 - Switch package manager from yarn to bun - Upgrade napi-rs from v2 to v3 with updated native bindings - Update tao from 0.30.8 to 0.34.5 and wry from 0.47.0 to 0.48.0 - Update CI workflows to use bun for installation and caching - Regenerate type definitions and JavaScript bindings for napi-rs v3 - Update development documentation with bun prerequisites - Remove yarn, taplo configurations and add bun-specific ignores - Add new build scripts: build:all, build:prebuilds, clean, check, clippy - Improve native binding loading with better error handling and platform support * rename JsTheme to Theme * chore: migrate from yarn to bun and refactor code Replace yarn with bun across CI/CD workflows, husky hooks, and development scripts. Refactor Rust code to use more idiomatic patterns including unwrap_or_default, map instead of match expressions, and simplified callback handling. * feat(api): add graceful exit and window control methods Add new methods for application lifecycle management and window control: - Application.exit() for graceful shutdown with resource cleanup - BrowserWindow.hide() and show() for window visibility control - Webview.reload() for reloading webview content - ApplicationCloseRequested event for handling close events - Application.bind() as an alias for on_event() Updated CI workflow to install required system dependencies for Linux. Added documentation and examples for the new closing functionality. * change build and workflow files * feat(api): add window id management and lifecycle control Add window identification, management methods, and application lifecycle control. Windows now have unique IDs for tracking, with new methods for closing specific windows. The Application can now prevent automatic exit when all windows are closed, requiring explicit exit() call. BREAKING CHANGE: package.json type changed from commonjs to module, affecting import syntax for consumers of this package * Revert "feat(api): add window id management and lifecycle control" This reverts commit 7a4c37e. * fix(webview): properly propagate build errors * refactor(api): optimize imports and simplify window method calls * fix lint * change test script * delete docs
1 parent bb55ded commit 7224645

File tree

18 files changed

+1241
-4113
lines changed

18 files changed

+1241
-4113
lines changed

.github/workflows/CI.yml

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ env:
44
APP_NAME: webview
55
MACOSX_DEPLOYMENT_TARGET: '10.13'
66
CARGO_INCREMENTAL: '1'
7+
CARGO_TERM_COLOR: always
78
permissions:
89
contents: write
910
id-token: write
@@ -31,50 +32,50 @@ jobs:
3132
settings:
3233
- host: macos-latest
3334
target: x86_64-apple-darwin
34-
build: yarn build --target x86_64-apple-darwin
35+
build: bun run build --target x86_64-apple-darwin
3536
- host: windows-latest
36-
build: yarn build --target x86_64-pc-windows-msvc
37+
build: bun run build --target x86_64-pc-windows-msvc
3738
target: x86_64-pc-windows-msvc
3839
- host: windows-latest
39-
build: yarn build --target i686-pc-windows-msvc
40+
build: bun run build --target i686-pc-windows-msvc
4041
target: i686-pc-windows-msvc
4142
# - host: ubuntu-latest
4243
# target: x86_64-unknown-linux-gnu
4344
# docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
4445
# setup: |
4546
# sudo apt-get update
4647
# sudo apt-get install pkg-config -y
47-
# build: yarn build --target x86_64-unknown-linux-gnu
48+
# build: bun run build --target x86_64-unknown-linux-gnu
4849
# - host: ubuntu-latest
4950
# target: x86_64-unknown-linux-musl
5051
# docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
5152
# setup: |
5253
# sudo apt-get update
5354
# sudo apt-get install pkg-config -y
54-
# build: yarn build --target x86_64-unknown-linux-musl
55+
# build: bun run build --target x86_64-unknown-linux-musl
5556
- host: macos-latest
5657
target: aarch64-apple-darwin
57-
build: yarn build --target aarch64-apple-darwin
58+
build: bun run build --target aarch64-apple-darwin
5859
# - host: ubuntu-latest
5960
# target: aarch64-unknown-linux-gnu
6061
# docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
6162
# setup: |
6263
# sudo apt-get update
6364
# sudo apt-get install pkg-config -y
64-
# build: yarn build --target aarch64-unknown-linux-gnu
65+
# build: bun run build --target aarch64-unknown-linux-gnu
6566
# - host: ubuntu-latest
6667
# target: armv7-unknown-linux-gnueabihf
6768
# setup: |
6869
# sudo apt-get update
6970
# sudo apt-get install gcc-arm-linux-gnueabihf -y
7071
# build: |
71-
# yarn build --target armv7-unknown-linux-gnueabihf
72+
# bun run build --target armv7-unknown-linux-gnueabihf
7273
- host: ubuntu-latest
7374
target: aarch64-linux-android
74-
build: yarn build --target aarch64-linux-android
75+
build: bun run build --target aarch64-linux-android
7576
- host: ubuntu-latest
7677
target: armv7-linux-androideabi
77-
build: yarn build --target armv7-linux-androideabi
78+
build: bun run build --target armv7-linux-androideabi
7879
# - host: ubuntu-latest
7980
# target: aarch64-unknown-linux-musl
8081
# docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
@@ -84,20 +85,24 @@ jobs:
8485
# build: |-
8586
# set -e &&
8687
# rustup target add aarch64-unknown-linux-musl &&
87-
# yarn build --target aarch64-unknown-linux-musl
88+
# bun run build --target aarch64-unknown-linux-musl
8889
- host: windows-latest
8990
target: aarch64-pc-windows-msvc
90-
build: yarn build --target aarch64-pc-windows-msvc
91+
build: bun run build --target aarch64-pc-windows-msvc
9192
name: stable - ${{ matrix.settings.target }} - node@18
9293
runs-on: ${{ matrix.settings.host }}
9394
steps:
9495
- uses: actions/checkout@v4
96+
- name: Setup bun
97+
uses: oven-sh/setup-bun@v2
98+
if: ${{ !matrix.settings.docker }}
99+
with:
100+
bun-version: latest
95101
- name: Setup node
96102
uses: actions/setup-node@v4
97103
if: ${{ !matrix.settings.docker }}
98104
with:
99105
node-version: 20
100-
cache: yarn
101106
- name: Install
102107
uses: dtolnay/rust-toolchain@stable
103108
if: ${{ !matrix.settings.docker }}
@@ -123,7 +128,7 @@ jobs:
123128
if: ${{ matrix.settings.setup }}
124129
shell: bash
125130
- name: Install dependencies
126-
run: yarn install
131+
run: bun install
127132
- name: Build in docker
128133
uses: addnab/docker-run-action@v3
129134
if: ${{ matrix.settings.docker }}
@@ -161,26 +166,26 @@ jobs:
161166
# shell: bash
162167
# run: |
163168
# sudo pkg install -y -f curl node libnghttp2 npm pkg-config
164-
# sudo npm install -g yarn --ignore-scripts
169+
# sudo npm install -g bun --ignore-scripts
165170
# curl https://sh.rustup.rs -sSf --output rustup.sh
166171
# sh rustup.sh -y --profile minimal --default-toolchain beta
167172
# source "$HOME/.cargo/env"
168173
# echo "~~~~ rustc --version ~~~~"
169174
# rustc --version
170175
# echo "~~~~ node -v ~~~~"
171176
# node -v
172-
# echo "~~~~ yarn --version ~~~~"
173-
# yarn --version
177+
# echo "~~~~ bun --version ~~~~"
178+
# bun --version
174179
# pwd
175180
# ls -lah
176181
# whoami
177182
# env
178183
# freebsd-version
179-
# yarn install
180-
# yarn build
184+
# bun install
185+
# bun run build
181186
# rm -rf node_modules
182187
# rm -rf target
183-
# rm -rf .yarn/cache
188+
# rm -rf .bun/cache
184189
# - name: Upload artifact
185190
# uses: actions/upload-artifact@v4
186191
# with:
@@ -195,19 +200,22 @@ jobs:
195200
# - build-freebsd
196201
steps:
197202
- uses: actions/checkout@v4
203+
- name: Setup bun
204+
uses: oven-sh/setup-bun@v2
205+
with:
206+
bun-version: latest
198207
- name: Setup node
199208
uses: actions/setup-node@v4
200209
with:
201210
node-version: 20
202-
cache: yarn
203211
- name: Install dependencies
204-
run: yarn install
212+
run: bun install
205213
- name: Download all artifacts
206214
uses: actions/download-artifact@v4
207215
with:
208216
path: artifacts
209217
- name: Move artifacts
210-
run: yarn artifacts
218+
run: bun run artifacts
211219
- name: List packages
212220
run: ls -R ./npm
213221
shell: bash

.github/workflows/lint.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,40 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v4
1919

20+
- name: Setup bun
21+
uses: oven-sh/setup-bun@v2
22+
with:
23+
bun-version: latest
24+
2025
- name: Setup node
2126
uses: actions/setup-node@v4
2227
with:
2328
node-version: 20
24-
cache: 'yarn'
2529

2630
- name: Install
2731
uses: dtolnay/rust-toolchain@stable
2832
with:
2933
components: clippy, rustfmt
3034

35+
- name: Install system dependencies
36+
run: |
37+
sudo apt-get update
38+
sudo apt-get install -y libwebkit2gtk-4.1-dev libgtk-3-dev libglib2.0-dev pkg-config
39+
3140
- name: Install dependencies
32-
run: yarn install
41+
run: bun install
3342

3443
- name: ESLint
35-
run: yarn lint
44+
run: bun run lint
3645

3746
- name: Cargo fmt
3847
run: cargo fmt -- --check
3948

4049
- name: Clippy
41-
run: cargo clippy
50+
run: bun run clippy
51+
52+
- name: Cargo check
53+
run: bun run check
54+
55+
- name: Run tests
56+
run: bun run test

.gitignore

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,40 @@ Cargo.lock
121121

122122
*.node
123123
.pnp.*
124+
125+
# Bun
126+
bun.lockb
127+
128+
# Yarn (legacy)
124129
.yarn/*
125130
!.yarn/patches
126131
!.yarn/plugins
127132
!.yarn/releases
128133
!.yarn/sdks
129-
!.yarn/versions
134+
!.yarn/versions
135+
136+
# Build artifacts
137+
*.a
138+
*.lib
139+
*.o
140+
*.obj
141+
*.so
142+
*.dylib
143+
*.dll
144+
*.exe
145+
146+
# Rust
147+
.cargo-cache/
148+
Cargo.lock
149+
150+
# NAPI
151+
index.d.ts
152+
npm/
153+
154+
# IDE
155+
.idea/
156+
*.swp
157+
*.swo
158+
*~
159+
.DS_Store
160+
bun.lock

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
yarn lint-staged
4+
bun run lint-staged

.taplo.toml

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)