Skip to content

Commit 3bbd0de

Browse files
committed
feat: desktop support and leaner npm package
1 parent 4d9334c commit 3bbd0de

109 files changed

Lines changed: 12860 additions & 853 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.

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ jobs:
183183
- name: Build Zig prebuilts for iOS
184184
run: ./scripts/build-zig-ios.sh
185185

186+
- name: Build Zig prebuilts for macOS
187+
run: ./scripts/build-zig-macos.sh
188+
189+
- name: Build Zig prebuilts for Windows
190+
run: ./scripts/build-zig-windows.sh
191+
186192
- name: Build package
187193
run: yarn prepare
188194

.github/workflows/manual-publish.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ jobs:
3434
run: ./scripts/build-zig-android.sh
3535
- name: Build Zig prebuilts for iOS
3636
run: ./scripts/build-zig-ios.sh
37+
- name: Build Zig prebuilts for macOS
38+
run: ./scripts/build-zig-macos.sh
39+
- name: Build Zig prebuilts for Windows
40+
run: ./scripts/build-zig-windows.sh
3741
- run: yarn prepare
3842
- name: Verify packaged artifacts
3943
run: yarn check:packaged-artifacts

.github/workflows/npm-publish.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ jobs:
5151
- name: Build Zig prebuilts for iOS
5252
run: ./scripts/build-zig-ios.sh
5353

54+
- name: Build Zig prebuilts for macOS
55+
run: ./scripts/build-zig-macos.sh
56+
57+
- name: Build Zig prebuilts for Windows
58+
run: ./scripts/build-zig-windows.sh
59+
5460
- name: Build package (bob via prepare)
5561
run: yarn prepare
5662

BENCHMARKS.md

Lines changed: 97 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
# Benchmarks
22

3-
Release measurements for `native` vs `zig` engines.
3+
Release measurements for `native` vs `zig` engines on mobile, plus Zig-only
4+
desktop snapshots for experimental macOS and Windows support.
45

56
## Environment
67

78
- Android: physical ARM64 device, Android 15
89
- iOS: physical Apple A15 device, iOS 26.3
10+
- macOS: Apple MacBook Pro 16-inch, M4 Max, 36 GB RAM
11+
- Windows: QEMU 10.0 ARM Virtual Machine, ARM64, 8 GB RAM
912
- Build: Release
1013
- Payload: generated local cache file, 200 MiB
1114
- App settings: `samples=3`, `warmups=1`
1215
- Values below are medians (`ms`, lower is better)
1316

14-
Each run reports the app-level median for three measured samples. The tables
15-
below use the median across repeated runs.
17+
Each run reports the app-level median for three measured samples. When repeated
18+
runs are available, comparison tables use the median across those runs.
1619

1720
This document is a current engine-selection snapshot, not a release-to-release
1821
speedup table. A slower row means "slower than `native` on that platform"; it
1922
does not by itself mean the Zig core regressed versus the previous release.
2023

24+
Desktop rows are Zig-only because macOS and Windows support currently ships the
25+
Zig engine only. The Windows numbers were captured in an ARM64 VM, so they are
26+
useful as a release smoke/performance snapshot, not as a hardware comparison
27+
against physical devices.
28+
2129
## Key Takeaways
2230

2331
- Zig `v0.0.5` improves the Zig path versus the previous benchmark set for
@@ -34,68 +42,106 @@ does not by itself mean the Zig core regressed versus the previous release.
3442
`SHA-512/256`, where the native implementation is much slower.
3543
- Android `native` is faster for `SHA-1`, `SHA-384`, `SHA-512`, `BLAKE3`,
3644
and `XXH3-64` in this measurement set.
45+
- Experimental macOS and Windows support produce matching digest prefixes for
46+
the same 200 MiB benchmark payload.
47+
- macOS on M4 Max is currently the fastest measured Zig desktop target, with
48+
`XXH3-64` at 14 ms and `SHA-256` / `SHA-224` / HMAC-SHA-2 224/256 around
49+
78-79 ms.
50+
- Windows ARM64 VM performs well for `BLAKE3`, `XXH3-64`, `SHA-1`, and the
51+
SHA-512 family, but is much slower than macOS for SHA-224/SHA-256 and their
52+
HMAC variants in this run.
3753

3854
## Quick Comparison
3955

4056
### iOS
4157

42-
| Scenario | Native | Zig | Zig vs native |
43-
|---|---:|---:|---:|
44-
| SHA-256, file 200 MiB | 228 | 209 | 9% faster |
45-
| SHA-512, file 200 MiB | 317 | 1176 | 271% slower |
46-
| BLAKE3, file 200 MiB | 310 | 302 | 3% faster |
47-
| XXH3-64, file 200 MiB | 108 | 66 | 39% faster |
58+
| Scenario | Native | Zig | Zig vs native |
59+
| --------------------- | -----: | ---: | ------------: |
60+
| SHA-256, file 200 MiB | 228 | 209 | 9% faster |
61+
| SHA-512, file 200 MiB | 317 | 1176 | 271% slower |
62+
| BLAKE3, file 200 MiB | 310 | 302 | 3% faster |
63+
| XXH3-64, file 200 MiB | 108 | 66 | 39% faster |
4864

4965
### Android
5066

51-
| Scenario | Native | Zig | Zig vs native |
52-
|---|---:|---:|---:|
53-
| SHA-256, file 200 MiB | 297 | 332 | 12% slower |
54-
| SHA-512/224, file 200 MiB | 3832 | 796 | 79% faster |
55-
| BLAKE3, file 200 MiB | 304 | 391 | 29% slower |
56-
| XXH3-64, file 200 MiB | 73 | 96 | 32% slower |
67+
| Scenario | Native | Zig | Zig vs native |
68+
| ------------------------- | -----: | --: | ------------: |
69+
| SHA-256, file 200 MiB | 297 | 332 | 12% slower |
70+
| SHA-512/224, file 200 MiB | 3832 | 796 | 79% faster |
71+
| BLAKE3, file 200 MiB | 304 | 391 | 29% slower |
72+
| XXH3-64, file 200 MiB | 73 | 96 | 32% slower |
73+
74+
### Desktop Zig
75+
76+
| Scenario | macOS M4 Max | Windows ARM64 VM |
77+
| --------------------- | -----------: | ---------------: |
78+
| SHA-256, file 200 MiB | 79.0 | 539 |
79+
| SHA-512, file 200 MiB | 295 | 332 |
80+
| BLAKE3, file 200 MiB | 102 | 125 |
81+
| XXH3-64, file 200 MiB | 14.0 | 28.0 |
5782

5883
## Full Matrix: iOS 200 MiB
5984

60-
| Algorithm | Native | Zig | Zig vs native |
61-
|---|---:|---:|---:|
62-
| SHA-256 | 228 | 209 | 9% faster |
63-
| MD5 | 587 | 561 | 5% faster |
64-
| SHA-1 | 222 | 552 | 149% slower |
65-
| SHA-224 | 227 | 207 | 9% faster |
66-
| SHA-384 | 316 | 1177 | 272% slower |
67-
| SHA-512 | 317 | 1176 | 271% slower |
68-
| SHA-512/224 | 315 | 1175 | 273% slower |
69-
| SHA-512/256 | 313 | 1173 | 275% slower |
70-
| HMAC-SHA-224 | 223 | 204 | 9% faster |
71-
| HMAC-SHA-256 | 223 | 207 | 7% faster |
72-
| HMAC-SHA-384 | 315 | 1173 | 272% slower |
73-
| HMAC-SHA-512 | 314 | 1174 | 274% slower |
74-
| HMAC-MD5 | 586 | 556 | 5% faster |
75-
| HMAC-SHA-1 | 214 | 549 | 157% slower |
76-
| BLAKE3 | 310 | 302 | 3% faster |
77-
| XXH3-64 | 108 | 66 | 39% faster |
85+
| Algorithm | Native | Zig | Zig vs native |
86+
| ------------ | -----: | ---: | ------------: |
87+
| SHA-256 | 228 | 209 | 9% faster |
88+
| MD5 | 587 | 561 | 5% faster |
89+
| SHA-1 | 222 | 552 | 149% slower |
90+
| SHA-224 | 227 | 207 | 9% faster |
91+
| SHA-384 | 316 | 1177 | 272% slower |
92+
| SHA-512 | 317 | 1176 | 271% slower |
93+
| SHA-512/224 | 315 | 1175 | 273% slower |
94+
| SHA-512/256 | 313 | 1173 | 275% slower |
95+
| HMAC-SHA-224 | 223 | 204 | 9% faster |
96+
| HMAC-SHA-256 | 223 | 207 | 7% faster |
97+
| HMAC-SHA-384 | 315 | 1173 | 272% slower |
98+
| HMAC-SHA-512 | 314 | 1174 | 274% slower |
99+
| HMAC-MD5 | 586 | 556 | 5% faster |
100+
| HMAC-SHA-1 | 214 | 549 | 157% slower |
101+
| BLAKE3 | 310 | 302 | 3% faster |
102+
| XXH3-64 | 108 | 66 | 39% faster |
78103

79104
## Full Matrix: Android 200 MiB
80105

81-
| Algorithm | Native | Zig | Zig vs native |
82-
|---|---:|---:|---:|
83-
| SHA-256 | 297 | 332 | 12% slower |
84-
| MD5 | 585 | 605 | 3% slower |
85-
| SHA-1 | 228 | 581 | 155% slower |
86-
| SHA-224 | 222 | 227 | 2% slower |
87-
| SHA-384 | 552 | 818 | 48% slower |
88-
| SHA-512 | 549 | 808 | 47% slower |
89-
| SHA-512/224 | 3832 | 796 | 79% faster |
90-
| SHA-512/256 | 3868 | 795 | 79% faster |
91-
| HMAC-SHA-224 | 222 | 227 | 2% slower |
92-
| HMAC-SHA-256 | 222 | 225 | 1% slower |
93-
| HMAC-SHA-384 | 553 | 792 | 43% slower |
94-
| HMAC-SHA-512 | 553 | 797 | 44% slower |
95-
| HMAC-MD5 | 581 | 588 | 1% slower |
96-
| HMAC-SHA-1 | 229 | 557 | 143% slower |
97-
| BLAKE3 | 304 | 391 | 29% slower |
98-
| XXH3-64 | 73 | 96 | 32% slower |
106+
| Algorithm | Native | Zig | Zig vs native |
107+
| ------------ | -----: | --: | ------------: |
108+
| SHA-256 | 297 | 332 | 12% slower |
109+
| MD5 | 585 | 605 | 3% slower |
110+
| SHA-1 | 228 | 581 | 155% slower |
111+
| SHA-224 | 222 | 227 | 2% slower |
112+
| SHA-384 | 552 | 818 | 48% slower |
113+
| SHA-512 | 549 | 808 | 47% slower |
114+
| SHA-512/224 | 3832 | 796 | 79% faster |
115+
| SHA-512/256 | 3868 | 795 | 79% faster |
116+
| HMAC-SHA-224 | 222 | 227 | 2% slower |
117+
| HMAC-SHA-256 | 222 | 225 | 1% slower |
118+
| HMAC-SHA-384 | 553 | 792 | 43% slower |
119+
| HMAC-SHA-512 | 553 | 797 | 44% slower |
120+
| HMAC-MD5 | 581 | 588 | 1% slower |
121+
| HMAC-SHA-1 | 229 | 557 | 143% slower |
122+
| BLAKE3 | 304 | 391 | 29% slower |
123+
| XXH3-64 | 73 | 96 | 32% slower |
124+
125+
## Full Matrix: Desktop Zig 200 MiB
126+
127+
| Algorithm | macOS M4 Max | macOS range | Windows ARM64 VM | Windows range |
128+
| ------------ | -----------: | ----------: | ---------------: | ------------: |
129+
| SHA-256 | 79.0 | 79.0-79.0 | 539 | 516-636 |
130+
| MD5 | 238 | 238-239 | 285 | 269-289 |
131+
| SHA-1 | 171 | 169-171 | 201 | 198-205 |
132+
| SHA-224 | 79.0 | 78.0-79.0 | 496 | 496-504 |
133+
| SHA-384 | 295 | 293-295 | 335 | 333-362 |
134+
| SHA-512 | 295 | 293-296 | 332 | 331-337 |
135+
| SHA-512/224 | 296 | 295-296 | 347 | 329-365 |
136+
| SHA-512/256 | 296 | 295-297 | 349 | 340-525 |
137+
| HMAC-SHA-224 | 78.0 | 78.0-79.0 | 502 | 493-515 |
138+
| HMAC-SHA-256 | 78.0 | 78.0-78.0 | 505 | 503-508 |
139+
| HMAC-SHA-384 | 297 | 293-299 | 349 | 340-374 |
140+
| HMAC-SHA-512 | 297 | 295-298 | 338 | 332-339 |
141+
| HMAC-MD5 | 239 | 238-246 | 269 | 266-269 |
142+
| HMAC-SHA-1 | 172 | 172-172 | 202 | 200-203 |
143+
| BLAKE3 | 102 | 102-103 | 125 | 125-126 |
144+
| XXH3-64 | 14.0 | 14.0-15.0 | 28.0 | 28.0-30.0 |
99145

100146
## Notes
101147

CHANGELOG.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,72 @@
11
# Releases
22

3+
## v2.0.7 - Desktop support and leaner npm package
4+
5+
This release line starts desktop support for React Native out-of-tree
6+
platforms. macOS support lands through `react-native-macos`; React Native
7+
Windows support lands through `react-native-windows`.
8+
9+
### Added
10+
11+
- Added experimental macOS support for `react-native-macos`.
12+
- Added a separate macOS example workspace in `examples/macos`.
13+
- Added a macOS Zig prebuilt xcframework at
14+
`third_party/zig-files-hash-prebuilt/macos/ZigFilesHash.xcframework`.
15+
- Added `scripts/build-zig-macos.sh` for rebuilding the macOS Zig prebuilt.
16+
- Added experimental Windows support for `react-native-windows`.
17+
- Added a separate Windows example workspace in `examples/windows`.
18+
- Added Windows Zig prebuilt `.lib` artifacts for `Win32`, `x64`, and `ARM64`
19+
at `third_party/zig-files-hash-prebuilt/windows`.
20+
- Added `scripts/build-zig-windows.sh` for rebuilding Windows Zig prebuilts.
21+
- Added desktop development notes and workspace commands to `CONTRIBUTING.md`.
22+
- Added release benchmark snapshots for experimental macOS and Windows Zig
23+
desktop support to `BENCHMARKS.md`.
24+
- Added platform status badges and short desktop support links to `README.md`.
25+
26+
### Changed
27+
28+
- The podspec now declares both iOS and macOS platforms.
29+
- macOS uses the Zig engine only. The native Apple engine switch remains iOS
30+
specific.
31+
- Windows uses the Zig engine only. There is no Windows native-engine switch.
32+
- Updated the bundled Zig core to `zig-files-hash` `v0.0.6`. Windows Zig
33+
prebuilts are rebuilt with bundled compiler-rt so MSVC consumers do not hit
34+
unresolved runtime helpers such as `__divti3` when linking
35+
`zig_files_hash.lib`.
36+
- iOS and macOS Zig xcframework builds now expose only the C API headers in
37+
their `Headers` directories instead of the full Zig source tree.
38+
- The npm package allowlist now separates repository build inputs from
39+
consumer package contents. Source submodules remain in the repository for
40+
maintainers, while npm users receive only the native build inputs needed by
41+
Gradle/CocoaPods.
42+
- The npm package no longer includes large unused upstream directories such as
43+
`third_party/xxhash/tests`, `third_party/xxhash/cli`,
44+
`third_party/blake3/src`, `third_party/blake3/benches`, and
45+
`third_party/zig-files-hash/src/*.zig`.
46+
- `scripts/check-packed-prebuilts.sh` now verifies the minimal required
47+
third-party artifacts and fails if unnecessary third-party source/test
48+
directories re-enter the packed tarball.
49+
- The Windows example uses the Hermes compiler from the React Native Windows
50+
Hermes NuGet package for release bundling, keeping the generated bytecode
51+
aligned with the RNW runtime used by the app.
52+
53+
### Package size
54+
55+
Local `npm pack --dry-run --json` numbers after this cleanup and the Windows
56+
prebuilt addition:
57+
58+
- package entries: `310` -> `106`
59+
- unpacked size: `24.35 MB` -> `23.24 MB`
60+
- tarball size: `5.75 MB` -> `5.98 MB`
61+
62+
The tarball is slightly larger than before because this release adds three
63+
Windows `.lib` prebuilts. The cleanup still removes unused upstream sources and
64+
keeps the shipped payload focused on required native build inputs. Most of the
65+
remaining package size is the expected Zig prebuilt payload for Android, iOS,
66+
macOS, and Windows.
67+
68+
---
69+
370
## v2.0.6 - Seeded XXH3
471

572
This release adds optional seeded `XXH3-64` / `XXH3-128` support.
@@ -77,6 +144,8 @@ const cacheKey = await fileHash(fileUri, {
77144
- With the optional `zig` engine, seeded XXH3 currently means `XXH3-64`;
78145
`XXH3-128` remains native-only.
79146

147+
---
148+
80149
## v2.0.5 - Zig C ABI v3, streaming files, and cancellation
81150

82151
This release updates the Zig core to `zig-files-hash` `v0.0.5`, moves file

CONTRIBUTING.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ This project is a monorepo managed using [Yarn workspaces](https://yarnpkg.com/f
1010

1111
- The library package in the root directory.
1212
- An example app in the `example/` directory.
13+
- A separate React Native macOS example workspace in `examples/macos/`.
14+
- A separate React Native Windows example workspace in `examples/windows/`.
1315

1416
To get started with the project, make sure you have the correct version of [Node.js](https://nodejs.org/) installed. See the [`.nvmrc`](./.nvmrc) file for the version used in this project.
1517

@@ -35,14 +37,18 @@ If you are changing Zig engine integration and need to refresh Zig prebuilts:
3537
```sh
3638
./scripts/build-zig-android.sh
3739
./scripts/build-zig-ios.sh
40+
./scripts/build-zig-macos.sh
41+
./scripts/build-zig-windows.sh
3842
```
3943

4044
Prebuilt output locations:
4145

4246
- `third_party/zig-files-hash-prebuilt/android/<ABI>/libzig_files_hash.a`
4347
- `third_party/zig-files-hash-prebuilt/ios/ZigFilesHash.xcframework`
48+
- `third_party/zig-files-hash-prebuilt/macos/ZigFilesHash.xcframework`
49+
- `third_party/zig-files-hash-prebuilt/windows/<Platform>/zig_files_hash.lib`
4450

45-
The bundled Zig core is `zig-files-hash v0.0.5` with C ABI v3
51+
The bundled Zig core is `zig-files-hash v0.0.6` with C ABI v3
4652
(`ZFH_API_VERSION = 3`). Custom source/prebuilt builds must use a compatible
4753
Zig C ABI.
4854

@@ -63,6 +69,50 @@ Replace `"<IOS_DEVICE_NAME>"` with your actual iPhone device name.
6369

6470
# 4) iOS / zig / Release / physical device
6571
./scripts/build-zig-ios.sh && (cd example && ZFH_ENGINE=zig bundle exec pod install --project-directory=ios && ZFH_ENGINE=zig npx react-native run-ios --mode Release --device "<IOS_DEVICE_NAME>")
72+
73+
# 5) macOS / zig / Debug
74+
./scripts/build-zig-macos.sh && yarn install && (cd examples/macos && yarn pods && yarn macos)
75+
76+
# 6) Windows / zig / Debug
77+
./scripts/build-zig-windows.sh && yarn install && (cd examples/windows && yarn windows)
78+
```
79+
80+
The desktop examples are Yarn workspaces, so the same commands can also be run
81+
from the repository root:
82+
83+
```sh
84+
yarn workspace @preeternal/react-native-file-hash-macos-example pods
85+
yarn workspace @preeternal/react-native-file-hash-macos-example start --reset-cache
86+
yarn workspace @preeternal/react-native-file-hash-macos-example macos
87+
88+
yarn workspace @preeternal/react-native-file-hash-windows-example start --reset-cache
89+
yarn workspace @preeternal/react-native-file-hash-windows-example windows
90+
```
91+
92+
React Native Windows CLI currently requires PowerShell 7 (`pwsh.exe`) on
93+
`PATH`. Without it, RNW commands can fail with a misleading `unknown command`
94+
error instead of the real cause; see
95+
[microsoft/react-native-windows#16274](https://github.com/microsoft/react-native-windows/issues/16274).
96+
97+
If the Windows example shell needs to be created or refreshed from the official
98+
React Native Windows template, run this from `examples/windows`:
99+
100+
```sh
101+
npx react-native init-windows --overwrite
102+
```
103+
104+
The command can overwrite RNW-generated files such as `windows/` and
105+
`metro.config.js`, so re-apply the monorepo Metro config and local app changes
106+
after regenerating.
107+
108+
If RNW points you to
109+
`node_modules/react-native-windows/scripts/rnw-dependencies.ps1`, it is asking
110+
for the Windows development prerequisites. Run the dependency setup from an
111+
elevated PowerShell window:
112+
113+
```powershell
114+
Set-ExecutionPolicy Unrestricted -Scope Process -Force
115+
iex (New-Object System.Net.WebClient).DownloadString('https://aka.ms/rnw-vs2022-deps.ps1')
66116
```
67117

68118
### Local development and rebuilds

0 commit comments

Comments
 (0)