doxum 0.1.31 → 0.1.32

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
@@ -354,14 +354,22 @@ projection dependencies by name:
354
354
  const cardContent = derive.keyed(
355
355
  items,
356
356
  {
357
+ metadata: { source: metadataByItemId },
357
358
  record: { source: records, key: item => item.recordId },
358
359
  view: activeView,
359
360
  fields: visibleFields,
360
361
  },
361
- (item, itemId, { record, view, fields }) => renderCard(itemId, item, record, view, fields)
362
+ (item, itemId, { metadata, record, view, fields }) =>
363
+ renderCard(itemId, item, metadata, record, view, fields)
362
364
  );
363
365
  ```
364
366
 
367
+ Use `{ source }` when driver and dependency use the same key. It directly binds driver
368
+ key `K` to source key `K`, requires the driver key type to be assignable to the source
369
+ key type, and avoids a redundant `key: (_value, id) => id` selector. Source value or
370
+ membership changes invalidate only the driver entry with that key; source order-only
371
+ changes do not invalidate it.
372
+
365
373
  For `{ source, key }` dependencies, the Runtime owns output-key → source-key bindings
366
374
  and reverse invalidation. A missing source entry resolves to `undefined` but remains
367
375
  bound, so adding it later invalidates the dependent output keys. An ordinary projection
package/dist/advanced.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_transform = require("./transform-B6YxfR0R.cjs");
2
+ const require_transform = require("./transform-CENhTaVN.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-B3E65M1E.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-B1qIJJBL.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-BYbdDHNa.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-BRgPvyN6.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-BQY9I6il.js";
1
+ import { D as defineProcessor, S as compileProjectionDependencies, l as assertSynchronous, p as collectionChange, t as createKeyedTransform, w as collectionView } from "./transform-gOtqcdHe.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" });
@@ -113,6 +113,11 @@ type SingularKeyedDependency<DriverKey extends string, DriverValue, SourceKey ex
113
113
  readonly key: (value: DriverValue, key: DriverKey) => Synchronous<SourceKey | undefined>;
114
114
  readonly keys?: never;
115
115
  };
116
+ type SameKeyedDependency<SourceKey extends string, SourceValue> = {
117
+ readonly source: KeyedProjection<SourceKey, SourceValue>;
118
+ readonly key?: never;
119
+ readonly keys?: never;
120
+ };
116
121
  type PluralKeyedDependency<DriverKey extends string, DriverValue, SourceKey extends string, SourceValue> = {
117
122
  readonly source: KeyedProjection<SourceKey, SourceValue>;
118
123
  readonly keys: (value: DriverValue, key: DriverKey) => Synchronous<readonly SourceKey[]>;
@@ -122,8 +127,15 @@ type KeyedDependency<DriverKey extends string, DriverValue> = (Projection<unknow
122
127
  readonly source?: never;
123
128
  readonly key?: never;
124
129
  readonly keys?: never;
125
- }) | SingularKeyedDependency<DriverKey, DriverValue, string, unknown> | PluralKeyedDependency<DriverKey, DriverValue, string, unknown>;
126
- type KeyedDependencies<DriverKey extends string, DriverValue, D extends object> = { readonly [P in keyof D]: P extends string ? KeyedDependency<DriverKey, DriverValue> : never };
130
+ }) | SameKeyedDependency<string, unknown> | SingularKeyedDependency<DriverKey, DriverValue, string, unknown> | PluralKeyedDependency<DriverKey, DriverValue, string, unknown>;
131
+ type SameKeyConstraint<DriverKey extends string, Dependency> = Dependency extends {
132
+ readonly source: KeyedProjection<infer SourceKey extends string, unknown>;
133
+ } ? Dependency extends {
134
+ readonly key: unknown;
135
+ } | {
136
+ readonly keys: unknown;
137
+ } ? unknown : DriverKey extends SourceKey ? unknown : never : unknown;
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 };
127
139
  type KeyedDependencyValues<D extends object> = { readonly [P in keyof D]: D[P] extends {
128
140
  readonly source: KeyedProjection<infer K extends string, infer V>;
129
141
  readonly keys: (...args: never[]) => unknown;
@@ -132,4 +144,4 @@ type KeyedDependencyValues<D extends object> = { readonly [P in keyof D]: D[P] e
132
144
  } ? V | undefined : D[P] extends Projection<infer T> ? T : never };
133
145
  //#endregion
134
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 };
135
- //# sourceMappingURL=dependency-B3E65M1E.d.cts.map
147
+ //# sourceMappingURL=dependency-B1qIJJBL.d.cts.map
@@ -113,6 +113,11 @@ type SingularKeyedDependency<DriverKey extends string, DriverValue, SourceKey ex
113
113
  readonly key: (value: DriverValue, key: DriverKey) => Synchronous<SourceKey | undefined>;
114
114
  readonly keys?: never;
115
115
  };
116
+ type SameKeyedDependency<SourceKey extends string, SourceValue> = {
117
+ readonly source: KeyedProjection<SourceKey, SourceValue>;
118
+ readonly key?: never;
119
+ readonly keys?: never;
120
+ };
116
121
  type PluralKeyedDependency<DriverKey extends string, DriverValue, SourceKey extends string, SourceValue> = {
117
122
  readonly source: KeyedProjection<SourceKey, SourceValue>;
118
123
  readonly keys: (value: DriverValue, key: DriverKey) => Synchronous<readonly SourceKey[]>;
@@ -122,8 +127,15 @@ type KeyedDependency<DriverKey extends string, DriverValue> = (Projection<unknow
122
127
  readonly source?: never;
123
128
  readonly key?: never;
124
129
  readonly keys?: never;
125
- }) | SingularKeyedDependency<DriverKey, DriverValue, string, unknown> | PluralKeyedDependency<DriverKey, DriverValue, string, unknown>;
126
- type KeyedDependencies<DriverKey extends string, DriverValue, D extends object> = { readonly [P in keyof D]: P extends string ? KeyedDependency<DriverKey, DriverValue> : never };
130
+ }) | SameKeyedDependency<string, unknown> | SingularKeyedDependency<DriverKey, DriverValue, string, unknown> | PluralKeyedDependency<DriverKey, DriverValue, string, unknown>;
131
+ type SameKeyConstraint<DriverKey extends string, Dependency> = Dependency extends {
132
+ readonly source: KeyedProjection<infer SourceKey extends string, unknown>;
133
+ } ? Dependency extends {
134
+ readonly key: unknown;
135
+ } | {
136
+ readonly keys: unknown;
137
+ } ? unknown : DriverKey extends SourceKey ? unknown : never : unknown;
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 };
127
139
  type KeyedDependencyValues<D extends object> = { readonly [P in keyof D]: D[P] extends {
128
140
  readonly source: KeyedProjection<infer K extends string, infer V>;
129
141
  readonly keys: (...args: never[]) => unknown;
@@ -132,4 +144,4 @@ type KeyedDependencyValues<D extends object> = { readonly [P in keyof D]: D[P] e
132
144
  } ? V | undefined : D[P] extends Projection<infer T> ? T : never };
133
145
  //#endregion
134
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 };
135
- //# sourceMappingURL=dependency-BYbdDHNa.d.ts.map
147
+ //# sourceMappingURL=dependency-BRgPvyN6.d.ts.map
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_transform = require("./transform-B6YxfR0R.cjs");
2
+ const require_transform = require("./transform-CENhTaVN.cjs");
3
3
  const require_record = require("./record-ChYUi8PP.cjs");
4
4
  const require_driver = require("./driver-CN3dGxQI.cjs");
5
5
  //#region core/src/schema/model.ts
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { $ as table, A as ParseError, B as DocumentListConfig, C as Read, D as ChangeSet, E as Change, F as CollectionPath, G as ReadonlyValue, H as DocumentTreeValue, I as PathValueOf, J as field, K as Schema, L as SchemaPath, M as parse, N as CollectionEntry, O as MemberChange, P as CollectionId, Q as optional, R as DocumentAddress, S as Draft, T as snapshot, U as Infer, V as DocumentTreeNode, W as ObjectSchema, X as map, Y as list, Z as object, _ as Unsubscribe, a as DocumentProblem, b as CollectionImpact, c as HistoryState, d as OperationResult, et as tree, f as ReadonlyDocument, g as Readable, h as TransactionResult, i as DocumentDisposedError, j as ParseIssue, k as ValueTransition, l as LocalHistory, m as TransactionRejected, n as DocumentCommit, o as DocumentReentrancyError, p as Synchronous, q as Validator, r as DocumentDiagnostic, s as DocumentRuntime, t as CommitSource, tt as variant, u as ObserverError, v as MutationIssue, w as replace, x as DocumentImpact, y as MutationIssueCode, z as DocumentAnchor } from "./contract-CNR6BS75.cjs";
2
- import { _ as ProjectionDisposedError, a as Input, f as ExternalCollectionEvent, g as ExternalValueSource, h as ExternalValueEvent, i as CollectionInputDraft, m as ExternalCollectionSource, n as KeyedDependencyValues, o as KeyedProjection, p as ExternalCollectionRead, r as CollectionInput, s as Projection, t as KeyedDependencies, v as ProjectionError } from "./dependency-B3E65M1E.cjs";
2
+ import { _ as ProjectionDisposedError, a as Input, f as ExternalCollectionEvent, g as ExternalValueSource, h as ExternalValueEvent, i as CollectionInputDraft, m as ExternalCollectionSource, n as KeyedDependencyValues, o as KeyedProjection, p as ExternalCollectionRead, r as CollectionInput, s as Projection, t as KeyedDependencies, v as ProjectionError } from "./dependency-B1qIJJBL.cjs";
3
3
 
4
4
  //#region core/src/runtime.d.ts
5
5
  declare const createDocument: <S extends ObjectSchema<object>>(input: {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { $ as table, A as ParseError, B as DocumentListConfig, C as Read, D as ChangeSet, E as Change, F as CollectionPath, G as ReadonlyValue, H as DocumentTreeValue, I as PathValueOf, J as field, K as Schema, L as SchemaPath, M as parse, N as CollectionEntry, O as MemberChange, P as CollectionId, Q as optional, R as DocumentAddress, S as Draft, T as snapshot, U as Infer, V as DocumentTreeNode, W as ObjectSchema, X as map, Y as list, Z as object, _ as Unsubscribe, a as DocumentProblem, b as CollectionImpact, c as HistoryState, d as OperationResult, et as tree, f as ReadonlyDocument, g as Readable, h as TransactionResult, i as DocumentDisposedError, j as ParseIssue, k as ValueTransition, l as LocalHistory, m as TransactionRejected, n as DocumentCommit, o as DocumentReentrancyError, p as Synchronous, q as Validator, r as DocumentDiagnostic, s as DocumentRuntime, t as CommitSource, tt as variant, u as ObserverError, v as MutationIssue, w as replace, x as DocumentImpact, y as MutationIssueCode, z as DocumentAnchor } from "./contract-COgxO5sv.js";
2
- import { _ as ProjectionDisposedError, a as Input, f as ExternalCollectionEvent, g as ExternalValueSource, h as ExternalValueEvent, i as CollectionInputDraft, m as ExternalCollectionSource, n as KeyedDependencyValues, o as KeyedProjection, p as ExternalCollectionRead, r as CollectionInput, s as Projection, t as KeyedDependencies, v as ProjectionError } from "./dependency-BYbdDHNa.js";
2
+ import { _ as ProjectionDisposedError, a as Input, f as ExternalCollectionEvent, g as ExternalValueSource, h as ExternalValueEvent, i as CollectionInputDraft, m as ExternalCollectionSource, n as KeyedDependencyValues, o as KeyedProjection, p as ExternalCollectionRead, r as CollectionInput, s as Projection, t as KeyedDependencies, v as ProjectionError } from "./dependency-BRgPvyN6.js";
3
3
 
4
4
  //#region core/src/runtime.d.ts
5
5
  declare const createDocument: <S extends ObjectSchema<object>>(input: {
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as ownProjections, C as snapshotDependencyValue, D as defineProcessor, E as snapshotCollectionView, M as projectionRef, N as profile, O as defineSource, S as compileProjectionDependencies, T as mapRead, _ as createCollectionChange, a as createKeyedDependencyRuntime, b as sameArray, c as assertScope, d as ProjectionDisposedError, f as ProjectionError, g as collectionHasStructuralChange, h as collectionChangeTouchesKey, i as compileKeyedDependencies, j as producerOf, k as isProjection, l as assertSynchronous, m as collectionChangeIntersects, n as keyedAbsent, o as outputKind, r as assertKeyedProjection, s as createKeyRelation, t as createKeyedTransform, u as createScheduler, v as diffCollection, w as collectionView, x as snapshotArray, y as iterableMatchesArray } from "./transform-BQY9I6il.js";
1
+ import { A as ownProjections, C as snapshotDependencyValue, D as defineProcessor, E as snapshotCollectionView, M as projectionRef, N as profile, O as defineSource, S as compileProjectionDependencies, T as mapRead, _ as createCollectionChange, a as createKeyedDependencyRuntime, b as sameArray, c as assertScope, d as ProjectionDisposedError, f as ProjectionError, g as collectionHasStructuralChange, h as collectionChangeTouchesKey, i as compileKeyedDependencies, j as producerOf, k as isProjection, l as assertSynchronous, m as collectionChangeIntersects, n as keyedAbsent, o as outputKind, r as assertKeyedProjection, s as createKeyRelation, t as createKeyedTransform, u as createScheduler, v as diffCollection, w as collectionView, x as snapshotArray, y as iterableMatchesArray } from "./transform-gOtqcdHe.js";
2
2
  import { n as isPlainObject, r as isRecord, t as installOwn } from "./record-B2yRhYsc.js";
3
3
  import { c as AddressIndex, d as invalidValue, f as children, g as validate, h as parent, i as contextOf, l as MutationRejected, m as is, o as decodeChanges, p as contains$1, r as bindContext, s as sealChanges, t as assertRuntimeWritable, u as fail } from "./driver-B7RR-VfX.js";
4
4
  //#region core/src/schema/model.ts
@@ -750,7 +750,7 @@ const assertKeyedProjection = (projection, role) => {
750
750
  if (outputKind(projection) !== "collection") throw new TypeError(`${role} must be a keyed collection projection.`);
751
751
  };
752
752
  const compileDynamicDependency = (value, label) => {
753
- if (!require_record.isPlainObject(value) || isProjection(value)) throw new TypeError(`${label} dependencies must be projections or singular/plural keyed lookups.`);
753
+ if (!require_record.isPlainObject(value) || isProjection(value)) throw new TypeError(`${label} dependencies must be projections or keyed lookups.`);
754
754
  const candidate = {};
755
755
  const allowed = new Set([
756
756
  "source",
@@ -768,11 +768,15 @@ const compileDynamicDependency = (value, label) => {
768
768
  if (name === "keys") hasKeys = true;
769
769
  }
770
770
  if (!isProjection(candidate.source)) throw new TypeError(`${label} dynamic keyed dependency source must be a projection.`);
771
- if (hasKey === hasKeys) throw new TypeError(`${label} dynamic keyed dependency must declare exactly one of key or keys.`);
771
+ if (hasKey && hasKeys) throw new TypeError(`${label} dynamic keyed dependency must not declare both key and keys.`);
772
+ assertKeyedProjection(candidate.source, `${label} dynamic keyed dependency source`);
773
+ if (!hasKey && !hasKeys) return {
774
+ kind: "same",
775
+ projection: candidate.source
776
+ };
772
777
  const singular = hasKey;
773
778
  const selector = singular ? candidate.key : candidate.keys;
774
779
  if (typeof selector !== "function") throw new TypeError(`${label} dynamic keyed dependency selector must be a function.`);
775
- assertKeyedProjection(candidate.source, `${label} dynamic keyed dependency source`);
776
780
  return singular ? {
777
781
  kind: "one",
778
782
  projection: candidate.source,
@@ -833,18 +837,28 @@ const selectedKeys = (dependency, value, key) => {
833
837
  };
834
838
  const emptyValues = Object.freeze(Object.create(null));
835
839
  const createKeyedDependencyRuntime = (compiled) => {
836
- const states = compiled.entries.map((entry, index) => entry.kind === "global" ? {
837
- kind: "global",
838
- entry,
839
- sourceIndex: index + 1,
840
- revision: -1,
841
- globalValue: void 0
842
- } : {
843
- kind: "dynamic",
844
- entry,
845
- sourceIndex: index + 1,
846
- relation: createKeyRelation(),
847
- revision: -1
840
+ const states = compiled.entries.map((entry, index) => {
841
+ const sourceIndex = index + 1;
842
+ if (entry.kind === "global") return {
843
+ kind: "global",
844
+ entry,
845
+ sourceIndex,
846
+ revision: -1,
847
+ globalValue: void 0
848
+ };
849
+ if (entry.kind === "same") return {
850
+ kind: "same",
851
+ entry,
852
+ sourceIndex,
853
+ revision: -1
854
+ };
855
+ return {
856
+ kind: "dynamic",
857
+ entry,
858
+ sourceIndex,
859
+ relation: createKeyRelation(),
860
+ revision: -1
861
+ };
848
862
  });
849
863
  let driverRevision = -1;
850
864
  return {
@@ -863,9 +877,13 @@ const createKeyedDependencyRuntime = (compiled) => {
863
877
  values[state.entry.name] = state.globalValue;
864
878
  continue;
865
879
  }
866
- const dependency = state.entry;
867
880
  const source = sources[state.sourceIndex];
868
881
  if (source.kind !== "collection") throw new TypeError("Dynamic keyed dependency resolved to a non-collection source.");
882
+ if (state.kind === "same") {
883
+ values[state.entry.name] = source.read.get(driverKey);
884
+ continue;
885
+ }
886
+ const dependency = state.entry;
869
887
  if (dependency.kind === "one") {
870
888
  const selected = selectedKey(dependency, driverValue, driverKey);
871
889
  state.relation.replaceOne(driverKey, selected);
@@ -897,6 +915,12 @@ const createKeyedDependencyRuntime = (compiled) => {
897
915
  all = true;
898
916
  continue;
899
917
  }
918
+ if (state.kind === "same") {
919
+ for (const entry of source.change.added) dirty.add(entry.key);
920
+ for (const entry of source.change.updated) dirty.add(entry.key);
921
+ for (const entry of source.change.removed) dirty.add(entry.key);
922
+ continue;
923
+ }
900
924
  for (const entry of source.change.added) for (const dependent of state.relation.reverse(entry.key) ?? []) dirty.add(dependent);
901
925
  for (const entry of source.change.updated) for (const dependent of state.relation.reverse(entry.key) ?? []) dirty.add(dependent);
902
926
  for (const entry of source.change.removed) for (const dependent of state.relation.reverse(entry.key) ?? []) dirty.add(dependent);
@@ -917,7 +941,7 @@ const createKeyedDependencyRuntime = (compiled) => {
917
941
  for (const state of states) {
918
942
  state.revision = -1;
919
943
  if (state.kind === "global") state.globalValue = void 0;
920
- else state.relation.clear();
944
+ else if (state.kind === "dynamic") state.relation.clear();
921
945
  }
922
946
  driverRevision = -1;
923
947
  }
@@ -1228,4 +1252,4 @@ Object.defineProperty(exports, "snapshotDependencyValue", {
1228
1252
  }
1229
1253
  });
1230
1254
 
1231
- //# sourceMappingURL=transform-B6YxfR0R.cjs.map
1255
+ //# sourceMappingURL=transform-CENhTaVN.cjs.map