@directive-run/core 1.13.0 → 1.15.0

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.
Files changed (80) hide show
  1. package/dist/adapter-utils.cjs +1 -1
  2. package/dist/adapter-utils.d.cts +3 -3
  3. package/dist/adapter-utils.d.ts +3 -3
  4. package/dist/adapter-utils.js +1 -1
  5. package/dist/{chunk-I722BZA5.js → chunk-3ETCZLAY.js} +3 -3
  6. package/dist/chunk-3ETCZLAY.js.map +1 -0
  7. package/dist/chunk-4MTC4BSK.cjs +2 -0
  8. package/dist/chunk-4MTC4BSK.cjs.map +1 -0
  9. package/dist/{chunk-644QZVTT.js → chunk-F5JPF4YX.js} +3 -3
  10. package/dist/chunk-F5JPF4YX.js.map +1 -0
  11. package/dist/{chunk-X7G7UBXU.cjs → chunk-JGPPJV5P.cjs} +3 -3
  12. package/dist/chunk-JGPPJV5P.cjs.map +1 -0
  13. package/dist/{chunk-2FF6QGOA.js → chunk-O4GQEV4G.js} +2 -2
  14. package/dist/chunk-O4GQEV4G.js.map +1 -0
  15. package/dist/{chunk-ENZEHIL7.cjs → chunk-Q5UTBMX2.cjs} +3 -3
  16. package/dist/chunk-Q5UTBMX2.cjs.map +1 -0
  17. package/dist/{chunk-T4TRJEJN.cjs → chunk-RWFKUNF7.cjs} +2 -2
  18. package/dist/chunk-RWFKUNF7.cjs.map +1 -0
  19. package/dist/chunk-RWJV7QLM.js +3 -0
  20. package/dist/chunk-RWJV7QLM.js.map +1 -0
  21. package/dist/{chunk-NPX5EKPP.cjs → chunk-SUCLMJSZ.cjs} +3 -3
  22. package/dist/chunk-SUCLMJSZ.cjs.map +1 -0
  23. package/dist/chunk-YYFRZJO2.js +2 -0
  24. package/dist/chunk-YYFRZJO2.js.map +1 -0
  25. package/dist/{audit-ledger-dxvslGi3.d.ts → index-D_oNDe4l.d.cts} +78 -50
  26. package/dist/{audit-ledger-Dc6hAXam.d.cts → index-c5wGodzh.d.ts} +78 -50
  27. package/dist/index.cjs +2 -2
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +6 -6
  30. package/dist/index.d.ts +6 -6
  31. package/dist/index.js +2 -2
  32. package/dist/index.js.map +1 -1
  33. package/dist/internals.cjs +1 -1
  34. package/dist/internals.d.cts +5 -5
  35. package/dist/internals.d.ts +5 -5
  36. package/dist/internals.js +1 -1
  37. package/dist/plugins/index.cjs +2 -2
  38. package/dist/plugins/index.cjs.map +1 -1
  39. package/dist/plugins/index.d.cts +2 -2
  40. package/dist/plugins/index.d.ts +2 -2
  41. package/dist/plugins/index.js +1 -1
  42. package/dist/plugins/index.js.map +1 -1
  43. package/dist/{plugins-BIzXaYbg.d.cts → plugins-BpNMkJRw.d.cts} +47 -8
  44. package/dist/{plugins-BIzXaYbg.d.ts → plugins-BpNMkJRw.d.ts} +47 -8
  45. package/dist/{predicate-BxQVf0ug.d.ts → predicate-BinuVL33.d.ts} +1 -1
  46. package/dist/{predicate-Bnx3LN7P.d.cts → predicate-DN1MnDbi.d.cts} +1 -1
  47. package/dist/system-MMCZKPI2.js +2 -0
  48. package/dist/{system-A6VYKLVF.js.map → system-MMCZKPI2.js.map} +1 -1
  49. package/dist/system-RHSYFDOB.cjs +2 -0
  50. package/dist/{system-CDJMD5O5.cjs.map → system-RHSYFDOB.cjs.map} +1 -1
  51. package/dist/testing.cjs +1 -1
  52. package/dist/testing.cjs.map +1 -1
  53. package/dist/testing.d.cts +1 -1
  54. package/dist/testing.d.ts +1 -1
  55. package/dist/testing.js +1 -1
  56. package/dist/testing.js.map +1 -1
  57. package/dist/{utils-Mg55IerF.d.cts → utils-BZBBwS5A.d.cts} +10 -1
  58. package/dist/{utils-Mg55IerF.d.ts → utils-BZBBwS5A.d.ts} +10 -1
  59. package/dist/worker.cjs +1 -1
  60. package/dist/worker.cjs.map +1 -1
  61. package/dist/worker.d.cts +24 -7
  62. package/dist/worker.d.ts +24 -7
  63. package/dist/worker.js +1 -1
  64. package/dist/worker.js.map +1 -1
  65. package/package.json +1 -1
  66. package/dist/chunk-2FF6QGOA.js.map +0 -1
  67. package/dist/chunk-644QZVTT.js.map +0 -1
  68. package/dist/chunk-ENZEHIL7.cjs.map +0 -1
  69. package/dist/chunk-I722BZA5.js.map +0 -1
  70. package/dist/chunk-IXRS4LM4.cjs +0 -2
  71. package/dist/chunk-IXRS4LM4.cjs.map +0 -1
  72. package/dist/chunk-NPX5EKPP.cjs.map +0 -1
  73. package/dist/chunk-PA6VC32N.js +0 -2
  74. package/dist/chunk-PA6VC32N.js.map +0 -1
  75. package/dist/chunk-R2GHSCTR.js +0 -3
  76. package/dist/chunk-R2GHSCTR.js.map +0 -1
  77. package/dist/chunk-T4TRJEJN.cjs.map +0 -1
  78. package/dist/chunk-X7G7UBXU.cjs.map +0 -1
  79. package/dist/system-A6VYKLVF.js +0 -2
  80. package/dist/system-CDJMD5O5.cjs +0 -2
@@ -814,7 +814,7 @@ interface BatchItemResult<T = unknown> {
814
814
  * Results from batch resolution with per-item status.
815
815
  * The array order must match the order of requirements passed in.
816
816
  */
817
- type BatchResolveResults<T = unknown> = Array<BatchItemResult<T>>;
817
+ type BatchResolveResults<T = unknown> = BatchItemResult<T>[];
818
818
  /** Resolver context passed to resolve function */
819
819
  interface ResolverContext<S extends Schema = Schema> {
820
820
  readonly facts: Facts<S>;
@@ -1098,7 +1098,7 @@ interface CreateSystemOptionsNamed<Modules extends ModulesMap> {
1098
1098
  /** Modules as object = namespaced access */
1099
1099
  modules: Modules;
1100
1100
  /** Plugins to register */
1101
- plugins?: Array<Plugin<ModuleSchema>>;
1101
+ plugins?: Plugin<ModuleSchema>[];
1102
1102
  /** History configuration for snapshot-based state history */
1103
1103
  history?: HistoryOption;
1104
1104
  /** Trace: per-run reconciliation changelog */
@@ -1363,7 +1363,7 @@ interface CreateSystemOptionsSingle<S extends ModuleSchema> {
1363
1363
  /** Single module = direct access (use `modules` for multiple) */
1364
1364
  module: ModuleDef<S>;
1365
1365
  /** Plugins to register */
1366
- plugins?: Array<Plugin<ModuleSchema>>;
1366
+ plugins?: Plugin<ModuleSchema>[];
1367
1367
  /** History configuration for snapshot-based state history */
1368
1368
  history?: HistoryOption;
1369
1369
  /** Trace: per-run reconciliation changelog */
@@ -1589,6 +1589,45 @@ declare function isSingleModuleSystem(system: AnySystem): boolean;
1589
1589
  * ```
1590
1590
  */
1591
1591
  declare function isNamespacedSystem(system: AnySystem): boolean;
1592
+ /**
1593
+ * Extract the typed facts shape from a Directive system or module schema.
1594
+ *
1595
+ * Useful in framework adapter callbacks (`bind`, `useSelector`, etc.) so an
1596
+ * updater that receives a facts snapshot inherits the schema's narrow types
1597
+ * instead of falling back to `Record<string, unknown>`.
1598
+ *
1599
+ * Accepts any of:
1600
+ * - `SingleModuleSystem<S>` — returns `InferFacts<S>`
1601
+ * - `NamespacedSystem<Modules>` — returns the namespaced facts shape
1602
+ * - A raw `ModuleSchema` — returns `InferFacts<M>`
1603
+ *
1604
+ * @example
1605
+ * ```ts
1606
+ * const system = createSystem({ module: trafficLight });
1607
+ *
1608
+ * function paintLight(facts: SystemFacts<typeof system>) {
1609
+ * // facts.phase is "red" | "green" | "yellow", not unknown
1610
+ * }
1611
+ * ```
1612
+ */
1613
+ type SystemFacts<T> = T extends SingleModuleSystem<infer S> ? InferFacts<S> : T extends NamespacedSystem<infer Modules> ? NamespacedFacts<Modules> : T extends ModuleSchema ? InferFacts<T> : never;
1614
+ /**
1615
+ * Extract the typed derivations shape from a Directive system or module schema.
1616
+ *
1617
+ * Mirrors {@link SystemFacts} but for `system.derive`. The `DerivationsControl`
1618
+ * runtime-control methods (`assign`/`register`/`restore`) are stripped — what
1619
+ * adapter callbacks need is the derived value shape, not the control surface.
1620
+ *
1621
+ * @example
1622
+ * ```ts
1623
+ * const system = createSystem({ module: trafficLight });
1624
+ *
1625
+ * function statusLine(derived: SystemDerived<typeof system>) {
1626
+ * return derived.isRed ? "STOP" : "GO";
1627
+ * }
1628
+ * ```
1629
+ */
1630
+ type SystemDerived<T> = T extends SingleModuleSystem<infer S> ? InferDerivations<S> : T extends NamespacedSystem<infer Modules> ? NamespacedDerivations<Modules> : T extends ModuleSchema ? InferDerivations<T> : never;
1592
1631
 
1593
1632
  /**
1594
1633
  * Module Types - Type definitions for modules with consolidated schema
@@ -2419,7 +2458,7 @@ interface DynamicConstraintDef<M extends ModuleSchema = ModuleSchema> {
2419
2458
  }
2420
2459
  /** Effect definition for dynamic registration — typed facts */
2421
2460
  interface DynamicEffectDef<M extends ModuleSchema = ModuleSchema> {
2422
- run: (facts: Readonly<InferSchema<M["facts"]>>, prev: InferSchema<M["facts"]> | null) => void | (() => void) | Promise<void | (() => void)>;
2461
+ run: (facts: Readonly<InferSchema<M["facts"]>>, prev: InferSchema<M["facts"]> | null) => void | (() => void) | Promise<undefined | (() => void)>;
2423
2462
  deps?: Array<string & keyof InferSchema<M["facts"]>>;
2424
2463
  /**
2425
2464
  * Optional declarative trigger — a {@link FactPredicate} that gates whether
@@ -2669,7 +2708,7 @@ interface System<M extends ModuleSchema = ModuleSchema> {
2669
2708
  * Keys are auto-detected -- pass any mix of fact keys and derivation keys.
2670
2709
  * @example system.subscribe(["count", "doubled"], () => { ... })
2671
2710
  */
2672
- subscribe(ids: Array<ObservableKeys<M>>, listener: () => void): () => void;
2711
+ subscribe(ids: ObservableKeys<M>[], listener: () => void): () => void;
2673
2712
  /**
2674
2713
  * Watch a fact or derivation for value changes.
2675
2714
  * The key is auto-detected -- works with both fact keys and derivation keys.
@@ -2753,8 +2792,8 @@ interface System<M extends ModuleSchema = ModuleSchema> {
2753
2792
  }
2754
2793
  /** System configuration */
2755
2794
  interface SystemConfig<M extends ModuleSchema = ModuleSchema> {
2756
- modules: Array<ModuleDef<M>>;
2757
- plugins?: Array<Plugin<any>>;
2795
+ modules: ModuleDef<M>[];
2796
+ plugins?: Plugin<any>[];
2758
2797
  history?: HistoryOption;
2759
2798
  trace?: TraceOption;
2760
2799
  errorBoundary?: ErrorBoundaryConfig;
@@ -3060,4 +3099,4 @@ interface Plugin<M extends ModuleSchema = ModuleSchema> {
3060
3099
  onTraceComplete?: (entry: TraceEntry) => void;
3061
3100
  }
3062
3101
 
3063
- export { type PatchSpec as $, type AnySystem as A, type BatchConfig as B, type ClauseResult as C, type DefinitionMeta as D, type EffectsDef as E, type FactPredicate as F, type HistoryOption as G, type HistoryAPI as H, type HistoryState as I, type InferDerivations as J, type InferEvents as K, type InferFacts as L, type ModuleSchema as M, type NamespacedSystem as N, type InferRequirementTypes as O, type Plugin as P, type InferRequirements as Q, type RequirementWithId as R, type SchemaType as S, type TypedDerivationsDef as T, type InferSchemaType as U, type InferSelectorState as V, type KeySelector as W, type MetaAccessor as X, type MetaMatch as Y, type ObservationEvent as Z, type OperatorObject as _, type Facts as a, type RequirementsSchema as a$, type PatchValue as a0, type PayloadRef as a1, type PredicateClause as a2, type PredicateCombinator as a3, type PredicateCombinatorKey as a4, type PredicateObject as a5, type PredicateOp as a6, type RetryPolicy as a7, type Schema as a8, type Snapshot as a9, type DerivationReturnType as aA, type DerivationsControl as aB, type DerivationsSchema as aC, type DeriveAccessor as aD, type DispatchEventsFromSchema as aE, type EffectCleanup as aF, type EffectsControl as aG, type EventPayloadSchema as aH, type EventsAccessor as aI, type EventsAccessorFromSchema as aJ, type EventsDef as aK, type EventsSchema as aL, type FactKeys as aM, type FactReturnType as aN, type FlexibleEventHandler as aO, type HistoryConfig as aP, type InferEventPayloadFromSchema as aQ, type InferRequirementPayloadFromSchema as aR, type InferSchema as aS, type MutableNamespacedFacts as aT, type NamespacedDerivations as aU, type NamespacedEventsAccessor as aV, type NamespacedFacts as aW, type ObservableKeys as aX, type RequirementExplanation as aY, type RequirementOutput as aZ, type RequirementPayloadSchema$1 as a_, type System as aa, type SystemConfig as ab, type SystemInspection as ac, type SystemMode as ad, type SystemSnapshot as ae, type TraceEntry as af, isNamespacedSystem as ag, isSingleModuleSystem as ah, type FactsStore as ai, type ConstraintsDef as aj, type ConstraintState as ak, type ResolversDef as al, type ResolverStatus as am, type FactChange as an, type ReconcileResult as ao, type RecoveryStrategy as ap, type ErrorSource as aq, type RetryLaterConfig as ar, type BatchItemResult as as, type BatchResolveResults as at, type ConstraintsControl as au, type CrossModuleConstraintDef as av, type CrossModuleDerivationFn as aw, type CrossModuleEffectDef as ax, type CrossModuleFactsWithSelf as ay, type DerivationKeys as az, type TypedEventsDef as b, type ResolverContext as b0, type ResolversControl as b1, type SnapshotMeta as b2, type SystemEvent as b3, type TraceConfig as b4, type TypedConstraintDef as b5, type TypedResolverContext as b6, type TypedResolverDef as b7, type UnionEvents as b8, type RequirementOutput$1 as b9, type TypedConstraintsDef as c, type TypedResolversDef as d, type ModuleHooks as e, type CrossModuleDeps as f, type CrossModuleDerivationsDef as g, type CrossModuleEffectsDef as h, type CrossModuleConstraintsDef as i, type ModuleDef as j, type CreateSystemOptionsSingle as k, type SingleModuleSystem as l, type ModulesMap as m, type CreateSystemOptionsNamed as n, type TraceOption as o, type ErrorBoundaryConfig as p, type Requirement as q, type RequirementKeyFn as r, DirectiveError as s, type DistributableSnapshot as t, type DistributableSnapshotOptions as u, type DynamicConstraintDef as v, type DynamicEffectDef as w, type DynamicResolverDef as x, type FactTemplate as y, type FactsSnapshot as z };
3102
+ export { type PatchSpec as $, type AnySystem as A, type BatchConfig as B, type ClauseResult as C, type DefinitionMeta as D, type EffectsDef as E, type FactPredicate as F, type HistoryOption as G, type HistoryAPI as H, type HistoryState as I, type InferDerivations as J, type InferEvents as K, type InferFacts as L, type ModuleSchema as M, type NamespacedSystem as N, type InferRequirementTypes as O, type Plugin as P, type InferRequirements as Q, type RequirementWithId as R, type SchemaType as S, type TypedDerivationsDef as T, type InferSchemaType as U, type InferSelectorState as V, type KeySelector as W, type MetaAccessor as X, type MetaMatch as Y, type ObservationEvent as Z, type OperatorObject as _, type Facts as a, type RequirementOutput as a$, type PatchValue as a0, type PayloadRef as a1, type PredicateClause as a2, type PredicateCombinator as a3, type PredicateCombinatorKey as a4, type PredicateObject as a5, type PredicateOp as a6, type RetryPolicy as a7, type Schema as a8, type Snapshot as a9, type CrossModuleFactsWithSelf as aA, type DerivationKeys as aB, type DerivationReturnType as aC, type DerivationsControl as aD, type DerivationsSchema as aE, type DeriveAccessor as aF, type DispatchEventsFromSchema as aG, type EffectCleanup as aH, type EffectsControl as aI, type EventPayloadSchema as aJ, type EventsAccessor as aK, type EventsAccessorFromSchema as aL, type EventsDef as aM, type EventsSchema as aN, type FactKeys as aO, type FactReturnType as aP, type FlexibleEventHandler as aQ, type HistoryConfig as aR, type InferEventPayloadFromSchema as aS, type InferRequirementPayloadFromSchema as aT, type InferSchema as aU, type MutableNamespacedFacts as aV, type NamespacedDerivations as aW, type NamespacedEventsAccessor as aX, type NamespacedFacts as aY, type ObservableKeys as aZ, type RequirementExplanation as a_, type System as aa, type SystemConfig as ab, type SystemDerived as ac, type SystemFacts as ad, type SystemInspection as ae, type SystemMode as af, type SystemSnapshot as ag, type TraceEntry as ah, isNamespacedSystem as ai, isSingleModuleSystem as aj, type FactsStore as ak, type ConstraintsDef as al, type ConstraintState as am, type ResolversDef as an, type ResolverStatus as ao, type FactChange as ap, type ReconcileResult as aq, type RecoveryStrategy as ar, type ErrorSource as as, type RetryLaterConfig as at, type BatchItemResult as au, type BatchResolveResults as av, type ConstraintsControl as aw, type CrossModuleConstraintDef as ax, type CrossModuleDerivationFn as ay, type CrossModuleEffectDef as az, type TypedEventsDef as b, type RequirementPayloadSchema$1 as b0, type RequirementsSchema as b1, type ResolverContext as b2, type ResolversControl as b3, type SnapshotMeta as b4, type SystemEvent as b5, type TraceConfig as b6, type TypedConstraintDef as b7, type TypedResolverContext as b8, type TypedResolverDef as b9, type UnionEvents as ba, type RequirementOutput$1 as bb, type TypedConstraintsDef as c, type TypedResolversDef as d, type ModuleHooks as e, type CrossModuleDeps as f, type CrossModuleDerivationsDef as g, type CrossModuleEffectsDef as h, type CrossModuleConstraintsDef as i, type ModuleDef as j, type CreateSystemOptionsSingle as k, type SingleModuleSystem as l, type ModulesMap as m, type CreateSystemOptionsNamed as n, type TraceOption as o, type ErrorBoundaryConfig as p, type Requirement as q, type RequirementKeyFn as r, DirectiveError as s, type DistributableSnapshot as t, type DistributableSnapshotOptions as u, type DynamicConstraintDef as v, type DynamicEffectDef as w, type DynamicResolverDef as x, type FactTemplate as y, type FactsSnapshot as z };
@@ -814,7 +814,7 @@ interface BatchItemResult<T = unknown> {
814
814
  * Results from batch resolution with per-item status.
815
815
  * The array order must match the order of requirements passed in.
816
816
  */
817
- type BatchResolveResults<T = unknown> = Array<BatchItemResult<T>>;
817
+ type BatchResolveResults<T = unknown> = BatchItemResult<T>[];
818
818
  /** Resolver context passed to resolve function */
819
819
  interface ResolverContext<S extends Schema = Schema> {
820
820
  readonly facts: Facts<S>;
@@ -1098,7 +1098,7 @@ interface CreateSystemOptionsNamed<Modules extends ModulesMap> {
1098
1098
  /** Modules as object = namespaced access */
1099
1099
  modules: Modules;
1100
1100
  /** Plugins to register */
1101
- plugins?: Array<Plugin<ModuleSchema>>;
1101
+ plugins?: Plugin<ModuleSchema>[];
1102
1102
  /** History configuration for snapshot-based state history */
1103
1103
  history?: HistoryOption;
1104
1104
  /** Trace: per-run reconciliation changelog */
@@ -1363,7 +1363,7 @@ interface CreateSystemOptionsSingle<S extends ModuleSchema> {
1363
1363
  /** Single module = direct access (use `modules` for multiple) */
1364
1364
  module: ModuleDef<S>;
1365
1365
  /** Plugins to register */
1366
- plugins?: Array<Plugin<ModuleSchema>>;
1366
+ plugins?: Plugin<ModuleSchema>[];
1367
1367
  /** History configuration for snapshot-based state history */
1368
1368
  history?: HistoryOption;
1369
1369
  /** Trace: per-run reconciliation changelog */
@@ -1589,6 +1589,45 @@ declare function isSingleModuleSystem(system: AnySystem): boolean;
1589
1589
  * ```
1590
1590
  */
1591
1591
  declare function isNamespacedSystem(system: AnySystem): boolean;
1592
+ /**
1593
+ * Extract the typed facts shape from a Directive system or module schema.
1594
+ *
1595
+ * Useful in framework adapter callbacks (`bind`, `useSelector`, etc.) so an
1596
+ * updater that receives a facts snapshot inherits the schema's narrow types
1597
+ * instead of falling back to `Record<string, unknown>`.
1598
+ *
1599
+ * Accepts any of:
1600
+ * - `SingleModuleSystem<S>` — returns `InferFacts<S>`
1601
+ * - `NamespacedSystem<Modules>` — returns the namespaced facts shape
1602
+ * - A raw `ModuleSchema` — returns `InferFacts<M>`
1603
+ *
1604
+ * @example
1605
+ * ```ts
1606
+ * const system = createSystem({ module: trafficLight });
1607
+ *
1608
+ * function paintLight(facts: SystemFacts<typeof system>) {
1609
+ * // facts.phase is "red" | "green" | "yellow", not unknown
1610
+ * }
1611
+ * ```
1612
+ */
1613
+ type SystemFacts<T> = T extends SingleModuleSystem<infer S> ? InferFacts<S> : T extends NamespacedSystem<infer Modules> ? NamespacedFacts<Modules> : T extends ModuleSchema ? InferFacts<T> : never;
1614
+ /**
1615
+ * Extract the typed derivations shape from a Directive system or module schema.
1616
+ *
1617
+ * Mirrors {@link SystemFacts} but for `system.derive`. The `DerivationsControl`
1618
+ * runtime-control methods (`assign`/`register`/`restore`) are stripped — what
1619
+ * adapter callbacks need is the derived value shape, not the control surface.
1620
+ *
1621
+ * @example
1622
+ * ```ts
1623
+ * const system = createSystem({ module: trafficLight });
1624
+ *
1625
+ * function statusLine(derived: SystemDerived<typeof system>) {
1626
+ * return derived.isRed ? "STOP" : "GO";
1627
+ * }
1628
+ * ```
1629
+ */
1630
+ type SystemDerived<T> = T extends SingleModuleSystem<infer S> ? InferDerivations<S> : T extends NamespacedSystem<infer Modules> ? NamespacedDerivations<Modules> : T extends ModuleSchema ? InferDerivations<T> : never;
1592
1631
 
1593
1632
  /**
1594
1633
  * Module Types - Type definitions for modules with consolidated schema
@@ -2419,7 +2458,7 @@ interface DynamicConstraintDef<M extends ModuleSchema = ModuleSchema> {
2419
2458
  }
2420
2459
  /** Effect definition for dynamic registration — typed facts */
2421
2460
  interface DynamicEffectDef<M extends ModuleSchema = ModuleSchema> {
2422
- run: (facts: Readonly<InferSchema<M["facts"]>>, prev: InferSchema<M["facts"]> | null) => void | (() => void) | Promise<void | (() => void)>;
2461
+ run: (facts: Readonly<InferSchema<M["facts"]>>, prev: InferSchema<M["facts"]> | null) => void | (() => void) | Promise<undefined | (() => void)>;
2423
2462
  deps?: Array<string & keyof InferSchema<M["facts"]>>;
2424
2463
  /**
2425
2464
  * Optional declarative trigger — a {@link FactPredicate} that gates whether
@@ -2669,7 +2708,7 @@ interface System<M extends ModuleSchema = ModuleSchema> {
2669
2708
  * Keys are auto-detected -- pass any mix of fact keys and derivation keys.
2670
2709
  * @example system.subscribe(["count", "doubled"], () => { ... })
2671
2710
  */
2672
- subscribe(ids: Array<ObservableKeys<M>>, listener: () => void): () => void;
2711
+ subscribe(ids: ObservableKeys<M>[], listener: () => void): () => void;
2673
2712
  /**
2674
2713
  * Watch a fact or derivation for value changes.
2675
2714
  * The key is auto-detected -- works with both fact keys and derivation keys.
@@ -2753,8 +2792,8 @@ interface System<M extends ModuleSchema = ModuleSchema> {
2753
2792
  }
2754
2793
  /** System configuration */
2755
2794
  interface SystemConfig<M extends ModuleSchema = ModuleSchema> {
2756
- modules: Array<ModuleDef<M>>;
2757
- plugins?: Array<Plugin<any>>;
2795
+ modules: ModuleDef<M>[];
2796
+ plugins?: Plugin<any>[];
2758
2797
  history?: HistoryOption;
2759
2798
  trace?: TraceOption;
2760
2799
  errorBoundary?: ErrorBoundaryConfig;
@@ -3060,4 +3099,4 @@ interface Plugin<M extends ModuleSchema = ModuleSchema> {
3060
3099
  onTraceComplete?: (entry: TraceEntry) => void;
3061
3100
  }
3062
3101
 
3063
- export { type PatchSpec as $, type AnySystem as A, type BatchConfig as B, type ClauseResult as C, type DefinitionMeta as D, type EffectsDef as E, type FactPredicate as F, type HistoryOption as G, type HistoryAPI as H, type HistoryState as I, type InferDerivations as J, type InferEvents as K, type InferFacts as L, type ModuleSchema as M, type NamespacedSystem as N, type InferRequirementTypes as O, type Plugin as P, type InferRequirements as Q, type RequirementWithId as R, type SchemaType as S, type TypedDerivationsDef as T, type InferSchemaType as U, type InferSelectorState as V, type KeySelector as W, type MetaAccessor as X, type MetaMatch as Y, type ObservationEvent as Z, type OperatorObject as _, type Facts as a, type RequirementsSchema as a$, type PatchValue as a0, type PayloadRef as a1, type PredicateClause as a2, type PredicateCombinator as a3, type PredicateCombinatorKey as a4, type PredicateObject as a5, type PredicateOp as a6, type RetryPolicy as a7, type Schema as a8, type Snapshot as a9, type DerivationReturnType as aA, type DerivationsControl as aB, type DerivationsSchema as aC, type DeriveAccessor as aD, type DispatchEventsFromSchema as aE, type EffectCleanup as aF, type EffectsControl as aG, type EventPayloadSchema as aH, type EventsAccessor as aI, type EventsAccessorFromSchema as aJ, type EventsDef as aK, type EventsSchema as aL, type FactKeys as aM, type FactReturnType as aN, type FlexibleEventHandler as aO, type HistoryConfig as aP, type InferEventPayloadFromSchema as aQ, type InferRequirementPayloadFromSchema as aR, type InferSchema as aS, type MutableNamespacedFacts as aT, type NamespacedDerivations as aU, type NamespacedEventsAccessor as aV, type NamespacedFacts as aW, type ObservableKeys as aX, type RequirementExplanation as aY, type RequirementOutput as aZ, type RequirementPayloadSchema$1 as a_, type System as aa, type SystemConfig as ab, type SystemInspection as ac, type SystemMode as ad, type SystemSnapshot as ae, type TraceEntry as af, isNamespacedSystem as ag, isSingleModuleSystem as ah, type FactsStore as ai, type ConstraintsDef as aj, type ConstraintState as ak, type ResolversDef as al, type ResolverStatus as am, type FactChange as an, type ReconcileResult as ao, type RecoveryStrategy as ap, type ErrorSource as aq, type RetryLaterConfig as ar, type BatchItemResult as as, type BatchResolveResults as at, type ConstraintsControl as au, type CrossModuleConstraintDef as av, type CrossModuleDerivationFn as aw, type CrossModuleEffectDef as ax, type CrossModuleFactsWithSelf as ay, type DerivationKeys as az, type TypedEventsDef as b, type ResolverContext as b0, type ResolversControl as b1, type SnapshotMeta as b2, type SystemEvent as b3, type TraceConfig as b4, type TypedConstraintDef as b5, type TypedResolverContext as b6, type TypedResolverDef as b7, type UnionEvents as b8, type RequirementOutput$1 as b9, type TypedConstraintsDef as c, type TypedResolversDef as d, type ModuleHooks as e, type CrossModuleDeps as f, type CrossModuleDerivationsDef as g, type CrossModuleEffectsDef as h, type CrossModuleConstraintsDef as i, type ModuleDef as j, type CreateSystemOptionsSingle as k, type SingleModuleSystem as l, type ModulesMap as m, type CreateSystemOptionsNamed as n, type TraceOption as o, type ErrorBoundaryConfig as p, type Requirement as q, type RequirementKeyFn as r, DirectiveError as s, type DistributableSnapshot as t, type DistributableSnapshotOptions as u, type DynamicConstraintDef as v, type DynamicEffectDef as w, type DynamicResolverDef as x, type FactTemplate as y, type FactsSnapshot as z };
3102
+ export { type PatchSpec as $, type AnySystem as A, type BatchConfig as B, type ClauseResult as C, type DefinitionMeta as D, type EffectsDef as E, type FactPredicate as F, type HistoryOption as G, type HistoryAPI as H, type HistoryState as I, type InferDerivations as J, type InferEvents as K, type InferFacts as L, type ModuleSchema as M, type NamespacedSystem as N, type InferRequirementTypes as O, type Plugin as P, type InferRequirements as Q, type RequirementWithId as R, type SchemaType as S, type TypedDerivationsDef as T, type InferSchemaType as U, type InferSelectorState as V, type KeySelector as W, type MetaAccessor as X, type MetaMatch as Y, type ObservationEvent as Z, type OperatorObject as _, type Facts as a, type RequirementOutput as a$, type PatchValue as a0, type PayloadRef as a1, type PredicateClause as a2, type PredicateCombinator as a3, type PredicateCombinatorKey as a4, type PredicateObject as a5, type PredicateOp as a6, type RetryPolicy as a7, type Schema as a8, type Snapshot as a9, type CrossModuleFactsWithSelf as aA, type DerivationKeys as aB, type DerivationReturnType as aC, type DerivationsControl as aD, type DerivationsSchema as aE, type DeriveAccessor as aF, type DispatchEventsFromSchema as aG, type EffectCleanup as aH, type EffectsControl as aI, type EventPayloadSchema as aJ, type EventsAccessor as aK, type EventsAccessorFromSchema as aL, type EventsDef as aM, type EventsSchema as aN, type FactKeys as aO, type FactReturnType as aP, type FlexibleEventHandler as aQ, type HistoryConfig as aR, type InferEventPayloadFromSchema as aS, type InferRequirementPayloadFromSchema as aT, type InferSchema as aU, type MutableNamespacedFacts as aV, type NamespacedDerivations as aW, type NamespacedEventsAccessor as aX, type NamespacedFacts as aY, type ObservableKeys as aZ, type RequirementExplanation as a_, type System as aa, type SystemConfig as ab, type SystemDerived as ac, type SystemFacts as ad, type SystemInspection as ae, type SystemMode as af, type SystemSnapshot as ag, type TraceEntry as ah, isNamespacedSystem as ai, isSingleModuleSystem as aj, type FactsStore as ak, type ConstraintsDef as al, type ConstraintState as am, type ResolversDef as an, type ResolverStatus as ao, type FactChange as ap, type ReconcileResult as aq, type RecoveryStrategy as ar, type ErrorSource as as, type RetryLaterConfig as at, type BatchItemResult as au, type BatchResolveResults as av, type ConstraintsControl as aw, type CrossModuleConstraintDef as ax, type CrossModuleDerivationFn as ay, type CrossModuleEffectDef as az, type TypedEventsDef as b, type RequirementPayloadSchema$1 as b0, type RequirementsSchema as b1, type ResolverContext as b2, type ResolversControl as b3, type SnapshotMeta as b4, type SystemEvent as b5, type TraceConfig as b6, type TypedConstraintDef as b7, type TypedResolverContext as b8, type TypedResolverDef as b9, type UnionEvents as ba, type RequirementOutput$1 as bb, type TypedConstraintsDef as c, type TypedResolversDef as d, type ModuleHooks as e, type CrossModuleDeps as f, type CrossModuleDerivationsDef as g, type CrossModuleEffectsDef as h, type CrossModuleConstraintsDef as i, type ModuleDef as j, type CreateSystemOptionsSingle as k, type SingleModuleSystem as l, type ModulesMap as m, type CreateSystemOptionsNamed as n, type TraceOption as o, type ErrorBoundaryConfig as p, type Requirement as q, type RequirementKeyFn as r, DirectiveError as s, type DistributableSnapshot as t, type DistributableSnapshotOptions as u, type DynamicConstraintDef as v, type DynamicEffectDef as w, type DynamicResolverDef as x, type FactTemplate as y, type FactsSnapshot as z };
@@ -1,4 +1,4 @@
1
- import { a8 as Schema, a as Facts, F as FactPredicate, aS as InferSchema, y as FactTemplate, D as DefinitionMeta, q as Requirement, b9 as RequirementOutput, a7 as RetryPolicy, B as BatchConfig, b0 as ResolverContext, a6 as PredicateOp, $ as PatchSpec, C as ClauseResult } from './plugins-BIzXaYbg.js';
1
+ import { a8 as Schema, a as Facts, F as FactPredicate, aU as InferSchema, y as FactTemplate, D as DefinitionMeta, q as Requirement, bb as RequirementOutput, a7 as RetryPolicy, B as BatchConfig, b2 as ResolverContext, a6 as PredicateOp, $ as PatchSpec, C as ClauseResult } from './plugins-BpNMkJRw.js';
2
2
 
3
3
  /**
4
4
  * Derivation Types - Type definitions for derivations
@@ -1,4 +1,4 @@
1
- import { a8 as Schema, a as Facts, F as FactPredicate, aS as InferSchema, y as FactTemplate, D as DefinitionMeta, q as Requirement, b9 as RequirementOutput, a7 as RetryPolicy, B as BatchConfig, b0 as ResolverContext, a6 as PredicateOp, $ as PatchSpec, C as ClauseResult } from './plugins-BIzXaYbg.cjs';
1
+ import { a8 as Schema, a as Facts, F as FactPredicate, aU as InferSchema, y as FactTemplate, D as DefinitionMeta, q as Requirement, bb as RequirementOutput, a7 as RetryPolicy, B as BatchConfig, b2 as ResolverContext, a6 as PredicateOp, $ as PatchSpec, C as ClauseResult } from './plugins-BpNMkJRw.cjs';
2
2
 
3
3
  /**
4
4
  * Derivation Types - Type definitions for derivations
@@ -0,0 +1,2 @@
1
+ export{a as createSystem}from'./chunk-F5JPF4YX.js';import'./chunk-RWJV7QLM.js';import'./chunk-O4GQEV4G.js';import'./chunk-3ETCZLAY.js';import'./chunk-PXRV64PA.js';//# sourceMappingURL=system-MMCZKPI2.js.map
2
+ //# sourceMappingURL=system-MMCZKPI2.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"system-A6VYKLVF.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"system-MMCZKPI2.js"}
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunkSUCLMJSZ_cjs=require('./chunk-SUCLMJSZ.cjs');require('./chunk-Q5UTBMX2.cjs'),require('./chunk-RWFKUNF7.cjs'),require('./chunk-JGPPJV5P.cjs'),require('./chunk-4MNQDXH7.cjs');Object.defineProperty(exports,"createSystem",{enumerable:true,get:function(){return chunkSUCLMJSZ_cjs.a}});//# sourceMappingURL=system-RHSYFDOB.cjs.map
2
+ //# sourceMappingURL=system-RHSYFDOB.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"system-CDJMD5O5.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"system-RHSYFDOB.cjs"}
package/dist/testing.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkNPX5EKPP_cjs=require('./chunk-NPX5EKPP.cjs');require('./chunk-ENZEHIL7.cjs'),require('./chunk-T4TRJEJN.cjs'),require('./chunk-X7G7UBXU.cjs'),require('./chunk-4MNQDXH7.cjs');async function R(){for(let e=0;e<10;e++)await Promise.resolve();}async function T(){for(let e=0;e<10;e++)await Promise.resolve();await new Promise(e=>setTimeout(e,0));for(let e=0;e<10;e++)await Promise.resolve();await new Promise(e=>setTimeout(e,0));for(let e=0;e<10;e++)await Promise.resolve();}async function D(e,s,r={}){let{totalTime:o=5e3,stepSize:c=10,maxIterations:l=1e3}=r,m=0,d=0;for(;m<o&&d<l;){if(await R(),e.inspect().inflight.length===0){await R();return}s(c),m+=c,d++;}let v=e.inspect();if(v.inflight.length>0){let f=v.inflight.map(p=>p.resolverId).join(", ");throw new Error(`[Directive] settleWithFakeTimers did not settle after ${o}ms. ${v.inflight.length} resolvers still inflight: ${f}`)}}function C(){let e=0,s=[];return {async advance(r){let o=e+r;for(;s.length>0&&s[0].time<=o;){let c=s.shift();e=c.time,c.callback(),await Promise.resolve();}e=o;},async next(){if(s.length===0)return;let r=s.shift();e=r.time,r.callback(),await Promise.resolve();},async runAll(){for(;s.length>0;)await this.next();},now(){return e},reset(){e=0,s.length=0;}}}function b(e){let s=typeof e=="string"?{requirement:(o=>o.type===e)}:e,r=s.calls??[];return {requirement:s.requirement??(o=>true),async resolve(o,c){if(r.push(o),s.delay&&await new Promise(l=>setTimeout(l,s.delay)),s.error)throw typeof s.error=="string"?new Error(s.error):s.error;s.resolve&&await s.resolve(o,c);}}}function E(e){let s=[],r=[];return {...{get calls(){return s},get pending(){return r},resolve(l){let m=r.shift();m&&m.resolve(l);},reject(l){let m=r.shift();m&&m.reject(l);},resolveAll(l){for(;r.length>0;)this.resolve(l);},rejectAll(l){for(;r.length>0;)this.reject(l);},reset(){s.length=0,r.length=0;}},handler:(l,m)=>(s.push(l),new Promise((d,v)=>{r.push({requirement:l,resolve:f=>d(f),reject:v});}))}}function P(e){return "module"in e?x(e):M(e)}function x(e){let s=[],r=new Map,o=[],c=[],l={};if(e.mocks?.resolvers)for(let[i,t]of Object.entries(e.mocks.resolvers)){let n=[];r.set(i,n),l[i]=b({...t,calls:n});}let m={...e.module,resolvers:{...e.module.resolvers,...l}},v=chunkNPX5EKPP_cjs.a({...e,module:m,plugins:[{name:"__test-tracking__",onFactSet:(i,t,n)=>{c.push({key:i,fullKey:i,namespace:void 0,previousValue:n,newValue:t,timestamp:Date.now()});},onRequirementCreated:i=>{o.push(i);}},...e.plugins??[]]}),f=v.dispatch.bind(v);return v.dispatch=i=>{s.push(i),f(i);},{...v,eventHistory:s,resolverCalls:r,get allRequirements(){return o},getFactsHistory(){return [...c]},resetFactsHistory(){c.length=0;},async waitForIdle(i=5e3){let t=Date.now(),n=async()=>{await new Promise(u=>setTimeout(u,0));let a=v.inspect();if(a.inflight.length>0){if(Date.now()-t>i){let u=a.inflight.map(g=>g.id).join(", ");throw new Error(`[Directive] waitForIdle timed out after ${i}ms. ${a.inflight.length} resolvers still inflight: ${u}`)}return await new Promise(u=>setTimeout(u,10)),n()}};return n()},assertRequirement(i){if(!o.some(n=>n.requirement.type===i))throw new Error(`[Directive] Expected requirement of type "${i}" but none found`)},assertResolverCalled(i,t){let n=r.get(i)??[];if(t!==void 0){if(n.length!==t)throw new Error(`[Directive] Expected resolver "${i}" to be called ${t} times but was called ${n.length} times`)}else if(n.length===0)throw new Error(`[Directive] Expected resolver "${i}" to be called but it was not`)},assertFactSet(i,t){let n=c.filter(a=>a.key===i);if(n.length===0)throw new Error(`[Directive] Expected fact "${i}" to be set but it was not`);if(t!==void 0&&!n.some(u=>u.newValue===t)){let u=n.map(g=>JSON.stringify(g.newValue)).join(", ");throw new Error(`[Directive] Expected fact "${i}" to be set to ${JSON.stringify(t)} but got: ${u}`)}},assertFactChanges(i,t){let n=c.filter(a=>a.key===i);if(n.length!==t)throw new Error(`[Directive] Expected fact "${i}" to change ${t} times but it changed ${n.length} times`)}}}function M(e){let s=[],r=new Map,o=[],c=[],l={};if(e.mocks?.resolvers)for(let[t,n]of Object.entries(e.mocks.resolvers)){let a=[];r.set(t,a),l[t]=b({...n,calls:a});}let m={};for(let[t,n]of Object.entries(e.modules))m[t]={...n,resolvers:{...n.resolvers,...l}};let d=new Set(Object.keys(e.modules)),f=chunkNPX5EKPP_cjs.a({...e,modules:m,plugins:[{name:"__test-tracking__",onFactSet:(t,n,a)=>{let g=t.indexOf("::"),y,h;if(g>0){let S=t.substring(0,g);d.has(S)?(y=S,h=t.substring(g+2)):h=t;}else h=t;c.push({key:h,fullKey:t,namespace:y,previousValue:a,newValue:n,timestamp:Date.now()});},onRequirementCreated:t=>{o.push(t);}},...e.plugins??[]]}),p=f.dispatch.bind(f);return f.dispatch=t=>{s.push(t),p(t);},{...f,eventHistory:s,resolverCalls:r,get allRequirements(){return o},getFactsHistory(){return [...c]},resetFactsHistory(){c.length=0;},async waitForIdle(t=5e3){let n=Date.now(),a=async()=>{await new Promise(g=>setTimeout(g,0));let u=f.inspect();if(u.inflight.length>0){if(Date.now()-n>t){let g=u.inflight.map(y=>y.id).join(", ");throw new Error(`[Directive] waitForIdle timed out after ${t}ms. ${u.inflight.length} resolvers still inflight: ${g}`)}return await new Promise(g=>setTimeout(g,10)),a()}};return a()},assertRequirement(t){if(!o.some(a=>a.requirement.type===t))throw new Error(`[Directive] Expected requirement of type "${t}" but none found`)},assertResolverCalled(t,n){let a=r.get(t)??[];if(n!==void 0){if(a.length!==n)throw new Error(`[Directive] Expected resolver "${t}" to be called ${n} times but was called ${a.length} times`)}else if(a.length===0)throw new Error(`[Directive] Expected resolver "${t}" to be called but it was not`)},assertFactSet(t,n){let a=c.filter(u=>u.key===t);if(a.length===0)throw new Error(`[Directive] Expected fact "${t}" to be set but it was not`);if(n!==void 0&&!a.some(g=>g.newValue===n)){let g=a.map(y=>JSON.stringify(y.newValue)).join(", ");throw new Error(`[Directive] Expected fact "${t}" to be set to ${JSON.stringify(n)} but got: ${g}`)}},assertFactChanges(t,n){let a=c.filter(u=>u.key===t);if(a.length!==n)throw new Error(`[Directive] Expected fact "${t}" to change ${n} times but it changed ${a.length} times`)}}}function O(e,s,r){if(!k(e,s,r))throw new Error(`[Directive] Expected ${s} "${r}" to be dynamic, but it is not.`)}function $(e,s,r){if(k(e,s,r))throw new Error(`[Directive] Expected ${s} "${r}" to NOT be dynamic, but it is.`)}function k(e,s,r){switch(s){case "constraint":return e.constraints.isDynamic(r);case "resolver":return e.resolvers.isDynamic(r);case "derivation":return e.derive.isDynamic(r);case "effect":return e.effects.isDynamic(r)}}function F(e){let s=new Set,r=new Set,o=new Set,c=new Set,l=null;return {async run(m){l=e.observe(d=>{switch(d.type){case "constraint.evaluate":d.active&&s.add(d.id);break;case "resolver.start":r.add(d.resolver);break;case "effect.run":o.add(d.id);break;case "derivation.compute":c.add(d.id);break}});try{await m();}finally{l?.(),l=null;}},report(){let m=e.inspect(),d=new Set(m.constraints.map(i=>i.id)),v=new Set(m.resolverDefs.map(i=>i.id)),f=new Set;for(let i of d)s.has(i)||f.add(i);let p=new Set;for(let i of v)r.has(i)||p.add(i);return {constraintsHit:s,constraintsMissed:f,resolversRun:r,resolversMissed:p,effectsRun:o,derivationsComputed:c,constraintCoverage:d.size===0?1:s.size/d.size,resolverCoverage:v.size===0?1:r.size/v.size,effectCoverage:m.effects.length===0?1:o.size/m.effects.length,derivationCoverage:m.derivations.length===0?1:c.size/m.derivations.length}}}}function I(e){let s=[],r=e.observe(o=>s.push(o));return {events:s,ofType(o){return s.filter(c=>c.type===o)},clear(){s.length=0;},dispose(){r();}}}exports.assertDynamic=O;exports.assertNotDynamic=$;exports.createCoverageTracker=F;exports.createFakeTimers=C;exports.createMockResolver=b;exports.createTestObserver=I;exports.createTestSystem=P;exports.flushAsync=T;exports.flushMicrotasks=R;exports.mockResolver=E;exports.settleWithFakeTimers=D;//# sourceMappingURL=testing.cjs.map
1
+ 'use strict';var chunkSUCLMJSZ_cjs=require('./chunk-SUCLMJSZ.cjs');require('./chunk-Q5UTBMX2.cjs'),require('./chunk-RWFKUNF7.cjs'),require('./chunk-JGPPJV5P.cjs'),require('./chunk-4MNQDXH7.cjs');async function R(){for(let e=0;e<10;e++)await Promise.resolve();}async function T(){for(let e=0;e<10;e++)await Promise.resolve();await new Promise(e=>setTimeout(e,0));for(let e=0;e<10;e++)await Promise.resolve();await new Promise(e=>setTimeout(e,0));for(let e=0;e<10;e++)await Promise.resolve();}async function D(e,s,r={}){let{totalTime:o=5e3,stepSize:c=10,maxIterations:l=1e3}=r,m=0,d=0;for(;m<o&&d<l;){if(await R(),e.inspect().inflight.length===0){await R();return}s(c),m+=c,d++;}let v=e.inspect();if(v.inflight.length>0){let f=v.inflight.map(p=>p.resolverId).join(", ");throw new Error(`[Directive] settleWithFakeTimers did not settle after ${o}ms. ${v.inflight.length} resolvers still inflight: ${f}`)}}function C(){let e=0,s=[];return {async advance(r){let o=e+r;for(;s.length>0&&s[0].time<=o;){let c=s.shift();e=c.time,c.callback(),await Promise.resolve();}e=o;},async next(){if(s.length===0)return;let r=s.shift();e=r.time,r.callback(),await Promise.resolve();},async runAll(){for(;s.length>0;)await this.next();},now(){return e},reset(){e=0,s.length=0;}}}function b(e){let s=typeof e=="string"?{requirement:(o=>o.type===e)}:e,r=s.calls??[];return {requirement:s.requirement??(o=>true),async resolve(o,c){if(r.push(o),s.delay&&await new Promise(l=>setTimeout(l,s.delay)),s.error)throw typeof s.error=="string"?new Error(s.error):s.error;s.resolve&&await s.resolve(o,c);}}}function E(e){let s=[],r=[];return {...{get calls(){return s},get pending(){return r},resolve(l){let m=r.shift();m&&m.resolve(l);},reject(l){let m=r.shift();m&&m.reject(l);},resolveAll(l){for(;r.length>0;)this.resolve(l);},rejectAll(l){for(;r.length>0;)this.reject(l);},reset(){s.length=0,r.length=0;}},handler:(l,m)=>(s.push(l),new Promise((d,v)=>{r.push({requirement:l,resolve:f=>d(f),reject:v});}))}}function P(e){return "module"in e?x(e):M(e)}function x(e){let s=[],r=new Map,o=[],c=[],l={};if(e.mocks?.resolvers)for(let[i,t]of Object.entries(e.mocks.resolvers)){let n=[];r.set(i,n),l[i]=b({...t,calls:n});}let m={...e.module,resolvers:{...e.module.resolvers,...l}},v=chunkSUCLMJSZ_cjs.a({...e,module:m,plugins:[{name:"__test-tracking__",onFactSet:(i,t,n)=>{c.push({key:i,fullKey:i,namespace:void 0,previousValue:n,newValue:t,timestamp:Date.now()});},onRequirementCreated:i=>{o.push(i);}},...e.plugins??[]]}),f=v.dispatch.bind(v);return v.dispatch=i=>{s.push(i),f(i);},{...v,eventHistory:s,resolverCalls:r,get allRequirements(){return o},getFactsHistory(){return [...c]},resetFactsHistory(){c.length=0;},async waitForIdle(i=5e3){let t=Date.now(),n=async()=>{await new Promise(u=>setTimeout(u,0));let a=v.inspect();if(a.inflight.length>0){if(Date.now()-t>i){let u=a.inflight.map(g=>g.id).join(", ");throw new Error(`[Directive] waitForIdle timed out after ${i}ms. ${a.inflight.length} resolvers still inflight: ${u}`)}return await new Promise(u=>setTimeout(u,10)),n()}};return n()},assertRequirement(i){if(!o.some(n=>n.requirement.type===i))throw new Error(`[Directive] Expected requirement of type "${i}" but none found`)},assertResolverCalled(i,t){let n=r.get(i)??[];if(t!==void 0){if(n.length!==t)throw new Error(`[Directive] Expected resolver "${i}" to be called ${t} times but was called ${n.length} times`)}else if(n.length===0)throw new Error(`[Directive] Expected resolver "${i}" to be called but it was not`)},assertFactSet(i,t){let n=c.filter(a=>a.key===i);if(n.length===0)throw new Error(`[Directive] Expected fact "${i}" to be set but it was not`);if(t!==void 0&&!n.some(u=>u.newValue===t)){let u=n.map(g=>JSON.stringify(g.newValue)).join(", ");throw new Error(`[Directive] Expected fact "${i}" to be set to ${JSON.stringify(t)} but got: ${u}`)}},assertFactChanges(i,t){let n=c.filter(a=>a.key===i);if(n.length!==t)throw new Error(`[Directive] Expected fact "${i}" to change ${t} times but it changed ${n.length} times`)}}}function M(e){let s=[],r=new Map,o=[],c=[],l={};if(e.mocks?.resolvers)for(let[t,n]of Object.entries(e.mocks.resolvers)){let a=[];r.set(t,a),l[t]=b({...n,calls:a});}let m={};for(let[t,n]of Object.entries(e.modules))m[t]={...n,resolvers:{...n.resolvers,...l}};let d=new Set(Object.keys(e.modules)),f=chunkSUCLMJSZ_cjs.a({...e,modules:m,plugins:[{name:"__test-tracking__",onFactSet:(t,n,a)=>{let g=t.indexOf("::"),y,h;if(g>0){let S=t.substring(0,g);d.has(S)?(y=S,h=t.substring(g+2)):h=t;}else h=t;c.push({key:h,fullKey:t,namespace:y,previousValue:a,newValue:n,timestamp:Date.now()});},onRequirementCreated:t=>{o.push(t);}},...e.plugins??[]]}),p=f.dispatch.bind(f);return f.dispatch=t=>{s.push(t),p(t);},{...f,eventHistory:s,resolverCalls:r,get allRequirements(){return o},getFactsHistory(){return [...c]},resetFactsHistory(){c.length=0;},async waitForIdle(t=5e3){let n=Date.now(),a=async()=>{await new Promise(g=>setTimeout(g,0));let u=f.inspect();if(u.inflight.length>0){if(Date.now()-n>t){let g=u.inflight.map(y=>y.id).join(", ");throw new Error(`[Directive] waitForIdle timed out after ${t}ms. ${u.inflight.length} resolvers still inflight: ${g}`)}return await new Promise(g=>setTimeout(g,10)),a()}};return a()},assertRequirement(t){if(!o.some(a=>a.requirement.type===t))throw new Error(`[Directive] Expected requirement of type "${t}" but none found`)},assertResolverCalled(t,n){let a=r.get(t)??[];if(n!==void 0){if(a.length!==n)throw new Error(`[Directive] Expected resolver "${t}" to be called ${n} times but was called ${a.length} times`)}else if(a.length===0)throw new Error(`[Directive] Expected resolver "${t}" to be called but it was not`)},assertFactSet(t,n){let a=c.filter(u=>u.key===t);if(a.length===0)throw new Error(`[Directive] Expected fact "${t}" to be set but it was not`);if(n!==void 0&&!a.some(g=>g.newValue===n)){let g=a.map(y=>JSON.stringify(y.newValue)).join(", ");throw new Error(`[Directive] Expected fact "${t}" to be set to ${JSON.stringify(n)} but got: ${g}`)}},assertFactChanges(t,n){let a=c.filter(u=>u.key===t);if(a.length!==n)throw new Error(`[Directive] Expected fact "${t}" to change ${n} times but it changed ${a.length} times`)}}}function O(e,s,r){if(!k(e,s,r))throw new Error(`[Directive] Expected ${s} "${r}" to be dynamic, but it is not.`)}function $(e,s,r){if(k(e,s,r))throw new Error(`[Directive] Expected ${s} "${r}" to NOT be dynamic, but it is.`)}function k(e,s,r){switch(s){case "constraint":return e.constraints.isDynamic(r);case "resolver":return e.resolvers.isDynamic(r);case "derivation":return e.derive.isDynamic(r);case "effect":return e.effects.isDynamic(r)}}function F(e){let s=new Set,r=new Set,o=new Set,c=new Set,l=null;return {async run(m){l=e.observe(d=>{switch(d.type){case "constraint.evaluate":d.active&&s.add(d.id);break;case "resolver.start":r.add(d.resolver);break;case "effect.run":o.add(d.id);break;case "derivation.compute":c.add(d.id);break}});try{await m();}finally{l?.(),l=null;}},report(){let m=e.inspect(),d=new Set(m.constraints.map(i=>i.id)),v=new Set(m.resolverDefs.map(i=>i.id)),f=new Set;for(let i of d)s.has(i)||f.add(i);let p=new Set;for(let i of v)r.has(i)||p.add(i);return {constraintsHit:s,constraintsMissed:f,resolversRun:r,resolversMissed:p,effectsRun:o,derivationsComputed:c,constraintCoverage:d.size===0?1:s.size/d.size,resolverCoverage:v.size===0?1:r.size/v.size,effectCoverage:m.effects.length===0?1:o.size/m.effects.length,derivationCoverage:m.derivations.length===0?1:c.size/m.derivations.length}}}}function I(e){let s=[],r=e.observe(o=>s.push(o));return {events:s,ofType(o){return s.filter(c=>c.type===o)},clear(){s.length=0;},dispose(){r();}}}exports.assertDynamic=O;exports.assertNotDynamic=$;exports.createCoverageTracker=F;exports.createFakeTimers=C;exports.createMockResolver=b;exports.createTestObserver=I;exports.createTestSystem=P;exports.flushAsync=T;exports.flushMicrotasks=R;exports.mockResolver=E;exports.settleWithFakeTimers=D;//# sourceMappingURL=testing.cjs.map
2
2
  //# sourceMappingURL=testing.cjs.map