Skip to content

Commit aba5728

Browse files
committed
init
0 parents  commit aba5728

244 files changed

Lines changed: 34132 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
name: automate-zero-native
3+
description: Automate and inspect running zero-native WebView shell apps via the built-in automation server. Use when the user asks to test the app, list windows, take a screenshot, inspect a snapshot, reload the WebView, or verify a running zero-native example.
4+
---
5+
6+
# Automate zero-native apps
7+
8+
zero-native has a built-in automation system for inspecting running WebView shell apps. It works through file-based IPC in `.zig-cache/zero-native-automation/`.
9+
10+
## Prerequisites
11+
12+
Run an app with automation enabled:
13+
14+
```bash
15+
zig build run-webview -Dplatform=macos -Dautomation=true
16+
```
17+
18+
## Commands
19+
20+
```bash
21+
zig build
22+
zig-out/bin/zero-native automate list
23+
zig-out/bin/zero-native automate snapshot
24+
zig-out/bin/zero-native automate screenshot [path]
25+
zig-out/bin/zero-native automate reload
26+
```
27+
28+
## Workflow
29+
30+
1. Start the app with automation enabled.
31+
2. Run `zig-out/bin/zero-native automate snapshot` to confirm the window and WebView source.
32+
3. Use `zig-out/bin/zero-native automate reload` to request a reload.
33+
4. Use `zig-out/bin/zero-native automate screenshot [path]` when a placeholder screenshot artifact is enough.
34+
35+
## Notes
36+
37+
- Automation is compile-time gated: apps built without `-Dautomation=true` ignore automation files.
38+
- The current screenshot artifact is a placeholder PPM.
39+
- WebView DOM interaction is intentionally out of scope for this file-based automation layer.

‎.github/workflows/cef-runtime.yml‎

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: CEF Runtime
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
cef_version:
7+
description: "CEF version to package"
8+
required: true
9+
default: "144.0.6+g5f7e671+chromium-144.0.7559.59"
10+
source:
11+
description: "Build from official archive or CEF source"
12+
required: true
13+
type: choice
14+
default: "official"
15+
options:
16+
- official
17+
- source
18+
cef_branch:
19+
description: "Optional CEF branch for source builds"
20+
required: false
21+
default: ""
22+
23+
permissions:
24+
contents: write
25+
26+
jobs:
27+
build:
28+
name: Build ${{ matrix.platform }}
29+
runs-on: ${{ matrix.runner }}
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
include:
34+
- platform: macosarm64
35+
runner: macos-14
36+
- platform: macosx64
37+
runner: macos-13
38+
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- uses: mlugg/setup-zig@v2
43+
with:
44+
version: 0.16.0
45+
46+
- name: Download official CEF
47+
if: ${{ inputs.source == 'official' }}
48+
shell: bash
49+
run: |
50+
set -euo pipefail
51+
version="${{ inputs.cef_version }}"
52+
platform="${{ matrix.platform }}"
53+
archive="cef_binary_${version}_${platform}.tar.bz2"
54+
base="https://cef-builds.spotifycdn.com"
55+
mkdir -p zig-out/cef-download
56+
curl --fail --location --output "zig-out/cef-download/${archive}" "${base}/${archive}"
57+
curl --fail --location --output "zig-out/cef-download/${archive}.sha256" "${base}/${archive}.sha256"
58+
expected="$(tr -d '[:space:]' < "zig-out/cef-download/${archive}.sha256")"
59+
actual="$(shasum -a 256 "zig-out/cef-download/${archive}" | awk '{print $1}')"
60+
test "$expected" = "$actual"
61+
tar -xjf "zig-out/cef-download/${archive}" -C zig-out/cef-download
62+
echo "CEF_ROOT=zig-out/cef-download/${archive%.tar.bz2}" >> "$GITHUB_ENV"
63+
64+
- name: Build CEF wrapper
65+
if: ${{ inputs.source == 'official' }}
66+
shell: bash
67+
run: |
68+
set -euo pipefail
69+
cmake -S "$CEF_ROOT" -B "$CEF_ROOT/build/libcef_dll_wrapper"
70+
cmake --build "$CEF_ROOT/build/libcef_dll_wrapper" --target libcef_dll_wrapper --config Release
71+
mkdir -p "$CEF_ROOT/libcef_dll_wrapper"
72+
find "$CEF_ROOT/build/libcef_dll_wrapper" -name libcef_dll_wrapper.a -print -quit | xargs -I{} cp "{}" "$CEF_ROOT/libcef_dll_wrapper/libcef_dll_wrapper.a"
73+
74+
- name: Prepare zero-native runtime archive
75+
if: ${{ inputs.source == 'official' }}
76+
run: |
77+
zig build
78+
zig-out/bin/zero-native cef prepare-release --dir "$CEF_ROOT" --output zig-out/cef --version "${{ inputs.cef_version }}"
79+
80+
- name: Build CEF from source and prepare runtime
81+
if: ${{ inputs.source == 'source' }}
82+
shell: bash
83+
run: |
84+
zig build
85+
chmod +x tools/cef/build-from-source.sh
86+
args=(
87+
tools/cef/build-from-source.sh
88+
--platform "${{ matrix.platform }}"
89+
--version "${{ inputs.cef_version }}"
90+
--output zig-out/cef
91+
--zero-native-bin zig-out/bin/zero-native
92+
)
93+
if [ -n "${{ inputs.cef_branch }}" ]; then
94+
args+=(--cef-branch "${{ inputs.cef_branch }}")
95+
fi
96+
"${args[@]}"
97+
98+
- name: Publish release asset
99+
uses: softprops/action-gh-release@v2
100+
with:
101+
tag_name: cef-${{ inputs.cef_version }}
102+
name: CEF ${{ inputs.cef_version }}
103+
files: |
104+
zig-out/cef/zero-native-cef-${{ inputs.cef_version }}-${{ matrix.platform }}.tar.gz
105+
zig-out/cef/zero-native-cef-${{ inputs.cef_version }}-${{ matrix.platform }}.tar.gz.sha256

‎.github/workflows/ci.yml‎

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
zig:
14+
name: Zig Core
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: mlugg/setup-zig@v2
19+
with:
20+
version: 0.16.0
21+
- run: zig build test
22+
- run: zig build validate
23+
24+
macos-webview:
25+
name: macOS WebView
26+
runs-on: macos-14
27+
steps:
28+
- uses: actions/checkout@v4
29+
- uses: mlugg/setup-zig@v2
30+
with:
31+
version: 0.16.0
32+
- run: zig build test-webview-system-link
33+
- run: zig build test-webview-smoke
34+
35+
linux-webkitgtk:
36+
name: Linux WebKitGTK
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: mlugg/setup-zig@v2
41+
with:
42+
version: 0.16.0
43+
- name: Install WebKitGTK dependencies
44+
run: sudo apt-get update && sudo apt-get install -y libgtk-4-dev libwebkitgtk-6.0-dev
45+
- run: zig build test-webview-system-link -Dplatform=linux
46+
47+
npm-package:
48+
name: npm Package
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v4
52+
- uses: actions/setup-node@v4
53+
with:
54+
node-version: 24
55+
- run: npm --prefix packages/zero-native run version:check
56+
- run: npm --prefix packages/zero-native run scripts:check
57+
58+
frontend-examples:
59+
name: Frontend Examples
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: actions/checkout@v4
63+
- uses: mlugg/setup-zig@v2
64+
with:
65+
version: 0.16.0
66+
- run: zig build test-examples-frontends
67+
68+
mobile-examples:
69+
name: Mobile Examples
70+
runs-on: ubuntu-latest
71+
steps:
72+
- uses: actions/checkout@v4
73+
- uses: mlugg/setup-zig@v2
74+
with:
75+
version: 0.16.0
76+
- run: zig build test-examples-mobile
77+
78+
scaffold:
79+
name: Generated App Scaffolds
80+
runs-on: ubuntu-latest
81+
steps:
82+
- uses: actions/checkout@v4
83+
- uses: mlugg/setup-zig@v2
84+
with:
85+
version: 0.16.0
86+
- run: zig build
87+
- name: Scaffold and test frontend templates
88+
run: |
89+
set -euo pipefail
90+
for frontend in next vite react svelte vue; do
91+
app=".zig-cache/scaffold-${frontend}"
92+
rm -rf "$app"
93+
./zig-out/bin/zero-native init "$app" --frontend "$frontend"
94+
(cd "$app" && zig build test -Dplatform=null && ../../zig-out/bin/zero-native validate app.zon)
95+
done
96+
97+
docs:
98+
name: Docs
99+
runs-on: ubuntu-latest
100+
steps:
101+
- uses: actions/checkout@v4
102+
- uses: actions/setup-node@v4
103+
with:
104+
node-version: 22
105+
- uses: pnpm/action-setup@v4
106+
with:
107+
version: 10.23.0
108+
package_json_file: docs/package.json
109+
- run: pnpm install --frozen-lockfile
110+
working-directory: docs
111+
- run: pnpm check
112+
working-directory: docs

‎.github/workflows/release.yml‎

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
concurrency: ${{ github.workflow }}-${{ github.ref }}
10+
11+
jobs:
12+
check-release:
13+
name: Check for new CLI version
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 5
16+
permissions:
17+
contents: read
18+
outputs:
19+
should_release: ${{ steps.check.outputs.should_release }}
20+
version: ${{ steps.check.outputs.version }}
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: "24"
29+
registry-url: "https://registry.npmjs.org"
30+
31+
- name: Compare package.json version to npm
32+
id: check
33+
run: |
34+
LOCAL_VERSION=$(node -p "require('./packages/zero-native/package.json').version")
35+
echo "Local version: $LOCAL_VERSION"
36+
37+
NPM_VERSION=$(npm view zero-native version 2>/dev/null || echo "0.0.0")
38+
echo "npm version: $NPM_VERSION"
39+
40+
if [ "$LOCAL_VERSION" != "$NPM_VERSION" ]; then
41+
echo "Version changed: $NPM_VERSION -> $LOCAL_VERSION"
42+
echo "should_release=true" >> "$GITHUB_OUTPUT"
43+
else
44+
echo "Version unchanged on npm, skipping publish"
45+
echo "should_release=false" >> "$GITHUB_OUTPUT"
46+
fi
47+
48+
echo "version=$LOCAL_VERSION" >> "$GITHUB_OUTPUT"
49+
50+
publish:
51+
name: Publish CLI to npm
52+
needs: check-release
53+
if: needs.check-release.outputs.should_release == 'true'
54+
runs-on: ubuntu-latest
55+
timeout-minutes: 10
56+
environment: Release
57+
permissions:
58+
contents: read
59+
id-token: write
60+
steps:
61+
- name: Checkout repository
62+
uses: actions/checkout@v4
63+
64+
- name: Setup Node.js
65+
uses: actions/setup-node@v4
66+
with:
67+
node-version: "24"
68+
registry-url: "https://registry.npmjs.org"
69+
70+
- name: Check version sync
71+
run: npm --prefix packages/zero-native run version:check
72+
73+
- name: Check package scripts
74+
run: npm --prefix packages/zero-native run scripts:check
75+
76+
- name: Publish to npm
77+
run: npm publish --provenance --access public
78+
working-directory: packages/zero-native

‎.gitignore‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.DS_Store
2+
.zig-cache/
3+
zig-out/
4+
5+
# Native binaries in zero-native npm package (built by CI or locally)
6+
packages/zero-native/bin/zero-native-*
7+
8+
# Downloaded/prepared CEF runtimes are large local artifacts.
9+
third_party/cef/macos/
10+
third_party/cef/windows/
11+
third_party/cef/linux/
12+
13+
# Compiled static libraries
14+
*.a
15+
16+
# TypeScript build info (generated)
17+
docs/tsconfig.tsbuildinfo

‎CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
All notable changes to zero-native will be documented in this file.
4+
5+
## 0.1.0
6+
7+
- Initial pre-release development version.

0 commit comments

Comments
 (0)