doxum 0.1.33 → 0.1.35
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 +18 -7
- package/dist/advanced.cjs +1 -1
- package/dist/advanced.js +1 -1
- package/dist/index.cjs +395 -142
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -11
- package/dist/index.d.ts +13 -11
- package/dist/index.js +395 -142
- package/dist/index.js.map +1 -1
- package/dist/{transform-A9Lx5R2l.js → transform-3mj0eStL.js} +147 -152
- package/dist/transform-3mj0eStL.js.map +1 -0
- package/dist/{transform-CSPGdBe5.cjs → transform-D45KWMzj.cjs} +148 -159
- package/dist/transform-D45KWMzj.cjs.map +1 -0
- package/package.json +1 -1
- package/skills/doxum-runtime/SKILL.md +3 -3
- 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 +48 -20
- package/skills/doxum-runtime/references/public-api.md +22 -21
- package/skills/doxum-runtime/references/recipes.md +25 -2
- package/dist/transform-A9Lx5R2l.js.map +0 -1
- package/dist/transform-CSPGdBe5.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -282,26 +282,25 @@ exposes `read`, `select`, `items`, `update`, `batch`, `scope` and `dispose`.
|
|
|
282
282
|
|
|
283
283
|
### Commands inside a batch
|
|
284
284
|
|
|
285
|
-
|
|
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
286
|
|
|
287
287
|
```ts
|
|
288
288
|
const count = input(0);
|
|
289
289
|
const doubled = derive({ count }, ({ count }) => count * 2);
|
|
290
290
|
|
|
291
291
|
function increment() {
|
|
292
|
-
runtime.
|
|
293
|
-
runtime.update(count, read(count) + 1);
|
|
294
|
-
});
|
|
292
|
+
runtime.update(count, runtime.read(count) + 1);
|
|
295
293
|
}
|
|
296
294
|
|
|
297
295
|
runtime.batch(() => {
|
|
298
296
|
increment();
|
|
297
|
+
runtime.read(doubled); // 2
|
|
299
298
|
increment();
|
|
299
|
+
runtime.read(doubled); // 4
|
|
300
300
|
});
|
|
301
|
-
runtime.read(doubled); // 4
|
|
302
301
|
```
|
|
303
302
|
|
|
304
|
-
|
|
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.
|
|
305
304
|
|
|
306
305
|
### Keyed projection
|
|
307
306
|
|
|
@@ -433,6 +432,18 @@ const lines = derive.keyed.flatMap(orders, order =>
|
|
|
433
432
|
|
|
434
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.
|
|
435
434
|
|
|
435
|
+
### Compute a keyed result from named inputs
|
|
436
|
+
|
|
437
|
+
```ts
|
|
438
|
+
const errors = derive.keyed.fromEntries(
|
|
439
|
+
{ form: formState, rules: validationRules },
|
|
440
|
+
({ form, rules }) => validateForm(form, rules).map(error => [error.id, error]),
|
|
441
|
+
(before, after) => before.message === after.message && before.field === after.field
|
|
442
|
+
);
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
`fromEntries` uses the same named dependencies as `derive`, including the single-source form `{ form }`. The synchronous callback returns the complete ordered `[key, value]` array: `[]` is empty, missing keys are removed, and `[key, undefined]` is present. Duplicate keys are errors. Per-entry equality preserves equivalent value references while membership/order changes remain observable. It computes and scans the full result, then publishes exact changes; use `flatMap` for per-parent incremental computation or `derive.keyed.get` as an input for precise active-entry dependencies. See [Projection API](docs/projections.md#keyed-results-from-named-dependencies).
|
|
446
|
+
|
|
436
447
|
### Runtime-local keyed state
|
|
437
448
|
|
|
438
449
|
Use `input.collection` for selection, expanded state, local overrides and other
|
|
@@ -454,7 +465,7 @@ Its state is owned by the `ProjectionRuntime`, not the document, history or pers
|
|
|
454
465
|
Updates are synchronous and atomic. It publishes exact keyed `CollectionChange`
|
|
455
466
|
transitions and preserves order. The optional per-entry equality defaults to `Object.is`
|
|
456
467
|
and suppresses equivalent `set` operations. Callback and equality failures leave both
|
|
457
|
-
the
|
|
468
|
+
the current value and the next draft unchanged.
|
|
458
469
|
|
|
459
470
|
The processor-facing `CollectionChange` type and `collectionChange.keys(...)` utility
|
|
460
471
|
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-D45KWMzj.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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as defineProcessor, S as compileProjectionDependencies, _ as assertSynchronous, r as collectionChange, t as createKeyedTransform, w as collectionView } from "./transform-3mj0eStL.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" });
|