js-bao 0.12.0-alpha.9 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1310,6 +1310,9 @@ public server path).
1310
1310
 
1311
1311
  - **Vite / Create React App**: copy `node_modules/sql.js/dist/sql-wasm.wasm` into
1312
1312
  your project's `public/` directory so it is served at `/sql-wasm.wasm`.
1313
+ Copy it from the sql.js that js-bao resolved, and again whenever that version
1314
+ changes: sql.js only loads the wasm built with it, and a wasm from another
1315
+ version rejects `ensureReady()` with a `sql.js wasm mismatch` error.
1313
1316
  - **Custom path**: if the wasm lives elsewhere, point at it via `DatabaseConfig`:
1314
1317
 
1315
1318
  ```typescript
@@ -1596,6 +1599,24 @@ See the `examples/` directory for complete working examples:
1596
1599
  Changes a consumer of this package can observe, including the on-disk
1597
1600
  behaviour of `js-bao/cloudflare/do` (`DurableObjectEngine`). Newest first.
1598
1601
 
1602
+ - **A db3 binds with no `Y.Doc`; the browser entry loads Yjs on demand**
1603
+ (unreleased). `connectDocument(id, null, permission, { documentFormat: 3 })`
1604
+ binds a db3, and the connected record's `yDoc` is `null` for a format-3
1605
+ document whatever was passed (`ConnectedDocument.yDoc` is now
1606
+ `Y.Doc | null`). A format-1 connect with `null` is refused, naming the fix.
1607
+ `ModelRegistry.initializeAllForDocument` and `BaseModel.initializeForDocument`
1608
+ take `Y.Doc | null` too. The browser entry (`js-bao/browser`, the `browser`
1609
+ condition) imports `yjs` only at the first format-1 `connectDocument`, or
1610
+ when `loadYjs()` is awaited, so an app that only uses db3s never loads it.
1611
+ Its CommonJS file (`dist/browser.cjs`) loads Yjs at the same moment with
1612
+ `require("yjs")`, so it shares the copy a CommonJS caller requires. Every entry exports `loadYjs()`, `yjsLoaded()` and `YjsNotLoadedError`; on
1613
+ the `node`, default and `cloudflare` entries Yjs is static and `loadYjs()`
1614
+ resolves at once. On the browser entry, every helper that takes a `Y.Doc`
1615
+ (`discoverSchema`, `syncModelMeta` and the rest) throws `YjsNotLoadedError`
1616
+ until Yjs is loaded: `await loadYjs()` first when you use one on a `Y.Doc` of
1617
+ your own before any format-1 document is connected. `yjs` stays a peer
1618
+ dependency; an app that wants it in its startup bundle imports it once
1619
+ statically.
1599
1620
  - **Breaking: format 2 (large document) is removed** (0.12.0). Every
1600
1621
  `models/format2*` export that served the epoch overlay is gone — the record
1601
1622
  store and its asynchronous host, the overlay observer and fold, the epoch