doxum 0.1.5 → 0.1.6

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.
Files changed (46) hide show
  1. package/README.md +46 -5
  2. package/dist/{contract-4E3moCbY.d.ts → contract-I99DUMbN.d.ts} +1 -1
  3. package/dist/index.cjs +73 -608
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +2 -63
  6. package/dist/index.d.ts +3 -64
  7. package/dist/index.js +11 -547
  8. package/dist/index.js.map +1 -1
  9. package/dist/integration-Bs3pOk65.cjs +35 -0
  10. package/dist/integration-Bs3pOk65.cjs.map +1 -0
  11. package/dist/integration-xupBIKjU.js +30 -0
  12. package/dist/integration-xupBIKjU.js.map +1 -0
  13. package/dist/integration.cjs +4 -14
  14. package/dist/integration.d.cts +2 -1
  15. package/dist/integration.d.ts +3 -2
  16. package/dist/integration.js +3 -14
  17. package/dist/local-sync.cjs +1 -1
  18. package/dist/local-sync.d.ts +1 -1
  19. package/dist/local-sync.js +1 -1
  20. package/dist/{ownership-CU-9DKJQ.cjs → ownership-CY0nPXGF.cjs} +4 -1
  21. package/dist/ownership-CY0nPXGF.cjs.map +1 -0
  22. package/dist/{ownership-B-VAPcce.js → ownership-CduRygE7.js} +4 -1
  23. package/dist/ownership-CduRygE7.js.map +1 -0
  24. package/dist/react.cjs +1 -1
  25. package/dist/react.js +1 -1
  26. package/dist/runtime-BJRXF0gq.js +1735 -0
  27. package/dist/runtime-BJRXF0gq.js.map +1 -0
  28. package/dist/runtime-CRijXjYp.cjs +1991 -0
  29. package/dist/runtime-CRijXjYp.cjs.map +1 -0
  30. package/dist/runtime-CUcvhFNP.d.ts +152 -0
  31. package/dist/runtime-C_vKHmhy.d.cts +152 -0
  32. package/package.json +1 -1
  33. package/skills/doxum-runtime/references/guide.en.md +30 -18
  34. package/skills/doxum-runtime/references/guide.zh-CN.md +22 -14
  35. package/skills/doxum-runtime/references/invariants.en.md +12 -9
  36. package/skills/doxum-runtime/references/invariants.zh-CN.md +2 -2
  37. package/skills/doxum-runtime/references/patterns.en.md +29 -56
  38. package/skills/doxum-runtime/references/patterns.zh-CN.md +21 -45
  39. package/dist/dependency-C5_R1tvQ.js +0 -496
  40. package/dist/dependency-C5_R1tvQ.js.map +0 -1
  41. package/dist/dependency-Dfzs3khk.cjs +0 -722
  42. package/dist/dependency-Dfzs3khk.cjs.map +0 -1
  43. package/dist/integration.cjs.map +0 -1
  44. package/dist/integration.js.map +0 -1
  45. package/dist/ownership-B-VAPcce.js.map +0 -1
  46. package/dist/ownership-CU-9DKJQ.cjs.map +0 -1
package/README.md CHANGED
@@ -239,11 +239,52 @@ views, materialized views, and history state.
239
239
 
240
240
  ## Derived Views
241
241
 
242
- `createCollectionView` incrementally projects one table or map into `ids`,
243
- `all`, and cached `item(id)` readables. `createMaterializedView` is for
244
- indexes and aggregates that need custom incremental update logic. A materialized
245
- view may depend on earlier views from the same runtime; Doxum settles that graph
246
- before notifying external listeners.
242
+ `createProjectionRuntime` owns an explicit graph of derived values and keyed
243
+ collections. It combines document runtimes and external values without owning
244
+ their mutations or history.
245
+
246
+ ```ts
247
+ const projection = createProjectionRuntime({ onError: error => console.error(error) });
248
+ const document = projection.document(runtime);
249
+ const taskTitles = projection.map(
250
+ document.collection(path => path.tasks),
251
+ (_id, task) => task.title.get()
252
+ );
253
+ const taskCount = projection.value({
254
+ sources: { tasks: taskTitles },
255
+ build: ({ tasks }) => ({
256
+ value: tasks.ids().length,
257
+ update: ({ tasks }) => ({ kind: 'changed', value: tasks.ids().length }),
258
+ }),
259
+ });
260
+ ```
261
+
262
+ `projection.collection(spec)` handles custom incremental algorithms. Its scoped
263
+ writer supports `set`, `remove`, `order`, and `replace`; `previous` and `next`
264
+ provide scoped reads. Declare all sources and use their native commit impacts
265
+ or upstream collection changes to choose candidate keys. Doxum stages writes,
266
+ applies equality, and publishes exact `CollectionImpact` changes. It does not
267
+ automatically track item dependencies. `ids`, lazy `all`, and cached `item(id)`
268
+ implement `Readable` and work with `useReadable`.
269
+
270
+ Use `projection.input(initial, { isEqual })` for boundary values such as container
271
+ size. Its application-owned `set` updates a read-only `source`. Use
272
+ `projection.fromReadable(existing, { isEqual })` for an existing external source.
273
+ Neither replaces a document with domain mutation semantics.
274
+
275
+ Wrap the entire synchronous application action in `projection.batch(() => ...)`
276
+ before its first document commit to combine document changes and editor cleanup.
277
+ Batches nest, preserve committed source changes on exceptions, and provide no
278
+ cross-document rollback. Projection reads inside a batch return the last
279
+ published state. Document listeners still run synchronously.
280
+
281
+ All affected nodes settle before listeners. Output revisions change only when
282
+ their output changes. Update failures discard the processor instance and attempt
283
+ one fresh build; persistent faults block descendants, while independent branches
284
+ continue. Errors reach `onError` and, when inside document notification, the
285
+ committed result's `observerErrors`. Manual `rebuild()` uses the same graph.
286
+ Dispose the projection with its service; component unmount only unsubscribes.
287
+ Disposing a node with consumers is rejected, and disposed handles throw.
247
288
 
248
289
  ## Data Ownership
249
290
 
@@ -549,4 +549,4 @@ type DocumentRuntime<TSchema extends DocumentSchema> = DocumentReadable<TSchema>
549
549
  };
550
550
  //#endregion
551
551
  export { EntityEntry as $, tree as $t, MutationIssue as A, MapNode as At, CollectionReader as B, ValueSelector as Bt, contains as C, DocumentTreeValue as Ct, resolveAddress as D, FieldNode as Dt, read as E, EntitySchemaNode as Et, FieldWriter as F, RecordNode as Ft, TreeReader as G, list as Gt, FieldReader as H, VariantShape as Ht, ListWriter as I, SchemaPath as It, DictSetOperation as J, optional as Jt, DictDeleteOperation as K, map as Kt, MapWriter as L, SingleNode as Lt, CollectionWriter as M, ObjectShape as Mt, DictionaryWriter as N, OptionalNode as Nt, CollectionImpact as O, ImpactTarget as Ot, DocumentWriter as P, ReadonlyDocument as Pt, EntityCreateOperation as Q, table as Qt, TreeWriter as R, TableNode as Rt, AddressRef as S, DocumentTreeNode as St, overlaps as T, DocumentValueOfShape as Tt, ListReader as U, dict as Ut, DocumentReader as V, VariantNode as Vt, ReaderOfNode as W, field as Wt, DocumentOperation as X, schema as Xt, DocumentAnchor as Y, record as Yt, DocumentOperationUnion as Z, single as Zt, CommandFootprint as _, DictNode as _t, DocumentProblem as a, ListMoveOperation as at, decodeCommandFootprint as b, DocumentNode as bt, DocumentRuntime as c, TreeInsertOperation as ct, LocalHistory as d, TreeReplaceOperation as dt, variant as en, EntityMoveOperation as et, ObserverError as f, TreeSetOperation as ft, Unsubscribe as g, CollectionSelector as gt, TransactionResult as h, CollectionNode as ht, DocumentDisposedError as i, ListInsertOperation as it, MutationIssueCode as j, ObjectNode as jt, DocumentImpact as k, ListNode as kt, DocumentTransaction as l, TreeMoveOperation as lt, PreparedUpdateResult as m, VariantReplaceOperation as mt, DocumentCommit as n, FieldClearOperation as nt, DocumentReadable as o, ListRemoveOperation as ot, OperationResult as p, ValueClearOperation as pt, DictReplaceOperation as q, object as qt, DocumentDiagnostic as r, FieldSetOperation as rt, DocumentReentrancyError as s, ListReplaceOperation as st, CommitSource as t, EntityRemoveOperation as tt, HistoryState as u, TreeRemoveOperation as ut, CommandFootprintTarget as v, DocumentAddress as vt, debugKey as w, DocumentValueOfNode as wt, footprintsOverlap as x, DocumentSchema as xt, commandFootprint as y, DocumentListConfig as yt, WriterOfNode as z, TreeNode as zt };
552
- //# sourceMappingURL=contract-4E3moCbY.d.ts.map
552
+ //# sourceMappingURL=contract-I99DUMbN.d.ts.map