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 +33 -1
- package/dist/advanced.cjs +1 -1
- package/dist/advanced.d.cts +1 -1
- package/dist/advanced.d.ts +1 -1
- package/dist/advanced.js +1 -1
- package/dist/{dependency-B1qIJJBL.d.cts → dependency-Cbf3C8eJ.d.cts} +2 -2
- package/dist/{dependency-BRgPvyN6.d.ts → dependency-DzxXGYe1.d.ts} +2 -2
- package/dist/index.cjs +580 -212
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -12
- package/dist/index.d.ts +19 -12
- package/dist/index.js +580 -212
- package/dist/index.js.map +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js.map +1 -1
- package/dist/{transform-CENhTaVN.cjs → transform-Bt1Mwgrj.cjs} +310 -280
- package/dist/transform-Bt1Mwgrj.cjs.map +1 -0
- package/dist/{transform-gOtqcdHe.js → transform-RghG_Qxs.js} +305 -275
- package/dist/transform-RghG_Qxs.js.map +1 -0
- package/package.json +1 -1
- package/skills/doxum-runtime/SKILL.md +4 -2
- package/skills/doxum-runtime/references/integrations.md +2 -2
- package/skills/doxum-runtime/references/invariants.md +6 -3
- package/skills/doxum-runtime/references/projections.md +62 -3
- package/skills/doxum-runtime/references/public-api.md +14 -4
- package/skills/doxum-runtime/references/recipes.md +32 -0
- package/dist/transform-CENhTaVN.cjs.map +0 -1
- package/dist/transform-gOtqcdHe.js.map +0 -1
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
|
|
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-
|
|
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" });
|
package/dist/advanced.d.cts
CHANGED
|
@@ -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-
|
|
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: {
|
package/dist/advanced.d.ts
CHANGED
|
@@ -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-
|
|
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,
|
|
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-
|
|
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-
|
|
147
|
+
//# sourceMappingURL=dependency-DzxXGYe1.d.ts.map
|