doxum 0.1.36 → 0.1.37

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/dist/index.d.cts CHANGED
@@ -40,7 +40,7 @@ type KeyedEntries<K extends string, V> = readonly (readonly [K, V])[];
40
40
  type Equality$2<T> = (previous: T, next: T) => boolean;
41
41
  declare function createKeyedFrom<K extends string, V>(source: Projection<readonly V[]>, keyOf: (value: NoInfer<V>) => Synchronous<K>, equality?: Equality$2<V>): KeyedProjection<K, V>;
42
42
  declare function createKeyedFrom<K extends string, V>(source: readonly V[], keyOf: (value: NoInfer<V>) => Synchronous<K>, equality?: Equality$2<V>): KeyedProjection<K, V>;
43
- declare function createKeyedFromEntries<const D extends ProjectionDependencies, K extends string, V>(dependencies: D, compute: (values: ProjectionValues<D>) => Synchronous<KeyedEntries<K, V>>, equality?: Equality$2<NoInfer<V>>): KeyedProjection<K, V>;
43
+ declare function createKeyedFromEntries<const D extends ProjectionDependencies, K extends string, V>(dependencies: D, compute: (values: ProjectionValues<D>) => Synchronous<KeyedEntries<K, V>>, equality?: Equality$2<V>): KeyedProjection<K, V>;
44
44
  declare function createKeyedMerge<K extends string, V>(sources: readonly KeyedProjection<K, V>[], options: {
45
45
  readonly conflict: 'error' | 'first' | 'last';
46
46
  readonly equality?: Equality$2<V>;
package/dist/index.d.ts CHANGED
@@ -40,7 +40,7 @@ type KeyedEntries<K extends string, V> = readonly (readonly [K, V])[];
40
40
  type Equality$2<T> = (previous: T, next: T) => boolean;
41
41
  declare function createKeyedFrom<K extends string, V>(source: Projection<readonly V[]>, keyOf: (value: NoInfer<V>) => Synchronous<K>, equality?: Equality$2<V>): KeyedProjection<K, V>;
42
42
  declare function createKeyedFrom<K extends string, V>(source: readonly V[], keyOf: (value: NoInfer<V>) => Synchronous<K>, equality?: Equality$2<V>): KeyedProjection<K, V>;
43
- declare function createKeyedFromEntries<const D extends ProjectionDependencies, K extends string, V>(dependencies: D, compute: (values: ProjectionValues<D>) => Synchronous<KeyedEntries<K, V>>, equality?: Equality$2<NoInfer<V>>): KeyedProjection<K, V>;
43
+ declare function createKeyedFromEntries<const D extends ProjectionDependencies, K extends string, V>(dependencies: D, compute: (values: ProjectionValues<D>) => Synchronous<KeyedEntries<K, V>>, equality?: Equality$2<V>): KeyedProjection<K, V>;
44
44
  declare function createKeyedMerge<K extends string, V>(sources: readonly KeyedProjection<K, V>[], options: {
45
45
  readonly conflict: 'error' | 'first' | 'last';
46
46
  readonly equality?: Equality$2<V>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doxum",
3
- "version": "0.1.36",
3
+ "version": "0.1.37",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "Doxum is a typed runtime for complex mutable documents.",
@@ -200,6 +200,8 @@ const errors = derive.keyed.fromEntries(
200
200
 
201
201
  Each synchronous computation returns the **complete** finite `readonly (readonly [K, V])[]` result. The tuple order is formal output order; `[]` removes all members. Keys must be unique strings. `[key, undefined]` is a present member. A key missing from the next result is removed. Reordering alone does not invent value updates.
202
202
 
203
+ Value inference uses both `compute` and a typed `equality` callback, including computations with empty-array branches and union values. These cases do not require an output `KeyedProjection<K, V>` annotation. Equality must accept every emitted value variant. Normal TypeScript literal widening still applies; preserve discriminants with a declared value type or `as const` when needed.
204
+
203
205
  Equality defaults to `Object.is` and compares values under the same key, not the outer array or tuple objects. Equality-equivalent values retain their existing reference; new value objects require stable references or a suitable equality callback. Equality cannot suppress membership/order. Callback failures, thenables, malformed tuples, duplicate keys and equality failures install no partial output and follow normal initialization/processor recovery semantics. Output definitions are lazy, reusable across runtimes and compatible with scopes and `runtime.items()`.
204
206
 
205
207
  This is **whole-result computation with incremental output publication**. Each necessary evaluation runs the callback for all inputs and scans the old/new result membership, costing O(old result size + new result size), plus callback work and keyed dependency snapshot costs. A keyed dependency is consumed as a whole: `records.get(activeId)` inside the callback does not establish an entry dependency. For precise dynamic lookup, compose the existing scalar lookup first:
@@ -350,6 +350,7 @@ derive.keyed.from(source: Projection<readonly V[]>, keyOf, equality?): KeyedProj
350
350
  derive.keyed.from(source: readonly V[], keyOf, equality?): KeyedProjection<K,V>
351
351
  derive.keyed.fromEntries(dependencies, compute, equality?): KeyedProjection<K,V>
352
352
  // compute(readonlyNamedValues) returns Synchronous<readonly (readonly [K,V])[]>
353
+ // V is inferred from compute and typed equality; equality must accept every emitted variant.
353
354
  derive.keyed.merge(sources, { conflict: 'error' | 'first' | 'last', equality? }): KeyedProjection<K,V>
354
355
  derive.keyed.merge(sources, { conflict: 'resolve', resolve, equality? }): KeyedProjection<K,V>
355
356
  derive.keyed.subset(source, orderedKeysOrProjection): KeyedProjection<K,V>