doxum 0.1.32 → 0.1.34

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
@@ -280,6 +280,28 @@ exposes `read`, `select`, `items`, `update`, `batch`, `scope` and `dispose`.
280
280
  `ProjectionScope` mirrors `read`, `select`, `items`, `update`, `batch` and `dispose`, plus
281
281
  `own(definitionOrTree)` for lifecycle ownership of lazy projection definitions.
282
282
 
283
+ ### Commands inside a batch
284
+
285
+ `runtime.read` and `Readable.current()` read current state, including inside a batch. Derived reads evaluate necessary stale dependencies on demand; batch defers external notifications.
286
+
287
+ ```ts
288
+ const count = input(0);
289
+ const doubled = derive({ count }, ({ count }) => count * 2);
290
+
291
+ function increment() {
292
+ runtime.update(count, runtime.read(count) + 1);
293
+ }
294
+
295
+ runtime.batch(() => {
296
+ increment();
297
+ runtime.read(doubled); // 2
298
+ increment();
299
+ runtime.read(doubled); // 4
300
+ });
301
+ ```
302
+
303
+ Nested batches notify at the outer boundary. Cross-input commands use the same reads without mirrors or borrowed reader parameters. Input equality is checked before acceptance; a failed edit leaves earlier successes intact. A batch is not a transaction, and intermediate reads may advance retained processors more than once. See [current reads and batching](docs/projections.md#current-reads-and-batching) for snapshots, net notifications and lifecycle.
304
+
283
305
  ### Keyed projection
284
306
 
285
307
  `derive.keyed` preserves a keyed driver's membership and order while deriving entries
@@ -400,6 +422,16 @@ key later creates a new generation. A subscribed missing item stays latent and a
400
422
  if the key is later added. Runtime batches follow the net published membership, so a
401
423
  remove/add collapsed to an update does not create a false lifecycle break.
402
424
 
425
+ ### One-to-many keyed derivation
426
+
427
+ ```ts
428
+ const lines = derive.keyed.flatMap(orders, order =>
429
+ order.lines.map(line => [line.id, line] as const)
430
+ );
431
+ ```
432
+
433
+ Each parent returns ordered `[globalKey, value]` tuples, including zero entries. `flatMap` reuses named/dynamic keyed dependencies and only recomputes invalidated parents. Formal output order follows parent order then child order; parent-only reordering runs no selectors. Duplicate final output keys are errors, and present `undefined` is valid. Same-batch transfers preserve a global key's membership identity. Structural changes can rebuild full order; this is not a claim that every operation costs only the changed entries.
434
+
403
435
  ### Runtime-local keyed state
404
436
 
405
437
  Use `input.collection` for selection, expanded state, local overrides and other
@@ -421,7 +453,7 @@ Its state is owned by the `ProjectionRuntime`, not the document, history or pers
421
453
  Updates are synchronous and atomic. It publishes exact keyed `CollectionChange`
422
454
  transitions and preserves order. The optional per-entry equality defaults to `Object.is`
423
455
  and suppresses equivalent `set` operations. Callback and equality failures leave both
424
- the published value and the next draft unchanged.
456
+ the current value and the next draft unchanged.
425
457
 
426
458
  The processor-facing `CollectionChange` type and `collectionChange.keys(...)` utility
427
459
  are exported by `doxum/advanced`. The utility lazily iterates incremental added,
package/dist/advanced.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_transform = require("./transform-CENhTaVN.cjs");
2
+ const require_transform = require("./transform-Bt1Mwgrj.cjs");
3
3
  const require_record = require("./record-ChYUi8PP.cjs");
4
4
  //#region core/src/projection/advanced.ts
5
5
  const resetCollectionChange = Object.freeze({ kind: "reset" });
@@ -1,4 +1,4 @@
1
- import { c as ProjectionChange, d as CollectionRead, l as CollectionChange, n as KeyedDependencyValues, o as KeyedProjection, s as Projection, t as KeyedDependencies, u as CollectionDraft } from "./dependency-B1qIJJBL.cjs";
1
+ import { c as ProjectionChange, d as CollectionRead, l as CollectionChange, n as KeyedDependencyValues, o as KeyedProjection, s as Projection, t as KeyedDependencies, u as CollectionDraft } from "./dependency-Cbf3C8eJ.cjs";
2
2
 
3
3
  //#region core/src/projection/collection/change.d.ts
4
4
  declare const collectionChange: {
@@ -1,4 +1,4 @@
1
- import { c as ProjectionChange, d as CollectionRead, l as CollectionChange, n as KeyedDependencyValues, o as KeyedProjection, s as Projection, t as KeyedDependencies, u as CollectionDraft } from "./dependency-BRgPvyN6.js";
1
+ import { c as ProjectionChange, d as CollectionRead, l as CollectionChange, n as KeyedDependencyValues, o as KeyedProjection, s as Projection, t as KeyedDependencies, u as CollectionDraft } from "./dependency-DzxXGYe1.js";
2
2
 
3
3
  //#region core/src/projection/collection/change.d.ts
4
4
  declare const collectionChange: {
package/dist/advanced.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D as defineProcessor, S as compileProjectionDependencies, l as assertSynchronous, p as collectionChange, t as createKeyedTransform, w as collectionView } from "./transform-gOtqcdHe.js";
1
+ import { D as defineProcessor, S as compileProjectionDependencies, _ as assertSynchronous, r as collectionChange, t as createKeyedTransform, w as collectionView } from "./transform-RghG_Qxs.js";
2
2
  import { n as isPlainObject } from "./record-B2yRhYsc.js";
3
3
  //#region core/src/projection/advanced.ts
4
4
  const resetCollectionChange = Object.freeze({ kind: "reset" });
@@ -134,7 +134,7 @@ type SameKeyConstraint<DriverKey extends string, Dependency> = Dependency extend
134
134
  readonly key: unknown;
135
135
  } | {
136
136
  readonly keys: unknown;
137
- } ? unknown : DriverKey extends SourceKey ? unknown : never : unknown;
137
+ } ? unknown : [DriverKey] extends [SourceKey] ? unknown : never : unknown;
138
138
  type KeyedDependencies<DriverKey extends string, DriverValue, D extends object> = { readonly [P in keyof D]: P extends string ? KeyedDependency<DriverKey, DriverValue> & SameKeyConstraint<DriverKey, D[P]> : never };
139
139
  type KeyedDependencyValues<D extends object> = { readonly [P in keyof D]: D[P] extends {
140
140
  readonly source: KeyedProjection<infer K extends string, infer V>;
@@ -144,4 +144,4 @@ type KeyedDependencyValues<D extends object> = { readonly [P in keyof D]: D[P] e
144
144
  } ? V | undefined : D[P] extends Projection<infer T> ? T : never };
145
145
  //#endregion
146
146
  export { ProjectionDisposedError as _, Input as a, ProjectionChange as c, CollectionRead as d, ExternalCollectionEvent as f, ExternalValueSource as g, ExternalValueEvent as h, CollectionInputDraft as i, CollectionChange as l, ExternalCollectionSource as m, KeyedDependencyValues as n, KeyedProjection as o, ExternalCollectionRead as p, CollectionInput as r, Projection as s, KeyedDependencies as t, CollectionDraft as u, ProjectionError as v };
147
- //# sourceMappingURL=dependency-B1qIJJBL.d.cts.map
147
+ //# sourceMappingURL=dependency-Cbf3C8eJ.d.cts.map
@@ -134,7 +134,7 @@ type SameKeyConstraint<DriverKey extends string, Dependency> = Dependency extend
134
134
  readonly key: unknown;
135
135
  } | {
136
136
  readonly keys: unknown;
137
- } ? unknown : DriverKey extends SourceKey ? unknown : never : unknown;
137
+ } ? unknown : [DriverKey] extends [SourceKey] ? unknown : never : unknown;
138
138
  type KeyedDependencies<DriverKey extends string, DriverValue, D extends object> = { readonly [P in keyof D]: P extends string ? KeyedDependency<DriverKey, DriverValue> & SameKeyConstraint<DriverKey, D[P]> : never };
139
139
  type KeyedDependencyValues<D extends object> = { readonly [P in keyof D]: D[P] extends {
140
140
  readonly source: KeyedProjection<infer K extends string, infer V>;
@@ -144,4 +144,4 @@ type KeyedDependencyValues<D extends object> = { readonly [P in keyof D]: D[P] e
144
144
  } ? V | undefined : D[P] extends Projection<infer T> ? T : never };
145
145
  //#endregion
146
146
  export { ProjectionDisposedError as _, Input as a, ProjectionChange as c, CollectionRead as d, ExternalCollectionEvent as f, ExternalValueSource as g, ExternalValueEvent as h, CollectionInputDraft as i, CollectionChange as l, ExternalCollectionSource as m, KeyedDependencyValues as n, KeyedProjection as o, ExternalCollectionRead as p, CollectionInput as r, Projection as s, KeyedDependencies as t, CollectionDraft as u, ProjectionError as v };
147
- //# sourceMappingURL=dependency-BRgPvyN6.d.ts.map
147
+ //# sourceMappingURL=dependency-DzxXGYe1.d.ts.map