@directive-run/vue 0.1.1 → 0.2.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.
- package/README.md +95 -7
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -8
- package/dist/index.d.ts +0 -8
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# @directive-run/vue
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@directive-run/vue)
|
|
4
|
+
[](https://www.npmjs.com/package/@directive-run/vue)
|
|
5
|
+
[](https://bundlephobia.com/package/@directive-run/vue)
|
|
6
|
+
|
|
7
|
+
Vue 3 composables for [Directive](https://www.npmjs.com/package/@directive-run/core). Returns reactive `Ref` and `ShallowRef` values that integrate with Vue's reactivity system.
|
|
4
8
|
|
|
5
9
|
## Install
|
|
6
10
|
|
|
@@ -8,11 +12,42 @@ Vue 3 composition API adapter for Directive. Provides reactive `ref` and `shallo
|
|
|
8
12
|
npm install @directive-run/core @directive-run/vue
|
|
9
13
|
```
|
|
10
14
|
|
|
11
|
-
##
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
Define a module in a shared file, then use it in any component:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
// system.ts
|
|
21
|
+
import { createModule, createSystem, t } from "@directive-run/core";
|
|
22
|
+
|
|
23
|
+
const counter = createModule("counter", {
|
|
24
|
+
schema: {
|
|
25
|
+
facts: { count: t.number() },
|
|
26
|
+
derivations: { doubled: t.number() },
|
|
27
|
+
events: { increment: {}, decrement: {} },
|
|
28
|
+
requirements: {},
|
|
29
|
+
},
|
|
30
|
+
init: (facts) => {
|
|
31
|
+
facts.count = 0;
|
|
32
|
+
},
|
|
33
|
+
derive: {
|
|
34
|
+
doubled: (facts) => facts.count * 2,
|
|
35
|
+
},
|
|
36
|
+
events: {
|
|
37
|
+
increment: (facts) => { facts.count += 1; },
|
|
38
|
+
decrement: (facts) => { facts.count -= 1; },
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const system = createSystem({ module: counter });
|
|
43
|
+
system.start();
|
|
44
|
+
```
|
|
12
45
|
|
|
13
46
|
```vue
|
|
14
|
-
|
|
47
|
+
<!-- Counter.vue -->
|
|
48
|
+
<script setup lang="ts">
|
|
15
49
|
import { useFact, useDerived, useEvents } from "@directive-run/vue";
|
|
50
|
+
import { system } from "./system";
|
|
16
51
|
|
|
17
52
|
const count = useFact(system, "count");
|
|
18
53
|
const doubled = useDerived(system, "doubled");
|
|
@@ -22,20 +57,73 @@ const events = useEvents(system);
|
|
|
22
57
|
<template>
|
|
23
58
|
<p>Count: {{ count }} (doubled: {{ doubled }})</p>
|
|
24
59
|
<button @click="events.increment()">+</button>
|
|
60
|
+
<button @click="events.decrement()">−</button>
|
|
61
|
+
</template>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## useSelector
|
|
65
|
+
|
|
66
|
+
Auto-tracking selector over facts and derivations. Returns a `Ref` that updates when accessed keys change:
|
|
67
|
+
|
|
68
|
+
```vue
|
|
69
|
+
<script setup lang="ts">
|
|
70
|
+
import { useSelector } from "@directive-run/vue";
|
|
71
|
+
import { system } from "./system";
|
|
72
|
+
|
|
73
|
+
const label = useSelector(system, (state) => {
|
|
74
|
+
return state.count > 10 ? "High" : "Low";
|
|
75
|
+
});
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<template>
|
|
79
|
+
<span>{{ label }}</span>
|
|
25
80
|
</template>
|
|
26
81
|
```
|
|
27
82
|
|
|
28
|
-
##
|
|
83
|
+
## API Reference
|
|
84
|
+
|
|
85
|
+
### Core Composables
|
|
86
|
+
|
|
87
|
+
| Composable | Return Type | Description |
|
|
88
|
+
|------------|------------|-------------|
|
|
89
|
+
| `useFact(system, key)` | `Ref<T>` | Subscribe to a single fact value |
|
|
90
|
+
| `useFact(system, [keys])` | `ShallowRef<Pick<Facts, K>>` | Subscribe to multiple facts |
|
|
91
|
+
| `useDerived(system, key)` | `Ref<T>` | Subscribe to a single derivation |
|
|
92
|
+
| `useDerived(system, [keys])` | `ShallowRef<Pick<Derivations, K>>` | Subscribe to multiple derivations |
|
|
93
|
+
| `useSelector(system, fn)` | `Ref<R>` | Auto-tracking selector with optional equality function |
|
|
94
|
+
| `useEvents(system)` | `Events` | Events dispatcher |
|
|
95
|
+
| `useDispatch(system)` | `(event) => void` | Low-level dispatch function |
|
|
29
96
|
|
|
30
|
-
|
|
97
|
+
### Advanced Composables
|
|
98
|
+
|
|
99
|
+
| Composable | Return Type | Description |
|
|
100
|
+
|------------|------------|-------------|
|
|
101
|
+
| `useWatch(system, key, cb)` | `void` | Side-effect on fact or derivation change |
|
|
102
|
+
| `useInspect(system)` | `ShallowRef<InspectState>` | Consolidated system state (isSettled, unmet, inflight) |
|
|
103
|
+
| `useRequirementStatus(plugin, type)` | `ShallowRef<RequirementTypeStatus>` | Requirement loading/error state |
|
|
104
|
+
| `useExplain(system, reqId)` | `Ref<string \| null>` | Human-readable requirement explanation |
|
|
105
|
+
| `useConstraintStatus(system)` | `ComputedRef<ConstraintInfo[]>` | All constraint states |
|
|
106
|
+
| `useOptimisticUpdate(system)` | `{ mutate, isPending: Ref, error: Ref, rollback }` | Optimistic mutation with auto-rollback |
|
|
107
|
+
| `useTimeTravel(system)` | `ShallowRef<TimeTravelState \| null>` | Undo/redo navigation |
|
|
108
|
+
|
|
109
|
+
### Vue-Specific
|
|
110
|
+
|
|
111
|
+
| Export | Description |
|
|
112
|
+
|--------|-------------|
|
|
113
|
+
| `useDirective(module, config?)` | Scoped system with lifecycle (auto-start/destroy) |
|
|
114
|
+
| `createTypedHooks()` | Factory for pre-typed composables |
|
|
115
|
+
| `shallowEqual` | Shallow equality helper for selectors |
|
|
31
116
|
|
|
32
117
|
## Peer Dependencies
|
|
33
118
|
|
|
34
119
|
- `vue >= 3`
|
|
35
120
|
- `@directive-run/core`
|
|
36
121
|
|
|
122
|
+
## Documentation
|
|
123
|
+
|
|
124
|
+
- [Vue Adapter Guide](https://directive.run/docs/adapters/vue)
|
|
125
|
+
- [API Reference](https://directive.run/docs/api)
|
|
126
|
+
|
|
37
127
|
## License
|
|
38
128
|
|
|
39
129
|
MIT
|
|
40
|
-
|
|
41
|
-
[Full documentation](https://directive.run/docs)
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var vue=require('vue'),core=require('@directive-run/core'),adapterUtils=require('@directive-run/core/adapter-utils');function
|
|
1
|
+
'use strict';var vue=require('vue'),core=require('@directive-run/core'),adapterUtils=require('@directive-run/core/adapter-utils');function E(e,t){return adapterUtils.assertSystem("useFact",e),process.env.NODE_ENV!=="production"&&typeof t=="function"&&console.error("[Directive] useFact() received a function. Did you mean useSelector()? useFact() takes a string key or array of keys, not a selector function."),Array.isArray(t)?V(e,t):T(e,t)}function T(e,t){process.env.NODE_ENV!=="production"&&(e.facts.$store.has(t)||console.warn(`[Directive] useFact("${t}") \u2014 fact not found in store. Check that "${t}" is defined in your module's schema.`));let s=vue.ref(e.facts.$store.get(t)),o=e.facts.$store.subscribe([t],()=>{s.value=e.facts.$store.get(t);});return vue.onScopeDispose(o),s}function V(e,t){let s=()=>{let r={};for(let u of t)r[u]=e.facts.$store.get(u);return r},o=vue.shallowRef(s()),n=e.facts.$store.subscribe(t,()=>{o.value=s();});return vue.onScopeDispose(n),o}function $(e,t){return adapterUtils.assertSystem("useDerived",e),process.env.NODE_ENV!=="production"&&typeof t=="function"&&console.error("[Directive] useDerived() received a function. Did you mean useSelector()? useDerived() takes a string key or array of keys, not a selector function."),Array.isArray(t)?A(e,t):q(e,t)}function q(e,t){process.env.NODE_ENV!=="production"&&e.read(t)===void 0&&console.warn(`[Directive] useDerived("${t}") returned undefined. Check that "${t}" is defined in your module's derive property.`);let s=vue.ref(e.read(t)),o=e.subscribe([t],()=>{s.value=e.read(t);});return vue.onScopeDispose(o),s}function A(e,t){let s=()=>{let r={};for(let u of t)r[u]=e.read(u);return r},o=vue.shallowRef(s()),n=e.subscribe(t,()=>{o.value=s();});return vue.onScopeDispose(n),o}function z(e,t,s=adapterUtils.defaultEquality){adapterUtils.assertSystem("useSelector",e);let o=new Set(Object.keys(e.derive??{})),n=()=>adapterUtils.runTrackedSelector(e,o,t),r=n(),u=r.factKeys,i=r.deriveKeys,l=vue.ref(r.value),S=[],c=()=>{for(let d of S)d();S.length=0;let g=()=>{let d=n();s(l.value,d.value)||(l.value=d.value),adapterUtils.depsChanged(u,d.factKeys,i,d.deriveKeys)&&(u=d.factKeys,i=d.deriveKeys,c());};u.length>0?S.push(e.facts.$store.subscribe(u,g)):i.length===0&&S.push(e.facts.$store.subscribeAll(g)),i.length>0&&S.push(e.subscribe(i,g));};return c(),vue.onScopeDispose(()=>{for(let g of S)g();}),l}function H(e){return adapterUtils.assertSystem("useDispatch",e),t=>{e.dispatch(t);}}function P(e){return adapterUtils.assertSystem("useEvents",e),e.events}function U(e,t,s){adapterUtils.assertSystem("useWatch",e);let o=e.watch(t,s);vue.onScopeDispose(o);}function N(e,t){adapterUtils.assertSystem("useInspect",e);let s=vue.shallowRef(adapterUtils.computeInspectState(e)),o=()=>{s.value=adapterUtils.computeInspectState(e);};if(t?.throttleMs&&t.throttleMs>0){let{throttled:n,cleanup:r}=adapterUtils.createThrottle(o,t.throttleMs),u=e.facts.$store.subscribeAll(n),i=e.onSettledChange(n);vue.onScopeDispose(()=>{r(),u(),i();});}else {let n=e.facts.$store.subscribeAll(o),r=e.onSettledChange(o);vue.onScopeDispose(()=>{n(),r();});}return s}function L(e,t){if(Array.isArray(t)){let n=()=>{let i={};for(let l of t)i[l]=e.getStatus(l);return i},r=vue.shallowRef(n()),u=e.subscribe(()=>{r.value=n();});return vue.onScopeDispose(u),r}let s=vue.shallowRef(e.getStatus(t)),o=e.subscribe(()=>{s.value=e.getStatus(t);});return vue.onScopeDispose(o),s}function G(e,t){adapterUtils.assertSystem("useExplain",e);let s=vue.ref(e.explain(t)),o=()=>{s.value=e.explain(t);},n=e.facts.$store.subscribeAll(o),r=e.onSettledChange(o);return vue.onScopeDispose(()=>{n(),r();}),s}function J(e,t){adapterUtils.assertSystem("useConstraintStatus",e);let s=N(e);return vue.computed(()=>{s.value;let o=e.inspect();return t?o.constraints.find(n=>n.id===t)??null:o.constraints})}function Q(e,t,s){adapterUtils.assertSystem("useOptimisticUpdate",e);let o=vue.ref(false),n=vue.ref(null),r=null,u=null,i=()=>{r&&(e.restore(r),r=null),o.value=false,n.value=null,u?.(),u=null;},l=S=>{r=e.getSnapshot(),o.value=true,n.value=null,e.batch(S),t&&s&&(u?.(),u=t.subscribe(()=>{let c=t.getStatus(s);!c.isLoading&&!c.hasError?(r=null,o.value=false,u?.(),u=null):c.hasError&&(n.value=c.lastError,i());}));};return vue.onScopeDispose(()=>{u?.();}),{mutate:l,isPending:o,error:n,rollback:i}}function X(e){adapterUtils.assertSystem("useTimeTravel",e);let t=vue.shallowRef(adapterUtils.buildTimeTravelState(e)),s=e.onTimeTravelChange(()=>{t.value=adapterUtils.buildTimeTravelState(e);});return vue.onScopeDispose(s),t}function Y(e,t){let s=[...t?.plugins??[]],o;if(t?.status){let v=core.createRequirementStatusPlugin();o=v,s.push(v.plugin);}let n=core.createSystem({module:e,plugins:s.length>0?s:void 0,debug:t?.debug,errorBoundary:t?.errorBoundary,tickMs:t?.tickMs,zeroConfig:t?.zeroConfig,initialFacts:t?.initialFacts});n.start(),vue.onScopeDispose(()=>{n.destroy();});let r=t?.facts,u=t?.derived,i=!r&&!u,l=vue.shallowRef(i?n.facts.$store.toObject():adapterUtils.pickFacts(n,r??[])),S=i?n.facts.$store.subscribeAll(()=>{l.value=n.facts.$store.toObject();}):r&&r.length>0?n.facts.$store.subscribe(r,()=>{l.value=adapterUtils.pickFacts(n,r);}):null,c=i?Object.keys(n.derive??{}):u??[],g=()=>{let v={};for(let M of c)v[M]=n.read(M);return v},d=vue.shallowRef(g()),R=c.length>0?n.subscribe(c,()=>{d.value=g();}):null;vue.onScopeDispose(()=>{S?.(),R?.();});let k=n.events;return {system:n,facts:l,derived:d,events:k,dispatch:v=>n.dispatch(v),statusPlugin:o}}function Z(){return {useFact:(e,t)=>E(e,t),useDerived:(e,t)=>$(e,t),useDispatch:e=>t=>{e.dispatch(t);},useEvents:e=>P(e),useWatch:(e,t,s)=>U(e,t,s)}}Object.defineProperty(exports,"shallowEqual",{enumerable:true,get:function(){return adapterUtils.shallowEqual}});exports.createTypedHooks=Z;exports.useConstraintStatus=J;exports.useDerived=$;exports.useDirective=Y;exports.useDispatch=H;exports.useEvents=P;exports.useExplain=G;exports.useFact=E;exports.useInspect=N;exports.useOptimisticUpdate=Q;exports.useRequirementStatus=L;exports.useSelector=z;exports.useTimeTravel=X;exports.useWatch=U;//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["useFact","system","keyOrKeys","assertSystem","_useFactMulti","_useFactSingle","factKey","value","ref","unsubscribe","onScopeDispose","factKeys","getValues","result","key","state","shallowRef","useDerived","idOrIds","_useDerivedMulti","_useDerivedSingle","derivationId","derivationIds","id","useSelector","selector","equalityFn","defaultEquality","deriveKeySet","runWithTracking","runTrackedSelector","initial","trackedFactKeys","trackedDeriveKeys","selected","unsubs","resubscribe","unsub","onUpdate","depsChanged","useDispatch","event","useEvents","useWatch","derivationIdOrKind","callbackOrFactKey","maybeCallback","isFact","callback","useInspect","options","computeInspectState","update","throttled","cleanup","createThrottle","unsubFacts","unsubSettled","useRequirementStatus","statusPlugin","typeOrTypes","type","status","useExplain","requirementId","explanation","useConstraintStatus","constraintId","inspectState","computed","fullInspection","c","useOptimisticUpdate","requirementType","isPending","error","snapshot","rollback","mutate","updateFn","useTimeTravel","buildTimeTravelState","useDirective","moduleDef","config","allPlugins","sp","createRequirementStatusPlugin","createSystem","derivedKeys","subscribeAll","factsState","pickFacts","allDerivationKeys","getDerived","derivedState","unsubDerived","events","createTypedHooks"],"mappings":"kIAkEO,SAASA,CAAAA,CAEfC,CAAAA,CACAC,CAAAA,CACqC,CAUrC,OATAC,yBAAAA,CAAa,UAAWF,CAAM,CAAA,CAC1B,OAAA,CAAQ,GAAA,CAAI,WAAa,YAAA,EAAgB,OAAOC,CAAAA,EAAc,UAAA,EACjE,QAAQ,KAAA,CACP,gJAED,CAAA,CAIG,KAAA,CAAM,OAAA,CAAQA,CAAS,CAAA,CACnBE,CAAAA,CAAcH,EAAQC,CAAS,CAAA,CAIhCG,CAAAA,CAAeJ,CAAAA,CAAQC,CAAS,CACxC,CAGA,SAASG,CAAAA,CAAeJ,EAAiCK,CAAAA,CAA+B,CACnF,OAAA,CAAQ,GAAA,CAAI,QAAA,GAAa,YAAA,GACvBL,CAAAA,CAAO,KAAA,CAAM,OAAO,GAAA,CAAIK,CAAO,CAAA,EACnC,OAAA,CAAQ,KACP,CAAA,qBAAA,EAAwBA,CAAO,CAAA,+CAAA,EAChBA,CAAO,uCACvB,CAAA,CAAA,CAIF,IAAMC,CAAAA,CAAQC,OAAAA,CAAIP,CAAAA,CAAO,KAAA,CAAM,MAAA,CAAO,GAAA,CAAIK,CAAO,CAAC,CAAA,CAC5CG,CAAAA,CAAcR,CAAAA,CAAO,MAAM,MAAA,CAAO,SAAA,CAAU,CAACK,CAAO,EAAG,IAAM,CAClEC,CAAAA,CAAM,KAAA,CAAQN,CAAAA,CAAO,KAAA,CAAM,MAAA,CAAO,GAAA,CAAIK,CAAO,EAC9C,CAAC,CAAA,CACD,OAAAI,mBAAeD,CAAW,CAAA,CACnBF,CACR,CAGA,SAASH,CAAAA,CAAcH,CAAAA,CAAiCU,CAAAA,CAAyD,CAChH,IAAMC,CAAAA,CAAY,IAA+B,CAChD,IAAMC,CAAAA,CAAkC,EAAC,CACzC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A,CAASwC,CAAK,EACtB,EAED,SAAA,CAAYxC,CAAAA,EAAkCyC,CAAAA,CAAazC,CAAM,EACjE,QAAA,CAAU,CACTA,CAAAA,CACAa,CAAAA,CACAkC,IAGAL,CAAAA,CAAS1C,CAAAA,CAAmCa,CAAAA,CAAKkC,CAAQ,CAC3D,CACD","file":"index.cjs","sourcesContent":["/**\n * Vue Adapter - Vue 3 composables for Directive\n *\n * Exports: useFact, useDerived, useDispatch, useSelector,\n * useWatch, useInspect, useRequirementStatus, useEvents, useExplain,\n * useConstraintStatus, useOptimisticUpdate, useDirective, useTimeTravel,\n * createTypedHooks, shallowEqual\n */\n\nimport {\n\tcomputed,\n\tonScopeDispose,\n\tref,\n\tshallowRef,\n\ttype ComputedRef,\n\ttype Ref,\n\ttype ShallowRef,\n} from \"vue\";\nimport type {\n\tModuleSchema,\n\tModuleDef,\n\tPlugin,\n\tDebugConfig,\n\tErrorBoundaryConfig,\n\tInferFacts,\n\tInferDerivations,\n\tInferSelectorState,\n\tInferEvents,\n\tSingleModuleSystem,\n\tSystemSnapshot,\n} from \"@directive-run/core\";\nimport {\n\tcreateSystem,\n\tcreateRequirementStatusPlugin,\n} from \"@directive-run/core\";\nimport type { RequirementTypeStatus } from \"@directive-run/core\";\nimport {\n\ttype InspectState,\n\ttype ConstraintInfo,\n\tcomputeInspectState,\n\tcreateThrottle,\n\tassertSystem,\n\tdefaultEquality,\n\tbuildTimeTravelState,\n\tpickFacts,\n\trunTrackedSelector,\n\tdepsChanged,\n\tshallowEqual,\n} from \"@directive-run/core/adapter-utils\";\n\n// Re-export for convenience\nexport type { RequirementTypeStatus, InspectState, ConstraintInfo };\nexport { shallowEqual };\n\n/** Type for the requirement status plugin return value */\nexport type StatusPlugin = ReturnType<typeof createRequirementStatusPlugin>;\n\n// ============================================================================\n// useFact — single key or multi key\n// ============================================================================\n\n/** Single key overload */\nexport function useFact<S extends ModuleSchema, K extends keyof InferFacts<S> & string>(system: SingleModuleSystem<S>, factKey: K): Ref<InferFacts<S>[K] | undefined>;\n/** Multi-key overload */\nexport function useFact<S extends ModuleSchema, K extends keyof InferFacts<S> & string>(system: SingleModuleSystem<S>, factKeys: K[]): ShallowRef<Pick<InferFacts<S>, K>>;\n/** Implementation */\nexport function useFact(\n\t// biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n\tsystem: SingleModuleSystem<any>,\n\tkeyOrKeys: string | string[],\n): Ref<unknown> | ShallowRef<unknown> {\n\tassertSystem(\"useFact\", system);\n\tif (process.env.NODE_ENV !== \"production\" && typeof keyOrKeys === \"function\") {\n\t\tconsole.error(\n\t\t\t\"[Directive] useFact() received a function. Did you mean useSelector()? \" +\n\t\t\t\t\"useFact() takes a string key or array of keys, not a selector function.\",\n\t\t);\n\t}\n\n\t// Multi-key path: useFact(system, [keys])\n\tif (Array.isArray(keyOrKeys)) {\n\t\treturn _useFactMulti(system, keyOrKeys);\n\t}\n\n\t// Single key path: useFact(system, key)\n\treturn _useFactSingle(system, keyOrKeys);\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useFactSingle(system: SingleModuleSystem<any>, factKey: string): Ref<unknown> {\n\tif (process.env.NODE_ENV !== \"production\") {\n\t\tif (!system.facts.$store.has(factKey)) {\n\t\t\tconsole.warn(\n\t\t\t\t`[Directive] useFact(\"${factKey}\") — fact not found in store. ` +\n\t\t\t\t`Check that \"${factKey}\" is defined in your module's schema.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tconst value = ref(system.facts.$store.get(factKey));\n\tconst unsubscribe = system.facts.$store.subscribe([factKey], () => {\n\t\tvalue.value = system.facts.$store.get(factKey);\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn value;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useFactMulti(system: SingleModuleSystem<any>, factKeys: string[]): ShallowRef<Record<string, unknown>> {\n\tconst getValues = (): Record<string, unknown> => {\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const key of factKeys) {\n\t\t\tresult[key] = system.facts.$store.get(key);\n\t\t}\n\t\treturn result;\n\t};\n\tconst state = shallowRef(getValues());\n\tconst unsubscribe = system.facts.$store.subscribe(factKeys, () => {\n\t\tstate.value = getValues();\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn state;\n}\n\n// ============================================================================\n// useDerived — single key or multi key\n// ============================================================================\n\n/** Single key overload */\nexport function useDerived<S extends ModuleSchema, K extends keyof InferDerivations<S> & string>(system: SingleModuleSystem<S>, derivationId: K): Ref<InferDerivations<S>[K]>;\n/** Multi-key overload */\nexport function useDerived<S extends ModuleSchema, K extends keyof InferDerivations<S> & string>(system: SingleModuleSystem<S>, derivationIds: K[]): ShallowRef<Pick<InferDerivations<S>, K>>;\n/** Implementation */\nexport function useDerived(\n\t// biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n\tsystem: SingleModuleSystem<any>,\n\tidOrIds: string | string[],\n): Ref<unknown> | ShallowRef<unknown> {\n\tassertSystem(\"useDerived\", system);\n\tif (process.env.NODE_ENV !== \"production\" && typeof idOrIds === \"function\") {\n\t\tconsole.error(\n\t\t\t\"[Directive] useDerived() received a function. Did you mean useSelector()? \" +\n\t\t\t\t\"useDerived() takes a string key or array of keys, not a selector function.\",\n\t\t);\n\t}\n\n\t// Multi-key path\n\tif (Array.isArray(idOrIds)) {\n\t\treturn _useDerivedMulti(system, idOrIds);\n\t}\n\n\t// Single key path\n\treturn _useDerivedSingle(system, idOrIds);\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useDerivedSingle(system: SingleModuleSystem<any>, derivationId: string): Ref<unknown> {\n\tif (process.env.NODE_ENV !== \"production\") {\n\t\tconst initialValue = system.read(derivationId);\n\t\tif (initialValue === undefined) {\n\t\t\tconsole.warn(\n\t\t\t\t`[Directive] useDerived(\"${derivationId}\") returned undefined. ` +\n\t\t\t\t`Check that \"${derivationId}\" is defined in your module's derive property.`,\n\t\t\t);\n\t\t}\n\t}\n\tconst value = ref(system.read(derivationId));\n\tconst unsubscribe = system.subscribe([derivationId], () => {\n\t\tvalue.value = system.read(derivationId);\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn value;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useDerivedMulti(system: SingleModuleSystem<any>, derivationIds: string[]): ShallowRef<Record<string, unknown>> {\n\tconst getValues = (): Record<string, unknown> => {\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const id of derivationIds) {\n\t\t\tresult[id] = system.read(id);\n\t\t}\n\t\treturn result;\n\t};\n\tconst state = shallowRef(getValues());\n\tconst unsubscribe = system.subscribe(derivationIds, () => {\n\t\tstate.value = getValues();\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn state;\n}\n\n// ============================================================================\n// useSelector — auto-tracking selector over facts and derivations\n// ============================================================================\n\n/**\n * Auto-tracking selector over facts and derivations.\n * Uses `withTracking()` to detect which facts the selector accesses,\n * then subscribes only to those keys.\n */\nexport function useSelector<S extends ModuleSchema, R>(system: SingleModuleSystem<S>, selector: (state: InferSelectorState<S>) => R, equalityFn?: (a: R, b: R) => boolean): Ref<R>;\nexport function useSelector<R>(\n\t// biome-ignore lint/suspicious/noExplicitAny: Backward-compatible fallback\n\tsystem: SingleModuleSystem<any>,\n\t// biome-ignore lint/suspicious/noExplicitAny: Selector receives dynamic state\n\tselector: (state: Record<string, any>) => R,\n\tequalityFn?: (a: R, b: R) => boolean,\n): Ref<R>;\nexport function useSelector(\n\t// biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n\tsystem: SingleModuleSystem<any>,\n\tselector: (state: Record<string, unknown>) => unknown,\n\tequalityFn: (a: unknown, b: unknown) => boolean = defaultEquality,\n): Ref<unknown> {\n\tassertSystem(\"useSelector\", system);\n\tconst deriveKeySet = new Set(Object.keys(system.derive ?? {}));\n\n\tconst runWithTracking = () => runTrackedSelector(system, deriveKeySet, selector);\n\n\tconst initial = runWithTracking();\n\tlet trackedFactKeys = initial.factKeys;\n\tlet trackedDeriveKeys = initial.deriveKeys;\n\tconst selected = ref(initial.value);\n\n\tconst unsubs: Array<() => void> = [];\n\n\tconst resubscribe = () => {\n\t\tfor (const unsub of unsubs) unsub();\n\t\tunsubs.length = 0;\n\n\t\tconst onUpdate = () => {\n\t\t\tconst result = runWithTracking();\n\t\t\tif (!equalityFn(selected.value, result.value)) {\n\t\t\t\tselected.value = result.value;\n\t\t\t}\n\t\t\t// Re-track: check if deps changed\n\t\t\tif (depsChanged(trackedFactKeys, result.factKeys, trackedDeriveKeys, result.deriveKeys)) {\n\t\t\t\ttrackedFactKeys = result.factKeys;\n\t\t\t\ttrackedDeriveKeys = result.deriveKeys;\n\t\t\t\tresubscribe();\n\t\t\t}\n\t\t};\n\n\t\tif (trackedFactKeys.length > 0) {\n\t\t\tunsubs.push(system.facts.$store.subscribe(trackedFactKeys, onUpdate));\n\t\t} else if (trackedDeriveKeys.length === 0) {\n\t\t\tunsubs.push(system.facts.$store.subscribeAll(onUpdate));\n\t\t}\n\t\tif (trackedDeriveKeys.length > 0) {\n\t\t\tunsubs.push(system.subscribe(trackedDeriveKeys, onUpdate));\n\t\t}\n\t};\n\n\tresubscribe();\n\n\tonScopeDispose(() => {\n\t\tfor (const unsub of unsubs) unsub();\n\t});\n\n\treturn selected;\n}\n\n// ============================================================================\n// useDispatch\n// ============================================================================\n\nexport function useDispatch<S extends ModuleSchema>(\n\tsystem: SingleModuleSystem<S>,\n): (event: InferEvents<S>) => void {\n\tassertSystem(\"useDispatch\", system);\n\treturn (event: InferEvents<S>) => {\n\t\tsystem.dispatch(event);\n\t};\n}\n\n// ============================================================================\n// useEvents — memoized events reference\n// ============================================================================\n\n/**\n * Returns the system's events dispatcher.\n */\nexport function useEvents<S extends ModuleSchema>(\n\tsystem: SingleModuleSystem<S>,\n): SingleModuleSystem<S>[\"events\"] {\n\tassertSystem(\"useEvents\", system);\n\treturn system.events;\n}\n\n// ============================================================================\n// useWatch — derivation or fact side-effect\n// ============================================================================\n\n/** Watch a derivation or fact by key (auto-detected). When a key exists in both facts and derivations, the derivation overload takes priority. */\nexport function useWatch<S extends ModuleSchema, K extends keyof InferDerivations<S> & string>(\n\tsystem: SingleModuleSystem<S>,\n\tkey: K,\n\tcallback: (newValue: InferDerivations<S>[K], previousValue: InferDerivations<S>[K] | undefined) => void,\n): void;\n/** Watch a fact key with auto-detection. */\nexport function useWatch<S extends ModuleSchema, K extends keyof InferFacts<S> & string>(\n\tsystem: SingleModuleSystem<S>,\n\tkey: K,\n\tcallback: (newValue: InferFacts<S>[K] | undefined, previousValue: InferFacts<S>[K] | undefined) => void,\n): void;\n/**\n * Watch a fact by explicit \"fact\" discriminator.\n * @deprecated Use `useWatch(system, key, callback)` instead — facts are now auto-detected.\n */\nexport function useWatch<S extends ModuleSchema, K extends keyof InferFacts<S> & string>(\n\tsystem: SingleModuleSystem<S>,\n\tkind: \"fact\",\n\tfactKey: K,\n\tcallback: (newValue: InferFacts<S>[K] | undefined, previousValue: InferFacts<S>[K] | undefined) => void,\n): void;\n/** Watch a fact or derivation (generic fallback) */\nexport function useWatch<T>(\n\t// biome-ignore lint/suspicious/noExplicitAny: Backward-compatible fallback\n\tsystem: SingleModuleSystem<any>,\n\tkey: string,\n\tcallback: (newValue: T, previousValue: T | undefined) => void,\n): void;\n/** Implementation */\nexport function useWatch(\n\t// biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n\tsystem: SingleModuleSystem<any>,\n\tderivationIdOrKind: string,\n\tcallbackOrFactKey: string | ((newValue: unknown, prevValue: unknown) => void),\n\tmaybeCallback?: (newValue: unknown, prevValue: unknown) => void,\n): void {\n\tassertSystem(\"useWatch\", system);\n\t// Backward compat: useWatch(system, \"fact\", factKey, callback)\n\tconst isFact =\n\t\tderivationIdOrKind === \"fact\" &&\n\t\ttypeof callbackOrFactKey === \"string\" &&\n\t\ttypeof maybeCallback === \"function\";\n\n\tconst key = isFact ? (callbackOrFactKey as string) : derivationIdOrKind;\n\tconst callback = isFact\n\t\t? maybeCallback!\n\t\t: (callbackOrFactKey as (newValue: unknown, prevValue: unknown) => void);\n\n\tconst unsubscribe = system.watch(key, callback);\n\tonScopeDispose(unsubscribe);\n}\n\n// ============================================================================\n// useInspect — consolidated inspection hook\n// ============================================================================\n\n/** Options for useInspect */\nexport interface UseInspectOptions {\n\tthrottleMs?: number;\n}\n\n/**\n * Consolidated system inspection hook.\n * Returns InspectState with optional throttling.\n */\nexport function useInspect(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n\toptions?: UseInspectOptions,\n): ShallowRef<InspectState> {\n\tassertSystem(\"useInspect\", system);\n\tconst state = shallowRef<InspectState>(computeInspectState(system));\n\n\tconst update = () => {\n\t\tstate.value = computeInspectState(system);\n\t};\n\n\tif (options?.throttleMs && options.throttleMs > 0) {\n\t\tconst { throttled, cleanup } = createThrottle(update, options.throttleMs);\n\t\tconst unsubFacts = system.facts.$store.subscribeAll(throttled);\n\t\tconst unsubSettled = system.onSettledChange(throttled);\n\t\tonScopeDispose(() => {\n\t\t\tcleanup();\n\t\t\tunsubFacts();\n\t\t\tunsubSettled();\n\t\t});\n\t} else {\n\t\tconst unsubFacts = system.facts.$store.subscribeAll(update);\n\t\tconst unsubSettled = system.onSettledChange(update);\n\t\tonScopeDispose(() => {\n\t\t\tunsubFacts();\n\t\t\tunsubSettled();\n\t\t});\n\t}\n\n\treturn state;\n}\n\n// ============================================================================\n// useRequirementStatus — single or multi\n// ============================================================================\n\n/** Single type overload */\nexport function useRequirementStatus(statusPlugin: StatusPlugin, type: string): ShallowRef<RequirementTypeStatus>;\n/** Multi-type overload */\nexport function useRequirementStatus(statusPlugin: StatusPlugin, types: string[]): ShallowRef<Record<string, RequirementTypeStatus>>;\n/** Implementation */\nexport function useRequirementStatus(\n\tstatusPlugin: StatusPlugin,\n\ttypeOrTypes: string | string[],\n): ShallowRef<RequirementTypeStatus> | ShallowRef<Record<string, RequirementTypeStatus>> {\n\tif (Array.isArray(typeOrTypes)) {\n\t\tconst getValues = (): Record<string, RequirementTypeStatus> => {\n\t\t\tconst result: Record<string, RequirementTypeStatus> = {};\n\t\t\tfor (const type of typeOrTypes) {\n\t\t\t\tresult[type] = statusPlugin.getStatus(type);\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\t\tconst state = shallowRef(getValues());\n\t\tconst unsubscribe = statusPlugin.subscribe(() => {\n\t\t\tstate.value = getValues();\n\t\t});\n\t\tonScopeDispose(unsubscribe);\n\t\treturn state;\n\t}\n\n\tconst status = shallowRef<RequirementTypeStatus>(statusPlugin.getStatus(typeOrTypes));\n\tconst unsubscribe = statusPlugin.subscribe(() => {\n\t\tstatus.value = statusPlugin.getStatus(typeOrTypes);\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn status;\n}\n\n// ============================================================================\n// useExplain — reactive requirement explanation\n// ============================================================================\n\n/**\n * Reactively returns the explanation string for a requirement.\n */\nexport function useExplain(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n\trequirementId: string,\n): Ref<string | null> {\n\tassertSystem(\"useExplain\", system);\n\tconst explanation = ref<string | null>(system.explain(requirementId)) as Ref<string | null>;\n\n\tconst update = () => {\n\t\texplanation.value = system.explain(requirementId);\n\t};\n\n\tconst unsubFacts = system.facts.$store.subscribeAll(update);\n\tconst unsubSettled = system.onSettledChange(update);\n\tonScopeDispose(() => {\n\t\tunsubFacts();\n\t\tunsubSettled();\n\t});\n\n\treturn explanation;\n}\n\n// ============================================================================\n// useConstraintStatus — reactive constraint inspection\n// ============================================================================\n\n/** Get all constraints */\nexport function useConstraintStatus(\n\tsystem: SingleModuleSystem<any>,\n): ComputedRef<ConstraintInfo[]>;\n/** Get a single constraint by ID */\nexport function useConstraintStatus(\n\tsystem: SingleModuleSystem<any>,\n\tconstraintId: string,\n): ComputedRef<ConstraintInfo | null>;\n/** Implementation */\nexport function useConstraintStatus(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n\tconstraintId?: string,\n): ComputedRef<ConstraintInfo[] | ConstraintInfo | null> {\n\tassertSystem(\"useConstraintStatus\", system);\n\tconst inspectState = useInspect(system);\n\n\treturn computed(() => {\n\t\t// Track reactivity via inspectState, but use full inspect() for constraint list\n\t\tvoid inspectState.value;\n\t\tconst fullInspection = system.inspect();\n\t\tif (!constraintId) return fullInspection.constraints;\n\t\treturn fullInspection.constraints.find((c) => c.id === constraintId) ?? null;\n\t});\n}\n\n// ============================================================================\n// useOptimisticUpdate — batch with rollback on failure\n// ============================================================================\n\nexport interface OptimisticUpdateResult {\n\tmutate: (updateFn: () => void) => void;\n\tisPending: Ref<boolean>;\n\terror: Ref<Error | null>;\n\trollback: () => void;\n}\n\n/**\n * Optimistic update hook. Saves a snapshot before mutating, monitors\n * a requirement type via statusPlugin, and rolls back on failure.\n */\nexport function useOptimisticUpdate(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n\tstatusPlugin?: StatusPlugin,\n\trequirementType?: string,\n): OptimisticUpdateResult {\n\tassertSystem(\"useOptimisticUpdate\", system);\n\tconst isPending = ref(false);\n\tconst error = ref<Error | null>(null) as Ref<Error | null>;\n\tlet snapshot: SystemSnapshot | null = null;\n\tlet unsubscribe: (() => void) | null = null;\n\n\tconst rollback = () => {\n\t\tif (snapshot) {\n\t\t\tsystem.restore(snapshot);\n\t\t\tsnapshot = null;\n\t\t}\n\t\tisPending.value = false;\n\t\terror.value = null;\n\t\tunsubscribe?.();\n\t\tunsubscribe = null;\n\t};\n\n\tconst mutate = (updateFn: () => void) => {\n\t\tsnapshot = system.getSnapshot();\n\t\tisPending.value = true;\n\t\terror.value = null;\n\t\tsystem.batch(updateFn);\n\n\t\t// Watch for resolver completion/failure\n\t\tif (statusPlugin && requirementType) {\n\t\t\tunsubscribe?.();\n\t\t\tunsubscribe = statusPlugin.subscribe(() => {\n\t\t\t\tconst status = statusPlugin.getStatus(requirementType);\n\t\t\t\tif (!status.isLoading && !status.hasError) {\n\t\t\t\t\tsnapshot = null;\n\t\t\t\t\tisPending.value = false;\n\t\t\t\t\tunsubscribe?.();\n\t\t\t\t\tunsubscribe = null;\n\t\t\t\t} else if (status.hasError) {\n\t\t\t\t\terror.value = status.lastError;\n\t\t\t\t\trollback();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t};\n\n\tonScopeDispose(() => {\n\t\tunsubscribe?.();\n\t});\n\n\treturn { mutate, isPending, error, rollback };\n}\n\n// ============================================================================\n// useTimeTravel — reactive time-travel state\n// ============================================================================\n\n/**\n * Reactive time-travel composable. Returns a ShallowRef that updates\n * when snapshots are taken or navigation occurs.\n *\n * @example\n * ```vue\n * const tt = useTimeTravel(system);\n * <button :disabled=\"!tt.value?.canUndo\" @click=\"tt.value?.undo()\">Undo</button>\n * ```\n */\nexport function useTimeTravel(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n): ShallowRef<ReturnType<typeof buildTimeTravelState>> {\n\tassertSystem(\"useTimeTravel\", system);\n\tconst state = shallowRef<ReturnType<typeof buildTimeTravelState>>(buildTimeTravelState(system));\n\tconst unsub = system.onTimeTravelChange(() => {\n\t\tstate.value = buildTimeTravelState(system);\n\t});\n\tonScopeDispose(unsub);\n\treturn state;\n}\n\n// ============================================================================\n// Scoped System Composable\n// ============================================================================\n\n/** Configuration for useDirective */\ninterface UseDirectiveConfig {\n\t// biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n\tplugins?: Plugin<any>[];\n\tdebug?: DebugConfig;\n\terrorBoundary?: ErrorBoundaryConfig;\n\ttickMs?: number;\n\tzeroConfig?: boolean;\n\t// biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n\tinitialFacts?: Record<string, any>;\n\tstatus?: boolean;\n\t/** Fact keys to subscribe to (omit for all) */\n\tfacts?: string[];\n\t/** Derivation keys to subscribe to (omit for all) */\n\tderived?: string[];\n}\n\n/**\n * Create a scoped Directive system with automatic lifecycle management.\n * When no `facts` or `derived` keys are specified, subscribes to ALL\n * facts and derivations and returns reactive state.\n *\n * @example\n * ```vue\n * // Subscribe to everything\n * const { facts, derived, events, dispatch } = useDirective(counterModule);\n *\n * // Selective keys\n * const { facts, derived } = useDirective(counterModule, { facts: [\"count\"], derived: [\"doubled\"] });\n * ```\n */\nexport function useDirective<M extends ModuleSchema>(\n\tmoduleDef: ModuleDef<M>,\n\tconfig?: UseDirectiveConfig,\n) {\n\tconst allPlugins = [...(config?.plugins ?? [])];\n\tlet statusPlugin: StatusPlugin | undefined;\n\n\tif (config?.status) {\n\t\tconst sp = createRequirementStatusPlugin();\n\t\tstatusPlugin = sp;\n\t\t// biome-ignore lint/suspicious/noExplicitAny: Plugin generic issues\n\t\tallPlugins.push(sp.plugin as Plugin<any>);\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: Required for overload compatibility\n\tconst system = createSystem({\n\t\tmodule: moduleDef,\n\t\tplugins: allPlugins.length > 0 ? allPlugins : undefined,\n\t\tdebug: config?.debug,\n\t\terrorBoundary: config?.errorBoundary,\n\t\ttickMs: config?.tickMs,\n\t\tzeroConfig: config?.zeroConfig,\n\t\tinitialFacts: config?.initialFacts,\n\t} as any) as unknown as SingleModuleSystem<M>;\n\n\tsystem.start();\n\n\tonScopeDispose(() => {\n\t\tsystem.destroy();\n\t});\n\n\tconst factKeys = config?.facts;\n\tconst derivedKeys = config?.derived;\n\tconst subscribeAll = !factKeys && !derivedKeys;\n\n\t// Subscribe to facts\n\tconst factsState = shallowRef(\n\t\tsubscribeAll\n\t\t\t? (system.facts.$store.toObject() as InferFacts<M>)\n\t\t\t: pickFacts(system, factKeys ?? []),\n\t);\n\tconst unsubFacts = subscribeAll\n\t\t? system.facts.$store.subscribeAll(() => {\n\t\t\tfactsState.value = system.facts.$store.toObject() as InferFacts<M>;\n\t\t})\n\t\t: factKeys && factKeys.length > 0\n\t\t\t? system.facts.$store.subscribe(factKeys, () => {\n\t\t\t\tfactsState.value = pickFacts(system, factKeys) as InferFacts<M>;\n\t\t\t})\n\t\t\t: null;\n\n\t// Subscribe to derivations\n\tconst allDerivationKeys = subscribeAll ? Object.keys(system.derive ?? {}) : (derivedKeys ?? []);\n\tconst getDerived = (): InferDerivations<M> => {\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const key of allDerivationKeys) {\n\t\t\tresult[key] = system.read(key);\n\t\t}\n\t\treturn result as InferDerivations<M>;\n\t};\n\tconst derivedState = shallowRef(getDerived());\n\tconst unsubDerived = allDerivationKeys.length > 0\n\t\t? system.subscribe(allDerivationKeys, () => { derivedState.value = getDerived(); })\n\t\t: null;\n\n\tonScopeDispose(() => {\n\t\tunsubFacts?.();\n\t\tunsubDerived?.();\n\t});\n\n\tconst events = system.events;\n\tconst dispatch = (event: InferEvents<M>) => system.dispatch(event);\n\n\treturn {\n\t\tsystem,\n\t\tfacts: factsState as ShallowRef<InferFacts<M>>,\n\t\tderived: derivedState as ShallowRef<InferDerivations<M>>,\n\t\tevents,\n\t\tdispatch,\n\t\tstatusPlugin,\n\t};\n}\n\n// ============================================================================\n// Typed Hooks Factory\n// ============================================================================\n\nexport function createTypedHooks<M extends ModuleSchema>(): {\n\tuseFact: <K extends keyof InferFacts<M> & string>(\n\t\tsystem: SingleModuleSystem<M>,\n\t\tfactKey: K,\n\t) => Ref<InferFacts<M>[K] | undefined>;\n\tuseDerived: <K extends keyof InferDerivations<M> & string>(\n\t\tsystem: SingleModuleSystem<M>,\n\t\tderivationId: K,\n\t) => Ref<InferDerivations<M>[K]>;\n\tuseDispatch: (system: SingleModuleSystem<M>) => (event: InferEvents<M>) => void;\n\tuseEvents: (system: SingleModuleSystem<M>) => SingleModuleSystem<M>[\"events\"];\n\tuseWatch: <K extends string>(\n\t\tsystem: SingleModuleSystem<M>,\n\t\tkey: K,\n\t\tcallback: (newValue: unknown, previousValue: unknown) => void,\n\t) => void;\n} {\n\treturn {\n\t\tuseFact: <K extends keyof InferFacts<M> & string>(system: SingleModuleSystem<M>, factKey: K) =>\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n\t\t\tuseFact(system as SingleModuleSystem<any>, factKey) as Ref<InferFacts<M>[K] | undefined>,\n\t\tuseDerived: <K extends keyof InferDerivations<M> & string>(system: SingleModuleSystem<M>, derivationId: K) =>\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n\t\t\tuseDerived(system as SingleModuleSystem<any>, derivationId) as Ref<InferDerivations<M>[K]>,\n\t\tuseDispatch: (system: SingleModuleSystem<M>) => {\n\t\t\treturn (event: InferEvents<M>) => {\n\t\t\t\tsystem.dispatch(event);\n\t\t\t};\n\t\t},\n\t\tuseEvents: (system: SingleModuleSystem<M>) => useEvents<M>(system),\n\t\tuseWatch: <K extends string>(\n\t\t\tsystem: SingleModuleSystem<M>,\n\t\t\tkey: K,\n\t\t\tcallback: (newValue: unknown, previousValue: unknown) => void,\n\t\t) =>\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n\t\t\tuseWatch(system as SingleModuleSystem<any>, key, callback),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["useFact","system","keyOrKeys","assertSystem","_useFactMulti","_useFactSingle","factKey","value","ref","unsubscribe","onScopeDispose","factKeys","getValues","result","key","state","shallowRef","useDerived","idOrIds","_useDerivedMulti","_useDerivedSingle","derivationId","derivationIds","id","useSelector","selector","equalityFn","defaultEquality","deriveKeySet","runWithTracking","runTrackedSelector","initial","trackedFactKeys","trackedDeriveKeys","selected","unsubs","resubscribe","unsub","onUpdate","depsChanged","useDispatch","event","useEvents","useWatch","callback","useInspect","options","computeInspectState","update","throttled","cleanup","createThrottle","unsubFacts","unsubSettled","useRequirementStatus","statusPlugin","typeOrTypes","type","status","useExplain","requirementId","explanation","useConstraintStatus","constraintId","inspectState","computed","fullInspection","c","useOptimisticUpdate","requirementType","isPending","error","snapshot","rollback","mutate","updateFn","useTimeTravel","buildTimeTravelState","useDirective","moduleDef","config","allPlugins","sp","createRequirementStatusPlugin","createSystem","derivedKeys","subscribeAll","factsState","pickFacts","allDerivationKeys","getDerived","derivedState","unsubDerived","events","createTypedHooks"],"mappings":"kIAkEO,SAASA,CAAAA,CAEfC,CAAAA,CACAC,CAAAA,CACqC,CAUrC,OATAC,0BAAa,SAAA,CAAWF,CAAM,CAAA,CAC1B,OAAA,CAAQ,IAAI,QAAA,GAAa,YAAA,EAAgB,OAAOC,CAAAA,EAAc,YACjE,OAAA,CAAQ,KAAA,CACP,gJAED,CAAA,CAIG,KAAA,CAAM,OAAA,CAAQA,CAAS,CAAA,CACnBE,EAAcH,CAAAA,CAAQC,CAAS,CAAA,CAIhCG,CAAAA,CAAeJ,EAAQC,CAAS,CACxC,CAGA,SAASG,EAAeJ,CAAAA,CAAiCK,CAAAA,CAA+B,CACnF,OAAA,CAAQ,GAAA,CAAI,QAAA,GAAa,YAAA,GACvBL,CAAAA,CAAO,MAAM,MAAA,CAAO,GAAA,CAAIK,CAAO,CAAA,EACnC,OAAA,CAAQ,IAAA,CACP,CAAA,qBAAA,EAAwBA,CAAO,kDAChBA,CAAO,CAAA,qCAAA,CACvB,CAAA,CAAA,CAIF,IAAMC,CAAAA,CAAQC,OAAAA,CAAIP,CAAAA,CAAO,KAAA,CAAM,OAAO,GAAA,CAAIK,CAAO,CAAC,CAAA,CAC5CG,EAAcR,CAAAA,CAAO,KAAA,CAAM,MAAA,CAAO,SAAA,CAAU,CAACK,CAAO,CAAA,CAAG,IAAM,CAClEC,CAAAA,CAAM,KAAA,CAAQN,CAAAA,CAAO,KAAA,CAAM,OAAO,GAAA,CAAIK,CAAO,EAC9C,CAAC,EACD,OAAAI,kBAAAA,CAAeD,CAAW,CAAA,CACnBF,CACR,CAGA,SAASH,CAAAA,CAAcH,CAAAA,CAAiCU,CAAAA,CAAyD,CAChH,IAAMC,CAAAA,CAAY,IAA+B,CAChD,IAAMC,CAAAA,CAAkC,GACxC,IAAA,IA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IAGAD,CAAAA,CAAS1C,CAAAA,CAAmCa,CAAAA,CAAK8B,CAAQ,CAC3D,CACD","file":"index.cjs","sourcesContent":["/**\n * Vue Adapter - Vue 3 composables for Directive\n *\n * Exports: useFact, useDerived, useDispatch, useSelector,\n * useWatch, useInspect, useRequirementStatus, useEvents, useExplain,\n * useConstraintStatus, useOptimisticUpdate, useDirective, useTimeTravel,\n * createTypedHooks, shallowEqual\n */\n\nimport {\n\tcomputed,\n\tonScopeDispose,\n\tref,\n\tshallowRef,\n\ttype ComputedRef,\n\ttype Ref,\n\ttype ShallowRef,\n} from \"vue\";\nimport type {\n\tModuleSchema,\n\tModuleDef,\n\tPlugin,\n\tDebugConfig,\n\tErrorBoundaryConfig,\n\tInferFacts,\n\tInferDerivations,\n\tInferSelectorState,\n\tInferEvents,\n\tSingleModuleSystem,\n\tSystemSnapshot,\n} from \"@directive-run/core\";\nimport {\n\tcreateSystem,\n\tcreateRequirementStatusPlugin,\n} from \"@directive-run/core\";\nimport type { RequirementTypeStatus } from \"@directive-run/core\";\nimport {\n\ttype InspectState,\n\ttype ConstraintInfo,\n\tcomputeInspectState,\n\tcreateThrottle,\n\tassertSystem,\n\tdefaultEquality,\n\tbuildTimeTravelState,\n\tpickFacts,\n\trunTrackedSelector,\n\tdepsChanged,\n\tshallowEqual,\n} from \"@directive-run/core/adapter-utils\";\n\n// Re-export for convenience\nexport type { RequirementTypeStatus, InspectState, ConstraintInfo };\nexport { shallowEqual };\n\n/** Type for the requirement status plugin return value */\nexport type StatusPlugin = ReturnType<typeof createRequirementStatusPlugin>;\n\n// ============================================================================\n// useFact — single key or multi key\n// ============================================================================\n\n/** Single key overload */\nexport function useFact<S extends ModuleSchema, K extends keyof InferFacts<S> & string>(system: SingleModuleSystem<S>, factKey: K): Ref<InferFacts<S>[K] | undefined>;\n/** Multi-key overload */\nexport function useFact<S extends ModuleSchema, K extends keyof InferFacts<S> & string>(system: SingleModuleSystem<S>, factKeys: K[]): ShallowRef<Pick<InferFacts<S>, K>>;\n/** Implementation */\nexport function useFact(\n\t// biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n\tsystem: SingleModuleSystem<any>,\n\tkeyOrKeys: string | string[],\n): Ref<unknown> | ShallowRef<unknown> {\n\tassertSystem(\"useFact\", system);\n\tif (process.env.NODE_ENV !== \"production\" && typeof keyOrKeys === \"function\") {\n\t\tconsole.error(\n\t\t\t\"[Directive] useFact() received a function. Did you mean useSelector()? \" +\n\t\t\t\t\"useFact() takes a string key or array of keys, not a selector function.\",\n\t\t);\n\t}\n\n\t// Multi-key path: useFact(system, [keys])\n\tif (Array.isArray(keyOrKeys)) {\n\t\treturn _useFactMulti(system, keyOrKeys);\n\t}\n\n\t// Single key path: useFact(system, key)\n\treturn _useFactSingle(system, keyOrKeys);\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useFactSingle(system: SingleModuleSystem<any>, factKey: string): Ref<unknown> {\n\tif (process.env.NODE_ENV !== \"production\") {\n\t\tif (!system.facts.$store.has(factKey)) {\n\t\t\tconsole.warn(\n\t\t\t\t`[Directive] useFact(\"${factKey}\") — fact not found in store. ` +\n\t\t\t\t`Check that \"${factKey}\" is defined in your module's schema.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tconst value = ref(system.facts.$store.get(factKey));\n\tconst unsubscribe = system.facts.$store.subscribe([factKey], () => {\n\t\tvalue.value = system.facts.$store.get(factKey);\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn value;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useFactMulti(system: SingleModuleSystem<any>, factKeys: string[]): ShallowRef<Record<string, unknown>> {\n\tconst getValues = (): Record<string, unknown> => {\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const key of factKeys) {\n\t\t\tresult[key] = system.facts.$store.get(key);\n\t\t}\n\t\treturn result;\n\t};\n\tconst state = shallowRef(getValues());\n\tconst unsubscribe = system.facts.$store.subscribe(factKeys, () => {\n\t\tstate.value = getValues();\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn state;\n}\n\n// ============================================================================\n// useDerived — single key or multi key\n// ============================================================================\n\n/** Single key overload */\nexport function useDerived<S extends ModuleSchema, K extends keyof InferDerivations<S> & string>(system: SingleModuleSystem<S>, derivationId: K): Ref<InferDerivations<S>[K]>;\n/** Multi-key overload */\nexport function useDerived<S extends ModuleSchema, K extends keyof InferDerivations<S> & string>(system: SingleModuleSystem<S>, derivationIds: K[]): ShallowRef<Pick<InferDerivations<S>, K>>;\n/** Implementation */\nexport function useDerived(\n\t// biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n\tsystem: SingleModuleSystem<any>,\n\tidOrIds: string | string[],\n): Ref<unknown> | ShallowRef<unknown> {\n\tassertSystem(\"useDerived\", system);\n\tif (process.env.NODE_ENV !== \"production\" && typeof idOrIds === \"function\") {\n\t\tconsole.error(\n\t\t\t\"[Directive] useDerived() received a function. Did you mean useSelector()? \" +\n\t\t\t\t\"useDerived() takes a string key or array of keys, not a selector function.\",\n\t\t);\n\t}\n\n\t// Multi-key path\n\tif (Array.isArray(idOrIds)) {\n\t\treturn _useDerivedMulti(system, idOrIds);\n\t}\n\n\t// Single key path\n\treturn _useDerivedSingle(system, idOrIds);\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useDerivedSingle(system: SingleModuleSystem<any>, derivationId: string): Ref<unknown> {\n\tif (process.env.NODE_ENV !== \"production\") {\n\t\tconst initialValue = system.read(derivationId);\n\t\tif (initialValue === undefined) {\n\t\t\tconsole.warn(\n\t\t\t\t`[Directive] useDerived(\"${derivationId}\") returned undefined. ` +\n\t\t\t\t`Check that \"${derivationId}\" is defined in your module's derive property.`,\n\t\t\t);\n\t\t}\n\t}\n\tconst value = ref(system.read(derivationId));\n\tconst unsubscribe = system.subscribe([derivationId], () => {\n\t\tvalue.value = system.read(derivationId);\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn value;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useDerivedMulti(system: SingleModuleSystem<any>, derivationIds: string[]): ShallowRef<Record<string, unknown>> {\n\tconst getValues = (): Record<string, unknown> => {\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const id of derivationIds) {\n\t\t\tresult[id] = system.read(id);\n\t\t}\n\t\treturn result;\n\t};\n\tconst state = shallowRef(getValues());\n\tconst unsubscribe = system.subscribe(derivationIds, () => {\n\t\tstate.value = getValues();\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn state;\n}\n\n// ============================================================================\n// useSelector — auto-tracking selector over facts and derivations\n// ============================================================================\n\n/**\n * Auto-tracking selector over facts and derivations.\n * Uses `withTracking()` to detect which facts the selector accesses,\n * then subscribes only to those keys.\n */\nexport function useSelector<S extends ModuleSchema, R>(system: SingleModuleSystem<S>, selector: (state: InferSelectorState<S>) => R, equalityFn?: (a: R, b: R) => boolean): Ref<R>;\nexport function useSelector(\n\t// biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n\tsystem: SingleModuleSystem<any>,\n\tselector: (state: Record<string, unknown>) => unknown,\n\tequalityFn: (a: unknown, b: unknown) => boolean = defaultEquality,\n): Ref<unknown> {\n\tassertSystem(\"useSelector\", system);\n\tconst deriveKeySet = new Set(Object.keys(system.derive ?? {}));\n\n\tconst runWithTracking = () => runTrackedSelector(system, deriveKeySet, selector);\n\n\tconst initial = runWithTracking();\n\tlet trackedFactKeys = initial.factKeys;\n\tlet trackedDeriveKeys = initial.deriveKeys;\n\tconst selected = ref(initial.value);\n\n\tconst unsubs: Array<() => void> = [];\n\n\tconst resubscribe = () => {\n\t\tfor (const unsub of unsubs) unsub();\n\t\tunsubs.length = 0;\n\n\t\tconst onUpdate = () => {\n\t\t\tconst result = runWithTracking();\n\t\t\tif (!equalityFn(selected.value, result.value)) {\n\t\t\t\tselected.value = result.value;\n\t\t\t}\n\t\t\t// Re-track: check if deps changed\n\t\t\tif (depsChanged(trackedFactKeys, result.factKeys, trackedDeriveKeys, result.deriveKeys)) {\n\t\t\t\ttrackedFactKeys = result.factKeys;\n\t\t\t\ttrackedDeriveKeys = result.deriveKeys;\n\t\t\t\tresubscribe();\n\t\t\t}\n\t\t};\n\n\t\tif (trackedFactKeys.length > 0) {\n\t\t\tunsubs.push(system.facts.$store.subscribe(trackedFactKeys, onUpdate));\n\t\t} else if (trackedDeriveKeys.length === 0) {\n\t\t\tunsubs.push(system.facts.$store.subscribeAll(onUpdate));\n\t\t}\n\t\tif (trackedDeriveKeys.length > 0) {\n\t\t\tunsubs.push(system.subscribe(trackedDeriveKeys, onUpdate));\n\t\t}\n\t};\n\n\tresubscribe();\n\n\tonScopeDispose(() => {\n\t\tfor (const unsub of unsubs) unsub();\n\t});\n\n\treturn selected;\n}\n\n// ============================================================================\n// useDispatch\n// ============================================================================\n\nexport function useDispatch<S extends ModuleSchema>(\n\tsystem: SingleModuleSystem<S>,\n): (event: InferEvents<S>) => void {\n\tassertSystem(\"useDispatch\", system);\n\treturn (event: InferEvents<S>) => {\n\t\tsystem.dispatch(event);\n\t};\n}\n\n// ============================================================================\n// useEvents — memoized events reference\n// ============================================================================\n\n/**\n * Returns the system's events dispatcher.\n */\nexport function useEvents<S extends ModuleSchema>(\n\tsystem: SingleModuleSystem<S>,\n): SingleModuleSystem<S>[\"events\"] {\n\tassertSystem(\"useEvents\", system);\n\treturn system.events;\n}\n\n// ============================================================================\n// useWatch — derivation or fact side-effect\n// ============================================================================\n\n/** Watch a derivation or fact by key (auto-detected). When a key exists in both facts and derivations, the derivation overload takes priority. */\nexport function useWatch<S extends ModuleSchema, K extends keyof InferDerivations<S> & string>(\n\tsystem: SingleModuleSystem<S>,\n\tkey: K,\n\tcallback: (newValue: InferDerivations<S>[K], previousValue: InferDerivations<S>[K] | undefined) => void,\n): void;\n/** Watch a fact key with auto-detection. */\nexport function useWatch<S extends ModuleSchema, K extends keyof InferFacts<S> & string>(\n\tsystem: SingleModuleSystem<S>,\n\tkey: K,\n\tcallback: (newValue: InferFacts<S>[K] | undefined, previousValue: InferFacts<S>[K] | undefined) => void,\n): void;\n/** Implementation */\nexport function useWatch(\n\t// biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n\tsystem: SingleModuleSystem<any>,\n\tkey: string,\n\tcallback: (newValue: unknown, prevValue: unknown) => void,\n): void {\n\tassertSystem(\"useWatch\", system);\n\n\tconst unsubscribe = system.watch(key, callback);\n\tonScopeDispose(unsubscribe);\n}\n\n// ============================================================================\n// useInspect — consolidated inspection hook\n// ============================================================================\n\n/** Options for useInspect */\nexport interface UseInspectOptions {\n\tthrottleMs?: number;\n}\n\n/**\n * Consolidated system inspection hook.\n * Returns InspectState with optional throttling.\n */\nexport function useInspect(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n\toptions?: UseInspectOptions,\n): ShallowRef<InspectState> {\n\tassertSystem(\"useInspect\", system);\n\tconst state = shallowRef<InspectState>(computeInspectState(system));\n\n\tconst update = () => {\n\t\tstate.value = computeInspectState(system);\n\t};\n\n\tif (options?.throttleMs && options.throttleMs > 0) {\n\t\tconst { throttled, cleanup } = createThrottle(update, options.throttleMs);\n\t\tconst unsubFacts = system.facts.$store.subscribeAll(throttled);\n\t\tconst unsubSettled = system.onSettledChange(throttled);\n\t\tonScopeDispose(() => {\n\t\t\tcleanup();\n\t\t\tunsubFacts();\n\t\t\tunsubSettled();\n\t\t});\n\t} else {\n\t\tconst unsubFacts = system.facts.$store.subscribeAll(update);\n\t\tconst unsubSettled = system.onSettledChange(update);\n\t\tonScopeDispose(() => {\n\t\t\tunsubFacts();\n\t\t\tunsubSettled();\n\t\t});\n\t}\n\n\treturn state;\n}\n\n// ============================================================================\n// useRequirementStatus — single or multi\n// ============================================================================\n\n/** Single type overload */\nexport function useRequirementStatus(statusPlugin: StatusPlugin, type: string): ShallowRef<RequirementTypeStatus>;\n/** Multi-type overload */\nexport function useRequirementStatus(statusPlugin: StatusPlugin, types: string[]): ShallowRef<Record<string, RequirementTypeStatus>>;\n/** Implementation */\nexport function useRequirementStatus(\n\tstatusPlugin: StatusPlugin,\n\ttypeOrTypes: string | string[],\n): ShallowRef<RequirementTypeStatus> | ShallowRef<Record<string, RequirementTypeStatus>> {\n\tif (Array.isArray(typeOrTypes)) {\n\t\tconst getValues = (): Record<string, RequirementTypeStatus> => {\n\t\t\tconst result: Record<string, RequirementTypeStatus> = {};\n\t\t\tfor (const type of typeOrTypes) {\n\t\t\t\tresult[type] = statusPlugin.getStatus(type);\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\t\tconst state = shallowRef(getValues());\n\t\tconst unsubscribe = statusPlugin.subscribe(() => {\n\t\t\tstate.value = getValues();\n\t\t});\n\t\tonScopeDispose(unsubscribe);\n\t\treturn state;\n\t}\n\n\tconst status = shallowRef<RequirementTypeStatus>(statusPlugin.getStatus(typeOrTypes));\n\tconst unsubscribe = statusPlugin.subscribe(() => {\n\t\tstatus.value = statusPlugin.getStatus(typeOrTypes);\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn status;\n}\n\n// ============================================================================\n// useExplain — reactive requirement explanation\n// ============================================================================\n\n/**\n * Reactively returns the explanation string for a requirement.\n */\nexport function useExplain(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n\trequirementId: string,\n): Ref<string | null> {\n\tassertSystem(\"useExplain\", system);\n\tconst explanation = ref<string | null>(system.explain(requirementId)) as Ref<string | null>;\n\n\tconst update = () => {\n\t\texplanation.value = system.explain(requirementId);\n\t};\n\n\tconst unsubFacts = system.facts.$store.subscribeAll(update);\n\tconst unsubSettled = system.onSettledChange(update);\n\tonScopeDispose(() => {\n\t\tunsubFacts();\n\t\tunsubSettled();\n\t});\n\n\treturn explanation;\n}\n\n// ============================================================================\n// useConstraintStatus — reactive constraint inspection\n// ============================================================================\n\n/** Get all constraints */\nexport function useConstraintStatus(\n\tsystem: SingleModuleSystem<any>,\n): ComputedRef<ConstraintInfo[]>;\n/** Get a single constraint by ID */\nexport function useConstraintStatus(\n\tsystem: SingleModuleSystem<any>,\n\tconstraintId: string,\n): ComputedRef<ConstraintInfo | null>;\n/** Implementation */\nexport function useConstraintStatus(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n\tconstraintId?: string,\n): ComputedRef<ConstraintInfo[] | ConstraintInfo | null> {\n\tassertSystem(\"useConstraintStatus\", system);\n\tconst inspectState = useInspect(system);\n\n\treturn computed(() => {\n\t\t// Track reactivity via inspectState, but use full inspect() for constraint list\n\t\tvoid inspectState.value;\n\t\tconst fullInspection = system.inspect();\n\t\tif (!constraintId) return fullInspection.constraints;\n\t\treturn fullInspection.constraints.find((c) => c.id === constraintId) ?? null;\n\t});\n}\n\n// ============================================================================\n// useOptimisticUpdate — batch with rollback on failure\n// ============================================================================\n\nexport interface OptimisticUpdateResult {\n\tmutate: (updateFn: () => void) => void;\n\tisPending: Ref<boolean>;\n\terror: Ref<Error | null>;\n\trollback: () => void;\n}\n\n/**\n * Optimistic update hook. Saves a snapshot before mutating, monitors\n * a requirement type via statusPlugin, and rolls back on failure.\n */\nexport function useOptimisticUpdate(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n\tstatusPlugin?: StatusPlugin,\n\trequirementType?: string,\n): OptimisticUpdateResult {\n\tassertSystem(\"useOptimisticUpdate\", system);\n\tconst isPending = ref(false);\n\tconst error = ref<Error | null>(null) as Ref<Error | null>;\n\tlet snapshot: SystemSnapshot | null = null;\n\tlet unsubscribe: (() => void) | null = null;\n\n\tconst rollback = () => {\n\t\tif (snapshot) {\n\t\t\tsystem.restore(snapshot);\n\t\t\tsnapshot = null;\n\t\t}\n\t\tisPending.value = false;\n\t\terror.value = null;\n\t\tunsubscribe?.();\n\t\tunsubscribe = null;\n\t};\n\n\tconst mutate = (updateFn: () => void) => {\n\t\tsnapshot = system.getSnapshot();\n\t\tisPending.value = true;\n\t\terror.value = null;\n\t\tsystem.batch(updateFn);\n\n\t\t// Watch for resolver completion/failure\n\t\tif (statusPlugin && requirementType) {\n\t\t\tunsubscribe?.();\n\t\t\tunsubscribe = statusPlugin.subscribe(() => {\n\t\t\t\tconst status = statusPlugin.getStatus(requirementType);\n\t\t\t\tif (!status.isLoading && !status.hasError) {\n\t\t\t\t\tsnapshot = null;\n\t\t\t\t\tisPending.value = false;\n\t\t\t\t\tunsubscribe?.();\n\t\t\t\t\tunsubscribe = null;\n\t\t\t\t} else if (status.hasError) {\n\t\t\t\t\terror.value = status.lastError;\n\t\t\t\t\trollback();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t};\n\n\tonScopeDispose(() => {\n\t\tunsubscribe?.();\n\t});\n\n\treturn { mutate, isPending, error, rollback };\n}\n\n// ============================================================================\n// useTimeTravel — reactive time-travel state\n// ============================================================================\n\n/**\n * Reactive time-travel composable. Returns a ShallowRef that updates\n * when snapshots are taken or navigation occurs.\n *\n * @example\n * ```vue\n * const tt = useTimeTravel(system);\n * <button :disabled=\"!tt.value?.canUndo\" @click=\"tt.value?.undo()\">Undo</button>\n * ```\n */\nexport function useTimeTravel(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n): ShallowRef<ReturnType<typeof buildTimeTravelState>> {\n\tassertSystem(\"useTimeTravel\", system);\n\tconst state = shallowRef<ReturnType<typeof buildTimeTravelState>>(buildTimeTravelState(system));\n\tconst unsub = system.onTimeTravelChange(() => {\n\t\tstate.value = buildTimeTravelState(system);\n\t});\n\tonScopeDispose(unsub);\n\treturn state;\n}\n\n// ============================================================================\n// Scoped System Composable\n// ============================================================================\n\n/** Configuration for useDirective */\ninterface UseDirectiveConfig {\n\t// biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n\tplugins?: Plugin<any>[];\n\tdebug?: DebugConfig;\n\terrorBoundary?: ErrorBoundaryConfig;\n\ttickMs?: number;\n\tzeroConfig?: boolean;\n\t// biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n\tinitialFacts?: Record<string, any>;\n\tstatus?: boolean;\n\t/** Fact keys to subscribe to (omit for all) */\n\tfacts?: string[];\n\t/** Derivation keys to subscribe to (omit for all) */\n\tderived?: string[];\n}\n\n/**\n * Create a scoped Directive system with automatic lifecycle management.\n * When no `facts` or `derived` keys are specified, subscribes to ALL\n * facts and derivations and returns reactive state.\n *\n * @example\n * ```vue\n * // Subscribe to everything\n * const { facts, derived, events, dispatch } = useDirective(counterModule);\n *\n * // Selective keys\n * const { facts, derived } = useDirective(counterModule, { facts: [\"count\"], derived: [\"doubled\"] });\n * ```\n */\nexport function useDirective<M extends ModuleSchema>(\n\tmoduleDef: ModuleDef<M>,\n\tconfig?: UseDirectiveConfig,\n) {\n\tconst allPlugins = [...(config?.plugins ?? [])];\n\tlet statusPlugin: StatusPlugin | undefined;\n\n\tif (config?.status) {\n\t\tconst sp = createRequirementStatusPlugin();\n\t\tstatusPlugin = sp;\n\t\t// biome-ignore lint/suspicious/noExplicitAny: Plugin generic issues\n\t\tallPlugins.push(sp.plugin as Plugin<any>);\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: Required for overload compatibility\n\tconst system = createSystem({\n\t\tmodule: moduleDef,\n\t\tplugins: allPlugins.length > 0 ? allPlugins : undefined,\n\t\tdebug: config?.debug,\n\t\terrorBoundary: config?.errorBoundary,\n\t\ttickMs: config?.tickMs,\n\t\tzeroConfig: config?.zeroConfig,\n\t\tinitialFacts: config?.initialFacts,\n\t} as any) as unknown as SingleModuleSystem<M>;\n\n\tsystem.start();\n\n\tonScopeDispose(() => {\n\t\tsystem.destroy();\n\t});\n\n\tconst factKeys = config?.facts;\n\tconst derivedKeys = config?.derived;\n\tconst subscribeAll = !factKeys && !derivedKeys;\n\n\t// Subscribe to facts\n\tconst factsState = shallowRef(\n\t\tsubscribeAll\n\t\t\t? (system.facts.$store.toObject() as InferFacts<M>)\n\t\t\t: pickFacts(system, factKeys ?? []),\n\t);\n\tconst unsubFacts = subscribeAll\n\t\t? system.facts.$store.subscribeAll(() => {\n\t\t\tfactsState.value = system.facts.$store.toObject() as InferFacts<M>;\n\t\t})\n\t\t: factKeys && factKeys.length > 0\n\t\t\t? system.facts.$store.subscribe(factKeys, () => {\n\t\t\t\tfactsState.value = pickFacts(system, factKeys) as InferFacts<M>;\n\t\t\t})\n\t\t\t: null;\n\n\t// Subscribe to derivations\n\tconst allDerivationKeys = subscribeAll ? Object.keys(system.derive ?? {}) : (derivedKeys ?? []);\n\tconst getDerived = (): InferDerivations<M> => {\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const key of allDerivationKeys) {\n\t\t\tresult[key] = system.read(key);\n\t\t}\n\t\treturn result as InferDerivations<M>;\n\t};\n\tconst derivedState = shallowRef(getDerived());\n\tconst unsubDerived = allDerivationKeys.length > 0\n\t\t? system.subscribe(allDerivationKeys, () => { derivedState.value = getDerived(); })\n\t\t: null;\n\n\tonScopeDispose(() => {\n\t\tunsubFacts?.();\n\t\tunsubDerived?.();\n\t});\n\n\tconst events = system.events;\n\tconst dispatch = (event: InferEvents<M>) => system.dispatch(event);\n\n\treturn {\n\t\tsystem,\n\t\tfacts: factsState as ShallowRef<InferFacts<M>>,\n\t\tderived: derivedState as ShallowRef<InferDerivations<M>>,\n\t\tevents,\n\t\tdispatch,\n\t\tstatusPlugin,\n\t};\n}\n\n// ============================================================================\n// Typed Hooks Factory\n// ============================================================================\n\nexport function createTypedHooks<M extends ModuleSchema>(): {\n\tuseFact: <K extends keyof InferFacts<M> & string>(\n\t\tsystem: SingleModuleSystem<M>,\n\t\tfactKey: K,\n\t) => Ref<InferFacts<M>[K] | undefined>;\n\tuseDerived: <K extends keyof InferDerivations<M> & string>(\n\t\tsystem: SingleModuleSystem<M>,\n\t\tderivationId: K,\n\t) => Ref<InferDerivations<M>[K]>;\n\tuseDispatch: (system: SingleModuleSystem<M>) => (event: InferEvents<M>) => void;\n\tuseEvents: (system: SingleModuleSystem<M>) => SingleModuleSystem<M>[\"events\"];\n\tuseWatch: <K extends string>(\n\t\tsystem: SingleModuleSystem<M>,\n\t\tkey: K,\n\t\tcallback: (newValue: unknown, previousValue: unknown) => void,\n\t) => void;\n} {\n\treturn {\n\t\tuseFact: <K extends keyof InferFacts<M> & string>(system: SingleModuleSystem<M>, factKey: K) =>\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n\t\t\tuseFact(system as SingleModuleSystem<any>, factKey) as Ref<InferFacts<M>[K] | undefined>,\n\t\tuseDerived: <K extends keyof InferDerivations<M> & string>(system: SingleModuleSystem<M>, derivationId: K) =>\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n\t\t\tuseDerived(system as SingleModuleSystem<any>, derivationId) as Ref<InferDerivations<M>[K]>,\n\t\tuseDispatch: (system: SingleModuleSystem<M>) => {\n\t\t\treturn (event: InferEvents<M>) => {\n\t\t\t\tsystem.dispatch(event);\n\t\t\t};\n\t\t},\n\t\tuseEvents: (system: SingleModuleSystem<M>) => useEvents<M>(system),\n\t\tuseWatch: <K extends string>(\n\t\t\tsystem: SingleModuleSystem<M>,\n\t\t\tkey: K,\n\t\t\tcallback: (newValue: unknown, previousValue: unknown) => void,\n\t\t) =>\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n\t\t\tuseWatch(system as SingleModuleSystem<any>, key, callback),\n\t};\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -29,7 +29,6 @@ declare function useDerived<S extends ModuleSchema, K extends keyof InferDerivat
|
|
|
29
29
|
* then subscribes only to those keys.
|
|
30
30
|
*/
|
|
31
31
|
declare function useSelector<S extends ModuleSchema, R>(system: SingleModuleSystem<S>, selector: (state: InferSelectorState<S>) => R, equalityFn?: (a: R, b: R) => boolean): Ref<R>;
|
|
32
|
-
declare function useSelector<R>(system: SingleModuleSystem<any>, selector: (state: Record<string, any>) => R, equalityFn?: (a: R, b: R) => boolean): Ref<R>;
|
|
33
32
|
declare function useDispatch<S extends ModuleSchema>(system: SingleModuleSystem<S>): (event: InferEvents<S>) => void;
|
|
34
33
|
/**
|
|
35
34
|
* Returns the system's events dispatcher.
|
|
@@ -39,13 +38,6 @@ declare function useEvents<S extends ModuleSchema>(system: SingleModuleSystem<S>
|
|
|
39
38
|
declare function useWatch<S extends ModuleSchema, K extends keyof InferDerivations<S> & string>(system: SingleModuleSystem<S>, key: K, callback: (newValue: InferDerivations<S>[K], previousValue: InferDerivations<S>[K] | undefined) => void): void;
|
|
40
39
|
/** Watch a fact key with auto-detection. */
|
|
41
40
|
declare function useWatch<S extends ModuleSchema, K extends keyof InferFacts<S> & string>(system: SingleModuleSystem<S>, key: K, callback: (newValue: InferFacts<S>[K] | undefined, previousValue: InferFacts<S>[K] | undefined) => void): void;
|
|
42
|
-
/**
|
|
43
|
-
* Watch a fact by explicit "fact" discriminator.
|
|
44
|
-
* @deprecated Use `useWatch(system, key, callback)` instead — facts are now auto-detected.
|
|
45
|
-
*/
|
|
46
|
-
declare function useWatch<S extends ModuleSchema, K extends keyof InferFacts<S> & string>(system: SingleModuleSystem<S>, kind: "fact", factKey: K, callback: (newValue: InferFacts<S>[K] | undefined, previousValue: InferFacts<S>[K] | undefined) => void): void;
|
|
47
|
-
/** Watch a fact or derivation (generic fallback) */
|
|
48
|
-
declare function useWatch<T>(system: SingleModuleSystem<any>, key: string, callback: (newValue: T, previousValue: T | undefined) => void): void;
|
|
49
41
|
/** Options for useInspect */
|
|
50
42
|
interface UseInspectOptions {
|
|
51
43
|
throttleMs?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -29,7 +29,6 @@ declare function useDerived<S extends ModuleSchema, K extends keyof InferDerivat
|
|
|
29
29
|
* then subscribes only to those keys.
|
|
30
30
|
*/
|
|
31
31
|
declare function useSelector<S extends ModuleSchema, R>(system: SingleModuleSystem<S>, selector: (state: InferSelectorState<S>) => R, equalityFn?: (a: R, b: R) => boolean): Ref<R>;
|
|
32
|
-
declare function useSelector<R>(system: SingleModuleSystem<any>, selector: (state: Record<string, any>) => R, equalityFn?: (a: R, b: R) => boolean): Ref<R>;
|
|
33
32
|
declare function useDispatch<S extends ModuleSchema>(system: SingleModuleSystem<S>): (event: InferEvents<S>) => void;
|
|
34
33
|
/**
|
|
35
34
|
* Returns the system's events dispatcher.
|
|
@@ -39,13 +38,6 @@ declare function useEvents<S extends ModuleSchema>(system: SingleModuleSystem<S>
|
|
|
39
38
|
declare function useWatch<S extends ModuleSchema, K extends keyof InferDerivations<S> & string>(system: SingleModuleSystem<S>, key: K, callback: (newValue: InferDerivations<S>[K], previousValue: InferDerivations<S>[K] | undefined) => void): void;
|
|
40
39
|
/** Watch a fact key with auto-detection. */
|
|
41
40
|
declare function useWatch<S extends ModuleSchema, K extends keyof InferFacts<S> & string>(system: SingleModuleSystem<S>, key: K, callback: (newValue: InferFacts<S>[K] | undefined, previousValue: InferFacts<S>[K] | undefined) => void): void;
|
|
42
|
-
/**
|
|
43
|
-
* Watch a fact by explicit "fact" discriminator.
|
|
44
|
-
* @deprecated Use `useWatch(system, key, callback)` instead — facts are now auto-detected.
|
|
45
|
-
*/
|
|
46
|
-
declare function useWatch<S extends ModuleSchema, K extends keyof InferFacts<S> & string>(system: SingleModuleSystem<S>, kind: "fact", factKey: K, callback: (newValue: InferFacts<S>[K] | undefined, previousValue: InferFacts<S>[K] | undefined) => void): void;
|
|
47
|
-
/** Watch a fact or derivation (generic fallback) */
|
|
48
|
-
declare function useWatch<T>(system: SingleModuleSystem<any>, key: string, callback: (newValue: T, previousValue: T | undefined) => void): void;
|
|
49
41
|
/** Options for useInspect */
|
|
50
42
|
interface UseInspectOptions {
|
|
51
43
|
throttleMs?: number;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {ref,onScopeDispose,shallowRef,computed}from'vue';import {createRequirementStatusPlugin,createSystem}from'@directive-run/core';import {defaultEquality,assertSystem,computeInspectState,createThrottle,buildTimeTravelState,pickFacts,runTrackedSelector,depsChanged}from'@directive-run/core/adapter-utils';export{shallowEqual}from'@directive-run/core/adapter-utils';function
|
|
1
|
+
import {ref,onScopeDispose,shallowRef,computed}from'vue';import {createRequirementStatusPlugin,createSystem}from'@directive-run/core';import {defaultEquality,assertSystem,computeInspectState,createThrottle,buildTimeTravelState,pickFacts,runTrackedSelector,depsChanged}from'@directive-run/core/adapter-utils';export{shallowEqual}from'@directive-run/core/adapter-utils';function E(e,t){return assertSystem("useFact",e),process.env.NODE_ENV!=="production"&&typeof t=="function"&&console.error("[Directive] useFact() received a function. Did you mean useSelector()? useFact() takes a string key or array of keys, not a selector function."),Array.isArray(t)?V(e,t):T(e,t)}function T(e,t){process.env.NODE_ENV!=="production"&&(e.facts.$store.has(t)||console.warn(`[Directive] useFact("${t}") \u2014 fact not found in store. Check that "${t}" is defined in your module's schema.`));let s=ref(e.facts.$store.get(t)),o=e.facts.$store.subscribe([t],()=>{s.value=e.facts.$store.get(t);});return onScopeDispose(o),s}function V(e,t){let s=()=>{let r={};for(let u of t)r[u]=e.facts.$store.get(u);return r},o=shallowRef(s()),n=e.facts.$store.subscribe(t,()=>{o.value=s();});return onScopeDispose(n),o}function $(e,t){return assertSystem("useDerived",e),process.env.NODE_ENV!=="production"&&typeof t=="function"&&console.error("[Directive] useDerived() received a function. Did you mean useSelector()? useDerived() takes a string key or array of keys, not a selector function."),Array.isArray(t)?A(e,t):q(e,t)}function q(e,t){process.env.NODE_ENV!=="production"&&e.read(t)===void 0&&console.warn(`[Directive] useDerived("${t}") returned undefined. Check that "${t}" is defined in your module's derive property.`);let s=ref(e.read(t)),o=e.subscribe([t],()=>{s.value=e.read(t);});return onScopeDispose(o),s}function A(e,t){let s=()=>{let r={};for(let u of t)r[u]=e.read(u);return r},o=shallowRef(s()),n=e.subscribe(t,()=>{o.value=s();});return onScopeDispose(n),o}function z(e,t,s=defaultEquality){assertSystem("useSelector",e);let o=new Set(Object.keys(e.derive??{})),n=()=>runTrackedSelector(e,o,t),r=n(),u=r.factKeys,i=r.deriveKeys,l=ref(r.value),S=[],c=()=>{for(let d of S)d();S.length=0;let g=()=>{let d=n();s(l.value,d.value)||(l.value=d.value),depsChanged(u,d.factKeys,i,d.deriveKeys)&&(u=d.factKeys,i=d.deriveKeys,c());};u.length>0?S.push(e.facts.$store.subscribe(u,g)):i.length===0&&S.push(e.facts.$store.subscribeAll(g)),i.length>0&&S.push(e.subscribe(i,g));};return c(),onScopeDispose(()=>{for(let g of S)g();}),l}function H(e){return assertSystem("useDispatch",e),t=>{e.dispatch(t);}}function P(e){return assertSystem("useEvents",e),e.events}function U(e,t,s){assertSystem("useWatch",e);let o=e.watch(t,s);onScopeDispose(o);}function N(e,t){assertSystem("useInspect",e);let s=shallowRef(computeInspectState(e)),o=()=>{s.value=computeInspectState(e);};if(t?.throttleMs&&t.throttleMs>0){let{throttled:n,cleanup:r}=createThrottle(o,t.throttleMs),u=e.facts.$store.subscribeAll(n),i=e.onSettledChange(n);onScopeDispose(()=>{r(),u(),i();});}else {let n=e.facts.$store.subscribeAll(o),r=e.onSettledChange(o);onScopeDispose(()=>{n(),r();});}return s}function L(e,t){if(Array.isArray(t)){let n=()=>{let i={};for(let l of t)i[l]=e.getStatus(l);return i},r=shallowRef(n()),u=e.subscribe(()=>{r.value=n();});return onScopeDispose(u),r}let s=shallowRef(e.getStatus(t)),o=e.subscribe(()=>{s.value=e.getStatus(t);});return onScopeDispose(o),s}function G(e,t){assertSystem("useExplain",e);let s=ref(e.explain(t)),o=()=>{s.value=e.explain(t);},n=e.facts.$store.subscribeAll(o),r=e.onSettledChange(o);return onScopeDispose(()=>{n(),r();}),s}function J(e,t){assertSystem("useConstraintStatus",e);let s=N(e);return computed(()=>{s.value;let o=e.inspect();return t?o.constraints.find(n=>n.id===t)??null:o.constraints})}function Q(e,t,s){assertSystem("useOptimisticUpdate",e);let o=ref(false),n=ref(null),r=null,u=null,i=()=>{r&&(e.restore(r),r=null),o.value=false,n.value=null,u?.(),u=null;},l=S=>{r=e.getSnapshot(),o.value=true,n.value=null,e.batch(S),t&&s&&(u?.(),u=t.subscribe(()=>{let c=t.getStatus(s);!c.isLoading&&!c.hasError?(r=null,o.value=false,u?.(),u=null):c.hasError&&(n.value=c.lastError,i());}));};return onScopeDispose(()=>{u?.();}),{mutate:l,isPending:o,error:n,rollback:i}}function X(e){assertSystem("useTimeTravel",e);let t=shallowRef(buildTimeTravelState(e)),s=e.onTimeTravelChange(()=>{t.value=buildTimeTravelState(e);});return onScopeDispose(s),t}function Y(e,t){let s=[...t?.plugins??[]],o;if(t?.status){let v=createRequirementStatusPlugin();o=v,s.push(v.plugin);}let n=createSystem({module:e,plugins:s.length>0?s:void 0,debug:t?.debug,errorBoundary:t?.errorBoundary,tickMs:t?.tickMs,zeroConfig:t?.zeroConfig,initialFacts:t?.initialFacts});n.start(),onScopeDispose(()=>{n.destroy();});let r=t?.facts,u=t?.derived,i=!r&&!u,l=shallowRef(i?n.facts.$store.toObject():pickFacts(n,r??[])),S=i?n.facts.$store.subscribeAll(()=>{l.value=n.facts.$store.toObject();}):r&&r.length>0?n.facts.$store.subscribe(r,()=>{l.value=pickFacts(n,r);}):null,c=i?Object.keys(n.derive??{}):u??[],g=()=>{let v={};for(let M of c)v[M]=n.read(M);return v},d=shallowRef(g()),R=c.length>0?n.subscribe(c,()=>{d.value=g();}):null;onScopeDispose(()=>{S?.(),R?.();});let k=n.events;return {system:n,facts:l,derived:d,events:k,dispatch:v=>n.dispatch(v),statusPlugin:o}}function Z(){return {useFact:(e,t)=>E(e,t),useDerived:(e,t)=>$(e,t),useDispatch:e=>t=>{e.dispatch(t);},useEvents:e=>P(e),useWatch:(e,t,s)=>U(e,t,s)}}export{Z as createTypedHooks,J as useConstraintStatus,$ as useDerived,Y as useDirective,H as useDispatch,P as useEvents,G as useExplain,E as useFact,N as useInspect,Q as useOptimisticUpdate,L as useRequirementStatus,z as useSelector,X as useTimeTravel,U as useWatch};//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["useFact","system","keyOrKeys","assertSystem","_useFactMulti","_useFactSingle","factKey","value","ref","unsubscribe","onScopeDispose","factKeys","getValues","result","key","state","shallowRef","useDerived","idOrIds","_useDerivedMulti","_useDerivedSingle","derivationId","derivationIds","id","useSelector","selector","equalityFn","defaultEquality","deriveKeySet","runWithTracking","runTrackedSelector","initial","trackedFactKeys","trackedDeriveKeys","selected","unsubs","resubscribe","unsub","onUpdate","depsChanged","useDispatch","event","useEvents","useWatch","derivationIdOrKind","callbackOrFactKey","maybeCallback","isFact","callback","useInspect","options","computeInspectState","update","throttled","cleanup","createThrottle","unsubFacts","unsubSettled","useRequirementStatus","statusPlugin","typeOrTypes","type","status","useExplain","requirementId","explanation","useConstraintStatus","constraintId","inspectState","computed","fullInspection","c","useOptimisticUpdate","requirementType","isPending","error","snapshot","rollback","mutate","updateFn","useTimeTravel","buildTimeTravelState","useDirective","moduleDef","config","allPlugins","sp","createRequirementStatusPlugin","createSystem","derivedKeys","subscribeAll","factsState","pickFacts","allDerivationKeys","getDerived","derivedState","unsubDerived","events","createTypedHooks"],"mappings":"gXAkEO,SAASA,CAAAA,CAEfC,CAAAA,CACAC,CAAAA,CACqC,CAUrC,OATAC,YAAAA,CAAa,UAAWF,CAAM,CAAA,CAC1B,OAAA,CAAQ,GAAA,CAAI,WAAa,YAAA,EAAgB,OAAOC,CAAAA,EAAc,UAAA,EACjE,QAAQ,KAAA,CACP,gJAED,CAAA,CAIG,KAAA,CAAM,OAAA,CAAQA,CAAS,CAAA,CACnBE,CAAAA,CAAcH,EAAQC,CAAS,CAAA,CAIhCG,CAAAA,CAAeJ,CAAAA,CAAQC,CAAS,CACxC,CAGA,SAASG,CAAAA,CAAeJ,EAAiCK,CAAAA,CAA+B,CACnF,OAAA,CAAQ,GAAA,CAAI,QAAA,GAAa,YAAA,GACvBL,CAAAA,CAAO,KAAA,CAAM,OAAO,GA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AED,IAAMC,CAAAA,CAAShG,CAAAA,CAAO,MAAA,CAGtB,OAAO,CACN,MAAA,CAAAA,CAAAA,CACA,KAAA,CAAO0F,CAAAA,CACP,QAASI,CAAAA,CACT,MAAA,CAAAE,CAAAA,CACA,QAAA,CAPiBxD,CAAAA,EAA0BxC,CAAAA,CAAO,QAAA,CAASwC,CAAK,EAQhE,YAAA,CAAAkB,CACD,CACD,CAMO,SAASuC,CAAAA,EAgBd,CACD,OAAO,CACN,QAAS,CAAyCjG,CAAAA,CAA+BK,CAAAA,GAEhFN,CAAAA,CAAQC,CAAAA,CAAmCK,CAAO,CAAA,CACnD,UAAA,CAAY,CAA+CL,CAAAA,CAA+BoB,CAAAA,GAEzFJ,CAAAA,CAAWhB,CAAAA,CAAmCoB,CAAY,CAAA,CAC3D,WAAA,CAAcpB,CAAAA,EACLwC,CAAAA,EAA0B,CACjCxC,CAAAA,CAAO,QAAA,CAASwC,CAAK,EACtB,EAED,SAAA,CAAYxC,CAAAA,EAAkCyC,CAAAA,CAAazC,CAAM,EACjE,QAAA,CAAU,CACTA,CAAAA,CACAa,CAAAA,CACAkC,IAGAL,CAAAA,CAAS1C,CAAAA,CAAmCa,CAAAA,CAAKkC,CAAQ,CAC3D,CACD","file":"index.js","sourcesContent":["/**\n * Vue Adapter - Vue 3 composables for Directive\n *\n * Exports: useFact, useDerived, useDispatch, useSelector,\n * useWatch, useInspect, useRequirementStatus, useEvents, useExplain,\n * useConstraintStatus, useOptimisticUpdate, useDirective, useTimeTravel,\n * createTypedHooks, shallowEqual\n */\n\nimport {\n\tcomputed,\n\tonScopeDispose,\n\tref,\n\tshallowRef,\n\ttype ComputedRef,\n\ttype Ref,\n\ttype ShallowRef,\n} from \"vue\";\nimport type {\n\tModuleSchema,\n\tModuleDef,\n\tPlugin,\n\tDebugConfig,\n\tErrorBoundaryConfig,\n\tInferFacts,\n\tInferDerivations,\n\tInferSelectorState,\n\tInferEvents,\n\tSingleModuleSystem,\n\tSystemSnapshot,\n} from \"@directive-run/core\";\nimport {\n\tcreateSystem,\n\tcreateRequirementStatusPlugin,\n} from \"@directive-run/core\";\nimport type { RequirementTypeStatus } from \"@directive-run/core\";\nimport {\n\ttype InspectState,\n\ttype ConstraintInfo,\n\tcomputeInspectState,\n\tcreateThrottle,\n\tassertSystem,\n\tdefaultEquality,\n\tbuildTimeTravelState,\n\tpickFacts,\n\trunTrackedSelector,\n\tdepsChanged,\n\tshallowEqual,\n} from \"@directive-run/core/adapter-utils\";\n\n// Re-export for convenience\nexport type { RequirementTypeStatus, InspectState, ConstraintInfo };\nexport { shallowEqual };\n\n/** Type for the requirement status plugin return value */\nexport type StatusPlugin = ReturnType<typeof createRequirementStatusPlugin>;\n\n// ============================================================================\n// useFact — single key or multi key\n// ============================================================================\n\n/** Single key overload */\nexport function useFact<S extends ModuleSchema, K extends keyof InferFacts<S> & string>(system: SingleModuleSystem<S>, factKey: K): Ref<InferFacts<S>[K] | undefined>;\n/** Multi-key overload */\nexport function useFact<S extends ModuleSchema, K extends keyof InferFacts<S> & string>(system: SingleModuleSystem<S>, factKeys: K[]): ShallowRef<Pick<InferFacts<S>, K>>;\n/** Implementation */\nexport function useFact(\n\t// biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n\tsystem: SingleModuleSystem<any>,\n\tkeyOrKeys: string | string[],\n): Ref<unknown> | ShallowRef<unknown> {\n\tassertSystem(\"useFact\", system);\n\tif (process.env.NODE_ENV !== \"production\" && typeof keyOrKeys === \"function\") {\n\t\tconsole.error(\n\t\t\t\"[Directive] useFact() received a function. Did you mean useSelector()? \" +\n\t\t\t\t\"useFact() takes a string key or array of keys, not a selector function.\",\n\t\t);\n\t}\n\n\t// Multi-key path: useFact(system, [keys])\n\tif (Array.isArray(keyOrKeys)) {\n\t\treturn _useFactMulti(system, keyOrKeys);\n\t}\n\n\t// Single key path: useFact(system, key)\n\treturn _useFactSingle(system, keyOrKeys);\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useFactSingle(system: SingleModuleSystem<any>, factKey: string): Ref<unknown> {\n\tif (process.env.NODE_ENV !== \"production\") {\n\t\tif (!system.facts.$store.has(factKey)) {\n\t\t\tconsole.warn(\n\t\t\t\t`[Directive] useFact(\"${factKey}\") — fact not found in store. ` +\n\t\t\t\t`Check that \"${factKey}\" is defined in your module's schema.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tconst value = ref(system.facts.$store.get(factKey));\n\tconst unsubscribe = system.facts.$store.subscribe([factKey], () => {\n\t\tvalue.value = system.facts.$store.get(factKey);\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn value;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useFactMulti(system: SingleModuleSystem<any>, factKeys: string[]): ShallowRef<Record<string, unknown>> {\n\tconst getValues = (): Record<string, unknown> => {\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const key of factKeys) {\n\t\t\tresult[key] = system.facts.$store.get(key);\n\t\t}\n\t\treturn result;\n\t};\n\tconst state = shallowRef(getValues());\n\tconst unsubscribe = system.facts.$store.subscribe(factKeys, () => {\n\t\tstate.value = getValues();\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn state;\n}\n\n// ============================================================================\n// useDerived — single key or multi key\n// ============================================================================\n\n/** Single key overload */\nexport function useDerived<S extends ModuleSchema, K extends keyof InferDerivations<S> & string>(system: SingleModuleSystem<S>, derivationId: K): Ref<InferDerivations<S>[K]>;\n/** Multi-key overload */\nexport function useDerived<S extends ModuleSchema, K extends keyof InferDerivations<S> & string>(system: SingleModuleSystem<S>, derivationIds: K[]): ShallowRef<Pick<InferDerivations<S>, K>>;\n/** Implementation */\nexport function useDerived(\n\t// biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n\tsystem: SingleModuleSystem<any>,\n\tidOrIds: string | string[],\n): Ref<unknown> | ShallowRef<unknown> {\n\tassertSystem(\"useDerived\", system);\n\tif (process.env.NODE_ENV !== \"production\" && typeof idOrIds === \"function\") {\n\t\tconsole.error(\n\t\t\t\"[Directive] useDerived() received a function. Did you mean useSelector()? \" +\n\t\t\t\t\"useDerived() takes a string key or array of keys, not a selector function.\",\n\t\t);\n\t}\n\n\t// Multi-key path\n\tif (Array.isArray(idOrIds)) {\n\t\treturn _useDerivedMulti(system, idOrIds);\n\t}\n\n\t// Single key path\n\treturn _useDerivedSingle(system, idOrIds);\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useDerivedSingle(system: SingleModuleSystem<any>, derivationId: string): Ref<unknown> {\n\tif (process.env.NODE_ENV !== \"production\") {\n\t\tconst initialValue = system.read(derivationId);\n\t\tif (initialValue === undefined) {\n\t\t\tconsole.warn(\n\t\t\t\t`[Directive] useDerived(\"${derivationId}\") returned undefined. ` +\n\t\t\t\t`Check that \"${derivationId}\" is defined in your module's derive property.`,\n\t\t\t);\n\t\t}\n\t}\n\tconst value = ref(system.read(derivationId));\n\tconst unsubscribe = system.subscribe([derivationId], () => {\n\t\tvalue.value = system.read(derivationId);\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn value;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useDerivedMulti(system: SingleModuleSystem<any>, derivationIds: string[]): ShallowRef<Record<string, unknown>> {\n\tconst getValues = (): Record<string, unknown> => {\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const id of derivationIds) {\n\t\t\tresult[id] = system.read(id);\n\t\t}\n\t\treturn result;\n\t};\n\tconst state = shallowRef(getValues());\n\tconst unsubscribe = system.subscribe(derivationIds, () => {\n\t\tstate.value = getValues();\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn state;\n}\n\n// ============================================================================\n// useSelector — auto-tracking selector over facts and derivations\n// ============================================================================\n\n/**\n * Auto-tracking selector over facts and derivations.\n * Uses `withTracking()` to detect which facts the selector accesses,\n * then subscribes only to those keys.\n */\nexport function useSelector<S extends ModuleSchema, R>(system: SingleModuleSystem<S>, selector: (state: InferSelectorState<S>) => R, equalityFn?: (a: R, b: R) => boolean): Ref<R>;\nexport function useSelector<R>(\n\t// biome-ignore lint/suspicious/noExplicitAny: Backward-compatible fallback\n\tsystem: SingleModuleSystem<any>,\n\t// biome-ignore lint/suspicious/noExplicitAny: Selector receives dynamic state\n\tselector: (state: Record<string, any>) => R,\n\tequalityFn?: (a: R, b: R) => boolean,\n): Ref<R>;\nexport function useSelector(\n\t// biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n\tsystem: SingleModuleSystem<any>,\n\tselector: (state: Record<string, unknown>) => unknown,\n\tequalityFn: (a: unknown, b: unknown) => boolean = defaultEquality,\n): Ref<unknown> {\n\tassertSystem(\"useSelector\", system);\n\tconst deriveKeySet = new Set(Object.keys(system.derive ?? {}));\n\n\tconst runWithTracking = () => runTrackedSelector(system, deriveKeySet, selector);\n\n\tconst initial = runWithTracking();\n\tlet trackedFactKeys = initial.factKeys;\n\tlet trackedDeriveKeys = initial.deriveKeys;\n\tconst selected = ref(initial.value);\n\n\tconst unsubs: Array<() => void> = [];\n\n\tconst resubscribe = () => {\n\t\tfor (const unsub of unsubs) unsub();\n\t\tunsubs.length = 0;\n\n\t\tconst onUpdate = () => {\n\t\t\tconst result = runWithTracking();\n\t\t\tif (!equalityFn(selected.value, result.value)) {\n\t\t\t\tselected.value = result.value;\n\t\t\t}\n\t\t\t// Re-track: check if deps changed\n\t\t\tif (depsChanged(trackedFactKeys, result.factKeys, trackedDeriveKeys, result.deriveKeys)) {\n\t\t\t\ttrackedFactKeys = result.factKeys;\n\t\t\t\ttrackedDeriveKeys = result.deriveKeys;\n\t\t\t\tresubscribe();\n\t\t\t}\n\t\t};\n\n\t\tif (trackedFactKeys.length > 0) {\n\t\t\tunsubs.push(system.facts.$store.subscribe(trackedFactKeys, onUpdate));\n\t\t} else if (trackedDeriveKeys.length === 0) {\n\t\t\tunsubs.push(system.facts.$store.subscribeAll(onUpdate));\n\t\t}\n\t\tif (trackedDeriveKeys.length > 0) {\n\t\t\tunsubs.push(system.subscribe(trackedDeriveKeys, onUpdate));\n\t\t}\n\t};\n\n\tresubscribe();\n\n\tonScopeDispose(() => {\n\t\tfor (const unsub of unsubs) unsub();\n\t});\n\n\treturn selected;\n}\n\n// ============================================================================\n// useDispatch\n// ============================================================================\n\nexport function useDispatch<S extends ModuleSchema>(\n\tsystem: SingleModuleSystem<S>,\n): (event: InferEvents<S>) => void {\n\tassertSystem(\"useDispatch\", system);\n\treturn (event: InferEvents<S>) => {\n\t\tsystem.dispatch(event);\n\t};\n}\n\n// ============================================================================\n// useEvents — memoized events reference\n// ============================================================================\n\n/**\n * Returns the system's events dispatcher.\n */\nexport function useEvents<S extends ModuleSchema>(\n\tsystem: SingleModuleSystem<S>,\n): SingleModuleSystem<S>[\"events\"] {\n\tassertSystem(\"useEvents\", system);\n\treturn system.events;\n}\n\n// ============================================================================\n// useWatch — derivation or fact side-effect\n// ============================================================================\n\n/** Watch a derivation or fact by key (auto-detected). When a key exists in both facts and derivations, the derivation overload takes priority. */\nexport function useWatch<S extends ModuleSchema, K extends keyof InferDerivations<S> & string>(\n\tsystem: SingleModuleSystem<S>,\n\tkey: K,\n\tcallback: (newValue: InferDerivations<S>[K], previousValue: InferDerivations<S>[K] | undefined) => void,\n): void;\n/** Watch a fact key with auto-detection. */\nexport function useWatch<S extends ModuleSchema, K extends keyof InferFacts<S> & string>(\n\tsystem: SingleModuleSystem<S>,\n\tkey: K,\n\tcallback: (newValue: InferFacts<S>[K] | undefined, previousValue: InferFacts<S>[K] | undefined) => void,\n): void;\n/**\n * Watch a fact by explicit \"fact\" discriminator.\n * @deprecated Use `useWatch(system, key, callback)` instead — facts are now auto-detected.\n */\nexport function useWatch<S extends ModuleSchema, K extends keyof InferFacts<S> & string>(\n\tsystem: SingleModuleSystem<S>,\n\tkind: \"fact\",\n\tfactKey: K,\n\tcallback: (newValue: InferFacts<S>[K] | undefined, previousValue: InferFacts<S>[K] | undefined) => void,\n): void;\n/** Watch a fact or derivation (generic fallback) */\nexport function useWatch<T>(\n\t// biome-ignore lint/suspicious/noExplicitAny: Backward-compatible fallback\n\tsystem: SingleModuleSystem<any>,\n\tkey: string,\n\tcallback: (newValue: T, previousValue: T | undefined) => void,\n): void;\n/** Implementation */\nexport function useWatch(\n\t// biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n\tsystem: SingleModuleSystem<any>,\n\tderivationIdOrKind: string,\n\tcallbackOrFactKey: string | ((newValue: unknown, prevValue: unknown) => void),\n\tmaybeCallback?: (newValue: unknown, prevValue: unknown) => void,\n): void {\n\tassertSystem(\"useWatch\", system);\n\t// Backward compat: useWatch(system, \"fact\", factKey, callback)\n\tconst isFact =\n\t\tderivationIdOrKind === \"fact\" &&\n\t\ttypeof callbackOrFactKey === \"string\" &&\n\t\ttypeof maybeCallback === \"function\";\n\n\tconst key = isFact ? (callbackOrFactKey as string) : derivationIdOrKind;\n\tconst callback = isFact\n\t\t? maybeCallback!\n\t\t: (callbackOrFactKey as (newValue: unknown, prevValue: unknown) => void);\n\n\tconst unsubscribe = system.watch(key, callback);\n\tonScopeDispose(unsubscribe);\n}\n\n// ============================================================================\n// useInspect — consolidated inspection hook\n// ============================================================================\n\n/** Options for useInspect */\nexport interface UseInspectOptions {\n\tthrottleMs?: number;\n}\n\n/**\n * Consolidated system inspection hook.\n * Returns InspectState with optional throttling.\n */\nexport function useInspect(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n\toptions?: UseInspectOptions,\n): ShallowRef<InspectState> {\n\tassertSystem(\"useInspect\", system);\n\tconst state = shallowRef<InspectState>(computeInspectState(system));\n\n\tconst update = () => {\n\t\tstate.value = computeInspectState(system);\n\t};\n\n\tif (options?.throttleMs && options.throttleMs > 0) {\n\t\tconst { throttled, cleanup } = createThrottle(update, options.throttleMs);\n\t\tconst unsubFacts = system.facts.$store.subscribeAll(throttled);\n\t\tconst unsubSettled = system.onSettledChange(throttled);\n\t\tonScopeDispose(() => {\n\t\t\tcleanup();\n\t\t\tunsubFacts();\n\t\t\tunsubSettled();\n\t\t});\n\t} else {\n\t\tconst unsubFacts = system.facts.$store.subscribeAll(update);\n\t\tconst unsubSettled = system.onSettledChange(update);\n\t\tonScopeDispose(() => {\n\t\t\tunsubFacts();\n\t\t\tunsubSettled();\n\t\t});\n\t}\n\n\treturn state;\n}\n\n// ============================================================================\n// useRequirementStatus — single or multi\n// ============================================================================\n\n/** Single type overload */\nexport function useRequirementStatus(statusPlugin: StatusPlugin, type: string): ShallowRef<RequirementTypeStatus>;\n/** Multi-type overload */\nexport function useRequirementStatus(statusPlugin: StatusPlugin, types: string[]): ShallowRef<Record<string, RequirementTypeStatus>>;\n/** Implementation */\nexport function useRequirementStatus(\n\tstatusPlugin: StatusPlugin,\n\ttypeOrTypes: string | string[],\n): ShallowRef<RequirementTypeStatus> | ShallowRef<Record<string, RequirementTypeStatus>> {\n\tif (Array.isArray(typeOrTypes)) {\n\t\tconst getValues = (): Record<string, RequirementTypeStatus> => {\n\t\t\tconst result: Record<string, RequirementTypeStatus> = {};\n\t\t\tfor (const type of typeOrTypes) {\n\t\t\t\tresult[type] = statusPlugin.getStatus(type);\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\t\tconst state = shallowRef(getValues());\n\t\tconst unsubscribe = statusPlugin.subscribe(() => {\n\t\t\tstate.value = getValues();\n\t\t});\n\t\tonScopeDispose(unsubscribe);\n\t\treturn state;\n\t}\n\n\tconst status = shallowRef<RequirementTypeStatus>(statusPlugin.getStatus(typeOrTypes));\n\tconst unsubscribe = statusPlugin.subscribe(() => {\n\t\tstatus.value = statusPlugin.getStatus(typeOrTypes);\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn status;\n}\n\n// ============================================================================\n// useExplain — reactive requirement explanation\n// ============================================================================\n\n/**\n * Reactively returns the explanation string for a requirement.\n */\nexport function useExplain(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n\trequirementId: string,\n): Ref<string | null> {\n\tassertSystem(\"useExplain\", system);\n\tconst explanation = ref<string | null>(system.explain(requirementId)) as Ref<string | null>;\n\n\tconst update = () => {\n\t\texplanation.value = system.explain(requirementId);\n\t};\n\n\tconst unsubFacts = system.facts.$store.subscribeAll(update);\n\tconst unsubSettled = system.onSettledChange(update);\n\tonScopeDispose(() => {\n\t\tunsubFacts();\n\t\tunsubSettled();\n\t});\n\n\treturn explanation;\n}\n\n// ============================================================================\n// useConstraintStatus — reactive constraint inspection\n// ============================================================================\n\n/** Get all constraints */\nexport function useConstraintStatus(\n\tsystem: SingleModuleSystem<any>,\n): ComputedRef<ConstraintInfo[]>;\n/** Get a single constraint by ID */\nexport function useConstraintStatus(\n\tsystem: SingleModuleSystem<any>,\n\tconstraintId: string,\n): ComputedRef<ConstraintInfo | null>;\n/** Implementation */\nexport function useConstraintStatus(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n\tconstraintId?: string,\n): ComputedRef<ConstraintInfo[] | ConstraintInfo | null> {\n\tassertSystem(\"useConstraintStatus\", system);\n\tconst inspectState = useInspect(system);\n\n\treturn computed(() => {\n\t\t// Track reactivity via inspectState, but use full inspect() for constraint list\n\t\tvoid inspectState.value;\n\t\tconst fullInspection = system.inspect();\n\t\tif (!constraintId) return fullInspection.constraints;\n\t\treturn fullInspection.constraints.find((c) => c.id === constraintId) ?? null;\n\t});\n}\n\n// ============================================================================\n// useOptimisticUpdate — batch with rollback on failure\n// ============================================================================\n\nexport interface OptimisticUpdateResult {\n\tmutate: (updateFn: () => void) => void;\n\tisPending: Ref<boolean>;\n\terror: Ref<Error | null>;\n\trollback: () => void;\n}\n\n/**\n * Optimistic update hook. Saves a snapshot before mutating, monitors\n * a requirement type via statusPlugin, and rolls back on failure.\n */\nexport function useOptimisticUpdate(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n\tstatusPlugin?: StatusPlugin,\n\trequirementType?: string,\n): OptimisticUpdateResult {\n\tassertSystem(\"useOptimisticUpdate\", system);\n\tconst isPending = ref(false);\n\tconst error = ref<Error | null>(null) as Ref<Error | null>;\n\tlet snapshot: SystemSnapshot | null = null;\n\tlet unsubscribe: (() => void) | null = null;\n\n\tconst rollback = () => {\n\t\tif (snapshot) {\n\t\t\tsystem.restore(snapshot);\n\t\t\tsnapshot = null;\n\t\t}\n\t\tisPending.value = false;\n\t\terror.value = null;\n\t\tunsubscribe?.();\n\t\tunsubscribe = null;\n\t};\n\n\tconst mutate = (updateFn: () => void) => {\n\t\tsnapshot = system.getSnapshot();\n\t\tisPending.value = true;\n\t\terror.value = null;\n\t\tsystem.batch(updateFn);\n\n\t\t// Watch for resolver completion/failure\n\t\tif (statusPlugin && requirementType) {\n\t\t\tunsubscribe?.();\n\t\t\tunsubscribe = statusPlugin.subscribe(() => {\n\t\t\t\tconst status = statusPlugin.getStatus(requirementType);\n\t\t\t\tif (!status.isLoading && !status.hasError) {\n\t\t\t\t\tsnapshot = null;\n\t\t\t\t\tisPending.value = false;\n\t\t\t\t\tunsubscribe?.();\n\t\t\t\t\tunsubscribe = null;\n\t\t\t\t} else if (status.hasError) {\n\t\t\t\t\terror.value = status.lastError;\n\t\t\t\t\trollback();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t};\n\n\tonScopeDispose(() => {\n\t\tunsubscribe?.();\n\t});\n\n\treturn { mutate, isPending, error, rollback };\n}\n\n// ============================================================================\n// useTimeTravel — reactive time-travel state\n// ============================================================================\n\n/**\n * Reactive time-travel composable. Returns a ShallowRef that updates\n * when snapshots are taken or navigation occurs.\n *\n * @example\n * ```vue\n * const tt = useTimeTravel(system);\n * <button :disabled=\"!tt.value?.canUndo\" @click=\"tt.value?.undo()\">Undo</button>\n * ```\n */\nexport function useTimeTravel(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n): ShallowRef<ReturnType<typeof buildTimeTravelState>> {\n\tassertSystem(\"useTimeTravel\", system);\n\tconst state = shallowRef<ReturnType<typeof buildTimeTravelState>>(buildTimeTravelState(system));\n\tconst unsub = system.onTimeTravelChange(() => {\n\t\tstate.value = buildTimeTravelState(system);\n\t});\n\tonScopeDispose(unsub);\n\treturn state;\n}\n\n// ============================================================================\n// Scoped System Composable\n// ============================================================================\n\n/** Configuration for useDirective */\ninterface UseDirectiveConfig {\n\t// biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n\tplugins?: Plugin<any>[];\n\tdebug?: DebugConfig;\n\terrorBoundary?: ErrorBoundaryConfig;\n\ttickMs?: number;\n\tzeroConfig?: boolean;\n\t// biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n\tinitialFacts?: Record<string, any>;\n\tstatus?: boolean;\n\t/** Fact keys to subscribe to (omit for all) */\n\tfacts?: string[];\n\t/** Derivation keys to subscribe to (omit for all) */\n\tderived?: string[];\n}\n\n/**\n * Create a scoped Directive system with automatic lifecycle management.\n * When no `facts` or `derived` keys are specified, subscribes to ALL\n * facts and derivations and returns reactive state.\n *\n * @example\n * ```vue\n * // Subscribe to everything\n * const { facts, derived, events, dispatch } = useDirective(counterModule);\n *\n * // Selective keys\n * const { facts, derived } = useDirective(counterModule, { facts: [\"count\"], derived: [\"doubled\"] });\n * ```\n */\nexport function useDirective<M extends ModuleSchema>(\n\tmoduleDef: ModuleDef<M>,\n\tconfig?: UseDirectiveConfig,\n) {\n\tconst allPlugins = [...(config?.plugins ?? [])];\n\tlet statusPlugin: StatusPlugin | undefined;\n\n\tif (config?.status) {\n\t\tconst sp = createRequirementStatusPlugin();\n\t\tstatusPlugin = sp;\n\t\t// biome-ignore lint/suspicious/noExplicitAny: Plugin generic issues\n\t\tallPlugins.push(sp.plugin as Plugin<any>);\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: Required for overload compatibility\n\tconst system = createSystem({\n\t\tmodule: moduleDef,\n\t\tplugins: allPlugins.length > 0 ? allPlugins : undefined,\n\t\tdebug: config?.debug,\n\t\terrorBoundary: config?.errorBoundary,\n\t\ttickMs: config?.tickMs,\n\t\tzeroConfig: config?.zeroConfig,\n\t\tinitialFacts: config?.initialFacts,\n\t} as any) as unknown as SingleModuleSystem<M>;\n\n\tsystem.start();\n\n\tonScopeDispose(() => {\n\t\tsystem.destroy();\n\t});\n\n\tconst factKeys = config?.facts;\n\tconst derivedKeys = config?.derived;\n\tconst subscribeAll = !factKeys && !derivedKeys;\n\n\t// Subscribe to facts\n\tconst factsState = shallowRef(\n\t\tsubscribeAll\n\t\t\t? (system.facts.$store.toObject() as InferFacts<M>)\n\t\t\t: pickFacts(system, factKeys ?? []),\n\t);\n\tconst unsubFacts = subscribeAll\n\t\t? system.facts.$store.subscribeAll(() => {\n\t\t\tfactsState.value = system.facts.$store.toObject() as InferFacts<M>;\n\t\t})\n\t\t: factKeys && factKeys.length > 0\n\t\t\t? system.facts.$store.subscribe(factKeys, () => {\n\t\t\t\tfactsState.value = pickFacts(system, factKeys) as InferFacts<M>;\n\t\t\t})\n\t\t\t: null;\n\n\t// Subscribe to derivations\n\tconst allDerivationKeys = subscribeAll ? Object.keys(system.derive ?? {}) : (derivedKeys ?? []);\n\tconst getDerived = (): InferDerivations<M> => {\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const key of allDerivationKeys) {\n\t\t\tresult[key] = system.read(key);\n\t\t}\n\t\treturn result as InferDerivations<M>;\n\t};\n\tconst derivedState = shallowRef(getDerived());\n\tconst unsubDerived = allDerivationKeys.length > 0\n\t\t? system.subscribe(allDerivationKeys, () => { derivedState.value = getDerived(); })\n\t\t: null;\n\n\tonScopeDispose(() => {\n\t\tunsubFacts?.();\n\t\tunsubDerived?.();\n\t});\n\n\tconst events = system.events;\n\tconst dispatch = (event: InferEvents<M>) => system.dispatch(event);\n\n\treturn {\n\t\tsystem,\n\t\tfacts: factsState as ShallowRef<InferFacts<M>>,\n\t\tderived: derivedState as ShallowRef<InferDerivations<M>>,\n\t\tevents,\n\t\tdispatch,\n\t\tstatusPlugin,\n\t};\n}\n\n// ============================================================================\n// Typed Hooks Factory\n// ============================================================================\n\nexport function createTypedHooks<M extends ModuleSchema>(): {\n\tuseFact: <K extends keyof InferFacts<M> & string>(\n\t\tsystem: SingleModuleSystem<M>,\n\t\tfactKey: K,\n\t) => Ref<InferFacts<M>[K] | undefined>;\n\tuseDerived: <K extends keyof InferDerivations<M> & string>(\n\t\tsystem: SingleModuleSystem<M>,\n\t\tderivationId: K,\n\t) => Ref<InferDerivations<M>[K]>;\n\tuseDispatch: (system: SingleModuleSystem<M>) => (event: InferEvents<M>) => void;\n\tuseEvents: (system: SingleModuleSystem<M>) => SingleModuleSystem<M>[\"events\"];\n\tuseWatch: <K extends string>(\n\t\tsystem: SingleModuleSystem<M>,\n\t\tkey: K,\n\t\tcallback: (newValue: unknown, previousValue: unknown) => void,\n\t) => void;\n} {\n\treturn {\n\t\tuseFact: <K extends keyof InferFacts<M> & string>(system: SingleModuleSystem<M>, factKey: K) =>\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n\t\t\tuseFact(system as SingleModuleSystem<any>, factKey) as Ref<InferFacts<M>[K] | undefined>,\n\t\tuseDerived: <K extends keyof InferDerivations<M> & string>(system: SingleModuleSystem<M>, derivationId: K) =>\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n\t\t\tuseDerived(system as SingleModuleSystem<any>, derivationId) as Ref<InferDerivations<M>[K]>,\n\t\tuseDispatch: (system: SingleModuleSystem<M>) => {\n\t\t\treturn (event: InferEvents<M>) => {\n\t\t\t\tsystem.dispatch(event);\n\t\t\t};\n\t\t},\n\t\tuseEvents: (system: SingleModuleSystem<M>) => useEvents<M>(system),\n\t\tuseWatch: <K extends string>(\n\t\t\tsystem: SingleModuleSystem<M>,\n\t\t\tkey: K,\n\t\t\tcallback: (newValue: unknown, previousValue: unknown) => void,\n\t\t) =>\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n\t\t\tuseWatch(system as SingleModuleSystem<any>, key, callback),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["useFact","system","keyOrKeys","assertSystem","_useFactMulti","_useFactSingle","factKey","value","ref","unsubscribe","onScopeDispose","factKeys","getValues","result","key","state","shallowRef","useDerived","idOrIds","_useDerivedMulti","_useDerivedSingle","derivationId","derivationIds","id","useSelector","selector","equalityFn","defaultEquality","deriveKeySet","runWithTracking","runTrackedSelector","initial","trackedFactKeys","trackedDeriveKeys","selected","unsubs","resubscribe","unsub","onUpdate","depsChanged","useDispatch","event","useEvents","useWatch","callback","useInspect","options","computeInspectState","update","throttled","cleanup","createThrottle","unsubFacts","unsubSettled","useRequirementStatus","statusPlugin","typeOrTypes","type","status","useExplain","requirementId","explanation","useConstraintStatus","constraintId","inspectState","computed","fullInspection","c","useOptimisticUpdate","requirementType","isPending","error","snapshot","rollback","mutate","updateFn","useTimeTravel","buildTimeTravelState","useDirective","moduleDef","config","allPlugins","sp","createRequirementStatusPlugin","createSystem","derivedKeys","subscribeAll","factsState","pickFacts","allDerivationKeys","getDerived","derivedState","unsubDerived","events","createTypedHooks"],"mappings":"gXAkEO,SAASA,CAAAA,CAEfC,CAAAA,CACAC,CAAAA,CACqC,CAUrC,OATAC,aAAa,SAAA,CAAWF,CAAM,CAAA,CAC1B,OAAA,CAAQ,IAAI,QAAA,GAAa,YAAA,EAAgB,OAAOC,CAAAA,EAAc,YACjE,OAAA,CAAQ,KAAA,CACP,gJAED,CAAA,CAIG,KAAA,CAAM,OAAA,CAAQA,CAAS,CAAA,CACnBE,EAAcH,CAAAA,CAAQC,CAAS,CAAA,CAIhCG,CAAAA,CAAeJ,EAAQC,CAAS,CACxC,CAGA,SAASG,EAAeJ,CAAAA,CAAiCK,CAAAA,CAA+B,CACnF,OAAA,CAAQ,GAAA,CAAI,QAAA,GAAa,YAAA,GACvBL,CAAAA,CAAO,MAAM,MAAA,CAAO,GAAA,CAAIK,CAAO,CAAA,EACnC,OAAA,CAAQ,IA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ACA,QAAA,CAPiBpD,CAAAA,EAA0BxC,CAAAA,CAAO,QAAA,CAASwC,CAAK,CAAA,CAQhE,aAAAc,CACD,CACD,CAMO,SAASuC,GAgBd,CACD,OAAO,CACN,OAAA,CAAS,CAAyC7F,CAAAA,CAA+BK,CAAAA,GAEhFN,CAAAA,CAAQC,CAAAA,CAAmCK,CAAO,CAAA,CACnD,UAAA,CAAY,CAA+CL,EAA+BoB,CAAAA,GAEzFJ,CAAAA,CAAWhB,CAAAA,CAAmCoB,CAAY,EAC3D,WAAA,CAAcpB,CAAAA,EACLwC,CAAAA,EAA0B,CACjCxC,EAAO,QAAA,CAASwC,CAAK,EACtB,CAAA,CAED,SAAA,CAAYxC,CAAAA,EAAkCyC,CAAAA,CAAazC,CAAM,EACjE,QAAA,CAAU,CACTA,CAAAA,CACAa,CAAAA,CACA8B,IAGAD,CAAAA,CAAS1C,CAAAA,CAAmCa,CAAAA,CAAK8B,CAAQ,CAC3D,CACD","file":"index.js","sourcesContent":["/**\n * Vue Adapter - Vue 3 composables for Directive\n *\n * Exports: useFact, useDerived, useDispatch, useSelector,\n * useWatch, useInspect, useRequirementStatus, useEvents, useExplain,\n * useConstraintStatus, useOptimisticUpdate, useDirective, useTimeTravel,\n * createTypedHooks, shallowEqual\n */\n\nimport {\n\tcomputed,\n\tonScopeDispose,\n\tref,\n\tshallowRef,\n\ttype ComputedRef,\n\ttype Ref,\n\ttype ShallowRef,\n} from \"vue\";\nimport type {\n\tModuleSchema,\n\tModuleDef,\n\tPlugin,\n\tDebugConfig,\n\tErrorBoundaryConfig,\n\tInferFacts,\n\tInferDerivations,\n\tInferSelectorState,\n\tInferEvents,\n\tSingleModuleSystem,\n\tSystemSnapshot,\n} from \"@directive-run/core\";\nimport {\n\tcreateSystem,\n\tcreateRequirementStatusPlugin,\n} from \"@directive-run/core\";\nimport type { RequirementTypeStatus } from \"@directive-run/core\";\nimport {\n\ttype InspectState,\n\ttype ConstraintInfo,\n\tcomputeInspectState,\n\tcreateThrottle,\n\tassertSystem,\n\tdefaultEquality,\n\tbuildTimeTravelState,\n\tpickFacts,\n\trunTrackedSelector,\n\tdepsChanged,\n\tshallowEqual,\n} from \"@directive-run/core/adapter-utils\";\n\n// Re-export for convenience\nexport type { RequirementTypeStatus, InspectState, ConstraintInfo };\nexport { shallowEqual };\n\n/** Type for the requirement status plugin return value */\nexport type StatusPlugin = ReturnType<typeof createRequirementStatusPlugin>;\n\n// ============================================================================\n// useFact — single key or multi key\n// ============================================================================\n\n/** Single key overload */\nexport function useFact<S extends ModuleSchema, K extends keyof InferFacts<S> & string>(system: SingleModuleSystem<S>, factKey: K): Ref<InferFacts<S>[K] | undefined>;\n/** Multi-key overload */\nexport function useFact<S extends ModuleSchema, K extends keyof InferFacts<S> & string>(system: SingleModuleSystem<S>, factKeys: K[]): ShallowRef<Pick<InferFacts<S>, K>>;\n/** Implementation */\nexport function useFact(\n\t// biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n\tsystem: SingleModuleSystem<any>,\n\tkeyOrKeys: string | string[],\n): Ref<unknown> | ShallowRef<unknown> {\n\tassertSystem(\"useFact\", system);\n\tif (process.env.NODE_ENV !== \"production\" && typeof keyOrKeys === \"function\") {\n\t\tconsole.error(\n\t\t\t\"[Directive] useFact() received a function. Did you mean useSelector()? \" +\n\t\t\t\t\"useFact() takes a string key or array of keys, not a selector function.\",\n\t\t);\n\t}\n\n\t// Multi-key path: useFact(system, [keys])\n\tif (Array.isArray(keyOrKeys)) {\n\t\treturn _useFactMulti(system, keyOrKeys);\n\t}\n\n\t// Single key path: useFact(system, key)\n\treturn _useFactSingle(system, keyOrKeys);\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useFactSingle(system: SingleModuleSystem<any>, factKey: string): Ref<unknown> {\n\tif (process.env.NODE_ENV !== \"production\") {\n\t\tif (!system.facts.$store.has(factKey)) {\n\t\t\tconsole.warn(\n\t\t\t\t`[Directive] useFact(\"${factKey}\") — fact not found in store. ` +\n\t\t\t\t`Check that \"${factKey}\" is defined in your module's schema.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tconst value = ref(system.facts.$store.get(factKey));\n\tconst unsubscribe = system.facts.$store.subscribe([factKey], () => {\n\t\tvalue.value = system.facts.$store.get(factKey);\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn value;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useFactMulti(system: SingleModuleSystem<any>, factKeys: string[]): ShallowRef<Record<string, unknown>> {\n\tconst getValues = (): Record<string, unknown> => {\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const key of factKeys) {\n\t\t\tresult[key] = system.facts.$store.get(key);\n\t\t}\n\t\treturn result;\n\t};\n\tconst state = shallowRef(getValues());\n\tconst unsubscribe = system.facts.$store.subscribe(factKeys, () => {\n\t\tstate.value = getValues();\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn state;\n}\n\n// ============================================================================\n// useDerived — single key or multi key\n// ============================================================================\n\n/** Single key overload */\nexport function useDerived<S extends ModuleSchema, K extends keyof InferDerivations<S> & string>(system: SingleModuleSystem<S>, derivationId: K): Ref<InferDerivations<S>[K]>;\n/** Multi-key overload */\nexport function useDerived<S extends ModuleSchema, K extends keyof InferDerivations<S> & string>(system: SingleModuleSystem<S>, derivationIds: K[]): ShallowRef<Pick<InferDerivations<S>, K>>;\n/** Implementation */\nexport function useDerived(\n\t// biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n\tsystem: SingleModuleSystem<any>,\n\tidOrIds: string | string[],\n): Ref<unknown> | ShallowRef<unknown> {\n\tassertSystem(\"useDerived\", system);\n\tif (process.env.NODE_ENV !== \"production\" && typeof idOrIds === \"function\") {\n\t\tconsole.error(\n\t\t\t\"[Directive] useDerived() received a function. Did you mean useSelector()? \" +\n\t\t\t\t\"useDerived() takes a string key or array of keys, not a selector function.\",\n\t\t);\n\t}\n\n\t// Multi-key path\n\tif (Array.isArray(idOrIds)) {\n\t\treturn _useDerivedMulti(system, idOrIds);\n\t}\n\n\t// Single key path\n\treturn _useDerivedSingle(system, idOrIds);\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useDerivedSingle(system: SingleModuleSystem<any>, derivationId: string): Ref<unknown> {\n\tif (process.env.NODE_ENV !== \"production\") {\n\t\tconst initialValue = system.read(derivationId);\n\t\tif (initialValue === undefined) {\n\t\t\tconsole.warn(\n\t\t\t\t`[Directive] useDerived(\"${derivationId}\") returned undefined. ` +\n\t\t\t\t`Check that \"${derivationId}\" is defined in your module's derive property.`,\n\t\t\t);\n\t\t}\n\t}\n\tconst value = ref(system.read(derivationId));\n\tconst unsubscribe = system.subscribe([derivationId], () => {\n\t\tvalue.value = system.read(derivationId);\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn value;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useDerivedMulti(system: SingleModuleSystem<any>, derivationIds: string[]): ShallowRef<Record<string, unknown>> {\n\tconst getValues = (): Record<string, unknown> => {\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const id of derivationIds) {\n\t\t\tresult[id] = system.read(id);\n\t\t}\n\t\treturn result;\n\t};\n\tconst state = shallowRef(getValues());\n\tconst unsubscribe = system.subscribe(derivationIds, () => {\n\t\tstate.value = getValues();\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn state;\n}\n\n// ============================================================================\n// useSelector — auto-tracking selector over facts and derivations\n// ============================================================================\n\n/**\n * Auto-tracking selector over facts and derivations.\n * Uses `withTracking()` to detect which facts the selector accesses,\n * then subscribes only to those keys.\n */\nexport function useSelector<S extends ModuleSchema, R>(system: SingleModuleSystem<S>, selector: (state: InferSelectorState<S>) => R, equalityFn?: (a: R, b: R) => boolean): Ref<R>;\nexport function useSelector(\n\t// biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n\tsystem: SingleModuleSystem<any>,\n\tselector: (state: Record<string, unknown>) => unknown,\n\tequalityFn: (a: unknown, b: unknown) => boolean = defaultEquality,\n): Ref<unknown> {\n\tassertSystem(\"useSelector\", system);\n\tconst deriveKeySet = new Set(Object.keys(system.derive ?? {}));\n\n\tconst runWithTracking = () => runTrackedSelector(system, deriveKeySet, selector);\n\n\tconst initial = runWithTracking();\n\tlet trackedFactKeys = initial.factKeys;\n\tlet trackedDeriveKeys = initial.deriveKeys;\n\tconst selected = ref(initial.value);\n\n\tconst unsubs: Array<() => void> = [];\n\n\tconst resubscribe = () => {\n\t\tfor (const unsub of unsubs) unsub();\n\t\tunsubs.length = 0;\n\n\t\tconst onUpdate = () => {\n\t\t\tconst result = runWithTracking();\n\t\t\tif (!equalityFn(selected.value, result.value)) {\n\t\t\t\tselected.value = result.value;\n\t\t\t}\n\t\t\t// Re-track: check if deps changed\n\t\t\tif (depsChanged(trackedFactKeys, result.factKeys, trackedDeriveKeys, result.deriveKeys)) {\n\t\t\t\ttrackedFactKeys = result.factKeys;\n\t\t\t\ttrackedDeriveKeys = result.deriveKeys;\n\t\t\t\tresubscribe();\n\t\t\t}\n\t\t};\n\n\t\tif (trackedFactKeys.length > 0) {\n\t\t\tunsubs.push(system.facts.$store.subscribe(trackedFactKeys, onUpdate));\n\t\t} else if (trackedDeriveKeys.length === 0) {\n\t\t\tunsubs.push(system.facts.$store.subscribeAll(onUpdate));\n\t\t}\n\t\tif (trackedDeriveKeys.length > 0) {\n\t\t\tunsubs.push(system.subscribe(trackedDeriveKeys, onUpdate));\n\t\t}\n\t};\n\n\tresubscribe();\n\n\tonScopeDispose(() => {\n\t\tfor (const unsub of unsubs) unsub();\n\t});\n\n\treturn selected;\n}\n\n// ============================================================================\n// useDispatch\n// ============================================================================\n\nexport function useDispatch<S extends ModuleSchema>(\n\tsystem: SingleModuleSystem<S>,\n): (event: InferEvents<S>) => void {\n\tassertSystem(\"useDispatch\", system);\n\treturn (event: InferEvents<S>) => {\n\t\tsystem.dispatch(event);\n\t};\n}\n\n// ============================================================================\n// useEvents — memoized events reference\n// ============================================================================\n\n/**\n * Returns the system's events dispatcher.\n */\nexport function useEvents<S extends ModuleSchema>(\n\tsystem: SingleModuleSystem<S>,\n): SingleModuleSystem<S>[\"events\"] {\n\tassertSystem(\"useEvents\", system);\n\treturn system.events;\n}\n\n// ============================================================================\n// useWatch — derivation or fact side-effect\n// ============================================================================\n\n/** Watch a derivation or fact by key (auto-detected). When a key exists in both facts and derivations, the derivation overload takes priority. */\nexport function useWatch<S extends ModuleSchema, K extends keyof InferDerivations<S> & string>(\n\tsystem: SingleModuleSystem<S>,\n\tkey: K,\n\tcallback: (newValue: InferDerivations<S>[K], previousValue: InferDerivations<S>[K] | undefined) => void,\n): void;\n/** Watch a fact key with auto-detection. */\nexport function useWatch<S extends ModuleSchema, K extends keyof InferFacts<S> & string>(\n\tsystem: SingleModuleSystem<S>,\n\tkey: K,\n\tcallback: (newValue: InferFacts<S>[K] | undefined, previousValue: InferFacts<S>[K] | undefined) => void,\n): void;\n/** Implementation */\nexport function useWatch(\n\t// biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n\tsystem: SingleModuleSystem<any>,\n\tkey: string,\n\tcallback: (newValue: unknown, prevValue: unknown) => void,\n): void {\n\tassertSystem(\"useWatch\", system);\n\n\tconst unsubscribe = system.watch(key, callback);\n\tonScopeDispose(unsubscribe);\n}\n\n// ============================================================================\n// useInspect — consolidated inspection hook\n// ============================================================================\n\n/** Options for useInspect */\nexport interface UseInspectOptions {\n\tthrottleMs?: number;\n}\n\n/**\n * Consolidated system inspection hook.\n * Returns InspectState with optional throttling.\n */\nexport function useInspect(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n\toptions?: UseInspectOptions,\n): ShallowRef<InspectState> {\n\tassertSystem(\"useInspect\", system);\n\tconst state = shallowRef<InspectState>(computeInspectState(system));\n\n\tconst update = () => {\n\t\tstate.value = computeInspectState(system);\n\t};\n\n\tif (options?.throttleMs && options.throttleMs > 0) {\n\t\tconst { throttled, cleanup } = createThrottle(update, options.throttleMs);\n\t\tconst unsubFacts = system.facts.$store.subscribeAll(throttled);\n\t\tconst unsubSettled = system.onSettledChange(throttled);\n\t\tonScopeDispose(() => {\n\t\t\tcleanup();\n\t\t\tunsubFacts();\n\t\t\tunsubSettled();\n\t\t});\n\t} else {\n\t\tconst unsubFacts = system.facts.$store.subscribeAll(update);\n\t\tconst unsubSettled = system.onSettledChange(update);\n\t\tonScopeDispose(() => {\n\t\t\tunsubFacts();\n\t\t\tunsubSettled();\n\t\t});\n\t}\n\n\treturn state;\n}\n\n// ============================================================================\n// useRequirementStatus — single or multi\n// ============================================================================\n\n/** Single type overload */\nexport function useRequirementStatus(statusPlugin: StatusPlugin, type: string): ShallowRef<RequirementTypeStatus>;\n/** Multi-type overload */\nexport function useRequirementStatus(statusPlugin: StatusPlugin, types: string[]): ShallowRef<Record<string, RequirementTypeStatus>>;\n/** Implementation */\nexport function useRequirementStatus(\n\tstatusPlugin: StatusPlugin,\n\ttypeOrTypes: string | string[],\n): ShallowRef<RequirementTypeStatus> | ShallowRef<Record<string, RequirementTypeStatus>> {\n\tif (Array.isArray(typeOrTypes)) {\n\t\tconst getValues = (): Record<string, RequirementTypeStatus> => {\n\t\t\tconst result: Record<string, RequirementTypeStatus> = {};\n\t\t\tfor (const type of typeOrTypes) {\n\t\t\t\tresult[type] = statusPlugin.getStatus(type);\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\t\tconst state = shallowRef(getValues());\n\t\tconst unsubscribe = statusPlugin.subscribe(() => {\n\t\t\tstate.value = getValues();\n\t\t});\n\t\tonScopeDispose(unsubscribe);\n\t\treturn state;\n\t}\n\n\tconst status = shallowRef<RequirementTypeStatus>(statusPlugin.getStatus(typeOrTypes));\n\tconst unsubscribe = statusPlugin.subscribe(() => {\n\t\tstatus.value = statusPlugin.getStatus(typeOrTypes);\n\t});\n\tonScopeDispose(unsubscribe);\n\treturn status;\n}\n\n// ============================================================================\n// useExplain — reactive requirement explanation\n// ============================================================================\n\n/**\n * Reactively returns the explanation string for a requirement.\n */\nexport function useExplain(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n\trequirementId: string,\n): Ref<string | null> {\n\tassertSystem(\"useExplain\", system);\n\tconst explanation = ref<string | null>(system.explain(requirementId)) as Ref<string | null>;\n\n\tconst update = () => {\n\t\texplanation.value = system.explain(requirementId);\n\t};\n\n\tconst unsubFacts = system.facts.$store.subscribeAll(update);\n\tconst unsubSettled = system.onSettledChange(update);\n\tonScopeDispose(() => {\n\t\tunsubFacts();\n\t\tunsubSettled();\n\t});\n\n\treturn explanation;\n}\n\n// ============================================================================\n// useConstraintStatus — reactive constraint inspection\n// ============================================================================\n\n/** Get all constraints */\nexport function useConstraintStatus(\n\tsystem: SingleModuleSystem<any>,\n): ComputedRef<ConstraintInfo[]>;\n/** Get a single constraint by ID */\nexport function useConstraintStatus(\n\tsystem: SingleModuleSystem<any>,\n\tconstraintId: string,\n): ComputedRef<ConstraintInfo | null>;\n/** Implementation */\nexport function useConstraintStatus(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n\tconstraintId?: string,\n): ComputedRef<ConstraintInfo[] | ConstraintInfo | null> {\n\tassertSystem(\"useConstraintStatus\", system);\n\tconst inspectState = useInspect(system);\n\n\treturn computed(() => {\n\t\t// Track reactivity via inspectState, but use full inspect() for constraint list\n\t\tvoid inspectState.value;\n\t\tconst fullInspection = system.inspect();\n\t\tif (!constraintId) return fullInspection.constraints;\n\t\treturn fullInspection.constraints.find((c) => c.id === constraintId) ?? null;\n\t});\n}\n\n// ============================================================================\n// useOptimisticUpdate — batch with rollback on failure\n// ============================================================================\n\nexport interface OptimisticUpdateResult {\n\tmutate: (updateFn: () => void) => void;\n\tisPending: Ref<boolean>;\n\terror: Ref<Error | null>;\n\trollback: () => void;\n}\n\n/**\n * Optimistic update hook. Saves a snapshot before mutating, monitors\n * a requirement type via statusPlugin, and rolls back on failure.\n */\nexport function useOptimisticUpdate(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n\tstatusPlugin?: StatusPlugin,\n\trequirementType?: string,\n): OptimisticUpdateResult {\n\tassertSystem(\"useOptimisticUpdate\", system);\n\tconst isPending = ref(false);\n\tconst error = ref<Error | null>(null) as Ref<Error | null>;\n\tlet snapshot: SystemSnapshot | null = null;\n\tlet unsubscribe: (() => void) | null = null;\n\n\tconst rollback = () => {\n\t\tif (snapshot) {\n\t\t\tsystem.restore(snapshot);\n\t\t\tsnapshot = null;\n\t\t}\n\t\tisPending.value = false;\n\t\terror.value = null;\n\t\tunsubscribe?.();\n\t\tunsubscribe = null;\n\t};\n\n\tconst mutate = (updateFn: () => void) => {\n\t\tsnapshot = system.getSnapshot();\n\t\tisPending.value = true;\n\t\terror.value = null;\n\t\tsystem.batch(updateFn);\n\n\t\t// Watch for resolver completion/failure\n\t\tif (statusPlugin && requirementType) {\n\t\t\tunsubscribe?.();\n\t\t\tunsubscribe = statusPlugin.subscribe(() => {\n\t\t\t\tconst status = statusPlugin.getStatus(requirementType);\n\t\t\t\tif (!status.isLoading && !status.hasError) {\n\t\t\t\t\tsnapshot = null;\n\t\t\t\t\tisPending.value = false;\n\t\t\t\t\tunsubscribe?.();\n\t\t\t\t\tunsubscribe = null;\n\t\t\t\t} else if (status.hasError) {\n\t\t\t\t\terror.value = status.lastError;\n\t\t\t\t\trollback();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t};\n\n\tonScopeDispose(() => {\n\t\tunsubscribe?.();\n\t});\n\n\treturn { mutate, isPending, error, rollback };\n}\n\n// ============================================================================\n// useTimeTravel — reactive time-travel state\n// ============================================================================\n\n/**\n * Reactive time-travel composable. Returns a ShallowRef that updates\n * when snapshots are taken or navigation occurs.\n *\n * @example\n * ```vue\n * const tt = useTimeTravel(system);\n * <button :disabled=\"!tt.value?.canUndo\" @click=\"tt.value?.undo()\">Undo</button>\n * ```\n */\nexport function useTimeTravel(\n\t// biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n\tsystem: SingleModuleSystem<any>,\n): ShallowRef<ReturnType<typeof buildTimeTravelState>> {\n\tassertSystem(\"useTimeTravel\", system);\n\tconst state = shallowRef<ReturnType<typeof buildTimeTravelState>>(buildTimeTravelState(system));\n\tconst unsub = system.onTimeTravelChange(() => {\n\t\tstate.value = buildTimeTravelState(system);\n\t});\n\tonScopeDispose(unsub);\n\treturn state;\n}\n\n// ============================================================================\n// Scoped System Composable\n// ============================================================================\n\n/** Configuration for useDirective */\ninterface UseDirectiveConfig {\n\t// biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n\tplugins?: Plugin<any>[];\n\tdebug?: DebugConfig;\n\terrorBoundary?: ErrorBoundaryConfig;\n\ttickMs?: number;\n\tzeroConfig?: boolean;\n\t// biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n\tinitialFacts?: Record<string, any>;\n\tstatus?: boolean;\n\t/** Fact keys to subscribe to (omit for all) */\n\tfacts?: string[];\n\t/** Derivation keys to subscribe to (omit for all) */\n\tderived?: string[];\n}\n\n/**\n * Create a scoped Directive system with automatic lifecycle management.\n * When no `facts` or `derived` keys are specified, subscribes to ALL\n * facts and derivations and returns reactive state.\n *\n * @example\n * ```vue\n * // Subscribe to everything\n * const { facts, derived, events, dispatch } = useDirective(counterModule);\n *\n * // Selective keys\n * const { facts, derived } = useDirective(counterModule, { facts: [\"count\"], derived: [\"doubled\"] });\n * ```\n */\nexport function useDirective<M extends ModuleSchema>(\n\tmoduleDef: ModuleDef<M>,\n\tconfig?: UseDirectiveConfig,\n) {\n\tconst allPlugins = [...(config?.plugins ?? [])];\n\tlet statusPlugin: StatusPlugin | undefined;\n\n\tif (config?.status) {\n\t\tconst sp = createRequirementStatusPlugin();\n\t\tstatusPlugin = sp;\n\t\t// biome-ignore lint/suspicious/noExplicitAny: Plugin generic issues\n\t\tallPlugins.push(sp.plugin as Plugin<any>);\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: Required for overload compatibility\n\tconst system = createSystem({\n\t\tmodule: moduleDef,\n\t\tplugins: allPlugins.length > 0 ? allPlugins : undefined,\n\t\tdebug: config?.debug,\n\t\terrorBoundary: config?.errorBoundary,\n\t\ttickMs: config?.tickMs,\n\t\tzeroConfig: config?.zeroConfig,\n\t\tinitialFacts: config?.initialFacts,\n\t} as any) as unknown as SingleModuleSystem<M>;\n\n\tsystem.start();\n\n\tonScopeDispose(() => {\n\t\tsystem.destroy();\n\t});\n\n\tconst factKeys = config?.facts;\n\tconst derivedKeys = config?.derived;\n\tconst subscribeAll = !factKeys && !derivedKeys;\n\n\t// Subscribe to facts\n\tconst factsState = shallowRef(\n\t\tsubscribeAll\n\t\t\t? (system.facts.$store.toObject() as InferFacts<M>)\n\t\t\t: pickFacts(system, factKeys ?? []),\n\t);\n\tconst unsubFacts = subscribeAll\n\t\t? system.facts.$store.subscribeAll(() => {\n\t\t\tfactsState.value = system.facts.$store.toObject() as InferFacts<M>;\n\t\t})\n\t\t: factKeys && factKeys.length > 0\n\t\t\t? system.facts.$store.subscribe(factKeys, () => {\n\t\t\t\tfactsState.value = pickFacts(system, factKeys) as InferFacts<M>;\n\t\t\t})\n\t\t\t: null;\n\n\t// Subscribe to derivations\n\tconst allDerivationKeys = subscribeAll ? Object.keys(system.derive ?? {}) : (derivedKeys ?? []);\n\tconst getDerived = (): InferDerivations<M> => {\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const key of allDerivationKeys) {\n\t\t\tresult[key] = system.read(key);\n\t\t}\n\t\treturn result as InferDerivations<M>;\n\t};\n\tconst derivedState = shallowRef(getDerived());\n\tconst unsubDerived = allDerivationKeys.length > 0\n\t\t? system.subscribe(allDerivationKeys, () => { derivedState.value = getDerived(); })\n\t\t: null;\n\n\tonScopeDispose(() => {\n\t\tunsubFacts?.();\n\t\tunsubDerived?.();\n\t});\n\n\tconst events = system.events;\n\tconst dispatch = (event: InferEvents<M>) => system.dispatch(event);\n\n\treturn {\n\t\tsystem,\n\t\tfacts: factsState as ShallowRef<InferFacts<M>>,\n\t\tderived: derivedState as ShallowRef<InferDerivations<M>>,\n\t\tevents,\n\t\tdispatch,\n\t\tstatusPlugin,\n\t};\n}\n\n// ============================================================================\n// Typed Hooks Factory\n// ============================================================================\n\nexport function createTypedHooks<M extends ModuleSchema>(): {\n\tuseFact: <K extends keyof InferFacts<M> & string>(\n\t\tsystem: SingleModuleSystem<M>,\n\t\tfactKey: K,\n\t) => Ref<InferFacts<M>[K] | undefined>;\n\tuseDerived: <K extends keyof InferDerivations<M> & string>(\n\t\tsystem: SingleModuleSystem<M>,\n\t\tderivationId: K,\n\t) => Ref<InferDerivations<M>[K]>;\n\tuseDispatch: (system: SingleModuleSystem<M>) => (event: InferEvents<M>) => void;\n\tuseEvents: (system: SingleModuleSystem<M>) => SingleModuleSystem<M>[\"events\"];\n\tuseWatch: <K extends string>(\n\t\tsystem: SingleModuleSystem<M>,\n\t\tkey: K,\n\t\tcallback: (newValue: unknown, previousValue: unknown) => void,\n\t) => void;\n} {\n\treturn {\n\t\tuseFact: <K extends keyof InferFacts<M> & string>(system: SingleModuleSystem<M>, factKey: K) =>\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n\t\t\tuseFact(system as SingleModuleSystem<any>, factKey) as Ref<InferFacts<M>[K] | undefined>,\n\t\tuseDerived: <K extends keyof InferDerivations<M> & string>(system: SingleModuleSystem<M>, derivationId: K) =>\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n\t\t\tuseDerived(system as SingleModuleSystem<any>, derivationId) as Ref<InferDerivations<M>[K]>,\n\t\tuseDispatch: (system: SingleModuleSystem<M>) => {\n\t\t\treturn (event: InferEvents<M>) => {\n\t\t\t\tsystem.dispatch(event);\n\t\t\t};\n\t\t},\n\t\tuseEvents: (system: SingleModuleSystem<M>) => useEvents<M>(system),\n\t\tuseWatch: <K extends string>(\n\t\t\tsystem: SingleModuleSystem<M>,\n\t\t\tkey: K,\n\t\t\tcallback: (newValue: unknown, previousValue: unknown) => void,\n\t\t) =>\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n\t\t\tuseWatch(system as SingleModuleSystem<any>, key, callback),\n\t};\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@directive-run/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Vue composition API adapter for Directive.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Jason Comes",
|
|
@@ -44,15 +44,15 @@
|
|
|
44
44
|
"dist"
|
|
45
45
|
],
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"
|
|
48
|
-
"
|
|
47
|
+
"@directive-run/core": "*",
|
|
48
|
+
"vue": ">=3"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^25.2.0",
|
|
52
52
|
"vue": "^3.4.0",
|
|
53
53
|
"tsup": "^8.3.5",
|
|
54
54
|
"typescript": "^5.7.2",
|
|
55
|
-
"@directive-run/core": "0.
|
|
55
|
+
"@directive-run/core": "0.2.0"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "tsup",
|