@directive-run/lit 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
- 'use strict';var core=require('@directive-run/core'),adapterUtils=require('@directive-run/core/adapter-utils');var E=Symbol("directive"),r=class{host;system;unsubscribe;constructor(e,t){this.host=e,this.system=t,e.addController(this);}hostConnected(){this.subscribe();}hostDisconnected(){this.unsubscribe?.(),this.unsubscribe=void 0;}requestUpdate(){this.host.requestUpdate();}},d=class extends r{keys;isMulti;value;constructor(e,t,i){super(e,t),this.isMulti=Array.isArray(i),this.keys=this.isMulti?i:[i],this.value=this.getValues(),process.env.NODE_ENV!=="production"&&!this.isMulti&&this.value===void 0&&console.warn(`[Directive] DerivedController("${this.keys[0]}") returned undefined. Check that "${this.keys[0]}" is defined in your module's derive property.`);}getValues(){if(this.isMulti){let e={};for(let t of this.keys)e[t]=this.system.read(t);return e}return this.system.read(this.keys[0])}subscribe(){this.value=this.getValues(),this.unsubscribe=this.system.subscribe(this.keys,()=>{this.value=this.getValues(),this.requestUpdate();});}},h=class extends r{factKey;value;constructor(e,t,i){super(e,t),this.factKey=i,this.value=t.facts.$store.get(i),process.env.NODE_ENV!=="production"&&(t.facts.$store.has(i)||console.warn(`[Directive] FactController("${i}") \u2014 fact not found in store. Check that "${i}" is defined in your module's schema.`));}subscribe(){this.value=this.system.facts.$store.get(this.factKey),this.unsubscribe=this.system.facts.$store.subscribe([this.factKey],()=>{this.value=this.system.facts.$store.get(this.factKey),this.requestUpdate();});}},v=class extends r{value;throttleMs;throttleCleanup;unsubSettled;constructor(e,t,i){super(e,t),this.throttleMs=i?.throttleMs??0,this.value=adapterUtils.computeInspectState(t);}subscribe(){this.value=adapterUtils.computeInspectState(this.system);let e=()=>{this.value=adapterUtils.computeInspectState(this.system),this.requestUpdate();};if(this.throttleMs>0){let{throttled:t,cleanup:i}=adapterUtils.createThrottle(e,this.throttleMs);this.throttleCleanup=i,this.unsubscribe=this.system.facts.$store.subscribeAll(t),this.unsubSettled=this.system.onSettledChange(t);}else this.unsubscribe=this.system.facts.$store.subscribeAll(e),this.unsubSettled=this.system.onSettledChange(e);}hostDisconnected(){this.throttleCleanup?.(),this.unsubSettled?.(),super.hostDisconnected();}},y=class{host;statusPlugin;type;unsubscribe;value;constructor(e,t,i){this.host=e,this.statusPlugin=t,this.type=i,this.value=t.getStatus(i),e.addController(this);}hostConnected(){this.value=this.statusPlugin.getStatus(this.type),this.unsubscribe=this.statusPlugin.subscribe(()=>{this.value=this.statusPlugin.getStatus(this.type),this.host.requestUpdate();});}hostDisconnected(){this.unsubscribe?.(),this.unsubscribe=void 0;}},p=class extends r{selector;equalityFn;autoTrack;deriveKeySet;trackedFactKeys=[];trackedDeriveKeys=[];unsubs=[];value;constructor(e,t,i,n=adapterUtils.defaultEquality,o){super(e,t),this.selector=i,this.equalityFn=n,this.autoTrack=o?.autoTrack??true,this.deriveKeySet=new Set(Object.keys(t.derive??{}));let a=this.runWithTracking();this.value=a.value,this.trackedFactKeys=a.factKeys,this.trackedDeriveKeys=a.deriveKeys;}runWithTracking(){return adapterUtils.runTrackedSelector(this.system,this.deriveKeySet,this.selector)}resubscribe(){for(let t of this.unsubs)t();this.unsubs=[];let e=()=>{let t=this.runWithTracking();this.equalityFn(this.value,t.value)||(this.value=t.value,this.requestUpdate()),this.autoTrack&&adapterUtils.depsChanged(this.trackedFactKeys,t.factKeys,this.trackedDeriveKeys,t.deriveKeys)&&(this.trackedFactKeys=t.factKeys,this.trackedDeriveKeys=t.deriveKeys,this.resubscribe());};this.autoTrack?(this.trackedFactKeys.length>0?this.unsubs.push(this.system.facts.$store.subscribe(this.trackedFactKeys,e)):this.trackedDeriveKeys.length===0&&this.unsubs.push(this.system.facts.$store.subscribeAll(e)),this.trackedDeriveKeys.length>0&&this.unsubs.push(this.system.subscribe(this.trackedDeriveKeys,e))):this.unsubs.push(this.system.facts.$store.subscribeAll(e));}subscribe(){let e=this.runWithTracking();this.value=e.value,this.trackedFactKeys=e.factKeys,this.trackedDeriveKeys=e.deriveKeys,this.resubscribe();}hostDisconnected(){for(let e of this.unsubs)e();this.unsubs=[],super.hostDisconnected();}},g=class extends r{key;callback;constructor(e,t,i,n){super(e,t),this.key=i,this.callback=n;}subscribe(){this.unsubscribe=this.system.watch(this.key,this.callback);}},m=class extends r{requirementId;value;unsubSettled;constructor(e,t,i){super(e,t),this.requirementId=i,this.value=t.explain(i);}subscribe(){this.value=this.system.explain(this.requirementId);let e=()=>{this.value=this.system.explain(this.requirementId),this.requestUpdate();};this.unsubscribe=this.system.facts.$store.subscribeAll(e),this.unsubSettled=this.system.onSettledChange(e);}hostDisconnected(){this.unsubSettled?.(),super.hostDisconnected();}},f=class extends r{constraintId;value;unsubSettled;constructor(e,t,i){super(e,t),this.constraintId=i,this.value=this.getVal();}getVal(){let e=this.system.inspect();return this.constraintId?e.constraints.find(t=>t.id===this.constraintId)??null:e.constraints}subscribe(){this.value=this.getVal();let e=()=>{this.value=this.getVal(),this.requestUpdate();};this.unsubscribe=this.system.facts.$store.subscribeAll(e),this.unsubSettled=this.system.onSettledChange(e);}hostDisconnected(){this.unsubSettled?.(),super.hostDisconnected();}},b=class{host;system;statusPlugin;requirementType;snapshot=null;statusUnsub=null;isPending=false;error=null;constructor(e,t,i,n){this.host=e,this.system=t,this.statusPlugin=i,this.requirementType=n,e.addController(this);}hostConnected(){}hostDisconnected(){this.statusUnsub?.(),this.statusUnsub=null;}rollback(){this.snapshot&&(this.system.restore(this.snapshot),this.snapshot=null),this.isPending=false,this.error=null,this.statusUnsub?.(),this.statusUnsub=null,this.host.requestUpdate();}mutate(e){this.snapshot=this.system.getSnapshot(),this.isPending=true,this.error=null,this.system.batch(e),this.host.requestUpdate(),this.statusPlugin&&this.requirementType&&(this.statusUnsub?.(),this.statusUnsub=this.statusPlugin.subscribe(()=>{let t=this.statusPlugin.getStatus(this.requirementType);!t.isLoading&&!t.hasError?(this.snapshot=null,this.isPending=false,this.statusUnsub?.(),this.statusUnsub=null,this.host.requestUpdate()):t.hasError&&(this.error=t.lastError,this.rollback());}));}},C=class{options;_system=null;constructor(e,t){this.options=t,e.addController(this);}get system(){if(!this._system)throw new Error(`[Directive] SystemController.system is not available. This can happen if:
1
+ 'use strict';var core=require('@directive-run/core'),adapterUtils=require('@directive-run/core/adapter-utils');var U=Symbol("directive"),r=class{host;system;unsubscribe;constructor(e,t){this.host=e,this.system=t,e.addController(this);}hostConnected(){this.subscribe();}hostDisconnected(){this.unsubscribe?.(),this.unsubscribe=void 0;}requestUpdate(){this.host.requestUpdate();}},d=class extends r{keys;isMulti;value;constructor(e,t,i){super(e,t),this.isMulti=Array.isArray(i),this.keys=this.isMulti?i:[i],this.value=this.getValues(),process.env.NODE_ENV!=="production"&&!this.isMulti&&this.value===void 0&&console.warn(`[Directive] DerivedController("${this.keys[0]}") returned undefined. Check that "${this.keys[0]}" is defined in your module's derive property.`);}getValues(){if(this.isMulti){let e={};for(let t of this.keys)e[t]=this.system.read(t);return e}return this.system.read(this.keys[0])}subscribe(){this.value=this.getValues(),this.unsubscribe=this.system.subscribe(this.keys,()=>{this.value=this.getValues(),this.requestUpdate();});}},h=class extends r{factKey;value;constructor(e,t,i){super(e,t),this.factKey=i,this.value=t.facts.$store.get(i),process.env.NODE_ENV!=="production"&&(t.facts.$store.has(i)||console.warn(`[Directive] FactController("${i}") \u2014 fact not found in store. Check that "${i}" is defined in your module's schema.`));}subscribe(){this.value=this.system.facts.$store.get(this.factKey),this.unsubscribe=this.system.facts.$store.subscribe([this.factKey],()=>{this.value=this.system.facts.$store.get(this.factKey),this.requestUpdate();});}},v=class extends r{value;throttleMs;throttleCleanup;unsubSettled;constructor(e,t,i){super(e,t),this.throttleMs=i?.throttleMs??0,this.value=adapterUtils.computeInspectState(t);}subscribe(){this.value=adapterUtils.computeInspectState(this.system);let e=()=>{this.value=adapterUtils.computeInspectState(this.system),this.requestUpdate();};if(this.throttleMs>0){let{throttled:t,cleanup:i}=adapterUtils.createThrottle(e,this.throttleMs);this.throttleCleanup=i,this.unsubscribe=this.system.facts.$store.subscribeAll(t),this.unsubSettled=this.system.onSettledChange(t);}else this.unsubscribe=this.system.facts.$store.subscribeAll(e),this.unsubSettled=this.system.onSettledChange(e);}hostDisconnected(){this.throttleCleanup?.(),this.unsubSettled?.(),super.hostDisconnected();}},y=class{host;statusPlugin;type;unsubscribe;value;constructor(e,t,i){this.host=e,this.statusPlugin=t,this.type=i,this.value=t.getStatus(i),e.addController(this);}hostConnected(){this.value=this.statusPlugin.getStatus(this.type),this.unsubscribe=this.statusPlugin.subscribe(()=>{this.value=this.statusPlugin.getStatus(this.type),this.host.requestUpdate();});}hostDisconnected(){this.unsubscribe?.(),this.unsubscribe=void 0;}},p=class extends r{selector;equalityFn;autoTrack;deriveKeySet;trackedFactKeys=[];trackedDeriveKeys=[];unsubs=[];value;constructor(e,t,i,n=adapterUtils.defaultEquality,o){super(e,t),this.selector=i,this.equalityFn=n,this.autoTrack=o?.autoTrack??true,this.deriveKeySet=new Set(Object.keys(t.derive??{}));let a=this.runWithTracking();this.value=a.value,this.trackedFactKeys=a.factKeys,this.trackedDeriveKeys=a.deriveKeys;}runWithTracking(){return adapterUtils.runTrackedSelector(this.system,this.deriveKeySet,this.selector)}resubscribe(){for(let t of this.unsubs)t();this.unsubs=[];let e=()=>{let t=this.runWithTracking();this.equalityFn(this.value,t.value)||(this.value=t.value,this.requestUpdate()),this.autoTrack&&adapterUtils.depsChanged(this.trackedFactKeys,t.factKeys,this.trackedDeriveKeys,t.deriveKeys)&&(this.trackedFactKeys=t.factKeys,this.trackedDeriveKeys=t.deriveKeys,this.resubscribe());};this.autoTrack?(this.trackedFactKeys.length>0?this.unsubs.push(this.system.facts.$store.subscribe(this.trackedFactKeys,e)):this.trackedDeriveKeys.length===0&&this.unsubs.push(this.system.facts.$store.subscribeAll(e)),this.trackedDeriveKeys.length>0&&this.unsubs.push(this.system.subscribe(this.trackedDeriveKeys,e))):this.unsubs.push(this.system.facts.$store.subscribeAll(e));}subscribe(){let e=this.runWithTracking();this.value=e.value,this.trackedFactKeys=e.factKeys,this.trackedDeriveKeys=e.deriveKeys,this.resubscribe();}hostDisconnected(){for(let e of this.unsubs)e();this.unsubs=[],super.hostDisconnected();}},m=class extends r{key;callback;constructor(e,t,i,n){super(e,t),this.key=i,this.callback=n;}subscribe(){this.unsubscribe=this.system.watch(this.key,this.callback);}},g=class extends r{requirementId;value;unsubSettled;constructor(e,t,i){super(e,t),this.requirementId=i,this.value=t.explain(i);}subscribe(){this.value=this.system.explain(this.requirementId);let e=()=>{this.value=this.system.explain(this.requirementId),this.requestUpdate();};this.unsubscribe=this.system.facts.$store.subscribeAll(e),this.unsubSettled=this.system.onSettledChange(e);}hostDisconnected(){this.unsubSettled?.(),super.hostDisconnected();}},b=class extends r{constraintId;value;unsubSettled;constructor(e,t,i){super(e,t),this.constraintId=i,this.value=this.getVal();}getVal(){let e=this.system.inspect();return this.constraintId?e.constraints.find(t=>t.id===this.constraintId)??null:e.constraints}subscribe(){this.value=this.getVal();let e=()=>{this.value=this.getVal(),this.requestUpdate();};this.unsubscribe=this.system.facts.$store.subscribeAll(e),this.unsubSettled=this.system.onSettledChange(e);}hostDisconnected(){this.unsubSettled?.(),super.hostDisconnected();}},f=class{host;system;statusPlugin;requirementType;snapshot=null;statusUnsub=null;isPending=false;error=null;constructor(e,t,i,n){this.host=e,this.system=t,this.statusPlugin=i,this.requirementType=n,e.addController(this);}hostConnected(){}hostDisconnected(){this.statusUnsub?.(),this.statusUnsub=null;}rollback(){this.snapshot&&(this.system.restore(this.snapshot),this.snapshot=null),this.isPending=false,this.error=null,this.statusUnsub?.(),this.statusUnsub=null,this.host.requestUpdate();}mutate(e){this.snapshot=this.system.getSnapshot(),this.isPending=true,this.error=null,this.system.batch(e),this.host.requestUpdate(),this.statusPlugin&&this.requirementType&&(this.statusUnsub?.(),this.statusUnsub=this.statusPlugin.subscribe(()=>{let t=this.statusPlugin.getStatus(this.requirementType);!t.isLoading&&!t.hasError?(this.snapshot=null,this.isPending=false,this.statusUnsub?.(),this.statusUnsub=null,this.host.requestUpdate()):t.hasError&&(this.error=t.lastError,this.rollback());}));}},R=class{options;_system=null;constructor(e,t){this.options=t,e.addController(this);}get system(){if(!this._system)throw new Error(`[Directive] SystemController.system is not available. This can happen if:
2
2
  1. Accessed before hostConnected (e.g., in a class field initializer)
3
3
  2. Accessed after hostDisconnected (system was destroyed)
4
- Solution: Access system only in lifecycle methods (connectedCallback, render) or after the element is connected to the DOM.`);return this._system}hostConnected(){let t="id"in this.options&&"schema"in this.options?core.createSystem({module:this.options}):core.createSystem(this.options);this._system=t,this._system.start();}hostDisconnected(){this._system?.destroy(),this._system=null;}},S=class{host;moduleDef;config;_system=null;unsubFacts;unsubDerived;facts={};derived={};statusPlugin;get system(){if(!this._system)throw new Error("[Directive] ModuleController.system is not available before hostConnected.");return this._system}get events(){return this.system.events}constructor(e,t,i){this.host=e,this.moduleDef=t,this.config=i,e.addController(this);}hostConnected(){let e=[...this.config?.plugins??[]];if(this.config?.status){let o=core.createRequirementStatusPlugin();this.statusPlugin=o,e.push(o.plugin);}let t=core.createSystem({module:this.moduleDef,plugins:e.length>0?e:void 0,debug:this.config?.debug,errorBoundary:this.config?.errorBoundary,tickMs:this.config?.tickMs,zeroConfig:this.config?.zeroConfig,initialFacts:this.config?.initialFacts});this._system=t,t.start(),this.facts=t.facts.$store.toObject(),this.unsubFacts=t.facts.$store.subscribeAll(()=>{this.facts=t.facts.$store.toObject(),this.host.requestUpdate();});let i=Object.keys(t.derive??{}),n=()=>{let o={};for(let a of i)o[a]=t.read(a);return o};this.derived=n(),i.length>0&&(this.unsubDerived=t.subscribe(i,()=>{this.derived=n(),this.host.requestUpdate();}));}hostDisconnected(){this.unsubFacts?.(),this.unsubDerived?.(),this._system?.destroy(),this._system=null;}dispatch(e){this.system.dispatch(e);}};function I(s,e,t){return new d(s,e,t)}function w(s,e,t){return new h(s,e,t)}function U(s,e,t){return new v(s,e,t)}function _(s,e,t){return new y(s,e,t)}function H(s,e,t,i){return new g(s,e,t,i)}function V(s,e,t,i=adapterUtils.defaultEquality,n){return new p(s,e,t,i,n)}function $(s,e,t){return new m(s,e,t)}function A(s,e,t){return new f(s,e,t)}function O(s,e,t,i){return new b(s,e,t,i)}function B(s,e,t){return new S(s,e,t)}function W(s){return adapterUtils.assertSystem("useDispatch",s),e=>{s.dispatch(e);}}function z(s){return adapterUtils.assertSystem("useEvents",s),s.events}var k=class{constructor(e,t){this._host=e;this._system=t;this._host.addController(this);}value=null;_unsub;hostConnected(){this.value=adapterUtils.buildTimeTravelState(this._system),this._unsub=this._system.onTimeTravelChange(()=>{this.value=adapterUtils.buildTimeTravelState(this._system),this._host.requestUpdate();});}hostDisconnected(){this._unsub?.(),this._unsub=void 0;}};function j(s){return adapterUtils.assertSystem("useTimeTravel",s),adapterUtils.buildTimeTravelState(s)}function N(s,e){return ()=>s.read(e)}function L(s,e){return ()=>s.facts.$store.get(e)}function G(){return {createDerived:(s,e,t)=>I(s,e,t),createFact:(s,e,t)=>w(s,e,t),useDispatch:s=>e=>{s.dispatch(e);},useEvents:s=>s.events,createWatch:(s,e,t,i)=>H(s,e,t,i)}}Object.defineProperty(exports,"shallowEqual",{enumerable:true,get:function(){return adapterUtils.shallowEqual}});exports.ConstraintStatusController=f;exports.DerivedController=d;exports.DirectiveSelectorController=p;exports.ExplainController=m;exports.FactController=h;exports.InspectController=v;exports.ModuleController=S;exports.OptimisticUpdateController=b;exports.RequirementStatusController=y;exports.SystemController=C;exports.TimeTravelController=k;exports.WatchController=g;exports.createConstraintStatus=A;exports.createDerived=I;exports.createDirectiveSelector=V;exports.createExplain=$;exports.createFact=w;exports.createInspect=U;exports.createModule=B;exports.createOptimisticUpdate=O;exports.createRequirementStatus=_;exports.createTypedHooks=G;exports.createWatch=H;exports.directiveContext=E;exports.getDerived=N;exports.getFact=L;exports.useDispatch=W;exports.useEvents=z;exports.useTimeTravel=j;//# sourceMappingURL=index.cjs.map
4
+ Solution: Access system only in lifecycle methods (connectedCallback, render) or after the element is connected to the DOM.`);return this._system}hostConnected(){let t="id"in this.options&&"schema"in this.options?core.createSystem({module:this.options}):core.createSystem(this.options);this._system=t,this._system.start();}hostDisconnected(){this._system?.destroy(),this._system=null;}},S=class{host;moduleDef;config;_system=null;unsubFacts;unsubDerived;facts={};derived={};statusPlugin;get system(){if(!this._system)throw new Error("[Directive] ModuleController.system is not available before hostConnected.");return this._system}get events(){return this.system.events}constructor(e,t,i){this.host=e,this.moduleDef=t,this.config=i,e.addController(this);}hostConnected(){let e=[...this.config?.plugins??[]];if(this.config?.status){let o=core.createRequirementStatusPlugin();this.statusPlugin=o,e.push(o.plugin);}let t=core.createSystem({module:this.moduleDef,plugins:e.length>0?e:void 0,debug:this.config?.debug,errorBoundary:this.config?.errorBoundary,tickMs:this.config?.tickMs,zeroConfig:this.config?.zeroConfig,initialFacts:this.config?.initialFacts});this._system=t,t.start(),this.facts=t.facts.$store.toObject(),this.unsubFacts=t.facts.$store.subscribeAll(()=>{this.facts=t.facts.$store.toObject(),this.host.requestUpdate();});let i=Object.keys(t.derive??{}),n=()=>{let o={};for(let a of i)o[a]=t.read(a);return o};this.derived=n(),i.length>0&&(this.unsubDerived=t.subscribe(i,()=>{this.derived=n(),this.host.requestUpdate();}));}hostDisconnected(){this.unsubFacts?.(),this.unsubDerived?.(),this._system?.destroy(),this._system=null;}dispatch(e){this.system.dispatch(e);}};function w(s,e,t){return new d(s,e,t)}function H(s,e,t){return new h(s,e,t)}function _(s,e,t){return new v(s,e,t)}function V(s,e,t){return new y(s,e,t)}function q(s,e,t,i){return new m(s,e,t,i)}function $(s,e,t,i=adapterUtils.defaultEquality,n){return new p(s,e,t,i,n)}function A(s,e,t){return new g(s,e,t)}function N(s,e,t){return new b(s,e,t)}function O(s,e,t,i){return new f(s,e,t,i)}function B(s,e,t){return new S(s,e,t)}function W(s){return adapterUtils.assertSystem("useDispatch",s),e=>{s.dispatch(e);}}function z(s){return adapterUtils.assertSystem("useEvents",s),s.events}var k=class{constructor(e,t){this._host=e;this._system=t;this._host.addController(this);}value=null;_unsub;hostConnected(){this.value=adapterUtils.buildTimeTravelState(this._system),this._unsub=this._system.onTimeTravelChange(()=>{this.value=adapterUtils.buildTimeTravelState(this._system),this._host.requestUpdate();});}hostDisconnected(){this._unsub?.(),this._unsub=void 0;}};function j(s){return adapterUtils.assertSystem("useTimeTravel",s),adapterUtils.buildTimeTravelState(s)}function L(s,e){return ()=>s.read(e)}function G(s,e){return ()=>s.facts.$store.get(e)}function J(){return {createDerived:(s,e,t)=>w(s,e,t),createFact:(s,e,t)=>H(s,e,t),useDispatch:s=>e=>{s.dispatch(e);},useEvents:s=>s.events,createWatch:(s,e,t,i)=>q(s,e,t,i)}}var M=class{host;system;keys;selector;unsubscribe;value;constructor(e,t,i,n){this.host=e,this.system=t,this.keys=i,this.selector=n,this.value=n(t),e.addController(this);}hostConnected(){this.value=this.selector(this.system),this.unsubscribe=this.system.subscribe(this.keys,()=>{this.value=this.selector(this.system),this.host.requestUpdate();});}hostDisconnected(){this.unsubscribe?.(),this.unsubscribe=void 0;}};function Q(s,e,t,i){return new M(s,e,t,i)}Object.defineProperty(exports,"shallowEqual",{enumerable:true,get:function(){return adapterUtils.shallowEqual}});exports.ConstraintStatusController=b;exports.DerivedController=d;exports.DirectiveSelectorController=p;exports.ExplainController=g;exports.FactController=h;exports.InspectController=v;exports.ModuleController=S;exports.NamespacedSelectorController=M;exports.OptimisticUpdateController=f;exports.RequirementStatusController=y;exports.SystemController=R;exports.TimeTravelController=k;exports.WatchController=m;exports.createConstraintStatus=N;exports.createDerived=w;exports.createDirectiveSelector=$;exports.createExplain=A;exports.createFact=H;exports.createInspect=_;exports.createModule=B;exports.createNamespacedSelector=Q;exports.createOptimisticUpdate=O;exports.createRequirementStatus=V;exports.createTypedHooks=J;exports.createWatch=q;exports.directiveContext=U;exports.getDerived=L;exports.getFact=G;exports.useDispatch=W;exports.useEvents=z;exports.useTimeTravel=j;//# sourceMappingURL=index.cjs.map
5
5
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["directiveContext","DirectiveController","host","system","DerivedController","key","result","id","FactController","factKey","InspectController","options","computeInspectState","update","throttled","cleanup","createThrottle","RequirementStatusController","statusPlugin","type","DirectiveSelectorController","selector","equalityFn","defaultEquality","initial","runTrackedSelector","unsub","onUpdate","depsChanged","WatchController","callback","ExplainController","requirementId","ConstraintStatusController","constraintId","inspection","c","OptimisticUpdateController","requirementType","updateFn","status","SystemController","createSystem","ModuleController","moduleDef","config","allPlugins","sp","createRequirementStatusPlugin","derivationKeys","getDerived","event","createDerived","createFact","createInspect","createRequirementStatus","createWatch","derivationId","createDirectiveSelector","createExplain","createConstraintStatus","createOptimisticUpdate","createModule","useDispatch","assertSystem","useEvents","TimeTravelController","_host","_system","buildTimeTravelState","useTimeTravel","getFact","createTypedHooks"],"mappings":"+GAgEO,IAAMA,CAAAA,CAAmB,MAAA,CAAO,WAAW,CAAA,CASnCC,CAAAA,CAAf,KAAiE,CACtD,IAAA,CAEA,MAAA,CACA,WAAA,CAGV,WAAA,CAAYC,CAAAA,CAA8BC,CAAAA,CAAiC,CAC1E,IAAA,CAAK,IAAA,CAAOD,CAAAA,CACZ,IAAA,CAAK,MAAA,CAASC,CAAAA,CACdD,CAAAA,CAAK,aAAA,CAAc,IAAI,EACxB,CAEA,aAAA,EAAsB,CACrB,IAAA,CAAK,SAAA,GACN,CAEA,gBAAA,EAAyB,CACxB,IAAA,CAAK,WAAA,IAAc,CACnB,IAAA,CAAK,WAAA,CAAc,OACpB,CAIU,aAAA,EAAsB,CAC/B,IAAA,CAAK,IAAA,CAAK,aAAA,GACX,CACD,CAAA,CAYaE,CAAAA,CAAN,cAAmCH,CAAoB,CACrD,IAAA,CACA,OAAA,CACR,KAAA,CAEA,WAAA,CACCC,CAAAA,CAEAC,CAAAA,CACAE,EACC,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AAK,MAAA,IAAS,CACd,IAAA,CAAK,OAAS,OACf,CACD,EAOO,SAASC,EAAcnE,CAAAA,CAAyD,CACtF,OAAA6D,yBAAAA,CAAa,gBAAiB7D,CAAM,CAAA,CAC7BkE,iCAAAA,CAAqBlE,CAAM,CACnC,CAEO,SAAS+C,CAAAA,CAEf/C,CAAAA,CACAsD,CAAAA,CACU,CACV,OAAO,IAAMtD,EAAO,IAAA,CAAKsD,CAAY,CACtC,CAEO,SAASc,CAAAA,CAEfpE,CAAAA,CACAM,CAAAA,CACsB,CACtB,OAAO,IAAMN,CAAAA,CAAO,KAAA,CAAM,MAAA,CAAO,GAAA,CAAIM,CAAO,CAC7C,CAMO,SAAS+D,CAAAA,EAmBd,CACD,OAAO,CACN,cAAe,CACdtE,CAAAA,CACAC,CAAAA,CACAsD,CAAAA,GACIL,EAAsClD,CAAAA,CAAMC,CAAAA,CAAQsD,CAAsB,CAAA,CAC/E,UAAA,CAAY,CACXvD,CAAAA,CACAC,CAAAA,CACAM,IACI4C,CAAAA,CAA6BnD,CAAAA,CAAMC,CAAAA,CAAQM,CAAiB,EACjE,WAAA,CAAcN,CAAAA,EACLgD,CAAAA,EAA0B,CACjChD,EAAO,QAAA,CAASgD,CAAK,EACtB,CAAA,CAED,UAAYhD,CAAAA,EAAkCA,CAAAA,CAAO,MAAA,CACrD,WAAA,CAAa,CACZD,CAAAA,CACAC,CAAAA,CACAE,CAAAA,CACAyB,CAAAA,GACI0B,EAAqBtD,CAAAA,CAAMC,CAAAA,CAAQE,CAAAA,CAAKyB,CAAQ,CACtD,CACD","file":"index.cjs","sourcesContent":["/**\n * Lit Adapter - Consolidated Web Components integration for Directive\n *\n * Controllers: DerivedController, FactController,\n * InspectController (with throttle), RequirementStatusController,\n * DirectiveSelectorController,\n * WatchController (with fact mode), SystemController,\n * ExplainController, ConstraintStatusController, OptimisticUpdateController, ModuleController\n *\n * Factories: createDerived, createFact, createInspect,\n * createRequirementStatus, createWatch,\n * createDirectiveSelector, useDispatch, useEvents, useTimeTravel,\n * getDerived, getFact, createTypedHooks, shallowEqual\n */\n\nimport type { ReactiveController, ReactiveControllerHost } from \"lit\";\nimport type {\n\tCreateSystemOptionsSingle,\n\tModuleSchema,\n\tModuleDef,\n\tPlugin,\n\tDebugConfig,\n\tErrorBoundaryConfig,\n\tInferFacts,\n\tInferDerivations,\n\tInferEvents,\n\tSingleModuleSystem,\n\tSystemSnapshot,\n\tTimeTravelState,\n} from \"@directive-run/core\";\nimport {\n\tcreateSystem,\n\tcreateRequirementStatusPlugin,\n} from \"@directive-run/core\";\nimport type { RequirementTypeStatus } from \"@directive-run/core\";\nimport {\n\ttype InspectState,\n\ttype ConstraintInfo,\n\ttype TrackedSelectorResult,\n\tcomputeInspectState,\n\tcreateThrottle,\n\tassertSystem,\n\tdefaultEquality,\n\tbuildTimeTravelState,\n\trunTrackedSelector,\n\tdepsChanged,\n\tshallowEqual,\n} from \"@directive-run/core/adapter-utils\";\n\n// Re-export for convenience\nexport type { RequirementTypeStatus, InspectState, ConstraintInfo };\nexport { shallowEqual };\n\n/** Type for the requirement status plugin return value */\nexport type StatusPlugin = ReturnType<typeof createRequirementStatusPlugin>;\n\n// ============================================================================\n// Context\n// ============================================================================\n\n/**\n * Context key for Directive system.\n * Use with @lit/context for dependency injection across shadow DOM boundaries.\n */\nexport const directiveContext = Symbol(\"directive\");\n\n// ============================================================================\n// Base Controller\n// ============================================================================\n\n/**\n * Base controller that manages system subscription lifecycle.\n */\nabstract class DirectiveController implements ReactiveController {\n\tprotected host: ReactiveControllerHost;\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tprotected system: SingleModuleSystem<any>;\n\tprotected unsubscribe?: () => void;\n\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tconstructor(host: ReactiveControllerHost, system: SingleModuleSystem<any>) {\n\t\tthis.host = host;\n\t\tthis.system = system;\n\t\thost.addController(this);\n\t}\n\n\thostConnected(): void {\n\t\tthis.subscribe();\n\t}\n\n\thostDisconnected(): void {\n\t\tthis.unsubscribe?.();\n\t\tthis.unsubscribe = undefined;\n\t}\n\n\tprotected abstract subscribe(): void;\n\n\tprotected requestUpdate(): void {\n\t\tthis.host.requestUpdate();\n\t}\n}\n\n// ============================================================================\n// Core Controllers\n// ============================================================================\n\n/**\n * Reactive controller for derivations.\n * Accepts a single key (string) or an array of keys (string[]).\n * - Single key: `.value` returns `T`\n * - Array of keys: `.value` returns `Record<string, unknown>`\n */\nexport class DerivedController<T> extends DirectiveController {\n\tprivate keys: string[];\n\tprivate isMulti: boolean;\n\tvalue: T;\n\n\tconstructor(\n\t\thost: ReactiveControllerHost,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\t\tsystem: SingleModuleSystem<any>,\n\t\tkey: string | string[],\n\t) {\n\t\tsuper(host, system);\n\t\tthis.isMulti = Array.isArray(key);\n\t\tthis.keys = this.isMulti ? (key as string[]) : [key as string];\n\t\tthis.value = this.getValues();\n\n\t\tif (process.env.NODE_ENV !== \"production\") {\n\t\t\tif (!this.isMulti && this.value === undefined) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[Directive] DerivedController(\"${this.keys[0]}\") returned undefined. ` +\n\t\t\t\t\t`Check that \"${this.keys[0]}\" is defined in your module's derive property.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getValues(): T {\n\t\tif (this.isMulti) {\n\t\t\tconst result: Record<string, unknown> = {};\n\t\t\tfor (const id of this.keys) {\n\t\t\t\tresult[id] = this.system.read(id);\n\t\t\t}\n\t\t\treturn result as T;\n\t\t}\n\t\treturn this.system.read(this.keys[0]!) as T;\n\t}\n\n\tprotected subscribe(): void {\n\t\tthis.value = this.getValues();\n\t\tthis.unsubscribe = this.system.subscribe(this.keys, () => {\n\t\t\tthis.value = this.getValues();\n\t\t\tthis.requestUpdate();\n\t\t});\n\t}\n}\n\n/**\n * Reactive controller for a single fact value.\n */\nexport class FactController<T> extends DirectiveController {\n\tprivate factKey: string;\n\tvalue: T | undefined;\n\n\tconstructor(\n\t\thost: ReactiveControllerHost,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\t\tsystem: SingleModuleSystem<any>,\n\t\tfactKey: string,\n\t) {\n\t\tsuper(host, system);\n\t\tthis.factKey = factKey;\n\t\tthis.value = system.facts.$store.get(factKey) as T | undefined;\n\n\t\tif (process.env.NODE_ENV !== \"production\") {\n\t\t\tif (!system.facts.$store.has(factKey)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[Directive] FactController(\"${factKey}\") — fact not found in store. ` +\n\t\t\t\t\t`Check that \"${factKey}\" is defined in your module's schema.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected subscribe(): void {\n\t\tthis.value = this.system.facts.$store.get(this.factKey) as T | undefined;\n\t\tthis.unsubscribe = this.system.facts.$store.subscribe(\n\t\t\t[this.factKey],\n\t\t\t() => {\n\t\t\t\tthis.value = this.system.facts.$store.get(this.factKey) as T | undefined;\n\t\t\t\tthis.requestUpdate();\n\t\t\t},\n\t\t);\n\t}\n}\n\n/**\n * Consolidated inspection controller.\n * Returns InspectState with optional throttling.\n */\nexport class InspectController extends DirectiveController {\n\tvalue: InspectState;\n\tprivate throttleMs: number;\n\tprivate throttleCleanup?: () => void;\n\tprivate unsubSettled?: () => void;\n\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tconstructor(host: ReactiveControllerHost, system: SingleModuleSystem<any>, options?: { throttleMs?: number }) {\n\t\tsuper(host, system);\n\t\tthis.throttleMs = options?.throttleMs ?? 0;\n\t\tthis.value = computeInspectState(system);\n\t}\n\n\tprotected subscribe(): void {\n\t\tthis.value = computeInspectState(this.system);\n\n\t\tconst update = () => {\n\t\t\tthis.value = computeInspectState(this.system);\n\t\t\tthis.requestUpdate();\n\t\t};\n\n\t\tif (this.throttleMs > 0) {\n\t\t\tconst { throttled, cleanup } = createThrottle(update, this.throttleMs);\n\t\t\tthis.throttleCleanup = cleanup;\n\t\t\tthis.unsubscribe = this.system.facts.$store.subscribeAll(throttled);\n\t\t\tthis.unsubSettled = this.system.onSettledChange(throttled);\n\t\t} else {\n\t\t\tthis.unsubscribe = this.system.facts.$store.subscribeAll(update);\n\t\t\tthis.unsubSettled = this.system.onSettledChange(update);\n\t\t}\n\t}\n\n\thostDisconnected(): void {\n\t\tthis.throttleCleanup?.();\n\t\tthis.unsubSettled?.();\n\t\tsuper.hostDisconnected();\n\t}\n}\n\n/**\n * Reactive controller for requirement status.\n */\nexport class RequirementStatusController implements ReactiveController {\n\tprivate host: ReactiveControllerHost;\n\tprivate statusPlugin: StatusPlugin;\n\tprivate type: string;\n\tprivate unsubscribe?: () => void;\n\tvalue: RequirementTypeStatus;\n\n\tconstructor(\n\t\thost: ReactiveControllerHost,\n\t\tstatusPlugin: StatusPlugin,\n\t\ttype: string,\n\t) {\n\t\tthis.host = host;\n\t\tthis.statusPlugin = statusPlugin;\n\t\tthis.type = type;\n\t\tthis.value = statusPlugin.getStatus(type);\n\t\thost.addController(this);\n\t}\n\n\thostConnected(): void {\n\t\tthis.value = this.statusPlugin.getStatus(this.type);\n\t\tthis.unsubscribe = this.statusPlugin.subscribe(() => {\n\t\t\tthis.value = this.statusPlugin.getStatus(this.type);\n\t\t\tthis.host.requestUpdate();\n\t\t});\n\t}\n\n\thostDisconnected(): void {\n\t\tthis.unsubscribe?.();\n\t\tthis.unsubscribe = undefined;\n\t}\n}\n\n// ============================================================================\n// Selector Controllers\n// ============================================================================\n\n/**\n * Reactive controller for selecting across all facts.\n * Uses `withTracking()` for auto-tracking when constructed with `autoTrack: true`.\n */\nexport class DirectiveSelectorController<R> extends DirectiveController {\n\tprivate selector: (state: Record<string, unknown>) => R;\n\tprivate equalityFn: (a: R, b: R) => boolean;\n\tprivate autoTrack: boolean;\n\tprivate deriveKeySet: Set<string>;\n\tprivate trackedFactKeys: string[] = [];\n\tprivate trackedDeriveKeys: string[] = [];\n\tprivate unsubs: Array<() => void> = [];\n\tvalue: R;\n\n\tconstructor(\n\t\thost: ReactiveControllerHost,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\t\tsystem: SingleModuleSystem<any>,\n\t\tselector: (state: Record<string, unknown>) => R,\n\t\tequalityFn: (a: R, b: R) => boolean = defaultEquality,\n\t\toptions?: { autoTrack?: boolean },\n\t) {\n\t\tsuper(host, system);\n\t\tthis.selector = selector;\n\t\tthis.equalityFn = equalityFn;\n\t\tthis.autoTrack = options?.autoTrack ?? true;\n\t\tthis.deriveKeySet = new Set(Object.keys(system.derive ?? {}));\n\n\t\tconst initial = this.runWithTracking();\n\t\tthis.value = initial.value;\n\t\tthis.trackedFactKeys = initial.factKeys;\n\t\tthis.trackedDeriveKeys = initial.deriveKeys;\n\t}\n\n\tprivate runWithTracking(): TrackedSelectorResult<R> {\n\t\treturn runTrackedSelector(this.system, this.deriveKeySet, this.selector);\n\t}\n\n\tprivate resubscribe(): void {\n\t\tfor (const unsub of this.unsubs) unsub();\n\t\tthis.unsubs = [];\n\n\t\tconst onUpdate = () => {\n\t\t\tconst result = this.runWithTracking();\n\t\t\tif (!this.equalityFn(this.value, result.value)) {\n\t\t\t\tthis.value = result.value;\n\t\t\t\tthis.requestUpdate();\n\t\t\t}\n\t\t\tif (this.autoTrack) {\n\t\t\t\t// Re-track: check if deps changed\n\t\t\t\tif (depsChanged(this.trackedFactKeys, result.factKeys, this.trackedDeriveKeys, result.deriveKeys)) {\n\t\t\t\t\tthis.trackedFactKeys = result.factKeys;\n\t\t\t\t\tthis.trackedDeriveKeys = result.deriveKeys;\n\t\t\t\t\tthis.resubscribe();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tif (this.autoTrack) {\n\t\t\tif (this.trackedFactKeys.length > 0) {\n\t\t\t\tthis.unsubs.push(this.system.facts.$store.subscribe(this.trackedFactKeys, onUpdate));\n\t\t\t} else if (this.trackedDeriveKeys.length === 0) {\n\t\t\t\tthis.unsubs.push(this.system.facts.$store.subscribeAll(onUpdate));\n\t\t\t}\n\t\t\tif (this.trackedDeriveKeys.length > 0) {\n\t\t\t\tthis.unsubs.push(this.system.subscribe(this.trackedDeriveKeys, onUpdate));\n\t\t\t}\n\t\t} else {\n\t\t\tthis.unsubs.push(this.system.facts.$store.subscribeAll(onUpdate));\n\t\t}\n\t}\n\n\tprotected subscribe(): void {\n\t\tconst result = this.runWithTracking();\n\t\tthis.value = result.value;\n\t\tthis.trackedFactKeys = result.factKeys;\n\t\tthis.trackedDeriveKeys = result.deriveKeys;\n\t\tthis.resubscribe();\n\t}\n\n\thostDisconnected(): void {\n\t\tfor (const unsub of this.unsubs) unsub();\n\t\tthis.unsubs = [];\n\t\tsuper.hostDisconnected();\n\t}\n}\n\n/**\n * Reactive controller that watches a fact or derivation and calls a callback on change.\n * The key is auto-detected — works with both fact keys and derivation keys.\n */\nexport class WatchController<T> extends DirectiveController {\n\tprivate key: string;\n\tprivate callback: (newValue: T, previousValue: T | undefined) => void;\n\n\t/** Watch a derivation or fact by key (auto-detected). When a key exists in both facts and derivations, the derivation overload takes priority. */\n\tconstructor(\n\t\thost: ReactiveControllerHost,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\t\tsystem: SingleModuleSystem<any>,\n\t\tkey: string,\n\t\tcallback: (newValue: T, previousValue: T | undefined) => void,\n\t) {\n\t\tsuper(host, system);\n\t\tthis.key = key;\n\t\tthis.callback = callback;\n\t}\n\n\tprotected subscribe(): void {\n\t\tthis.unsubscribe = this.system.watch<T>(this.key, this.callback);\n\t}\n}\n\n// ============================================================================\n// New Controllers\n// ============================================================================\n\n/**\n * Reactive controller for requirement explanations.\n */\nexport class ExplainController extends DirectiveController {\n\tprivate requirementId: string;\n\tvalue: string | null;\n\tprivate unsubSettled?: () => void;\n\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tconstructor(host: ReactiveControllerHost, system: SingleModuleSystem<any>, requirementId: string) {\n\t\tsuper(host, system);\n\t\tthis.requirementId = requirementId;\n\t\tthis.value = system.explain(requirementId);\n\t}\n\n\tprotected subscribe(): void {\n\t\tthis.value = this.system.explain(this.requirementId);\n\n\t\tconst update = () => {\n\t\t\tthis.value = this.system.explain(this.requirementId);\n\t\t\tthis.requestUpdate();\n\t\t};\n\n\t\tthis.unsubscribe = this.system.facts.$store.subscribeAll(update);\n\t\tthis.unsubSettled = this.system.onSettledChange(update);\n\t}\n\n\thostDisconnected(): void {\n\t\tthis.unsubSettled?.();\n\t\tsuper.hostDisconnected();\n\t}\n}\n\n/**\n * Reactive controller for constraint status.\n */\nexport class ConstraintStatusController extends DirectiveController {\n\tprivate constraintId?: string;\n\tvalue: ConstraintInfo[] | ConstraintInfo | null;\n\tprivate unsubSettled?: () => void;\n\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tconstructor(host: ReactiveControllerHost, system: SingleModuleSystem<any>, constraintId?: string) {\n\t\tsuper(host, system);\n\t\tthis.constraintId = constraintId;\n\t\tthis.value = this.getVal();\n\t}\n\n\tprivate getVal(): ConstraintInfo[] | ConstraintInfo | null {\n\t\tconst inspection = this.system.inspect();\n\t\tif (!this.constraintId) return inspection.constraints;\n\t\treturn inspection.constraints.find((c: ConstraintInfo) => c.id === this.constraintId) ?? null;\n\t}\n\n\tprotected subscribe(): void {\n\t\tthis.value = this.getVal();\n\n\t\tconst update = () => {\n\t\t\tthis.value = this.getVal();\n\t\t\tthis.requestUpdate();\n\t\t};\n\n\t\tthis.unsubscribe = this.system.facts.$store.subscribeAll(update);\n\t\tthis.unsubSettled = this.system.onSettledChange(update);\n\t}\n\n\thostDisconnected(): void {\n\t\tthis.unsubSettled?.();\n\t\tsuper.hostDisconnected();\n\t}\n}\n\n/**\n * Reactive controller for optimistic updates.\n */\nexport class OptimisticUpdateController implements ReactiveController {\n\tprivate host: ReactiveControllerHost;\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tprivate system: SingleModuleSystem<any>;\n\tprivate statusPlugin?: StatusPlugin;\n\tprivate requirementType?: string;\n\tprivate snapshot: SystemSnapshot | null = null;\n\tprivate statusUnsub: (() => void) | null = null;\n\n\tisPending = false;\n\terror: Error | null = null;\n\n\tconstructor(\n\t\thost: ReactiveControllerHost,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\t\tsystem: SingleModuleSystem<any>,\n\t\tstatusPlugin?: StatusPlugin,\n\t\trequirementType?: string,\n\t) {\n\t\tthis.host = host;\n\t\tthis.system = system;\n\t\tthis.statusPlugin = statusPlugin;\n\t\tthis.requirementType = requirementType;\n\t\thost.addController(this);\n\t}\n\n\thostConnected(): void {}\n\n\thostDisconnected(): void {\n\t\tthis.statusUnsub?.();\n\t\tthis.statusUnsub = null;\n\t}\n\n\trollback(): void {\n\t\tif (this.snapshot) {\n\t\t\tthis.system.restore(this.snapshot);\n\t\t\tthis.snapshot = null;\n\t\t}\n\t\tthis.isPending = false;\n\t\tthis.error = null;\n\t\tthis.statusUnsub?.();\n\t\tthis.statusUnsub = null;\n\t\tthis.host.requestUpdate();\n\t}\n\n\tmutate(updateFn: () => void): void {\n\t\tthis.snapshot = this.system.getSnapshot();\n\t\tthis.isPending = true;\n\t\tthis.error = null;\n\t\tthis.system.batch(updateFn);\n\t\tthis.host.requestUpdate();\n\n\t\tif (this.statusPlugin && this.requirementType) {\n\t\t\tthis.statusUnsub?.();\n\t\t\tthis.statusUnsub = this.statusPlugin.subscribe(() => {\n\t\t\t\tconst status = this.statusPlugin!.getStatus(this.requirementType!);\n\t\t\t\tif (!status.isLoading && !status.hasError) {\n\t\t\t\t\tthis.snapshot = null;\n\t\t\t\t\tthis.isPending = false;\n\t\t\t\t\tthis.statusUnsub?.();\n\t\t\t\t\tthis.statusUnsub = null;\n\t\t\t\t\tthis.host.requestUpdate();\n\t\t\t\t} else if (status.hasError) {\n\t\t\t\t\tthis.error = status.lastError;\n\t\t\t\t\tthis.rollback();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Reactive controller that creates and manages a Directive system.\n * The system is automatically started when the host connects and destroyed when it disconnects.\n */\nexport class SystemController<M extends ModuleSchema> implements ReactiveController {\n\tprivate options: ModuleDef<M> | CreateSystemOptionsSingle<M>;\n\tprivate _system: SingleModuleSystem<M> | null = null;\n\n\tconstructor(host: ReactiveControllerHost, options: ModuleDef<M> | CreateSystemOptionsSingle<M>) {\n\t\tthis.options = options;\n\t\thost.addController(this);\n\t}\n\n\tget system(): SingleModuleSystem<M> {\n\t\tif (!this._system) {\n\t\t\tthrow new Error(\n\t\t\t\t\"[Directive] SystemController.system is not available. \" +\n\t\t\t\t\"This can happen if:\\n\" +\n\t\t\t\t\" 1. Accessed before hostConnected (e.g., in a class field initializer)\\n\" +\n\t\t\t\t\" 2. Accessed after hostDisconnected (system was destroyed)\\n\" +\n\t\t\t\t\"Solution: Access system only in lifecycle methods (connectedCallback, render) \" +\n\t\t\t\t\"or after the element is connected to the DOM.\",\n\t\t\t);\n\t\t}\n\t\treturn this._system;\n\t}\n\n\thostConnected(): void {\n\t\tconst isModule = \"id\" in this.options && \"schema\" in this.options;\n\t\tconst system = isModule\n\t\t\t? createSystem({ module: this.options as ModuleDef<M> })\n\t\t\t: createSystem(this.options as CreateSystemOptionsSingle<M>);\n\t\tthis._system = system as unknown as SingleModuleSystem<M>;\n\t\tthis._system.start();\n\t}\n\n\thostDisconnected(): void {\n\t\tthis._system?.destroy();\n\t\tthis._system = null;\n\t}\n}\n\n/**\n * Module controller — zero-config all-in-one.\n * Creates system, starts it, subscribes to all facts/derivations.\n */\nexport class ModuleController<M extends ModuleSchema> implements ReactiveController {\n\tprivate host: ReactiveControllerHost;\n\tprivate moduleDef: ModuleDef<M>;\n\tprivate config?: {\n\t\t// biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n\t\tplugins?: Plugin<any>[];\n\t\tdebug?: DebugConfig;\n\t\terrorBoundary?: ErrorBoundaryConfig;\n\t\ttickMs?: number;\n\t\tzeroConfig?: boolean;\n\t\t// biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n\t\tinitialFacts?: Record<string, any>;\n\t\tstatus?: boolean;\n\t};\n\n\tprivate _system: SingleModuleSystem<M> | null = null;\n\tprivate unsubFacts?: () => void;\n\tprivate unsubDerived?: () => void;\n\n\tfacts: InferFacts<M> = {} as InferFacts<M>;\n\tderived: InferDerivations<M> = {} as InferDerivations<M>;\n\tstatusPlugin?: StatusPlugin;\n\n\tget system(): SingleModuleSystem<M> {\n\t\tif (!this._system) {\n\t\t\tthrow new Error(\"[Directive] ModuleController.system is not available before hostConnected.\");\n\t\t}\n\t\treturn this._system;\n\t}\n\n\tget events(): SingleModuleSystem<M>[\"events\"] {\n\t\treturn this.system.events;\n\t}\n\n\tconstructor(\n\t\thost: ReactiveControllerHost,\n\t\tmoduleDef: ModuleDef<M>,\n\t\tconfig?: {\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n\t\t\tplugins?: Plugin<any>[];\n\t\t\tdebug?: DebugConfig;\n\t\t\terrorBoundary?: ErrorBoundaryConfig;\n\t\t\ttickMs?: number;\n\t\t\tzeroConfig?: boolean;\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n\t\t\tinitialFacts?: Record<string, any>;\n\t\t\tstatus?: boolean;\n\t\t},\n\t) {\n\t\tthis.host = host;\n\t\tthis.moduleDef = moduleDef;\n\t\tthis.config = config;\n\t\thost.addController(this);\n\t}\n\n\thostConnected(): void {\n\t\tconst allPlugins = [...(this.config?.plugins ?? [])];\n\n\t\tif (this.config?.status) {\n\t\t\tconst sp = createRequirementStatusPlugin();\n\t\t\tthis.statusPlugin = sp;\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Plugin generic issues\n\t\t\tallPlugins.push(sp.plugin as Plugin<any>);\n\t\t}\n\n\t\t// biome-ignore lint/suspicious/noExplicitAny: Required for overload compatibility\n\t\tconst system = createSystem({\n\t\t\tmodule: this.moduleDef,\n\t\t\tplugins: allPlugins.length > 0 ? allPlugins : undefined,\n\t\t\tdebug: this.config?.debug,\n\t\t\terrorBoundary: this.config?.errorBoundary,\n\t\t\ttickMs: this.config?.tickMs,\n\t\t\tzeroConfig: this.config?.zeroConfig,\n\t\t\tinitialFacts: this.config?.initialFacts,\n\t\t} as any) as unknown as SingleModuleSystem<M>;\n\n\t\tthis._system = system;\n\t\tsystem.start();\n\n\t\t// Subscribe to all facts\n\t\tthis.facts = system.facts.$store.toObject() as InferFacts<M>;\n\t\tthis.unsubFacts = system.facts.$store.subscribeAll(() => {\n\t\t\tthis.facts = system.facts.$store.toObject() as InferFacts<M>;\n\t\t\tthis.host.requestUpdate();\n\t\t});\n\n\t\t// Subscribe to all derivations\n\t\tconst derivationKeys = Object.keys(system.derive ?? {});\n\t\tconst getDerived = (): InferDerivations<M> => {\n\t\t\tconst result: Record<string, unknown> = {};\n\t\t\tfor (const key of derivationKeys) {\n\t\t\t\tresult[key] = system.read(key);\n\t\t\t}\n\t\t\treturn result as InferDerivations<M>;\n\t\t};\n\t\tthis.derived = getDerived();\n\n\t\tif (derivationKeys.length > 0) {\n\t\t\tthis.unsubDerived = system.subscribe(derivationKeys, () => {\n\t\t\t\tthis.derived = getDerived();\n\t\t\t\tthis.host.requestUpdate();\n\t\t\t});\n\t\t}\n\t}\n\n\thostDisconnected(): void {\n\t\tthis.unsubFacts?.();\n\t\tthis.unsubDerived?.();\n\t\tthis._system?.destroy();\n\t\tthis._system = null;\n\t}\n\n\tdispatch(event: InferEvents<M>): void {\n\t\tthis.system.dispatch(event);\n\t}\n}\n\n// ============================================================================\n// Factory Functions (active)\n// ============================================================================\n\nexport function createDerived<T>(\n\thost: ReactiveControllerHost,\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\tkey: string | string[],\n): DerivedController<T> {\n\treturn new DerivedController<T>(host, system, key);\n}\n\nexport function createFact<T>(\n\thost: ReactiveControllerHost,\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\tfactKey: string,\n): FactController<T> {\n\treturn new FactController<T>(host, system, factKey);\n}\n\n/**\n * Create an inspect controller.\n * Returns InspectState; pass `{ throttleMs }` for throttled updates.\n */\nexport function createInspect(\n\thost: ReactiveControllerHost,\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\toptions?: { throttleMs?: number },\n): InspectController {\n\treturn new InspectController(host, system, options);\n}\n\nexport function createRequirementStatus(\n\thost: ReactiveControllerHost,\n\tstatusPlugin: StatusPlugin,\n\ttype: string,\n): RequirementStatusController {\n\treturn new RequirementStatusController(host, statusPlugin, type);\n}\n\nexport function createWatch<T>(\n\thost: ReactiveControllerHost,\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\tderivationId: string,\n\tcallback: (newValue: T, previousValue: T | undefined) => void,\n): WatchController<T> {\n\treturn new WatchController<T>(host, system, derivationId, callback);\n}\n\nexport function createDirectiveSelector<R>(\n\thost: ReactiveControllerHost,\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\tselector: (state: Record<string, unknown>) => R,\n\tequalityFn: (a: R, b: R) => boolean = defaultEquality,\n\toptions?: { autoTrack?: boolean },\n): DirectiveSelectorController<R> {\n\treturn new DirectiveSelectorController<R>(host, system, selector, equalityFn, options);\n}\n\nexport function createExplain(\n\thost: ReactiveControllerHost,\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\trequirementId: string,\n): ExplainController {\n\treturn new ExplainController(host, system, requirementId);\n}\n\nexport function createConstraintStatus(\n\thost: ReactiveControllerHost,\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\tconstraintId?: string,\n): ConstraintStatusController {\n\treturn new ConstraintStatusController(host, system, constraintId);\n}\n\nexport function createOptimisticUpdate(\n\thost: ReactiveControllerHost,\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\tstatusPlugin?: StatusPlugin,\n\trequirementType?: string,\n): OptimisticUpdateController {\n\treturn new OptimisticUpdateController(host, system, statusPlugin, requirementType);\n}\n\nexport function createModule<M extends ModuleSchema>(\n\thost: ReactiveControllerHost,\n\tmoduleDef: ModuleDef<M>,\n\tconfig?: {\n\t\t// biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n\t\tplugins?: Plugin<any>[];\n\t\tdebug?: DebugConfig;\n\t\terrorBoundary?: ErrorBoundaryConfig;\n\t\ttickMs?: number;\n\t\tzeroConfig?: boolean;\n\t\t// biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n\t\tinitialFacts?: Record<string, any>;\n\t\tstatus?: boolean;\n\t},\n): ModuleController<M> {\n\treturn new ModuleController<M>(host, moduleDef, config);\n}\n\n// ============================================================================\n// Functional Helpers\n// ============================================================================\n\nexport function useDispatch<M extends ModuleSchema = ModuleSchema>(\n\tsystem: SingleModuleSystem<M>,\n): (event: InferEvents<M>) => void {\n\tassertSystem(\"useDispatch\", system);\n\treturn (event: InferEvents<M>) => {\n\t\tsystem.dispatch(event);\n\t};\n}\n\n/**\n * Returns the system's events dispatcher.\n */\nexport function useEvents<M extends ModuleSchema = ModuleSchema>(\n\tsystem: SingleModuleSystem<M>,\n): SingleModuleSystem<M>[\"events\"] {\n\tassertSystem(\"useEvents\", system);\n\treturn system.events;\n}\n\n/**\n * Reactive controller for time-travel state.\n * Triggers host updates when snapshots change or navigation occurs.\n *\n * @example\n * ```typescript\n * class MyElement extends LitElement {\n * private tt = new TimeTravelController(this, system);\n * render() {\n * const { canUndo, undo } = this.tt.value ?? {};\n * return html`<button ?disabled=${!canUndo} @click=${undo}>Undo</button>`;\n * }\n * }\n * ```\n */\nexport class TimeTravelController implements ReactiveController {\n\tvalue: TimeTravelState | null = null;\n\tprivate _unsub?: () => void;\n\n\tconstructor(\n\t\tprivate _host: ReactiveControllerHost,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\t\tprivate _system: SingleModuleSystem<any>,\n\t) {\n\t\tthis._host.addController(this);\n\t}\n\n\thostConnected(): void {\n\t\tthis.value = buildTimeTravelState(this._system);\n\t\tthis._unsub = this._system.onTimeTravelChange(() => {\n\t\t\tthis.value = buildTimeTravelState(this._system);\n\t\t\tthis._host.requestUpdate();\n\t\t});\n\t}\n\n\thostDisconnected(): void {\n\t\tthis._unsub?.();\n\t\tthis._unsub = undefined;\n\t}\n}\n\n/**\n * Functional helper for time-travel state (non-reactive, snapshot).\n * For reactive updates, use TimeTravelController.\n */\n// biome-ignore lint/suspicious/noExplicitAny: System type varies\nexport function useTimeTravel(system: SingleModuleSystem<any>): TimeTravelState | null {\n\tassertSystem(\"useTimeTravel\", system);\n\treturn buildTimeTravelState(system);\n}\n\nexport function getDerived<T>(\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\tderivationId: string,\n): () => T {\n\treturn () => system.read(derivationId) as T;\n}\n\nexport function getFact<T>(\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\tfactKey: string,\n): () => T | undefined {\n\treturn () => system.facts.$store.get(factKey) as T | undefined;\n}\n\n// ============================================================================\n// Typed Hooks Factory\n// ============================================================================\n\nexport function createTypedHooks<M extends ModuleSchema>(): {\n\tcreateDerived: <K extends keyof InferDerivations<M>>(\n\t\thost: ReactiveControllerHost,\n\t\tsystem: SingleModuleSystem<M>,\n\t\tderivationId: K,\n\t) => DerivedController<InferDerivations<M>[K]>;\n\tcreateFact: <K extends keyof InferFacts<M>>(\n\t\thost: ReactiveControllerHost,\n\t\tsystem: SingleModuleSystem<M>,\n\t\tfactKey: K,\n\t) => FactController<InferFacts<M>[K]>;\n\tuseDispatch: (system: SingleModuleSystem<M>) => (event: InferEvents<M>) => void;\n\tuseEvents: (system: SingleModuleSystem<M>) => SingleModuleSystem<M>[\"events\"];\n\tcreateWatch: <K extends string>(\n\t\thost: ReactiveControllerHost,\n\t\tsystem: SingleModuleSystem<M>,\n\t\tkey: K,\n\t\tcallback: (newValue: unknown, previousValue: unknown) => void,\n\t) => WatchController<unknown>;\n} {\n\treturn {\n\t\tcreateDerived: <K extends keyof InferDerivations<M>>(\n\t\t\thost: ReactiveControllerHost,\n\t\t\tsystem: SingleModuleSystem<M>,\n\t\t\tderivationId: K,\n\t\t) => createDerived<InferDerivations<M>[K]>(host, system, derivationId as string),\n\t\tcreateFact: <K extends keyof InferFacts<M>>(\n\t\t\thost: ReactiveControllerHost,\n\t\t\tsystem: SingleModuleSystem<M>,\n\t\t\tfactKey: K,\n\t\t) => createFact<InferFacts<M>[K]>(host, system, factKey as string),\n\t\tuseDispatch: (system: SingleModuleSystem<M>) => {\n\t\t\treturn (event: InferEvents<M>) => {\n\t\t\t\tsystem.dispatch(event);\n\t\t\t};\n\t\t},\n\t\tuseEvents: (system: SingleModuleSystem<M>) => system.events,\n\t\tcreateWatch: <K extends string>(\n\t\t\thost: ReactiveControllerHost,\n\t\t\tsystem: SingleModuleSystem<M>,\n\t\t\tkey: K,\n\t\t\tcallback: (newValue: unknown, previousValue: unknown) => void,\n\t\t) => createWatch<unknown>(host, system, key, callback),\n\t};\n}\n\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["directiveContext","DirectiveController","host","system","DerivedController","key","result","id","FactController","factKey","InspectController","options","computeInspectState","update","throttled","cleanup","createThrottle","RequirementStatusController","statusPlugin","type","DirectiveSelectorController","selector","equalityFn","defaultEquality","initial","runTrackedSelector","unsub","onUpdate","depsChanged","WatchController","callback","ExplainController","requirementId","ConstraintStatusController","constraintId","inspection","c","OptimisticUpdateController","requirementType","updateFn","status","SystemController","createSystem","ModuleController","moduleDef","config","allPlugins","sp","createRequirementStatusPlugin","derivationKeys","getDerived","event","createDerived","createFact","createInspect","createRequirementStatus","createWatch","derivationId","createDirectiveSelector","createExplain","createConstraintStatus","createOptimisticUpdate","createModule","useDispatch","assertSystem","useEvents","TimeTravelController","_host","_system","buildTimeTravelState","useTimeTravel","getFact","createTypedHooks","NamespacedSelectorController","keys","createNamespacedSelector"],"mappings":"+GAkEO,IAAMA,CAAAA,CAAmB,MAAA,CAAO,WAAW,CAAA,CASnCC,CAAAA,CAAf,KAAiE,CACrD,IAAA,CAEA,MAAA,CACA,WAAA,CAGV,WAAA,CAAYC,CAAAA,CAA8BC,CAAAA,CAAiC,CACzE,IAAA,CAAK,IAAA,CAAOD,CAAAA,CACZ,IAAA,CAAK,MAAA,CAASC,CAAAA,CACdD,CAAAA,CAAK,aAAA,CAAc,IAAI,EACzB,CAEA,aAAA,EAAsB,CACpB,IAAA,CAAK,SAAA,GACP,CAEA,gBAAA,EAAyB,CACvB,IAAA,CAAK,WAAA,IAAc,CACnB,IAAA,CAAK,WAAA,CAAc,OACrB,CAIU,aAAA,EAAsB,CAC9B,IAAA,CAAK,IAAA,CAAK,aAAA,GACZ,CACF,CAAA,CAYaE,CAAAA,CAAN,cAAmCH,CAAoB,CACpD,IAAA,CACA,OAAA,CACR,KAAA,CAEA,WAAA,CACEC,CAAAA,CAEAC,CAAAA,CACAE,EACA,CACA,KAAA,CAAMH,CAAAA,CAAMC,CAAM,CAAA,CAClB,IAAA,CAAK,OAAA,CAAU,KAAA,CAAM,QAAQE,CAAG,CAAA,CAChC,IAAA,CAAK,IAAA,CAAO,IAAA,CAAK,OAAA,CAAWA,CAAAA,CAAmB,CAACA,CAAa,CAAA,CAC7D,IAAA,CAAK,KAAA,CAAQ,IAAA,CAAK,SAAA,EAAU,CAExB,OAAA,CAAQ,GAAA,CAAI,QAAA,GAAa,YAAA,EACvB,CAAC,IAAA,CAAK,OAAA,EAAW,IAAA,CAAK,KAAA,GAAU,MAAA,EAClC,QAAQ,IAAA,CACN,CAAA,+BAAA,EAAkC,IAAA,CAAK,IAAA,CAAK,CAAC,CAAC,CAAA,mCAAA,EAC7B,IAAA,CAAK,KAAK,CAAC,CAAC,CAAA,8CAAA,CAC/B,EAGN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AAqBtD,CAAAA,CAAMC,CAAAA,CAAQE,EAAKyB,CAAQ,CACvD,CACF,CAsBO,IAAM2C,EAAN,KAEP,CACU,KACA,MAAA,CACA,IAAA,CACA,QAAA,CACA,WAAA,CACR,MAEA,WAAA,CACEvE,CAAAA,CACAC,EACAuE,CAAAA,CACArD,CAAAA,CACA,CACA,IAAA,CAAK,IAAA,CAAOnB,CAAAA,CACZ,IAAA,CAAK,OAASC,CAAAA,CACd,IAAA,CAAK,KAAOuE,CAAAA,CACZ,IAAA,CAAK,SAAWrD,CAAAA,CAChB,IAAA,CAAK,KAAA,CAAQA,CAAAA,CAASlB,CAAM,CAAA,CAC5BD,CAAAA,CAAK,cAAc,IAAI,EACzB,CAEA,aAAA,EAAsB,CACpB,IAAA,CAAK,KAAA,CAAQ,KAAK,QAAA,CAAS,IAAA,CAAK,MAAM,CAAA,CACtC,IAAA,CAAK,YAAc,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU,IAAA,CAAK,KAAM,IAAM,CACxD,KAAK,KAAA,CAAQ,IAAA,CAAK,SAAS,IAAA,CAAK,MAAM,CAAA,CACtC,IAAA,CAAK,KAAK,aAAA,GACZ,CAAC,EACH,CAEA,kBAAyB,CACvB,IAAA,CAAK,WAAA,IAAc,CACnB,KAAK,WAAA,CAAc,OACrB,CACF,EAEO,SAASyE,EACdzE,CAAAA,CACAC,CAAAA,CACAuE,EACArD,CAAAA,CAC0C,CAC1C,OAAO,IAAIoD,CAAAA,CAA6BvE,EAAMC,CAAAA,CAAQuE,CAAAA,CAAMrD,CAAQ,CACtE","file":"index.cjs","sourcesContent":["/**\n * Lit Adapter - Consolidated Web Components integration for Directive\n *\n * Controllers: DerivedController, FactController,\n * InspectController (with throttle), RequirementStatusController,\n * DirectiveSelectorController,\n * WatchController (with fact mode), SystemController,\n * ExplainController, ConstraintStatusController, OptimisticUpdateController, ModuleController\n *\n * Factories: createDerived, createFact, createInspect,\n * createRequirementStatus, createWatch,\n * createDirectiveSelector, useDispatch, useEvents, useTimeTravel,\n * getDerived, getFact, createTypedHooks, shallowEqual\n */\n\nimport type {\n CreateSystemOptionsSingle,\n DebugConfig,\n ErrorBoundaryConfig,\n InferDerivations,\n InferEvents,\n InferFacts,\n ModuleDef,\n ModuleSchema,\n ModulesMap,\n NamespacedSystem,\n Plugin,\n SingleModuleSystem,\n SystemSnapshot,\n TimeTravelState,\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 type TrackedSelectorResult,\n assertSystem,\n buildTimeTravelState,\n computeInspectState,\n createThrottle,\n defaultEquality,\n depsChanged,\n runTrackedSelector,\n shallowEqual,\n} from \"@directive-run/core/adapter-utils\";\nimport type { ReactiveController, ReactiveControllerHost } from \"lit\";\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// Context\n// ============================================================================\n\n/**\n * Context key for Directive system.\n * Use with @lit/context for dependency injection across shadow DOM boundaries.\n */\nexport const directiveContext = Symbol(\"directive\");\n\n// ============================================================================\n// Base Controller\n// ============================================================================\n\n/**\n * Base controller that manages system subscription lifecycle.\n */\nabstract class DirectiveController implements ReactiveController {\n protected host: ReactiveControllerHost;\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n protected system: SingleModuleSystem<any>;\n protected unsubscribe?: () => void;\n\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n constructor(host: ReactiveControllerHost, system: SingleModuleSystem<any>) {\n this.host = host;\n this.system = system;\n host.addController(this);\n }\n\n hostConnected(): void {\n this.subscribe();\n }\n\n hostDisconnected(): void {\n this.unsubscribe?.();\n this.unsubscribe = undefined;\n }\n\n protected abstract subscribe(): void;\n\n protected requestUpdate(): void {\n this.host.requestUpdate();\n }\n}\n\n// ============================================================================\n// Core Controllers\n// ============================================================================\n\n/**\n * Reactive controller for derivations.\n * Accepts a single key (string) or an array of keys (string[]).\n * - Single key: `.value` returns `T`\n * - Array of keys: `.value` returns `Record<string, unknown>`\n */\nexport class DerivedController<T> extends DirectiveController {\n private keys: string[];\n private isMulti: boolean;\n value: T;\n\n constructor(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n key: string | string[],\n ) {\n super(host, system);\n this.isMulti = Array.isArray(key);\n this.keys = this.isMulti ? (key as string[]) : [key as string];\n this.value = this.getValues();\n\n if (process.env.NODE_ENV !== \"production\") {\n if (!this.isMulti && this.value === undefined) {\n console.warn(\n `[Directive] DerivedController(\"${this.keys[0]}\") returned undefined. ` +\n `Check that \"${this.keys[0]}\" is defined in your module's derive property.`,\n );\n }\n }\n }\n\n private getValues(): T {\n if (this.isMulti) {\n const result: Record<string, unknown> = {};\n for (const id of this.keys) {\n result[id] = this.system.read(id);\n }\n return result as T;\n }\n return this.system.read(this.keys[0]!) as T;\n }\n\n protected subscribe(): void {\n this.value = this.getValues();\n this.unsubscribe = this.system.subscribe(this.keys, () => {\n this.value = this.getValues();\n this.requestUpdate();\n });\n }\n}\n\n/**\n * Reactive controller for a single fact value.\n */\nexport class FactController<T> extends DirectiveController {\n private factKey: string;\n value: T | undefined;\n\n constructor(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n factKey: string,\n ) {\n super(host, system);\n this.factKey = factKey;\n this.value = system.facts.$store.get(factKey) as T | undefined;\n\n if (process.env.NODE_ENV !== \"production\") {\n if (!system.facts.$store.has(factKey)) {\n console.warn(\n `[Directive] FactController(\"${factKey}\") — fact not found in store. ` +\n `Check that \"${factKey}\" is defined in your module's schema.`,\n );\n }\n }\n }\n\n protected subscribe(): void {\n this.value = this.system.facts.$store.get(this.factKey) as T | undefined;\n this.unsubscribe = this.system.facts.$store.subscribe(\n [this.factKey],\n () => {\n this.value = this.system.facts.$store.get(this.factKey) as\n | T\n | undefined;\n this.requestUpdate();\n },\n );\n }\n}\n\n/**\n * Consolidated inspection controller.\n * Returns InspectState with optional throttling.\n */\nexport class InspectController extends DirectiveController {\n value: InspectState;\n private throttleMs: number;\n private throttleCleanup?: () => void;\n private unsubSettled?: () => void;\n\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n constructor(\n host: ReactiveControllerHost,\n system: SingleModuleSystem<any>,\n options?: { throttleMs?: number },\n ) {\n super(host, system);\n this.throttleMs = options?.throttleMs ?? 0;\n this.value = computeInspectState(system);\n }\n\n protected subscribe(): void {\n this.value = computeInspectState(this.system);\n\n const update = () => {\n this.value = computeInspectState(this.system);\n this.requestUpdate();\n };\n\n if (this.throttleMs > 0) {\n const { throttled, cleanup } = createThrottle(update, this.throttleMs);\n this.throttleCleanup = cleanup;\n this.unsubscribe = this.system.facts.$store.subscribeAll(throttled);\n this.unsubSettled = this.system.onSettledChange(throttled);\n } else {\n this.unsubscribe = this.system.facts.$store.subscribeAll(update);\n this.unsubSettled = this.system.onSettledChange(update);\n }\n }\n\n hostDisconnected(): void {\n this.throttleCleanup?.();\n this.unsubSettled?.();\n super.hostDisconnected();\n }\n}\n\n/**\n * Reactive controller for requirement status.\n */\nexport class RequirementStatusController implements ReactiveController {\n private host: ReactiveControllerHost;\n private statusPlugin: StatusPlugin;\n private type: string;\n private unsubscribe?: () => void;\n value: RequirementTypeStatus;\n\n constructor(\n host: ReactiveControllerHost,\n statusPlugin: StatusPlugin,\n type: string,\n ) {\n this.host = host;\n this.statusPlugin = statusPlugin;\n this.type = type;\n this.value = statusPlugin.getStatus(type);\n host.addController(this);\n }\n\n hostConnected(): void {\n this.value = this.statusPlugin.getStatus(this.type);\n this.unsubscribe = this.statusPlugin.subscribe(() => {\n this.value = this.statusPlugin.getStatus(this.type);\n this.host.requestUpdate();\n });\n }\n\n hostDisconnected(): void {\n this.unsubscribe?.();\n this.unsubscribe = undefined;\n }\n}\n\n// ============================================================================\n// Selector Controllers\n// ============================================================================\n\n/**\n * Reactive controller for selecting across all facts.\n * Uses `withTracking()` for auto-tracking when constructed with `autoTrack: true`.\n */\nexport class DirectiveSelectorController<R> extends DirectiveController {\n private selector: (state: Record<string, unknown>) => R;\n private equalityFn: (a: R, b: R) => boolean;\n private autoTrack: boolean;\n private deriveKeySet: Set<string>;\n private trackedFactKeys: string[] = [];\n private trackedDeriveKeys: string[] = [];\n private unsubs: Array<() => void> = [];\n value: R;\n\n constructor(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n selector: (state: Record<string, unknown>) => R,\n equalityFn: (a: R, b: R) => boolean = defaultEquality,\n options?: { autoTrack?: boolean },\n ) {\n super(host, system);\n this.selector = selector;\n this.equalityFn = equalityFn;\n this.autoTrack = options?.autoTrack ?? true;\n this.deriveKeySet = new Set(Object.keys(system.derive ?? {}));\n\n const initial = this.runWithTracking();\n this.value = initial.value;\n this.trackedFactKeys = initial.factKeys;\n this.trackedDeriveKeys = initial.deriveKeys;\n }\n\n private runWithTracking(): TrackedSelectorResult<R> {\n return runTrackedSelector(this.system, this.deriveKeySet, this.selector);\n }\n\n private resubscribe(): void {\n for (const unsub of this.unsubs) unsub();\n this.unsubs = [];\n\n const onUpdate = () => {\n const result = this.runWithTracking();\n if (!this.equalityFn(this.value, result.value)) {\n this.value = result.value;\n this.requestUpdate();\n }\n if (this.autoTrack) {\n // Re-track: check if deps changed\n if (\n depsChanged(\n this.trackedFactKeys,\n result.factKeys,\n this.trackedDeriveKeys,\n result.deriveKeys,\n )\n ) {\n this.trackedFactKeys = result.factKeys;\n this.trackedDeriveKeys = result.deriveKeys;\n this.resubscribe();\n }\n }\n };\n\n if (this.autoTrack) {\n if (this.trackedFactKeys.length > 0) {\n this.unsubs.push(\n this.system.facts.$store.subscribe(this.trackedFactKeys, onUpdate),\n );\n } else if (this.trackedDeriveKeys.length === 0) {\n this.unsubs.push(this.system.facts.$store.subscribeAll(onUpdate));\n }\n if (this.trackedDeriveKeys.length > 0) {\n this.unsubs.push(\n this.system.subscribe(this.trackedDeriveKeys, onUpdate),\n );\n }\n } else {\n this.unsubs.push(this.system.facts.$store.subscribeAll(onUpdate));\n }\n }\n\n protected subscribe(): void {\n const result = this.runWithTracking();\n this.value = result.value;\n this.trackedFactKeys = result.factKeys;\n this.trackedDeriveKeys = result.deriveKeys;\n this.resubscribe();\n }\n\n hostDisconnected(): void {\n for (const unsub of this.unsubs) unsub();\n this.unsubs = [];\n super.hostDisconnected();\n }\n}\n\n/**\n * Reactive controller that watches a fact or derivation and calls a callback on change.\n * The key is auto-detected — works with both fact keys and derivation keys.\n */\nexport class WatchController<T> extends DirectiveController {\n private key: string;\n private callback: (newValue: T, previousValue: T | undefined) => void;\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. */\n constructor(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n key: string,\n callback: (newValue: T, previousValue: T | undefined) => void,\n ) {\n super(host, system);\n this.key = key;\n this.callback = callback;\n }\n\n protected subscribe(): void {\n this.unsubscribe = this.system.watch<T>(this.key, this.callback);\n }\n}\n\n// ============================================================================\n// New Controllers\n// ============================================================================\n\n/**\n * Reactive controller for requirement explanations.\n */\nexport class ExplainController extends DirectiveController {\n private requirementId: string;\n value: string | null;\n private unsubSettled?: () => void;\n\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n constructor(\n host: ReactiveControllerHost,\n system: SingleModuleSystem<any>,\n requirementId: string,\n ) {\n super(host, system);\n this.requirementId = requirementId;\n this.value = system.explain(requirementId);\n }\n\n protected subscribe(): void {\n this.value = this.system.explain(this.requirementId);\n\n const update = () => {\n this.value = this.system.explain(this.requirementId);\n this.requestUpdate();\n };\n\n this.unsubscribe = this.system.facts.$store.subscribeAll(update);\n this.unsubSettled = this.system.onSettledChange(update);\n }\n\n hostDisconnected(): void {\n this.unsubSettled?.();\n super.hostDisconnected();\n }\n}\n\n/**\n * Reactive controller for constraint status.\n */\nexport class ConstraintStatusController extends DirectiveController {\n private constraintId?: string;\n value: ConstraintInfo[] | ConstraintInfo | null;\n private unsubSettled?: () => void;\n\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n constructor(\n host: ReactiveControllerHost,\n system: SingleModuleSystem<any>,\n constraintId?: string,\n ) {\n super(host, system);\n this.constraintId = constraintId;\n this.value = this.getVal();\n }\n\n private getVal(): ConstraintInfo[] | ConstraintInfo | null {\n const inspection = this.system.inspect();\n if (!this.constraintId) return inspection.constraints;\n return (\n inspection.constraints.find(\n (c: ConstraintInfo) => c.id === this.constraintId,\n ) ?? null\n );\n }\n\n protected subscribe(): void {\n this.value = this.getVal();\n\n const update = () => {\n this.value = this.getVal();\n this.requestUpdate();\n };\n\n this.unsubscribe = this.system.facts.$store.subscribeAll(update);\n this.unsubSettled = this.system.onSettledChange(update);\n }\n\n hostDisconnected(): void {\n this.unsubSettled?.();\n super.hostDisconnected();\n }\n}\n\n/**\n * Reactive controller for optimistic updates.\n */\nexport class OptimisticUpdateController implements ReactiveController {\n private host: ReactiveControllerHost;\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n private system: SingleModuleSystem<any>;\n private statusPlugin?: StatusPlugin;\n private requirementType?: string;\n private snapshot: SystemSnapshot | null = null;\n private statusUnsub: (() => void) | null = null;\n\n isPending = false;\n error: Error | null = null;\n\n constructor(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n statusPlugin?: StatusPlugin,\n requirementType?: string,\n ) {\n this.host = host;\n this.system = system;\n this.statusPlugin = statusPlugin;\n this.requirementType = requirementType;\n host.addController(this);\n }\n\n hostConnected(): void {}\n\n hostDisconnected(): void {\n this.statusUnsub?.();\n this.statusUnsub = null;\n }\n\n rollback(): void {\n if (this.snapshot) {\n this.system.restore(this.snapshot);\n this.snapshot = null;\n }\n this.isPending = false;\n this.error = null;\n this.statusUnsub?.();\n this.statusUnsub = null;\n this.host.requestUpdate();\n }\n\n mutate(updateFn: () => void): void {\n this.snapshot = this.system.getSnapshot();\n this.isPending = true;\n this.error = null;\n this.system.batch(updateFn);\n this.host.requestUpdate();\n\n if (this.statusPlugin && this.requirementType) {\n this.statusUnsub?.();\n this.statusUnsub = this.statusPlugin.subscribe(() => {\n const status = this.statusPlugin!.getStatus(this.requirementType!);\n if (!status.isLoading && !status.hasError) {\n this.snapshot = null;\n this.isPending = false;\n this.statusUnsub?.();\n this.statusUnsub = null;\n this.host.requestUpdate();\n } else if (status.hasError) {\n this.error = status.lastError;\n this.rollback();\n }\n });\n }\n }\n}\n\n/**\n * Reactive controller that creates and manages a Directive system.\n * The system is automatically started when the host connects and destroyed when it disconnects.\n */\nexport class SystemController<M extends ModuleSchema>\n implements ReactiveController\n{\n private options: ModuleDef<M> | CreateSystemOptionsSingle<M>;\n private _system: SingleModuleSystem<M> | null = null;\n\n constructor(\n host: ReactiveControllerHost,\n options: ModuleDef<M> | CreateSystemOptionsSingle<M>,\n ) {\n this.options = options;\n host.addController(this);\n }\n\n get system(): SingleModuleSystem<M> {\n if (!this._system) {\n throw new Error(\n \"[Directive] SystemController.system is not available. \" +\n \"This can happen if:\\n\" +\n \" 1. Accessed before hostConnected (e.g., in a class field initializer)\\n\" +\n \" 2. Accessed after hostDisconnected (system was destroyed)\\n\" +\n \"Solution: Access system only in lifecycle methods (connectedCallback, render) \" +\n \"or after the element is connected to the DOM.\",\n );\n }\n return this._system;\n }\n\n hostConnected(): void {\n const isModule = \"id\" in this.options && \"schema\" in this.options;\n const system = isModule\n ? createSystem({ module: this.options as ModuleDef<M> })\n : createSystem(this.options as CreateSystemOptionsSingle<M>);\n this._system = system as unknown as SingleModuleSystem<M>;\n this._system.start();\n }\n\n hostDisconnected(): void {\n this._system?.destroy();\n this._system = null;\n }\n}\n\n/**\n * Module controller — zero-config all-in-one.\n * Creates system, starts it, subscribes to all facts/derivations.\n */\nexport class ModuleController<M extends ModuleSchema>\n implements ReactiveController\n{\n private host: ReactiveControllerHost;\n private moduleDef: ModuleDef<M>;\n private config?: {\n // biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n plugins?: Plugin<any>[];\n debug?: DebugConfig;\n errorBoundary?: ErrorBoundaryConfig;\n tickMs?: number;\n zeroConfig?: boolean;\n // biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n initialFacts?: Record<string, any>;\n status?: boolean;\n };\n\n private _system: SingleModuleSystem<M> | null = null;\n private unsubFacts?: () => void;\n private unsubDerived?: () => void;\n\n facts: InferFacts<M> = {} as InferFacts<M>;\n derived: InferDerivations<M> = {} as InferDerivations<M>;\n statusPlugin?: StatusPlugin;\n\n get system(): SingleModuleSystem<M> {\n if (!this._system) {\n throw new Error(\n \"[Directive] ModuleController.system is not available before hostConnected.\",\n );\n }\n return this._system;\n }\n\n get events(): SingleModuleSystem<M>[\"events\"] {\n return this.system.events;\n }\n\n constructor(\n host: ReactiveControllerHost,\n moduleDef: ModuleDef<M>,\n config?: {\n // biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n plugins?: Plugin<any>[];\n debug?: DebugConfig;\n errorBoundary?: ErrorBoundaryConfig;\n tickMs?: number;\n zeroConfig?: boolean;\n // biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n initialFacts?: Record<string, any>;\n status?: boolean;\n },\n ) {\n this.host = host;\n this.moduleDef = moduleDef;\n this.config = config;\n host.addController(this);\n }\n\n hostConnected(): void {\n const allPlugins = [...(this.config?.plugins ?? [])];\n\n if (this.config?.status) {\n const sp = createRequirementStatusPlugin();\n this.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: this.moduleDef,\n plugins: allPlugins.length > 0 ? allPlugins : undefined,\n debug: this.config?.debug,\n errorBoundary: this.config?.errorBoundary,\n tickMs: this.config?.tickMs,\n zeroConfig: this.config?.zeroConfig,\n initialFacts: this.config?.initialFacts,\n } as any) as unknown as SingleModuleSystem<M>;\n\n this._system = system;\n system.start();\n\n // Subscribe to all facts\n this.facts = system.facts.$store.toObject() as InferFacts<M>;\n this.unsubFacts = system.facts.$store.subscribeAll(() => {\n this.facts = system.facts.$store.toObject() as InferFacts<M>;\n this.host.requestUpdate();\n });\n\n // Subscribe to all derivations\n const derivationKeys = Object.keys(system.derive ?? {});\n const getDerived = (): InferDerivations<M> => {\n const result: Record<string, unknown> = {};\n for (const key of derivationKeys) {\n result[key] = system.read(key);\n }\n return result as InferDerivations<M>;\n };\n this.derived = getDerived();\n\n if (derivationKeys.length > 0) {\n this.unsubDerived = system.subscribe(derivationKeys, () => {\n this.derived = getDerived();\n this.host.requestUpdate();\n });\n }\n }\n\n hostDisconnected(): void {\n this.unsubFacts?.();\n this.unsubDerived?.();\n this._system?.destroy();\n this._system = null;\n }\n\n dispatch(event: InferEvents<M>): void {\n this.system.dispatch(event);\n }\n}\n\n// ============================================================================\n// Factory Functions (active)\n// ============================================================================\n\nexport function createDerived<T>(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n key: string | string[],\n): DerivedController<T> {\n return new DerivedController<T>(host, system, key);\n}\n\nexport function createFact<T>(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n factKey: string,\n): FactController<T> {\n return new FactController<T>(host, system, factKey);\n}\n\n/**\n * Create an inspect controller.\n * Returns InspectState; pass `{ throttleMs }` for throttled updates.\n */\nexport function createInspect(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n options?: { throttleMs?: number },\n): InspectController {\n return new InspectController(host, system, options);\n}\n\nexport function createRequirementStatus(\n host: ReactiveControllerHost,\n statusPlugin: StatusPlugin,\n type: string,\n): RequirementStatusController {\n return new RequirementStatusController(host, statusPlugin, type);\n}\n\nexport function createWatch<T>(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n derivationId: string,\n callback: (newValue: T, previousValue: T | undefined) => void,\n): WatchController<T> {\n return new WatchController<T>(host, system, derivationId, callback);\n}\n\nexport function createDirectiveSelector<R>(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n selector: (state: Record<string, unknown>) => R,\n equalityFn: (a: R, b: R) => boolean = defaultEquality,\n options?: { autoTrack?: boolean },\n): DirectiveSelectorController<R> {\n return new DirectiveSelectorController<R>(\n host,\n system,\n selector,\n equalityFn,\n options,\n );\n}\n\nexport function createExplain(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n requirementId: string,\n): ExplainController {\n return new ExplainController(host, system, requirementId);\n}\n\nexport function createConstraintStatus(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n constraintId?: string,\n): ConstraintStatusController {\n return new ConstraintStatusController(host, system, constraintId);\n}\n\nexport function createOptimisticUpdate(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n statusPlugin?: StatusPlugin,\n requirementType?: string,\n): OptimisticUpdateController {\n return new OptimisticUpdateController(\n host,\n system,\n statusPlugin,\n requirementType,\n );\n}\n\nexport function createModule<M extends ModuleSchema>(\n host: ReactiveControllerHost,\n moduleDef: ModuleDef<M>,\n config?: {\n // biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n plugins?: Plugin<any>[];\n debug?: DebugConfig;\n errorBoundary?: ErrorBoundaryConfig;\n tickMs?: number;\n zeroConfig?: boolean;\n // biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n initialFacts?: Record<string, any>;\n status?: boolean;\n },\n): ModuleController<M> {\n return new ModuleController<M>(host, moduleDef, config);\n}\n\n// ============================================================================\n// Functional Helpers\n// ============================================================================\n\nexport function useDispatch<M extends ModuleSchema = ModuleSchema>(\n system: SingleModuleSystem<M>,\n): (event: InferEvents<M>) => void {\n assertSystem(\"useDispatch\", system);\n return (event: InferEvents<M>) => {\n system.dispatch(event);\n };\n}\n\n/**\n * Returns the system's events dispatcher.\n */\nexport function useEvents<M extends ModuleSchema = ModuleSchema>(\n system: SingleModuleSystem<M>,\n): SingleModuleSystem<M>[\"events\"] {\n assertSystem(\"useEvents\", system);\n return system.events;\n}\n\n/**\n * Reactive controller for time-travel state.\n * Triggers host updates when snapshots change or navigation occurs.\n *\n * @example\n * ```typescript\n * class MyElement extends LitElement {\n * private tt = new TimeTravelController(this, system);\n * render() {\n * const { canUndo, undo } = this.tt.value ?? {};\n * return html`<button ?disabled=${!canUndo} @click=${undo}>Undo</button>`;\n * }\n * }\n * ```\n */\nexport class TimeTravelController implements ReactiveController {\n value: TimeTravelState | null = null;\n private _unsub?: () => void;\n\n constructor(\n private _host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n private _system: SingleModuleSystem<any>,\n ) {\n this._host.addController(this);\n }\n\n hostConnected(): void {\n this.value = buildTimeTravelState(this._system);\n this._unsub = this._system.onTimeTravelChange(() => {\n this.value = buildTimeTravelState(this._system);\n this._host.requestUpdate();\n });\n }\n\n hostDisconnected(): void {\n this._unsub?.();\n this._unsub = undefined;\n }\n}\n\n/**\n * Functional helper for time-travel state (non-reactive, snapshot).\n * For reactive updates, use TimeTravelController.\n */\n// biome-ignore lint/suspicious/noExplicitAny: System type varies\nexport function useTimeTravel(\n system: SingleModuleSystem<any>,\n): TimeTravelState | null {\n assertSystem(\"useTimeTravel\", system);\n return buildTimeTravelState(system);\n}\n\nexport function getDerived<T>(\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n derivationId: string,\n): () => T {\n return () => system.read(derivationId) as T;\n}\n\nexport function getFact<T>(\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n factKey: string,\n): () => T | undefined {\n return () => system.facts.$store.get(factKey) as T | undefined;\n}\n\n// ============================================================================\n// Typed Hooks Factory\n// ============================================================================\n\nexport function createTypedHooks<M extends ModuleSchema>(): {\n createDerived: <K extends keyof InferDerivations<M>>(\n host: ReactiveControllerHost,\n system: SingleModuleSystem<M>,\n derivationId: K,\n ) => DerivedController<InferDerivations<M>[K]>;\n createFact: <K extends keyof InferFacts<M>>(\n host: ReactiveControllerHost,\n system: SingleModuleSystem<M>,\n factKey: K,\n ) => FactController<InferFacts<M>[K]>;\n useDispatch: (\n system: SingleModuleSystem<M>,\n ) => (event: InferEvents<M>) => void;\n useEvents: (system: SingleModuleSystem<M>) => SingleModuleSystem<M>[\"events\"];\n createWatch: <K extends string>(\n host: ReactiveControllerHost,\n system: SingleModuleSystem<M>,\n key: K,\n callback: (newValue: unknown, previousValue: unknown) => void,\n ) => WatchController<unknown>;\n} {\n return {\n createDerived: <K extends keyof InferDerivations<M>>(\n host: ReactiveControllerHost,\n system: SingleModuleSystem<M>,\n derivationId: K,\n ) =>\n createDerived<InferDerivations<M>[K]>(\n host,\n system,\n derivationId as string,\n ),\n createFact: <K extends keyof InferFacts<M>>(\n host: ReactiveControllerHost,\n system: SingleModuleSystem<M>,\n factKey: K,\n ) => createFact<InferFacts<M>[K]>(host, system, factKey as string),\n useDispatch: (system: SingleModuleSystem<M>) => {\n return (event: InferEvents<M>) => {\n system.dispatch(event);\n };\n },\n useEvents: (system: SingleModuleSystem<M>) => system.events,\n createWatch: <K extends string>(\n host: ReactiveControllerHost,\n system: SingleModuleSystem<M>,\n key: K,\n callback: (newValue: unknown, previousValue: unknown) => void,\n ) => createWatch<unknown>(host, system, key, callback),\n };\n}\n\n// ============================================================================\n// NamespacedSelectorController — select from a NamespacedSystem\n// ============================================================================\n\n/**\n * Reactive controller that selects from a NamespacedSystem.\n * Subscribes to specified keys and triggers host updates.\n *\n * @example\n * ```typescript\n * class MyElement extends LitElement {\n * private token = new NamespacedSelectorController(\n * this, system, [\"auth.token\"], (s) => s.facts.auth.token,\n * );\n * render() {\n * return html`<span>${this.token.value}</span>`;\n * }\n * }\n * ```\n */\nexport class NamespacedSelectorController<Modules extends ModulesMap, R>\n implements ReactiveController\n{\n private host: ReactiveControllerHost;\n private system: NamespacedSystem<Modules>;\n private keys: string[];\n private selector: (system: NamespacedSystem<Modules>) => R;\n private unsubscribe?: () => void;\n value: R;\n\n constructor(\n host: ReactiveControllerHost,\n system: NamespacedSystem<Modules>,\n keys: string[],\n selector: (system: NamespacedSystem<Modules>) => R,\n ) {\n this.host = host;\n this.system = system;\n this.keys = keys;\n this.selector = selector;\n this.value = selector(system);\n host.addController(this);\n }\n\n hostConnected(): void {\n this.value = this.selector(this.system);\n this.unsubscribe = this.system.subscribe(this.keys, () => {\n this.value = this.selector(this.system);\n this.host.requestUpdate();\n });\n }\n\n hostDisconnected(): void {\n this.unsubscribe?.();\n this.unsubscribe = undefined;\n }\n}\n\nexport function createNamespacedSelector<Modules extends ModulesMap, R>(\n host: ReactiveControllerHost,\n system: NamespacedSystem<Modules>,\n keys: string[],\n selector: (system: NamespacedSystem<Modules>) => R,\n): NamespacedSelectorController<Modules, R> {\n return new NamespacedSelectorController(host, system, keys, selector);\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { ReactiveController, ReactiveControllerHost } from 'lit';
2
- import { SingleModuleSystem, ModuleSchema, InferFacts, InferDerivations, createRequirementStatusPlugin, ModuleDef, Plugin, DebugConfig, ErrorBoundaryConfig, InferEvents, RequirementTypeStatus, CreateSystemOptionsSingle, TimeTravelState } from '@directive-run/core';
1
+ import { SingleModuleSystem, ModuleSchema, InferFacts, InferDerivations, createRequirementStatusPlugin, ModuleDef, Plugin, DebugConfig, ErrorBoundaryConfig, InferEvents, ModulesMap, NamespacedSystem, RequirementTypeStatus, CreateSystemOptionsSingle, TimeTravelState } from '@directive-run/core';
3
2
  export { RequirementTypeStatus } from '@directive-run/core';
4
3
  import { ConstraintInfo, InspectState } from '@directive-run/core/adapter-utils';
5
4
  export { ConstraintInfo, InspectState, shallowEqual } from '@directive-run/core/adapter-utils';
5
+ import { ReactiveController, ReactiveControllerHost } from 'lit';
6
6
 
7
7
  /**
8
8
  * Lit Adapter - Consolidated Web Components integration for Directive
@@ -273,5 +273,33 @@ declare function createTypedHooks<M extends ModuleSchema>(): {
273
273
  useEvents: (system: SingleModuleSystem<M>) => SingleModuleSystem<M>["events"];
274
274
  createWatch: <K extends string>(host: ReactiveControllerHost, system: SingleModuleSystem<M>, key: K, callback: (newValue: unknown, previousValue: unknown) => void) => WatchController<unknown>;
275
275
  };
276
+ /**
277
+ * Reactive controller that selects from a NamespacedSystem.
278
+ * Subscribes to specified keys and triggers host updates.
279
+ *
280
+ * @example
281
+ * ```typescript
282
+ * class MyElement extends LitElement {
283
+ * private token = new NamespacedSelectorController(
284
+ * this, system, ["auth.token"], (s) => s.facts.auth.token,
285
+ * );
286
+ * render() {
287
+ * return html`<span>${this.token.value}</span>`;
288
+ * }
289
+ * }
290
+ * ```
291
+ */
292
+ declare class NamespacedSelectorController<Modules extends ModulesMap, R> implements ReactiveController {
293
+ private host;
294
+ private system;
295
+ private keys;
296
+ private selector;
297
+ private unsubscribe?;
298
+ value: R;
299
+ constructor(host: ReactiveControllerHost, system: NamespacedSystem<Modules>, keys: string[], selector: (system: NamespacedSystem<Modules>) => R);
300
+ hostConnected(): void;
301
+ hostDisconnected(): void;
302
+ }
303
+ declare function createNamespacedSelector<Modules extends ModulesMap, R>(host: ReactiveControllerHost, system: NamespacedSystem<Modules>, keys: string[], selector: (system: NamespacedSystem<Modules>) => R): NamespacedSelectorController<Modules, R>;
276
304
 
277
- export { ConstraintStatusController, DerivedController, DirectiveSelectorController, ExplainController, FactController, InspectController, ModuleController, OptimisticUpdateController, RequirementStatusController, type StatusPlugin, SystemController, TimeTravelController, WatchController, createConstraintStatus, createDerived, createDirectiveSelector, createExplain, createFact, createInspect, createModule, createOptimisticUpdate, createRequirementStatus, createTypedHooks, createWatch, directiveContext, getDerived, getFact, useDispatch, useEvents, useTimeTravel };
305
+ export { ConstraintStatusController, DerivedController, DirectiveSelectorController, ExplainController, FactController, InspectController, ModuleController, NamespacedSelectorController, OptimisticUpdateController, RequirementStatusController, type StatusPlugin, SystemController, TimeTravelController, WatchController, createConstraintStatus, createDerived, createDirectiveSelector, createExplain, createFact, createInspect, createModule, createNamespacedSelector, createOptimisticUpdate, createRequirementStatus, createTypedHooks, createWatch, directiveContext, getDerived, getFact, useDispatch, useEvents, useTimeTravel };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { ReactiveController, ReactiveControllerHost } from 'lit';
2
- import { SingleModuleSystem, ModuleSchema, InferFacts, InferDerivations, createRequirementStatusPlugin, ModuleDef, Plugin, DebugConfig, ErrorBoundaryConfig, InferEvents, RequirementTypeStatus, CreateSystemOptionsSingle, TimeTravelState } from '@directive-run/core';
1
+ import { SingleModuleSystem, ModuleSchema, InferFacts, InferDerivations, createRequirementStatusPlugin, ModuleDef, Plugin, DebugConfig, ErrorBoundaryConfig, InferEvents, ModulesMap, NamespacedSystem, RequirementTypeStatus, CreateSystemOptionsSingle, TimeTravelState } from '@directive-run/core';
3
2
  export { RequirementTypeStatus } from '@directive-run/core';
4
3
  import { ConstraintInfo, InspectState } from '@directive-run/core/adapter-utils';
5
4
  export { ConstraintInfo, InspectState, shallowEqual } from '@directive-run/core/adapter-utils';
5
+ import { ReactiveController, ReactiveControllerHost } from 'lit';
6
6
 
7
7
  /**
8
8
  * Lit Adapter - Consolidated Web Components integration for Directive
@@ -273,5 +273,33 @@ declare function createTypedHooks<M extends ModuleSchema>(): {
273
273
  useEvents: (system: SingleModuleSystem<M>) => SingleModuleSystem<M>["events"];
274
274
  createWatch: <K extends string>(host: ReactiveControllerHost, system: SingleModuleSystem<M>, key: K, callback: (newValue: unknown, previousValue: unknown) => void) => WatchController<unknown>;
275
275
  };
276
+ /**
277
+ * Reactive controller that selects from a NamespacedSystem.
278
+ * Subscribes to specified keys and triggers host updates.
279
+ *
280
+ * @example
281
+ * ```typescript
282
+ * class MyElement extends LitElement {
283
+ * private token = new NamespacedSelectorController(
284
+ * this, system, ["auth.token"], (s) => s.facts.auth.token,
285
+ * );
286
+ * render() {
287
+ * return html`<span>${this.token.value}</span>`;
288
+ * }
289
+ * }
290
+ * ```
291
+ */
292
+ declare class NamespacedSelectorController<Modules extends ModulesMap, R> implements ReactiveController {
293
+ private host;
294
+ private system;
295
+ private keys;
296
+ private selector;
297
+ private unsubscribe?;
298
+ value: R;
299
+ constructor(host: ReactiveControllerHost, system: NamespacedSystem<Modules>, keys: string[], selector: (system: NamespacedSystem<Modules>) => R);
300
+ hostConnected(): void;
301
+ hostDisconnected(): void;
302
+ }
303
+ declare function createNamespacedSelector<Modules extends ModulesMap, R>(host: ReactiveControllerHost, system: NamespacedSystem<Modules>, keys: string[], selector: (system: NamespacedSystem<Modules>) => R): NamespacedSelectorController<Modules, R>;
276
304
 
277
- export { ConstraintStatusController, DerivedController, DirectiveSelectorController, ExplainController, FactController, InspectController, ModuleController, OptimisticUpdateController, RequirementStatusController, type StatusPlugin, SystemController, TimeTravelController, WatchController, createConstraintStatus, createDerived, createDirectiveSelector, createExplain, createFact, createInspect, createModule, createOptimisticUpdate, createRequirementStatus, createTypedHooks, createWatch, directiveContext, getDerived, getFact, useDispatch, useEvents, useTimeTravel };
305
+ export { ConstraintStatusController, DerivedController, DirectiveSelectorController, ExplainController, FactController, InspectController, ModuleController, NamespacedSelectorController, OptimisticUpdateController, RequirementStatusController, type StatusPlugin, SystemController, TimeTravelController, WatchController, createConstraintStatus, createDerived, createDirectiveSelector, createExplain, createFact, createInspect, createModule, createNamespacedSelector, createOptimisticUpdate, createRequirementStatus, createTypedHooks, createWatch, directiveContext, getDerived, getFact, useDispatch, useEvents, useTimeTravel };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import {createSystem,createRequirementStatusPlugin}from'@directive-run/core';import {defaultEquality,computeInspectState,createThrottle,runTrackedSelector,assertSystem,buildTimeTravelState,depsChanged}from'@directive-run/core/adapter-utils';export{shallowEqual}from'@directive-run/core/adapter-utils';var E=Symbol("directive"),r=class{host;system;unsubscribe;constructor(e,t){this.host=e,this.system=t,e.addController(this);}hostConnected(){this.subscribe();}hostDisconnected(){this.unsubscribe?.(),this.unsubscribe=void 0;}requestUpdate(){this.host.requestUpdate();}},d=class extends r{keys;isMulti;value;constructor(e,t,i){super(e,t),this.isMulti=Array.isArray(i),this.keys=this.isMulti?i:[i],this.value=this.getValues(),process.env.NODE_ENV!=="production"&&!this.isMulti&&this.value===void 0&&console.warn(`[Directive] DerivedController("${this.keys[0]}") returned undefined. Check that "${this.keys[0]}" is defined in your module's derive property.`);}getValues(){if(this.isMulti){let e={};for(let t of this.keys)e[t]=this.system.read(t);return e}return this.system.read(this.keys[0])}subscribe(){this.value=this.getValues(),this.unsubscribe=this.system.subscribe(this.keys,()=>{this.value=this.getValues(),this.requestUpdate();});}},h=class extends r{factKey;value;constructor(e,t,i){super(e,t),this.factKey=i,this.value=t.facts.$store.get(i),process.env.NODE_ENV!=="production"&&(t.facts.$store.has(i)||console.warn(`[Directive] FactController("${i}") \u2014 fact not found in store. Check that "${i}" is defined in your module's schema.`));}subscribe(){this.value=this.system.facts.$store.get(this.factKey),this.unsubscribe=this.system.facts.$store.subscribe([this.factKey],()=>{this.value=this.system.facts.$store.get(this.factKey),this.requestUpdate();});}},v=class extends r{value;throttleMs;throttleCleanup;unsubSettled;constructor(e,t,i){super(e,t),this.throttleMs=i?.throttleMs??0,this.value=computeInspectState(t);}subscribe(){this.value=computeInspectState(this.system);let e=()=>{this.value=computeInspectState(this.system),this.requestUpdate();};if(this.throttleMs>0){let{throttled:t,cleanup:i}=createThrottle(e,this.throttleMs);this.throttleCleanup=i,this.unsubscribe=this.system.facts.$store.subscribeAll(t),this.unsubSettled=this.system.onSettledChange(t);}else this.unsubscribe=this.system.facts.$store.subscribeAll(e),this.unsubSettled=this.system.onSettledChange(e);}hostDisconnected(){this.throttleCleanup?.(),this.unsubSettled?.(),super.hostDisconnected();}},y=class{host;statusPlugin;type;unsubscribe;value;constructor(e,t,i){this.host=e,this.statusPlugin=t,this.type=i,this.value=t.getStatus(i),e.addController(this);}hostConnected(){this.value=this.statusPlugin.getStatus(this.type),this.unsubscribe=this.statusPlugin.subscribe(()=>{this.value=this.statusPlugin.getStatus(this.type),this.host.requestUpdate();});}hostDisconnected(){this.unsubscribe?.(),this.unsubscribe=void 0;}},p=class extends r{selector;equalityFn;autoTrack;deriveKeySet;trackedFactKeys=[];trackedDeriveKeys=[];unsubs=[];value;constructor(e,t,i,n=defaultEquality,o){super(e,t),this.selector=i,this.equalityFn=n,this.autoTrack=o?.autoTrack??true,this.deriveKeySet=new Set(Object.keys(t.derive??{}));let a=this.runWithTracking();this.value=a.value,this.trackedFactKeys=a.factKeys,this.trackedDeriveKeys=a.deriveKeys;}runWithTracking(){return runTrackedSelector(this.system,this.deriveKeySet,this.selector)}resubscribe(){for(let t of this.unsubs)t();this.unsubs=[];let e=()=>{let t=this.runWithTracking();this.equalityFn(this.value,t.value)||(this.value=t.value,this.requestUpdate()),this.autoTrack&&depsChanged(this.trackedFactKeys,t.factKeys,this.trackedDeriveKeys,t.deriveKeys)&&(this.trackedFactKeys=t.factKeys,this.trackedDeriveKeys=t.deriveKeys,this.resubscribe());};this.autoTrack?(this.trackedFactKeys.length>0?this.unsubs.push(this.system.facts.$store.subscribe(this.trackedFactKeys,e)):this.trackedDeriveKeys.length===0&&this.unsubs.push(this.system.facts.$store.subscribeAll(e)),this.trackedDeriveKeys.length>0&&this.unsubs.push(this.system.subscribe(this.trackedDeriveKeys,e))):this.unsubs.push(this.system.facts.$store.subscribeAll(e));}subscribe(){let e=this.runWithTracking();this.value=e.value,this.trackedFactKeys=e.factKeys,this.trackedDeriveKeys=e.deriveKeys,this.resubscribe();}hostDisconnected(){for(let e of this.unsubs)e();this.unsubs=[],super.hostDisconnected();}},g=class extends r{key;callback;constructor(e,t,i,n){super(e,t),this.key=i,this.callback=n;}subscribe(){this.unsubscribe=this.system.watch(this.key,this.callback);}},m=class extends r{requirementId;value;unsubSettled;constructor(e,t,i){super(e,t),this.requirementId=i,this.value=t.explain(i);}subscribe(){this.value=this.system.explain(this.requirementId);let e=()=>{this.value=this.system.explain(this.requirementId),this.requestUpdate();};this.unsubscribe=this.system.facts.$store.subscribeAll(e),this.unsubSettled=this.system.onSettledChange(e);}hostDisconnected(){this.unsubSettled?.(),super.hostDisconnected();}},f=class extends r{constraintId;value;unsubSettled;constructor(e,t,i){super(e,t),this.constraintId=i,this.value=this.getVal();}getVal(){let e=this.system.inspect();return this.constraintId?e.constraints.find(t=>t.id===this.constraintId)??null:e.constraints}subscribe(){this.value=this.getVal();let e=()=>{this.value=this.getVal(),this.requestUpdate();};this.unsubscribe=this.system.facts.$store.subscribeAll(e),this.unsubSettled=this.system.onSettledChange(e);}hostDisconnected(){this.unsubSettled?.(),super.hostDisconnected();}},b=class{host;system;statusPlugin;requirementType;snapshot=null;statusUnsub=null;isPending=false;error=null;constructor(e,t,i,n){this.host=e,this.system=t,this.statusPlugin=i,this.requirementType=n,e.addController(this);}hostConnected(){}hostDisconnected(){this.statusUnsub?.(),this.statusUnsub=null;}rollback(){this.snapshot&&(this.system.restore(this.snapshot),this.snapshot=null),this.isPending=false,this.error=null,this.statusUnsub?.(),this.statusUnsub=null,this.host.requestUpdate();}mutate(e){this.snapshot=this.system.getSnapshot(),this.isPending=true,this.error=null,this.system.batch(e),this.host.requestUpdate(),this.statusPlugin&&this.requirementType&&(this.statusUnsub?.(),this.statusUnsub=this.statusPlugin.subscribe(()=>{let t=this.statusPlugin.getStatus(this.requirementType);!t.isLoading&&!t.hasError?(this.snapshot=null,this.isPending=false,this.statusUnsub?.(),this.statusUnsub=null,this.host.requestUpdate()):t.hasError&&(this.error=t.lastError,this.rollback());}));}},C=class{options;_system=null;constructor(e,t){this.options=t,e.addController(this);}get system(){if(!this._system)throw new Error(`[Directive] SystemController.system is not available. This can happen if:
1
+ import {createSystem,createRequirementStatusPlugin}from'@directive-run/core';import {defaultEquality,computeInspectState,createThrottle,runTrackedSelector,assertSystem,buildTimeTravelState,depsChanged}from'@directive-run/core/adapter-utils';export{shallowEqual}from'@directive-run/core/adapter-utils';var U=Symbol("directive"),r=class{host;system;unsubscribe;constructor(e,t){this.host=e,this.system=t,e.addController(this);}hostConnected(){this.subscribe();}hostDisconnected(){this.unsubscribe?.(),this.unsubscribe=void 0;}requestUpdate(){this.host.requestUpdate();}},d=class extends r{keys;isMulti;value;constructor(e,t,i){super(e,t),this.isMulti=Array.isArray(i),this.keys=this.isMulti?i:[i],this.value=this.getValues(),process.env.NODE_ENV!=="production"&&!this.isMulti&&this.value===void 0&&console.warn(`[Directive] DerivedController("${this.keys[0]}") returned undefined. Check that "${this.keys[0]}" is defined in your module's derive property.`);}getValues(){if(this.isMulti){let e={};for(let t of this.keys)e[t]=this.system.read(t);return e}return this.system.read(this.keys[0])}subscribe(){this.value=this.getValues(),this.unsubscribe=this.system.subscribe(this.keys,()=>{this.value=this.getValues(),this.requestUpdate();});}},h=class extends r{factKey;value;constructor(e,t,i){super(e,t),this.factKey=i,this.value=t.facts.$store.get(i),process.env.NODE_ENV!=="production"&&(t.facts.$store.has(i)||console.warn(`[Directive] FactController("${i}") \u2014 fact not found in store. Check that "${i}" is defined in your module's schema.`));}subscribe(){this.value=this.system.facts.$store.get(this.factKey),this.unsubscribe=this.system.facts.$store.subscribe([this.factKey],()=>{this.value=this.system.facts.$store.get(this.factKey),this.requestUpdate();});}},v=class extends r{value;throttleMs;throttleCleanup;unsubSettled;constructor(e,t,i){super(e,t),this.throttleMs=i?.throttleMs??0,this.value=computeInspectState(t);}subscribe(){this.value=computeInspectState(this.system);let e=()=>{this.value=computeInspectState(this.system),this.requestUpdate();};if(this.throttleMs>0){let{throttled:t,cleanup:i}=createThrottle(e,this.throttleMs);this.throttleCleanup=i,this.unsubscribe=this.system.facts.$store.subscribeAll(t),this.unsubSettled=this.system.onSettledChange(t);}else this.unsubscribe=this.system.facts.$store.subscribeAll(e),this.unsubSettled=this.system.onSettledChange(e);}hostDisconnected(){this.throttleCleanup?.(),this.unsubSettled?.(),super.hostDisconnected();}},y=class{host;statusPlugin;type;unsubscribe;value;constructor(e,t,i){this.host=e,this.statusPlugin=t,this.type=i,this.value=t.getStatus(i),e.addController(this);}hostConnected(){this.value=this.statusPlugin.getStatus(this.type),this.unsubscribe=this.statusPlugin.subscribe(()=>{this.value=this.statusPlugin.getStatus(this.type),this.host.requestUpdate();});}hostDisconnected(){this.unsubscribe?.(),this.unsubscribe=void 0;}},p=class extends r{selector;equalityFn;autoTrack;deriveKeySet;trackedFactKeys=[];trackedDeriveKeys=[];unsubs=[];value;constructor(e,t,i,n=defaultEquality,o){super(e,t),this.selector=i,this.equalityFn=n,this.autoTrack=o?.autoTrack??true,this.deriveKeySet=new Set(Object.keys(t.derive??{}));let a=this.runWithTracking();this.value=a.value,this.trackedFactKeys=a.factKeys,this.trackedDeriveKeys=a.deriveKeys;}runWithTracking(){return runTrackedSelector(this.system,this.deriveKeySet,this.selector)}resubscribe(){for(let t of this.unsubs)t();this.unsubs=[];let e=()=>{let t=this.runWithTracking();this.equalityFn(this.value,t.value)||(this.value=t.value,this.requestUpdate()),this.autoTrack&&depsChanged(this.trackedFactKeys,t.factKeys,this.trackedDeriveKeys,t.deriveKeys)&&(this.trackedFactKeys=t.factKeys,this.trackedDeriveKeys=t.deriveKeys,this.resubscribe());};this.autoTrack?(this.trackedFactKeys.length>0?this.unsubs.push(this.system.facts.$store.subscribe(this.trackedFactKeys,e)):this.trackedDeriveKeys.length===0&&this.unsubs.push(this.system.facts.$store.subscribeAll(e)),this.trackedDeriveKeys.length>0&&this.unsubs.push(this.system.subscribe(this.trackedDeriveKeys,e))):this.unsubs.push(this.system.facts.$store.subscribeAll(e));}subscribe(){let e=this.runWithTracking();this.value=e.value,this.trackedFactKeys=e.factKeys,this.trackedDeriveKeys=e.deriveKeys,this.resubscribe();}hostDisconnected(){for(let e of this.unsubs)e();this.unsubs=[],super.hostDisconnected();}},m=class extends r{key;callback;constructor(e,t,i,n){super(e,t),this.key=i,this.callback=n;}subscribe(){this.unsubscribe=this.system.watch(this.key,this.callback);}},g=class extends r{requirementId;value;unsubSettled;constructor(e,t,i){super(e,t),this.requirementId=i,this.value=t.explain(i);}subscribe(){this.value=this.system.explain(this.requirementId);let e=()=>{this.value=this.system.explain(this.requirementId),this.requestUpdate();};this.unsubscribe=this.system.facts.$store.subscribeAll(e),this.unsubSettled=this.system.onSettledChange(e);}hostDisconnected(){this.unsubSettled?.(),super.hostDisconnected();}},b=class extends r{constraintId;value;unsubSettled;constructor(e,t,i){super(e,t),this.constraintId=i,this.value=this.getVal();}getVal(){let e=this.system.inspect();return this.constraintId?e.constraints.find(t=>t.id===this.constraintId)??null:e.constraints}subscribe(){this.value=this.getVal();let e=()=>{this.value=this.getVal(),this.requestUpdate();};this.unsubscribe=this.system.facts.$store.subscribeAll(e),this.unsubSettled=this.system.onSettledChange(e);}hostDisconnected(){this.unsubSettled?.(),super.hostDisconnected();}},f=class{host;system;statusPlugin;requirementType;snapshot=null;statusUnsub=null;isPending=false;error=null;constructor(e,t,i,n){this.host=e,this.system=t,this.statusPlugin=i,this.requirementType=n,e.addController(this);}hostConnected(){}hostDisconnected(){this.statusUnsub?.(),this.statusUnsub=null;}rollback(){this.snapshot&&(this.system.restore(this.snapshot),this.snapshot=null),this.isPending=false,this.error=null,this.statusUnsub?.(),this.statusUnsub=null,this.host.requestUpdate();}mutate(e){this.snapshot=this.system.getSnapshot(),this.isPending=true,this.error=null,this.system.batch(e),this.host.requestUpdate(),this.statusPlugin&&this.requirementType&&(this.statusUnsub?.(),this.statusUnsub=this.statusPlugin.subscribe(()=>{let t=this.statusPlugin.getStatus(this.requirementType);!t.isLoading&&!t.hasError?(this.snapshot=null,this.isPending=false,this.statusUnsub?.(),this.statusUnsub=null,this.host.requestUpdate()):t.hasError&&(this.error=t.lastError,this.rollback());}));}},R=class{options;_system=null;constructor(e,t){this.options=t,e.addController(this);}get system(){if(!this._system)throw new Error(`[Directive] SystemController.system is not available. This can happen if:
2
2
  1. Accessed before hostConnected (e.g., in a class field initializer)
3
3
  2. Accessed after hostDisconnected (system was destroyed)
4
- Solution: Access system only in lifecycle methods (connectedCallback, render) or after the element is connected to the DOM.`);return this._system}hostConnected(){let t="id"in this.options&&"schema"in this.options?createSystem({module:this.options}):createSystem(this.options);this._system=t,this._system.start();}hostDisconnected(){this._system?.destroy(),this._system=null;}},S=class{host;moduleDef;config;_system=null;unsubFacts;unsubDerived;facts={};derived={};statusPlugin;get system(){if(!this._system)throw new Error("[Directive] ModuleController.system is not available before hostConnected.");return this._system}get events(){return this.system.events}constructor(e,t,i){this.host=e,this.moduleDef=t,this.config=i,e.addController(this);}hostConnected(){let e=[...this.config?.plugins??[]];if(this.config?.status){let o=createRequirementStatusPlugin();this.statusPlugin=o,e.push(o.plugin);}let t=createSystem({module:this.moduleDef,plugins:e.length>0?e:void 0,debug:this.config?.debug,errorBoundary:this.config?.errorBoundary,tickMs:this.config?.tickMs,zeroConfig:this.config?.zeroConfig,initialFacts:this.config?.initialFacts});this._system=t,t.start(),this.facts=t.facts.$store.toObject(),this.unsubFacts=t.facts.$store.subscribeAll(()=>{this.facts=t.facts.$store.toObject(),this.host.requestUpdate();});let i=Object.keys(t.derive??{}),n=()=>{let o={};for(let a of i)o[a]=t.read(a);return o};this.derived=n(),i.length>0&&(this.unsubDerived=t.subscribe(i,()=>{this.derived=n(),this.host.requestUpdate();}));}hostDisconnected(){this.unsubFacts?.(),this.unsubDerived?.(),this._system?.destroy(),this._system=null;}dispatch(e){this.system.dispatch(e);}};function I(s,e,t){return new d(s,e,t)}function w(s,e,t){return new h(s,e,t)}function U(s,e,t){return new v(s,e,t)}function _(s,e,t){return new y(s,e,t)}function H(s,e,t,i){return new g(s,e,t,i)}function V(s,e,t,i=defaultEquality,n){return new p(s,e,t,i,n)}function $(s,e,t){return new m(s,e,t)}function A(s,e,t){return new f(s,e,t)}function O(s,e,t,i){return new b(s,e,t,i)}function B(s,e,t){return new S(s,e,t)}function W(s){return assertSystem("useDispatch",s),e=>{s.dispatch(e);}}function z(s){return assertSystem("useEvents",s),s.events}var k=class{constructor(e,t){this._host=e;this._system=t;this._host.addController(this);}value=null;_unsub;hostConnected(){this.value=buildTimeTravelState(this._system),this._unsub=this._system.onTimeTravelChange(()=>{this.value=buildTimeTravelState(this._system),this._host.requestUpdate();});}hostDisconnected(){this._unsub?.(),this._unsub=void 0;}};function j(s){return assertSystem("useTimeTravel",s),buildTimeTravelState(s)}function N(s,e){return ()=>s.read(e)}function L(s,e){return ()=>s.facts.$store.get(e)}function G(){return {createDerived:(s,e,t)=>I(s,e,t),createFact:(s,e,t)=>w(s,e,t),useDispatch:s=>e=>{s.dispatch(e);},useEvents:s=>s.events,createWatch:(s,e,t,i)=>H(s,e,t,i)}}export{f as ConstraintStatusController,d as DerivedController,p as DirectiveSelectorController,m as ExplainController,h as FactController,v as InspectController,S as ModuleController,b as OptimisticUpdateController,y as RequirementStatusController,C as SystemController,k as TimeTravelController,g as WatchController,A as createConstraintStatus,I as createDerived,V as createDirectiveSelector,$ as createExplain,w as createFact,U as createInspect,B as createModule,O as createOptimisticUpdate,_ as createRequirementStatus,G as createTypedHooks,H as createWatch,E as directiveContext,N as getDerived,L as getFact,W as useDispatch,z as useEvents,j as useTimeTravel};//# sourceMappingURL=index.js.map
4
+ Solution: Access system only in lifecycle methods (connectedCallback, render) or after the element is connected to the DOM.`);return this._system}hostConnected(){let t="id"in this.options&&"schema"in this.options?createSystem({module:this.options}):createSystem(this.options);this._system=t,this._system.start();}hostDisconnected(){this._system?.destroy(),this._system=null;}},S=class{host;moduleDef;config;_system=null;unsubFacts;unsubDerived;facts={};derived={};statusPlugin;get system(){if(!this._system)throw new Error("[Directive] ModuleController.system is not available before hostConnected.");return this._system}get events(){return this.system.events}constructor(e,t,i){this.host=e,this.moduleDef=t,this.config=i,e.addController(this);}hostConnected(){let e=[...this.config?.plugins??[]];if(this.config?.status){let o=createRequirementStatusPlugin();this.statusPlugin=o,e.push(o.plugin);}let t=createSystem({module:this.moduleDef,plugins:e.length>0?e:void 0,debug:this.config?.debug,errorBoundary:this.config?.errorBoundary,tickMs:this.config?.tickMs,zeroConfig:this.config?.zeroConfig,initialFacts:this.config?.initialFacts});this._system=t,t.start(),this.facts=t.facts.$store.toObject(),this.unsubFacts=t.facts.$store.subscribeAll(()=>{this.facts=t.facts.$store.toObject(),this.host.requestUpdate();});let i=Object.keys(t.derive??{}),n=()=>{let o={};for(let a of i)o[a]=t.read(a);return o};this.derived=n(),i.length>0&&(this.unsubDerived=t.subscribe(i,()=>{this.derived=n(),this.host.requestUpdate();}));}hostDisconnected(){this.unsubFacts?.(),this.unsubDerived?.(),this._system?.destroy(),this._system=null;}dispatch(e){this.system.dispatch(e);}};function w(s,e,t){return new d(s,e,t)}function H(s,e,t){return new h(s,e,t)}function _(s,e,t){return new v(s,e,t)}function V(s,e,t){return new y(s,e,t)}function q(s,e,t,i){return new m(s,e,t,i)}function $(s,e,t,i=defaultEquality,n){return new p(s,e,t,i,n)}function A(s,e,t){return new g(s,e,t)}function N(s,e,t){return new b(s,e,t)}function O(s,e,t,i){return new f(s,e,t,i)}function B(s,e,t){return new S(s,e,t)}function W(s){return assertSystem("useDispatch",s),e=>{s.dispatch(e);}}function z(s){return assertSystem("useEvents",s),s.events}var k=class{constructor(e,t){this._host=e;this._system=t;this._host.addController(this);}value=null;_unsub;hostConnected(){this.value=buildTimeTravelState(this._system),this._unsub=this._system.onTimeTravelChange(()=>{this.value=buildTimeTravelState(this._system),this._host.requestUpdate();});}hostDisconnected(){this._unsub?.(),this._unsub=void 0;}};function j(s){return assertSystem("useTimeTravel",s),buildTimeTravelState(s)}function L(s,e){return ()=>s.read(e)}function G(s,e){return ()=>s.facts.$store.get(e)}function J(){return {createDerived:(s,e,t)=>w(s,e,t),createFact:(s,e,t)=>H(s,e,t),useDispatch:s=>e=>{s.dispatch(e);},useEvents:s=>s.events,createWatch:(s,e,t,i)=>q(s,e,t,i)}}var M=class{host;system;keys;selector;unsubscribe;value;constructor(e,t,i,n){this.host=e,this.system=t,this.keys=i,this.selector=n,this.value=n(t),e.addController(this);}hostConnected(){this.value=this.selector(this.system),this.unsubscribe=this.system.subscribe(this.keys,()=>{this.value=this.selector(this.system),this.host.requestUpdate();});}hostDisconnected(){this.unsubscribe?.(),this.unsubscribe=void 0;}};function Q(s,e,t,i){return new M(s,e,t,i)}export{b as ConstraintStatusController,d as DerivedController,p as DirectiveSelectorController,g as ExplainController,h as FactController,v as InspectController,S as ModuleController,M as NamespacedSelectorController,f as OptimisticUpdateController,y as RequirementStatusController,R as SystemController,k as TimeTravelController,m as WatchController,N as createConstraintStatus,w as createDerived,$ as createDirectiveSelector,A as createExplain,H as createFact,_ as createInspect,B as createModule,Q as createNamespacedSelector,O as createOptimisticUpdate,V as createRequirementStatus,J as createTypedHooks,q as createWatch,U as directiveContext,L as getDerived,G as getFact,W as useDispatch,z as useEvents,j as useTimeTravel};//# sourceMappingURL=index.js.map
5
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["directiveContext","DirectiveController","host","system","DerivedController","key","result","id","FactController","factKey","InspectController","options","computeInspectState","update","throttled","cleanup","createThrottle","RequirementStatusController","statusPlugin","type","DirectiveSelectorController","selector","equalityFn","defaultEquality","initial","runTrackedSelector","unsub","onUpdate","depsChanged","WatchController","callback","ExplainController","requirementId","ConstraintStatusController","constraintId","inspection","c","OptimisticUpdateController","requirementType","updateFn","status","SystemController","createSystem","ModuleController","moduleDef","config","allPlugins","sp","createRequirementStatusPlugin","derivationKeys","getDerived","event","createDerived","createFact","createInspect","createRequirementStatus","createWatch","derivationId","createDirectiveSelector","createExplain","createConstraintStatus","createOptimisticUpdate","createModule","useDispatch","assertSystem","useEvents","TimeTravelController","_host","_system","buildTimeTravelState","useTimeTravel","getFact","createTypedHooks"],"mappings":"6SAgEO,IAAMA,CAAAA,CAAmB,MAAA,CAAO,WAAW,CAAA,CASnCC,CAAAA,CAAf,KAAiE,CACtD,IAAA,CAEA,MAAA,CACA,WAAA,CAGV,WAAA,CAAYC,CAAAA,CAA8BC,CAAAA,CAAiC,CAC1E,IAAA,CAAK,IAAA,CAAOD,CAAAA,CACZ,IAAA,CAAK,MAAA,CAASC,CAAAA,CACdD,CAAAA,CAAK,aAAA,CAAc,IAAI,EACxB,CAEA,aAAA,EAAsB,CACrB,IAAA,CAAK,SAAA,GACN,CAEA,gBAAA,EAAyB,CACxB,IAAA,CAAK,WAAA,IAAc,CACnB,IAAA,CAAK,WAAA,CAAc,OACpB,CAIU,aAAA,EAAsB,CAC/B,IAAA,CAAK,IAAA,CAAK,aAAA,GACX,CACD,CAAA,CAYaE,CAAAA,CAAN,cAAmCH,CAAoB,CACrD,IAAA,CACA,OAAA,CACR,KAAA,CAEA,WAAA,CACCC,CAAAA,CAEAC,CAAAA,CACAE,EACC,CACD,KAAA,CAAMH,CAAAA,CAAMC,CAAM,CAAA,CAClB,IAAA,CAAK,OAAA,CAAU,KAAA,CAAM,QAAQE,CAAG,CAAA,CAChC,IAAA,CAAK,IAAA,CAAO,IAAA,CAAK,OAAA,CAAWA,CAAAA,CAAmB,CAACA,CAAa,CAAA,CAC7D,IAAA,CAAK,KAAA,CAAQ,IAAA,CAAK,SAAA,EAAU,CAExB,OAAA,CAAQ,GAAA,CAAI,QAAA,GAAa,YAAA,EACxB,CAAC,IAAA,CAAK,OAAA,EAAW,IAAA,CAAK,KAAA,GAAU,MAAA,EACnC,QAAQ,IAAA,CACP,CAAA,+BAAA,EAAkC,IAAA,CAAK,I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CAAAA,EAmBd,CACD,OAAO,CACN,cAAe,CACdtE,CAAAA,CACAC,CAAAA,CACAsD,CAAAA,GACIL,EAAsClD,CAAAA,CAAMC,CAAAA,CAAQsD,CAAsB,CAAA,CAC/E,UAAA,CAAY,CACXvD,CAAAA,CACAC,CAAAA,CACAM,IACI4C,CAAAA,CAA6BnD,CAAAA,CAAMC,CAAAA,CAAQM,CAAiB,EACjE,WAAA,CAAcN,CAAAA,EACLgD,CAAAA,EAA0B,CACjChD,EAAO,QAAA,CAASgD,CAAK,EACtB,CAAA,CAED,UAAYhD,CAAAA,EAAkCA,CAAAA,CAAO,MAAA,CACrD,WAAA,CAAa,CACZD,CAAAA,CACAC,CAAAA,CACAE,CAAAA,CACAyB,CAAAA,GACI0B,EAAqBtD,CAAAA,CAAMC,CAAAA,CAAQE,CAAAA,CAAKyB,CAAQ,CACtD,CACD","file":"index.js","sourcesContent":["/**\n * Lit Adapter - Consolidated Web Components integration for Directive\n *\n * Controllers: DerivedController, FactController,\n * InspectController (with throttle), RequirementStatusController,\n * DirectiveSelectorController,\n * WatchController (with fact mode), SystemController,\n * ExplainController, ConstraintStatusController, OptimisticUpdateController, ModuleController\n *\n * Factories: createDerived, createFact, createInspect,\n * createRequirementStatus, createWatch,\n * createDirectiveSelector, useDispatch, useEvents, useTimeTravel,\n * getDerived, getFact, createTypedHooks, shallowEqual\n */\n\nimport type { ReactiveController, ReactiveControllerHost } from \"lit\";\nimport type {\n\tCreateSystemOptionsSingle,\n\tModuleSchema,\n\tModuleDef,\n\tPlugin,\n\tDebugConfig,\n\tErrorBoundaryConfig,\n\tInferFacts,\n\tInferDerivations,\n\tInferEvents,\n\tSingleModuleSystem,\n\tSystemSnapshot,\n\tTimeTravelState,\n} from \"@directive-run/core\";\nimport {\n\tcreateSystem,\n\tcreateRequirementStatusPlugin,\n} from \"@directive-run/core\";\nimport type { RequirementTypeStatus } from \"@directive-run/core\";\nimport {\n\ttype InspectState,\n\ttype ConstraintInfo,\n\ttype TrackedSelectorResult,\n\tcomputeInspectState,\n\tcreateThrottle,\n\tassertSystem,\n\tdefaultEquality,\n\tbuildTimeTravelState,\n\trunTrackedSelector,\n\tdepsChanged,\n\tshallowEqual,\n} from \"@directive-run/core/adapter-utils\";\n\n// Re-export for convenience\nexport type { RequirementTypeStatus, InspectState, ConstraintInfo };\nexport { shallowEqual };\n\n/** Type for the requirement status plugin return value */\nexport type StatusPlugin = ReturnType<typeof createRequirementStatusPlugin>;\n\n// ============================================================================\n// Context\n// ============================================================================\n\n/**\n * Context key for Directive system.\n * Use with @lit/context for dependency injection across shadow DOM boundaries.\n */\nexport const directiveContext = Symbol(\"directive\");\n\n// ============================================================================\n// Base Controller\n// ============================================================================\n\n/**\n * Base controller that manages system subscription lifecycle.\n */\nabstract class DirectiveController implements ReactiveController {\n\tprotected host: ReactiveControllerHost;\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tprotected system: SingleModuleSystem<any>;\n\tprotected unsubscribe?: () => void;\n\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tconstructor(host: ReactiveControllerHost, system: SingleModuleSystem<any>) {\n\t\tthis.host = host;\n\t\tthis.system = system;\n\t\thost.addController(this);\n\t}\n\n\thostConnected(): void {\n\t\tthis.subscribe();\n\t}\n\n\thostDisconnected(): void {\n\t\tthis.unsubscribe?.();\n\t\tthis.unsubscribe = undefined;\n\t}\n\n\tprotected abstract subscribe(): void;\n\n\tprotected requestUpdate(): void {\n\t\tthis.host.requestUpdate();\n\t}\n}\n\n// ============================================================================\n// Core Controllers\n// ============================================================================\n\n/**\n * Reactive controller for derivations.\n * Accepts a single key (string) or an array of keys (string[]).\n * - Single key: `.value` returns `T`\n * - Array of keys: `.value` returns `Record<string, unknown>`\n */\nexport class DerivedController<T> extends DirectiveController {\n\tprivate keys: string[];\n\tprivate isMulti: boolean;\n\tvalue: T;\n\n\tconstructor(\n\t\thost: ReactiveControllerHost,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\t\tsystem: SingleModuleSystem<any>,\n\t\tkey: string | string[],\n\t) {\n\t\tsuper(host, system);\n\t\tthis.isMulti = Array.isArray(key);\n\t\tthis.keys = this.isMulti ? (key as string[]) : [key as string];\n\t\tthis.value = this.getValues();\n\n\t\tif (process.env.NODE_ENV !== \"production\") {\n\t\t\tif (!this.isMulti && this.value === undefined) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[Directive] DerivedController(\"${this.keys[0]}\") returned undefined. ` +\n\t\t\t\t\t`Check that \"${this.keys[0]}\" is defined in your module's derive property.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getValues(): T {\n\t\tif (this.isMulti) {\n\t\t\tconst result: Record<string, unknown> = {};\n\t\t\tfor (const id of this.keys) {\n\t\t\t\tresult[id] = this.system.read(id);\n\t\t\t}\n\t\t\treturn result as T;\n\t\t}\n\t\treturn this.system.read(this.keys[0]!) as T;\n\t}\n\n\tprotected subscribe(): void {\n\t\tthis.value = this.getValues();\n\t\tthis.unsubscribe = this.system.subscribe(this.keys, () => {\n\t\t\tthis.value = this.getValues();\n\t\t\tthis.requestUpdate();\n\t\t});\n\t}\n}\n\n/**\n * Reactive controller for a single fact value.\n */\nexport class FactController<T> extends DirectiveController {\n\tprivate factKey: string;\n\tvalue: T | undefined;\n\n\tconstructor(\n\t\thost: ReactiveControllerHost,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\t\tsystem: SingleModuleSystem<any>,\n\t\tfactKey: string,\n\t) {\n\t\tsuper(host, system);\n\t\tthis.factKey = factKey;\n\t\tthis.value = system.facts.$store.get(factKey) as T | undefined;\n\n\t\tif (process.env.NODE_ENV !== \"production\") {\n\t\t\tif (!system.facts.$store.has(factKey)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[Directive] FactController(\"${factKey}\") — fact not found in store. ` +\n\t\t\t\t\t`Check that \"${factKey}\" is defined in your module's schema.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected subscribe(): void {\n\t\tthis.value = this.system.facts.$store.get(this.factKey) as T | undefined;\n\t\tthis.unsubscribe = this.system.facts.$store.subscribe(\n\t\t\t[this.factKey],\n\t\t\t() => {\n\t\t\t\tthis.value = this.system.facts.$store.get(this.factKey) as T | undefined;\n\t\t\t\tthis.requestUpdate();\n\t\t\t},\n\t\t);\n\t}\n}\n\n/**\n * Consolidated inspection controller.\n * Returns InspectState with optional throttling.\n */\nexport class InspectController extends DirectiveController {\n\tvalue: InspectState;\n\tprivate throttleMs: number;\n\tprivate throttleCleanup?: () => void;\n\tprivate unsubSettled?: () => void;\n\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tconstructor(host: ReactiveControllerHost, system: SingleModuleSystem<any>, options?: { throttleMs?: number }) {\n\t\tsuper(host, system);\n\t\tthis.throttleMs = options?.throttleMs ?? 0;\n\t\tthis.value = computeInspectState(system);\n\t}\n\n\tprotected subscribe(): void {\n\t\tthis.value = computeInspectState(this.system);\n\n\t\tconst update = () => {\n\t\t\tthis.value = computeInspectState(this.system);\n\t\t\tthis.requestUpdate();\n\t\t};\n\n\t\tif (this.throttleMs > 0) {\n\t\t\tconst { throttled, cleanup } = createThrottle(update, this.throttleMs);\n\t\t\tthis.throttleCleanup = cleanup;\n\t\t\tthis.unsubscribe = this.system.facts.$store.subscribeAll(throttled);\n\t\t\tthis.unsubSettled = this.system.onSettledChange(throttled);\n\t\t} else {\n\t\t\tthis.unsubscribe = this.system.facts.$store.subscribeAll(update);\n\t\t\tthis.unsubSettled = this.system.onSettledChange(update);\n\t\t}\n\t}\n\n\thostDisconnected(): void {\n\t\tthis.throttleCleanup?.();\n\t\tthis.unsubSettled?.();\n\t\tsuper.hostDisconnected();\n\t}\n}\n\n/**\n * Reactive controller for requirement status.\n */\nexport class RequirementStatusController implements ReactiveController {\n\tprivate host: ReactiveControllerHost;\n\tprivate statusPlugin: StatusPlugin;\n\tprivate type: string;\n\tprivate unsubscribe?: () => void;\n\tvalue: RequirementTypeStatus;\n\n\tconstructor(\n\t\thost: ReactiveControllerHost,\n\t\tstatusPlugin: StatusPlugin,\n\t\ttype: string,\n\t) {\n\t\tthis.host = host;\n\t\tthis.statusPlugin = statusPlugin;\n\t\tthis.type = type;\n\t\tthis.value = statusPlugin.getStatus(type);\n\t\thost.addController(this);\n\t}\n\n\thostConnected(): void {\n\t\tthis.value = this.statusPlugin.getStatus(this.type);\n\t\tthis.unsubscribe = this.statusPlugin.subscribe(() => {\n\t\t\tthis.value = this.statusPlugin.getStatus(this.type);\n\t\t\tthis.host.requestUpdate();\n\t\t});\n\t}\n\n\thostDisconnected(): void {\n\t\tthis.unsubscribe?.();\n\t\tthis.unsubscribe = undefined;\n\t}\n}\n\n// ============================================================================\n// Selector Controllers\n// ============================================================================\n\n/**\n * Reactive controller for selecting across all facts.\n * Uses `withTracking()` for auto-tracking when constructed with `autoTrack: true`.\n */\nexport class DirectiveSelectorController<R> extends DirectiveController {\n\tprivate selector: (state: Record<string, unknown>) => R;\n\tprivate equalityFn: (a: R, b: R) => boolean;\n\tprivate autoTrack: boolean;\n\tprivate deriveKeySet: Set<string>;\n\tprivate trackedFactKeys: string[] = [];\n\tprivate trackedDeriveKeys: string[] = [];\n\tprivate unsubs: Array<() => void> = [];\n\tvalue: R;\n\n\tconstructor(\n\t\thost: ReactiveControllerHost,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\t\tsystem: SingleModuleSystem<any>,\n\t\tselector: (state: Record<string, unknown>) => R,\n\t\tequalityFn: (a: R, b: R) => boolean = defaultEquality,\n\t\toptions?: { autoTrack?: boolean },\n\t) {\n\t\tsuper(host, system);\n\t\tthis.selector = selector;\n\t\tthis.equalityFn = equalityFn;\n\t\tthis.autoTrack = options?.autoTrack ?? true;\n\t\tthis.deriveKeySet = new Set(Object.keys(system.derive ?? {}));\n\n\t\tconst initial = this.runWithTracking();\n\t\tthis.value = initial.value;\n\t\tthis.trackedFactKeys = initial.factKeys;\n\t\tthis.trackedDeriveKeys = initial.deriveKeys;\n\t}\n\n\tprivate runWithTracking(): TrackedSelectorResult<R> {\n\t\treturn runTrackedSelector(this.system, this.deriveKeySet, this.selector);\n\t}\n\n\tprivate resubscribe(): void {\n\t\tfor (const unsub of this.unsubs) unsub();\n\t\tthis.unsubs = [];\n\n\t\tconst onUpdate = () => {\n\t\t\tconst result = this.runWithTracking();\n\t\t\tif (!this.equalityFn(this.value, result.value)) {\n\t\t\t\tthis.value = result.value;\n\t\t\t\tthis.requestUpdate();\n\t\t\t}\n\t\t\tif (this.autoTrack) {\n\t\t\t\t// Re-track: check if deps changed\n\t\t\t\tif (depsChanged(this.trackedFactKeys, result.factKeys, this.trackedDeriveKeys, result.deriveKeys)) {\n\t\t\t\t\tthis.trackedFactKeys = result.factKeys;\n\t\t\t\t\tthis.trackedDeriveKeys = result.deriveKeys;\n\t\t\t\t\tthis.resubscribe();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tif (this.autoTrack) {\n\t\t\tif (this.trackedFactKeys.length > 0) {\n\t\t\t\tthis.unsubs.push(this.system.facts.$store.subscribe(this.trackedFactKeys, onUpdate));\n\t\t\t} else if (this.trackedDeriveKeys.length === 0) {\n\t\t\t\tthis.unsubs.push(this.system.facts.$store.subscribeAll(onUpdate));\n\t\t\t}\n\t\t\tif (this.trackedDeriveKeys.length > 0) {\n\t\t\t\tthis.unsubs.push(this.system.subscribe(this.trackedDeriveKeys, onUpdate));\n\t\t\t}\n\t\t} else {\n\t\t\tthis.unsubs.push(this.system.facts.$store.subscribeAll(onUpdate));\n\t\t}\n\t}\n\n\tprotected subscribe(): void {\n\t\tconst result = this.runWithTracking();\n\t\tthis.value = result.value;\n\t\tthis.trackedFactKeys = result.factKeys;\n\t\tthis.trackedDeriveKeys = result.deriveKeys;\n\t\tthis.resubscribe();\n\t}\n\n\thostDisconnected(): void {\n\t\tfor (const unsub of this.unsubs) unsub();\n\t\tthis.unsubs = [];\n\t\tsuper.hostDisconnected();\n\t}\n}\n\n/**\n * Reactive controller that watches a fact or derivation and calls a callback on change.\n * The key is auto-detected — works with both fact keys and derivation keys.\n */\nexport class WatchController<T> extends DirectiveController {\n\tprivate key: string;\n\tprivate callback: (newValue: T, previousValue: T | undefined) => void;\n\n\t/** Watch a derivation or fact by key (auto-detected). When a key exists in both facts and derivations, the derivation overload takes priority. */\n\tconstructor(\n\t\thost: ReactiveControllerHost,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\t\tsystem: SingleModuleSystem<any>,\n\t\tkey: string,\n\t\tcallback: (newValue: T, previousValue: T | undefined) => void,\n\t) {\n\t\tsuper(host, system);\n\t\tthis.key = key;\n\t\tthis.callback = callback;\n\t}\n\n\tprotected subscribe(): void {\n\t\tthis.unsubscribe = this.system.watch<T>(this.key, this.callback);\n\t}\n}\n\n// ============================================================================\n// New Controllers\n// ============================================================================\n\n/**\n * Reactive controller for requirement explanations.\n */\nexport class ExplainController extends DirectiveController {\n\tprivate requirementId: string;\n\tvalue: string | null;\n\tprivate unsubSettled?: () => void;\n\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tconstructor(host: ReactiveControllerHost, system: SingleModuleSystem<any>, requirementId: string) {\n\t\tsuper(host, system);\n\t\tthis.requirementId = requirementId;\n\t\tthis.value = system.explain(requirementId);\n\t}\n\n\tprotected subscribe(): void {\n\t\tthis.value = this.system.explain(this.requirementId);\n\n\t\tconst update = () => {\n\t\t\tthis.value = this.system.explain(this.requirementId);\n\t\t\tthis.requestUpdate();\n\t\t};\n\n\t\tthis.unsubscribe = this.system.facts.$store.subscribeAll(update);\n\t\tthis.unsubSettled = this.system.onSettledChange(update);\n\t}\n\n\thostDisconnected(): void {\n\t\tthis.unsubSettled?.();\n\t\tsuper.hostDisconnected();\n\t}\n}\n\n/**\n * Reactive controller for constraint status.\n */\nexport class ConstraintStatusController extends DirectiveController {\n\tprivate constraintId?: string;\n\tvalue: ConstraintInfo[] | ConstraintInfo | null;\n\tprivate unsubSettled?: () => void;\n\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tconstructor(host: ReactiveControllerHost, system: SingleModuleSystem<any>, constraintId?: string) {\n\t\tsuper(host, system);\n\t\tthis.constraintId = constraintId;\n\t\tthis.value = this.getVal();\n\t}\n\n\tprivate getVal(): ConstraintInfo[] | ConstraintInfo | null {\n\t\tconst inspection = this.system.inspect();\n\t\tif (!this.constraintId) return inspection.constraints;\n\t\treturn inspection.constraints.find((c: ConstraintInfo) => c.id === this.constraintId) ?? null;\n\t}\n\n\tprotected subscribe(): void {\n\t\tthis.value = this.getVal();\n\n\t\tconst update = () => {\n\t\t\tthis.value = this.getVal();\n\t\t\tthis.requestUpdate();\n\t\t};\n\n\t\tthis.unsubscribe = this.system.facts.$store.subscribeAll(update);\n\t\tthis.unsubSettled = this.system.onSettledChange(update);\n\t}\n\n\thostDisconnected(): void {\n\t\tthis.unsubSettled?.();\n\t\tsuper.hostDisconnected();\n\t}\n}\n\n/**\n * Reactive controller for optimistic updates.\n */\nexport class OptimisticUpdateController implements ReactiveController {\n\tprivate host: ReactiveControllerHost;\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tprivate system: SingleModuleSystem<any>;\n\tprivate statusPlugin?: StatusPlugin;\n\tprivate requirementType?: string;\n\tprivate snapshot: SystemSnapshot | null = null;\n\tprivate statusUnsub: (() => void) | null = null;\n\n\tisPending = false;\n\terror: Error | null = null;\n\n\tconstructor(\n\t\thost: ReactiveControllerHost,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\t\tsystem: SingleModuleSystem<any>,\n\t\tstatusPlugin?: StatusPlugin,\n\t\trequirementType?: string,\n\t) {\n\t\tthis.host = host;\n\t\tthis.system = system;\n\t\tthis.statusPlugin = statusPlugin;\n\t\tthis.requirementType = requirementType;\n\t\thost.addController(this);\n\t}\n\n\thostConnected(): void {}\n\n\thostDisconnected(): void {\n\t\tthis.statusUnsub?.();\n\t\tthis.statusUnsub = null;\n\t}\n\n\trollback(): void {\n\t\tif (this.snapshot) {\n\t\t\tthis.system.restore(this.snapshot);\n\t\t\tthis.snapshot = null;\n\t\t}\n\t\tthis.isPending = false;\n\t\tthis.error = null;\n\t\tthis.statusUnsub?.();\n\t\tthis.statusUnsub = null;\n\t\tthis.host.requestUpdate();\n\t}\n\n\tmutate(updateFn: () => void): void {\n\t\tthis.snapshot = this.system.getSnapshot();\n\t\tthis.isPending = true;\n\t\tthis.error = null;\n\t\tthis.system.batch(updateFn);\n\t\tthis.host.requestUpdate();\n\n\t\tif (this.statusPlugin && this.requirementType) {\n\t\t\tthis.statusUnsub?.();\n\t\t\tthis.statusUnsub = this.statusPlugin.subscribe(() => {\n\t\t\t\tconst status = this.statusPlugin!.getStatus(this.requirementType!);\n\t\t\t\tif (!status.isLoading && !status.hasError) {\n\t\t\t\t\tthis.snapshot = null;\n\t\t\t\t\tthis.isPending = false;\n\t\t\t\t\tthis.statusUnsub?.();\n\t\t\t\t\tthis.statusUnsub = null;\n\t\t\t\t\tthis.host.requestUpdate();\n\t\t\t\t} else if (status.hasError) {\n\t\t\t\t\tthis.error = status.lastError;\n\t\t\t\t\tthis.rollback();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Reactive controller that creates and manages a Directive system.\n * The system is automatically started when the host connects and destroyed when it disconnects.\n */\nexport class SystemController<M extends ModuleSchema> implements ReactiveController {\n\tprivate options: ModuleDef<M> | CreateSystemOptionsSingle<M>;\n\tprivate _system: SingleModuleSystem<M> | null = null;\n\n\tconstructor(host: ReactiveControllerHost, options: ModuleDef<M> | CreateSystemOptionsSingle<M>) {\n\t\tthis.options = options;\n\t\thost.addController(this);\n\t}\n\n\tget system(): SingleModuleSystem<M> {\n\t\tif (!this._system) {\n\t\t\tthrow new Error(\n\t\t\t\t\"[Directive] SystemController.system is not available. \" +\n\t\t\t\t\"This can happen if:\\n\" +\n\t\t\t\t\" 1. Accessed before hostConnected (e.g., in a class field initializer)\\n\" +\n\t\t\t\t\" 2. Accessed after hostDisconnected (system was destroyed)\\n\" +\n\t\t\t\t\"Solution: Access system only in lifecycle methods (connectedCallback, render) \" +\n\t\t\t\t\"or after the element is connected to the DOM.\",\n\t\t\t);\n\t\t}\n\t\treturn this._system;\n\t}\n\n\thostConnected(): void {\n\t\tconst isModule = \"id\" in this.options && \"schema\" in this.options;\n\t\tconst system = isModule\n\t\t\t? createSystem({ module: this.options as ModuleDef<M> })\n\t\t\t: createSystem(this.options as CreateSystemOptionsSingle<M>);\n\t\tthis._system = system as unknown as SingleModuleSystem<M>;\n\t\tthis._system.start();\n\t}\n\n\thostDisconnected(): void {\n\t\tthis._system?.destroy();\n\t\tthis._system = null;\n\t}\n}\n\n/**\n * Module controller — zero-config all-in-one.\n * Creates system, starts it, subscribes to all facts/derivations.\n */\nexport class ModuleController<M extends ModuleSchema> implements ReactiveController {\n\tprivate host: ReactiveControllerHost;\n\tprivate moduleDef: ModuleDef<M>;\n\tprivate config?: {\n\t\t// biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n\t\tplugins?: Plugin<any>[];\n\t\tdebug?: DebugConfig;\n\t\terrorBoundary?: ErrorBoundaryConfig;\n\t\ttickMs?: number;\n\t\tzeroConfig?: boolean;\n\t\t// biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n\t\tinitialFacts?: Record<string, any>;\n\t\tstatus?: boolean;\n\t};\n\n\tprivate _system: SingleModuleSystem<M> | null = null;\n\tprivate unsubFacts?: () => void;\n\tprivate unsubDerived?: () => void;\n\n\tfacts: InferFacts<M> = {} as InferFacts<M>;\n\tderived: InferDerivations<M> = {} as InferDerivations<M>;\n\tstatusPlugin?: StatusPlugin;\n\n\tget system(): SingleModuleSystem<M> {\n\t\tif (!this._system) {\n\t\t\tthrow new Error(\"[Directive] ModuleController.system is not available before hostConnected.\");\n\t\t}\n\t\treturn this._system;\n\t}\n\n\tget events(): SingleModuleSystem<M>[\"events\"] {\n\t\treturn this.system.events;\n\t}\n\n\tconstructor(\n\t\thost: ReactiveControllerHost,\n\t\tmoduleDef: ModuleDef<M>,\n\t\tconfig?: {\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n\t\t\tplugins?: Plugin<any>[];\n\t\t\tdebug?: DebugConfig;\n\t\t\terrorBoundary?: ErrorBoundaryConfig;\n\t\t\ttickMs?: number;\n\t\t\tzeroConfig?: boolean;\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n\t\t\tinitialFacts?: Record<string, any>;\n\t\t\tstatus?: boolean;\n\t\t},\n\t) {\n\t\tthis.host = host;\n\t\tthis.moduleDef = moduleDef;\n\t\tthis.config = config;\n\t\thost.addController(this);\n\t}\n\n\thostConnected(): void {\n\t\tconst allPlugins = [...(this.config?.plugins ?? [])];\n\n\t\tif (this.config?.status) {\n\t\t\tconst sp = createRequirementStatusPlugin();\n\t\t\tthis.statusPlugin = sp;\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: Plugin generic issues\n\t\t\tallPlugins.push(sp.plugin as Plugin<any>);\n\t\t}\n\n\t\t// biome-ignore lint/suspicious/noExplicitAny: Required for overload compatibility\n\t\tconst system = createSystem({\n\t\t\tmodule: this.moduleDef,\n\t\t\tplugins: allPlugins.length > 0 ? allPlugins : undefined,\n\t\t\tdebug: this.config?.debug,\n\t\t\terrorBoundary: this.config?.errorBoundary,\n\t\t\ttickMs: this.config?.tickMs,\n\t\t\tzeroConfig: this.config?.zeroConfig,\n\t\t\tinitialFacts: this.config?.initialFacts,\n\t\t} as any) as unknown as SingleModuleSystem<M>;\n\n\t\tthis._system = system;\n\t\tsystem.start();\n\n\t\t// Subscribe to all facts\n\t\tthis.facts = system.facts.$store.toObject() as InferFacts<M>;\n\t\tthis.unsubFacts = system.facts.$store.subscribeAll(() => {\n\t\t\tthis.facts = system.facts.$store.toObject() as InferFacts<M>;\n\t\t\tthis.host.requestUpdate();\n\t\t});\n\n\t\t// Subscribe to all derivations\n\t\tconst derivationKeys = Object.keys(system.derive ?? {});\n\t\tconst getDerived = (): InferDerivations<M> => {\n\t\t\tconst result: Record<string, unknown> = {};\n\t\t\tfor (const key of derivationKeys) {\n\t\t\t\tresult[key] = system.read(key);\n\t\t\t}\n\t\t\treturn result as InferDerivations<M>;\n\t\t};\n\t\tthis.derived = getDerived();\n\n\t\tif (derivationKeys.length > 0) {\n\t\t\tthis.unsubDerived = system.subscribe(derivationKeys, () => {\n\t\t\t\tthis.derived = getDerived();\n\t\t\t\tthis.host.requestUpdate();\n\t\t\t});\n\t\t}\n\t}\n\n\thostDisconnected(): void {\n\t\tthis.unsubFacts?.();\n\t\tthis.unsubDerived?.();\n\t\tthis._system?.destroy();\n\t\tthis._system = null;\n\t}\n\n\tdispatch(event: InferEvents<M>): void {\n\t\tthis.system.dispatch(event);\n\t}\n}\n\n// ============================================================================\n// Factory Functions (active)\n// ============================================================================\n\nexport function createDerived<T>(\n\thost: ReactiveControllerHost,\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\tkey: string | string[],\n): DerivedController<T> {\n\treturn new DerivedController<T>(host, system, key);\n}\n\nexport function createFact<T>(\n\thost: ReactiveControllerHost,\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\tfactKey: string,\n): FactController<T> {\n\treturn new FactController<T>(host, system, factKey);\n}\n\n/**\n * Create an inspect controller.\n * Returns InspectState; pass `{ throttleMs }` for throttled updates.\n */\nexport function createInspect(\n\thost: ReactiveControllerHost,\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\toptions?: { throttleMs?: number },\n): InspectController {\n\treturn new InspectController(host, system, options);\n}\n\nexport function createRequirementStatus(\n\thost: ReactiveControllerHost,\n\tstatusPlugin: StatusPlugin,\n\ttype: string,\n): RequirementStatusController {\n\treturn new RequirementStatusController(host, statusPlugin, type);\n}\n\nexport function createWatch<T>(\n\thost: ReactiveControllerHost,\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\tderivationId: string,\n\tcallback: (newValue: T, previousValue: T | undefined) => void,\n): WatchController<T> {\n\treturn new WatchController<T>(host, system, derivationId, callback);\n}\n\nexport function createDirectiveSelector<R>(\n\thost: ReactiveControllerHost,\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\tselector: (state: Record<string, unknown>) => R,\n\tequalityFn: (a: R, b: R) => boolean = defaultEquality,\n\toptions?: { autoTrack?: boolean },\n): DirectiveSelectorController<R> {\n\treturn new DirectiveSelectorController<R>(host, system, selector, equalityFn, options);\n}\n\nexport function createExplain(\n\thost: ReactiveControllerHost,\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\trequirementId: string,\n): ExplainController {\n\treturn new ExplainController(host, system, requirementId);\n}\n\nexport function createConstraintStatus(\n\thost: ReactiveControllerHost,\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\tconstraintId?: string,\n): ConstraintStatusController {\n\treturn new ConstraintStatusController(host, system, constraintId);\n}\n\nexport function createOptimisticUpdate(\n\thost: ReactiveControllerHost,\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\tstatusPlugin?: StatusPlugin,\n\trequirementType?: string,\n): OptimisticUpdateController {\n\treturn new OptimisticUpdateController(host, system, statusPlugin, requirementType);\n}\n\nexport function createModule<M extends ModuleSchema>(\n\thost: ReactiveControllerHost,\n\tmoduleDef: ModuleDef<M>,\n\tconfig?: {\n\t\t// biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n\t\tplugins?: Plugin<any>[];\n\t\tdebug?: DebugConfig;\n\t\terrorBoundary?: ErrorBoundaryConfig;\n\t\ttickMs?: number;\n\t\tzeroConfig?: boolean;\n\t\t// biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n\t\tinitialFacts?: Record<string, any>;\n\t\tstatus?: boolean;\n\t},\n): ModuleController<M> {\n\treturn new ModuleController<M>(host, moduleDef, config);\n}\n\n// ============================================================================\n// Functional Helpers\n// ============================================================================\n\nexport function useDispatch<M extends ModuleSchema = ModuleSchema>(\n\tsystem: SingleModuleSystem<M>,\n): (event: InferEvents<M>) => void {\n\tassertSystem(\"useDispatch\", system);\n\treturn (event: InferEvents<M>) => {\n\t\tsystem.dispatch(event);\n\t};\n}\n\n/**\n * Returns the system's events dispatcher.\n */\nexport function useEvents<M extends ModuleSchema = ModuleSchema>(\n\tsystem: SingleModuleSystem<M>,\n): SingleModuleSystem<M>[\"events\"] {\n\tassertSystem(\"useEvents\", system);\n\treturn system.events;\n}\n\n/**\n * Reactive controller for time-travel state.\n * Triggers host updates when snapshots change or navigation occurs.\n *\n * @example\n * ```typescript\n * class MyElement extends LitElement {\n * private tt = new TimeTravelController(this, system);\n * render() {\n * const { canUndo, undo } = this.tt.value ?? {};\n * return html`<button ?disabled=${!canUndo} @click=${undo}>Undo</button>`;\n * }\n * }\n * ```\n */\nexport class TimeTravelController implements ReactiveController {\n\tvalue: TimeTravelState | null = null;\n\tprivate _unsub?: () => void;\n\n\tconstructor(\n\t\tprivate _host: ReactiveControllerHost,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\t\tprivate _system: SingleModuleSystem<any>,\n\t) {\n\t\tthis._host.addController(this);\n\t}\n\n\thostConnected(): void {\n\t\tthis.value = buildTimeTravelState(this._system);\n\t\tthis._unsub = this._system.onTimeTravelChange(() => {\n\t\t\tthis.value = buildTimeTravelState(this._system);\n\t\t\tthis._host.requestUpdate();\n\t\t});\n\t}\n\n\thostDisconnected(): void {\n\t\tthis._unsub?.();\n\t\tthis._unsub = undefined;\n\t}\n}\n\n/**\n * Functional helper for time-travel state (non-reactive, snapshot).\n * For reactive updates, use TimeTravelController.\n */\n// biome-ignore lint/suspicious/noExplicitAny: System type varies\nexport function useTimeTravel(system: SingleModuleSystem<any>): TimeTravelState | null {\n\tassertSystem(\"useTimeTravel\", system);\n\treturn buildTimeTravelState(system);\n}\n\nexport function getDerived<T>(\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\tderivationId: string,\n): () => T {\n\treturn () => system.read(derivationId) as T;\n}\n\nexport function getFact<T>(\n\t// biome-ignore lint/suspicious/noExplicitAny: System type varies\n\tsystem: SingleModuleSystem<any>,\n\tfactKey: string,\n): () => T | undefined {\n\treturn () => system.facts.$store.get(factKey) as T | undefined;\n}\n\n// ============================================================================\n// Typed Hooks Factory\n// ============================================================================\n\nexport function createTypedHooks<M extends ModuleSchema>(): {\n\tcreateDerived: <K extends keyof InferDerivations<M>>(\n\t\thost: ReactiveControllerHost,\n\t\tsystem: SingleModuleSystem<M>,\n\t\tderivationId: K,\n\t) => DerivedController<InferDerivations<M>[K]>;\n\tcreateFact: <K extends keyof InferFacts<M>>(\n\t\thost: ReactiveControllerHost,\n\t\tsystem: SingleModuleSystem<M>,\n\t\tfactKey: K,\n\t) => FactController<InferFacts<M>[K]>;\n\tuseDispatch: (system: SingleModuleSystem<M>) => (event: InferEvents<M>) => void;\n\tuseEvents: (system: SingleModuleSystem<M>) => SingleModuleSystem<M>[\"events\"];\n\tcreateWatch: <K extends string>(\n\t\thost: ReactiveControllerHost,\n\t\tsystem: SingleModuleSystem<M>,\n\t\tkey: K,\n\t\tcallback: (newValue: unknown, previousValue: unknown) => void,\n\t) => WatchController<unknown>;\n} {\n\treturn {\n\t\tcreateDerived: <K extends keyof InferDerivations<M>>(\n\t\t\thost: ReactiveControllerHost,\n\t\t\tsystem: SingleModuleSystem<M>,\n\t\t\tderivationId: K,\n\t\t) => createDerived<InferDerivations<M>[K]>(host, system, derivationId as string),\n\t\tcreateFact: <K extends keyof InferFacts<M>>(\n\t\t\thost: ReactiveControllerHost,\n\t\t\tsystem: SingleModuleSystem<M>,\n\t\t\tfactKey: K,\n\t\t) => createFact<InferFacts<M>[K]>(host, system, factKey as string),\n\t\tuseDispatch: (system: SingleModuleSystem<M>) => {\n\t\t\treturn (event: InferEvents<M>) => {\n\t\t\t\tsystem.dispatch(event);\n\t\t\t};\n\t\t},\n\t\tuseEvents: (system: SingleModuleSystem<M>) => system.events,\n\t\tcreateWatch: <K extends string>(\n\t\t\thost: ReactiveControllerHost,\n\t\t\tsystem: SingleModuleSystem<M>,\n\t\t\tkey: K,\n\t\t\tcallback: (newValue: unknown, previousValue: unknown) => void,\n\t\t) => createWatch<unknown>(host, system, key, callback),\n\t};\n}\n\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["directiveContext","DirectiveController","host","system","DerivedController","key","result","id","FactController","factKey","InspectController","options","computeInspectState","update","throttled","cleanup","createThrottle","RequirementStatusController","statusPlugin","type","DirectiveSelectorController","selector","equalityFn","defaultEquality","initial","runTrackedSelector","unsub","onUpdate","depsChanged","WatchController","callback","ExplainController","requirementId","ConstraintStatusController","constraintId","inspection","c","OptimisticUpdateController","requirementType","updateFn","status","SystemController","createSystem","ModuleController","moduleDef","config","allPlugins","sp","createRequirementStatusPlugin","derivationKeys","getDerived","event","createDerived","createFact","createInspect","createRequirementStatus","createWatch","derivationId","createDirectiveSelector","createExplain","createConstraintStatus","createOptimisticUpdate","createModule","useDispatch","assertSystem","useEvents","TimeTravelController","_host","_system","buildTimeTravelState","useTimeTravel","getFact","createTypedHooks","NamespacedSelectorController","keys","createNamespacedSelector"],"mappings":"6SAkEO,IAAMA,CAAAA,CAAmB,MAAA,CAAO,WAAW,CAAA,CASnCC,CAAAA,CAAf,KAAiE,CACrD,IAAA,CAEA,MAAA,CACA,WAAA,CAGV,WAAA,CAAYC,CAAAA,CAA8BC,CAAAA,CAAiC,CACzE,IAAA,CAAK,IAAA,CAAOD,CAAAA,CACZ,IAAA,CAAK,MAAA,CAASC,CAAAA,CACdD,CAAAA,CAAK,aAAA,CAAc,IAAI,EACzB,CAEA,aAAA,EAAsB,CACpB,IAAA,CAAK,SAAA,GACP,CAEA,gB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AAA,EAAsB,CACpB,IAAA,CAAK,KAAA,CAAQ,KAAK,QAAA,CAAS,IAAA,CAAK,MAAM,CAAA,CACtC,IAAA,CAAK,YAAc,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU,IAAA,CAAK,KAAM,IAAM,CACxD,KAAK,KAAA,CAAQ,IAAA,CAAK,SAAS,IAAA,CAAK,MAAM,CAAA,CACtC,IAAA,CAAK,KAAK,aAAA,GACZ,CAAC,EACH,CAEA,kBAAyB,CACvB,IAAA,CAAK,WAAA,IAAc,CACnB,KAAK,WAAA,CAAc,OACrB,CACF,EAEO,SAASyE,EACdzE,CAAAA,CACAC,CAAAA,CACAuE,EACArD,CAAAA,CAC0C,CAC1C,OAAO,IAAIoD,CAAAA,CAA6BvE,EAAMC,CAAAA,CAAQuE,CAAAA,CAAMrD,CAAQ,CACtE","file":"index.js","sourcesContent":["/**\n * Lit Adapter - Consolidated Web Components integration for Directive\n *\n * Controllers: DerivedController, FactController,\n * InspectController (with throttle), RequirementStatusController,\n * DirectiveSelectorController,\n * WatchController (with fact mode), SystemController,\n * ExplainController, ConstraintStatusController, OptimisticUpdateController, ModuleController\n *\n * Factories: createDerived, createFact, createInspect,\n * createRequirementStatus, createWatch,\n * createDirectiveSelector, useDispatch, useEvents, useTimeTravel,\n * getDerived, getFact, createTypedHooks, shallowEqual\n */\n\nimport type {\n CreateSystemOptionsSingle,\n DebugConfig,\n ErrorBoundaryConfig,\n InferDerivations,\n InferEvents,\n InferFacts,\n ModuleDef,\n ModuleSchema,\n ModulesMap,\n NamespacedSystem,\n Plugin,\n SingleModuleSystem,\n SystemSnapshot,\n TimeTravelState,\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 type TrackedSelectorResult,\n assertSystem,\n buildTimeTravelState,\n computeInspectState,\n createThrottle,\n defaultEquality,\n depsChanged,\n runTrackedSelector,\n shallowEqual,\n} from \"@directive-run/core/adapter-utils\";\nimport type { ReactiveController, ReactiveControllerHost } from \"lit\";\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// Context\n// ============================================================================\n\n/**\n * Context key for Directive system.\n * Use with @lit/context for dependency injection across shadow DOM boundaries.\n */\nexport const directiveContext = Symbol(\"directive\");\n\n// ============================================================================\n// Base Controller\n// ============================================================================\n\n/**\n * Base controller that manages system subscription lifecycle.\n */\nabstract class DirectiveController implements ReactiveController {\n protected host: ReactiveControllerHost;\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n protected system: SingleModuleSystem<any>;\n protected unsubscribe?: () => void;\n\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n constructor(host: ReactiveControllerHost, system: SingleModuleSystem<any>) {\n this.host = host;\n this.system = system;\n host.addController(this);\n }\n\n hostConnected(): void {\n this.subscribe();\n }\n\n hostDisconnected(): void {\n this.unsubscribe?.();\n this.unsubscribe = undefined;\n }\n\n protected abstract subscribe(): void;\n\n protected requestUpdate(): void {\n this.host.requestUpdate();\n }\n}\n\n// ============================================================================\n// Core Controllers\n// ============================================================================\n\n/**\n * Reactive controller for derivations.\n * Accepts a single key (string) or an array of keys (string[]).\n * - Single key: `.value` returns `T`\n * - Array of keys: `.value` returns `Record<string, unknown>`\n */\nexport class DerivedController<T> extends DirectiveController {\n private keys: string[];\n private isMulti: boolean;\n value: T;\n\n constructor(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n key: string | string[],\n ) {\n super(host, system);\n this.isMulti = Array.isArray(key);\n this.keys = this.isMulti ? (key as string[]) : [key as string];\n this.value = this.getValues();\n\n if (process.env.NODE_ENV !== \"production\") {\n if (!this.isMulti && this.value === undefined) {\n console.warn(\n `[Directive] DerivedController(\"${this.keys[0]}\") returned undefined. ` +\n `Check that \"${this.keys[0]}\" is defined in your module's derive property.`,\n );\n }\n }\n }\n\n private getValues(): T {\n if (this.isMulti) {\n const result: Record<string, unknown> = {};\n for (const id of this.keys) {\n result[id] = this.system.read(id);\n }\n return result as T;\n }\n return this.system.read(this.keys[0]!) as T;\n }\n\n protected subscribe(): void {\n this.value = this.getValues();\n this.unsubscribe = this.system.subscribe(this.keys, () => {\n this.value = this.getValues();\n this.requestUpdate();\n });\n }\n}\n\n/**\n * Reactive controller for a single fact value.\n */\nexport class FactController<T> extends DirectiveController {\n private factKey: string;\n value: T | undefined;\n\n constructor(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n factKey: string,\n ) {\n super(host, system);\n this.factKey = factKey;\n this.value = system.facts.$store.get(factKey) as T | undefined;\n\n if (process.env.NODE_ENV !== \"production\") {\n if (!system.facts.$store.has(factKey)) {\n console.warn(\n `[Directive] FactController(\"${factKey}\") — fact not found in store. ` +\n `Check that \"${factKey}\" is defined in your module's schema.`,\n );\n }\n }\n }\n\n protected subscribe(): void {\n this.value = this.system.facts.$store.get(this.factKey) as T | undefined;\n this.unsubscribe = this.system.facts.$store.subscribe(\n [this.factKey],\n () => {\n this.value = this.system.facts.$store.get(this.factKey) as\n | T\n | undefined;\n this.requestUpdate();\n },\n );\n }\n}\n\n/**\n * Consolidated inspection controller.\n * Returns InspectState with optional throttling.\n */\nexport class InspectController extends DirectiveController {\n value: InspectState;\n private throttleMs: number;\n private throttleCleanup?: () => void;\n private unsubSettled?: () => void;\n\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n constructor(\n host: ReactiveControllerHost,\n system: SingleModuleSystem<any>,\n options?: { throttleMs?: number },\n ) {\n super(host, system);\n this.throttleMs = options?.throttleMs ?? 0;\n this.value = computeInspectState(system);\n }\n\n protected subscribe(): void {\n this.value = computeInspectState(this.system);\n\n const update = () => {\n this.value = computeInspectState(this.system);\n this.requestUpdate();\n };\n\n if (this.throttleMs > 0) {\n const { throttled, cleanup } = createThrottle(update, this.throttleMs);\n this.throttleCleanup = cleanup;\n this.unsubscribe = this.system.facts.$store.subscribeAll(throttled);\n this.unsubSettled = this.system.onSettledChange(throttled);\n } else {\n this.unsubscribe = this.system.facts.$store.subscribeAll(update);\n this.unsubSettled = this.system.onSettledChange(update);\n }\n }\n\n hostDisconnected(): void {\n this.throttleCleanup?.();\n this.unsubSettled?.();\n super.hostDisconnected();\n }\n}\n\n/**\n * Reactive controller for requirement status.\n */\nexport class RequirementStatusController implements ReactiveController {\n private host: ReactiveControllerHost;\n private statusPlugin: StatusPlugin;\n private type: string;\n private unsubscribe?: () => void;\n value: RequirementTypeStatus;\n\n constructor(\n host: ReactiveControllerHost,\n statusPlugin: StatusPlugin,\n type: string,\n ) {\n this.host = host;\n this.statusPlugin = statusPlugin;\n this.type = type;\n this.value = statusPlugin.getStatus(type);\n host.addController(this);\n }\n\n hostConnected(): void {\n this.value = this.statusPlugin.getStatus(this.type);\n this.unsubscribe = this.statusPlugin.subscribe(() => {\n this.value = this.statusPlugin.getStatus(this.type);\n this.host.requestUpdate();\n });\n }\n\n hostDisconnected(): void {\n this.unsubscribe?.();\n this.unsubscribe = undefined;\n }\n}\n\n// ============================================================================\n// Selector Controllers\n// ============================================================================\n\n/**\n * Reactive controller for selecting across all facts.\n * Uses `withTracking()` for auto-tracking when constructed with `autoTrack: true`.\n */\nexport class DirectiveSelectorController<R> extends DirectiveController {\n private selector: (state: Record<string, unknown>) => R;\n private equalityFn: (a: R, b: R) => boolean;\n private autoTrack: boolean;\n private deriveKeySet: Set<string>;\n private trackedFactKeys: string[] = [];\n private trackedDeriveKeys: string[] = [];\n private unsubs: Array<() => void> = [];\n value: R;\n\n constructor(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n selector: (state: Record<string, unknown>) => R,\n equalityFn: (a: R, b: R) => boolean = defaultEquality,\n options?: { autoTrack?: boolean },\n ) {\n super(host, system);\n this.selector = selector;\n this.equalityFn = equalityFn;\n this.autoTrack = options?.autoTrack ?? true;\n this.deriveKeySet = new Set(Object.keys(system.derive ?? {}));\n\n const initial = this.runWithTracking();\n this.value = initial.value;\n this.trackedFactKeys = initial.factKeys;\n this.trackedDeriveKeys = initial.deriveKeys;\n }\n\n private runWithTracking(): TrackedSelectorResult<R> {\n return runTrackedSelector(this.system, this.deriveKeySet, this.selector);\n }\n\n private resubscribe(): void {\n for (const unsub of this.unsubs) unsub();\n this.unsubs = [];\n\n const onUpdate = () => {\n const result = this.runWithTracking();\n if (!this.equalityFn(this.value, result.value)) {\n this.value = result.value;\n this.requestUpdate();\n }\n if (this.autoTrack) {\n // Re-track: check if deps changed\n if (\n depsChanged(\n this.trackedFactKeys,\n result.factKeys,\n this.trackedDeriveKeys,\n result.deriveKeys,\n )\n ) {\n this.trackedFactKeys = result.factKeys;\n this.trackedDeriveKeys = result.deriveKeys;\n this.resubscribe();\n }\n }\n };\n\n if (this.autoTrack) {\n if (this.trackedFactKeys.length > 0) {\n this.unsubs.push(\n this.system.facts.$store.subscribe(this.trackedFactKeys, onUpdate),\n );\n } else if (this.trackedDeriveKeys.length === 0) {\n this.unsubs.push(this.system.facts.$store.subscribeAll(onUpdate));\n }\n if (this.trackedDeriveKeys.length > 0) {\n this.unsubs.push(\n this.system.subscribe(this.trackedDeriveKeys, onUpdate),\n );\n }\n } else {\n this.unsubs.push(this.system.facts.$store.subscribeAll(onUpdate));\n }\n }\n\n protected subscribe(): void {\n const result = this.runWithTracking();\n this.value = result.value;\n this.trackedFactKeys = result.factKeys;\n this.trackedDeriveKeys = result.deriveKeys;\n this.resubscribe();\n }\n\n hostDisconnected(): void {\n for (const unsub of this.unsubs) unsub();\n this.unsubs = [];\n super.hostDisconnected();\n }\n}\n\n/**\n * Reactive controller that watches a fact or derivation and calls a callback on change.\n * The key is auto-detected — works with both fact keys and derivation keys.\n */\nexport class WatchController<T> extends DirectiveController {\n private key: string;\n private callback: (newValue: T, previousValue: T | undefined) => void;\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. */\n constructor(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n key: string,\n callback: (newValue: T, previousValue: T | undefined) => void,\n ) {\n super(host, system);\n this.key = key;\n this.callback = callback;\n }\n\n protected subscribe(): void {\n this.unsubscribe = this.system.watch<T>(this.key, this.callback);\n }\n}\n\n// ============================================================================\n// New Controllers\n// ============================================================================\n\n/**\n * Reactive controller for requirement explanations.\n */\nexport class ExplainController extends DirectiveController {\n private requirementId: string;\n value: string | null;\n private unsubSettled?: () => void;\n\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n constructor(\n host: ReactiveControllerHost,\n system: SingleModuleSystem<any>,\n requirementId: string,\n ) {\n super(host, system);\n this.requirementId = requirementId;\n this.value = system.explain(requirementId);\n }\n\n protected subscribe(): void {\n this.value = this.system.explain(this.requirementId);\n\n const update = () => {\n this.value = this.system.explain(this.requirementId);\n this.requestUpdate();\n };\n\n this.unsubscribe = this.system.facts.$store.subscribeAll(update);\n this.unsubSettled = this.system.onSettledChange(update);\n }\n\n hostDisconnected(): void {\n this.unsubSettled?.();\n super.hostDisconnected();\n }\n}\n\n/**\n * Reactive controller for constraint status.\n */\nexport class ConstraintStatusController extends DirectiveController {\n private constraintId?: string;\n value: ConstraintInfo[] | ConstraintInfo | null;\n private unsubSettled?: () => void;\n\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n constructor(\n host: ReactiveControllerHost,\n system: SingleModuleSystem<any>,\n constraintId?: string,\n ) {\n super(host, system);\n this.constraintId = constraintId;\n this.value = this.getVal();\n }\n\n private getVal(): ConstraintInfo[] | ConstraintInfo | null {\n const inspection = this.system.inspect();\n if (!this.constraintId) return inspection.constraints;\n return (\n inspection.constraints.find(\n (c: ConstraintInfo) => c.id === this.constraintId,\n ) ?? null\n );\n }\n\n protected subscribe(): void {\n this.value = this.getVal();\n\n const update = () => {\n this.value = this.getVal();\n this.requestUpdate();\n };\n\n this.unsubscribe = this.system.facts.$store.subscribeAll(update);\n this.unsubSettled = this.system.onSettledChange(update);\n }\n\n hostDisconnected(): void {\n this.unsubSettled?.();\n super.hostDisconnected();\n }\n}\n\n/**\n * Reactive controller for optimistic updates.\n */\nexport class OptimisticUpdateController implements ReactiveController {\n private host: ReactiveControllerHost;\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n private system: SingleModuleSystem<any>;\n private statusPlugin?: StatusPlugin;\n private requirementType?: string;\n private snapshot: SystemSnapshot | null = null;\n private statusUnsub: (() => void) | null = null;\n\n isPending = false;\n error: Error | null = null;\n\n constructor(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n statusPlugin?: StatusPlugin,\n requirementType?: string,\n ) {\n this.host = host;\n this.system = system;\n this.statusPlugin = statusPlugin;\n this.requirementType = requirementType;\n host.addController(this);\n }\n\n hostConnected(): void {}\n\n hostDisconnected(): void {\n this.statusUnsub?.();\n this.statusUnsub = null;\n }\n\n rollback(): void {\n if (this.snapshot) {\n this.system.restore(this.snapshot);\n this.snapshot = null;\n }\n this.isPending = false;\n this.error = null;\n this.statusUnsub?.();\n this.statusUnsub = null;\n this.host.requestUpdate();\n }\n\n mutate(updateFn: () => void): void {\n this.snapshot = this.system.getSnapshot();\n this.isPending = true;\n this.error = null;\n this.system.batch(updateFn);\n this.host.requestUpdate();\n\n if (this.statusPlugin && this.requirementType) {\n this.statusUnsub?.();\n this.statusUnsub = this.statusPlugin.subscribe(() => {\n const status = this.statusPlugin!.getStatus(this.requirementType!);\n if (!status.isLoading && !status.hasError) {\n this.snapshot = null;\n this.isPending = false;\n this.statusUnsub?.();\n this.statusUnsub = null;\n this.host.requestUpdate();\n } else if (status.hasError) {\n this.error = status.lastError;\n this.rollback();\n }\n });\n }\n }\n}\n\n/**\n * Reactive controller that creates and manages a Directive system.\n * The system is automatically started when the host connects and destroyed when it disconnects.\n */\nexport class SystemController<M extends ModuleSchema>\n implements ReactiveController\n{\n private options: ModuleDef<M> | CreateSystemOptionsSingle<M>;\n private _system: SingleModuleSystem<M> | null = null;\n\n constructor(\n host: ReactiveControllerHost,\n options: ModuleDef<M> | CreateSystemOptionsSingle<M>,\n ) {\n this.options = options;\n host.addController(this);\n }\n\n get system(): SingleModuleSystem<M> {\n if (!this._system) {\n throw new Error(\n \"[Directive] SystemController.system is not available. \" +\n \"This can happen if:\\n\" +\n \" 1. Accessed before hostConnected (e.g., in a class field initializer)\\n\" +\n \" 2. Accessed after hostDisconnected (system was destroyed)\\n\" +\n \"Solution: Access system only in lifecycle methods (connectedCallback, render) \" +\n \"or after the element is connected to the DOM.\",\n );\n }\n return this._system;\n }\n\n hostConnected(): void {\n const isModule = \"id\" in this.options && \"schema\" in this.options;\n const system = isModule\n ? createSystem({ module: this.options as ModuleDef<M> })\n : createSystem(this.options as CreateSystemOptionsSingle<M>);\n this._system = system as unknown as SingleModuleSystem<M>;\n this._system.start();\n }\n\n hostDisconnected(): void {\n this._system?.destroy();\n this._system = null;\n }\n}\n\n/**\n * Module controller — zero-config all-in-one.\n * Creates system, starts it, subscribes to all facts/derivations.\n */\nexport class ModuleController<M extends ModuleSchema>\n implements ReactiveController\n{\n private host: ReactiveControllerHost;\n private moduleDef: ModuleDef<M>;\n private config?: {\n // biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n plugins?: Plugin<any>[];\n debug?: DebugConfig;\n errorBoundary?: ErrorBoundaryConfig;\n tickMs?: number;\n zeroConfig?: boolean;\n // biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n initialFacts?: Record<string, any>;\n status?: boolean;\n };\n\n private _system: SingleModuleSystem<M> | null = null;\n private unsubFacts?: () => void;\n private unsubDerived?: () => void;\n\n facts: InferFacts<M> = {} as InferFacts<M>;\n derived: InferDerivations<M> = {} as InferDerivations<M>;\n statusPlugin?: StatusPlugin;\n\n get system(): SingleModuleSystem<M> {\n if (!this._system) {\n throw new Error(\n \"[Directive] ModuleController.system is not available before hostConnected.\",\n );\n }\n return this._system;\n }\n\n get events(): SingleModuleSystem<M>[\"events\"] {\n return this.system.events;\n }\n\n constructor(\n host: ReactiveControllerHost,\n moduleDef: ModuleDef<M>,\n config?: {\n // biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n plugins?: Plugin<any>[];\n debug?: DebugConfig;\n errorBoundary?: ErrorBoundaryConfig;\n tickMs?: number;\n zeroConfig?: boolean;\n // biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n initialFacts?: Record<string, any>;\n status?: boolean;\n },\n ) {\n this.host = host;\n this.moduleDef = moduleDef;\n this.config = config;\n host.addController(this);\n }\n\n hostConnected(): void {\n const allPlugins = [...(this.config?.plugins ?? [])];\n\n if (this.config?.status) {\n const sp = createRequirementStatusPlugin();\n this.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: this.moduleDef,\n plugins: allPlugins.length > 0 ? allPlugins : undefined,\n debug: this.config?.debug,\n errorBoundary: this.config?.errorBoundary,\n tickMs: this.config?.tickMs,\n zeroConfig: this.config?.zeroConfig,\n initialFacts: this.config?.initialFacts,\n } as any) as unknown as SingleModuleSystem<M>;\n\n this._system = system;\n system.start();\n\n // Subscribe to all facts\n this.facts = system.facts.$store.toObject() as InferFacts<M>;\n this.unsubFacts = system.facts.$store.subscribeAll(() => {\n this.facts = system.facts.$store.toObject() as InferFacts<M>;\n this.host.requestUpdate();\n });\n\n // Subscribe to all derivations\n const derivationKeys = Object.keys(system.derive ?? {});\n const getDerived = (): InferDerivations<M> => {\n const result: Record<string, unknown> = {};\n for (const key of derivationKeys) {\n result[key] = system.read(key);\n }\n return result as InferDerivations<M>;\n };\n this.derived = getDerived();\n\n if (derivationKeys.length > 0) {\n this.unsubDerived = system.subscribe(derivationKeys, () => {\n this.derived = getDerived();\n this.host.requestUpdate();\n });\n }\n }\n\n hostDisconnected(): void {\n this.unsubFacts?.();\n this.unsubDerived?.();\n this._system?.destroy();\n this._system = null;\n }\n\n dispatch(event: InferEvents<M>): void {\n this.system.dispatch(event);\n }\n}\n\n// ============================================================================\n// Factory Functions (active)\n// ============================================================================\n\nexport function createDerived<T>(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n key: string | string[],\n): DerivedController<T> {\n return new DerivedController<T>(host, system, key);\n}\n\nexport function createFact<T>(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n factKey: string,\n): FactController<T> {\n return new FactController<T>(host, system, factKey);\n}\n\n/**\n * Create an inspect controller.\n * Returns InspectState; pass `{ throttleMs }` for throttled updates.\n */\nexport function createInspect(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n options?: { throttleMs?: number },\n): InspectController {\n return new InspectController(host, system, options);\n}\n\nexport function createRequirementStatus(\n host: ReactiveControllerHost,\n statusPlugin: StatusPlugin,\n type: string,\n): RequirementStatusController {\n return new RequirementStatusController(host, statusPlugin, type);\n}\n\nexport function createWatch<T>(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n derivationId: string,\n callback: (newValue: T, previousValue: T | undefined) => void,\n): WatchController<T> {\n return new WatchController<T>(host, system, derivationId, callback);\n}\n\nexport function createDirectiveSelector<R>(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n selector: (state: Record<string, unknown>) => R,\n equalityFn: (a: R, b: R) => boolean = defaultEquality,\n options?: { autoTrack?: boolean },\n): DirectiveSelectorController<R> {\n return new DirectiveSelectorController<R>(\n host,\n system,\n selector,\n equalityFn,\n options,\n );\n}\n\nexport function createExplain(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n requirementId: string,\n): ExplainController {\n return new ExplainController(host, system, requirementId);\n}\n\nexport function createConstraintStatus(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n constraintId?: string,\n): ConstraintStatusController {\n return new ConstraintStatusController(host, system, constraintId);\n}\n\nexport function createOptimisticUpdate(\n host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n statusPlugin?: StatusPlugin,\n requirementType?: string,\n): OptimisticUpdateController {\n return new OptimisticUpdateController(\n host,\n system,\n statusPlugin,\n requirementType,\n );\n}\n\nexport function createModule<M extends ModuleSchema>(\n host: ReactiveControllerHost,\n moduleDef: ModuleDef<M>,\n config?: {\n // biome-ignore lint/suspicious/noExplicitAny: Plugin types vary\n plugins?: Plugin<any>[];\n debug?: DebugConfig;\n errorBoundary?: ErrorBoundaryConfig;\n tickMs?: number;\n zeroConfig?: boolean;\n // biome-ignore lint/suspicious/noExplicitAny: Facts type varies\n initialFacts?: Record<string, any>;\n status?: boolean;\n },\n): ModuleController<M> {\n return new ModuleController<M>(host, moduleDef, config);\n}\n\n// ============================================================================\n// Functional Helpers\n// ============================================================================\n\nexport function useDispatch<M extends ModuleSchema = ModuleSchema>(\n system: SingleModuleSystem<M>,\n): (event: InferEvents<M>) => void {\n assertSystem(\"useDispatch\", system);\n return (event: InferEvents<M>) => {\n system.dispatch(event);\n };\n}\n\n/**\n * Returns the system's events dispatcher.\n */\nexport function useEvents<M extends ModuleSchema = ModuleSchema>(\n system: SingleModuleSystem<M>,\n): SingleModuleSystem<M>[\"events\"] {\n assertSystem(\"useEvents\", system);\n return system.events;\n}\n\n/**\n * Reactive controller for time-travel state.\n * Triggers host updates when snapshots change or navigation occurs.\n *\n * @example\n * ```typescript\n * class MyElement extends LitElement {\n * private tt = new TimeTravelController(this, system);\n * render() {\n * const { canUndo, undo } = this.tt.value ?? {};\n * return html`<button ?disabled=${!canUndo} @click=${undo}>Undo</button>`;\n * }\n * }\n * ```\n */\nexport class TimeTravelController implements ReactiveController {\n value: TimeTravelState | null = null;\n private _unsub?: () => void;\n\n constructor(\n private _host: ReactiveControllerHost,\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n private _system: SingleModuleSystem<any>,\n ) {\n this._host.addController(this);\n }\n\n hostConnected(): void {\n this.value = buildTimeTravelState(this._system);\n this._unsub = this._system.onTimeTravelChange(() => {\n this.value = buildTimeTravelState(this._system);\n this._host.requestUpdate();\n });\n }\n\n hostDisconnected(): void {\n this._unsub?.();\n this._unsub = undefined;\n }\n}\n\n/**\n * Functional helper for time-travel state (non-reactive, snapshot).\n * For reactive updates, use TimeTravelController.\n */\n// biome-ignore lint/suspicious/noExplicitAny: System type varies\nexport function useTimeTravel(\n system: SingleModuleSystem<any>,\n): TimeTravelState | null {\n assertSystem(\"useTimeTravel\", system);\n return buildTimeTravelState(system);\n}\n\nexport function getDerived<T>(\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n derivationId: string,\n): () => T {\n return () => system.read(derivationId) as T;\n}\n\nexport function getFact<T>(\n // biome-ignore lint/suspicious/noExplicitAny: System type varies\n system: SingleModuleSystem<any>,\n factKey: string,\n): () => T | undefined {\n return () => system.facts.$store.get(factKey) as T | undefined;\n}\n\n// ============================================================================\n// Typed Hooks Factory\n// ============================================================================\n\nexport function createTypedHooks<M extends ModuleSchema>(): {\n createDerived: <K extends keyof InferDerivations<M>>(\n host: ReactiveControllerHost,\n system: SingleModuleSystem<M>,\n derivationId: K,\n ) => DerivedController<InferDerivations<M>[K]>;\n createFact: <K extends keyof InferFacts<M>>(\n host: ReactiveControllerHost,\n system: SingleModuleSystem<M>,\n factKey: K,\n ) => FactController<InferFacts<M>[K]>;\n useDispatch: (\n system: SingleModuleSystem<M>,\n ) => (event: InferEvents<M>) => void;\n useEvents: (system: SingleModuleSystem<M>) => SingleModuleSystem<M>[\"events\"];\n createWatch: <K extends string>(\n host: ReactiveControllerHost,\n system: SingleModuleSystem<M>,\n key: K,\n callback: (newValue: unknown, previousValue: unknown) => void,\n ) => WatchController<unknown>;\n} {\n return {\n createDerived: <K extends keyof InferDerivations<M>>(\n host: ReactiveControllerHost,\n system: SingleModuleSystem<M>,\n derivationId: K,\n ) =>\n createDerived<InferDerivations<M>[K]>(\n host,\n system,\n derivationId as string,\n ),\n createFact: <K extends keyof InferFacts<M>>(\n host: ReactiveControllerHost,\n system: SingleModuleSystem<M>,\n factKey: K,\n ) => createFact<InferFacts<M>[K]>(host, system, factKey as string),\n useDispatch: (system: SingleModuleSystem<M>) => {\n return (event: InferEvents<M>) => {\n system.dispatch(event);\n };\n },\n useEvents: (system: SingleModuleSystem<M>) => system.events,\n createWatch: <K extends string>(\n host: ReactiveControllerHost,\n system: SingleModuleSystem<M>,\n key: K,\n callback: (newValue: unknown, previousValue: unknown) => void,\n ) => createWatch<unknown>(host, system, key, callback),\n };\n}\n\n// ============================================================================\n// NamespacedSelectorController — select from a NamespacedSystem\n// ============================================================================\n\n/**\n * Reactive controller that selects from a NamespacedSystem.\n * Subscribes to specified keys and triggers host updates.\n *\n * @example\n * ```typescript\n * class MyElement extends LitElement {\n * private token = new NamespacedSelectorController(\n * this, system, [\"auth.token\"], (s) => s.facts.auth.token,\n * );\n * render() {\n * return html`<span>${this.token.value}</span>`;\n * }\n * }\n * ```\n */\nexport class NamespacedSelectorController<Modules extends ModulesMap, R>\n implements ReactiveController\n{\n private host: ReactiveControllerHost;\n private system: NamespacedSystem<Modules>;\n private keys: string[];\n private selector: (system: NamespacedSystem<Modules>) => R;\n private unsubscribe?: () => void;\n value: R;\n\n constructor(\n host: ReactiveControllerHost,\n system: NamespacedSystem<Modules>,\n keys: string[],\n selector: (system: NamespacedSystem<Modules>) => R,\n ) {\n this.host = host;\n this.system = system;\n this.keys = keys;\n this.selector = selector;\n this.value = selector(system);\n host.addController(this);\n }\n\n hostConnected(): void {\n this.value = this.selector(this.system);\n this.unsubscribe = this.system.subscribe(this.keys, () => {\n this.value = this.selector(this.system);\n this.host.requestUpdate();\n });\n }\n\n hostDisconnected(): void {\n this.unsubscribe?.();\n this.unsubscribe = undefined;\n }\n}\n\nexport function createNamespacedSelector<Modules extends ModulesMap, R>(\n host: ReactiveControllerHost,\n system: NamespacedSystem<Modules>,\n keys: string[],\n selector: (system: NamespacedSystem<Modules>) => R,\n): NamespacedSelectorController<Modules, R> {\n return new NamespacedSelectorController(host, system, keys, selector);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@directive-run/lit",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Lit web components adapter for Directive.",
5
5
  "license": "MIT",
6
6
  "author": "Jason Comes",
@@ -52,7 +52,7 @@
52
52
  "lit": "^3.1.0",
53
53
  "tsup": "^8.3.5",
54
54
  "typescript": "^5.7.2",
55
- "@directive-run/core": "0.2.0"
55
+ "@directive-run/core": "0.4.0"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "tsup",