Skip to content

Commit 0992b14

Browse files
authored
sync(common-v8): cautious wave1 cherry-pick sync (#58)
## Summary Cautious, commit-by-commit `upstream/common-v8` sync wave from a history-separated upstream branch (no merge, no unrelated-history merge). This PR ports low-risk/high-value pieces and explicitly defers high-risk runtime/dependency waves. ## Candidate upstream commits and decisions ### PORTED - `e903c47d` Add Set shim typings and refactor Abort polyfills - Ported as fork-equivalent: added `packages/react-native/src/Polyfills.ts` and `packages/react-native/src/SetPrototypeShimModules.d.ts`. - `a4287569` Improved polyfills for web and React Native runtimes (selective) - Ported selective parts in fork-relevant paths: - `packages/common/src/Polyfills.ts` - `packages/common/test/_browserSetup.ts` - `packages/react-native/test/Polyfills.test.ts` - `8c4101ac` Simplified cleaning (selective) - Ported safe root `.gitignore` patterns only. ### SKIPPED - `edf950f6` VSCode settings only (`.vscode/settings.json`) - `c06944fa` `apps/web` docs/minimal playground (not relevant in this fork layout for wave1) ### DEFERRED - `ec61d7fd` Expo 55 mega-wave (large lockfile/deps churn) - `9364b02c` shared sync resource management refactor (runtime-heavy) - Equivalent worker bootstrap from `a4287569` in web worker was tested and reverted due regression: - `@evolu/web (webkit)` `Worker.worker.test.ts` failed with `Object not disposable` - deferred to wave2 runtime branch ## Fork-compat adjustments included - Switched `@evolu/common/polyfills` imports to `@evolu/common` (fork export shape). - Added explicit `set.prototype.*` dependencies to `packages/react-native/package.json`. - Tightened Promise polyfill typing for TS 5.9/Node 24+ to keep build green. ## Risks and mitigations - **Risk:** polyfill behavior differences across RN/web runtimes. - **Mitigation:** added/ran dedicated `Polyfills.test.ts` (19 tests). - **Risk:** web worker runtime regression from direct upstream mapping. - **Mitigation:** reverted problematic worker bootstrap equivalent in wave1; keep for wave2 investigation. - **Risk:** cleanup changes accidentally hiding important artifacts. - **Mitigation:** only additive, conservative `.gitignore` changes; no destructive clean script switch. ## Validation (local) Required gates from plan: - `bun run build` ✅ - `bun run test` ✅ - `bun run lint` ✅ (Biome warnings only in upstream-derived test style; no errors) - `bun run coverage:lane:active` ✅ - `(cd examples/react-expo && bun run web:export)` ✅ Targeted checks: - `bunx vitest run --project react-native packages/react-native/test/Polyfills.test.ts` ✅ ## Wave2 plan Next branch: `sync/common-v8-2026-03-01-wave2-runtime` - Tackle deferred runtime refactor (`9364b02c`) - Re-evaluate selected parts of Expo55 wave (`ec61d7fd`) with explicit lockfile/dependency strategy - Revisit web worker polyfill bootstrap with architecture-specific adaptation + focused webkit worker tests <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Poznámky k vydání * **Nové funkce** * Polyfilly pro React Native (Promise statické metody, AbortController/AbortSignal) veřejně dostupné. * Polyfilly pro metody Set prototype. * Nová asynchronní pomocná funkce arrayFromAsync. * **Dokumentace** * Přepsané tabulky v README a aktualizovaný obrázek. * **Testy** * Přidána rozsáhlá sada testů pro polyfily a abort/timeout; přesun některých testů. * **Chores** * Aktualizovány položky .gitignore a drobné verze devDependencies. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents 45c6aac + 854bdc4 commit 0992b14

File tree

20 files changed

+1238
-192
lines changed

20 files changed

+1238
-192
lines changed

.changeset/array-module-refactor.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ if (isNonEmptyArray(mutableArr)) { ... }
3030
### New Functions
3131

3232
- **`arrayFrom`** — creates a readonly array from an iterable or by generating elements with a length and mapper
33+
- **`arrayFromAsync`** — creates a readonly array from an async iterable (or iterable of promises) and awaits all values
3334
- **`flatMapArray`** — maps each element to an array and flattens the result, preserving non-empty type when applicable
3435
- **`concatArrays`** — concatenates two arrays, returning non-empty when at least one input is non-empty
3536
- **`sortArray`** — returns a new sorted array (wraps `toSorted`), preserving non-empty type

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ coverage
2020
tmp
2121
__screenshots__
2222
*.tsBuildInfo
23+
*.tsbuildinfo
2324
.generated
2425

2526
.ai/
27+
.vite
28+
next-env.d.ts
29+
30+
# apps/relay
31+
apps/relay/data/*
32+
!apps/relay/data/.gitkeep
33+
34+
# examples/react-expo
35+
examples/react-expo/.expo/
36+
examples/react-expo/expo-env.d.ts
37+
examples/react-expo/ios
38+
examples/react-expo/android

README.md

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,55 @@ Evolu is a TypeScript library and local-first platform.
1414
## 🪴 Project Activity
1515

1616
<p align="center">
17-
<img src="https://repobeats.axiom.co/api/embed/<hash>.svg" alt="Repobeats analytics image" />
17+
<img src="https://repobeats.axiom.co/api/embed/9dbe31e742524e552a28ac3a7edf1d06e987b2ae.svg" alt="Repobeats analytics image" />
1818
</p>
1919

2020
## Integration Matrix
2121

22-
Coverage snapshot date: `2026-02-27` (from `bun run test:coverage` and `bun run test:coverage:bun`).
23-
24-
| Package | Supported Versions | Implementation Status | Coverage (Statements / Branches) | Notes |
25-
| --- | --- | --- | --- | --- |
26-
| `@evolu/common` | Node `>=24.0.0` | Stable core | `94.47% / 89.57%` | Main engine + local-first protocol/runtime. |
27-
| `@evolu/web` | `@evolu/common ^7.4.1` | Stable | `99.33% / 93.71%` | Browser runtime (Worker/SharedWorker/Web Locks path). |
28-
| `@evolu/nodejs` | Node `>=24.0.0`, `@evolu/common ^7.4.1` | Stable | `95.74% / 87.50%` | Includes relay adapter hardening (WS lifecycle + subscribe/broadcast/unsubscribe + restart coverage). |
29-
| `@evolu/react-web` | React `>=19`, React DOM `>=19`, `@evolu/web ^2.4.0` | Stable thin adapter | `100% / 100%` | Thin web integration wrapper. |
30-
| `@evolu/react-native` | React Native `>=0.84`, Expo `>=55`, `@op-engineering/op-sqlite >=12` | Lane-gated hardening | `100.00% / 100.00%` (lane gate) | Strict file gates (`react-native` + `expo`) are enforced at `100/100/100/100` for scoped source files. |
31-
| `@evolu/react` | React `>=19` | Wrapper support | `0% / 0%` | Hook wrappers; coverage expansion planned. |
32-
| `@evolu/vue` | Vue `>=3.5.29` | Wrapper support | `0% / 0%` | Composition API wrappers; coverage expansion planned. |
33-
| `@evolu/svelte` | Svelte `>=5.53.3`, `@evolu/web ^2.4.0` | Wrapper support | `0% / 0%` | Store-based wrappers; coverage expansion planned. |
34-
| `@evolu/bun` (private) | `@evolu/common ^7.4.1`, Bun `1.3.x` | Experimental adapter | `100% / 100%` | Measured via Bun coverage runner on `BunDbWorker.ts`. |
22+
Coverage snapshot date: `2026-03-01` (from `bun run verify`).
23+
24+
| Package | Baseline | Status |
25+
| ---------------------- | --------------------------------------- | -------------------- |
26+
| `@evolu/common` | Node `>=24.0.0` | Stable core |
27+
| `@evolu/web` | Browser + `@evolu/common ^7.4.1` | Stable |
28+
| `@evolu/nodejs` | Node `>=24.0.0` + `@evolu/common ^7.4.1` | Stable |
29+
| `@evolu/react-web` | React `>=19` + `@evolu/web ^2.4.0` | Thin adapter |
30+
| `@evolu/react-native` | RN `>=0.84`, Expo `>=55` | Lane-gated hardening |
31+
| `@evolu/react` | React `>=19` | Wrapper support |
32+
| `@evolu/vue` | Vue `>=3.5.29` | Wrapper support |
33+
| `@evolu/svelte` | Svelte `>=5.53.3` | Wrapper support |
34+
| `@evolu/bun` (private) | Bun `1.3.x` + `@evolu/common ^7.4.1` | Experimental adapter |
35+
36+
Coverage notes (Statements / Branches):
37+
38+
- `@evolu/common`: `94.46% / 89.64%`
39+
- `@evolu/web`: `98.90% / 93.30%`
40+
- `@evolu/nodejs`: `95.74% / 85.71%`
41+
- `@evolu/react-native`: `99.32% / 98.17%` + strict `react-native`/`expo` file gates at `100/100/100/100`
42+
- `@evolu/bun` (private): `100% / 100%` (`BunDbWorker.ts`)
43+
- Wrapper packages (`@evolu/react`, `@evolu/vue`, `@evolu/svelte`) are still coverage-expansion candidates.
3544

3645
## Planned Integrations (Roadmap View)
3746

38-
| Integration | Fit | Priority | Expected Path | Main Risk / Blocker |
39-
| --- | --- | --- | --- | --- |
40-
| Next.js (App Router) | Very high | P0 | Official `@evolu/react-web` guide + production example for Server/Client boundaries. | SSR/client boundary handling and Worker lifecycle in edge runtimes. |
41-
| TanStack Start | Very high | P0 | Use `@evolu/react` + `@evolu/web`, focus on SSR/client boundary docs and example app. | SSR edge cases (worker lifecycle and hydration boundary). |
42-
| Astro | High | P0 | Client-island integration on top of `@evolu/web`, starter template + docs. | Island hydration timing and worker boot ordering. |
43-
| SvelteKit | High | P1 | `@evolu/svelte` + `@evolu/web` reference app with SSR-aware browser-only init. | Avoiding server-side execution for browser worker primitives. |
44-
| Nuxt 3 | High | P1 | Vue composables + client-only plugin/module (`@evolu/vue` + `@evolu/web`). | Nitro/SSR split and client plugin ordering. |
45-
| Remix / React Router | High | P1 | React adapter with explicit browser init boundaries and route loader guidance. | Loader/action patterns can accidentally cross server/client boundary. |
46-
| Tauri | High | P1 | Web runtime in WebView + optional Rust-side relay bridge for desktop sync scenarios. | Packaging/runtime differences across desktop targets. |
47-
| Electron | High | P1 | Reuse web runtime in renderer + optional Node relay bridge in main process. | Multi-process lifecycle and secure IPC boundaries. |
48-
| Capacitor (Ionic) | Medium | P2 | Reuse web runtime in WebView first, then mobile storage/perf hardening. | Mobile WebView storage consistency and background lifecycle constraints. |
49-
| Flutter | Medium/Low | P2 | Separate adapter/SDK (likely not a thin wrapper) or protocol-level bridge. | Different runtime/language model (Dart), no direct reuse of TS hooks. |
47+
| Integration | Priority | Focus |
48+
| -------------------- | -------- | ---------------------------------------------- |
49+
| Next.js (App Router) | P0 | Official web guide + SSR/client boundary docs |
50+
| TanStack Start | P0 | React/web adapter docs + production example |
51+
| Astro | P0 | Client-island starter + worker boot guidance |
52+
| SvelteKit | P1 | Browser-only init reference app |
53+
| Nuxt 3 | P1 | Client plugin/module integration path |
54+
| Remix / React Router | P1 | Explicit browser init in route patterns |
55+
| Tauri | P1 | WebView runtime + optional relay bridge |
56+
| Electron | P1 | Renderer runtime + optional main-process relay |
57+
| Capacitor (Ionic) | P2 | WebView-first runtime hardening |
58+
| Flutter | P2 | Separate SDK/bridge exploration |
59+
60+
Main blockers to track:
61+
62+
- SSR/client boundaries and hydration order in framework runtimes.
63+
- Worker lifecycle consistency across browser, edge, and desktop shells.
64+
- Desktop packaging/process boundaries (Electron/Tauri).
65+
- Mobile WebView storage consistency and background lifecycle.
5066

5167
Current recommendation:
5268

@@ -63,15 +79,15 @@ Current recommendation:
6379

6480
Third-party runtime dependencies used by `@evolu/common`:
6581

66-
| Dependency | Why It Is Used |
67-
| --- | --- |
68-
| `@noble/ciphers` | Audited cryptographic ciphers for encryption flows. |
69-
| `@noble/hashes` | Audited hash primitives used by protocol/auth internals. |
70-
| `@scure/bip39` | Mnemonic handling for owner/account recovery flows. |
82+
| Dependency | Why It Is Used |
83+
| ----------------- | ------------------------------------------------------------- |
84+
| `@noble/ciphers` | Audited cryptographic ciphers for encryption flows. |
85+
| `@noble/hashes` | Audited hash primitives used by protocol/auth internals. |
86+
| `@scure/bip39` | Mnemonic handling for owner/account recovery flows. |
7187
| `disposablestack` | Disposable stack compatibility utility for cleanup semantics. |
72-
| `kysely` | Typed SQL query builder integration. |
73-
| `msgpackr` | Binary message serialization for protocol payloads. |
74-
| `zod` | Runtime schema validation and parsing. |
88+
| `kysely` | Typed SQL query builder integration. |
89+
| `msgpackr` | Binary message serialization for protocol payloads. |
90+
| `zod` | Runtime schema validation and parsing. |
7591

7692
Dependency policy:
7793

apps/relay/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"devDependencies": {
2121
"@evolu/tsconfig": "workspace:*",
22-
"@types/node": "^25.3.2",
22+
"@types/node": "^25.3.3",
2323
"typescript": "^5.9.3"
2424
},
2525
"engines": {

0 commit comments

Comments
 (0)