@directive-run/vue 0.8.2 → 0.8.4

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
@@ -2,6 +2,11 @@ MIT License
2
2
 
3
3
  Copyright (c) 2026 Sizls LLC
4
4
 
5
+ This project is dual-licensed under MIT OR Apache-2.0. You may choose
6
+ either license. See LICENSE-APACHE for the Apache License, Version 2.0.
7
+
8
+ ---
9
+
5
10
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
11
  of this software and associated documentation files (the "Software"), to deal
7
12
  in the Software without restriction, including without limitation the rights
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 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
1
+ 'use strict';var core=require('@directive-run/core'),adapterUtils=require('@directive-run/core/adapter-utils'),vue=require('vue');function q(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)?T(e,t):C(e,t)}function C(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)),r=e.facts.$store.subscribe([t],()=>{s.value=e.facts.$store.get(t);});return vue.onScopeDispose(r),s}function T(e,t){let s=()=>{let u={};for(let o of t)u[o]=e.facts.$store.get(o);return u},r=vue.shallowRef(s()),n=e.facts.$store.subscribe(t,()=>{r.value=s();});return vue.onScopeDispose(n),r}function V(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):$(e,t)}function $(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)),r=e.subscribe([t],()=>{s.value=e.read(t);});return vue.onScopeDispose(r),s}function A(e,t){let s=()=>{let u={};for(let o of t)u[o]=e.read(o);return u},r=vue.shallowRef(s()),n=e.subscribe(t,()=>{r.value=s();});return vue.onScopeDispose(n),r}function z(e,t,s=adapterUtils.defaultEquality){adapterUtils.assertSystem("useSelector",e);let r=new Set(Object.keys(e.derive??{})),n=()=>adapterUtils.runTrackedSelector(e,r,t),u=n(),o=u.factKeys,i=u.deriveKeys,l=vue.ref(u.value),S=[],c=()=>{for(let d of S)d();S.length=0;let f=()=>{let d=n();s(l.value,d.value)||(l.value=d.value),adapterUtils.depsChanged(o,d.factKeys,i,d.deriveKeys)&&(o=d.factKeys,i=d.deriveKeys,c());};o.length>0?S.push(e.facts.$store.subscribe(o,f)):i.length===0&&S.push(e.facts.$store.subscribeAll(f)),i.length>0&&S.push(e.subscribe(i,f));};return c(),vue.onScopeDispose(()=>{for(let f of S)f();}),l}function Q(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 r=e.watch(t,s);vue.onScopeDispose(r);}function _(e,t){adapterUtils.assertSystem("useInspect",e);let s=vue.shallowRef(adapterUtils.computeInspectState(e)),r=()=>{s.value=adapterUtils.computeInspectState(e);};if(t?.throttleMs&&t.throttleMs>0){let{throttled:n,cleanup:u}=adapterUtils.createThrottle(r,t.throttleMs),o=e.facts.$store.subscribeAll(n),i=e.onSettledChange(n);vue.onScopeDispose(()=>{u(),o(),i();});}else {let n=e.facts.$store.subscribeAll(r),u=e.onSettledChange(r);vue.onScopeDispose(()=>{n(),u();});}return s}function G(e,t){if(Array.isArray(t)){let n=()=>{let i={};for(let l of t)i[l]=e.getStatus(l);return i},u=vue.shallowRef(n()),o=e.subscribe(()=>{u.value=n();});return vue.onScopeDispose(o),u}let s=vue.shallowRef(e.getStatus(t)),r=e.subscribe(()=>{s.value=e.getStatus(t);});return vue.onScopeDispose(r),s}function J(e,t){return Array.isArray(t)?H(e,t):U(e,t)}async function U(e,t){let s=e.getStatus(t);if(s.hasError&&s.lastError)throw s.lastError;s.isLoading&&await new Promise((u,o)=>{let i=e.subscribe(()=>{let l=e.getStatus(t);l.isLoading||(i(),l.hasError&&l.lastError?o(l.lastError):u());});vue.onScopeDispose(i);});let r=vue.shallowRef(e.getStatus(t)),n=e.subscribe(()=>{r.value=e.getStatus(t);});return vue.onScopeDispose(n),r}async function H(e,t){for(let o of t){let i=e.getStatus(o);if(i.hasError&&i.lastError)throw i.lastError}t.some(o=>e.getStatus(o).isLoading)&&await new Promise((o,i)=>{let l=e.subscribe(()=>{if(t.every(c=>!e.getStatus(c).isLoading)){l();for(let c of t){let f=e.getStatus(c);if(f.hasError&&f.lastError){i(f.lastError);return}}o();}});vue.onScopeDispose(l);});let r=()=>{let o={};for(let i of t)o[i]=e.getStatus(i);return o},n=vue.shallowRef(r()),u=e.subscribe(()=>{n.value=r();});return vue.onScopeDispose(u),n}function X(e,t){adapterUtils.assertSystem("useExplain",e);let s=vue.ref(e.explain(t)),r=()=>{s.value=e.explain(t);},n=e.facts.$store.subscribeAll(r),u=e.onSettledChange(r);return vue.onScopeDispose(()=>{n(),u();}),s}function Y(e,t){adapterUtils.assertSystem("useConstraintStatus",e);let s=_(e);return vue.computed(()=>{s.value;let r=e.inspect();return t?r.constraints.find(n=>n.id===t)??null:r.constraints})}function Z(e,t,s){adapterUtils.assertSystem("useOptimisticUpdate",e);let r=vue.ref(false),n=vue.ref(null),u=null,o=null,i=()=>{u&&(e.restore(u),u=null),r.value=false,n.value=null,o?.(),o=null;},l=S=>{u=e.getSnapshot(),r.value=true,n.value=null,e.batch(S),t&&s&&(o?.(),o=t.subscribe(()=>{let c=t.getStatus(s);!c.isLoading&&!c.hasError?(u=null,r.value=false,o?.(),o=null):c.hasError&&(n.value=c.lastError,i());}));};return vue.onScopeDispose(()=>{o?.();}),{mutate:l,isPending:r,error:n,rollback:i}}function ee(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 te(e,t){let s=[...t?.plugins??[]],r;if(t?.status){let y=core.createRequirementStatusPlugin();r=y,s.push(y.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});typeof window<"u"?n.start():n.initialize(),vue.onScopeDispose(()=>{n.destroy();});let u=t?.facts,o=t?.derived,i=!u&&!o,l=vue.shallowRef(i?n.facts.$store.toObject():adapterUtils.pickFacts(n,u??[])),S=i?n.facts.$store.subscribeAll(()=>{l.value=n.facts.$store.toObject();}):u&&u.length>0?n.facts.$store.subscribe(u,()=>{l.value=adapterUtils.pickFacts(n,u);}):null,c=i?Object.keys(n.derive??{}):o??[],f=()=>{let y={};for(let R of c)y[R]=n.read(R);return y},d=vue.shallowRef(f()),h=c.length>0?n.subscribe(c,()=>{d.value=f();}):null;vue.onScopeDispose(()=>{S?.(),h?.();});let w=n.events;return {system:n,facts:l,derived:d,events:w,dispatch:y=>n.dispatch(y),statusPlugin:r}}function ne(){return {useFact:(e,t)=>q(e,t),useDerived:(e,t)=>V(e,t),useDispatch:e=>t=>{e.dispatch(t);},useEvents:e=>P(e),useWatch:(e,t,s)=>N(e,t,s)}}function se(e,t,s){let r=vue.ref(s(e)),n=e.subscribe(t,()=>{r.value=s(e);});return vue.onScopeDispose(n),r}function re(e){let t=e();return typeof window<"u"&&!t.isRunning&&t.start(),vue.onScopeDispose(()=>{t.destroy();}),t}Object.defineProperty(exports,"shallowEqual",{enumerable:true,get:function(){return adapterUtils.shallowEqual}});exports.createTypedHooks=ne;exports.useConstraintStatus=Y;exports.useDerived=V;exports.useDirective=te;exports.useDispatch=Q;exports.useEvents=P;exports.useExplain=X;exports.useFact=q;exports.useHistory=ee;exports.useInspect=_;exports.useNamespacedSelector=se;exports.useOptimisticUpdate=Z;exports.useQuerySystem=re;exports.useRequirementStatus=G;exports.useSelector=z;exports.useSuspenseRequirement=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","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,yBAAA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AAA,CAENhF,kBAAAA,CAAe,IAAM,CACnB0C,CAAAA,IAAa,CACbwC,CAAAA,KACF,CAAC,CAAA,CAED,IAAMC,CAAAA,CAAS5F,EAAO,MAAA,CAGtB,OAAO,CACL,MAAA,CAAAA,EACA,KAAA,CAAOsF,CAAAA,CACP,OAAA,CAASI,CAAAA,CACT,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"]}
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","useSuspenseRequirement","_useSuspenseRequirementMulti","_useSuspenseRequirementSingle","initialStatus","resolve","reject","current","types","s","t","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","useQuerySystem","factory"],"mappings":"kIA6EO,SAASA,EAEdC,CAAAA,CACAC,CAAAA,CACoC,CAapC,OAZAC,yBAAAA,CAAa,UAAWF,CAAM,CAAA,CAE5B,OAAA,CAAQ,GAAA,CAAI,WAAa,YAAA,EACzB,OAAOC,GAAc,UAAA,EAErB,OAAA,CAAQ,MACN,gJAEF,CAAA,CAIE,MAAM,OAAA,CAAQA,CAAS,EAClBE,CAAAA,CAAcH,CAAAA,CAAQC,CAAS,CAAA,CAIjCG,CAAAA,CAAeJ,EAAQC,CAAS,CACzC,CAGA,SAASG,CAAAA,CACPJ,EACAK,CAAAA,CACc,CACV,QAAQ,GAAA,CAAI,QAAA,GAAa,eACtBL,CAAAA,CAAO,KAAA,CAAM,OAAO,GAAA,CAAIK,CAAO,GAClC,OAAA,CAAQ,IAAA,CACN,wBAAwBA,CAAO,CAAA,+CAAA,EACdA,CAAO,CAAA,qCAAA,CAC1B,CAAA,CAAA,CAIJ,IAAMC,CAAAA,CAAQC,QAAIP,CAAAA,CAAO,KAAA,CAAM,OAAO,GAAA,CAAIK,CAAO,CAAC,CAAA,CAC5CG,CAAAA,CAAcR,EAAO,KAAA,CAAM,MAAA,CAAO,UAAU,CAACK,CAAO,EAAG,IAAM,CACjEC,EAAM,KAAA,CAAQN,CAAAA,CAAO,MAAM,MAAA,CAAO,GAAA,CAAIK,CAAO,EAC/C,CAAC,EACD,OAAAI,kBAAAA,CAAeD,CAAW,CAAA,CACnBF,CACT,CAGA,SAASH,CAAAA,CACPH,EACAU,CAAAA,CACqC,CACrC,IAAMC,CAAAA,CAAY,IAA+B,CAC/C,IAAMC,CAAAA,CAAkC,EAAC,CACzC,IAAA,IAAWC,KAAOH,CAAAA,CAChBE,CAAAA,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EACJwC,GAA0B,CAChCxC,CAAAA,CAAO,SAASwC,CAAK,EACvB,EAEF,SAAA,CAAYxC,CAAAA,EAAkCyC,EAAazC,CAAM,CAAA,CACjE,SAAU,CACRA,CAAAA,CACAa,EACA8B,CAAAA,GAGAD,CAAAA,CAAS1C,EAAmCa,CAAAA,CAAK8B,CAAQ,CAC7D,CACF,CAoBO,SAAS6D,EAAAA,CACdxG,CAAAA,CACAyG,EACAjF,CAAAA,CACQ,CACR,IAAMlB,CAAAA,CAAQC,OAAAA,CAAIiB,EAASxB,CAAM,CAAC,EAC5BQ,CAAAA,CAAcR,CAAAA,CAAO,UAAUyG,CAAAA,CAAM,IAAM,CAC/CnG,CAAAA,CAAM,KAAA,CAAQkB,EAASxB,CAAM,EAC/B,CAAC,CAAA,CACD,OAAAS,mBAAeD,CAAW,CAAA,CAEnBF,CACT,CA+BO,SAASoG,GACdC,CAAAA,CACG,CACH,IAAM3G,CAAAA,CAAS2G,CAAAA,GAGf,OAAI,OAAO,OAAW,GAAA,EAAe,CAAC3G,EAAO,SAAA,EAC3CA,CAAAA,CAAO,OAAM,CAGfS,kBAAAA,CAAe,IAAM,CACnBT,CAAAA,CAAO,UACT,CAAC,EAEMA,CACT","file":"index.cjs","sourcesContent":["/**\n * Vue Adapter - Vue 3 composables for Directive\n *\n * Exports: useFact, useDerived, useDispatch, useSelector,\n * useWatch, useInspect, useRequirementStatus, useSuspenseRequirement,\n * useEvents, useExplain, useConstraintStatus, useOptimisticUpdate,\n * useDirective, useHistory, 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// useSuspenseRequirement — async setup() Suspense integration\n// ============================================================================\n\n/**\n * Returns a promise that resolves when a requirement type settles.\n * Designed for Vue's async `setup()` with `<Suspense>`.\n *\n * - If the requirement is loading, the returned promise suspends the component.\n * - If the requirement has an error, the promise rejects with that error.\n * - If the requirement is already settled, resolves immediately.\n *\n * @example\n * ```vue\n * <script setup>\n * import { useSuspenseRequirement } from '@directive-run/vue';\n *\n * // In async setup(), this suspends until FETCH_USER settles\n * const status = await useSuspenseRequirement(statusPlugin, \"FETCH_USER\");\n * </script>\n *\n * <template>\n * <div>Resolved: {{ status.resolvedCount }}</div>\n * </template>\n * ```\n */\n\n/** Single type overload */\nexport function useSuspenseRequirement(\n statusPlugin: StatusPlugin,\n type: string,\n): Promise<ShallowRef<RequirementTypeStatus>>;\n\n/** Multi-type overload */\nexport function useSuspenseRequirement(\n statusPlugin: StatusPlugin,\n types: string[],\n): Promise<\n ShallowRef<Record<string, RequirementTypeStatus>>\n>;\n\n/** Implementation */\nexport function useSuspenseRequirement(\n statusPlugin: StatusPlugin,\n typeOrTypes: string | string[],\n): Promise<\n | ShallowRef<RequirementTypeStatus>\n | ShallowRef<Record<string, RequirementTypeStatus>>\n> {\n if (Array.isArray(typeOrTypes)) {\n return _useSuspenseRequirementMulti(statusPlugin, typeOrTypes);\n }\n\n return _useSuspenseRequirementSingle(statusPlugin, typeOrTypes);\n}\n\nasync function _useSuspenseRequirementSingle(\n statusPlugin: StatusPlugin,\n type: string,\n): Promise<ShallowRef<RequirementTypeStatus>> {\n const initialStatus = statusPlugin.getStatus(type);\n\n if (initialStatus.hasError && initialStatus.lastError) {\n throw initialStatus.lastError;\n }\n\n // If loading, wait for it to settle\n if (initialStatus.isLoading) {\n await new Promise<void>((resolve, reject) => {\n const unsubscribe = statusPlugin.subscribe(() => {\n const current = statusPlugin.getStatus(type);\n if (!current.isLoading) {\n unsubscribe();\n if (current.hasError && current.lastError) {\n reject(current.lastError);\n } else {\n resolve();\n }\n }\n });\n onScopeDispose(unsubscribe);\n });\n }\n\n // Now settled — return a reactive ref that continues tracking\n const status = shallowRef<RequirementTypeStatus>(\n statusPlugin.getStatus(type),\n );\n const unsubscribe = statusPlugin.subscribe(() => {\n status.value = statusPlugin.getStatus(type);\n });\n onScopeDispose(unsubscribe);\n\n return status;\n}\n\nasync function _useSuspenseRequirementMulti(\n statusPlugin: StatusPlugin,\n types: string[],\n): Promise<ShallowRef<Record<string, RequirementTypeStatus>>> {\n // Check for immediate errors\n for (const type of types) {\n const s = statusPlugin.getStatus(type);\n if (s.hasError && s.lastError) {\n throw s.lastError;\n }\n }\n\n // If any are loading, wait for all to settle\n const anyLoading = types.some(\n (t) => statusPlugin.getStatus(t).isLoading,\n );\n if (anyLoading) {\n await new Promise<void>((resolve, reject) => {\n const unsubscribe = statusPlugin.subscribe(() => {\n const allDone = types.every(\n (t) => !statusPlugin.getStatus(t).isLoading,\n );\n if (allDone) {\n unsubscribe();\n // Check for errors after settling\n for (const type of types) {\n const s = statusPlugin.getStatus(type);\n if (s.hasError && s.lastError) {\n reject(s.lastError);\n\n return;\n }\n }\n resolve();\n }\n });\n onScopeDispose(unsubscribe);\n });\n }\n\n // Now settled — return a reactive ref that continues tracking\n const getValues = (): Record<string, RequirementTypeStatus> => {\n const result: Record<string, RequirementTypeStatus> = {};\n for (const type of types) {\n result[type] = statusPlugin.getStatus(type);\n }\n\n return result;\n };\n const status = shallowRef(getValues());\n const unsubscribe = statusPlugin.subscribe(() => {\n status.value = getValues();\n });\n onScopeDispose(unsubscribe);\n\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 // SSR guard: initialize facts for SSR rendering, start reconciliation only in the browser\n if (typeof window !== \"undefined\") {\n system.start();\n } else {\n system.initialize();\n }\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\n// ============================================================================\n// useQuerySystem — Stable query system with lifecycle management\n// ============================================================================\n\n/**\n * Vue composable to create and manage a query system with proper lifecycle.\n *\n * Accepts a factory function that creates the system.\n * Handles cleanup on scope disposal.\n *\n * @example\n * ```vue\n * <script setup>\n * import { useQuerySystem, useDerived } from \"@directive-run/vue\";\n * import { createQuerySystem } from \"@directive-run/query\";\n *\n * const app = useQuerySystem(() =>\n * createQuerySystem({\n * facts: { userId: \"\" },\n * queries: { user: { key: ..., fetcher: ... } },\n * autoStart: false,\n * })\n * );\n *\n * const user = useDerived(app, \"user\");\n * </script>\n * ```\n */\n// biome-ignore lint/suspicious/noExplicitAny: Factory return type varies\nexport function useQuerySystem<T extends { start: () => void; destroy: () => void; isRunning?: boolean; [key: string]: any }>(\n factory: () => T,\n): T {\n const system = factory();\n\n // Start if not already running\n if (typeof window !== \"undefined\" && !system.isRunning) {\n system.start();\n }\n\n onScopeDispose(() => {\n system.destroy();\n });\n\n return system;\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -8,9 +8,9 @@ import { Ref, ComputedRef, ShallowRef } from 'vue';
8
8
  * Vue Adapter - Vue 3 composables for Directive
9
9
  *
10
10
  * Exports: useFact, useDerived, useDispatch, useSelector,
11
- * useWatch, useInspect, useRequirementStatus, useEvents, useExplain,
12
- * useConstraintStatus, useOptimisticUpdate, useDirective, useHistory,
13
- * createTypedHooks, shallowEqual
11
+ * useWatch, useInspect, useRequirementStatus, useSuspenseRequirement,
12
+ * useEvents, useExplain, useConstraintStatus, useOptimisticUpdate,
13
+ * useDirective, useHistory, createTypedHooks, shallowEqual
14
14
  */
15
15
 
16
16
  /** Type for the requirement status plugin return value */
@@ -51,6 +51,32 @@ declare function useInspect(system: SingleModuleSystem<any>, options?: UseInspec
51
51
  declare function useRequirementStatus(statusPlugin: StatusPlugin, type: string): ShallowRef<RequirementTypeStatus>;
52
52
  /** Multi-type overload */
53
53
  declare function useRequirementStatus(statusPlugin: StatusPlugin, types: string[]): ShallowRef<Record<string, RequirementTypeStatus>>;
54
+ /**
55
+ * Returns a promise that resolves when a requirement type settles.
56
+ * Designed for Vue's async `setup()` with `<Suspense>`.
57
+ *
58
+ * - If the requirement is loading, the returned promise suspends the component.
59
+ * - If the requirement has an error, the promise rejects with that error.
60
+ * - If the requirement is already settled, resolves immediately.
61
+ *
62
+ * @example
63
+ * ```vue
64
+ * <script setup>
65
+ * import { useSuspenseRequirement } from '@directive-run/vue';
66
+ *
67
+ * // In async setup(), this suspends until FETCH_USER settles
68
+ * const status = await useSuspenseRequirement(statusPlugin, "FETCH_USER");
69
+ * </script>
70
+ *
71
+ * <template>
72
+ * <div>Resolved: {{ status.resolvedCount }}</div>
73
+ * </template>
74
+ * ```
75
+ */
76
+ /** Single type overload */
77
+ declare function useSuspenseRequirement(statusPlugin: StatusPlugin, type: string): Promise<ShallowRef<RequirementTypeStatus>>;
78
+ /** Multi-type overload */
79
+ declare function useSuspenseRequirement(statusPlugin: StatusPlugin, types: string[]): Promise<ShallowRef<Record<string, RequirementTypeStatus>>>;
54
80
  /**
55
81
  * Reactively returns the explanation string for a requirement.
56
82
  */
@@ -147,5 +173,35 @@ declare function createTypedHooks<M extends ModuleSchema>(): {
147
173
  * ```
148
174
  */
149
175
  declare function useNamespacedSelector<Modules extends ModulesMap, R>(system: NamespacedSystem<Modules>, keys: string[], selector: (system: NamespacedSystem<Modules>) => R): Ref<R>;
176
+ /**
177
+ * Vue composable to create and manage a query system with proper lifecycle.
178
+ *
179
+ * Accepts a factory function that creates the system.
180
+ * Handles cleanup on scope disposal.
181
+ *
182
+ * @example
183
+ * ```vue
184
+ * <script setup>
185
+ * import { useQuerySystem, useDerived } from "@directive-run/vue";
186
+ * import { createQuerySystem } from "@directive-run/query";
187
+ *
188
+ * const app = useQuerySystem(() =>
189
+ * createQuerySystem({
190
+ * facts: { userId: "" },
191
+ * queries: { user: { key: ..., fetcher: ... } },
192
+ * autoStart: false,
193
+ * })
194
+ * );
195
+ *
196
+ * const user = useDerived(app, "user");
197
+ * </script>
198
+ * ```
199
+ */
200
+ declare function useQuerySystem<T extends {
201
+ start: () => void;
202
+ destroy: () => void;
203
+ isRunning?: boolean;
204
+ [key: string]: any;
205
+ }>(factory: () => T): T;
150
206
 
151
- export { type OptimisticUpdateResult, type StatusPlugin, type UseInspectOptions, createTypedHooks, useConstraintStatus, useDerived, useDirective, useDispatch, useEvents, useExplain, useFact, useHistory, useInspect, useNamespacedSelector, useOptimisticUpdate, useRequirementStatus, useSelector, useWatch };
207
+ export { type OptimisticUpdateResult, type StatusPlugin, type UseInspectOptions, createTypedHooks, useConstraintStatus, useDerived, useDirective, useDispatch, useEvents, useExplain, useFact, useHistory, useInspect, useNamespacedSelector, useOptimisticUpdate, useQuerySystem, useRequirementStatus, useSelector, useSuspenseRequirement, useWatch };
package/dist/index.d.ts CHANGED
@@ -8,9 +8,9 @@ import { Ref, ComputedRef, ShallowRef } from 'vue';
8
8
  * Vue Adapter - Vue 3 composables for Directive
9
9
  *
10
10
  * Exports: useFact, useDerived, useDispatch, useSelector,
11
- * useWatch, useInspect, useRequirementStatus, useEvents, useExplain,
12
- * useConstraintStatus, useOptimisticUpdate, useDirective, useHistory,
13
- * createTypedHooks, shallowEqual
11
+ * useWatch, useInspect, useRequirementStatus, useSuspenseRequirement,
12
+ * useEvents, useExplain, useConstraintStatus, useOptimisticUpdate,
13
+ * useDirective, useHistory, createTypedHooks, shallowEqual
14
14
  */
15
15
 
16
16
  /** Type for the requirement status plugin return value */
@@ -51,6 +51,32 @@ declare function useInspect(system: SingleModuleSystem<any>, options?: UseInspec
51
51
  declare function useRequirementStatus(statusPlugin: StatusPlugin, type: string): ShallowRef<RequirementTypeStatus>;
52
52
  /** Multi-type overload */
53
53
  declare function useRequirementStatus(statusPlugin: StatusPlugin, types: string[]): ShallowRef<Record<string, RequirementTypeStatus>>;
54
+ /**
55
+ * Returns a promise that resolves when a requirement type settles.
56
+ * Designed for Vue's async `setup()` with `<Suspense>`.
57
+ *
58
+ * - If the requirement is loading, the returned promise suspends the component.
59
+ * - If the requirement has an error, the promise rejects with that error.
60
+ * - If the requirement is already settled, resolves immediately.
61
+ *
62
+ * @example
63
+ * ```vue
64
+ * <script setup>
65
+ * import { useSuspenseRequirement } from '@directive-run/vue';
66
+ *
67
+ * // In async setup(), this suspends until FETCH_USER settles
68
+ * const status = await useSuspenseRequirement(statusPlugin, "FETCH_USER");
69
+ * </script>
70
+ *
71
+ * <template>
72
+ * <div>Resolved: {{ status.resolvedCount }}</div>
73
+ * </template>
74
+ * ```
75
+ */
76
+ /** Single type overload */
77
+ declare function useSuspenseRequirement(statusPlugin: StatusPlugin, type: string): Promise<ShallowRef<RequirementTypeStatus>>;
78
+ /** Multi-type overload */
79
+ declare function useSuspenseRequirement(statusPlugin: StatusPlugin, types: string[]): Promise<ShallowRef<Record<string, RequirementTypeStatus>>>;
54
80
  /**
55
81
  * Reactively returns the explanation string for a requirement.
56
82
  */
@@ -147,5 +173,35 @@ declare function createTypedHooks<M extends ModuleSchema>(): {
147
173
  * ```
148
174
  */
149
175
  declare function useNamespacedSelector<Modules extends ModulesMap, R>(system: NamespacedSystem<Modules>, keys: string[], selector: (system: NamespacedSystem<Modules>) => R): Ref<R>;
176
+ /**
177
+ * Vue composable to create and manage a query system with proper lifecycle.
178
+ *
179
+ * Accepts a factory function that creates the system.
180
+ * Handles cleanup on scope disposal.
181
+ *
182
+ * @example
183
+ * ```vue
184
+ * <script setup>
185
+ * import { useQuerySystem, useDerived } from "@directive-run/vue";
186
+ * import { createQuerySystem } from "@directive-run/query";
187
+ *
188
+ * const app = useQuerySystem(() =>
189
+ * createQuerySystem({
190
+ * facts: { userId: "" },
191
+ * queries: { user: { key: ..., fetcher: ... } },
192
+ * autoStart: false,
193
+ * })
194
+ * );
195
+ *
196
+ * const user = useDerived(app, "user");
197
+ * </script>
198
+ * ```
199
+ */
200
+ declare function useQuerySystem<T extends {
201
+ start: () => void;
202
+ destroy: () => void;
203
+ isRunning?: boolean;
204
+ [key: string]: any;
205
+ }>(factory: () => T): T;
150
206
 
151
- export { type OptimisticUpdateResult, type StatusPlugin, type UseInspectOptions, createTypedHooks, useConstraintStatus, useDerived, useDirective, useDispatch, useEvents, useExplain, useFact, useHistory, useInspect, useNamespacedSelector, useOptimisticUpdate, useRequirementStatus, useSelector, useWatch };
207
+ export { type OptimisticUpdateResult, type StatusPlugin, type UseInspectOptions, createTypedHooks, useConstraintStatus, useDerived, useDirective, useDispatch, useEvents, useExplain, useFact, useHistory, useInspect, useNamespacedSelector, useOptimisticUpdate, useQuerySystem, useRequirementStatus, useSelector, useSuspenseRequirement, useWatch };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
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
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 q(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)?T(e,t):C(e,t)}function C(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)),r=e.facts.$store.subscribe([t],()=>{s.value=e.facts.$store.get(t);});return onScopeDispose(r),s}function T(e,t){let s=()=>{let u={};for(let o of t)u[o]=e.facts.$store.get(o);return u},r=shallowRef(s()),n=e.facts.$store.subscribe(t,()=>{r.value=s();});return onScopeDispose(n),r}function V(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):$(e,t)}function $(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)),r=e.subscribe([t],()=>{s.value=e.read(t);});return onScopeDispose(r),s}function A(e,t){let s=()=>{let u={};for(let o of t)u[o]=e.read(o);return u},r=shallowRef(s()),n=e.subscribe(t,()=>{r.value=s();});return onScopeDispose(n),r}function z(e,t,s=defaultEquality){assertSystem("useSelector",e);let r=new Set(Object.keys(e.derive??{})),n=()=>runTrackedSelector(e,r,t),u=n(),o=u.factKeys,i=u.deriveKeys,l=ref(u.value),S=[],c=()=>{for(let d of S)d();S.length=0;let f=()=>{let d=n();s(l.value,d.value)||(l.value=d.value),depsChanged(o,d.factKeys,i,d.deriveKeys)&&(o=d.factKeys,i=d.deriveKeys,c());};o.length>0?S.push(e.facts.$store.subscribe(o,f)):i.length===0&&S.push(e.facts.$store.subscribeAll(f)),i.length>0&&S.push(e.subscribe(i,f));};return c(),onScopeDispose(()=>{for(let f of S)f();}),l}function Q(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 r=e.watch(t,s);onScopeDispose(r);}function _(e,t){assertSystem("useInspect",e);let s=shallowRef(computeInspectState(e)),r=()=>{s.value=computeInspectState(e);};if(t?.throttleMs&&t.throttleMs>0){let{throttled:n,cleanup:u}=createThrottle(r,t.throttleMs),o=e.facts.$store.subscribeAll(n),i=e.onSettledChange(n);onScopeDispose(()=>{u(),o(),i();});}else {let n=e.facts.$store.subscribeAll(r),u=e.onSettledChange(r);onScopeDispose(()=>{n(),u();});}return s}function G(e,t){if(Array.isArray(t)){let n=()=>{let i={};for(let l of t)i[l]=e.getStatus(l);return i},u=shallowRef(n()),o=e.subscribe(()=>{u.value=n();});return onScopeDispose(o),u}let s=shallowRef(e.getStatus(t)),r=e.subscribe(()=>{s.value=e.getStatus(t);});return onScopeDispose(r),s}function J(e,t){return Array.isArray(t)?H(e,t):U(e,t)}async function U(e,t){let s=e.getStatus(t);if(s.hasError&&s.lastError)throw s.lastError;s.isLoading&&await new Promise((u,o)=>{let i=e.subscribe(()=>{let l=e.getStatus(t);l.isLoading||(i(),l.hasError&&l.lastError?o(l.lastError):u());});onScopeDispose(i);});let r=shallowRef(e.getStatus(t)),n=e.subscribe(()=>{r.value=e.getStatus(t);});return onScopeDispose(n),r}async function H(e,t){for(let o of t){let i=e.getStatus(o);if(i.hasError&&i.lastError)throw i.lastError}t.some(o=>e.getStatus(o).isLoading)&&await new Promise((o,i)=>{let l=e.subscribe(()=>{if(t.every(c=>!e.getStatus(c).isLoading)){l();for(let c of t){let f=e.getStatus(c);if(f.hasError&&f.lastError){i(f.lastError);return}}o();}});onScopeDispose(l);});let r=()=>{let o={};for(let i of t)o[i]=e.getStatus(i);return o},n=shallowRef(r()),u=e.subscribe(()=>{n.value=r();});return onScopeDispose(u),n}function X(e,t){assertSystem("useExplain",e);let s=ref(e.explain(t)),r=()=>{s.value=e.explain(t);},n=e.facts.$store.subscribeAll(r),u=e.onSettledChange(r);return onScopeDispose(()=>{n(),u();}),s}function Y(e,t){assertSystem("useConstraintStatus",e);let s=_(e);return computed(()=>{s.value;let r=e.inspect();return t?r.constraints.find(n=>n.id===t)??null:r.constraints})}function Z(e,t,s){assertSystem("useOptimisticUpdate",e);let r=ref(false),n=ref(null),u=null,o=null,i=()=>{u&&(e.restore(u),u=null),r.value=false,n.value=null,o?.(),o=null;},l=S=>{u=e.getSnapshot(),r.value=true,n.value=null,e.batch(S),t&&s&&(o?.(),o=t.subscribe(()=>{let c=t.getStatus(s);!c.isLoading&&!c.hasError?(u=null,r.value=false,o?.(),o=null):c.hasError&&(n.value=c.lastError,i());}));};return onScopeDispose(()=>{o?.();}),{mutate:l,isPending:r,error:n,rollback:i}}function ee(e){assertSystem("useHistory",e);let t=shallowRef(buildHistoryState(e)),s=e.onHistoryChange(()=>{t.value=buildHistoryState(e);});return onScopeDispose(s),t}function te(e,t){let s=[...t?.plugins??[]],r;if(t?.status){let y=createRequirementStatusPlugin();r=y,s.push(y.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});typeof window<"u"?n.start():n.initialize(),onScopeDispose(()=>{n.destroy();});let u=t?.facts,o=t?.derived,i=!u&&!o,l=shallowRef(i?n.facts.$store.toObject():pickFacts(n,u??[])),S=i?n.facts.$store.subscribeAll(()=>{l.value=n.facts.$store.toObject();}):u&&u.length>0?n.facts.$store.subscribe(u,()=>{l.value=pickFacts(n,u);}):null,c=i?Object.keys(n.derive??{}):o??[],f=()=>{let y={};for(let R of c)y[R]=n.read(R);return y},d=shallowRef(f()),h=c.length>0?n.subscribe(c,()=>{d.value=f();}):null;onScopeDispose(()=>{S?.(),h?.();});let w=n.events;return {system:n,facts:l,derived:d,events:w,dispatch:y=>n.dispatch(y),statusPlugin:r}}function ne(){return {useFact:(e,t)=>q(e,t),useDerived:(e,t)=>V(e,t),useDispatch:e=>t=>{e.dispatch(t);},useEvents:e=>P(e),useWatch:(e,t,s)=>N(e,t,s)}}function se(e,t,s){let r=ref(s(e)),n=e.subscribe(t,()=>{r.value=s(e);});return onScopeDispose(n),r}function re(e){let t=e();return typeof window<"u"&&!t.isRunning&&t.start(),onScopeDispose(()=>{t.destroy();}),t}export{ne as createTypedHooks,Y as useConstraintStatus,V as useDerived,te as useDirective,Q as useDispatch,P as useEvents,X as useExplain,q as useFact,ee as useHistory,_ as useInspect,se as useNamespacedSelector,Z as useOptimisticUpdate,re as useQuerySystem,G as useRequirementStatus,z as useSelector,J as useSuspenseRequirement,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","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,CAAO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G5D,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"]}
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","useSuspenseRequirement","_useSuspenseRequirementMulti","_useSuspenseRequirementSingle","initialStatus","resolve","reject","current","types","s","t","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","useQuerySystem","factory"],"mappings":"6WA6EO,SAASA,EAEdC,CAAAA,CACAC,CAAAA,CACoC,CAapC,OAZAC,YAAAA,CAAa,UAAWF,CAAM,CAAA,CAE5B,OAAA,CAAQ,GAAA,CAAI,WAAa,YAAA,EACzB,OAAOC,GAAc,UAAA,EAErB,OAAA,CAAQ,MACN,gJAEF,CAAA,CAIE,MAAM,OAAA,CAAQA,CAAS,EAClBE,CAAAA,CAAcH,CAAAA,CAAQC,CAAS,CAAA,CAIjCG,CAAAA,CAAeJ,EAAQC,CAAS,CACzC,CAGA,SAASG,CAAAA,CACPJ,EACAK,CAAAA,C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2G,CAAAA,GAGf,OAAI,OAAO,OAAW,GAAA,EAAe,CAAC3G,EAAO,SAAA,EAC3CA,CAAAA,CAAO,OAAM,CAGfS,cAAAA,CAAe,IAAM,CACnBT,CAAAA,CAAO,UACT,CAAC,EAEMA,CACT","file":"index.js","sourcesContent":["/**\n * Vue Adapter - Vue 3 composables for Directive\n *\n * Exports: useFact, useDerived, useDispatch, useSelector,\n * useWatch, useInspect, useRequirementStatus, useSuspenseRequirement,\n * useEvents, useExplain, useConstraintStatus, useOptimisticUpdate,\n * useDirective, useHistory, 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// useSuspenseRequirement — async setup() Suspense integration\n// ============================================================================\n\n/**\n * Returns a promise that resolves when a requirement type settles.\n * Designed for Vue's async `setup()` with `<Suspense>`.\n *\n * - If the requirement is loading, the returned promise suspends the component.\n * - If the requirement has an error, the promise rejects with that error.\n * - If the requirement is already settled, resolves immediately.\n *\n * @example\n * ```vue\n * <script setup>\n * import { useSuspenseRequirement } from '@directive-run/vue';\n *\n * // In async setup(), this suspends until FETCH_USER settles\n * const status = await useSuspenseRequirement(statusPlugin, \"FETCH_USER\");\n * </script>\n *\n * <template>\n * <div>Resolved: {{ status.resolvedCount }}</div>\n * </template>\n * ```\n */\n\n/** Single type overload */\nexport function useSuspenseRequirement(\n statusPlugin: StatusPlugin,\n type: string,\n): Promise<ShallowRef<RequirementTypeStatus>>;\n\n/** Multi-type overload */\nexport function useSuspenseRequirement(\n statusPlugin: StatusPlugin,\n types: string[],\n): Promise<\n ShallowRef<Record<string, RequirementTypeStatus>>\n>;\n\n/** Implementation */\nexport function useSuspenseRequirement(\n statusPlugin: StatusPlugin,\n typeOrTypes: string | string[],\n): Promise<\n | ShallowRef<RequirementTypeStatus>\n | ShallowRef<Record<string, RequirementTypeStatus>>\n> {\n if (Array.isArray(typeOrTypes)) {\n return _useSuspenseRequirementMulti(statusPlugin, typeOrTypes);\n }\n\n return _useSuspenseRequirementSingle(statusPlugin, typeOrTypes);\n}\n\nasync function _useSuspenseRequirementSingle(\n statusPlugin: StatusPlugin,\n type: string,\n): Promise<ShallowRef<RequirementTypeStatus>> {\n const initialStatus = statusPlugin.getStatus(type);\n\n if (initialStatus.hasError && initialStatus.lastError) {\n throw initialStatus.lastError;\n }\n\n // If loading, wait for it to settle\n if (initialStatus.isLoading) {\n await new Promise<void>((resolve, reject) => {\n const unsubscribe = statusPlugin.subscribe(() => {\n const current = statusPlugin.getStatus(type);\n if (!current.isLoading) {\n unsubscribe();\n if (current.hasError && current.lastError) {\n reject(current.lastError);\n } else {\n resolve();\n }\n }\n });\n onScopeDispose(unsubscribe);\n });\n }\n\n // Now settled — return a reactive ref that continues tracking\n const status = shallowRef<RequirementTypeStatus>(\n statusPlugin.getStatus(type),\n );\n const unsubscribe = statusPlugin.subscribe(() => {\n status.value = statusPlugin.getStatus(type);\n });\n onScopeDispose(unsubscribe);\n\n return status;\n}\n\nasync function _useSuspenseRequirementMulti(\n statusPlugin: StatusPlugin,\n types: string[],\n): Promise<ShallowRef<Record<string, RequirementTypeStatus>>> {\n // Check for immediate errors\n for (const type of types) {\n const s = statusPlugin.getStatus(type);\n if (s.hasError && s.lastError) {\n throw s.lastError;\n }\n }\n\n // If any are loading, wait for all to settle\n const anyLoading = types.some(\n (t) => statusPlugin.getStatus(t).isLoading,\n );\n if (anyLoading) {\n await new Promise<void>((resolve, reject) => {\n const unsubscribe = statusPlugin.subscribe(() => {\n const allDone = types.every(\n (t) => !statusPlugin.getStatus(t).isLoading,\n );\n if (allDone) {\n unsubscribe();\n // Check for errors after settling\n for (const type of types) {\n const s = statusPlugin.getStatus(type);\n if (s.hasError && s.lastError) {\n reject(s.lastError);\n\n return;\n }\n }\n resolve();\n }\n });\n onScopeDispose(unsubscribe);\n });\n }\n\n // Now settled — return a reactive ref that continues tracking\n const getValues = (): Record<string, RequirementTypeStatus> => {\n const result: Record<string, RequirementTypeStatus> = {};\n for (const type of types) {\n result[type] = statusPlugin.getStatus(type);\n }\n\n return result;\n };\n const status = shallowRef(getValues());\n const unsubscribe = statusPlugin.subscribe(() => {\n status.value = getValues();\n });\n onScopeDispose(unsubscribe);\n\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 // SSR guard: initialize facts for SSR rendering, start reconciliation only in the browser\n if (typeof window !== \"undefined\") {\n system.start();\n } else {\n system.initialize();\n }\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\n// ============================================================================\n// useQuerySystem — Stable query system with lifecycle management\n// ============================================================================\n\n/**\n * Vue composable to create and manage a query system with proper lifecycle.\n *\n * Accepts a factory function that creates the system.\n * Handles cleanup on scope disposal.\n *\n * @example\n * ```vue\n * <script setup>\n * import { useQuerySystem, useDerived } from \"@directive-run/vue\";\n * import { createQuerySystem } from \"@directive-run/query\";\n *\n * const app = useQuerySystem(() =>\n * createQuerySystem({\n * facts: { userId: \"\" },\n * queries: { user: { key: ..., fetcher: ... } },\n * autoStart: false,\n * })\n * );\n *\n * const user = useDerived(app, \"user\");\n * </script>\n * ```\n */\n// biome-ignore lint/suspicious/noExplicitAny: Factory return type varies\nexport function useQuerySystem<T extends { start: () => void; destroy: () => void; isRunning?: boolean; [key: string]: any }>(\n factory: () => T,\n): T {\n const system = factory();\n\n // Start if not already running\n if (typeof window !== \"undefined\" && !system.isRunning) {\n system.start();\n }\n\n onScopeDispose(() => {\n system.destroy();\n });\n\n return system;\n}\n"]}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@directive-run/vue",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
4
4
  "description": "Vue composition API adapter for Directive.",
5
- "license": "MIT",
5
+ "license": "(MIT OR Apache-2.0)",
6
6
  "author": "Jason Comes",
7
7
  "repository": {
8
8
  "type": "git",
@@ -44,7 +44,7 @@
44
44
  "dist"
45
45
  ],
46
46
  "peerDependencies": {
47
- "@directive-run/core": "*",
47
+ "@directive-run/core": "^0.8.0",
48
48
  "vue": ">=3"
49
49
  },
50
50
  "devDependencies": {
@@ -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.8.2"
55
+ "@directive-run/core": "0.8.4"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "tsup",