@directive-run/core 1.3.0 → 1.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/adapter-utils.d.cts +1 -1
- package/dist/adapter-utils.d.ts +1 -1
- package/dist/chunk-E2WETPLH.js +3 -0
- package/dist/chunk-E2WETPLH.js.map +1 -0
- package/dist/{chunk-JYGG4RIL.js → chunk-LFMRWCIG.js} +3 -3
- package/dist/{chunk-JYGG4RIL.js.map → chunk-LFMRWCIG.js.map} +1 -1
- package/dist/chunk-TUS5WDVE.cjs +3 -0
- package/dist/chunk-TUS5WDVE.cjs.map +1 -0
- package/dist/{chunk-U3DN2WML.cjs → chunk-VSHSYVSY.cjs} +3 -3
- package/dist/{chunk-U3DN2WML.cjs.map → chunk-VSHSYVSY.cjs.map} +1 -1
- package/dist/{helpers-CCljEIsG.d.cts → helpers-BUY1lYCX.d.cts} +1 -1
- package/dist/{helpers-CfZCxxkR.d.ts → helpers-D6LcRum7.d.ts} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/internals.cjs +1 -1
- package/dist/internals.d.cts +35 -4
- package/dist/internals.d.ts +35 -4
- package/dist/internals.js +1 -1
- package/dist/plugins/index.d.cts +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/{plugins-CLZ3xci0.d.ts → plugins-Dy1C8GtT.d.cts} +60 -1
- package/dist/{plugins-CLZ3xci0.d.cts → plugins-Dy1C8GtT.d.ts} +60 -1
- package/dist/system-2THXJBFM.cjs +2 -0
- package/dist/{system-LZMEZBOA.cjs.map → system-2THXJBFM.cjs.map} +1 -1
- package/dist/system-JIO36ALC.js +2 -0
- package/dist/{system-F2QGHEG7.js.map → system-JIO36ALC.js.map} +1 -1
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +1 -1
- package/dist/worker.d.ts +1 -1
- package/dist/worker.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-GVVNFVEX.js +0 -3
- package/dist/chunk-GVVNFVEX.js.map +0 -1
- package/dist/chunk-RCCTZCZZ.cjs +0 -3
- package/dist/chunk-RCCTZCZZ.cjs.map +0 -1
- package/dist/system-F2QGHEG7.js +0 -2
- package/dist/system-LZMEZBOA.cjs +0 -2
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var chunkU3DN2WML_cjs=require('./chunk-U3DN2WML.cjs'),chunkRCCTZCZZ_cjs=require('./chunk-RCCTZCZZ.cjs'),chunkDDUARSUH_cjs=require('./chunk-DDUARSUH.cjs'),chunkBEJ6ICA7_cjs=require('./chunk-BEJ6ICA7.cjs');function h(e=[],n,t,s,i,l,o){return {_type:void 0,_validators:e,_typeName:n,_default:t,_transform:s,_description:i,_refinements:l,_meta:o,validate(p){return h([...e,p],n,t,s,i,l,o)}}}function c(e,n,t,s,i,l,o){return {...h(e,n,t,s,i,l,o),default(r){return c(e,n,r,s,i,l,o)},transform(r){return c([],n,void 0,u=>{let d=s?s(u):u;return r(d)},i,void 0,o)},brand(){return c(e,`Branded<${n}>`,t,s,i,l,o)},describe(r){return c(e,n,t,s,r,l,o)},refine(r,a){let u=[...l??[],{predicate:r,message:a}];return c([...e,r],n,t,s,i,u,o)},nullable(){return c([r=>r===null||e.every(a=>a(r))],`${n} | null`,t,s,i,void 0,o)},optional(){return c([r=>r===void 0||e.every(a=>a(r))],`${n} | undefined`,t,s,i,void 0,o)},meta(r){return c(e,n,t,s,i,l,r)}}}var X=((...e)=>{if(e.length===0)return c([],"union");let n=e.map(t=>t._typeName??"unknown");return c([t=>e.some(s=>s._validators.every(i=>i(t)))],n.join(" | "))}),Y={string(){let e=(n,t,s,i,l,o)=>({...c(n,"string",t,s,i,l,o),minLength(r){return e([...n,a=>a.length>=r],t,s,i,l,o)},maxLength(r){return e([...n,a=>a.length<=r],t,s,i,l,o)},pattern(r){return e([...n,a=>r.test(a)],t,s,i,l,o)},default(r){return e(n,r,s,i,l,o)},describe(r){return e(n,t,s,r,l,o)},refine(r,a){let u=[...l??[],{predicate:r,message:a}];return e([...n,r],t,s,i,u,o)},meta(r){return e(n,t,s,i,l,r)}});return e([n=>typeof n=="string"])},number(){let e=(n,t,s,i,l,o)=>({...c(n,"number",t,s,i,l,o),min(r){return e([...n,a=>a>=r],t,s,i,l,o)},max(r){return e([...n,a=>a<=r],t,s,i,l,o)},default(r){return e(n,r,s,i,l,o)},describe(r){return e(n,t,s,r,l,o)},refine(r,a){let u=[...l??[],{predicate:r,message:a}];return e([...n,r],t,s,i,u,o)},meta(r){return e(n,t,s,i,l,r)}});return e([n=>typeof n=="number"])},boolean(){return c([e=>typeof e=="boolean"],"boolean")},array(){let e=(n,t,s,i,l,o)=>{let p=c(n,"array",s,void 0,i,void 0,o),r=l??{value:-1};return {...p,get _lastFailedIndex(){return r.value},set _lastFailedIndex(u){r.value=u;},of(u){let d={value:-1};return e([...n,m=>{for(let g=0;g<m.length;g++)if(!u._validators.every(F=>F(m[g])))return d.value=g,false;return true}],u,s,i,d,o)},nonEmpty(){return e([...n,u=>u.length>0],t,s,i,r,o)},maxLength(u){return e([...n,d=>d.length<=u],t,s,i,r,o)},minLength(u){return e([...n,d=>d.length>=u],t,s,i,r,o)},default(u){return e(n,t,u,i,r,o)},describe(u){return e(n,t,s,u,r,o)},meta(u){return e(n,t,s,i,r,u)}}};return e([n=>Array.isArray(n)])},object(){let e=(n,t,s,i)=>({...c(n,"object",t,void 0,s,void 0,i),shape(o){return e([...n,p=>{for(let[r,a]of Object.entries(o)){let u=p[r],d=a;if(d&&!d._validators.every(m=>m(u)))return false}return true}],t,s,i)},nonNull(){return e([...n,o=>o!=null],t,s,i)},hasKeys(...o){return e([...n,p=>o.every(r=>r in p)],t,s,i)},default(o){return e(n,o,s,i)},describe(o){return e(n,t,o,i)},meta(o){return e(n,t,s,o)}});return e([n=>typeof n=="object"&&n!==null&&!Array.isArray(n)])},enum(...e){chunkDDUARSUH_cjs.f&&e.length===0&&console.warn("[Directive] t.enum() called with no values - this will reject all strings");let n=new Set(e);return c([t=>typeof t=="string"&&n.has(t)],`enum(${e.join("|")})`)},literal(e){return c([n=>n===e],`literal(${String(e)})`)},nullable(e){let n=e._typeName??"unknown";return h([t=>t===null?true:e._validators.every(s=>s(t))],`${n} | null`)},optional(e){let n=e._typeName??"unknown";return h([t=>t===void 0?true:e._validators.every(s=>s(t))],`${n} | undefined`)},union:X,record(e){let n=e._typeName??"unknown";return c([t=>typeof t!="object"||t===null||Array.isArray(t)?false:Object.values(t).every(s=>e._validators.every(i=>i(s)))],`Record<string, ${n}>`)},tuple(...e){chunkDDUARSUH_cjs.f&&e.length===0&&console.warn("[Directive] t.tuple() called with no types - this will only accept empty arrays");let n=e.map(t=>t._typeName??"unknown");return c([t=>!Array.isArray(t)||t.length!==e.length?false:e.every((s,i)=>s._validators.every(l=>l(t[i])))],`[${n.join(", ")}]`)},date(){return c([e=>e instanceof Date&&!Number.isNaN(e.getTime())],"Date")},uuid(){let e=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;return c([n=>typeof n=="string"&&e.test(n)],"uuid")},email(){let e=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return c([n=>typeof n=="string"&&e.test(n)],"email")},url(){return c([e=>{if(typeof e!="string")return false;try{return new URL(e),!0}catch{return false}}],"url")},bigint(){return c([e=>typeof e=="bigint"],"bigint")},any(){return c([],"any")},unknown(){return c([],"unknown")}};function Z(e){if(!e||typeof e!="string"){console.warn("[Directive] Module ID must be a non-empty string");return}/^(__[a-z][a-z0-9_-]*|[a-z][a-z0-9-]*)$/i.test(e)||console.warn(`[Directive] Module ID "${e}" should follow kebab-case convention (e.g., "my-module")`);}function b(e,n,t,s,i){for(let l of e)n.has(l)||console.warn(`[Directive] ${t} "${l}" not declared in ${s}`);for(let l of n)e.has(l)||console.warn(`[Directive] ${s}["${l}"] ${i}`);}function V(e,n){e.length===0&&console.warn("[Directive] history.snapshotEvents is an empty array \u2014 no events will create history snapshots. Omit history.snapshotEvents entirely to snapshot all events, or list specific events.");let t=new Set(Object.keys(n));for(let s of e)t.has(s)||console.warn(`[Directive] history.snapshotEvents entry "${s}" not declared in schema.events. Available events: ${[...t].join(", ")||"(none)"}`);}function ee(e,n){let t=new Set(Object.keys(n));for(let[s,i]of Object.entries(e)){let l=i;typeof l.requirement=="string"&&!t.has(l.requirement)&&console.warn(`[Directive] Resolver "${s}" references unknown requirement type "${l.requirement}". Available types: ${[...t].join(", ")||"(none)"}`);}}function ne(e,n){Z(e),n.schema?n.schema.facts||console.warn("[Directive] Module schema.facts is required"):console.warn("[Directive] Module schema is required"),b(new Set(Object.keys(n.derive??{})),new Set(Object.keys(n.schema?.derivations??{})),"Derivation","schema.derivations","has no matching implementation in derive"),b(new Set(Object.keys(n.events??{})),new Set(Object.keys(n.schema?.events??{})),"Event","schema.events","has no matching handler in events"),n.history?.snapshotEvents&&V(n.history.snapshotEvents,n.schema?.events??{}),n.resolvers&&n.schema?.requirements&&ee(n.resolvers,n.schema.requirements);}function v(e,n){chunkDDUARSUH_cjs.f&&ne(e,n);let t="crossModuleDeps"in n?n.crossModuleDeps:void 0;return {id:e,schema:n.schema,init:n.init,derive:n.derive??{},events:n.events??{},effects:n.effects,constraints:n.constraints,resolvers:n.resolvers,hooks:n.hooks,meta:n.meta,history:n.history,crossModuleDeps:t}}function te(e){return n=>v(n,e)}function M(){let e={pending:new Map,inflight:new Map,failed:new Map,errors:new Map,listeners:new Set};function n(){for(let r of e.listeners)r();}function t(r,a){let u=r.get(a);return u||(u=new Set,r.set(a,u)),u}function s(r){let a=e.pending.get(r)??new Set,u=e.inflight.get(r)??new Set,d=e.failed.get(r)??new Set,m=e.errors.get(r)??null;return {pending:a.size,inflight:u.size,failed:d.size,isLoading:a.size>0||u.size>0,hasError:d.size>0,lastError:m}}function i(){let r=new Set([...e.pending.keys(),...e.inflight.keys(),...e.failed.keys()]),a=new Map;for(let u of r)a.set(u,s(u));return a}function l(r){return e.listeners.add(r),()=>e.listeners.delete(r)}function o(){e.pending.clear(),e.inflight.clear(),e.failed.clear(),e.errors.clear(),n();}return {plugin:{name:"requirement-status",onRequirementCreated(r){let a=r.requirement.type;t(e.pending,a).add(r.id),e.failed.get(a)?.delete(r.id),n();},onResolverStart(r,a){let u=a.requirement.type;e.pending.get(u)?.delete(a.id),t(e.inflight,u).add(a.id),n();},onResolverComplete(r,a){let u=a.requirement.type;e.inflight.get(u)?.delete(a.id),e.pending.get(u)?.delete(a.id),n();},onResolverError(r,a,u){let d=a.requirement.type;e.inflight.get(d)?.delete(a.id),t(e.failed,d).add(a.id),e.errors.set(d,u instanceof Error?u:new Error(String(u))),n();},onResolverCancel(r,a){let u=a.requirement.type;e.pending.get(u)?.delete(a.id),e.inflight.get(u)?.delete(a.id),n();},onRequirementMet(r){let a=r.requirement.type;e.pending.get(a)?.delete(r.id),e.inflight.get(a)?.delete(r.id),n();}},getStatus:s,getAllStatus:i,subscribe:l,reset:o}}function re(e){return n=>e.getStatus(n)}function se(e){let n=M(),s=[...e.plugins??[],n.plugin];return {system:chunkU3DN2WML_cjs.a({module:e.module,plugins:s,trace:e.trace,errorBoundary:e.errorBoundary,tickMs:e.tickMs,zeroConfig:e.zeroConfig,initialFacts:e.initialFacts}),statusPlugin:n}}function D(){return {now:()=>Date.now(),setTimeout:(e,n)=>{let t=globalThis.setTimeout(e,n);return ()=>globalThis.clearTimeout(t)}}}function ie(e=0){let n=e,t=0,s=[];return {now:()=>n,setTimeout:(i,l)=>{let o={id:t++,deadlineMs:n+l,cb:i,canceled:false};return s.push(o),()=>{o.canceled=true;}},advanceBy:i=>{let l=n+i;for(;;){let o=s.filter(r=>!r.canceled&&r.deadlineMs<=l).sort((r,a)=>r.deadlineMs!==a.deadlineMs?r.deadlineMs-a.deadlineMs:r.id-a.id);if(o.length===0)break;let p=o[0];n=Math.max(n,p.deadlineMs),p.canceled=true,p.cb();}n=Math.max(n,l);}}}function ae(){return D()}function S(){return {startedAtMs:null,pausedDurationMs:0,pausedAtMs:null,status:"idle",repeats:0}}function T(e,n){return e.startedAtMs===null?0:e.status==="paused"&&e.pausedAtMs!==null?Math.max(0,e.pausedAtMs-e.startedAtMs-e.pausedDurationMs):Math.max(0,n-e.startedAtMs-e.pausedDurationMs)}function x(e,n,t){return Math.max(0,t-T(e,n))}function C(e,n){return e.status==="running"||e.status==="paused"?e:{...e,startedAtMs:n,pausedDurationMs:0,pausedAtMs:null,status:"running",repeats:0}}function k(e,n){return e.status!=="running"?e:{...e,pausedAtMs:n,status:"paused"}}function w(e,n){if(e.status!=="paused"||e.pausedAtMs===null)return e;let t=Math.max(0,n-e.pausedAtMs);return {...e,pausedDurationMs:e.pausedDurationMs+t,pausedAtMs:null,status:"running"}}function R(){return S()}function A(e){return {...e,status:"completed"}}function E(e,n){return e.startedAtMs===null||e.status==="paused"?e:{...e,startedAtMs:e.startedAtMs+n,pausedDurationMs:0,pausedAtMs:null,repeats:e.repeats+1}}function j(e,n,t){if(e.status!=="running")return {kind:"no-op"};let s=T(e,n);return t.mode==="up"?{kind:"no-op"}:t.mode==="repeat"?s>=t.ms?{kind:"repeat"}:{kind:"no-op"}:s>=t.ms?{kind:"complete"}:{kind:"no-op"}}function oe(e){return {initial:S,start:C,pause:k,resume:w,reset:R,complete:A,registerRepeat:n=>E(n,e.ms),tick:(n,t)=>j(n,t,e),elapsedMs:T,remainingMs:(n,t)=>x(n,t,e.ms)}}var fe={None:"none",Linear:"linear",Exponential:"exponential"};Object.defineProperty(exports,"createSystem",{enumerable:true,get:function(){return chunkU3DN2WML_cjs.a}});Object.defineProperty(exports,"DirectiveError",{enumerable:true,get:function(){return chunkRCCTZCZZ_cjs.b}});Object.defineProperty(exports,"RequirementSet",{enumerable:true,get:function(){return chunkRCCTZCZZ_cjs.o}});Object.defineProperty(exports,"forType",{enumerable:true,get:function(){return chunkRCCTZCZZ_cjs.n}});Object.defineProperty(exports,"generateRequirementId",{enumerable:true,get:function(){return chunkRCCTZCZZ_cjs.k}});Object.defineProperty(exports,"isNamespacedSystem",{enumerable:true,get:function(){return chunkRCCTZCZZ_cjs.h}});Object.defineProperty(exports,"isRequirementType",{enumerable:true,get:function(){return chunkRCCTZCZZ_cjs.m}});Object.defineProperty(exports,"isSingleModuleSystem",{enumerable:true,get:function(){return chunkRCCTZCZZ_cjs.g}});Object.defineProperty(exports,"req",{enumerable:true,get:function(){return chunkRCCTZCZZ_cjs.l}});Object.defineProperty(exports,"typedConstraint",{enumerable:true,get:function(){return chunkRCCTZCZZ_cjs.e}});Object.defineProperty(exports,"typedResolver",{enumerable:true,get:function(){return chunkRCCTZCZZ_cjs.f}});Object.defineProperty(exports,"diffSnapshots",{enumerable:true,get:function(){return chunkBEJ6ICA7_cjs.h}});Object.defineProperty(exports,"isSignedSnapshot",{enumerable:true,get:function(){return chunkBEJ6ICA7_cjs.i}});Object.defineProperty(exports,"isSnapshotExpired",{enumerable:true,get:function(){return chunkBEJ6ICA7_cjs.f}});Object.defineProperty(exports,"shallowEqual",{enumerable:true,get:function(){return chunkBEJ6ICA7_cjs.d}});Object.defineProperty(exports,"signSnapshot",{enumerable:true,get:function(){return chunkBEJ6ICA7_cjs.j}});Object.defineProperty(exports,"validateSnapshot",{enumerable:true,get:function(){return chunkBEJ6ICA7_cjs.g}});Object.defineProperty(exports,"verifySnapshotSignature",{enumerable:true,get:function(){return chunkBEJ6ICA7_cjs.k}});exports.Backoff=fe;exports.completeTimer=A;exports.createModule=v;exports.createModuleFactory=te;exports.createRequirementStatusPlugin=M;exports.createStatusHook=re;exports.createSystemWithStatus=se;exports.defaultClock=ae;exports.elapsedMs=T;exports.initialTimerState=S;exports.pauseTimer=k;exports.realClock=D;exports.registerRepeat=E;exports.remainingMs=x;exports.resetTimer=R;exports.resumeTimer=w;exports.startTimer=C;exports.t=Y;exports.tickTimer=j;exports.timerOps=oe;exports.virtualClock=ie;//# sourceMappingURL=index.cjs.map
|
|
1
|
+
'use strict';var chunkVSHSYVSY_cjs=require('./chunk-VSHSYVSY.cjs'),chunkTUS5WDVE_cjs=require('./chunk-TUS5WDVE.cjs'),chunkDDUARSUH_cjs=require('./chunk-DDUARSUH.cjs'),chunkBEJ6ICA7_cjs=require('./chunk-BEJ6ICA7.cjs');function h(e=[],n,t,s,i,l,o){return {_type:void 0,_validators:e,_typeName:n,_default:t,_transform:s,_description:i,_refinements:l,_meta:o,validate(p){return h([...e,p],n,t,s,i,l,o)}}}function c(e,n,t,s,i,l,o){return {...h(e,n,t,s,i,l,o),default(r){return c(e,n,r,s,i,l,o)},transform(r){return c([],n,void 0,u=>{let d=s?s(u):u;return r(d)},i,void 0,o)},brand(){return c(e,`Branded<${n}>`,t,s,i,l,o)},describe(r){return c(e,n,t,s,r,l,o)},refine(r,a){let u=[...l??[],{predicate:r,message:a}];return c([...e,r],n,t,s,i,u,o)},nullable(){return c([r=>r===null||e.every(a=>a(r))],`${n} | null`,t,s,i,void 0,o)},optional(){return c([r=>r===void 0||e.every(a=>a(r))],`${n} | undefined`,t,s,i,void 0,o)},meta(r){return c(e,n,t,s,i,l,r)}}}var X=((...e)=>{if(e.length===0)return c([],"union");let n=e.map(t=>t._typeName??"unknown");return c([t=>e.some(s=>s._validators.every(i=>i(t)))],n.join(" | "))}),Y={string(){let e=(n,t,s,i,l,o)=>({...c(n,"string",t,s,i,l,o),minLength(r){return e([...n,a=>a.length>=r],t,s,i,l,o)},maxLength(r){return e([...n,a=>a.length<=r],t,s,i,l,o)},pattern(r){return e([...n,a=>r.test(a)],t,s,i,l,o)},default(r){return e(n,r,s,i,l,o)},describe(r){return e(n,t,s,r,l,o)},refine(r,a){let u=[...l??[],{predicate:r,message:a}];return e([...n,r],t,s,i,u,o)},meta(r){return e(n,t,s,i,l,r)}});return e([n=>typeof n=="string"])},number(){let e=(n,t,s,i,l,o)=>({...c(n,"number",t,s,i,l,o),min(r){return e([...n,a=>a>=r],t,s,i,l,o)},max(r){return e([...n,a=>a<=r],t,s,i,l,o)},default(r){return e(n,r,s,i,l,o)},describe(r){return e(n,t,s,r,l,o)},refine(r,a){let u=[...l??[],{predicate:r,message:a}];return e([...n,r],t,s,i,u,o)},meta(r){return e(n,t,s,i,l,r)}});return e([n=>typeof n=="number"])},boolean(){return c([e=>typeof e=="boolean"],"boolean")},array(){let e=(n,t,s,i,l,o)=>{let p=c(n,"array",s,void 0,i,void 0,o),r=l??{value:-1};return {...p,get _lastFailedIndex(){return r.value},set _lastFailedIndex(u){r.value=u;},of(u){let d={value:-1};return e([...n,m=>{for(let g=0;g<m.length;g++)if(!u._validators.every(F=>F(m[g])))return d.value=g,false;return true}],u,s,i,d,o)},nonEmpty(){return e([...n,u=>u.length>0],t,s,i,r,o)},maxLength(u){return e([...n,d=>d.length<=u],t,s,i,r,o)},minLength(u){return e([...n,d=>d.length>=u],t,s,i,r,o)},default(u){return e(n,t,u,i,r,o)},describe(u){return e(n,t,s,u,r,o)},meta(u){return e(n,t,s,i,r,u)}}};return e([n=>Array.isArray(n)])},object(){let e=(n,t,s,i)=>({...c(n,"object",t,void 0,s,void 0,i),shape(o){return e([...n,p=>{for(let[r,a]of Object.entries(o)){let u=p[r],d=a;if(d&&!d._validators.every(m=>m(u)))return false}return true}],t,s,i)},nonNull(){return e([...n,o=>o!=null],t,s,i)},hasKeys(...o){return e([...n,p=>o.every(r=>r in p)],t,s,i)},default(o){return e(n,o,s,i)},describe(o){return e(n,t,o,i)},meta(o){return e(n,t,s,o)}});return e([n=>typeof n=="object"&&n!==null&&!Array.isArray(n)])},enum(...e){chunkDDUARSUH_cjs.f&&e.length===0&&console.warn("[Directive] t.enum() called with no values - this will reject all strings");let n=new Set(e);return c([t=>typeof t=="string"&&n.has(t)],`enum(${e.join("|")})`)},literal(e){return c([n=>n===e],`literal(${String(e)})`)},nullable(e){let n=e._typeName??"unknown";return h([t=>t===null?true:e._validators.every(s=>s(t))],`${n} | null`)},optional(e){let n=e._typeName??"unknown";return h([t=>t===void 0?true:e._validators.every(s=>s(t))],`${n} | undefined`)},union:X,record(e){let n=e._typeName??"unknown";return c([t=>typeof t!="object"||t===null||Array.isArray(t)?false:Object.values(t).every(s=>e._validators.every(i=>i(s)))],`Record<string, ${n}>`)},tuple(...e){chunkDDUARSUH_cjs.f&&e.length===0&&console.warn("[Directive] t.tuple() called with no types - this will only accept empty arrays");let n=e.map(t=>t._typeName??"unknown");return c([t=>!Array.isArray(t)||t.length!==e.length?false:e.every((s,i)=>s._validators.every(l=>l(t[i])))],`[${n.join(", ")}]`)},date(){return c([e=>e instanceof Date&&!Number.isNaN(e.getTime())],"Date")},uuid(){let e=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;return c([n=>typeof n=="string"&&e.test(n)],"uuid")},email(){let e=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return c([n=>typeof n=="string"&&e.test(n)],"email")},url(){return c([e=>{if(typeof e!="string")return false;try{return new URL(e),!0}catch{return false}}],"url")},bigint(){return c([e=>typeof e=="bigint"],"bigint")},any(){return c([],"any")},unknown(){return c([],"unknown")}};function Z(e){if(!e||typeof e!="string"){console.warn("[Directive] Module ID must be a non-empty string");return}/^(__[a-z][a-z0-9_-]*|[a-z][a-z0-9-]*)$/i.test(e)||console.warn(`[Directive] Module ID "${e}" should follow kebab-case convention (e.g., "my-module")`);}function b(e,n,t,s,i){for(let l of e)n.has(l)||console.warn(`[Directive] ${t} "${l}" not declared in ${s}`);for(let l of n)e.has(l)||console.warn(`[Directive] ${s}["${l}"] ${i}`);}function V(e,n){e.length===0&&console.warn("[Directive] history.snapshotEvents is an empty array \u2014 no events will create history snapshots. Omit history.snapshotEvents entirely to snapshot all events, or list specific events.");let t=new Set(Object.keys(n));for(let s of e)t.has(s)||console.warn(`[Directive] history.snapshotEvents entry "${s}" not declared in schema.events. Available events: ${[...t].join(", ")||"(none)"}`);}function ee(e,n){let t=new Set(Object.keys(n));for(let[s,i]of Object.entries(e)){let l=i;typeof l.requirement=="string"&&!t.has(l.requirement)&&console.warn(`[Directive] Resolver "${s}" references unknown requirement type "${l.requirement}". Available types: ${[...t].join(", ")||"(none)"}`);}}function ne(e,n){Z(e),n.schema?n.schema.facts||console.warn("[Directive] Module schema.facts is required"):console.warn("[Directive] Module schema is required"),b(new Set(Object.keys(n.derive??{})),new Set(Object.keys(n.schema?.derivations??{})),"Derivation","schema.derivations","has no matching implementation in derive"),b(new Set(Object.keys(n.events??{})),new Set(Object.keys(n.schema?.events??{})),"Event","schema.events","has no matching handler in events"),n.history?.snapshotEvents&&V(n.history.snapshotEvents,n.schema?.events??{}),n.resolvers&&n.schema?.requirements&&ee(n.resolvers,n.schema.requirements);}function v(e,n){chunkDDUARSUH_cjs.f&&ne(e,n);let t="crossModuleDeps"in n?n.crossModuleDeps:void 0;return {id:e,schema:n.schema,init:n.init,derive:n.derive??{},events:n.events??{},effects:n.effects,constraints:n.constraints,resolvers:n.resolvers,hooks:n.hooks,meta:n.meta,history:n.history,crossModuleDeps:t}}function te(e){return n=>v(n,e)}function M(){let e={pending:new Map,inflight:new Map,failed:new Map,errors:new Map,listeners:new Set};function n(){for(let r of e.listeners)r();}function t(r,a){let u=r.get(a);return u||(u=new Set,r.set(a,u)),u}function s(r){let a=e.pending.get(r)??new Set,u=e.inflight.get(r)??new Set,d=e.failed.get(r)??new Set,m=e.errors.get(r)??null;return {pending:a.size,inflight:u.size,failed:d.size,isLoading:a.size>0||u.size>0,hasError:d.size>0,lastError:m}}function i(){let r=new Set([...e.pending.keys(),...e.inflight.keys(),...e.failed.keys()]),a=new Map;for(let u of r)a.set(u,s(u));return a}function l(r){return e.listeners.add(r),()=>e.listeners.delete(r)}function o(){e.pending.clear(),e.inflight.clear(),e.failed.clear(),e.errors.clear(),n();}return {plugin:{name:"requirement-status",onRequirementCreated(r){let a=r.requirement.type;t(e.pending,a).add(r.id),e.failed.get(a)?.delete(r.id),n();},onResolverStart(r,a){let u=a.requirement.type;e.pending.get(u)?.delete(a.id),t(e.inflight,u).add(a.id),n();},onResolverComplete(r,a){let u=a.requirement.type;e.inflight.get(u)?.delete(a.id),e.pending.get(u)?.delete(a.id),n();},onResolverError(r,a,u){let d=a.requirement.type;e.inflight.get(d)?.delete(a.id),t(e.failed,d).add(a.id),e.errors.set(d,u instanceof Error?u:new Error(String(u))),n();},onResolverCancel(r,a){let u=a.requirement.type;e.pending.get(u)?.delete(a.id),e.inflight.get(u)?.delete(a.id),n();},onRequirementMet(r){let a=r.requirement.type;e.pending.get(a)?.delete(r.id),e.inflight.get(a)?.delete(r.id),n();}},getStatus:s,getAllStatus:i,subscribe:l,reset:o}}function re(e){return n=>e.getStatus(n)}function se(e){let n=M(),s=[...e.plugins??[],n.plugin];return {system:chunkVSHSYVSY_cjs.a({module:e.module,plugins:s,trace:e.trace,errorBoundary:e.errorBoundary,tickMs:e.tickMs,zeroConfig:e.zeroConfig,initialFacts:e.initialFacts}),statusPlugin:n}}function D(){return {now:()=>Date.now(),setTimeout:(e,n)=>{let t=globalThis.setTimeout(e,n);return ()=>globalThis.clearTimeout(t)}}}function ie(e=0){let n=e,t=0,s=[];return {now:()=>n,setTimeout:(i,l)=>{let o={id:t++,deadlineMs:n+l,cb:i,canceled:false};return s.push(o),()=>{o.canceled=true;}},advanceBy:i=>{let l=n+i;for(;;){let o=s.filter(r=>!r.canceled&&r.deadlineMs<=l).sort((r,a)=>r.deadlineMs!==a.deadlineMs?r.deadlineMs-a.deadlineMs:r.id-a.id);if(o.length===0)break;let p=o[0];n=Math.max(n,p.deadlineMs),p.canceled=true,p.cb();}n=Math.max(n,l);}}}function ae(){return D()}function S(){return {startedAtMs:null,pausedDurationMs:0,pausedAtMs:null,status:"idle",repeats:0}}function T(e,n){return e.startedAtMs===null?0:e.status==="paused"&&e.pausedAtMs!==null?Math.max(0,e.pausedAtMs-e.startedAtMs-e.pausedDurationMs):Math.max(0,n-e.startedAtMs-e.pausedDurationMs)}function x(e,n,t){return Math.max(0,t-T(e,n))}function C(e,n){return e.status==="running"||e.status==="paused"?e:{...e,startedAtMs:n,pausedDurationMs:0,pausedAtMs:null,status:"running",repeats:0}}function k(e,n){return e.status!=="running"?e:{...e,pausedAtMs:n,status:"paused"}}function w(e,n){if(e.status!=="paused"||e.pausedAtMs===null)return e;let t=Math.max(0,n-e.pausedAtMs);return {...e,pausedDurationMs:e.pausedDurationMs+t,pausedAtMs:null,status:"running"}}function R(){return S()}function A(e){return {...e,status:"completed"}}function E(e,n){return e.startedAtMs===null||e.status==="paused"?e:{...e,startedAtMs:e.startedAtMs+n,pausedDurationMs:0,pausedAtMs:null,repeats:e.repeats+1}}function j(e,n,t){if(e.status!=="running")return {kind:"no-op"};let s=T(e,n);return t.mode==="up"?{kind:"no-op"}:t.mode==="repeat"?s>=t.ms?{kind:"repeat"}:{kind:"no-op"}:s>=t.ms?{kind:"complete"}:{kind:"no-op"}}function oe(e){return {initial:S,start:C,pause:k,resume:w,reset:R,complete:A,registerRepeat:n=>E(n,e.ms),tick:(n,t)=>j(n,t,e),elapsedMs:T,remainingMs:(n,t)=>x(n,t,e.ms)}}var fe={None:"none",Linear:"linear",Exponential:"exponential"};Object.defineProperty(exports,"createSystem",{enumerable:true,get:function(){return chunkVSHSYVSY_cjs.a}});Object.defineProperty(exports,"DirectiveError",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.b}});Object.defineProperty(exports,"RequirementSet",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.o}});Object.defineProperty(exports,"forType",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.n}});Object.defineProperty(exports,"generateRequirementId",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.k}});Object.defineProperty(exports,"isNamespacedSystem",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.h}});Object.defineProperty(exports,"isRequirementType",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.m}});Object.defineProperty(exports,"isSingleModuleSystem",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.g}});Object.defineProperty(exports,"req",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.l}});Object.defineProperty(exports,"typedConstraint",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.e}});Object.defineProperty(exports,"typedResolver",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.f}});Object.defineProperty(exports,"diffSnapshots",{enumerable:true,get:function(){return chunkBEJ6ICA7_cjs.h}});Object.defineProperty(exports,"isSignedSnapshot",{enumerable:true,get:function(){return chunkBEJ6ICA7_cjs.i}});Object.defineProperty(exports,"isSnapshotExpired",{enumerable:true,get:function(){return chunkBEJ6ICA7_cjs.f}});Object.defineProperty(exports,"shallowEqual",{enumerable:true,get:function(){return chunkBEJ6ICA7_cjs.d}});Object.defineProperty(exports,"signSnapshot",{enumerable:true,get:function(){return chunkBEJ6ICA7_cjs.j}});Object.defineProperty(exports,"validateSnapshot",{enumerable:true,get:function(){return chunkBEJ6ICA7_cjs.g}});Object.defineProperty(exports,"verifySnapshotSignature",{enumerable:true,get:function(){return chunkBEJ6ICA7_cjs.k}});exports.Backoff=fe;exports.completeTimer=A;exports.createModule=v;exports.createModuleFactory=te;exports.createRequirementStatusPlugin=M;exports.createStatusHook=re;exports.createSystemWithStatus=se;exports.defaultClock=ae;exports.elapsedMs=T;exports.initialTimerState=S;exports.pauseTimer=k;exports.realClock=D;exports.registerRepeat=E;exports.remainingMs=x;exports.resetTimer=R;exports.resumeTimer=w;exports.startTimer=C;exports.t=Y;exports.tickTimer=j;exports.timerOps=oe;exports.virtualClock=ie;//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as SchemaType, D as DefinitionMeta, M as ModuleSchema, F as Facts, T as TypedDerivationsDef, a as TypedEventsDef, E as EffectsDef, b as TypedConstraintsDef, c as TypedResolversDef, d as ModuleHooks, C as CrossModuleDeps, e as CrossModuleDerivationsDef, f as CrossModuleEffectsDef, g as CrossModuleConstraintsDef, h as ModuleDef, i as CreateSystemOptionsSingle, j as SingleModuleSystem, k as ModulesMap, l as CreateSystemOptionsNamed, N as NamespacedSystem, P as Plugin, m as TraceOption, n as ErrorBoundaryConfig, R as RequirementWithId, o as Requirement, p as RequirementKeyFn } from './plugins-
|
|
2
|
-
export { A as AnySystem, B as BatchConfig, q as DirectiveError, r as DistributableSnapshot, s as DistributableSnapshotOptions, t as DynamicConstraintDef, u as DynamicEffectDef, v as DynamicResolverDef, w as FactsSnapshot, H as HistoryAPI, x as HistoryOption, y as HistoryState, I as InferDerivations, z as InferEvents, G as InferFacts, J as InferRequirementTypes, K as InferRequirements, L as InferSchemaType, O as InferSelectorState, Q as MetaAccessor, U as MetaMatch, V as ObservationEvent, W as RetryPolicy, X as Schema, Y as Snapshot, Z as System, _ as SystemConfig, $ as SystemInspection, a0 as SystemMode, a1 as SystemSnapshot, a2 as TraceEntry, a3 as isNamespacedSystem, a4 as isSingleModuleSystem } from './plugins-
|
|
3
|
-
export { D as DerivationDefWithMeta, t as typedConstraint, a as typedResolver } from './helpers-
|
|
1
|
+
import { S as SchemaType, D as DefinitionMeta, M as ModuleSchema, F as Facts, T as TypedDerivationsDef, a as TypedEventsDef, E as EffectsDef, b as TypedConstraintsDef, c as TypedResolversDef, d as ModuleHooks, C as CrossModuleDeps, e as CrossModuleDerivationsDef, f as CrossModuleEffectsDef, g as CrossModuleConstraintsDef, h as ModuleDef, i as CreateSystemOptionsSingle, j as SingleModuleSystem, k as ModulesMap, l as CreateSystemOptionsNamed, N as NamespacedSystem, P as Plugin, m as TraceOption, n as ErrorBoundaryConfig, R as RequirementWithId, o as Requirement, p as RequirementKeyFn } from './plugins-Dy1C8GtT.cjs';
|
|
2
|
+
export { A as AnySystem, B as BatchConfig, q as DirectiveError, r as DistributableSnapshot, s as DistributableSnapshotOptions, t as DynamicConstraintDef, u as DynamicEffectDef, v as DynamicResolverDef, w as FactsSnapshot, H as HistoryAPI, x as HistoryOption, y as HistoryState, I as InferDerivations, z as InferEvents, G as InferFacts, J as InferRequirementTypes, K as InferRequirements, L as InferSchemaType, O as InferSelectorState, Q as MetaAccessor, U as MetaMatch, V as ObservationEvent, W as RetryPolicy, X as Schema, Y as Snapshot, Z as System, _ as SystemConfig, $ as SystemInspection, a0 as SystemMode, a1 as SystemSnapshot, a2 as TraceEntry, a3 as isNamespacedSystem, a4 as isSingleModuleSystem } from './plugins-Dy1C8GtT.cjs';
|
|
3
|
+
export { D as DerivationDefWithMeta, t as typedConstraint, a as typedResolver } from './helpers-BUY1lYCX.cjs';
|
|
4
4
|
export { D as DistributableSnapshotLike, S as SignedSnapshot, a as SnapshotDiff, b as SnapshotDiffEntry, d as diffSnapshots, i as isSignedSnapshot, c as isSnapshotExpired, s as shallowEqual, e as signSnapshot, v as validateSnapshot, f as verifySnapshotSignature } from './utils-BnQajqPu.cjs';
|
|
5
5
|
|
|
6
6
|
/** Brand symbol for branded types */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as SchemaType, D as DefinitionMeta, M as ModuleSchema, F as Facts, T as TypedDerivationsDef, a as TypedEventsDef, E as EffectsDef, b as TypedConstraintsDef, c as TypedResolversDef, d as ModuleHooks, C as CrossModuleDeps, e as CrossModuleDerivationsDef, f as CrossModuleEffectsDef, g as CrossModuleConstraintsDef, h as ModuleDef, i as CreateSystemOptionsSingle, j as SingleModuleSystem, k as ModulesMap, l as CreateSystemOptionsNamed, N as NamespacedSystem, P as Plugin, m as TraceOption, n as ErrorBoundaryConfig, R as RequirementWithId, o as Requirement, p as RequirementKeyFn } from './plugins-
|
|
2
|
-
export { A as AnySystem, B as BatchConfig, q as DirectiveError, r as DistributableSnapshot, s as DistributableSnapshotOptions, t as DynamicConstraintDef, u as DynamicEffectDef, v as DynamicResolverDef, w as FactsSnapshot, H as HistoryAPI, x as HistoryOption, y as HistoryState, I as InferDerivations, z as InferEvents, G as InferFacts, J as InferRequirementTypes, K as InferRequirements, L as InferSchemaType, O as InferSelectorState, Q as MetaAccessor, U as MetaMatch, V as ObservationEvent, W as RetryPolicy, X as Schema, Y as Snapshot, Z as System, _ as SystemConfig, $ as SystemInspection, a0 as SystemMode, a1 as SystemSnapshot, a2 as TraceEntry, a3 as isNamespacedSystem, a4 as isSingleModuleSystem } from './plugins-
|
|
3
|
-
export { D as DerivationDefWithMeta, t as typedConstraint, a as typedResolver } from './helpers-
|
|
1
|
+
import { S as SchemaType, D as DefinitionMeta, M as ModuleSchema, F as Facts, T as TypedDerivationsDef, a as TypedEventsDef, E as EffectsDef, b as TypedConstraintsDef, c as TypedResolversDef, d as ModuleHooks, C as CrossModuleDeps, e as CrossModuleDerivationsDef, f as CrossModuleEffectsDef, g as CrossModuleConstraintsDef, h as ModuleDef, i as CreateSystemOptionsSingle, j as SingleModuleSystem, k as ModulesMap, l as CreateSystemOptionsNamed, N as NamespacedSystem, P as Plugin, m as TraceOption, n as ErrorBoundaryConfig, R as RequirementWithId, o as Requirement, p as RequirementKeyFn } from './plugins-Dy1C8GtT.js';
|
|
2
|
+
export { A as AnySystem, B as BatchConfig, q as DirectiveError, r as DistributableSnapshot, s as DistributableSnapshotOptions, t as DynamicConstraintDef, u as DynamicEffectDef, v as DynamicResolverDef, w as FactsSnapshot, H as HistoryAPI, x as HistoryOption, y as HistoryState, I as InferDerivations, z as InferEvents, G as InferFacts, J as InferRequirementTypes, K as InferRequirements, L as InferSchemaType, O as InferSelectorState, Q as MetaAccessor, U as MetaMatch, V as ObservationEvent, W as RetryPolicy, X as Schema, Y as Snapshot, Z as System, _ as SystemConfig, $ as SystemInspection, a0 as SystemMode, a1 as SystemSnapshot, a2 as TraceEntry, a3 as isNamespacedSystem, a4 as isSingleModuleSystem } from './plugins-Dy1C8GtT.js';
|
|
3
|
+
export { D as DerivationDefWithMeta, t as typedConstraint, a as typedResolver } from './helpers-D6LcRum7.js';
|
|
4
4
|
export { D as DistributableSnapshotLike, S as SignedSnapshot, a as SnapshotDiff, b as SnapshotDiffEntry, d as diffSnapshots, i as isSignedSnapshot, c as isSnapshotExpired, s as shallowEqual, e as signSnapshot, v as validateSnapshot, f as verifySnapshotSignature } from './utils-BnQajqPu.js';
|
|
5
5
|
|
|
6
6
|
/** Brand symbol for branded types */
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a}from'./chunk-JYGG4RIL.js';export{a as createSystem}from'./chunk-JYGG4RIL.js';export{b as DirectiveError,o as RequirementSet,n as forType,k as generateRequirementId,h as isNamespacedSystem,m as isRequirementType,g as isSingleModuleSystem,l as req,e as typedConstraint,f as typedResolver}from'./chunk-GVVNFVEX.js';import {f}from'./chunk-FK7BD7XT.js';export{h as diffSnapshots,i as isSignedSnapshot,f as isSnapshotExpired,d as shallowEqual,j as signSnapshot,g as validateSnapshot,k as verifySnapshotSignature}from'./chunk-4CMO5OVZ.js';function h(e=[],n,t,s,i,l,o){return {_type:void 0,_validators:e,_typeName:n,_default:t,_transform:s,_description:i,_refinements:l,_meta:o,validate(p){return h([...e,p],n,t,s,i,l,o)}}}function c(e,n,t,s,i,l,o){return {...h(e,n,t,s,i,l,o),default(r){return c(e,n,r,s,i,l,o)},transform(r){return c([],n,void 0,u=>{let d=s?s(u):u;return r(d)},i,void 0,o)},brand(){return c(e,`Branded<${n}>`,t,s,i,l,o)},describe(r){return c(e,n,t,s,r,l,o)},refine(r,a){let u=[...l??[],{predicate:r,message:a}];return c([...e,r],n,t,s,i,u,o)},nullable(){return c([r=>r===null||e.every(a=>a(r))],`${n} | null`,t,s,i,void 0,o)},optional(){return c([r=>r===void 0||e.every(a=>a(r))],`${n} | undefined`,t,s,i,void 0,o)},meta(r){return c(e,n,t,s,i,l,r)}}}var X=((...e)=>{if(e.length===0)return c([],"union");let n=e.map(t=>t._typeName??"unknown");return c([t=>e.some(s=>s._validators.every(i=>i(t)))],n.join(" | "))}),Y={string(){let e=(n,t,s,i,l,o)=>({...c(n,"string",t,s,i,l,o),minLength(r){return e([...n,a=>a.length>=r],t,s,i,l,o)},maxLength(r){return e([...n,a=>a.length<=r],t,s,i,l,o)},pattern(r){return e([...n,a=>r.test(a)],t,s,i,l,o)},default(r){return e(n,r,s,i,l,o)},describe(r){return e(n,t,s,r,l,o)},refine(r,a){let u=[...l??[],{predicate:r,message:a}];return e([...n,r],t,s,i,u,o)},meta(r){return e(n,t,s,i,l,r)}});return e([n=>typeof n=="string"])},number(){let e=(n,t,s,i,l,o)=>({...c(n,"number",t,s,i,l,o),min(r){return e([...n,a=>a>=r],t,s,i,l,o)},max(r){return e([...n,a=>a<=r],t,s,i,l,o)},default(r){return e(n,r,s,i,l,o)},describe(r){return e(n,t,s,r,l,o)},refine(r,a){let u=[...l??[],{predicate:r,message:a}];return e([...n,r],t,s,i,u,o)},meta(r){return e(n,t,s,i,l,r)}});return e([n=>typeof n=="number"])},boolean(){return c([e=>typeof e=="boolean"],"boolean")},array(){let e=(n,t,s,i,l,o)=>{let p=c(n,"array",s,void 0,i,void 0,o),r=l??{value:-1};return {...p,get _lastFailedIndex(){return r.value},set _lastFailedIndex(u){r.value=u;},of(u){let d={value:-1};return e([...n,m=>{for(let g=0;g<m.length;g++)if(!u._validators.every(F=>F(m[g])))return d.value=g,false;return true}],u,s,i,d,o)},nonEmpty(){return e([...n,u=>u.length>0],t,s,i,r,o)},maxLength(u){return e([...n,d=>d.length<=u],t,s,i,r,o)},minLength(u){return e([...n,d=>d.length>=u],t,s,i,r,o)},default(u){return e(n,t,u,i,r,o)},describe(u){return e(n,t,s,u,r,o)},meta(u){return e(n,t,s,i,r,u)}}};return e([n=>Array.isArray(n)])},object(){let e=(n,t,s,i)=>({...c(n,"object",t,void 0,s,void 0,i),shape(o){return e([...n,p=>{for(let[r,a]of Object.entries(o)){let u=p[r],d=a;if(d&&!d._validators.every(m=>m(u)))return false}return true}],t,s,i)},nonNull(){return e([...n,o=>o!=null],t,s,i)},hasKeys(...o){return e([...n,p=>o.every(r=>r in p)],t,s,i)},default(o){return e(n,o,s,i)},describe(o){return e(n,t,o,i)},meta(o){return e(n,t,s,o)}});return e([n=>typeof n=="object"&&n!==null&&!Array.isArray(n)])},enum(...e){f&&e.length===0&&console.warn("[Directive] t.enum() called with no values - this will reject all strings");let n=new Set(e);return c([t=>typeof t=="string"&&n.has(t)],`enum(${e.join("|")})`)},literal(e){return c([n=>n===e],`literal(${String(e)})`)},nullable(e){let n=e._typeName??"unknown";return h([t=>t===null?true:e._validators.every(s=>s(t))],`${n} | null`)},optional(e){let n=e._typeName??"unknown";return h([t=>t===void 0?true:e._validators.every(s=>s(t))],`${n} | undefined`)},union:X,record(e){let n=e._typeName??"unknown";return c([t=>typeof t!="object"||t===null||Array.isArray(t)?false:Object.values(t).every(s=>e._validators.every(i=>i(s)))],`Record<string, ${n}>`)},tuple(...e){f&&e.length===0&&console.warn("[Directive] t.tuple() called with no types - this will only accept empty arrays");let n=e.map(t=>t._typeName??"unknown");return c([t=>!Array.isArray(t)||t.length!==e.length?false:e.every((s,i)=>s._validators.every(l=>l(t[i])))],`[${n.join(", ")}]`)},date(){return c([e=>e instanceof Date&&!Number.isNaN(e.getTime())],"Date")},uuid(){let e=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;return c([n=>typeof n=="string"&&e.test(n)],"uuid")},email(){let e=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return c([n=>typeof n=="string"&&e.test(n)],"email")},url(){return c([e=>{if(typeof e!="string")return false;try{return new URL(e),!0}catch{return false}}],"url")},bigint(){return c([e=>typeof e=="bigint"],"bigint")},any(){return c([],"any")},unknown(){return c([],"unknown")}};function Z(e){if(!e||typeof e!="string"){console.warn("[Directive] Module ID must be a non-empty string");return}/^(__[a-z][a-z0-9_-]*|[a-z][a-z0-9-]*)$/i.test(e)||console.warn(`[Directive] Module ID "${e}" should follow kebab-case convention (e.g., "my-module")`);}function b(e,n,t,s,i){for(let l of e)n.has(l)||console.warn(`[Directive] ${t} "${l}" not declared in ${s}`);for(let l of n)e.has(l)||console.warn(`[Directive] ${s}["${l}"] ${i}`);}function V(e,n){e.length===0&&console.warn("[Directive] history.snapshotEvents is an empty array \u2014 no events will create history snapshots. Omit history.snapshotEvents entirely to snapshot all events, or list specific events.");let t=new Set(Object.keys(n));for(let s of e)t.has(s)||console.warn(`[Directive] history.snapshotEvents entry "${s}" not declared in schema.events. Available events: ${[...t].join(", ")||"(none)"}`);}function ee(e,n){let t=new Set(Object.keys(n));for(let[s,i]of Object.entries(e)){let l=i;typeof l.requirement=="string"&&!t.has(l.requirement)&&console.warn(`[Directive] Resolver "${s}" references unknown requirement type "${l.requirement}". Available types: ${[...t].join(", ")||"(none)"}`);}}function ne(e,n){Z(e),n.schema?n.schema.facts||console.warn("[Directive] Module schema.facts is required"):console.warn("[Directive] Module schema is required"),b(new Set(Object.keys(n.derive??{})),new Set(Object.keys(n.schema?.derivations??{})),"Derivation","schema.derivations","has no matching implementation in derive"),b(new Set(Object.keys(n.events??{})),new Set(Object.keys(n.schema?.events??{})),"Event","schema.events","has no matching handler in events"),n.history?.snapshotEvents&&V(n.history.snapshotEvents,n.schema?.events??{}),n.resolvers&&n.schema?.requirements&&ee(n.resolvers,n.schema.requirements);}function v(e,n){f&&ne(e,n);let t="crossModuleDeps"in n?n.crossModuleDeps:void 0;return {id:e,schema:n.schema,init:n.init,derive:n.derive??{},events:n.events??{},effects:n.effects,constraints:n.constraints,resolvers:n.resolvers,hooks:n.hooks,meta:n.meta,history:n.history,crossModuleDeps:t}}function te(e){return n=>v(n,e)}function M(){let e={pending:new Map,inflight:new Map,failed:new Map,errors:new Map,listeners:new Set};function n(){for(let r of e.listeners)r();}function t(r,a){let u=r.get(a);return u||(u=new Set,r.set(a,u)),u}function s(r){let a=e.pending.get(r)??new Set,u=e.inflight.get(r)??new Set,d=e.failed.get(r)??new Set,m=e.errors.get(r)??null;return {pending:a.size,inflight:u.size,failed:d.size,isLoading:a.size>0||u.size>0,hasError:d.size>0,lastError:m}}function i(){let r=new Set([...e.pending.keys(),...e.inflight.keys(),...e.failed.keys()]),a=new Map;for(let u of r)a.set(u,s(u));return a}function l(r){return e.listeners.add(r),()=>e.listeners.delete(r)}function o(){e.pending.clear(),e.inflight.clear(),e.failed.clear(),e.errors.clear(),n();}return {plugin:{name:"requirement-status",onRequirementCreated(r){let a=r.requirement.type;t(e.pending,a).add(r.id),e.failed.get(a)?.delete(r.id),n();},onResolverStart(r,a){let u=a.requirement.type;e.pending.get(u)?.delete(a.id),t(e.inflight,u).add(a.id),n();},onResolverComplete(r,a){let u=a.requirement.type;e.inflight.get(u)?.delete(a.id),e.pending.get(u)?.delete(a.id),n();},onResolverError(r,a,u){let d=a.requirement.type;e.inflight.get(d)?.delete(a.id),t(e.failed,d).add(a.id),e.errors.set(d,u instanceof Error?u:new Error(String(u))),n();},onResolverCancel(r,a){let u=a.requirement.type;e.pending.get(u)?.delete(a.id),e.inflight.get(u)?.delete(a.id),n();},onRequirementMet(r){let a=r.requirement.type;e.pending.get(a)?.delete(r.id),e.inflight.get(a)?.delete(r.id),n();}},getStatus:s,getAllStatus:i,subscribe:l,reset:o}}function re(e){return n=>e.getStatus(n)}function se(e){let n=M(),s=[...e.plugins??[],n.plugin];return {system:a({module:e.module,plugins:s,trace:e.trace,errorBoundary:e.errorBoundary,tickMs:e.tickMs,zeroConfig:e.zeroConfig,initialFacts:e.initialFacts}),statusPlugin:n}}function D(){return {now:()=>Date.now(),setTimeout:(e,n)=>{let t=globalThis.setTimeout(e,n);return ()=>globalThis.clearTimeout(t)}}}function ie(e=0){let n=e,t=0,s=[];return {now:()=>n,setTimeout:(i,l)=>{let o={id:t++,deadlineMs:n+l,cb:i,canceled:false};return s.push(o),()=>{o.canceled=true;}},advanceBy:i=>{let l=n+i;for(;;){let o=s.filter(r=>!r.canceled&&r.deadlineMs<=l).sort((r,a)=>r.deadlineMs!==a.deadlineMs?r.deadlineMs-a.deadlineMs:r.id-a.id);if(o.length===0)break;let p=o[0];n=Math.max(n,p.deadlineMs),p.canceled=true,p.cb();}n=Math.max(n,l);}}}function ae(){return D()}function S(){return {startedAtMs:null,pausedDurationMs:0,pausedAtMs:null,status:"idle",repeats:0}}function T(e,n){return e.startedAtMs===null?0:e.status==="paused"&&e.pausedAtMs!==null?Math.max(0,e.pausedAtMs-e.startedAtMs-e.pausedDurationMs):Math.max(0,n-e.startedAtMs-e.pausedDurationMs)}function x(e,n,t){return Math.max(0,t-T(e,n))}function C(e,n){return e.status==="running"||e.status==="paused"?e:{...e,startedAtMs:n,pausedDurationMs:0,pausedAtMs:null,status:"running",repeats:0}}function k(e,n){return e.status!=="running"?e:{...e,pausedAtMs:n,status:"paused"}}function w(e,n){if(e.status!=="paused"||e.pausedAtMs===null)return e;let t=Math.max(0,n-e.pausedAtMs);return {...e,pausedDurationMs:e.pausedDurationMs+t,pausedAtMs:null,status:"running"}}function R(){return S()}function A(e){return {...e,status:"completed"}}function E(e,n){return e.startedAtMs===null||e.status==="paused"?e:{...e,startedAtMs:e.startedAtMs+n,pausedDurationMs:0,pausedAtMs:null,repeats:e.repeats+1}}function j(e,n,t){if(e.status!=="running")return {kind:"no-op"};let s=T(e,n);return t.mode==="up"?{kind:"no-op"}:t.mode==="repeat"?s>=t.ms?{kind:"repeat"}:{kind:"no-op"}:s>=t.ms?{kind:"complete"}:{kind:"no-op"}}function oe(e){return {initial:S,start:C,pause:k,resume:w,reset:R,complete:A,registerRepeat:n=>E(n,e.ms),tick:(n,t)=>j(n,t,e),elapsedMs:T,remainingMs:(n,t)=>x(n,t,e.ms)}}var fe={None:"none",Linear:"linear",Exponential:"exponential"};export{fe as Backoff,A as completeTimer,v as createModule,te as createModuleFactory,M as createRequirementStatusPlugin,re as createStatusHook,se as createSystemWithStatus,ae as defaultClock,T as elapsedMs,S as initialTimerState,k as pauseTimer,D as realClock,E as registerRepeat,x as remainingMs,R as resetTimer,w as resumeTimer,C as startTimer,Y as t,j as tickTimer,oe as timerOps,ie as virtualClock};//# sourceMappingURL=index.js.map
|
|
1
|
+
import {a}from'./chunk-LFMRWCIG.js';export{a as createSystem}from'./chunk-LFMRWCIG.js';export{b as DirectiveError,o as RequirementSet,n as forType,k as generateRequirementId,h as isNamespacedSystem,m as isRequirementType,g as isSingleModuleSystem,l as req,e as typedConstraint,f as typedResolver}from'./chunk-E2WETPLH.js';import {f}from'./chunk-FK7BD7XT.js';export{h as diffSnapshots,i as isSignedSnapshot,f as isSnapshotExpired,d as shallowEqual,j as signSnapshot,g as validateSnapshot,k as verifySnapshotSignature}from'./chunk-4CMO5OVZ.js';function h(e=[],n,t,s,i,l,o){return {_type:void 0,_validators:e,_typeName:n,_default:t,_transform:s,_description:i,_refinements:l,_meta:o,validate(p){return h([...e,p],n,t,s,i,l,o)}}}function c(e,n,t,s,i,l,o){return {...h(e,n,t,s,i,l,o),default(r){return c(e,n,r,s,i,l,o)},transform(r){return c([],n,void 0,u=>{let d=s?s(u):u;return r(d)},i,void 0,o)},brand(){return c(e,`Branded<${n}>`,t,s,i,l,o)},describe(r){return c(e,n,t,s,r,l,o)},refine(r,a){let u=[...l??[],{predicate:r,message:a}];return c([...e,r],n,t,s,i,u,o)},nullable(){return c([r=>r===null||e.every(a=>a(r))],`${n} | null`,t,s,i,void 0,o)},optional(){return c([r=>r===void 0||e.every(a=>a(r))],`${n} | undefined`,t,s,i,void 0,o)},meta(r){return c(e,n,t,s,i,l,r)}}}var X=((...e)=>{if(e.length===0)return c([],"union");let n=e.map(t=>t._typeName??"unknown");return c([t=>e.some(s=>s._validators.every(i=>i(t)))],n.join(" | "))}),Y={string(){let e=(n,t,s,i,l,o)=>({...c(n,"string",t,s,i,l,o),minLength(r){return e([...n,a=>a.length>=r],t,s,i,l,o)},maxLength(r){return e([...n,a=>a.length<=r],t,s,i,l,o)},pattern(r){return e([...n,a=>r.test(a)],t,s,i,l,o)},default(r){return e(n,r,s,i,l,o)},describe(r){return e(n,t,s,r,l,o)},refine(r,a){let u=[...l??[],{predicate:r,message:a}];return e([...n,r],t,s,i,u,o)},meta(r){return e(n,t,s,i,l,r)}});return e([n=>typeof n=="string"])},number(){let e=(n,t,s,i,l,o)=>({...c(n,"number",t,s,i,l,o),min(r){return e([...n,a=>a>=r],t,s,i,l,o)},max(r){return e([...n,a=>a<=r],t,s,i,l,o)},default(r){return e(n,r,s,i,l,o)},describe(r){return e(n,t,s,r,l,o)},refine(r,a){let u=[...l??[],{predicate:r,message:a}];return e([...n,r],t,s,i,u,o)},meta(r){return e(n,t,s,i,l,r)}});return e([n=>typeof n=="number"])},boolean(){return c([e=>typeof e=="boolean"],"boolean")},array(){let e=(n,t,s,i,l,o)=>{let p=c(n,"array",s,void 0,i,void 0,o),r=l??{value:-1};return {...p,get _lastFailedIndex(){return r.value},set _lastFailedIndex(u){r.value=u;},of(u){let d={value:-1};return e([...n,m=>{for(let g=0;g<m.length;g++)if(!u._validators.every(F=>F(m[g])))return d.value=g,false;return true}],u,s,i,d,o)},nonEmpty(){return e([...n,u=>u.length>0],t,s,i,r,o)},maxLength(u){return e([...n,d=>d.length<=u],t,s,i,r,o)},minLength(u){return e([...n,d=>d.length>=u],t,s,i,r,o)},default(u){return e(n,t,u,i,r,o)},describe(u){return e(n,t,s,u,r,o)},meta(u){return e(n,t,s,i,r,u)}}};return e([n=>Array.isArray(n)])},object(){let e=(n,t,s,i)=>({...c(n,"object",t,void 0,s,void 0,i),shape(o){return e([...n,p=>{for(let[r,a]of Object.entries(o)){let u=p[r],d=a;if(d&&!d._validators.every(m=>m(u)))return false}return true}],t,s,i)},nonNull(){return e([...n,o=>o!=null],t,s,i)},hasKeys(...o){return e([...n,p=>o.every(r=>r in p)],t,s,i)},default(o){return e(n,o,s,i)},describe(o){return e(n,t,o,i)},meta(o){return e(n,t,s,o)}});return e([n=>typeof n=="object"&&n!==null&&!Array.isArray(n)])},enum(...e){f&&e.length===0&&console.warn("[Directive] t.enum() called with no values - this will reject all strings");let n=new Set(e);return c([t=>typeof t=="string"&&n.has(t)],`enum(${e.join("|")})`)},literal(e){return c([n=>n===e],`literal(${String(e)})`)},nullable(e){let n=e._typeName??"unknown";return h([t=>t===null?true:e._validators.every(s=>s(t))],`${n} | null`)},optional(e){let n=e._typeName??"unknown";return h([t=>t===void 0?true:e._validators.every(s=>s(t))],`${n} | undefined`)},union:X,record(e){let n=e._typeName??"unknown";return c([t=>typeof t!="object"||t===null||Array.isArray(t)?false:Object.values(t).every(s=>e._validators.every(i=>i(s)))],`Record<string, ${n}>`)},tuple(...e){f&&e.length===0&&console.warn("[Directive] t.tuple() called with no types - this will only accept empty arrays");let n=e.map(t=>t._typeName??"unknown");return c([t=>!Array.isArray(t)||t.length!==e.length?false:e.every((s,i)=>s._validators.every(l=>l(t[i])))],`[${n.join(", ")}]`)},date(){return c([e=>e instanceof Date&&!Number.isNaN(e.getTime())],"Date")},uuid(){let e=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;return c([n=>typeof n=="string"&&e.test(n)],"uuid")},email(){let e=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return c([n=>typeof n=="string"&&e.test(n)],"email")},url(){return c([e=>{if(typeof e!="string")return false;try{return new URL(e),!0}catch{return false}}],"url")},bigint(){return c([e=>typeof e=="bigint"],"bigint")},any(){return c([],"any")},unknown(){return c([],"unknown")}};function Z(e){if(!e||typeof e!="string"){console.warn("[Directive] Module ID must be a non-empty string");return}/^(__[a-z][a-z0-9_-]*|[a-z][a-z0-9-]*)$/i.test(e)||console.warn(`[Directive] Module ID "${e}" should follow kebab-case convention (e.g., "my-module")`);}function b(e,n,t,s,i){for(let l of e)n.has(l)||console.warn(`[Directive] ${t} "${l}" not declared in ${s}`);for(let l of n)e.has(l)||console.warn(`[Directive] ${s}["${l}"] ${i}`);}function V(e,n){e.length===0&&console.warn("[Directive] history.snapshotEvents is an empty array \u2014 no events will create history snapshots. Omit history.snapshotEvents entirely to snapshot all events, or list specific events.");let t=new Set(Object.keys(n));for(let s of e)t.has(s)||console.warn(`[Directive] history.snapshotEvents entry "${s}" not declared in schema.events. Available events: ${[...t].join(", ")||"(none)"}`);}function ee(e,n){let t=new Set(Object.keys(n));for(let[s,i]of Object.entries(e)){let l=i;typeof l.requirement=="string"&&!t.has(l.requirement)&&console.warn(`[Directive] Resolver "${s}" references unknown requirement type "${l.requirement}". Available types: ${[...t].join(", ")||"(none)"}`);}}function ne(e,n){Z(e),n.schema?n.schema.facts||console.warn("[Directive] Module schema.facts is required"):console.warn("[Directive] Module schema is required"),b(new Set(Object.keys(n.derive??{})),new Set(Object.keys(n.schema?.derivations??{})),"Derivation","schema.derivations","has no matching implementation in derive"),b(new Set(Object.keys(n.events??{})),new Set(Object.keys(n.schema?.events??{})),"Event","schema.events","has no matching handler in events"),n.history?.snapshotEvents&&V(n.history.snapshotEvents,n.schema?.events??{}),n.resolvers&&n.schema?.requirements&&ee(n.resolvers,n.schema.requirements);}function v(e,n){f&&ne(e,n);let t="crossModuleDeps"in n?n.crossModuleDeps:void 0;return {id:e,schema:n.schema,init:n.init,derive:n.derive??{},events:n.events??{},effects:n.effects,constraints:n.constraints,resolvers:n.resolvers,hooks:n.hooks,meta:n.meta,history:n.history,crossModuleDeps:t}}function te(e){return n=>v(n,e)}function M(){let e={pending:new Map,inflight:new Map,failed:new Map,errors:new Map,listeners:new Set};function n(){for(let r of e.listeners)r();}function t(r,a){let u=r.get(a);return u||(u=new Set,r.set(a,u)),u}function s(r){let a=e.pending.get(r)??new Set,u=e.inflight.get(r)??new Set,d=e.failed.get(r)??new Set,m=e.errors.get(r)??null;return {pending:a.size,inflight:u.size,failed:d.size,isLoading:a.size>0||u.size>0,hasError:d.size>0,lastError:m}}function i(){let r=new Set([...e.pending.keys(),...e.inflight.keys(),...e.failed.keys()]),a=new Map;for(let u of r)a.set(u,s(u));return a}function l(r){return e.listeners.add(r),()=>e.listeners.delete(r)}function o(){e.pending.clear(),e.inflight.clear(),e.failed.clear(),e.errors.clear(),n();}return {plugin:{name:"requirement-status",onRequirementCreated(r){let a=r.requirement.type;t(e.pending,a).add(r.id),e.failed.get(a)?.delete(r.id),n();},onResolverStart(r,a){let u=a.requirement.type;e.pending.get(u)?.delete(a.id),t(e.inflight,u).add(a.id),n();},onResolverComplete(r,a){let u=a.requirement.type;e.inflight.get(u)?.delete(a.id),e.pending.get(u)?.delete(a.id),n();},onResolverError(r,a,u){let d=a.requirement.type;e.inflight.get(d)?.delete(a.id),t(e.failed,d).add(a.id),e.errors.set(d,u instanceof Error?u:new Error(String(u))),n();},onResolverCancel(r,a){let u=a.requirement.type;e.pending.get(u)?.delete(a.id),e.inflight.get(u)?.delete(a.id),n();},onRequirementMet(r){let a=r.requirement.type;e.pending.get(a)?.delete(r.id),e.inflight.get(a)?.delete(r.id),n();}},getStatus:s,getAllStatus:i,subscribe:l,reset:o}}function re(e){return n=>e.getStatus(n)}function se(e){let n=M(),s=[...e.plugins??[],n.plugin];return {system:a({module:e.module,plugins:s,trace:e.trace,errorBoundary:e.errorBoundary,tickMs:e.tickMs,zeroConfig:e.zeroConfig,initialFacts:e.initialFacts}),statusPlugin:n}}function D(){return {now:()=>Date.now(),setTimeout:(e,n)=>{let t=globalThis.setTimeout(e,n);return ()=>globalThis.clearTimeout(t)}}}function ie(e=0){let n=e,t=0,s=[];return {now:()=>n,setTimeout:(i,l)=>{let o={id:t++,deadlineMs:n+l,cb:i,canceled:false};return s.push(o),()=>{o.canceled=true;}},advanceBy:i=>{let l=n+i;for(;;){let o=s.filter(r=>!r.canceled&&r.deadlineMs<=l).sort((r,a)=>r.deadlineMs!==a.deadlineMs?r.deadlineMs-a.deadlineMs:r.id-a.id);if(o.length===0)break;let p=o[0];n=Math.max(n,p.deadlineMs),p.canceled=true,p.cb();}n=Math.max(n,l);}}}function ae(){return D()}function S(){return {startedAtMs:null,pausedDurationMs:0,pausedAtMs:null,status:"idle",repeats:0}}function T(e,n){return e.startedAtMs===null?0:e.status==="paused"&&e.pausedAtMs!==null?Math.max(0,e.pausedAtMs-e.startedAtMs-e.pausedDurationMs):Math.max(0,n-e.startedAtMs-e.pausedDurationMs)}function x(e,n,t){return Math.max(0,t-T(e,n))}function C(e,n){return e.status==="running"||e.status==="paused"?e:{...e,startedAtMs:n,pausedDurationMs:0,pausedAtMs:null,status:"running",repeats:0}}function k(e,n){return e.status!=="running"?e:{...e,pausedAtMs:n,status:"paused"}}function w(e,n){if(e.status!=="paused"||e.pausedAtMs===null)return e;let t=Math.max(0,n-e.pausedAtMs);return {...e,pausedDurationMs:e.pausedDurationMs+t,pausedAtMs:null,status:"running"}}function R(){return S()}function A(e){return {...e,status:"completed"}}function E(e,n){return e.startedAtMs===null||e.status==="paused"?e:{...e,startedAtMs:e.startedAtMs+n,pausedDurationMs:0,pausedAtMs:null,repeats:e.repeats+1}}function j(e,n,t){if(e.status!=="running")return {kind:"no-op"};let s=T(e,n);return t.mode==="up"?{kind:"no-op"}:t.mode==="repeat"?s>=t.ms?{kind:"repeat"}:{kind:"no-op"}:s>=t.ms?{kind:"complete"}:{kind:"no-op"}}function oe(e){return {initial:S,start:C,pause:k,resume:w,reset:R,complete:A,registerRepeat:n=>E(n,e.ms),tick:(n,t)=>j(n,t,e),elapsedMs:T,remainingMs:(n,t)=>x(n,t,e.ms)}}var fe={None:"none",Linear:"linear",Exponential:"exponential"};export{fe as Backoff,A as completeTimer,v as createModule,te as createModuleFactory,M as createRequirementStatusPlugin,re as createStatusHook,se as createSystemWithStatus,ae as defaultClock,T as elapsedMs,S as initialTimerState,k as pauseTimer,D as realClock,E as registerRepeat,x as remainingMs,R as resetTimer,w as resumeTimer,C as startTimer,Y as t,j as tickTimer,oe as timerOps,ie as virtualClock};//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/internals.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkTUS5WDVE_cjs=require('./chunk-TUS5WDVE.cjs'),chunkDDUARSUH_cjs=require('./chunk-DDUARSUH.cjs'),chunkBEJ6ICA7_cjs=require('./chunk-BEJ6ICA7.cjs');Object.defineProperty(exports,"createConstraintFactory",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.c}});Object.defineProperty(exports,"createConstraintsManager",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.p}});Object.defineProperty(exports,"createDerivationsManager",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.q}});Object.defineProperty(exports,"createDisabledHistory",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.j}});Object.defineProperty(exports,"createEffectsManager",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.r}});Object.defineProperty(exports,"createEngine",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.z}});Object.defineProperty(exports,"createErrorBoundaryManager",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.t}});Object.defineProperty(exports,"createFacts",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.w}});Object.defineProperty(exports,"createFactsProxy",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.v}});Object.defineProperty(exports,"createFactsStore",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.u}});Object.defineProperty(exports,"createHistoryManager",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.i}});Object.defineProperty(exports,"createPluginManager",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.x}});Object.defineProperty(exports,"createResolverFactory",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.d}});Object.defineProperty(exports,"createResolversManager",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.y}});Object.defineProperty(exports,"createRetryLaterManager",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.s}});Object.defineProperty(exports,"getCurrentDeps",{enumerable:true,get:function(){return chunkDDUARSUH_cjs.g}});Object.defineProperty(exports,"isTracking",{enumerable:true,get:function(){return chunkDDUARSUH_cjs.h}});Object.defineProperty(exports,"trackAccess",{enumerable:true,get:function(){return chunkDDUARSUH_cjs.k}});Object.defineProperty(exports,"withTracking",{enumerable:true,get:function(){return chunkDDUARSUH_cjs.i}});Object.defineProperty(exports,"withoutTracking",{enumerable:true,get:function(){return chunkDDUARSUH_cjs.j}});Object.defineProperty(exports,"safeStringify",{enumerable:true,get:function(){return chunkBEJ6ICA7_cjs.l}});//# sourceMappingURL=internals.cjs.map
|
|
2
2
|
//# sourceMappingURL=internals.cjs.map
|
package/dist/internals.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { X as Schema, a5 as FactsStore, F as Facts, D as DefinitionMeta, E as EffectsDef, a6 as ConstraintsDef, p as RequirementKeyFn, R as RequirementWithId, a7 as ConstraintState, a8 as ResolversDef, a9 as ResolverStatus, o as Requirement, P as Plugin, Z as System,
|
|
2
|
-
export {
|
|
3
|
-
import { b as DerivationsDef, c as DerivedValues } from './helpers-
|
|
4
|
-
export { d as DerivationState, T as TypedConstraint, e as TypedResolver, f as createConstraintFactory, g as createResolverFactory } from './helpers-
|
|
1
|
+
import { X as Schema, a5 as FactsStore, F as Facts, D as DefinitionMeta, E as EffectsDef, a6 as ConstraintsDef, p as RequirementKeyFn, R as RequirementWithId, a7 as ConstraintState, a8 as ResolversDef, a9 as ConstraintBindMode, aa as ResolverStatus, o as Requirement, P as Plugin, Z as System, ab as FactChange, w as FactsSnapshot, ac as ReconcileResult, Y as Snapshot, q as DirectiveError, ad as RecoveryStrategy, a2 as TraceEntry, ae as ErrorSource, n as ErrorBoundaryConfig, af as RetryLaterConfig, H as HistoryAPI, x as HistoryOption, _ as SystemConfig } from './plugins-Dy1C8GtT.cjs';
|
|
2
|
+
export { ag as BatchItemResult, ah as BatchResolveResults, ai as ConstraintsControl, aj as CrossModuleConstraintDef, g as CrossModuleConstraintsDef, ak as CrossModuleDerivationFn, e as CrossModuleDerivationsDef, al as CrossModuleEffectDef, f as CrossModuleEffectsDef, am as CrossModuleFactsWithSelf, an as DerivationKeys, ao as DerivationReturnType, ap as DerivationsControl, aq as DerivationsSchema, ar as DeriveAccessor, as as DispatchEventsFromSchema, r as DistributableSnapshot, s as DistributableSnapshotOptions, at as EffectCleanup, au as EffectsControl, av as EventPayloadSchema, aw as EventsAccessor, ax as EventsAccessorFromSchema, ay as EventsDef, az as EventsSchema, aA as FactKeys, aB as FactReturnType, aC as FlexibleEventHandler, aD as HistoryConfig, aE as InferEventPayloadFromSchema, aF as InferRequirementPayloadFromSchema, aG as InferSchema, aH as MutableNamespacedFacts, aI as NamespacedDerivations, aJ as NamespacedEventsAccessor, aK as NamespacedFacts, aL as ObservableKeys, aM as RequirementExplanation, aN as RequirementOutput, aO as RequirementPayloadSchema, aP as RequirementsSchema, aQ as ResolverContext, aR as ResolversControl, aS as SnapshotMeta, aT as SystemEvent, aU as TraceConfig, aV as TypedConstraintDef, b as TypedConstraintsDef, T as TypedDerivationsDef, a as TypedEventsDef, aW as TypedResolverContext, aX as TypedResolverDef, c as TypedResolversDef, aY as UnionEvents } from './plugins-Dy1C8GtT.cjs';
|
|
3
|
+
import { b as DerivationsDef, c as DerivedValues } from './helpers-BUY1lYCX.cjs';
|
|
4
|
+
export { d as DerivationState, T as TypedConstraint, e as TypedResolver, f as createConstraintFactory, g as createResolverFactory } from './helpers-BUY1lYCX.cjs';
|
|
5
5
|
export { g as safeStringify } from './utils-BnQajqPu.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -705,6 +705,28 @@ interface ResolversManager<_S extends Schema> {
|
|
|
705
705
|
*/
|
|
706
706
|
destroy(): void;
|
|
707
707
|
}
|
|
708
|
+
/**
|
|
709
|
+
* Per-constraint binding info, used by RFC-1 (resolver constraint-binding).
|
|
710
|
+
*
|
|
711
|
+
* The engine wires this lookup into the resolvers manager so that a resolver
|
|
712
|
+
* dispatched from a constraint with `bind: 'auto'` can re-evaluate the
|
|
713
|
+
* constraint's `when()` predicate live on every fact write.
|
|
714
|
+
*
|
|
715
|
+
* Returns `null` (or the lookup itself returns `undefined`) when the source
|
|
716
|
+
* constraint is unknown, async, or has `bind: 'none'` — in which case
|
|
717
|
+
* binding is a no-op and the resolver behaves exactly as before.
|
|
718
|
+
*
|
|
719
|
+
* @internal
|
|
720
|
+
*/
|
|
721
|
+
interface ConstraintBindingInfo<S extends Schema> {
|
|
722
|
+
/** The constraint's `bind` mode (effective; async predicates are forced to `'none'`). */
|
|
723
|
+
mode: ConstraintBindMode;
|
|
724
|
+
/**
|
|
725
|
+
* The constraint's `when()` predicate, narrowed to a sync signature.
|
|
726
|
+
* Only populated when `mode === 'auto'` and the constraint is sync.
|
|
727
|
+
*/
|
|
728
|
+
when: ((facts: Facts<S>) => boolean) | null;
|
|
729
|
+
}
|
|
708
730
|
/**
|
|
709
731
|
* Configuration options accepted by {@link createResolversManager}.
|
|
710
732
|
*
|
|
@@ -717,6 +739,15 @@ interface CreateResolversOptions<S extends Schema> {
|
|
|
717
739
|
facts: Facts<S>;
|
|
718
740
|
/** Underlying fact store used for `batch()` coalescing of mutations. */
|
|
719
741
|
store: FactsStore<S>;
|
|
742
|
+
/**
|
|
743
|
+
* Look up binding info for a source constraint id (RFC-1).
|
|
744
|
+
*
|
|
745
|
+
* Wired by the engine — given the `fromConstraint` of a `RequirementWithId`,
|
|
746
|
+
* returns the constraint's effective bind mode + a synchronous `when()`
|
|
747
|
+
* reference. Return `undefined` if the constraint is unknown or binding
|
|
748
|
+
* does not apply.
|
|
749
|
+
*/
|
|
750
|
+
getConstraintBinding?: (constraintId: string) => ConstraintBindingInfo<S> | undefined;
|
|
720
751
|
/** Called when a resolver begins execution. */
|
|
721
752
|
onStart?: (resolver: string, req: RequirementWithId) => void;
|
|
722
753
|
/** Called when a resolver completes successfully, with the wall-clock duration in ms. */
|
package/dist/internals.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { X as Schema, a5 as FactsStore, F as Facts, D as DefinitionMeta, E as EffectsDef, a6 as ConstraintsDef, p as RequirementKeyFn, R as RequirementWithId, a7 as ConstraintState, a8 as ResolversDef, a9 as ResolverStatus, o as Requirement, P as Plugin, Z as System,
|
|
2
|
-
export {
|
|
3
|
-
import { b as DerivationsDef, c as DerivedValues } from './helpers-
|
|
4
|
-
export { d as DerivationState, T as TypedConstraint, e as TypedResolver, f as createConstraintFactory, g as createResolverFactory } from './helpers-
|
|
1
|
+
import { X as Schema, a5 as FactsStore, F as Facts, D as DefinitionMeta, E as EffectsDef, a6 as ConstraintsDef, p as RequirementKeyFn, R as RequirementWithId, a7 as ConstraintState, a8 as ResolversDef, a9 as ConstraintBindMode, aa as ResolverStatus, o as Requirement, P as Plugin, Z as System, ab as FactChange, w as FactsSnapshot, ac as ReconcileResult, Y as Snapshot, q as DirectiveError, ad as RecoveryStrategy, a2 as TraceEntry, ae as ErrorSource, n as ErrorBoundaryConfig, af as RetryLaterConfig, H as HistoryAPI, x as HistoryOption, _ as SystemConfig } from './plugins-Dy1C8GtT.js';
|
|
2
|
+
export { ag as BatchItemResult, ah as BatchResolveResults, ai as ConstraintsControl, aj as CrossModuleConstraintDef, g as CrossModuleConstraintsDef, ak as CrossModuleDerivationFn, e as CrossModuleDerivationsDef, al as CrossModuleEffectDef, f as CrossModuleEffectsDef, am as CrossModuleFactsWithSelf, an as DerivationKeys, ao as DerivationReturnType, ap as DerivationsControl, aq as DerivationsSchema, ar as DeriveAccessor, as as DispatchEventsFromSchema, r as DistributableSnapshot, s as DistributableSnapshotOptions, at as EffectCleanup, au as EffectsControl, av as EventPayloadSchema, aw as EventsAccessor, ax as EventsAccessorFromSchema, ay as EventsDef, az as EventsSchema, aA as FactKeys, aB as FactReturnType, aC as FlexibleEventHandler, aD as HistoryConfig, aE as InferEventPayloadFromSchema, aF as InferRequirementPayloadFromSchema, aG as InferSchema, aH as MutableNamespacedFacts, aI as NamespacedDerivations, aJ as NamespacedEventsAccessor, aK as NamespacedFacts, aL as ObservableKeys, aM as RequirementExplanation, aN as RequirementOutput, aO as RequirementPayloadSchema, aP as RequirementsSchema, aQ as ResolverContext, aR as ResolversControl, aS as SnapshotMeta, aT as SystemEvent, aU as TraceConfig, aV as TypedConstraintDef, b as TypedConstraintsDef, T as TypedDerivationsDef, a as TypedEventsDef, aW as TypedResolverContext, aX as TypedResolverDef, c as TypedResolversDef, aY as UnionEvents } from './plugins-Dy1C8GtT.js';
|
|
3
|
+
import { b as DerivationsDef, c as DerivedValues } from './helpers-D6LcRum7.js';
|
|
4
|
+
export { d as DerivationState, T as TypedConstraint, e as TypedResolver, f as createConstraintFactory, g as createResolverFactory } from './helpers-D6LcRum7.js';
|
|
5
5
|
export { g as safeStringify } from './utils-BnQajqPu.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -705,6 +705,28 @@ interface ResolversManager<_S extends Schema> {
|
|
|
705
705
|
*/
|
|
706
706
|
destroy(): void;
|
|
707
707
|
}
|
|
708
|
+
/**
|
|
709
|
+
* Per-constraint binding info, used by RFC-1 (resolver constraint-binding).
|
|
710
|
+
*
|
|
711
|
+
* The engine wires this lookup into the resolvers manager so that a resolver
|
|
712
|
+
* dispatched from a constraint with `bind: 'auto'` can re-evaluate the
|
|
713
|
+
* constraint's `when()` predicate live on every fact write.
|
|
714
|
+
*
|
|
715
|
+
* Returns `null` (or the lookup itself returns `undefined`) when the source
|
|
716
|
+
* constraint is unknown, async, or has `bind: 'none'` — in which case
|
|
717
|
+
* binding is a no-op and the resolver behaves exactly as before.
|
|
718
|
+
*
|
|
719
|
+
* @internal
|
|
720
|
+
*/
|
|
721
|
+
interface ConstraintBindingInfo<S extends Schema> {
|
|
722
|
+
/** The constraint's `bind` mode (effective; async predicates are forced to `'none'`). */
|
|
723
|
+
mode: ConstraintBindMode;
|
|
724
|
+
/**
|
|
725
|
+
* The constraint's `when()` predicate, narrowed to a sync signature.
|
|
726
|
+
* Only populated when `mode === 'auto'` and the constraint is sync.
|
|
727
|
+
*/
|
|
728
|
+
when: ((facts: Facts<S>) => boolean) | null;
|
|
729
|
+
}
|
|
708
730
|
/**
|
|
709
731
|
* Configuration options accepted by {@link createResolversManager}.
|
|
710
732
|
*
|
|
@@ -717,6 +739,15 @@ interface CreateResolversOptions<S extends Schema> {
|
|
|
717
739
|
facts: Facts<S>;
|
|
718
740
|
/** Underlying fact store used for `batch()` coalescing of mutations. */
|
|
719
741
|
store: FactsStore<S>;
|
|
742
|
+
/**
|
|
743
|
+
* Look up binding info for a source constraint id (RFC-1).
|
|
744
|
+
*
|
|
745
|
+
* Wired by the engine — given the `fromConstraint` of a `RequirementWithId`,
|
|
746
|
+
* returns the constraint's effective bind mode + a synchronous `when()`
|
|
747
|
+
* reference. Return `undefined` if the constraint is unknown or binding
|
|
748
|
+
* does not apply.
|
|
749
|
+
*/
|
|
750
|
+
getConstraintBinding?: (constraintId: string) => ConstraintBindingInfo<S> | undefined;
|
|
720
751
|
/** Called when a resolver begins execution. */
|
|
721
752
|
onStart?: (resolver: string, req: RequirementWithId) => void;
|
|
722
753
|
/** Called when a resolver completes successfully, with the wall-clock duration in ms. */
|
package/dist/internals.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{c as createConstraintFactory,p as createConstraintsManager,q as createDerivationsManager,j as createDisabledHistory,r as createEffectsManager,z as createEngine,t as createErrorBoundaryManager,w as createFacts,v as createFactsProxy,u as createFactsStore,i as createHistoryManager,x as createPluginManager,d as createResolverFactory,y as createResolversManager,s as createRetryLaterManager}from'./chunk-
|
|
1
|
+
export{c as createConstraintFactory,p as createConstraintsManager,q as createDerivationsManager,j as createDisabledHistory,r as createEffectsManager,z as createEngine,t as createErrorBoundaryManager,w as createFacts,v as createFactsProxy,u as createFactsStore,i as createHistoryManager,x as createPluginManager,d as createResolverFactory,y as createResolversManager,s as createRetryLaterManager}from'./chunk-E2WETPLH.js';export{g as getCurrentDeps,h as isTracking,k as trackAccess,i as withTracking,j as withoutTracking}from'./chunk-FK7BD7XT.js';export{l as safeStringify}from'./chunk-4CMO5OVZ.js';//# sourceMappingURL=internals.js.map
|
|
2
2
|
//# sourceMappingURL=internals.js.map
|
package/dist/plugins/index.d.cts
CHANGED
package/dist/plugins/index.d.ts
CHANGED
|
@@ -268,6 +268,39 @@ type RequirementsSchema = Record<string, RequirementPayloadSchema>;
|
|
|
268
268
|
* - No requirements: `null` or `[]`
|
|
269
269
|
*/
|
|
270
270
|
type RequirementOutput$1<R extends Requirement = Requirement> = R | R[] | null;
|
|
271
|
+
/**
|
|
272
|
+
* Resolver-to-constraint binding mode (RFC-1: Resolver Constraint-Binding).
|
|
273
|
+
*
|
|
274
|
+
* Controls whether fact writes from a resolver are *bound* to the constraint
|
|
275
|
+
* that triggered them. When the binding is `'auto'`, every write performed by
|
|
276
|
+
* the resolver re-evaluates the constraint's `when()` predicate against the
|
|
277
|
+
* latest facts; if `when()` no longer holds, the write is dropped, the
|
|
278
|
+
* resolver's {@link AbortController} is aborted, and `ctx.signal.aborted`
|
|
279
|
+
* becomes `true` so the resolver can early-exit on its next checkpoint.
|
|
280
|
+
*
|
|
281
|
+
* Binding is **one-shot per resolver invocation**: once `when()` flips to
|
|
282
|
+
* `false`, the binding stays deactivated even if `when()` would later flip
|
|
283
|
+
* back to `true` mid-resolver. This prevents a resolver from "resurrecting"
|
|
284
|
+
* a stale intent after the user has moved past it.
|
|
285
|
+
*
|
|
286
|
+
* - `'none'` (default): Current behavior. Every fact write succeeds.
|
|
287
|
+
* - `'auto'`: Writes are gated by the constraint's `when()` predicate. The
|
|
288
|
+
* predicate **must be synchronous** for `bind: 'auto'`; async constraints
|
|
289
|
+
* cannot be bound (their `when()` cannot be re-evaluated cheaply on every
|
|
290
|
+
* set).
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```ts
|
|
294
|
+
* constraints: {
|
|
295
|
+
* leaveParty: {
|
|
296
|
+
* when: (f) => f.status === 'mutating',
|
|
297
|
+
* require: { type: 'EXECUTE_ACTION' },
|
|
298
|
+
* bind: 'auto', // resolver tail won't clobber `status = 'left'`
|
|
299
|
+
* },
|
|
300
|
+
* }
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
type ConstraintBindMode = "none" | "auto";
|
|
271
304
|
/** Constraint definition */
|
|
272
305
|
interface ConstraintDef<S extends Schema, R extends Requirement = Requirement> {
|
|
273
306
|
/** Priority for ordering (higher runs first) */
|
|
@@ -286,6 +319,22 @@ interface ConstraintDef<S extends Schema, R extends Requirement = Requirement> {
|
|
|
286
319
|
require: RequirementOutput$1<R> | ((facts: Facts<S>) => RequirementOutput$1<R>);
|
|
287
320
|
/** Timeout for async constraints (ms) */
|
|
288
321
|
timeout?: number;
|
|
322
|
+
/**
|
|
323
|
+
* Resolver-to-constraint binding mode (RFC-1).
|
|
324
|
+
*
|
|
325
|
+
* When `'auto'`, fact writes from the resolver triggered by this
|
|
326
|
+
* constraint are dropped (and the resolver is aborted) once `when()`
|
|
327
|
+
* flips to false. Defaults to `'none'` (current behavior preserved).
|
|
328
|
+
*
|
|
329
|
+
* **Forbidden on async constraints** (`async: true`): the binding
|
|
330
|
+
* checker re-evaluates `when()` synchronously on every fact write,
|
|
331
|
+
* which is incompatible with async predicates. Setting `bind: 'auto'`
|
|
332
|
+
* on an async constraint logs a dev-mode warning and is treated as
|
|
333
|
+
* `'none'`.
|
|
334
|
+
*
|
|
335
|
+
* @see {@link ConstraintBindMode}
|
|
336
|
+
*/
|
|
337
|
+
bind?: ConstraintBindMode;
|
|
289
338
|
/**
|
|
290
339
|
* Constraint IDs whose resolvers must complete before this constraint is evaluated.
|
|
291
340
|
* If a dependency's `when()` returns false (no requirements), this constraint proceeds.
|
|
@@ -1380,6 +1429,11 @@ interface TypedConstraintDef<M extends ModuleSchema> {
|
|
|
1380
1429
|
require: RequirementOutput<InferRequirements<M>> | ((facts: Facts<M["facts"]>) => RequirementOutput<InferRequirements<M>>);
|
|
1381
1430
|
/** Timeout for async constraints (ms) */
|
|
1382
1431
|
timeout?: number;
|
|
1432
|
+
/**
|
|
1433
|
+
* Resolver-to-constraint binding mode (RFC-1).
|
|
1434
|
+
* Defaults to `'none'`. See {@link ConstraintBindMode}.
|
|
1435
|
+
*/
|
|
1436
|
+
bind?: ConstraintBindMode;
|
|
1383
1437
|
/**
|
|
1384
1438
|
* Constraint IDs whose resolvers must complete before this constraint is evaluated.
|
|
1385
1439
|
* If a dependency's `when()` returns false (no requirements), this constraint proceeds.
|
|
@@ -1420,6 +1474,11 @@ interface CrossModuleConstraintDef<M extends ModuleSchema, Deps extends CrossMod
|
|
|
1420
1474
|
require: RequirementOutput<InferRequirements<M>> | ((facts: CrossModuleFactsWithSelf<M, Deps>) => RequirementOutput<InferRequirements<M>>);
|
|
1421
1475
|
/** Timeout for async constraints (ms) */
|
|
1422
1476
|
timeout?: number;
|
|
1477
|
+
/**
|
|
1478
|
+
* Resolver-to-constraint binding mode (RFC-1).
|
|
1479
|
+
* Defaults to `'none'`. See {@link ConstraintBindMode}.
|
|
1480
|
+
*/
|
|
1481
|
+
bind?: ConstraintBindMode;
|
|
1423
1482
|
/**
|
|
1424
1483
|
* Constraint IDs whose resolvers must complete before this constraint is evaluated.
|
|
1425
1484
|
* If a dependency's `when()` returns false (no requirements), this constraint proceeds.
|
|
@@ -2584,4 +2643,4 @@ interface Plugin<M extends ModuleSchema = ModuleSchema> {
|
|
|
2584
2643
|
onTraceComplete?: (entry: TraceEntry) => void;
|
|
2585
2644
|
}
|
|
2586
2645
|
|
|
2587
|
-
export { type SystemInspection as $, type AnySystem as A, type BatchConfig as B, type CrossModuleDeps as C, type DefinitionMeta as D, type EffectsDef as E, type Facts as F, type InferFacts as G, type HistoryAPI as H, type InferDerivations as I, type InferRequirementTypes as J, type InferRequirements as K, type InferSchemaType as L, type ModuleSchema as M, type NamespacedSystem as N, type InferSelectorState as O, type Plugin as P, type MetaAccessor as Q, type RequirementWithId as R, type SchemaType as S, type TypedDerivationsDef as T, type MetaMatch as U, type ObservationEvent as V, type RetryPolicy as W, type Schema as X, type Snapshot as Y, type System as Z, type SystemConfig as _, type TypedEventsDef as a, type SystemMode as a0, type SystemSnapshot as a1, type TraceEntry as a2, isNamespacedSystem as a3, isSingleModuleSystem as a4, type FactsStore as a5, type ConstraintsDef as a6, type ConstraintState as a7, type ResolversDef as a8, type
|
|
2646
|
+
export { type SystemInspection as $, type AnySystem as A, type BatchConfig as B, type CrossModuleDeps as C, type DefinitionMeta as D, type EffectsDef as E, type Facts as F, type InferFacts as G, type HistoryAPI as H, type InferDerivations as I, type InferRequirementTypes as J, type InferRequirements as K, type InferSchemaType as L, type ModuleSchema as M, type NamespacedSystem as N, type InferSelectorState as O, type Plugin as P, type MetaAccessor as Q, type RequirementWithId as R, type SchemaType as S, type TypedDerivationsDef as T, type MetaMatch as U, type ObservationEvent as V, type RetryPolicy as W, type Schema as X, type Snapshot as Y, type System as Z, type SystemConfig as _, type TypedEventsDef as a, type SystemMode as a0, type SystemSnapshot as a1, type TraceEntry as a2, isNamespacedSystem as a3, isSingleModuleSystem as a4, type FactsStore as a5, type ConstraintsDef as a6, type ConstraintState as a7, type ResolversDef as a8, type ConstraintBindMode as a9, type FactKeys as aA, type FactReturnType as aB, type FlexibleEventHandler as aC, type HistoryConfig as aD, type InferEventPayloadFromSchema as aE, type InferRequirementPayloadFromSchema as aF, type InferSchema as aG, type MutableNamespacedFacts as aH, type NamespacedDerivations as aI, type NamespacedEventsAccessor as aJ, type NamespacedFacts as aK, type ObservableKeys as aL, type RequirementExplanation as aM, type RequirementOutput as aN, type RequirementPayloadSchema$1 as aO, type RequirementsSchema as aP, type ResolverContext as aQ, type ResolversControl as aR, type SnapshotMeta as aS, type SystemEvent as aT, type TraceConfig as aU, type TypedConstraintDef as aV, type TypedResolverContext as aW, type TypedResolverDef as aX, type UnionEvents as aY, type RequirementOutput$1 as aZ, type ResolverStatus as aa, type FactChange as ab, type ReconcileResult as ac, type RecoveryStrategy as ad, type ErrorSource as ae, type RetryLaterConfig as af, type BatchItemResult as ag, type BatchResolveResults as ah, type ConstraintsControl as ai, type CrossModuleConstraintDef as aj, type CrossModuleDerivationFn as ak, type CrossModuleEffectDef as al, type CrossModuleFactsWithSelf as am, type DerivationKeys as an, type DerivationReturnType as ao, type DerivationsControl as ap, type DerivationsSchema as aq, type DeriveAccessor as ar, type DispatchEventsFromSchema as as, type EffectCleanup as at, type EffectsControl as au, type EventPayloadSchema as av, type EventsAccessor as aw, type EventsAccessorFromSchema as ax, type EventsDef as ay, type EventsSchema as az, type TypedConstraintsDef as b, type TypedResolversDef as c, type ModuleHooks as d, type CrossModuleDerivationsDef as e, type CrossModuleEffectsDef as f, type CrossModuleConstraintsDef as g, type ModuleDef as h, type CreateSystemOptionsSingle as i, type SingleModuleSystem as j, type ModulesMap as k, type CreateSystemOptionsNamed as l, type TraceOption as m, type ErrorBoundaryConfig as n, type Requirement as o, type RequirementKeyFn as p, DirectiveError as q, type DistributableSnapshot as r, type DistributableSnapshotOptions as s, type DynamicConstraintDef as t, type DynamicEffectDef as u, type DynamicResolverDef as v, type FactsSnapshot as w, type HistoryOption as x, type HistoryState as y, type InferEvents as z };
|
|
@@ -268,6 +268,39 @@ type RequirementsSchema = Record<string, RequirementPayloadSchema>;
|
|
|
268
268
|
* - No requirements: `null` or `[]`
|
|
269
269
|
*/
|
|
270
270
|
type RequirementOutput$1<R extends Requirement = Requirement> = R | R[] | null;
|
|
271
|
+
/**
|
|
272
|
+
* Resolver-to-constraint binding mode (RFC-1: Resolver Constraint-Binding).
|
|
273
|
+
*
|
|
274
|
+
* Controls whether fact writes from a resolver are *bound* to the constraint
|
|
275
|
+
* that triggered them. When the binding is `'auto'`, every write performed by
|
|
276
|
+
* the resolver re-evaluates the constraint's `when()` predicate against the
|
|
277
|
+
* latest facts; if `when()` no longer holds, the write is dropped, the
|
|
278
|
+
* resolver's {@link AbortController} is aborted, and `ctx.signal.aborted`
|
|
279
|
+
* becomes `true` so the resolver can early-exit on its next checkpoint.
|
|
280
|
+
*
|
|
281
|
+
* Binding is **one-shot per resolver invocation**: once `when()` flips to
|
|
282
|
+
* `false`, the binding stays deactivated even if `when()` would later flip
|
|
283
|
+
* back to `true` mid-resolver. This prevents a resolver from "resurrecting"
|
|
284
|
+
* a stale intent after the user has moved past it.
|
|
285
|
+
*
|
|
286
|
+
* - `'none'` (default): Current behavior. Every fact write succeeds.
|
|
287
|
+
* - `'auto'`: Writes are gated by the constraint's `when()` predicate. The
|
|
288
|
+
* predicate **must be synchronous** for `bind: 'auto'`; async constraints
|
|
289
|
+
* cannot be bound (their `when()` cannot be re-evaluated cheaply on every
|
|
290
|
+
* set).
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```ts
|
|
294
|
+
* constraints: {
|
|
295
|
+
* leaveParty: {
|
|
296
|
+
* when: (f) => f.status === 'mutating',
|
|
297
|
+
* require: { type: 'EXECUTE_ACTION' },
|
|
298
|
+
* bind: 'auto', // resolver tail won't clobber `status = 'left'`
|
|
299
|
+
* },
|
|
300
|
+
* }
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
type ConstraintBindMode = "none" | "auto";
|
|
271
304
|
/** Constraint definition */
|
|
272
305
|
interface ConstraintDef<S extends Schema, R extends Requirement = Requirement> {
|
|
273
306
|
/** Priority for ordering (higher runs first) */
|
|
@@ -286,6 +319,22 @@ interface ConstraintDef<S extends Schema, R extends Requirement = Requirement> {
|
|
|
286
319
|
require: RequirementOutput$1<R> | ((facts: Facts<S>) => RequirementOutput$1<R>);
|
|
287
320
|
/** Timeout for async constraints (ms) */
|
|
288
321
|
timeout?: number;
|
|
322
|
+
/**
|
|
323
|
+
* Resolver-to-constraint binding mode (RFC-1).
|
|
324
|
+
*
|
|
325
|
+
* When `'auto'`, fact writes from the resolver triggered by this
|
|
326
|
+
* constraint are dropped (and the resolver is aborted) once `when()`
|
|
327
|
+
* flips to false. Defaults to `'none'` (current behavior preserved).
|
|
328
|
+
*
|
|
329
|
+
* **Forbidden on async constraints** (`async: true`): the binding
|
|
330
|
+
* checker re-evaluates `when()` synchronously on every fact write,
|
|
331
|
+
* which is incompatible with async predicates. Setting `bind: 'auto'`
|
|
332
|
+
* on an async constraint logs a dev-mode warning and is treated as
|
|
333
|
+
* `'none'`.
|
|
334
|
+
*
|
|
335
|
+
* @see {@link ConstraintBindMode}
|
|
336
|
+
*/
|
|
337
|
+
bind?: ConstraintBindMode;
|
|
289
338
|
/**
|
|
290
339
|
* Constraint IDs whose resolvers must complete before this constraint is evaluated.
|
|
291
340
|
* If a dependency's `when()` returns false (no requirements), this constraint proceeds.
|
|
@@ -1380,6 +1429,11 @@ interface TypedConstraintDef<M extends ModuleSchema> {
|
|
|
1380
1429
|
require: RequirementOutput<InferRequirements<M>> | ((facts: Facts<M["facts"]>) => RequirementOutput<InferRequirements<M>>);
|
|
1381
1430
|
/** Timeout for async constraints (ms) */
|
|
1382
1431
|
timeout?: number;
|
|
1432
|
+
/**
|
|
1433
|
+
* Resolver-to-constraint binding mode (RFC-1).
|
|
1434
|
+
* Defaults to `'none'`. See {@link ConstraintBindMode}.
|
|
1435
|
+
*/
|
|
1436
|
+
bind?: ConstraintBindMode;
|
|
1383
1437
|
/**
|
|
1384
1438
|
* Constraint IDs whose resolvers must complete before this constraint is evaluated.
|
|
1385
1439
|
* If a dependency's `when()` returns false (no requirements), this constraint proceeds.
|
|
@@ -1420,6 +1474,11 @@ interface CrossModuleConstraintDef<M extends ModuleSchema, Deps extends CrossMod
|
|
|
1420
1474
|
require: RequirementOutput<InferRequirements<M>> | ((facts: CrossModuleFactsWithSelf<M, Deps>) => RequirementOutput<InferRequirements<M>>);
|
|
1421
1475
|
/** Timeout for async constraints (ms) */
|
|
1422
1476
|
timeout?: number;
|
|
1477
|
+
/**
|
|
1478
|
+
* Resolver-to-constraint binding mode (RFC-1).
|
|
1479
|
+
* Defaults to `'none'`. See {@link ConstraintBindMode}.
|
|
1480
|
+
*/
|
|
1481
|
+
bind?: ConstraintBindMode;
|
|
1423
1482
|
/**
|
|
1424
1483
|
* Constraint IDs whose resolvers must complete before this constraint is evaluated.
|
|
1425
1484
|
* If a dependency's `when()` returns false (no requirements), this constraint proceeds.
|
|
@@ -2584,4 +2643,4 @@ interface Plugin<M extends ModuleSchema = ModuleSchema> {
|
|
|
2584
2643
|
onTraceComplete?: (entry: TraceEntry) => void;
|
|
2585
2644
|
}
|
|
2586
2645
|
|
|
2587
|
-
export { type SystemInspection as $, type AnySystem as A, type BatchConfig as B, type CrossModuleDeps as C, type DefinitionMeta as D, type EffectsDef as E, type Facts as F, type InferFacts as G, type HistoryAPI as H, type InferDerivations as I, type InferRequirementTypes as J, type InferRequirements as K, type InferSchemaType as L, type ModuleSchema as M, type NamespacedSystem as N, type InferSelectorState as O, type Plugin as P, type MetaAccessor as Q, type RequirementWithId as R, type SchemaType as S, type TypedDerivationsDef as T, type MetaMatch as U, type ObservationEvent as V, type RetryPolicy as W, type Schema as X, type Snapshot as Y, type System as Z, type SystemConfig as _, type TypedEventsDef as a, type SystemMode as a0, type SystemSnapshot as a1, type TraceEntry as a2, isNamespacedSystem as a3, isSingleModuleSystem as a4, type FactsStore as a5, type ConstraintsDef as a6, type ConstraintState as a7, type ResolversDef as a8, type
|
|
2646
|
+
export { type SystemInspection as $, type AnySystem as A, type BatchConfig as B, type CrossModuleDeps as C, type DefinitionMeta as D, type EffectsDef as E, type Facts as F, type InferFacts as G, type HistoryAPI as H, type InferDerivations as I, type InferRequirementTypes as J, type InferRequirements as K, type InferSchemaType as L, type ModuleSchema as M, type NamespacedSystem as N, type InferSelectorState as O, type Plugin as P, type MetaAccessor as Q, type RequirementWithId as R, type SchemaType as S, type TypedDerivationsDef as T, type MetaMatch as U, type ObservationEvent as V, type RetryPolicy as W, type Schema as X, type Snapshot as Y, type System as Z, type SystemConfig as _, type TypedEventsDef as a, type SystemMode as a0, type SystemSnapshot as a1, type TraceEntry as a2, isNamespacedSystem as a3, isSingleModuleSystem as a4, type FactsStore as a5, type ConstraintsDef as a6, type ConstraintState as a7, type ResolversDef as a8, type ConstraintBindMode as a9, type FactKeys as aA, type FactReturnType as aB, type FlexibleEventHandler as aC, type HistoryConfig as aD, type InferEventPayloadFromSchema as aE, type InferRequirementPayloadFromSchema as aF, type InferSchema as aG, type MutableNamespacedFacts as aH, type NamespacedDerivations as aI, type NamespacedEventsAccessor as aJ, type NamespacedFacts as aK, type ObservableKeys as aL, type RequirementExplanation as aM, type RequirementOutput as aN, type RequirementPayloadSchema$1 as aO, type RequirementsSchema as aP, type ResolverContext as aQ, type ResolversControl as aR, type SnapshotMeta as aS, type SystemEvent as aT, type TraceConfig as aU, type TypedConstraintDef as aV, type TypedResolverContext as aW, type TypedResolverDef as aX, type UnionEvents as aY, type RequirementOutput$1 as aZ, type ResolverStatus as aa, type FactChange as ab, type ReconcileResult as ac, type RecoveryStrategy as ad, type ErrorSource as ae, type RetryLaterConfig as af, type BatchItemResult as ag, type BatchResolveResults as ah, type ConstraintsControl as ai, type CrossModuleConstraintDef as aj, type CrossModuleDerivationFn as ak, type CrossModuleEffectDef as al, type CrossModuleFactsWithSelf as am, type DerivationKeys as an, type DerivationReturnType as ao, type DerivationsControl as ap, type DerivationsSchema as aq, type DeriveAccessor as ar, type DispatchEventsFromSchema as as, type EffectCleanup as at, type EffectsControl as au, type EventPayloadSchema as av, type EventsAccessor as aw, type EventsAccessorFromSchema as ax, type EventsDef as ay, type EventsSchema as az, type TypedConstraintsDef as b, type TypedResolversDef as c, type ModuleHooks as d, type CrossModuleDerivationsDef as e, type CrossModuleEffectsDef as f, type CrossModuleConstraintsDef as g, type ModuleDef as h, type CreateSystemOptionsSingle as i, type SingleModuleSystem as j, type ModulesMap as k, type CreateSystemOptionsNamed as l, type TraceOption as m, type ErrorBoundaryConfig as n, type Requirement as o, type RequirementKeyFn as p, DirectiveError as q, type DistributableSnapshot as r, type DistributableSnapshotOptions as s, type DynamicConstraintDef as t, type DynamicEffectDef as u, type DynamicResolverDef as v, type FactsSnapshot as w, type HistoryOption as x, type HistoryState as y, type InferEvents as z };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkVSHSYVSY_cjs=require('./chunk-VSHSYVSY.cjs');require('./chunk-TUS5WDVE.cjs'),require('./chunk-DDUARSUH.cjs'),require('./chunk-BEJ6ICA7.cjs');Object.defineProperty(exports,"createSystem",{enumerable:true,get:function(){return chunkVSHSYVSY_cjs.a}});//# sourceMappingURL=system-2THXJBFM.cjs.map
|
|
2
|
+
//# sourceMappingURL=system-2THXJBFM.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"system-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"system-2THXJBFM.cjs"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"system-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"system-JIO36ALC.js"}
|