@directive-run/vue 0.4.2 → 0.7.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 Jason Comes
3
+ Copyright (c) 2026 Sizls LLC
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -104,7 +104,7 @@ const label = useSelector(system, (state) => {
104
104
  | `useExplain(system, reqId)` | `Ref<string \| null>` | Human-readable requirement explanation |
105
105
  | `useConstraintStatus(system)` | `ComputedRef<ConstraintInfo[]>` | All constraint states |
106
106
  | `useOptimisticUpdate(system)` | `{ mutate, isPending: Ref, error: Ref, rollback }` | Optimistic mutation with auto-rollback |
107
- | `useTimeTravel(system)` | `ShallowRef<TimeTravelState \| null>` | Undo/redo navigation |
107
+ | `useHistory(system)` | `ShallowRef<HistoryState \| null>` | Undo/redo navigation |
108
108
 
109
109
  ### Vue-Specific
110
110
 
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var core=require('@directive-run/core'),adapterUtils=require('@directive-run/core/adapter-utils'),vue=require('vue');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 p=()=>{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,p)):i.length===0&&S.push(e.facts.$store.subscribeAll(p)),i.length>0&&S.push(e.subscribe(i,p));};return c(),vue.onScopeDispose(()=>{for(let p of S)p();}),l}function H(e){return adapterUtils.assertSystem("useDispatch",e),t=>{e.dispatch(t);}}function P(e){return adapterUtils.assertSystem("useEvents",e),e.events}function N(e,t,s){adapterUtils.assertSystem("useWatch",e);let o=e.watch(t,s);vue.onScopeDispose(o);}function U(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=U(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??[],p=()=>{let v={};for(let M of c)v[M]=n.read(M);return v},d=vue.shallowRef(p()),h=c.length>0?n.subscribe(c,()=>{d.value=p();}):null;vue.onScopeDispose(()=>{S?.(),h?.();});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)=>N(e,t,s)}}function ee(e,t,s){let o=vue.ref(s(e)),n=e.subscribe(t,()=>{o.value=s(e);});return vue.onScopeDispose(n),o}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=U;exports.useNamespacedSelector=ee;exports.useOptimisticUpdate=Q;exports.useRequirementStatus=L;exports.useSelector=z;exports.useTimeTravel=X;exports.useWatch=N;//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var core=require('@directive-run/core'),adapterUtils=require('@directive-run/core/adapter-utils'),vue=require('vue');function C(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)?$(e,t):V(e,t)}function V(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 $(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 q(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):T(e,t)}function T(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 j(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 p=()=>{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,p)):i.length===0&&S.push(e.facts.$store.subscribeAll(p)),i.length>0&&S.push(e.subscribe(i,p));};return c(),vue.onScopeDispose(()=>{for(let p of S)p();}),l}function z(e){return adapterUtils.assertSystem("useDispatch",e),t=>{e.dispatch(t);}}function P(e){return adapterUtils.assertSystem("useEvents",e),e.events}function N(e,t,s){adapterUtils.assertSystem("useWatch",e);let o=e.watch(t,s);vue.onScopeDispose(o);}function U(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=U(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("useHistory",e);let t=vue.shallowRef(adapterUtils.buildHistoryState(e)),s=e.onHistoryChange(()=>{t.value=adapterUtils.buildHistoryState(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,trace:t?.trace,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??[],p=()=>{let v={};for(let M of c)v[M]=n.read(M);return v},d=vue.shallowRef(p()),h=c.length>0?n.subscribe(c,()=>{d.value=p();}):null;vue.onScopeDispose(()=>{S?.(),h?.();});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)=>C(e,t),useDerived:(e,t)=>q(e,t),useDispatch:e=>t=>{e.dispatch(t);},useEvents:e=>P(e),useWatch:(e,t,s)=>N(e,t,s)}}function ee(e,t,s){let o=vue.ref(s(e)),n=e.subscribe(t,()=>{o.value=s(e);});return vue.onScopeDispose(n),o}Object.defineProperty(exports,"shallowEqual",{enumerable:true,get:function(){return adapterUtils.shallowEqual}});exports.createTypedHooks=Z;exports.useConstraintStatus=J;exports.useDerived=q;exports.useDirective=Y;exports.useDispatch=z;exports.useEvents=P;exports.useExplain=G;exports.useFact=C;exports.useHistory=X;exports.useInspect=U;exports.useNamespacedSelector=ee;exports.useOptimisticUpdate=Q;exports.useRequirementStatus=L;exports.useSelector=j;exports.useWatch=N;//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.cjs.map
@@ -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","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","useNamespacedSelector","keys"],"mappings":"kIA6EO,SAASA,CAAAA,CAEdC,CAAAA,CACAC,CAAAA,CACoC,CAapC,OAZAC,yBAAAA,CAAa,UAAWF,CAAM,CAAA,CAE5B,OAAA,CAAQ,GAAA,CAAI,WAAa,YAAA,EACzB,OAAOC,CAAAA,EAAc,UAAA,EAErB,QAAQ,KAAA,CACN,gJAEF,CAAA,CAIE,KAAA,CAAM,QAAQA,CAAS,CAAA,CAClBE,CAAAA,CAAcH,CAAAA,CAAQC,CAAS,CAAA,CAIjCG,CAAAA,CAAeJ,CAAAA,CAAQC,CAAS,CACzC,CAGA,SAASG,CAAAA,CACPJ,CAAAA,CACAK,EACc,CACV,OAAA,CAAQ,GAAA,CAAI,QAAA,GAAa,YAAA,GACtBL,CAAAA,CAAO,KAAA,CAAM,MAAA,CAAO,IAAIK,CAA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AQC,CAAAA,CAAmCK,CAAO,EAGpD,UAAA,CAAY,CACVL,CAAAA,CACAoB,CAAAA,GAGAJ,EAAWhB,CAAAA,CAAmCoB,CAAY,CAAA,CAG5D,WAAA,CAAcpB,GACJwC,CAAAA,EAA0B,CAChCxC,CAAAA,CAAO,QAAA,CAASwC,CAAK,EACvB,CAAA,CAEF,SAAA,CAAYxC,CAAAA,EAAkCyC,EAAazC,CAAM,CAAA,CACjE,QAAA,CAAU,CACRA,EACAa,CAAAA,CACA8B,CAAAA,GAGAD,CAAAA,CAAS1C,CAAAA,CAAmCa,CAAAA,CAAK8B,CAAQ,CAC7D,CACF,CAoBO,SAASmD,EAAAA,CACd9F,CAAAA,CACA+F,CAAAA,CACAvE,EACQ,CACR,IAAMlB,CAAAA,CAAQC,OAAAA,CAAIiB,EAASxB,CAAM,CAAC,CAAA,CAC5BQ,CAAAA,CAAcR,EAAO,SAAA,CAAU+F,CAAAA,CAAM,IAAM,CAC/CzF,EAAM,KAAA,CAAQkB,CAAAA,CAASxB,CAAM,EAC/B,CAAC,CAAA,CACD,OAAAS,kBAAAA,CAAeD,CAAW,EAEnBF,CACT","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 type {\n DebugConfig,\n ErrorBoundaryConfig,\n InferDerivations,\n InferEvents,\n InferFacts,\n InferSelectorState,\n ModuleDef,\n ModuleSchema,\n ModulesMap,\n NamespacedSystem,\n Plugin,\n SingleModuleSystem,\n SystemSnapshot,\n} from \"@directive-run/core\";\nimport {\n createRequirementStatusPlugin,\n createSystem,\n} from \"@directive-run/core\";\nimport type { RequirementTypeStatus } from \"@directive-run/core\";\nimport {\n type ConstraintInfo,\n type InspectState,\n assertSystem,\n buildTimeTravelState,\n computeInspectState,\n createThrottle,\n defaultEquality,\n depsChanged,\n pickFacts,\n runTrackedSelector,\n shallowEqual,\n} from \"@directive-run/core/adapter-utils\";\nimport {\n type ComputedRef,\n type Ref,\n type ShallowRef,\n computed,\n onScopeDispose,\n ref,\n shallowRef,\n} from \"vue\";\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<\n S extends ModuleSchema,\n K extends keyof InferFacts<S> & string,\n>(system: SingleModuleSystem<S>, factKey: K): Ref<InferFacts<S>[K] | undefined>;\n/** Multi-key overload */\nexport function useFact<\n S extends ModuleSchema,\n K extends keyof InferFacts<S> & string,\n>(\n system: SingleModuleSystem<S>,\n factKeys: K[],\n): ShallowRef<Pick<InferFacts<S>, K>>;\n/** Implementation */\nexport function useFact(\n // biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n system: SingleModuleSystem<any>,\n keyOrKeys: string | string[],\n): Ref<unknown> | ShallowRef<unknown> {\n assertSystem(\"useFact\", system);\n if (\n process.env.NODE_ENV !== \"production\" &&\n typeof keyOrKeys === \"function\"\n ) {\n console.error(\n \"[Directive] useFact() received a function. Did you mean useSelector()? \" +\n \"useFact() takes a string key or array of keys, not a selector function.\",\n );\n }\n\n // Multi-key path: useFact(system, [keys])\n if (Array.isArray(keyOrKeys)) {\n return _useFactMulti(system, keyOrKeys);\n }\n\n // Single key path: useFact(system, key)\n return _useFactSingle(system, keyOrKeys);\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useFactSingle(\n system: SingleModuleSystem<any>,\n factKey: string,\n): Ref<unknown> {\n if (process.env.NODE_ENV !== \"production\") {\n if (!system.facts.$store.has(factKey)) {\n console.warn(\n `[Directive] useFact(\"${factKey}\") — fact not found in store. ` +\n `Check that \"${factKey}\" is defined in your module's schema.`,\n );\n }\n }\n\n const value = ref(system.facts.$store.get(factKey));\n const unsubscribe = system.facts.$store.subscribe([factKey], () => {\n value.value = system.facts.$store.get(factKey);\n });\n onScopeDispose(unsubscribe);\n return value;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useFactMulti(\n system: SingleModuleSystem<any>,\n factKeys: string[],\n): ShallowRef<Record<string, unknown>> {\n const getValues = (): Record<string, unknown> => {\n const result: Record<string, unknown> = {};\n for (const key of factKeys) {\n result[key] = system.facts.$store.get(key);\n }\n return result;\n };\n const state = shallowRef(getValues());\n const unsubscribe = system.facts.$store.subscribe(factKeys, () => {\n state.value = getValues();\n });\n onScopeDispose(unsubscribe);\n return state;\n}\n\n// ============================================================================\n// useDerived — single key or multi key\n// ============================================================================\n\n/** Single key overload */\nexport function useDerived<\n S extends ModuleSchema,\n K extends keyof InferDerivations<S> & string,\n>(system: SingleModuleSystem<S>, derivationId: K): Ref<InferDerivations<S>[K]>;\n/** Multi-key overload */\nexport function useDerived<\n S extends ModuleSchema,\n K extends keyof InferDerivations<S> & string,\n>(\n system: SingleModuleSystem<S>,\n derivationIds: K[],\n): ShallowRef<Pick<InferDerivations<S>, K>>;\n/** Implementation */\nexport function useDerived(\n // biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n system: SingleModuleSystem<any>,\n idOrIds: string | string[],\n): Ref<unknown> | ShallowRef<unknown> {\n assertSystem(\"useDerived\", system);\n if (process.env.NODE_ENV !== \"production\" && typeof idOrIds === \"function\") {\n console.error(\n \"[Directive] useDerived() received a function. Did you mean useSelector()? \" +\n \"useDerived() takes a string key or array of keys, not a selector function.\",\n );\n }\n\n // Multi-key path\n if (Array.isArray(idOrIds)) {\n return _useDerivedMulti(system, idOrIds);\n }\n\n // Single key path\n return _useDerivedSingle(system, idOrIds);\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useDerivedSingle(\n system: SingleModuleSystem<any>,\n derivationId: string,\n): Ref<unknown> {\n if (process.env.NODE_ENV !== \"production\") {\n const initialValue = system.read(derivationId);\n if (initialValue === undefined) {\n console.warn(\n `[Directive] useDerived(\"${derivationId}\") returned undefined. ` +\n `Check that \"${derivationId}\" is defined in your module's derive property.`,\n );\n }\n }\n const value = ref(system.read(derivationId));\n const unsubscribe = system.subscribe([derivationId], () => {\n value.value = system.read(derivationId);\n });\n onScopeDispose(unsubscribe);\n return value;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useDerivedMulti(\n system: SingleModuleSystem<any>,\n derivationIds: string[],\n): ShallowRef<Record<string, unknown>> {\n const getValues = (): Record<string, unknown> => {\n const result: Record<string, unknown> = {};\n for (const id of derivationIds) {\n result[id] = system.read(id);\n }\n return result;\n };\n const state = shallowRef(getValues());\n const unsubscribe = system.subscribe(derivationIds, () => {\n state.value = getValues();\n });\n onScopeDispose(unsubscribe);\n return 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>(\n system: SingleModuleSystem<S>,\n selector: (state: InferSelectorState<S>) => R,\n equalityFn?: (a: R, b: R) => boolean,\n): Ref<R>;\nexport function useSelector(\n // biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n system: SingleModuleSystem<any>,\n selector: (state: Record<string, unknown>) => unknown,\n equalityFn: (a: unknown, b: unknown) => boolean = defaultEquality,\n): Ref<unknown> {\n assertSystem(\"useSelector\", system);\n const deriveKeySet = new Set(Object.keys(system.derive ?? {}));\n\n const runWithTracking = () =>\n runTrackedSelector(system, deriveKeySet, selector);\n\n const initial = runWithTracking();\n let trackedFactKeys = initial.factKeys;\n let trackedDeriveKeys = initial.deriveKeys;\n const selected = ref(initial.value);\n\n const unsubs: Array<() => void> = [];\n\n const resubscribe = () => {\n for (const unsub of unsubs) unsub();\n unsubs.length = 0;\n\n const onUpdate = () => {\n const result = runWithTracking();\n if (!equalityFn(selected.value, result.value)) {\n selected.value = result.value;\n }\n // Re-track: check if deps changed\n if (\n depsChanged(\n trackedFactKeys,\n result.factKeys,\n trackedDeriveKeys,\n result.deriveKeys,\n )\n ) {\n trackedFactKeys = result.factKeys;\n trackedDeriveKeys = result.deriveKeys;\n resubscribe();\n }\n };\n\n if (trackedFactKeys.length > 0) {\n unsubs.push(system.facts.$store.subscribe(trackedFactKeys, onUpdate));\n } else if (trackedDeriveKeys.length === 0) {\n unsubs.push(system.facts.$store.subscribeAll(onUpdate));\n }\n if (trackedDeriveKeys.length > 0) {\n unsubs.push(system.subscribe(trackedDeriveKeys, onUpdate));\n }\n };\n\n resubscribe();\n\n onScopeDispose(() => {\n for (const unsub of unsubs) unsub();\n });\n\n return selected;\n}\n\n// ============================================================================\n// useDispatch\n// ============================================================================\n\nexport function useDispatch<S extends ModuleSchema>(\n system: SingleModuleSystem<S>,\n): (event: InferEvents<S>) => void {\n assertSystem(\"useDispatch\", system);\n return (event: InferEvents<S>) => {\n system.dispatch(event);\n };\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 system: SingleModuleSystem<S>,\n): SingleModuleSystem<S>[\"events\"] {\n assertSystem(\"useEvents\", system);\n return 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<\n S extends ModuleSchema,\n K extends keyof InferDerivations<S> & string,\n>(\n system: SingleModuleSystem<S>,\n key: K,\n callback: (\n newValue: InferDerivations<S>[K],\n previousValue: InferDerivations<S>[K] | undefined,\n ) => void,\n): void;\n/** Watch a fact key with auto-detection. */\nexport function useWatch<\n S extends ModuleSchema,\n K extends keyof InferFacts<S> & string,\n>(\n system: SingleModuleSystem<S>,\n key: K,\n callback: (\n newValue: InferFacts<S>[K] | undefined,\n previousValue: InferFacts<S>[K] | undefined,\n ) => void,\n): void;\n/** Implementation */\nexport function useWatch(\n // biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n system: SingleModuleSystem<any>,\n key: string,\n callback: (newValue: unknown, prevValue: unknown) => void,\n): void {\n assertSystem(\"useWatch\", system);\n\n const unsubscribe = system.watch(key, callback);\n onScopeDispose(unsubscribe);\n}\n\n// ============================================================================\n// useInspect — consolidated inspection hook\n// ============================================================================\n\n/** Options for useInspect */\nexport interface UseInspectOptions {\n throttleMs?: number;\n}\n\n/**\n * Consolidated system inspection hook.\n * Returns InspectState with optional throttling.\n */\nexport function useInspect(\n // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n options?: UseInspectOptions,\n): ShallowRef<InspectState> {\n assertSystem(\"useInspect\", system);\n const state = shallowRef<InspectState>(computeInspectState(system));\n\n const update = () => {\n state.value = computeInspectState(system);\n };\n\n if (options?.throttleMs && options.throttleMs > 0) {\n const { throttled, cleanup } = createThrottle(update, options.throttleMs);\n const unsubFacts = system.facts.$store.subscribeAll(throttled);\n const unsubSettled = system.onSettledChange(throttled);\n onScopeDispose(() => {\n cleanup();\n unsubFacts();\n unsubSettled();\n });\n } else {\n const unsubFacts = system.facts.$store.subscribeAll(update);\n const unsubSettled = system.onSettledChange(update);\n onScopeDispose(() => {\n unsubFacts();\n unsubSettled();\n });\n }\n\n return state;\n}\n\n// ============================================================================\n// useRequirementStatus — single or multi\n// ============================================================================\n\n/** Single type overload */\nexport function useRequirementStatus(\n statusPlugin: StatusPlugin,\n type: string,\n): ShallowRef<RequirementTypeStatus>;\n/** Multi-type overload */\nexport function useRequirementStatus(\n statusPlugin: StatusPlugin,\n types: string[],\n): ShallowRef<Record<string, RequirementTypeStatus>>;\n/** Implementation */\nexport function useRequirementStatus(\n statusPlugin: StatusPlugin,\n typeOrTypes: string | string[],\n):\n | ShallowRef<RequirementTypeStatus>\n | ShallowRef<Record<string, RequirementTypeStatus>> {\n if (Array.isArray(typeOrTypes)) {\n const getValues = (): Record<string, RequirementTypeStatus> => {\n const result: Record<string, RequirementTypeStatus> = {};\n for (const type of typeOrTypes) {\n result[type] = statusPlugin.getStatus(type);\n }\n return result;\n };\n const state = shallowRef(getValues());\n const unsubscribe = statusPlugin.subscribe(() => {\n state.value = getValues();\n });\n onScopeDispose(unsubscribe);\n return state;\n }\n\n const status = shallowRef<RequirementTypeStatus>(\n statusPlugin.getStatus(typeOrTypes),\n );\n const unsubscribe = statusPlugin.subscribe(() => {\n status.value = statusPlugin.getStatus(typeOrTypes);\n });\n onScopeDispose(unsubscribe);\n return 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 // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n requirementId: string,\n): Ref<string | null> {\n assertSystem(\"useExplain\", system);\n const explanation = ref<string | null>(system.explain(requirementId)) as Ref<\n string | null\n >;\n\n const update = () => {\n explanation.value = system.explain(requirementId);\n };\n\n const unsubFacts = system.facts.$store.subscribeAll(update);\n const unsubSettled = system.onSettledChange(update);\n onScopeDispose(() => {\n unsubFacts();\n unsubSettled();\n });\n\n return explanation;\n}\n\n// ============================================================================\n// useConstraintStatus — reactive constraint inspection\n// ============================================================================\n\n/** Get all constraints */\nexport function useConstraintStatus(\n system: SingleModuleSystem<any>,\n): ComputedRef<ConstraintInfo[]>;\n/** Get a single constraint by ID */\nexport function useConstraintStatus(\n system: SingleModuleSystem<any>,\n constraintId: string,\n): ComputedRef<ConstraintInfo | null>;\n/** Implementation */\nexport function useConstraintStatus(\n // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n constraintId?: string,\n): ComputedRef<ConstraintInfo[] | ConstraintInfo | null> {\n assertSystem(\"useConstraintStatus\", system);\n const inspectState = useInspect(system);\n\n return computed(() => {\n // Track reactivity via inspectState, but use full inspect() for constraint list\n void inspectState.value;\n const fullInspection = system.inspect();\n if (!constraintId) return fullInspection.constraints;\n return (\n fullInspection.constraints.find((c) => c.id === constraintId) ?? null\n );\n });\n}\n\n// ============================================================================\n// useOptimisticUpdate — batch with rollback on failure\n// ============================================================================\n\nexport interface OptimisticUpdateResult {\n mutate: (updateFn: () => void) => void;\n isPending: Ref<boolean>;\n error: Ref<Error | null>;\n rollback: () => 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 // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n statusPlugin?: StatusPlugin,\n requirementType?: string,\n): OptimisticUpdateResult {\n assertSystem(\"useOptimisticUpdate\", system);\n const isPending = ref(false);\n const error = ref<Error | null>(null) as Ref<Error | null>;\n let snapshot: SystemSnapshot | null = null;\n let unsubscribe: (() => void) | null = null;\n\n const rollback = () => {\n if (snapshot) {\n system.restore(snapshot);\n snapshot = null;\n }\n isPending.value = false;\n error.value = null;\n unsubscribe?.();\n unsubscribe = null;\n };\n\n const mutate = (updateFn: () => void) => {\n snapshot = system.getSnapshot();\n isPending.value = true;\n error.value = null;\n system.batch(updateFn);\n\n // Watch for resolver completion/failure\n if (statusPlugin && requirementType) {\n unsubscribe?.();\n unsubscribe = statusPlugin.subscribe(() => {\n const status = statusPlugin.getStatus(requirementType);\n if (!status.isLoading && !status.hasError) {\n snapshot = null;\n isPending.value = false;\n unsubscribe?.();\n unsubscribe = null;\n } else if (status.hasError) {\n error.value = status.lastError;\n rollback();\n }\n });\n }\n };\n\n onScopeDispose(() => {\n unsubscribe?.();\n });\n\n return { 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 // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n): ShallowRef<ReturnType<typeof buildTimeTravelState>> {\n assertSystem(\"useTimeTravel\", system);\n const state = shallowRef<ReturnType<typeof buildTimeTravelState>>(\n buildTimeTravelState(system),\n );\n const unsub = system.onTimeTravelChange(() => {\n state.value = buildTimeTravelState(system);\n });\n onScopeDispose(unsub);\n return state;\n}\n\n// ============================================================================\n// Scoped System Composable\n// ============================================================================\n\n/** Configuration for useDirective */\ninterface UseDirectiveConfig {\n // biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n plugins?: Plugin<any>[];\n debug?: DebugConfig;\n errorBoundary?: ErrorBoundaryConfig;\n tickMs?: number;\n zeroConfig?: boolean;\n // biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n initialFacts?: Record<string, any>;\n status?: boolean;\n /** Fact keys to subscribe to (omit for all) */\n facts?: string[];\n /** Derivation keys to subscribe to (omit for all) */\n derived?: 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 moduleDef: ModuleDef<M>,\n config?: UseDirectiveConfig,\n) {\n const allPlugins = [...(config?.plugins ?? [])];\n let statusPlugin: StatusPlugin | undefined;\n\n if (config?.status) {\n const sp = createRequirementStatusPlugin();\n statusPlugin = sp;\n // biome-ignore lint/suspicious/noExplicitAny: Plugin generic issues\n allPlugins.push(sp.plugin as Plugin<any>);\n }\n\n // biome-ignore lint/suspicious/noExplicitAny: Required for overload compatibility\n const system = createSystem({\n module: moduleDef,\n plugins: allPlugins.length > 0 ? allPlugins : undefined,\n debug: config?.debug,\n errorBoundary: config?.errorBoundary,\n tickMs: config?.tickMs,\n zeroConfig: config?.zeroConfig,\n initialFacts: config?.initialFacts,\n } as any) as unknown as SingleModuleSystem<M>;\n\n system.start();\n\n onScopeDispose(() => {\n system.destroy();\n });\n\n const factKeys = config?.facts;\n const derivedKeys = config?.derived;\n const subscribeAll = !factKeys && !derivedKeys;\n\n // Subscribe to facts\n const factsState = shallowRef(\n subscribeAll\n ? (system.facts.$store.toObject() as InferFacts<M>)\n : pickFacts(system, factKeys ?? []),\n );\n const unsubFacts = subscribeAll\n ? system.facts.$store.subscribeAll(() => {\n factsState.value = system.facts.$store.toObject() as InferFacts<M>;\n })\n : factKeys && factKeys.length > 0\n ? system.facts.$store.subscribe(factKeys, () => {\n factsState.value = pickFacts(system, factKeys) as InferFacts<M>;\n })\n : null;\n\n // Subscribe to derivations\n const allDerivationKeys = subscribeAll\n ? Object.keys(system.derive ?? {})\n : (derivedKeys ?? []);\n const getDerived = (): InferDerivations<M> => {\n const result: Record<string, unknown> = {};\n for (const key of allDerivationKeys) {\n result[key] = system.read(key);\n }\n return result as InferDerivations<M>;\n };\n const derivedState = shallowRef(getDerived());\n const unsubDerived =\n allDerivationKeys.length > 0\n ? system.subscribe(allDerivationKeys, () => {\n derivedState.value = getDerived();\n })\n : null;\n\n onScopeDispose(() => {\n unsubFacts?.();\n unsubDerived?.();\n });\n\n const events = system.events;\n const dispatch = (event: InferEvents<M>) => system.dispatch(event);\n\n return {\n system,\n facts: factsState as ShallowRef<InferFacts<M>>,\n derived: derivedState as ShallowRef<InferDerivations<M>>,\n events,\n dispatch,\n statusPlugin,\n };\n}\n\n// ============================================================================\n// Typed Hooks Factory\n// ============================================================================\n\nexport function createTypedHooks<M extends ModuleSchema>(): {\n useFact: <K extends keyof InferFacts<M> & string>(\n system: SingleModuleSystem<M>,\n factKey: K,\n ) => Ref<InferFacts<M>[K] | undefined>;\n useDerived: <K extends keyof InferDerivations<M> & string>(\n system: SingleModuleSystem<M>,\n derivationId: K,\n ) => Ref<InferDerivations<M>[K]>;\n useDispatch: (\n system: SingleModuleSystem<M>,\n ) => (event: InferEvents<M>) => void;\n useEvents: (system: SingleModuleSystem<M>) => SingleModuleSystem<M>[\"events\"];\n useWatch: <K extends string>(\n system: SingleModuleSystem<M>,\n key: K,\n callback: (newValue: unknown, previousValue: unknown) => void,\n ) => void;\n} {\n return {\n useFact: <K extends keyof InferFacts<M> & string>(\n system: SingleModuleSystem<M>,\n factKey: K,\n ) =>\n // biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n useFact(system as SingleModuleSystem<any>, factKey) as Ref<\n InferFacts<M>[K] | undefined\n >,\n useDerived: <K extends keyof InferDerivations<M> & string>(\n system: SingleModuleSystem<M>,\n derivationId: K,\n ) =>\n // biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n useDerived(system as SingleModuleSystem<any>, derivationId) as Ref<\n InferDerivations<M>[K]\n >,\n useDispatch: (system: SingleModuleSystem<M>) => {\n return (event: InferEvents<M>) => {\n system.dispatch(event);\n };\n },\n useEvents: (system: SingleModuleSystem<M>) => useEvents<M>(system),\n useWatch: <K extends string>(\n system: SingleModuleSystem<M>,\n key: K,\n callback: (newValue: unknown, previousValue: unknown) => void,\n ) =>\n // biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n useWatch(system as SingleModuleSystem<any>, key, callback),\n };\n}\n\n// ============================================================================\n// useNamespacedSelector — select from a NamespacedSystem\n// ============================================================================\n\n/**\n * Reactive composable to select from a NamespacedSystem.\n * Subscribes to specified keys and returns a Vue ref.\n *\n * @param system - The namespaced system\n * @param keys - Namespaced keys to subscribe to (e.g., [\"auth.token\", \"data.count\"])\n * @param selector - Function that reads from system.facts / system.derive\n *\n * @example\n * ```vue\n * const system = useDirectiveRef({ modules: { auth, data } });\n * const token = useNamespacedSelector(system, [\"auth.token\"], (s) => s.facts.auth.token);\n * ```\n */\nexport function useNamespacedSelector<Modules extends ModulesMap, R>(\n system: NamespacedSystem<Modules>,\n keys: string[],\n selector: (system: NamespacedSystem<Modules>) => R,\n): Ref<R> {\n const value = ref(selector(system)) as Ref<R>;\n const unsubscribe = system.subscribe(keys, () => {\n value.value = selector(system) as R;\n });\n onScopeDispose(unsubscribe);\n\n return value;\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","useHistory","buildHistoryState","useDirective","moduleDef","config","allPlugins","sp","createRequirementStatusPlugin","createSystem","derivedKeys","subscribeAll","factsState","pickFacts","allDerivationKeys","getDerived","derivedState","unsubDerived","events","createTypedHooks","useNamespacedSelector","keys"],"mappings":"kIA6EO,SAASA,CAAAA,CAEdC,CAAAA,CACAC,CAAAA,CACoC,CAapC,OAZAC,yBAAAA,CAAa,UAAWF,CAAM,CAAA,CAE5B,OAAA,CAAQ,GAAA,CAAI,WAAa,YAAA,EACzB,OAAOC,CAAAA,EAAc,UAAA,EAErB,QAAQ,KAAA,CACN,gJAEF,CAAA,CAIE,KAAA,CAAM,QAAQA,CAAS,CAAA,CAClBE,CAAAA,CAAcH,CAAAA,C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T,OAAAE,CAAAA,CACA,QAAA,CAPgBpD,CAAAA,EAA0BxC,CAAAA,CAAO,SAASwC,CAAK,CAAA,CAQ/D,YAAA,CAAAc,CACF,CACF,CAMO,SAASuC,CAAAA,EAkBd,CACA,OAAO,CACL,OAAA,CAAS,CACP7F,EACAK,CAAAA,GAGAN,CAAAA,CAAQC,CAAAA,CAAmCK,CAAO,EAGpD,UAAA,CAAY,CACVL,CAAAA,CACAoB,CAAAA,GAGAJ,EAAWhB,CAAAA,CAAmCoB,CAAY,CAAA,CAG5D,WAAA,CAAcpB,GACJwC,CAAAA,EAA0B,CAChCxC,CAAAA,CAAO,QAAA,CAASwC,CAAK,EACvB,CAAA,CAEF,SAAA,CAAYxC,CAAAA,EAAkCyC,EAAazC,CAAM,CAAA,CACjE,QAAA,CAAU,CACRA,EACAa,CAAAA,CACA8B,CAAAA,GAGAD,CAAAA,CAAS1C,CAAAA,CAAmCa,CAAAA,CAAK8B,CAAQ,CAC7D,CACF,CAoBO,SAASmD,EAAAA,CACd9F,CAAAA,CACA+F,CAAAA,CACAvE,EACQ,CACR,IAAMlB,CAAAA,CAAQC,OAAAA,CAAIiB,EAASxB,CAAM,CAAC,CAAA,CAC5BQ,CAAAA,CAAcR,EAAO,SAAA,CAAU+F,CAAAA,CAAM,IAAM,CAC/CzF,EAAM,KAAA,CAAQkB,CAAAA,CAASxB,CAAM,EAC/B,CAAC,CAAA,CACD,OAAAS,kBAAAA,CAAeD,CAAW,EAEnBF,CACT","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, useHistory,\n * createTypedHooks, shallowEqual\n */\n\nimport type {\n TraceOption,\n ErrorBoundaryConfig,\n InferDerivations,\n InferEvents,\n InferFacts,\n InferSelectorState,\n ModuleDef,\n ModuleSchema,\n ModulesMap,\n NamespacedSystem,\n Plugin,\n SingleModuleSystem,\n SystemSnapshot,\n} from \"@directive-run/core\";\nimport {\n createRequirementStatusPlugin,\n createSystem,\n} from \"@directive-run/core\";\nimport type { RequirementTypeStatus } from \"@directive-run/core\";\nimport {\n type ConstraintInfo,\n type InspectState,\n assertSystem,\n buildHistoryState,\n computeInspectState,\n createThrottle,\n defaultEquality,\n depsChanged,\n pickFacts,\n runTrackedSelector,\n shallowEqual,\n} from \"@directive-run/core/adapter-utils\";\nimport {\n type ComputedRef,\n type Ref,\n type ShallowRef,\n computed,\n onScopeDispose,\n ref,\n shallowRef,\n} from \"vue\";\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<\n S extends ModuleSchema,\n K extends keyof InferFacts<S> & string,\n>(system: SingleModuleSystem<S>, factKey: K): Ref<InferFacts<S>[K] | undefined>;\n/** Multi-key overload */\nexport function useFact<\n S extends ModuleSchema,\n K extends keyof InferFacts<S> & string,\n>(\n system: SingleModuleSystem<S>,\n factKeys: K[],\n): ShallowRef<Pick<InferFacts<S>, K>>;\n/** Implementation */\nexport function useFact(\n // biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n system: SingleModuleSystem<any>,\n keyOrKeys: string | string[],\n): Ref<unknown> | ShallowRef<unknown> {\n assertSystem(\"useFact\", system);\n if (\n process.env.NODE_ENV !== \"production\" &&\n typeof keyOrKeys === \"function\"\n ) {\n console.error(\n \"[Directive] useFact() received a function. Did you mean useSelector()? \" +\n \"useFact() takes a string key or array of keys, not a selector function.\",\n );\n }\n\n // Multi-key path: useFact(system, [keys])\n if (Array.isArray(keyOrKeys)) {\n return _useFactMulti(system, keyOrKeys);\n }\n\n // Single key path: useFact(system, key)\n return _useFactSingle(system, keyOrKeys);\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useFactSingle(\n system: SingleModuleSystem<any>,\n factKey: string,\n): Ref<unknown> {\n if (process.env.NODE_ENV !== \"production\") {\n if (!system.facts.$store.has(factKey)) {\n console.warn(\n `[Directive] useFact(\"${factKey}\") — fact not found in store. ` +\n `Check that \"${factKey}\" is defined in your module's schema.`,\n );\n }\n }\n\n const value = ref(system.facts.$store.get(factKey));\n const unsubscribe = system.facts.$store.subscribe([factKey], () => {\n value.value = system.facts.$store.get(factKey);\n });\n onScopeDispose(unsubscribe);\n return value;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useFactMulti(\n system: SingleModuleSystem<any>,\n factKeys: string[],\n): ShallowRef<Record<string, unknown>> {\n const getValues = (): Record<string, unknown> => {\n const result: Record<string, unknown> = {};\n for (const key of factKeys) {\n result[key] = system.facts.$store.get(key);\n }\n return result;\n };\n const state = shallowRef(getValues());\n const unsubscribe = system.facts.$store.subscribe(factKeys, () => {\n state.value = getValues();\n });\n onScopeDispose(unsubscribe);\n return state;\n}\n\n// ============================================================================\n// useDerived — single key or multi key\n// ============================================================================\n\n/** Single key overload */\nexport function useDerived<\n S extends ModuleSchema,\n K extends keyof InferDerivations<S> & string,\n>(system: SingleModuleSystem<S>, derivationId: K): Ref<InferDerivations<S>[K]>;\n/** Multi-key overload */\nexport function useDerived<\n S extends ModuleSchema,\n K extends keyof InferDerivations<S> & string,\n>(\n system: SingleModuleSystem<S>,\n derivationIds: K[],\n): ShallowRef<Pick<InferDerivations<S>, K>>;\n/** Implementation */\nexport function useDerived(\n // biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n system: SingleModuleSystem<any>,\n idOrIds: string | string[],\n): Ref<unknown> | ShallowRef<unknown> {\n assertSystem(\"useDerived\", system);\n if (process.env.NODE_ENV !== \"production\" && typeof idOrIds === \"function\") {\n console.error(\n \"[Directive] useDerived() received a function. Did you mean useSelector()? \" +\n \"useDerived() takes a string key or array of keys, not a selector function.\",\n );\n }\n\n // Multi-key path\n if (Array.isArray(idOrIds)) {\n return _useDerivedMulti(system, idOrIds);\n }\n\n // Single key path\n return _useDerivedSingle(system, idOrIds);\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useDerivedSingle(\n system: SingleModuleSystem<any>,\n derivationId: string,\n): Ref<unknown> {\n if (process.env.NODE_ENV !== \"production\") {\n const initialValue = system.read(derivationId);\n if (initialValue === undefined) {\n console.warn(\n `[Directive] useDerived(\"${derivationId}\") returned undefined. ` +\n `Check that \"${derivationId}\" is defined in your module's derive property.`,\n );\n }\n }\n const value = ref(system.read(derivationId));\n const unsubscribe = system.subscribe([derivationId], () => {\n value.value = system.read(derivationId);\n });\n onScopeDispose(unsubscribe);\n return value;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useDerivedMulti(\n system: SingleModuleSystem<any>,\n derivationIds: string[],\n): ShallowRef<Record<string, unknown>> {\n const getValues = (): Record<string, unknown> => {\n const result: Record<string, unknown> = {};\n for (const id of derivationIds) {\n result[id] = system.read(id);\n }\n return result;\n };\n const state = shallowRef(getValues());\n const unsubscribe = system.subscribe(derivationIds, () => {\n state.value = getValues();\n });\n onScopeDispose(unsubscribe);\n return 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>(\n system: SingleModuleSystem<S>,\n selector: (state: InferSelectorState<S>) => R,\n equalityFn?: (a: R, b: R) => boolean,\n): Ref<R>;\nexport function useSelector(\n // biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n system: SingleModuleSystem<any>,\n selector: (state: Record<string, unknown>) => unknown,\n equalityFn: (a: unknown, b: unknown) => boolean = defaultEquality,\n): Ref<unknown> {\n assertSystem(\"useSelector\", system);\n const deriveKeySet = new Set(Object.keys(system.derive ?? {}));\n\n const runWithTracking = () =>\n runTrackedSelector(system, deriveKeySet, selector);\n\n const initial = runWithTracking();\n let trackedFactKeys = initial.factKeys;\n let trackedDeriveKeys = initial.deriveKeys;\n const selected = ref(initial.value);\n\n const unsubs: Array<() => void> = [];\n\n const resubscribe = () => {\n for (const unsub of unsubs) unsub();\n unsubs.length = 0;\n\n const onUpdate = () => {\n const result = runWithTracking();\n if (!equalityFn(selected.value, result.value)) {\n selected.value = result.value;\n }\n // Re-track: check if deps changed\n if (\n depsChanged(\n trackedFactKeys,\n result.factKeys,\n trackedDeriveKeys,\n result.deriveKeys,\n )\n ) {\n trackedFactKeys = result.factKeys;\n trackedDeriveKeys = result.deriveKeys;\n resubscribe();\n }\n };\n\n if (trackedFactKeys.length > 0) {\n unsubs.push(system.facts.$store.subscribe(trackedFactKeys, onUpdate));\n } else if (trackedDeriveKeys.length === 0) {\n unsubs.push(system.facts.$store.subscribeAll(onUpdate));\n }\n if (trackedDeriveKeys.length > 0) {\n unsubs.push(system.subscribe(trackedDeriveKeys, onUpdate));\n }\n };\n\n resubscribe();\n\n onScopeDispose(() => {\n for (const unsub of unsubs) unsub();\n });\n\n return selected;\n}\n\n// ============================================================================\n// useDispatch\n// ============================================================================\n\nexport function useDispatch<S extends ModuleSchema>(\n system: SingleModuleSystem<S>,\n): (event: InferEvents<S>) => void {\n assertSystem(\"useDispatch\", system);\n return (event: InferEvents<S>) => {\n system.dispatch(event);\n };\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 system: SingleModuleSystem<S>,\n): SingleModuleSystem<S>[\"events\"] {\n assertSystem(\"useEvents\", system);\n return 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<\n S extends ModuleSchema,\n K extends keyof InferDerivations<S> & string,\n>(\n system: SingleModuleSystem<S>,\n key: K,\n callback: (\n newValue: InferDerivations<S>[K],\n previousValue: InferDerivations<S>[K] | undefined,\n ) => void,\n): void;\n/** Watch a fact key with auto-detection. */\nexport function useWatch<\n S extends ModuleSchema,\n K extends keyof InferFacts<S> & string,\n>(\n system: SingleModuleSystem<S>,\n key: K,\n callback: (\n newValue: InferFacts<S>[K] | undefined,\n previousValue: InferFacts<S>[K] | undefined,\n ) => void,\n): void;\n/** Implementation */\nexport function useWatch(\n // biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n system: SingleModuleSystem<any>,\n key: string,\n callback: (newValue: unknown, prevValue: unknown) => void,\n): void {\n assertSystem(\"useWatch\", system);\n\n const unsubscribe = system.watch(key, callback);\n onScopeDispose(unsubscribe);\n}\n\n// ============================================================================\n// useInspect — consolidated inspection hook\n// ============================================================================\n\n/** Options for useInspect */\nexport interface UseInspectOptions {\n throttleMs?: number;\n}\n\n/**\n * Consolidated system inspection hook.\n * Returns InspectState with optional throttling.\n */\nexport function useInspect(\n // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n options?: UseInspectOptions,\n): ShallowRef<InspectState> {\n assertSystem(\"useInspect\", system);\n const state = shallowRef<InspectState>(computeInspectState(system));\n\n const update = () => {\n state.value = computeInspectState(system);\n };\n\n if (options?.throttleMs && options.throttleMs > 0) {\n const { throttled, cleanup } = createThrottle(update, options.throttleMs);\n const unsubFacts = system.facts.$store.subscribeAll(throttled);\n const unsubSettled = system.onSettledChange(throttled);\n onScopeDispose(() => {\n cleanup();\n unsubFacts();\n unsubSettled();\n });\n } else {\n const unsubFacts = system.facts.$store.subscribeAll(update);\n const unsubSettled = system.onSettledChange(update);\n onScopeDispose(() => {\n unsubFacts();\n unsubSettled();\n });\n }\n\n return state;\n}\n\n// ============================================================================\n// useRequirementStatus — single or multi\n// ============================================================================\n\n/** Single type overload */\nexport function useRequirementStatus(\n statusPlugin: StatusPlugin,\n type: string,\n): ShallowRef<RequirementTypeStatus>;\n/** Multi-type overload */\nexport function useRequirementStatus(\n statusPlugin: StatusPlugin,\n types: string[],\n): ShallowRef<Record<string, RequirementTypeStatus>>;\n/** Implementation */\nexport function useRequirementStatus(\n statusPlugin: StatusPlugin,\n typeOrTypes: string | string[],\n):\n | ShallowRef<RequirementTypeStatus>\n | ShallowRef<Record<string, RequirementTypeStatus>> {\n if (Array.isArray(typeOrTypes)) {\n const getValues = (): Record<string, RequirementTypeStatus> => {\n const result: Record<string, RequirementTypeStatus> = {};\n for (const type of typeOrTypes) {\n result[type] = statusPlugin.getStatus(type);\n }\n return result;\n };\n const state = shallowRef(getValues());\n const unsubscribe = statusPlugin.subscribe(() => {\n state.value = getValues();\n });\n onScopeDispose(unsubscribe);\n return state;\n }\n\n const status = shallowRef<RequirementTypeStatus>(\n statusPlugin.getStatus(typeOrTypes),\n );\n const unsubscribe = statusPlugin.subscribe(() => {\n status.value = statusPlugin.getStatus(typeOrTypes);\n });\n onScopeDispose(unsubscribe);\n return 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 // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n requirementId: string,\n): Ref<string | null> {\n assertSystem(\"useExplain\", system);\n const explanation = ref<string | null>(system.explain(requirementId)) as Ref<\n string | null\n >;\n\n const update = () => {\n explanation.value = system.explain(requirementId);\n };\n\n const unsubFacts = system.facts.$store.subscribeAll(update);\n const unsubSettled = system.onSettledChange(update);\n onScopeDispose(() => {\n unsubFacts();\n unsubSettled();\n });\n\n return explanation;\n}\n\n// ============================================================================\n// useConstraintStatus — reactive constraint inspection\n// ============================================================================\n\n/** Get all constraints */\nexport function useConstraintStatus(\n system: SingleModuleSystem<any>,\n): ComputedRef<ConstraintInfo[]>;\n/** Get a single constraint by ID */\nexport function useConstraintStatus(\n system: SingleModuleSystem<any>,\n constraintId: string,\n): ComputedRef<ConstraintInfo | null>;\n/** Implementation */\nexport function useConstraintStatus(\n // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n constraintId?: string,\n): ComputedRef<ConstraintInfo[] | ConstraintInfo | null> {\n assertSystem(\"useConstraintStatus\", system);\n const inspectState = useInspect(system);\n\n return computed(() => {\n // Track reactivity via inspectState, but use full inspect() for constraint list\n void inspectState.value;\n const fullInspection = system.inspect();\n if (!constraintId) return fullInspection.constraints;\n return (\n fullInspection.constraints.find((c) => c.id === constraintId) ?? null\n );\n });\n}\n\n// ============================================================================\n// useOptimisticUpdate — batch with rollback on failure\n// ============================================================================\n\nexport interface OptimisticUpdateResult {\n mutate: (updateFn: () => void) => void;\n isPending: Ref<boolean>;\n error: Ref<Error | null>;\n rollback: () => 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 // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n statusPlugin?: StatusPlugin,\n requirementType?: string,\n): OptimisticUpdateResult {\n assertSystem(\"useOptimisticUpdate\", system);\n const isPending = ref(false);\n const error = ref<Error | null>(null) as Ref<Error | null>;\n let snapshot: SystemSnapshot | null = null;\n let unsubscribe: (() => void) | null = null;\n\n const rollback = () => {\n if (snapshot) {\n system.restore(snapshot);\n snapshot = null;\n }\n isPending.value = false;\n error.value = null;\n unsubscribe?.();\n unsubscribe = null;\n };\n\n const mutate = (updateFn: () => void) => {\n snapshot = system.getSnapshot();\n isPending.value = true;\n error.value = null;\n system.batch(updateFn);\n\n // Watch for resolver completion/failure\n if (statusPlugin && requirementType) {\n unsubscribe?.();\n unsubscribe = statusPlugin.subscribe(() => {\n const status = statusPlugin.getStatus(requirementType);\n if (!status.isLoading && !status.hasError) {\n snapshot = null;\n isPending.value = false;\n unsubscribe?.();\n unsubscribe = null;\n } else if (status.hasError) {\n error.value = status.lastError;\n rollback();\n }\n });\n }\n };\n\n onScopeDispose(() => {\n unsubscribe?.();\n });\n\n return { mutate, isPending, error, rollback };\n}\n\n// ============================================================================\n// useHistory — reactive history state\n// ============================================================================\n\n/**\n * Reactive history composable. Returns a ShallowRef that updates\n * when snapshots are taken or navigation occurs.\n *\n * @example\n * ```vue\n * const history = useHistory(system);\n * <button :disabled=\"!history.value?.canGoBack\" @click=\"history.value?.goBack()\">Undo</button>\n * ```\n */\nexport function useHistory(\n // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n): ShallowRef<ReturnType<typeof buildHistoryState>> {\n assertSystem(\"useHistory\", system);\n const state = shallowRef<ReturnType<typeof buildHistoryState>>(\n buildHistoryState(system),\n );\n const unsub = system.onHistoryChange(() => {\n state.value = buildHistoryState(system);\n });\n onScopeDispose(unsub);\n return state;\n}\n\n// ============================================================================\n// Scoped System Composable\n// ============================================================================\n\n/** Configuration for useDirective */\ninterface UseDirectiveConfig {\n // biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n plugins?: Plugin<any>[];\n trace?: TraceOption;\n errorBoundary?: ErrorBoundaryConfig;\n tickMs?: number;\n zeroConfig?: boolean;\n // biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n initialFacts?: Record<string, any>;\n status?: boolean;\n /** Fact keys to subscribe to (omit for all) */\n facts?: string[];\n /** Derivation keys to subscribe to (omit for all) */\n derived?: 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 moduleDef: ModuleDef<M>,\n config?: UseDirectiveConfig,\n) {\n const allPlugins = [...(config?.plugins ?? [])];\n let statusPlugin: StatusPlugin | undefined;\n\n if (config?.status) {\n const sp = createRequirementStatusPlugin();\n statusPlugin = sp;\n // biome-ignore lint/suspicious/noExplicitAny: Plugin generic issues\n allPlugins.push(sp.plugin as Plugin<any>);\n }\n\n // biome-ignore lint/suspicious/noExplicitAny: Required for overload compatibility\n const system = createSystem({\n module: moduleDef,\n plugins: allPlugins.length > 0 ? allPlugins : undefined,\n trace: config?.trace,\n errorBoundary: config?.errorBoundary,\n tickMs: config?.tickMs,\n zeroConfig: config?.zeroConfig,\n initialFacts: config?.initialFacts,\n } as any) as unknown as SingleModuleSystem<M>;\n\n system.start();\n\n onScopeDispose(() => {\n system.destroy();\n });\n\n const factKeys = config?.facts;\n const derivedKeys = config?.derived;\n const subscribeAll = !factKeys && !derivedKeys;\n\n // Subscribe to facts\n const factsState = shallowRef(\n subscribeAll\n ? (system.facts.$store.toObject() as InferFacts<M>)\n : pickFacts(system, factKeys ?? []),\n );\n const unsubFacts = subscribeAll\n ? system.facts.$store.subscribeAll(() => {\n factsState.value = system.facts.$store.toObject() as InferFacts<M>;\n })\n : factKeys && factKeys.length > 0\n ? system.facts.$store.subscribe(factKeys, () => {\n factsState.value = pickFacts(system, factKeys) as InferFacts<M>;\n })\n : null;\n\n // Subscribe to derivations\n const allDerivationKeys = subscribeAll\n ? Object.keys(system.derive ?? {})\n : (derivedKeys ?? []);\n const getDerived = (): InferDerivations<M> => {\n const result: Record<string, unknown> = {};\n for (const key of allDerivationKeys) {\n result[key] = system.read(key);\n }\n return result as InferDerivations<M>;\n };\n const derivedState = shallowRef(getDerived());\n const unsubDerived =\n allDerivationKeys.length > 0\n ? system.subscribe(allDerivationKeys, () => {\n derivedState.value = getDerived();\n })\n : null;\n\n onScopeDispose(() => {\n unsubFacts?.();\n unsubDerived?.();\n });\n\n const events = system.events;\n const dispatch = (event: InferEvents<M>) => system.dispatch(event);\n\n return {\n system,\n facts: factsState as ShallowRef<InferFacts<M>>,\n derived: derivedState as ShallowRef<InferDerivations<M>>,\n events,\n dispatch,\n statusPlugin,\n };\n}\n\n// ============================================================================\n// Typed Hooks Factory\n// ============================================================================\n\nexport function createTypedHooks<M extends ModuleSchema>(): {\n useFact: <K extends keyof InferFacts<M> & string>(\n system: SingleModuleSystem<M>,\n factKey: K,\n ) => Ref<InferFacts<M>[K] | undefined>;\n useDerived: <K extends keyof InferDerivations<M> & string>(\n system: SingleModuleSystem<M>,\n derivationId: K,\n ) => Ref<InferDerivations<M>[K]>;\n useDispatch: (\n system: SingleModuleSystem<M>,\n ) => (event: InferEvents<M>) => void;\n useEvents: (system: SingleModuleSystem<M>) => SingleModuleSystem<M>[\"events\"];\n useWatch: <K extends string>(\n system: SingleModuleSystem<M>,\n key: K,\n callback: (newValue: unknown, previousValue: unknown) => void,\n ) => void;\n} {\n return {\n useFact: <K extends keyof InferFacts<M> & string>(\n system: SingleModuleSystem<M>,\n factKey: K,\n ) =>\n // biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n useFact(system as SingleModuleSystem<any>, factKey) as Ref<\n InferFacts<M>[K] | undefined\n >,\n useDerived: <K extends keyof InferDerivations<M> & string>(\n system: SingleModuleSystem<M>,\n derivationId: K,\n ) =>\n // biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n useDerived(system as SingleModuleSystem<any>, derivationId) as Ref<\n InferDerivations<M>[K]\n >,\n useDispatch: (system: SingleModuleSystem<M>) => {\n return (event: InferEvents<M>) => {\n system.dispatch(event);\n };\n },\n useEvents: (system: SingleModuleSystem<M>) => useEvents<M>(system),\n useWatch: <K extends string>(\n system: SingleModuleSystem<M>,\n key: K,\n callback: (newValue: unknown, previousValue: unknown) => void,\n ) =>\n // biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n useWatch(system as SingleModuleSystem<any>, key, callback),\n };\n}\n\n// ============================================================================\n// useNamespacedSelector — select from a NamespacedSystem\n// ============================================================================\n\n/**\n * Reactive composable to select from a NamespacedSystem.\n * Subscribes to specified keys and returns a Vue ref.\n *\n * @param system - The namespaced system\n * @param keys - Namespaced keys to subscribe to (e.g., [\"auth.token\", \"data.count\"])\n * @param selector - Function that reads from system.facts / system.derive\n *\n * @example\n * ```vue\n * const system = useDirectiveRef({ modules: { auth, data } });\n * const token = useNamespacedSelector(system, [\"auth.token\"], (s) => s.facts.auth.token);\n * ```\n */\nexport function useNamespacedSelector<Modules extends ModulesMap, R>(\n system: NamespacedSystem<Modules>,\n keys: string[],\n selector: (system: NamespacedSystem<Modules>) => R,\n): Ref<R> {\n const value = ref(selector(system)) as Ref<R>;\n const unsubscribe = system.subscribe(keys, () => {\n value.value = selector(system) as R;\n });\n onScopeDispose(unsubscribe);\n\n return value;\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
- import { createRequirementStatusPlugin, ModuleSchema, InferFacts, SingleModuleSystem, InferDerivations, InferEvents, ModuleDef, Plugin, DebugConfig, ErrorBoundaryConfig, RequirementTypeStatus, ModulesMap, NamespacedSystem, InferSelectorState } from '@directive-run/core';
1
+ import { createRequirementStatusPlugin, ModuleSchema, InferFacts, SingleModuleSystem, InferDerivations, InferEvents, ModuleDef, Plugin, TraceOption, ErrorBoundaryConfig, RequirementTypeStatus, ModulesMap, NamespacedSystem, InferSelectorState } from '@directive-run/core';
2
2
  export { RequirementTypeStatus } from '@directive-run/core';
3
- import { ConstraintInfo, InspectState, buildTimeTravelState } from '@directive-run/core/adapter-utils';
3
+ import { ConstraintInfo, buildHistoryState, InspectState } from '@directive-run/core/adapter-utils';
4
4
  export { ConstraintInfo, InspectState, shallowEqual } from '@directive-run/core/adapter-utils';
5
5
  import { Ref, ComputedRef, ShallowRef } from 'vue';
6
6
 
@@ -9,7 +9,7 @@ import { Ref, ComputedRef, ShallowRef } from 'vue';
9
9
  *
10
10
  * Exports: useFact, useDerived, useDispatch, useSelector,
11
11
  * useWatch, useInspect, useRequirementStatus, useEvents, useExplain,
12
- * useConstraintStatus, useOptimisticUpdate, useDirective, useTimeTravel,
12
+ * useConstraintStatus, useOptimisticUpdate, useDirective, useHistory,
13
13
  * createTypedHooks, shallowEqual
14
14
  */
15
15
 
@@ -71,20 +71,20 @@ interface OptimisticUpdateResult {
71
71
  */
72
72
  declare function useOptimisticUpdate(system: SingleModuleSystem<any>, statusPlugin?: StatusPlugin, requirementType?: string): OptimisticUpdateResult;
73
73
  /**
74
- * Reactive time-travel composable. Returns a ShallowRef that updates
74
+ * Reactive history composable. Returns a ShallowRef that updates
75
75
  * when snapshots are taken or navigation occurs.
76
76
  *
77
77
  * @example
78
78
  * ```vue
79
- * const tt = useTimeTravel(system);
80
- * <button :disabled="!tt.value?.canUndo" @click="tt.value?.undo()">Undo</button>
79
+ * const history = useHistory(system);
80
+ * <button :disabled="!history.value?.canGoBack" @click="history.value?.goBack()">Undo</button>
81
81
  * ```
82
82
  */
83
- declare function useTimeTravel(system: SingleModuleSystem<any>): ShallowRef<ReturnType<typeof buildTimeTravelState>>;
83
+ declare function useHistory(system: SingleModuleSystem<any>): ShallowRef<ReturnType<typeof buildHistoryState>>;
84
84
  /** Configuration for useDirective */
85
85
  interface UseDirectiveConfig {
86
86
  plugins?: Plugin<any>[];
87
- debug?: DebugConfig;
87
+ trace?: TraceOption;
88
88
  errorBoundary?: ErrorBoundaryConfig;
89
89
  tickMs?: number;
90
90
  zeroConfig?: boolean;
@@ -148,4 +148,4 @@ declare function createTypedHooks<M extends ModuleSchema>(): {
148
148
  */
149
149
  declare function useNamespacedSelector<Modules extends ModulesMap, R>(system: NamespacedSystem<Modules>, keys: string[], selector: (system: NamespacedSystem<Modules>) => R): Ref<R>;
150
150
 
151
- export { type OptimisticUpdateResult, type StatusPlugin, type UseInspectOptions, createTypedHooks, useConstraintStatus, useDerived, useDirective, useDispatch, useEvents, useExplain, useFact, useInspect, useNamespacedSelector, useOptimisticUpdate, useRequirementStatus, useSelector, useTimeTravel, useWatch };
151
+ export { type OptimisticUpdateResult, type StatusPlugin, type UseInspectOptions, createTypedHooks, useConstraintStatus, useDerived, useDirective, useDispatch, useEvents, useExplain, useFact, useHistory, useInspect, useNamespacedSelector, useOptimisticUpdate, useRequirementStatus, useSelector, useWatch };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { createRequirementStatusPlugin, ModuleSchema, InferFacts, SingleModuleSystem, InferDerivations, InferEvents, ModuleDef, Plugin, DebugConfig, ErrorBoundaryConfig, RequirementTypeStatus, ModulesMap, NamespacedSystem, InferSelectorState } from '@directive-run/core';
1
+ import { createRequirementStatusPlugin, ModuleSchema, InferFacts, SingleModuleSystem, InferDerivations, InferEvents, ModuleDef, Plugin, TraceOption, ErrorBoundaryConfig, RequirementTypeStatus, ModulesMap, NamespacedSystem, InferSelectorState } from '@directive-run/core';
2
2
  export { RequirementTypeStatus } from '@directive-run/core';
3
- import { ConstraintInfo, InspectState, buildTimeTravelState } from '@directive-run/core/adapter-utils';
3
+ import { ConstraintInfo, buildHistoryState, InspectState } from '@directive-run/core/adapter-utils';
4
4
  export { ConstraintInfo, InspectState, shallowEqual } from '@directive-run/core/adapter-utils';
5
5
  import { Ref, ComputedRef, ShallowRef } from 'vue';
6
6
 
@@ -9,7 +9,7 @@ import { Ref, ComputedRef, ShallowRef } from 'vue';
9
9
  *
10
10
  * Exports: useFact, useDerived, useDispatch, useSelector,
11
11
  * useWatch, useInspect, useRequirementStatus, useEvents, useExplain,
12
- * useConstraintStatus, useOptimisticUpdate, useDirective, useTimeTravel,
12
+ * useConstraintStatus, useOptimisticUpdate, useDirective, useHistory,
13
13
  * createTypedHooks, shallowEqual
14
14
  */
15
15
 
@@ -71,20 +71,20 @@ interface OptimisticUpdateResult {
71
71
  */
72
72
  declare function useOptimisticUpdate(system: SingleModuleSystem<any>, statusPlugin?: StatusPlugin, requirementType?: string): OptimisticUpdateResult;
73
73
  /**
74
- * Reactive time-travel composable. Returns a ShallowRef that updates
74
+ * Reactive history composable. Returns a ShallowRef that updates
75
75
  * when snapshots are taken or navigation occurs.
76
76
  *
77
77
  * @example
78
78
  * ```vue
79
- * const tt = useTimeTravel(system);
80
- * <button :disabled="!tt.value?.canUndo" @click="tt.value?.undo()">Undo</button>
79
+ * const history = useHistory(system);
80
+ * <button :disabled="!history.value?.canGoBack" @click="history.value?.goBack()">Undo</button>
81
81
  * ```
82
82
  */
83
- declare function useTimeTravel(system: SingleModuleSystem<any>): ShallowRef<ReturnType<typeof buildTimeTravelState>>;
83
+ declare function useHistory(system: SingleModuleSystem<any>): ShallowRef<ReturnType<typeof buildHistoryState>>;
84
84
  /** Configuration for useDirective */
85
85
  interface UseDirectiveConfig {
86
86
  plugins?: Plugin<any>[];
87
- debug?: DebugConfig;
87
+ trace?: TraceOption;
88
88
  errorBoundary?: ErrorBoundaryConfig;
89
89
  tickMs?: number;
90
90
  zeroConfig?: boolean;
@@ -148,4 +148,4 @@ declare function createTypedHooks<M extends ModuleSchema>(): {
148
148
  */
149
149
  declare function useNamespacedSelector<Modules extends ModulesMap, R>(system: NamespacedSystem<Modules>, keys: string[], selector: (system: NamespacedSystem<Modules>) => R): Ref<R>;
150
150
 
151
- export { type OptimisticUpdateResult, type StatusPlugin, type UseInspectOptions, createTypedHooks, useConstraintStatus, useDerived, useDirective, useDispatch, useEvents, useExplain, useFact, useInspect, useNamespacedSelector, useOptimisticUpdate, useRequirementStatus, useSelector, useTimeTravel, useWatch };
151
+ export { type OptimisticUpdateResult, type StatusPlugin, type UseInspectOptions, createTypedHooks, useConstraintStatus, useDerived, useDirective, useDispatch, useEvents, useExplain, useFact, useHistory, useInspect, useNamespacedSelector, useOptimisticUpdate, useRequirementStatus, useSelector, useWatch };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- 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';import {ref,onScopeDispose,shallowRef,computed}from'vue';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 p=()=>{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,p)):i.length===0&&S.push(e.facts.$store.subscribeAll(p)),i.length>0&&S.push(e.subscribe(i,p));};return c(),onScopeDispose(()=>{for(let p of S)p();}),l}function H(e){return assertSystem("useDispatch",e),t=>{e.dispatch(t);}}function P(e){return assertSystem("useEvents",e),e.events}function N(e,t,s){assertSystem("useWatch",e);let o=e.watch(t,s);onScopeDispose(o);}function U(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=U(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??[],p=()=>{let v={};for(let M of c)v[M]=n.read(M);return v},d=shallowRef(p()),h=c.length>0?n.subscribe(c,()=>{d.value=p();}):null;onScopeDispose(()=>{S?.(),h?.();});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)=>N(e,t,s)}}function ee(e,t,s){let o=ref(s(e)),n=e.subscribe(t,()=>{o.value=s(e);});return onScopeDispose(n),o}export{Z as createTypedHooks,J as useConstraintStatus,$ as useDerived,Y as useDirective,H as useDispatch,P as useEvents,G as useExplain,E as useFact,U as useInspect,ee as useNamespacedSelector,Q as useOptimisticUpdate,L as useRequirementStatus,z as useSelector,X as useTimeTravel,N as useWatch};//# sourceMappingURL=index.js.map
1
+ import {createRequirementStatusPlugin,createSystem}from'@directive-run/core';import {defaultEquality,assertSystem,computeInspectState,createThrottle,buildHistoryState,pickFacts,runTrackedSelector,depsChanged}from'@directive-run/core/adapter-utils';export{shallowEqual}from'@directive-run/core/adapter-utils';import {ref,onScopeDispose,shallowRef,computed}from'vue';function C(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)?$(e,t):V(e,t)}function V(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 $(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 q(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):T(e,t)}function T(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 j(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 p=()=>{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,p)):i.length===0&&S.push(e.facts.$store.subscribeAll(p)),i.length>0&&S.push(e.subscribe(i,p));};return c(),onScopeDispose(()=>{for(let p of S)p();}),l}function z(e){return assertSystem("useDispatch",e),t=>{e.dispatch(t);}}function P(e){return assertSystem("useEvents",e),e.events}function N(e,t,s){assertSystem("useWatch",e);let o=e.watch(t,s);onScopeDispose(o);}function U(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=U(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("useHistory",e);let t=shallowRef(buildHistoryState(e)),s=e.onHistoryChange(()=>{t.value=buildHistoryState(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,trace:t?.trace,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??[],p=()=>{let v={};for(let M of c)v[M]=n.read(M);return v},d=shallowRef(p()),h=c.length>0?n.subscribe(c,()=>{d.value=p();}):null;onScopeDispose(()=>{S?.(),h?.();});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)=>C(e,t),useDerived:(e,t)=>q(e,t),useDispatch:e=>t=>{e.dispatch(t);},useEvents:e=>P(e),useWatch:(e,t,s)=>N(e,t,s)}}function ee(e,t,s){let o=ref(s(e)),n=e.subscribe(t,()=>{o.value=s(e);});return onScopeDispose(n),o}export{Z as createTypedHooks,J as useConstraintStatus,q as useDerived,Y as useDirective,z as useDispatch,P as useEvents,G as useExplain,C as useFact,X as useHistory,U as useInspect,ee as useNamespacedSelector,Q as useOptimisticUpdate,L as useRequirementStatus,j as useSelector,N 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","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","useNamespacedSelector","keys"],"mappings":"gXA6EO,SAASA,CAAAA,CAEdC,CAAAA,CACAC,CAAAA,CACoC,CAapC,OAZAC,YAAAA,CAAa,UAAWF,CAAM,CAAA,CAE5B,OAAA,CAAQ,GAAA,CAAI,WAAa,YAAA,EACzB,OAAOC,CAAAA,EAAc,UAAA,EAErB,QAAQ,KAAA,CACN,gJAEF,CAAA,CAIE,KAAA,CAAM,QAAQA,CAAS,CAAA,CAClBE,CAAAA,CAAcH,CAAAA,CAAQC,CAAS,CAAA,CAIjCG,CAAAA,CAAeJ,CAAAA,CAAQC,CAAS,CACzC,CAGA,SAASG,CAAAA,CACPJ,CAAAA,CACAK,EACc,CACV,OAAA,CAAQ,GAAA,CAAI,QAAA,GAAa,YAAA,GACtBL,CAAAA,CAAO,KAAA,CAAM,MAAA,CAAO,IAAIK,CAAO,CAAA,EAClC,OAAA,CAAQ,IAAA,CACN,wBAAwBA,CAAO,CAAA,+CAAA,EACdA,CAAO,CAAA,qCAAA,CAC1B,GAIJ,IAAMC,CAAAA,CAAQC,GAAAA,CAAIP,CAAAA,CAAO,KAAA,CAAM,MAAA,CAAO,GAAA,CAAIK,CAAO,CAAC,CAAA,CAC5CG,CAAAA,CAAcR,CAAAA,CAAO,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AAU,CACRA,EACAa,CAAAA,CACA8B,CAAAA,GAGAD,CAAAA,CAAS1C,CAAAA,CAAmCa,CAAAA,CAAK8B,CAAQ,CAC7D,CACF,CAoBO,SAASmD,EAAAA,CACd9F,CAAAA,CACA+F,CAAAA,CACAvE,EACQ,CACR,IAAMlB,CAAAA,CAAQC,GAAAA,CAAIiB,EAASxB,CAAM,CAAC,CAAA,CAC5BQ,CAAAA,CAAcR,EAAO,SAAA,CAAU+F,CAAAA,CAAM,IAAM,CAC/CzF,EAAM,KAAA,CAAQkB,CAAAA,CAASxB,CAAM,EAC/B,CAAC,CAAA,CACD,OAAAS,cAAAA,CAAeD,CAAW,EAEnBF,CACT","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 type {\n DebugConfig,\n ErrorBoundaryConfig,\n InferDerivations,\n InferEvents,\n InferFacts,\n InferSelectorState,\n ModuleDef,\n ModuleSchema,\n ModulesMap,\n NamespacedSystem,\n Plugin,\n SingleModuleSystem,\n SystemSnapshot,\n} from \"@directive-run/core\";\nimport {\n createRequirementStatusPlugin,\n createSystem,\n} from \"@directive-run/core\";\nimport type { RequirementTypeStatus } from \"@directive-run/core\";\nimport {\n type ConstraintInfo,\n type InspectState,\n assertSystem,\n buildTimeTravelState,\n computeInspectState,\n createThrottle,\n defaultEquality,\n depsChanged,\n pickFacts,\n runTrackedSelector,\n shallowEqual,\n} from \"@directive-run/core/adapter-utils\";\nimport {\n type ComputedRef,\n type Ref,\n type ShallowRef,\n computed,\n onScopeDispose,\n ref,\n shallowRef,\n} from \"vue\";\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<\n S extends ModuleSchema,\n K extends keyof InferFacts<S> & string,\n>(system: SingleModuleSystem<S>, factKey: K): Ref<InferFacts<S>[K] | undefined>;\n/** Multi-key overload */\nexport function useFact<\n S extends ModuleSchema,\n K extends keyof InferFacts<S> & string,\n>(\n system: SingleModuleSystem<S>,\n factKeys: K[],\n): ShallowRef<Pick<InferFacts<S>, K>>;\n/** Implementation */\nexport function useFact(\n // biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n system: SingleModuleSystem<any>,\n keyOrKeys: string | string[],\n): Ref<unknown> | ShallowRef<unknown> {\n assertSystem(\"useFact\", system);\n if (\n process.env.NODE_ENV !== \"production\" &&\n typeof keyOrKeys === \"function\"\n ) {\n console.error(\n \"[Directive] useFact() received a function. Did you mean useSelector()? \" +\n \"useFact() takes a string key or array of keys, not a selector function.\",\n );\n }\n\n // Multi-key path: useFact(system, [keys])\n if (Array.isArray(keyOrKeys)) {\n return _useFactMulti(system, keyOrKeys);\n }\n\n // Single key path: useFact(system, key)\n return _useFactSingle(system, keyOrKeys);\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useFactSingle(\n system: SingleModuleSystem<any>,\n factKey: string,\n): Ref<unknown> {\n if (process.env.NODE_ENV !== \"production\") {\n if (!system.facts.$store.has(factKey)) {\n console.warn(\n `[Directive] useFact(\"${factKey}\") — fact not found in store. ` +\n `Check that \"${factKey}\" is defined in your module's schema.`,\n );\n }\n }\n\n const value = ref(system.facts.$store.get(factKey));\n const unsubscribe = system.facts.$store.subscribe([factKey], () => {\n value.value = system.facts.$store.get(factKey);\n });\n onScopeDispose(unsubscribe);\n return value;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useFactMulti(\n system: SingleModuleSystem<any>,\n factKeys: string[],\n): ShallowRef<Record<string, unknown>> {\n const getValues = (): Record<string, unknown> => {\n const result: Record<string, unknown> = {};\n for (const key of factKeys) {\n result[key] = system.facts.$store.get(key);\n }\n return result;\n };\n const state = shallowRef(getValues());\n const unsubscribe = system.facts.$store.subscribe(factKeys, () => {\n state.value = getValues();\n });\n onScopeDispose(unsubscribe);\n return state;\n}\n\n// ============================================================================\n// useDerived — single key or multi key\n// ============================================================================\n\n/** Single key overload */\nexport function useDerived<\n S extends ModuleSchema,\n K extends keyof InferDerivations<S> & string,\n>(system: SingleModuleSystem<S>, derivationId: K): Ref<InferDerivations<S>[K]>;\n/** Multi-key overload */\nexport function useDerived<\n S extends ModuleSchema,\n K extends keyof InferDerivations<S> & string,\n>(\n system: SingleModuleSystem<S>,\n derivationIds: K[],\n): ShallowRef<Pick<InferDerivations<S>, K>>;\n/** Implementation */\nexport function useDerived(\n // biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n system: SingleModuleSystem<any>,\n idOrIds: string | string[],\n): Ref<unknown> | ShallowRef<unknown> {\n assertSystem(\"useDerived\", system);\n if (process.env.NODE_ENV !== \"production\" && typeof idOrIds === \"function\") {\n console.error(\n \"[Directive] useDerived() received a function. Did you mean useSelector()? \" +\n \"useDerived() takes a string key or array of keys, not a selector function.\",\n );\n }\n\n // Multi-key path\n if (Array.isArray(idOrIds)) {\n return _useDerivedMulti(system, idOrIds);\n }\n\n // Single key path\n return _useDerivedSingle(system, idOrIds);\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useDerivedSingle(\n system: SingleModuleSystem<any>,\n derivationId: string,\n): Ref<unknown> {\n if (process.env.NODE_ENV !== \"production\") {\n const initialValue = system.read(derivationId);\n if (initialValue === undefined) {\n console.warn(\n `[Directive] useDerived(\"${derivationId}\") returned undefined. ` +\n `Check that \"${derivationId}\" is defined in your module's derive property.`,\n );\n }\n }\n const value = ref(system.read(derivationId));\n const unsubscribe = system.subscribe([derivationId], () => {\n value.value = system.read(derivationId);\n });\n onScopeDispose(unsubscribe);\n return value;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useDerivedMulti(\n system: SingleModuleSystem<any>,\n derivationIds: string[],\n): ShallowRef<Record<string, unknown>> {\n const getValues = (): Record<string, unknown> => {\n const result: Record<string, unknown> = {};\n for (const id of derivationIds) {\n result[id] = system.read(id);\n }\n return result;\n };\n const state = shallowRef(getValues());\n const unsubscribe = system.subscribe(derivationIds, () => {\n state.value = getValues();\n });\n onScopeDispose(unsubscribe);\n return 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>(\n system: SingleModuleSystem<S>,\n selector: (state: InferSelectorState<S>) => R,\n equalityFn?: (a: R, b: R) => boolean,\n): Ref<R>;\nexport function useSelector(\n // biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n system: SingleModuleSystem<any>,\n selector: (state: Record<string, unknown>) => unknown,\n equalityFn: (a: unknown, b: unknown) => boolean = defaultEquality,\n): Ref<unknown> {\n assertSystem(\"useSelector\", system);\n const deriveKeySet = new Set(Object.keys(system.derive ?? {}));\n\n const runWithTracking = () =>\n runTrackedSelector(system, deriveKeySet, selector);\n\n const initial = runWithTracking();\n let trackedFactKeys = initial.factKeys;\n let trackedDeriveKeys = initial.deriveKeys;\n const selected = ref(initial.value);\n\n const unsubs: Array<() => void> = [];\n\n const resubscribe = () => {\n for (const unsub of unsubs) unsub();\n unsubs.length = 0;\n\n const onUpdate = () => {\n const result = runWithTracking();\n if (!equalityFn(selected.value, result.value)) {\n selected.value = result.value;\n }\n // Re-track: check if deps changed\n if (\n depsChanged(\n trackedFactKeys,\n result.factKeys,\n trackedDeriveKeys,\n result.deriveKeys,\n )\n ) {\n trackedFactKeys = result.factKeys;\n trackedDeriveKeys = result.deriveKeys;\n resubscribe();\n }\n };\n\n if (trackedFactKeys.length > 0) {\n unsubs.push(system.facts.$store.subscribe(trackedFactKeys, onUpdate));\n } else if (trackedDeriveKeys.length === 0) {\n unsubs.push(system.facts.$store.subscribeAll(onUpdate));\n }\n if (trackedDeriveKeys.length > 0) {\n unsubs.push(system.subscribe(trackedDeriveKeys, onUpdate));\n }\n };\n\n resubscribe();\n\n onScopeDispose(() => {\n for (const unsub of unsubs) unsub();\n });\n\n return selected;\n}\n\n// ============================================================================\n// useDispatch\n// ============================================================================\n\nexport function useDispatch<S extends ModuleSchema>(\n system: SingleModuleSystem<S>,\n): (event: InferEvents<S>) => void {\n assertSystem(\"useDispatch\", system);\n return (event: InferEvents<S>) => {\n system.dispatch(event);\n };\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 system: SingleModuleSystem<S>,\n): SingleModuleSystem<S>[\"events\"] {\n assertSystem(\"useEvents\", system);\n return 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<\n S extends ModuleSchema,\n K extends keyof InferDerivations<S> & string,\n>(\n system: SingleModuleSystem<S>,\n key: K,\n callback: (\n newValue: InferDerivations<S>[K],\n previousValue: InferDerivations<S>[K] | undefined,\n ) => void,\n): void;\n/** Watch a fact key with auto-detection. */\nexport function useWatch<\n S extends ModuleSchema,\n K extends keyof InferFacts<S> & string,\n>(\n system: SingleModuleSystem<S>,\n key: K,\n callback: (\n newValue: InferFacts<S>[K] | undefined,\n previousValue: InferFacts<S>[K] | undefined,\n ) => void,\n): void;\n/** Implementation */\nexport function useWatch(\n // biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n system: SingleModuleSystem<any>,\n key: string,\n callback: (newValue: unknown, prevValue: unknown) => void,\n): void {\n assertSystem(\"useWatch\", system);\n\n const unsubscribe = system.watch(key, callback);\n onScopeDispose(unsubscribe);\n}\n\n// ============================================================================\n// useInspect — consolidated inspection hook\n// ============================================================================\n\n/** Options for useInspect */\nexport interface UseInspectOptions {\n throttleMs?: number;\n}\n\n/**\n * Consolidated system inspection hook.\n * Returns InspectState with optional throttling.\n */\nexport function useInspect(\n // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n options?: UseInspectOptions,\n): ShallowRef<InspectState> {\n assertSystem(\"useInspect\", system);\n const state = shallowRef<InspectState>(computeInspectState(system));\n\n const update = () => {\n state.value = computeInspectState(system);\n };\n\n if (options?.throttleMs && options.throttleMs > 0) {\n const { throttled, cleanup } = createThrottle(update, options.throttleMs);\n const unsubFacts = system.facts.$store.subscribeAll(throttled);\n const unsubSettled = system.onSettledChange(throttled);\n onScopeDispose(() => {\n cleanup();\n unsubFacts();\n unsubSettled();\n });\n } else {\n const unsubFacts = system.facts.$store.subscribeAll(update);\n const unsubSettled = system.onSettledChange(update);\n onScopeDispose(() => {\n unsubFacts();\n unsubSettled();\n });\n }\n\n return state;\n}\n\n// ============================================================================\n// useRequirementStatus — single or multi\n// ============================================================================\n\n/** Single type overload */\nexport function useRequirementStatus(\n statusPlugin: StatusPlugin,\n type: string,\n): ShallowRef<RequirementTypeStatus>;\n/** Multi-type overload */\nexport function useRequirementStatus(\n statusPlugin: StatusPlugin,\n types: string[],\n): ShallowRef<Record<string, RequirementTypeStatus>>;\n/** Implementation */\nexport function useRequirementStatus(\n statusPlugin: StatusPlugin,\n typeOrTypes: string | string[],\n):\n | ShallowRef<RequirementTypeStatus>\n | ShallowRef<Record<string, RequirementTypeStatus>> {\n if (Array.isArray(typeOrTypes)) {\n const getValues = (): Record<string, RequirementTypeStatus> => {\n const result: Record<string, RequirementTypeStatus> = {};\n for (const type of typeOrTypes) {\n result[type] = statusPlugin.getStatus(type);\n }\n return result;\n };\n const state = shallowRef(getValues());\n const unsubscribe = statusPlugin.subscribe(() => {\n state.value = getValues();\n });\n onScopeDispose(unsubscribe);\n return state;\n }\n\n const status = shallowRef<RequirementTypeStatus>(\n statusPlugin.getStatus(typeOrTypes),\n );\n const unsubscribe = statusPlugin.subscribe(() => {\n status.value = statusPlugin.getStatus(typeOrTypes);\n });\n onScopeDispose(unsubscribe);\n return 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 // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n requirementId: string,\n): Ref<string | null> {\n assertSystem(\"useExplain\", system);\n const explanation = ref<string | null>(system.explain(requirementId)) as Ref<\n string | null\n >;\n\n const update = () => {\n explanation.value = system.explain(requirementId);\n };\n\n const unsubFacts = system.facts.$store.subscribeAll(update);\n const unsubSettled = system.onSettledChange(update);\n onScopeDispose(() => {\n unsubFacts();\n unsubSettled();\n });\n\n return explanation;\n}\n\n// ============================================================================\n// useConstraintStatus — reactive constraint inspection\n// ============================================================================\n\n/** Get all constraints */\nexport function useConstraintStatus(\n system: SingleModuleSystem<any>,\n): ComputedRef<ConstraintInfo[]>;\n/** Get a single constraint by ID */\nexport function useConstraintStatus(\n system: SingleModuleSystem<any>,\n constraintId: string,\n): ComputedRef<ConstraintInfo | null>;\n/** Implementation */\nexport function useConstraintStatus(\n // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n constraintId?: string,\n): ComputedRef<ConstraintInfo[] | ConstraintInfo | null> {\n assertSystem(\"useConstraintStatus\", system);\n const inspectState = useInspect(system);\n\n return computed(() => {\n // Track reactivity via inspectState, but use full inspect() for constraint list\n void inspectState.value;\n const fullInspection = system.inspect();\n if (!constraintId) return fullInspection.constraints;\n return (\n fullInspection.constraints.find((c) => c.id === constraintId) ?? null\n );\n });\n}\n\n// ============================================================================\n// useOptimisticUpdate — batch with rollback on failure\n// ============================================================================\n\nexport interface OptimisticUpdateResult {\n mutate: (updateFn: () => void) => void;\n isPending: Ref<boolean>;\n error: Ref<Error | null>;\n rollback: () => 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 // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n statusPlugin?: StatusPlugin,\n requirementType?: string,\n): OptimisticUpdateResult {\n assertSystem(\"useOptimisticUpdate\", system);\n const isPending = ref(false);\n const error = ref<Error | null>(null) as Ref<Error | null>;\n let snapshot: SystemSnapshot | null = null;\n let unsubscribe: (() => void) | null = null;\n\n const rollback = () => {\n if (snapshot) {\n system.restore(snapshot);\n snapshot = null;\n }\n isPending.value = false;\n error.value = null;\n unsubscribe?.();\n unsubscribe = null;\n };\n\n const mutate = (updateFn: () => void) => {\n snapshot = system.getSnapshot();\n isPending.value = true;\n error.value = null;\n system.batch(updateFn);\n\n // Watch for resolver completion/failure\n if (statusPlugin && requirementType) {\n unsubscribe?.();\n unsubscribe = statusPlugin.subscribe(() => {\n const status = statusPlugin.getStatus(requirementType);\n if (!status.isLoading && !status.hasError) {\n snapshot = null;\n isPending.value = false;\n unsubscribe?.();\n unsubscribe = null;\n } else if (status.hasError) {\n error.value = status.lastError;\n rollback();\n }\n });\n }\n };\n\n onScopeDispose(() => {\n unsubscribe?.();\n });\n\n return { 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 // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n): ShallowRef<ReturnType<typeof buildTimeTravelState>> {\n assertSystem(\"useTimeTravel\", system);\n const state = shallowRef<ReturnType<typeof buildTimeTravelState>>(\n buildTimeTravelState(system),\n );\n const unsub = system.onTimeTravelChange(() => {\n state.value = buildTimeTravelState(system);\n });\n onScopeDispose(unsub);\n return state;\n}\n\n// ============================================================================\n// Scoped System Composable\n// ============================================================================\n\n/** Configuration for useDirective */\ninterface UseDirectiveConfig {\n // biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n plugins?: Plugin<any>[];\n debug?: DebugConfig;\n errorBoundary?: ErrorBoundaryConfig;\n tickMs?: number;\n zeroConfig?: boolean;\n // biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n initialFacts?: Record<string, any>;\n status?: boolean;\n /** Fact keys to subscribe to (omit for all) */\n facts?: string[];\n /** Derivation keys to subscribe to (omit for all) */\n derived?: 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 moduleDef: ModuleDef<M>,\n config?: UseDirectiveConfig,\n) {\n const allPlugins = [...(config?.plugins ?? [])];\n let statusPlugin: StatusPlugin | undefined;\n\n if (config?.status) {\n const sp = createRequirementStatusPlugin();\n statusPlugin = sp;\n // biome-ignore lint/suspicious/noExplicitAny: Plugin generic issues\n allPlugins.push(sp.plugin as Plugin<any>);\n }\n\n // biome-ignore lint/suspicious/noExplicitAny: Required for overload compatibility\n const system = createSystem({\n module: moduleDef,\n plugins: allPlugins.length > 0 ? allPlugins : undefined,\n debug: config?.debug,\n errorBoundary: config?.errorBoundary,\n tickMs: config?.tickMs,\n zeroConfig: config?.zeroConfig,\n initialFacts: config?.initialFacts,\n } as any) as unknown as SingleModuleSystem<M>;\n\n system.start();\n\n onScopeDispose(() => {\n system.destroy();\n });\n\n const factKeys = config?.facts;\n const derivedKeys = config?.derived;\n const subscribeAll = !factKeys && !derivedKeys;\n\n // Subscribe to facts\n const factsState = shallowRef(\n subscribeAll\n ? (system.facts.$store.toObject() as InferFacts<M>)\n : pickFacts(system, factKeys ?? []),\n );\n const unsubFacts = subscribeAll\n ? system.facts.$store.subscribeAll(() => {\n factsState.value = system.facts.$store.toObject() as InferFacts<M>;\n })\n : factKeys && factKeys.length > 0\n ? system.facts.$store.subscribe(factKeys, () => {\n factsState.value = pickFacts(system, factKeys) as InferFacts<M>;\n })\n : null;\n\n // Subscribe to derivations\n const allDerivationKeys = subscribeAll\n ? Object.keys(system.derive ?? {})\n : (derivedKeys ?? []);\n const getDerived = (): InferDerivations<M> => {\n const result: Record<string, unknown> = {};\n for (const key of allDerivationKeys) {\n result[key] = system.read(key);\n }\n return result as InferDerivations<M>;\n };\n const derivedState = shallowRef(getDerived());\n const unsubDerived =\n allDerivationKeys.length > 0\n ? system.subscribe(allDerivationKeys, () => {\n derivedState.value = getDerived();\n })\n : null;\n\n onScopeDispose(() => {\n unsubFacts?.();\n unsubDerived?.();\n });\n\n const events = system.events;\n const dispatch = (event: InferEvents<M>) => system.dispatch(event);\n\n return {\n system,\n facts: factsState as ShallowRef<InferFacts<M>>,\n derived: derivedState as ShallowRef<InferDerivations<M>>,\n events,\n dispatch,\n statusPlugin,\n };\n}\n\n// ============================================================================\n// Typed Hooks Factory\n// ============================================================================\n\nexport function createTypedHooks<M extends ModuleSchema>(): {\n useFact: <K extends keyof InferFacts<M> & string>(\n system: SingleModuleSystem<M>,\n factKey: K,\n ) => Ref<InferFacts<M>[K] | undefined>;\n useDerived: <K extends keyof InferDerivations<M> & string>(\n system: SingleModuleSystem<M>,\n derivationId: K,\n ) => Ref<InferDerivations<M>[K]>;\n useDispatch: (\n system: SingleModuleSystem<M>,\n ) => (event: InferEvents<M>) => void;\n useEvents: (system: SingleModuleSystem<M>) => SingleModuleSystem<M>[\"events\"];\n useWatch: <K extends string>(\n system: SingleModuleSystem<M>,\n key: K,\n callback: (newValue: unknown, previousValue: unknown) => void,\n ) => void;\n} {\n return {\n useFact: <K extends keyof InferFacts<M> & string>(\n system: SingleModuleSystem<M>,\n factKey: K,\n ) =>\n // biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n useFact(system as SingleModuleSystem<any>, factKey) as Ref<\n InferFacts<M>[K] | undefined\n >,\n useDerived: <K extends keyof InferDerivations<M> & string>(\n system: SingleModuleSystem<M>,\n derivationId: K,\n ) =>\n // biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n useDerived(system as SingleModuleSystem<any>, derivationId) as Ref<\n InferDerivations<M>[K]\n >,\n useDispatch: (system: SingleModuleSystem<M>) => {\n return (event: InferEvents<M>) => {\n system.dispatch(event);\n };\n },\n useEvents: (system: SingleModuleSystem<M>) => useEvents<M>(system),\n useWatch: <K extends string>(\n system: SingleModuleSystem<M>,\n key: K,\n callback: (newValue: unknown, previousValue: unknown) => void,\n ) =>\n // biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n useWatch(system as SingleModuleSystem<any>, key, callback),\n };\n}\n\n// ============================================================================\n// useNamespacedSelector — select from a NamespacedSystem\n// ============================================================================\n\n/**\n * Reactive composable to select from a NamespacedSystem.\n * Subscribes to specified keys and returns a Vue ref.\n *\n * @param system - The namespaced system\n * @param keys - Namespaced keys to subscribe to (e.g., [\"auth.token\", \"data.count\"])\n * @param selector - Function that reads from system.facts / system.derive\n *\n * @example\n * ```vue\n * const system = useDirectiveRef({ modules: { auth, data } });\n * const token = useNamespacedSelector(system, [\"auth.token\"], (s) => s.facts.auth.token);\n * ```\n */\nexport function useNamespacedSelector<Modules extends ModulesMap, R>(\n system: NamespacedSystem<Modules>,\n keys: string[],\n selector: (system: NamespacedSystem<Modules>) => R,\n): Ref<R> {\n const value = ref(selector(system)) as Ref<R>;\n const unsubscribe = system.subscribe(keys, () => {\n value.value = selector(system) as R;\n });\n onScopeDispose(unsubscribe);\n\n return value;\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","useHistory","buildHistoryState","useDirective","moduleDef","config","allPlugins","sp","createRequirementStatusPlugin","createSystem","derivedKeys","subscribeAll","factsState","pickFacts","allDerivationKeys","getDerived","derivedState","unsubDerived","events","createTypedHooks","useNamespacedSelector","keys"],"mappings":"6WA6EO,SAASA,CAAAA,CAEdC,CAAAA,CACAC,CAAAA,CACoC,CAapC,OAZAC,YAAAA,CAAa,UAAWF,CAAM,CAAA,CAE5B,OAAA,CAAQ,GAAA,CAAI,WAAa,YAAA,EACzB,OAAOC,CAAAA,EAAc,UAAA,EAErB,QAAQ,KAAA,CACN,gJAEF,CAAA,CAIE,KAAA,CAAM,QAAQA,CAAS,CAAA,CAClBE,CAAAA,CAAcH,CAAAA,CAAQC,CAAS,CAAA,CAIjCG,CAAAA,CAAeJ,CAAAA,CAAQC,CAAS,CACzC,CAGA,SAASG,CAAAA,CACPJ,CAAAA,CACAK,EACc,CACV,OAAA,CAAQ,GAAA,CAAI,QAAA,GAAa,YAAA,GACtBL,CAAAA,CAAO,KAAA,CAAM,MAAA,CAAO,IAAIK,CAAO,CAAA,EAClC,OAAA,CAAQ,IAAA,CACN,wBAAwBA,CAAO,CAAA,+CAAA,EACdA,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A,CAG5D,WAAA,CAAcpB,GACJwC,CAAAA,EAA0B,CAChCxC,CAAAA,CAAO,QAAA,CAASwC,CAAK,EACvB,CAAA,CAEF,SAAA,CAAYxC,CAAAA,EAAkCyC,EAAazC,CAAM,CAAA,CACjE,QAAA,CAAU,CACRA,EACAa,CAAAA,CACA8B,CAAAA,GAGAD,CAAAA,CAAS1C,CAAAA,CAAmCa,CAAAA,CAAK8B,CAAQ,CAC7D,CACF,CAoBO,SAASmD,EAAAA,CACd9F,CAAAA,CACA+F,CAAAA,CACAvE,EACQ,CACR,IAAMlB,CAAAA,CAAQC,GAAAA,CAAIiB,EAASxB,CAAM,CAAC,CAAA,CAC5BQ,CAAAA,CAAcR,EAAO,SAAA,CAAU+F,CAAAA,CAAM,IAAM,CAC/CzF,EAAM,KAAA,CAAQkB,CAAAA,CAASxB,CAAM,EAC/B,CAAC,CAAA,CACD,OAAAS,cAAAA,CAAeD,CAAW,EAEnBF,CACT","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, useHistory,\n * createTypedHooks, shallowEqual\n */\n\nimport type {\n TraceOption,\n ErrorBoundaryConfig,\n InferDerivations,\n InferEvents,\n InferFacts,\n InferSelectorState,\n ModuleDef,\n ModuleSchema,\n ModulesMap,\n NamespacedSystem,\n Plugin,\n SingleModuleSystem,\n SystemSnapshot,\n} from \"@directive-run/core\";\nimport {\n createRequirementStatusPlugin,\n createSystem,\n} from \"@directive-run/core\";\nimport type { RequirementTypeStatus } from \"@directive-run/core\";\nimport {\n type ConstraintInfo,\n type InspectState,\n assertSystem,\n buildHistoryState,\n computeInspectState,\n createThrottle,\n defaultEquality,\n depsChanged,\n pickFacts,\n runTrackedSelector,\n shallowEqual,\n} from \"@directive-run/core/adapter-utils\";\nimport {\n type ComputedRef,\n type Ref,\n type ShallowRef,\n computed,\n onScopeDispose,\n ref,\n shallowRef,\n} from \"vue\";\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<\n S extends ModuleSchema,\n K extends keyof InferFacts<S> & string,\n>(system: SingleModuleSystem<S>, factKey: K): Ref<InferFacts<S>[K] | undefined>;\n/** Multi-key overload */\nexport function useFact<\n S extends ModuleSchema,\n K extends keyof InferFacts<S> & string,\n>(\n system: SingleModuleSystem<S>,\n factKeys: K[],\n): ShallowRef<Pick<InferFacts<S>, K>>;\n/** Implementation */\nexport function useFact(\n // biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n system: SingleModuleSystem<any>,\n keyOrKeys: string | string[],\n): Ref<unknown> | ShallowRef<unknown> {\n assertSystem(\"useFact\", system);\n if (\n process.env.NODE_ENV !== \"production\" &&\n typeof keyOrKeys === \"function\"\n ) {\n console.error(\n \"[Directive] useFact() received a function. Did you mean useSelector()? \" +\n \"useFact() takes a string key or array of keys, not a selector function.\",\n );\n }\n\n // Multi-key path: useFact(system, [keys])\n if (Array.isArray(keyOrKeys)) {\n return _useFactMulti(system, keyOrKeys);\n }\n\n // Single key path: useFact(system, key)\n return _useFactSingle(system, keyOrKeys);\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useFactSingle(\n system: SingleModuleSystem<any>,\n factKey: string,\n): Ref<unknown> {\n if (process.env.NODE_ENV !== \"production\") {\n if (!system.facts.$store.has(factKey)) {\n console.warn(\n `[Directive] useFact(\"${factKey}\") — fact not found in store. ` +\n `Check that \"${factKey}\" is defined in your module's schema.`,\n );\n }\n }\n\n const value = ref(system.facts.$store.get(factKey));\n const unsubscribe = system.facts.$store.subscribe([factKey], () => {\n value.value = system.facts.$store.get(factKey);\n });\n onScopeDispose(unsubscribe);\n return value;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useFactMulti(\n system: SingleModuleSystem<any>,\n factKeys: string[],\n): ShallowRef<Record<string, unknown>> {\n const getValues = (): Record<string, unknown> => {\n const result: Record<string, unknown> = {};\n for (const key of factKeys) {\n result[key] = system.facts.$store.get(key);\n }\n return result;\n };\n const state = shallowRef(getValues());\n const unsubscribe = system.facts.$store.subscribe(factKeys, () => {\n state.value = getValues();\n });\n onScopeDispose(unsubscribe);\n return state;\n}\n\n// ============================================================================\n// useDerived — single key or multi key\n// ============================================================================\n\n/** Single key overload */\nexport function useDerived<\n S extends ModuleSchema,\n K extends keyof InferDerivations<S> & string,\n>(system: SingleModuleSystem<S>, derivationId: K): Ref<InferDerivations<S>[K]>;\n/** Multi-key overload */\nexport function useDerived<\n S extends ModuleSchema,\n K extends keyof InferDerivations<S> & string,\n>(\n system: SingleModuleSystem<S>,\n derivationIds: K[],\n): ShallowRef<Pick<InferDerivations<S>, K>>;\n/** Implementation */\nexport function useDerived(\n // biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n system: SingleModuleSystem<any>,\n idOrIds: string | string[],\n): Ref<unknown> | ShallowRef<unknown> {\n assertSystem(\"useDerived\", system);\n if (process.env.NODE_ENV !== \"production\" && typeof idOrIds === \"function\") {\n console.error(\n \"[Directive] useDerived() received a function. Did you mean useSelector()? \" +\n \"useDerived() takes a string key or array of keys, not a selector function.\",\n );\n }\n\n // Multi-key path\n if (Array.isArray(idOrIds)) {\n return _useDerivedMulti(system, idOrIds);\n }\n\n // Single key path\n return _useDerivedSingle(system, idOrIds);\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useDerivedSingle(\n system: SingleModuleSystem<any>,\n derivationId: string,\n): Ref<unknown> {\n if (process.env.NODE_ENV !== \"production\") {\n const initialValue = system.read(derivationId);\n if (initialValue === undefined) {\n console.warn(\n `[Directive] useDerived(\"${derivationId}\") returned undefined. ` +\n `Check that \"${derivationId}\" is defined in your module's derive property.`,\n );\n }\n }\n const value = ref(system.read(derivationId));\n const unsubscribe = system.subscribe([derivationId], () => {\n value.value = system.read(derivationId);\n });\n onScopeDispose(unsubscribe);\n return value;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: Internal\nfunction _useDerivedMulti(\n system: SingleModuleSystem<any>,\n derivationIds: string[],\n): ShallowRef<Record<string, unknown>> {\n const getValues = (): Record<string, unknown> => {\n const result: Record<string, unknown> = {};\n for (const id of derivationIds) {\n result[id] = system.read(id);\n }\n return result;\n };\n const state = shallowRef(getValues());\n const unsubscribe = system.subscribe(derivationIds, () => {\n state.value = getValues();\n });\n onScopeDispose(unsubscribe);\n return 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>(\n system: SingleModuleSystem<S>,\n selector: (state: InferSelectorState<S>) => R,\n equalityFn?: (a: R, b: R) => boolean,\n): Ref<R>;\nexport function useSelector(\n // biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n system: SingleModuleSystem<any>,\n selector: (state: Record<string, unknown>) => unknown,\n equalityFn: (a: unknown, b: unknown) => boolean = defaultEquality,\n): Ref<unknown> {\n assertSystem(\"useSelector\", system);\n const deriveKeySet = new Set(Object.keys(system.derive ?? {}));\n\n const runWithTracking = () =>\n runTrackedSelector(system, deriveKeySet, selector);\n\n const initial = runWithTracking();\n let trackedFactKeys = initial.factKeys;\n let trackedDeriveKeys = initial.deriveKeys;\n const selected = ref(initial.value);\n\n const unsubs: Array<() => void> = [];\n\n const resubscribe = () => {\n for (const unsub of unsubs) unsub();\n unsubs.length = 0;\n\n const onUpdate = () => {\n const result = runWithTracking();\n if (!equalityFn(selected.value, result.value)) {\n selected.value = result.value;\n }\n // Re-track: check if deps changed\n if (\n depsChanged(\n trackedFactKeys,\n result.factKeys,\n trackedDeriveKeys,\n result.deriveKeys,\n )\n ) {\n trackedFactKeys = result.factKeys;\n trackedDeriveKeys = result.deriveKeys;\n resubscribe();\n }\n };\n\n if (trackedFactKeys.length > 0) {\n unsubs.push(system.facts.$store.subscribe(trackedFactKeys, onUpdate));\n } else if (trackedDeriveKeys.length === 0) {\n unsubs.push(system.facts.$store.subscribeAll(onUpdate));\n }\n if (trackedDeriveKeys.length > 0) {\n unsubs.push(system.subscribe(trackedDeriveKeys, onUpdate));\n }\n };\n\n resubscribe();\n\n onScopeDispose(() => {\n for (const unsub of unsubs) unsub();\n });\n\n return selected;\n}\n\n// ============================================================================\n// useDispatch\n// ============================================================================\n\nexport function useDispatch<S extends ModuleSchema>(\n system: SingleModuleSystem<S>,\n): (event: InferEvents<S>) => void {\n assertSystem(\"useDispatch\", system);\n return (event: InferEvents<S>) => {\n system.dispatch(event);\n };\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 system: SingleModuleSystem<S>,\n): SingleModuleSystem<S>[\"events\"] {\n assertSystem(\"useEvents\", system);\n return 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<\n S extends ModuleSchema,\n K extends keyof InferDerivations<S> & string,\n>(\n system: SingleModuleSystem<S>,\n key: K,\n callback: (\n newValue: InferDerivations<S>[K],\n previousValue: InferDerivations<S>[K] | undefined,\n ) => void,\n): void;\n/** Watch a fact key with auto-detection. */\nexport function useWatch<\n S extends ModuleSchema,\n K extends keyof InferFacts<S> & string,\n>(\n system: SingleModuleSystem<S>,\n key: K,\n callback: (\n newValue: InferFacts<S>[K] | undefined,\n previousValue: InferFacts<S>[K] | undefined,\n ) => void,\n): void;\n/** Implementation */\nexport function useWatch(\n // biome-ignore lint/suspicious/noExplicitAny: Implementation signature\n system: SingleModuleSystem<any>,\n key: string,\n callback: (newValue: unknown, prevValue: unknown) => void,\n): void {\n assertSystem(\"useWatch\", system);\n\n const unsubscribe = system.watch(key, callback);\n onScopeDispose(unsubscribe);\n}\n\n// ============================================================================\n// useInspect — consolidated inspection hook\n// ============================================================================\n\n/** Options for useInspect */\nexport interface UseInspectOptions {\n throttleMs?: number;\n}\n\n/**\n * Consolidated system inspection hook.\n * Returns InspectState with optional throttling.\n */\nexport function useInspect(\n // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n options?: UseInspectOptions,\n): ShallowRef<InspectState> {\n assertSystem(\"useInspect\", system);\n const state = shallowRef<InspectState>(computeInspectState(system));\n\n const update = () => {\n state.value = computeInspectState(system);\n };\n\n if (options?.throttleMs && options.throttleMs > 0) {\n const { throttled, cleanup } = createThrottle(update, options.throttleMs);\n const unsubFacts = system.facts.$store.subscribeAll(throttled);\n const unsubSettled = system.onSettledChange(throttled);\n onScopeDispose(() => {\n cleanup();\n unsubFacts();\n unsubSettled();\n });\n } else {\n const unsubFacts = system.facts.$store.subscribeAll(update);\n const unsubSettled = system.onSettledChange(update);\n onScopeDispose(() => {\n unsubFacts();\n unsubSettled();\n });\n }\n\n return state;\n}\n\n// ============================================================================\n// useRequirementStatus — single or multi\n// ============================================================================\n\n/** Single type overload */\nexport function useRequirementStatus(\n statusPlugin: StatusPlugin,\n type: string,\n): ShallowRef<RequirementTypeStatus>;\n/** Multi-type overload */\nexport function useRequirementStatus(\n statusPlugin: StatusPlugin,\n types: string[],\n): ShallowRef<Record<string, RequirementTypeStatus>>;\n/** Implementation */\nexport function useRequirementStatus(\n statusPlugin: StatusPlugin,\n typeOrTypes: string | string[],\n):\n | ShallowRef<RequirementTypeStatus>\n | ShallowRef<Record<string, RequirementTypeStatus>> {\n if (Array.isArray(typeOrTypes)) {\n const getValues = (): Record<string, RequirementTypeStatus> => {\n const result: Record<string, RequirementTypeStatus> = {};\n for (const type of typeOrTypes) {\n result[type] = statusPlugin.getStatus(type);\n }\n return result;\n };\n const state = shallowRef(getValues());\n const unsubscribe = statusPlugin.subscribe(() => {\n state.value = getValues();\n });\n onScopeDispose(unsubscribe);\n return state;\n }\n\n const status = shallowRef<RequirementTypeStatus>(\n statusPlugin.getStatus(typeOrTypes),\n );\n const unsubscribe = statusPlugin.subscribe(() => {\n status.value = statusPlugin.getStatus(typeOrTypes);\n });\n onScopeDispose(unsubscribe);\n return 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 // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n requirementId: string,\n): Ref<string | null> {\n assertSystem(\"useExplain\", system);\n const explanation = ref<string | null>(system.explain(requirementId)) as Ref<\n string | null\n >;\n\n const update = () => {\n explanation.value = system.explain(requirementId);\n };\n\n const unsubFacts = system.facts.$store.subscribeAll(update);\n const unsubSettled = system.onSettledChange(update);\n onScopeDispose(() => {\n unsubFacts();\n unsubSettled();\n });\n\n return explanation;\n}\n\n// ============================================================================\n// useConstraintStatus — reactive constraint inspection\n// ============================================================================\n\n/** Get all constraints */\nexport function useConstraintStatus(\n system: SingleModuleSystem<any>,\n): ComputedRef<ConstraintInfo[]>;\n/** Get a single constraint by ID */\nexport function useConstraintStatus(\n system: SingleModuleSystem<any>,\n constraintId: string,\n): ComputedRef<ConstraintInfo | null>;\n/** Implementation */\nexport function useConstraintStatus(\n // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n constraintId?: string,\n): ComputedRef<ConstraintInfo[] | ConstraintInfo | null> {\n assertSystem(\"useConstraintStatus\", system);\n const inspectState = useInspect(system);\n\n return computed(() => {\n // Track reactivity via inspectState, but use full inspect() for constraint list\n void inspectState.value;\n const fullInspection = system.inspect();\n if (!constraintId) return fullInspection.constraints;\n return (\n fullInspection.constraints.find((c) => c.id === constraintId) ?? null\n );\n });\n}\n\n// ============================================================================\n// useOptimisticUpdate — batch with rollback on failure\n// ============================================================================\n\nexport interface OptimisticUpdateResult {\n mutate: (updateFn: () => void) => void;\n isPending: Ref<boolean>;\n error: Ref<Error | null>;\n rollback: () => 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 // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n statusPlugin?: StatusPlugin,\n requirementType?: string,\n): OptimisticUpdateResult {\n assertSystem(\"useOptimisticUpdate\", system);\n const isPending = ref(false);\n const error = ref<Error | null>(null) as Ref<Error | null>;\n let snapshot: SystemSnapshot | null = null;\n let unsubscribe: (() => void) | null = null;\n\n const rollback = () => {\n if (snapshot) {\n system.restore(snapshot);\n snapshot = null;\n }\n isPending.value = false;\n error.value = null;\n unsubscribe?.();\n unsubscribe = null;\n };\n\n const mutate = (updateFn: () => void) => {\n snapshot = system.getSnapshot();\n isPending.value = true;\n error.value = null;\n system.batch(updateFn);\n\n // Watch for resolver completion/failure\n if (statusPlugin && requirementType) {\n unsubscribe?.();\n unsubscribe = statusPlugin.subscribe(() => {\n const status = statusPlugin.getStatus(requirementType);\n if (!status.isLoading && !status.hasError) {\n snapshot = null;\n isPending.value = false;\n unsubscribe?.();\n unsubscribe = null;\n } else if (status.hasError) {\n error.value = status.lastError;\n rollback();\n }\n });\n }\n };\n\n onScopeDispose(() => {\n unsubscribe?.();\n });\n\n return { mutate, isPending, error, rollback };\n}\n\n// ============================================================================\n// useHistory — reactive history state\n// ============================================================================\n\n/**\n * Reactive history composable. Returns a ShallowRef that updates\n * when snapshots are taken or navigation occurs.\n *\n * @example\n * ```vue\n * const history = useHistory(system);\n * <button :disabled=\"!history.value?.canGoBack\" @click=\"history.value?.goBack()\">Undo</button>\n * ```\n */\nexport function useHistory(\n // biome-ignore lint/suspicious/noExplicitAny: Must work with any schema\n system: SingleModuleSystem<any>,\n): ShallowRef<ReturnType<typeof buildHistoryState>> {\n assertSystem(\"useHistory\", system);\n const state = shallowRef<ReturnType<typeof buildHistoryState>>(\n buildHistoryState(system),\n );\n const unsub = system.onHistoryChange(() => {\n state.value = buildHistoryState(system);\n });\n onScopeDispose(unsub);\n return state;\n}\n\n// ============================================================================\n// Scoped System Composable\n// ============================================================================\n\n/** Configuration for useDirective */\ninterface UseDirectiveConfig {\n // biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n plugins?: Plugin<any>[];\n trace?: TraceOption;\n errorBoundary?: ErrorBoundaryConfig;\n tickMs?: number;\n zeroConfig?: boolean;\n // biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n initialFacts?: Record<string, any>;\n status?: boolean;\n /** Fact keys to subscribe to (omit for all) */\n facts?: string[];\n /** Derivation keys to subscribe to (omit for all) */\n derived?: 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 moduleDef: ModuleDef<M>,\n config?: UseDirectiveConfig,\n) {\n const allPlugins = [...(config?.plugins ?? [])];\n let statusPlugin: StatusPlugin | undefined;\n\n if (config?.status) {\n const sp = createRequirementStatusPlugin();\n statusPlugin = sp;\n // biome-ignore lint/suspicious/noExplicitAny: Plugin generic issues\n allPlugins.push(sp.plugin as Plugin<any>);\n }\n\n // biome-ignore lint/suspicious/noExplicitAny: Required for overload compatibility\n const system = createSystem({\n module: moduleDef,\n plugins: allPlugins.length > 0 ? allPlugins : undefined,\n trace: config?.trace,\n errorBoundary: config?.errorBoundary,\n tickMs: config?.tickMs,\n zeroConfig: config?.zeroConfig,\n initialFacts: config?.initialFacts,\n } as any) as unknown as SingleModuleSystem<M>;\n\n system.start();\n\n onScopeDispose(() => {\n system.destroy();\n });\n\n const factKeys = config?.facts;\n const derivedKeys = config?.derived;\n const subscribeAll = !factKeys && !derivedKeys;\n\n // Subscribe to facts\n const factsState = shallowRef(\n subscribeAll\n ? (system.facts.$store.toObject() as InferFacts<M>)\n : pickFacts(system, factKeys ?? []),\n );\n const unsubFacts = subscribeAll\n ? system.facts.$store.subscribeAll(() => {\n factsState.value = system.facts.$store.toObject() as InferFacts<M>;\n })\n : factKeys && factKeys.length > 0\n ? system.facts.$store.subscribe(factKeys, () => {\n factsState.value = pickFacts(system, factKeys) as InferFacts<M>;\n })\n : null;\n\n // Subscribe to derivations\n const allDerivationKeys = subscribeAll\n ? Object.keys(system.derive ?? {})\n : (derivedKeys ?? []);\n const getDerived = (): InferDerivations<M> => {\n const result: Record<string, unknown> = {};\n for (const key of allDerivationKeys) {\n result[key] = system.read(key);\n }\n return result as InferDerivations<M>;\n };\n const derivedState = shallowRef(getDerived());\n const unsubDerived =\n allDerivationKeys.length > 0\n ? system.subscribe(allDerivationKeys, () => {\n derivedState.value = getDerived();\n })\n : null;\n\n onScopeDispose(() => {\n unsubFacts?.();\n unsubDerived?.();\n });\n\n const events = system.events;\n const dispatch = (event: InferEvents<M>) => system.dispatch(event);\n\n return {\n system,\n facts: factsState as ShallowRef<InferFacts<M>>,\n derived: derivedState as ShallowRef<InferDerivations<M>>,\n events,\n dispatch,\n statusPlugin,\n };\n}\n\n// ============================================================================\n// Typed Hooks Factory\n// ============================================================================\n\nexport function createTypedHooks<M extends ModuleSchema>(): {\n useFact: <K extends keyof InferFacts<M> & string>(\n system: SingleModuleSystem<M>,\n factKey: K,\n ) => Ref<InferFacts<M>[K] | undefined>;\n useDerived: <K extends keyof InferDerivations<M> & string>(\n system: SingleModuleSystem<M>,\n derivationId: K,\n ) => Ref<InferDerivations<M>[K]>;\n useDispatch: (\n system: SingleModuleSystem<M>,\n ) => (event: InferEvents<M>) => void;\n useEvents: (system: SingleModuleSystem<M>) => SingleModuleSystem<M>[\"events\"];\n useWatch: <K extends string>(\n system: SingleModuleSystem<M>,\n key: K,\n callback: (newValue: unknown, previousValue: unknown) => void,\n ) => void;\n} {\n return {\n useFact: <K extends keyof InferFacts<M> & string>(\n system: SingleModuleSystem<M>,\n factKey: K,\n ) =>\n // biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n useFact(system as SingleModuleSystem<any>, factKey) as Ref<\n InferFacts<M>[K] | undefined\n >,\n useDerived: <K extends keyof InferDerivations<M> & string>(\n system: SingleModuleSystem<M>,\n derivationId: K,\n ) =>\n // biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n useDerived(system as SingleModuleSystem<any>, derivationId) as Ref<\n InferDerivations<M>[K]\n >,\n useDispatch: (system: SingleModuleSystem<M>) => {\n return (event: InferEvents<M>) => {\n system.dispatch(event);\n };\n },\n useEvents: (system: SingleModuleSystem<M>) => useEvents<M>(system),\n useWatch: <K extends string>(\n system: SingleModuleSystem<M>,\n key: K,\n callback: (newValue: unknown, previousValue: unknown) => void,\n ) =>\n // biome-ignore lint/suspicious/noExplicitAny: Type narrowing for internal call\n useWatch(system as SingleModuleSystem<any>, key, callback),\n };\n}\n\n// ============================================================================\n// useNamespacedSelector — select from a NamespacedSystem\n// ============================================================================\n\n/**\n * Reactive composable to select from a NamespacedSystem.\n * Subscribes to specified keys and returns a Vue ref.\n *\n * @param system - The namespaced system\n * @param keys - Namespaced keys to subscribe to (e.g., [\"auth.token\", \"data.count\"])\n * @param selector - Function that reads from system.facts / system.derive\n *\n * @example\n * ```vue\n * const system = useDirectiveRef({ modules: { auth, data } });\n * const token = useNamespacedSelector(system, [\"auth.token\"], (s) => s.facts.auth.token);\n * ```\n */\nexport function useNamespacedSelector<Modules extends ModulesMap, R>(\n system: NamespacedSystem<Modules>,\n keys: string[],\n selector: (system: NamespacedSystem<Modules>) => R,\n): Ref<R> {\n const value = ref(selector(system)) as Ref<R>;\n const unsubscribe = system.subscribe(keys, () => {\n value.value = selector(system) as R;\n });\n onScopeDispose(unsubscribe);\n\n return value;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@directive-run/vue",
3
- "version": "0.4.2",
3
+ "version": "0.7.0",
4
4
  "description": "Vue composition API adapter for Directive.",
5
5
  "license": "MIT",
6
6
  "author": "Jason Comes",
@@ -52,7 +52,7 @@
52
52
  "vue": "^3.4.0",
53
53
  "tsup": "^8.3.5",
54
54
  "typescript": "^5.7.2",
55
- "@directive-run/core": "0.4.2"
55
+ "@directive-run/core": "0.7.0"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "tsup",