@rxova/journey-core 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -46,14 +46,14 @@ const machine = createJourneyMachine<Ctx, StepId, Event>(journey);
46
46
  The machine tracks two related collections:
47
47
 
48
48
  - `history`: ordered list of prior steps. It grows when you move to a different step.
49
- - `visited`: derived list of steps you have ever reached (including current), with duplicates removed.
49
+ - `visited`: list of steps you have reached (including current), with duplicates removed. It is not affected by history trimming.
50
50
 
51
51
  Why `visited` is a list (not a `Set`) for the following reasons:
52
52
 
53
53
  - JSON-friendly for snapshots, logs, and persistence.
54
54
  - Deterministic order for tests and UI rendering.
55
55
  - Easier to consume in TypeScript (`readonly TStepId[]`).
56
- - It is derived from `history + current`, so a list is the simplest representation.
56
+ - It is derived from `history + current` initially, then maintained independently so trimming history does not remove earlier entries.
57
57
 
58
58
  History is used when you target `HISTORY_TARGET` in a transition. It resolves to the most recent valid step in `history`. If history is empty (or contains invalid steps), the machine stays on the current step.
59
59
 
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var G=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var ee=(e,r)=>{for(var o in r)G(e,o,{get:r[o],enumerable:!0})},te=(e,r,o,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of Z(r))!j.call(e,s)&&s!==o&&G(e,s,{get:()=>r[s],enumerable:!(a=K(r,s))||a.enumerable});return e};var ne=e=>te(G({},"__esModule",{value:!0}),e);var Te={};ee(Te,{HISTORY_TARGET:()=>k,JOURNEY_ASYNC_PHASE:()=>g,JOURNEY_EVENT:()=>N,JOURNEY_STATUS:()=>x,JOURNEY_TERMINAL:()=>C,JOURNEY_WILDCARD:()=>O,createJourneyMachine:()=>Q,createPersistenceController:()=>H});module.exports=ne(Te);var C={COMPLETE:"COMPLETE",CLOSE:"CLOSE"},x={RUNNING:"running",COMPLETE:"complete",CLOSED:"closed"},k="__HISTORY__",O="*",N={GO_TO:"goTo"},g={IDLE:"idle",EVALUATING_WHEN:"evaluating-when",RUNNING_EFFECT:"running-effect",ERROR:"error"};var U=(e,r,o)=>{if(!(r in e))throw new Error(o)},re=e=>[...new Set(e)],L=e=>typeof e=="object"&&e!==null&&"then"in e&&typeof e.then=="function",Y=()=>({phase:g.IDLE,eventType:null,transitionId:null,error:null}),A=e=>({isLoading:!1,byStep:Object.fromEntries(Object.keys(e).map(o=>[o,Y()]))}),z=e=>e.type===N.GO_TO&&"to"in e,D=e=>e===C.COMPLETE||e===C.CLOSE,M=(e,r,o)=>o?{transitioned:r,transitionId:o,snapshot:e}:{transitioned:r,snapshot:e},v=(e,r,o,a,s)=>({status:a,current:e,context:r,history:o,visited:re([...o,e]),async:s}),$=(e,r)=>{let o=[...e.history];for(;o.length>0;){let a=o.pop();if(!a)break;if(a in r)return{target:a,history:o}}return{target:e.current,history:[...e.history]}},B=async(e,r,o,a)=>{for(let s of e){let y=s.from===O||s.from===r.current,f=s.event===o.type;if(!y||!f)continue;if(!s.when)return s;let u=s.when({context:r.context,from:r.current,history:r.history,event:o}),t=L(u);t&&a?.onAsyncGuardStart?.(s);let m;try{m=await u}catch(T){throw t&&a?.onAsyncGuardError?.(s,T),T}if(t&&a?.onAsyncGuardSuccess?.(s),m)return s}return null},V=(e,r,o)=>{let a=r===e.current?[...e.history]:[...e.history,e.current];return v(r,o,a,e.status,e.async)};var q=e=>typeof e=="object"&&e!==null,oe=e=>e===x.RUNNING||e===x.COMPLETE||e===x.CLOSED,se=()=>{let e=globalThis.localStorage;return!e||typeof e.getItem!="function"||typeof e.setItem!="function"||typeof e.removeItem!="function"?null:e},ie=e=>{if(!e)return null;let r=e.storage??se();return r?{key:e.key,storage:r,version:e.version??1,clearOnReset:e.clearOnReset??!0,serialize:e.serialize??JSON.stringify,deserialize:e.deserialize??JSON.parse,...e.migrate?{migrate:e.migrate}:{},...e.onError?{onError:e.onError}:{}}:null},W=(e,r,o)=>{if(!q(e))return null;let a=e.current;if(typeof a!="string"||!(a in r))return null;let s=a,y=Array.isArray(e.history)?e.history.filter(u=>typeof u=="string"&&u in r):[],f=oe(e.status)?e.status:x.RUNNING;return{current:s,context:"context"in e?e.context:o,history:y,status:f}},H=e=>{let{initial:r,context:o,steps:a,options:s}=e,y=ie(s?.persistence),f=T=>{y?.onError?.(T)},u=T=>{if(y)try{let E={version:y.version,snapshot:{current:T.current,context:T.context,history:[...T.history],status:T.status}};y.storage.setItem(y.key,y.serialize(E))}catch(E){f(E)}},t=()=>{if(y)try{y.storage.removeItem(y.key)}catch(T){f(T)}},m=()=>{let T=v(r,o,[],x.RUNNING,A(a));if(!y)return T;try{let E=y.storage.getItem(y.key);if(!E)return T;let c=y.deserialize(E);if(!q(c))return T;let w=c.version;if(typeof w!="number")return T;let J=null,_=!1;if(w===y.version)J=W(c.snapshot,a,o);else if(y.migrate){let b=y.migrate(c.snapshot,w);J=W(b,a,o),_=J!==null}if(!J)return T;let h=v(J.current,J.context,J.history,J.status,A(a));return _&&u(h),h}catch(E){return f(E),T}};return{clearOnReset:y?.clearOnReset??!0,hydrateSnapshot:m,persistSnapshot:u,removePersistedSnapshot:t}};var ae=50,ye=e=>e===null?null:typeof e=="number"&&Number.isFinite(e)?Math.max(0,Math.trunc(e)):ae,pe=(e,r)=>{if(r===null||e.length<=r)return{next:[...e],trimmed:[]};let o=e.length-r;return{next:e.slice(o),trimmed:e.slice(0,o)}},Q=(e,r)=>{if(!e.steps||typeof e.steps!="object")throw new Error("Journey steps must be a record object.");if(!Array.isArray(e.transitions))throw new Error("Journey transitions must be an array.");U(e.steps,e.initial,`Journey initial step "${e.initial}" does not exist in steps registry.`);for(let[n,i]of e.transitions.entries()){if(!i||typeof i!="object")throw new Error(`Journey transition at index ${n} must be an object.`);if(typeof i.from!="string"||typeof i.event!="string")throw new Error(`Journey transition at index ${n} must define string "from" and "event".`);if(i.from!==O&&!(i.from in e.steps))throw new Error(`Journey transition at index ${n} references unknown from step "${i.from}".`);if(i.to!==k&&!D(i.to)&&!(i.to in e.steps))throw new Error(`Journey transition at index ${n} points to unknown step "${i.to}".`)}let{clearOnReset:o,hydrateSnapshot:a,persistSnapshot:s,removePersistedSnapshot:y}=H({initial:e.initial,context:e.context,steps:e.steps,...r?{options:r}:{}}),f=r?.history,u=(n,i,S)=>{let p=ye(S??f?.maxHistory),{next:d,trimmed:I}=pe(n.history,p);if(I.length===0)return{snapshot:n,trimmed:I,maxHistory:p};let R=v(n.current,n.context,d,n.status,n.async);return f?.onOverflow?.({previous:n.history,next:d,trimmed:I,maxHistory:p,reason:i}),{snapshot:R,trimmed:I,maxHistory:p}},t=a(),m=u(t,"hydrate");t=m.snapshot,m.trimmed.length>0&&s(t);let T=new Set,E=Promise.resolve();t={...t,async:A(e.steps)};let c=()=>{for(let n of T)n()},w=n=>n===g.EVALUATING_WHEN||n===g.RUNNING_EFFECT,J=(n,i)=>{let S=t.async.byStep[n]??Y(),p=i(S);if(S.phase===p.phase&&S.eventType===p.eventType&&S.transitionId===p.transitionId&&S.error===p.error)return;let d={...t.async.byStep,[n]:p},I=Object.values(d).some(R=>w(R.phase));t={...t,async:{isLoading:I,byStep:d}},c()},_=(n,i,S,p)=>{J(n,()=>({phase:i,eventType:S,transitionId:p??null,error:null}))},h=n=>{J(n,()=>Y())},b=(n,i,S,p)=>{J(n,()=>({phase:g.ERROR,eventType:i,transitionId:p??null,error:S}))};return{getSnapshot:()=>t,subscribe:n=>(T.add(n),()=>{T.delete(n)}),reset:()=>(t=v(e.initial,e.context,[],x.RUNNING,A(e.steps)),o?y():s(t),c(),t),updateContext:n=>(t={...t,context:n(t.context)},s(t),c(),t),clearStepError:n=>{let i=n??t.current;return i in e.steps&&h(i),t},trimHistory:n=>{let i=u(t,"manual",n);return i.trimmed.length===0||(t=i.snapshot,s(t),c()),t},clearHistory:()=>(t.history.length===0||(t=v(t.current,t.context,[],t.status,t.async),s(t),c()),t),send:n=>{let i=async()=>{if(t.status!==x.RUNNING)return{transitioned:!1,snapshot:t};let p=t.current;if(z(n))return U(e.steps,n.to,`Cannot goTo unknown step "${n.to}".`),h(p),t=V(t,n.to,t.context),t=u(t,"auto").snapshot,s(t),c(),M(t,!0,N.GO_TO);let d;try{d=await B(e.transitions,t,n,{onAsyncGuardStart:l=>{_(p,g.EVALUATING_WHEN,n.type,l.id)},onAsyncGuardSuccess:()=>{h(p)},onAsyncGuardError:(l,P)=>{b(p,n.type,P,l.id)}})}catch(l){throw b(p,n.type,l),l}if(!d)return M(t,!1);let I=t.context;if(d.effect){let l=d.effect({context:t.context,from:t.current,history:t.history,event:n});L(l)&&_(p,g.RUNNING_EFFECT,n.type,d.id);let P;try{P=await l}catch(F){throw b(p,n.type,F,d.id),F}P!==void 0&&(I=P)}if(h(p),D(d.to))return t={...t,context:I,status:d.to===C.COMPLETE?x.COMPLETE:x.CLOSED},t=u(t,"auto").snapshot,s(t),c(),M(t,!0,d.id);if(d.to===k){let{target:l,history:P}=$(t,e.steps);return U(e.steps,l,`Transition points to unknown step "${l}".`),t=v(l,I,P,t.status,t.async),t=u(t,"auto").snapshot,s(t),c(),M(t,!0,d.id)}let R=d.to;U(e.steps,R,`Transition points to unknown step "${R}".`);let X=V(t,R,I);return t=u(X,"auto").snapshot,s(t),c(),M(t,!0,d.id)},S=E.then(i,i);return E=S.then(()=>{},()=>{}),S}}};0&&(module.exports={HISTORY_TARGET,JOURNEY_ASYNC_PHASE,JOURNEY_EVENT,JOURNEY_STATUS,JOURNEY_TERMINAL,JOURNEY_WILDCARD,createJourneyMachine,createPersistenceController});
1
+ "use strict";var L=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var ne=(e,n)=>{for(var s in n)L(e,s,{get:n[s],enumerable:!0})},oe=(e,n,s,y)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of ee(n))!te.call(e,r)&&r!==s&&L(e,r,{get:()=>n[r],enumerable:!(y=j(n,r))||y.enumerable});return e};var re=e=>oe(L({},"__esModule",{value:!0}),e);var ue={};ne(ue,{HISTORY_TARGET:()=>k,JOURNEY_ASYNC_PHASE:()=>g,JOURNEY_EVENT:()=>w,JOURNEY_STATUS:()=>J,JOURNEY_TERMINAL:()=>O,JOURNEY_WILDCARD:()=>A,createJourneyMachine:()=>K,createPersistenceController:()=>G});module.exports=re(ue);var O={COMPLETE:"COMPLETE",CLOSE:"CLOSE"},J={RUNNING:"running",COMPLETE:"complete",CLOSED:"closed"},k="__HISTORY__",A="*",w={GO_TO:"goTo"},g={IDLE:"idle",EVALUATING_WHEN:"evaluating-when",RUNNING_EFFECT:"running-effect",ERROR:"error"};var U=(e,n,s)=>{if(!(n in e))throw new Error(s)},se=e=>[...new Set(e)],V=(e,n)=>se([...e,n]),D=(e,n)=>e.includes(n)?[...e]:[...e,n],F=e=>typeof e=="object"&&e!==null&&"then"in e&&typeof e.then=="function",H=()=>({phase:g.IDLE,eventType:null,transitionId:null,error:null}),M=e=>({isLoading:!1,byStep:Object.fromEntries(Object.keys(e).map(s=>[s,H()]))}),$=e=>e.type===w.GO_TO&&"to"in e,z=e=>e===O.COMPLETE||e===O.CLOSE,b=(e,n,s)=>s?{transitioned:n,transitionId:s,snapshot:e}:{transitioned:n,snapshot:e},h=(e,n,s,y,r,p)=>({status:y,current:e,context:n,history:s,visited:p?[...p]:V(s,e),async:r}),W=(e,n)=>{let s=[...e.history];for(;s.length>0;){let y=s.pop();if(!y)break;if(y in n)return{target:y,history:s}}return{target:e.current,history:[...e.history]}},q=async(e,n,s,y)=>{for(let r of e){let p=r.from===A||r.from===n.current,f=r.event===s.type;if(!p||!f)continue;if(!r.when)return r;let u=r.when({context:n.context,from:n.current,history:n.history,event:s}),t=F(u);t&&y?.onAsyncGuardStart?.(r);let v;try{v=await u}catch(i){throw t&&y?.onAsyncGuardError?.(r,i),i}if(t&&y?.onAsyncGuardSuccess?.(r),v)return r}return null},B=(e,n,s)=>{let y=n===e.current?[...e.history]:[...e.history,e.current],r=D(e.visited,n);return h(n,s,y,e.status,e.async,r)};var X=e=>typeof e=="object"&&e!==null,ie=e=>e===J.RUNNING||e===J.COMPLETE||e===J.CLOSED,ae=()=>{let e=globalThis.localStorage;return!e||typeof e.getItem!="function"||typeof e.setItem!="function"||typeof e.removeItem!="function"?null:e},pe=e=>{if(!e)return null;let n=e.storage??ae();return n?{key:e.key,storage:n,version:e.version??1,clearOnReset:e.clearOnReset??!0,serialize:e.serialize??JSON.stringify,deserialize:e.deserialize??JSON.parse,...e.migrate?{migrate:e.migrate}:{},...e.onError?{onError:e.onError}:{}}:null},Q=(e,n,s)=>{if(!X(e))return null;let y=e.current;if(typeof y!="string"||!(y in n))return null;let r=y,p=Array.isArray(e.history)?e.history.filter(i=>typeof i=="string"&&i in n):[],f=ie(e.status)?e.status:J.RUNNING,u=Array.isArray(e.visited)?e.visited.filter(i=>typeof i=="string"&&i in n):null,t=u&&u.length>0?u:V(p,r),v=!u||u.length===0;return{snapshot:{current:r,context:"context"in e?e.context:s,history:p,status:f,visited:t},needsRewrite:v}},G=e=>{let{initial:n,context:s,steps:y,options:r}=e,p=pe(r?.persistence),f=i=>{p?.onError?.(i)},u=i=>{if(p)try{let E={version:p.version,snapshot:{current:i.current,context:i.context,history:[...i.history],status:i.status,visited:[...i.visited]}};p.storage.setItem(p.key,p.serialize(E))}catch(E){f(E)}},t=()=>{if(p)try{p.storage.removeItem(p.key)}catch(i){f(i)}},v=()=>{let i=h(n,s,[],J.RUNNING,M(y));if(!p)return i;try{let E=p.storage.getItem(p.key);if(!E)return i;let c=p.deserialize(E);if(!X(c))return i;let _=c.version;if(typeof _!="number")return i;let x=null,N=!1;if(_===p.version){let m=Q(c.snapshot,y,s);x=m?.snapshot??null,N=!!m?.needsRewrite}else if(p.migrate){let m=p.migrate(c.snapshot,_);x=Q(m,y,s)?.snapshot??null,N=x!==null}if(!x)return i;let R=h(x.current,x.context,x.history,x.status,M(y),x.visited);return N&&u(R),R}catch(E){return f(E),i}};return{clearOnReset:p?.clearOnReset??!0,hydrateSnapshot:v,persistSnapshot:u,removePersistedSnapshot:t}};var ye=50,de=e=>e===null?null:typeof e=="number"&&Number.isFinite(e)?Math.max(0,Math.trunc(e)):ye,Te=(e,n)=>{if(n===null||e.length<=n)return{next:[...e],trimmed:[]};let s=e.length-n;return{next:e.slice(s),trimmed:e.slice(0,s)}},K=(e,n)=>{if(!e.steps||typeof e.steps!="object")throw new Error("Journey steps must be a record object.");if(!Array.isArray(e.transitions))throw new Error("Journey transitions must be an array.");U(e.steps,e.initial,`Journey initial step "${e.initial}" does not exist in steps registry.`);for(let[o,a]of e.transitions.entries()){if(!a||typeof a!="object")throw new Error(`Journey transition at index ${o} must be an object.`);if(typeof a.from!="string"||typeof a.event!="string")throw new Error(`Journey transition at index ${o} must define string "from" and "event".`);if(a.from!==A&&!(a.from in e.steps))throw new Error(`Journey transition at index ${o} references unknown from step "${a.from}".`);if(a.to!==k&&!z(a.to)&&!(a.to in e.steps))throw new Error(`Journey transition at index ${o} points to unknown step "${a.to}".`)}let{clearOnReset:s,hydrateSnapshot:y,persistSnapshot:r,removePersistedSnapshot:p}=G({initial:e.initial,context:e.context,steps:e.steps,...n?{options:n}:{}}),f=n?.history,u=(o,a,S)=>{let d=de(S??f?.maxHistory),{next:T,trimmed:I}=Te(o.history,d);if(I.length===0)return{snapshot:o,trimmed:I,maxHistory:d};let P=h(o.current,o.context,T,o.status,o.async,o.visited);return f?.onOverflow?.({previous:o.history,next:T,trimmed:I,maxHistory:d,reason:a}),{snapshot:P,trimmed:I,maxHistory:d}},t=y(),v=u(t,"hydrate");t=v.snapshot,v.trimmed.length>0&&r(t);let i=new Set,E=Promise.resolve();t={...t,async:M(e.steps)};let c=()=>{for(let o of i)o()},_=o=>o===g.EVALUATING_WHEN||o===g.RUNNING_EFFECT,x=(o,a)=>{let S=t.async.byStep[o]??H(),d=a(S);if(S.phase===d.phase&&S.eventType===d.eventType&&S.transitionId===d.transitionId&&S.error===d.error)return;let T={...t.async.byStep,[o]:d},I=Object.values(T).some(P=>_(P.phase));t={...t,async:{isLoading:I,byStep:T}},c()},N=(o,a,S,d)=>{x(o,()=>({phase:a,eventType:S,transitionId:d??null,error:null}))},R=o=>{x(o,()=>H())},m=(o,a,S,d)=>{x(o,()=>({phase:g.ERROR,eventType:a,transitionId:d??null,error:S}))};return{getSnapshot:()=>t,subscribe:o=>(i.add(o),()=>{i.delete(o)}),reset:()=>(t=h(e.initial,e.context,[],J.RUNNING,M(e.steps)),s?p():r(t),c(),t),updateContext:o=>(t={...t,context:o(t.context)},r(t),c(),t),clearStepError:o=>{let a=o??t.current;return a in e.steps&&R(a),t},trimHistory:o=>{let a=u(t,"manual",o);return a.trimmed.length===0||(t=a.snapshot,r(t),c()),t},clearHistory:()=>(t.history.length===0||(t=h(t.current,t.context,[],t.status,t.async,t.visited),r(t),c()),t),send:o=>{let a=async()=>{if(t.status!==J.RUNNING)return{transitioned:!1,snapshot:t};let d=t.current;if($(o))return U(e.steps,o.to,`Cannot goTo unknown step "${o.to}".`),R(d),t=B(t,o.to,t.context),t=u(t,"auto").snapshot,r(t),c(),b(t,!0,w.GO_TO);let T;try{T=await q(e.transitions,t,o,{onAsyncGuardStart:l=>{N(d,g.EVALUATING_WHEN,o.type,l.id)},onAsyncGuardSuccess:()=>{R(d)},onAsyncGuardError:(l,C)=>{m(d,o.type,C,l.id)}})}catch(l){throw m(d,o.type,l),l}if(!T)return b(t,!1);let I=t.context;if(T.effect){let l=T.effect({context:t.context,from:t.current,history:t.history,event:o});F(l)&&N(d,g.RUNNING_EFFECT,o.type,T.id);let C;try{C=await l}catch(Y){throw m(d,o.type,Y,T.id),Y}C!==void 0&&(I=C)}if(R(d),z(T.to))return t={...t,context:I,status:T.to===O.COMPLETE?J.COMPLETE:J.CLOSED},t=u(t,"auto").snapshot,r(t),c(),b(t,!0,T.id);if(T.to===k){let{target:l,history:C}=W(t,e.steps);U(e.steps,l,`Transition points to unknown step "${l}".`);let Y=D(t.visited,l);return t=h(l,I,C,t.status,t.async,Y),t=u(t,"auto").snapshot,r(t),c(),b(t,!0,T.id)}let P=T.to;U(e.steps,P,`Transition points to unknown step "${P}".`);let Z=B(t,P,I);return t=u(Z,"auto").snapshot,r(t),c(),b(t,!0,T.id)},S=E.then(a,a);return E=S.then(()=>{},()=>{}),S}}};0&&(module.exports={HISTORY_TARGET,JOURNEY_ASYNC_PHASE,JOURNEY_EVENT,JOURNEY_STATUS,JOURNEY_TERMINAL,JOURNEY_WILDCARD,createJourneyMachine,createPersistenceController});
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts", "../src/types.ts", "../src/machine-helpers.ts", "../src/persistence.ts", "../src/machine.ts"],
4
- "sourcesContent": ["export { createJourneyMachine } from \"./machine\";\nexport { createPersistenceController } from \"./persistence\";\nexport {\n JOURNEY_EVENT,\n JOURNEY_ASYNC_PHASE,\n JOURNEY_STATUS,\n JOURNEY_WILDCARD,\n HISTORY_TARGET,\n JOURNEY_TERMINAL,\n type JourneyBuiltInEvent,\n type JourneyBuiltInFrom,\n type JourneyAsyncPhase,\n type JourneyStatus,\n type JourneyAsyncState,\n type JourneyStepAsyncState,\n type JourneyEvent,\n type JourneyEventPayloadMap,\n type JourneyDefinition,\n type JourneyHistoryOptions,\n type JourneyHistoryOverflow,\n type JourneyHistoryOverflowReason,\n type JourneyMachineOptions,\n type JourneyGoToEvent,\n type JourneyMachine,\n type JourneyPayloadFor,\n type JourneyPersistedSnapshot,\n type JourneyPersistedState,\n type JourneyPersistenceOptions,\n type JourneyStorage,\n type JourneySendResult,\n type JourneySnapshot,\n type JourneyTerminal,\n type JourneyTransition,\n type JourneyTransitionArgs,\n type JourneyTransitionTarget\n} from \"./types\";\n", "export const JOURNEY_TERMINAL = {\n COMPLETE: \"COMPLETE\",\n CLOSE: \"CLOSE\"\n} as const;\n\nexport type JourneyTerminal = (typeof JOURNEY_TERMINAL)[keyof typeof JOURNEY_TERMINAL];\n\nexport const JOURNEY_STATUS = {\n RUNNING: \"running\",\n COMPLETE: \"complete\",\n CLOSED: \"closed\"\n} as const;\n\nexport type JourneyStatus = (typeof JOURNEY_STATUS)[keyof typeof JOURNEY_STATUS];\n\nexport const HISTORY_TARGET = \"__HISTORY__\" as const;\nexport const JOURNEY_WILDCARD = \"*\" as const;\n\nexport const JOURNEY_EVENT = {\n GO_TO: \"goTo\"\n} as const;\n\nexport type JourneyBuiltInEvent = (typeof JOURNEY_EVENT)[keyof typeof JOURNEY_EVENT];\nexport type JourneyBuiltInFrom = typeof JOURNEY_WILDCARD;\n\nexport const JOURNEY_ASYNC_PHASE = {\n IDLE: \"idle\",\n EVALUATING_WHEN: \"evaluating-when\",\n RUNNING_EFFECT: \"running-effect\",\n ERROR: \"error\"\n} as const;\n\nexport type JourneyAsyncPhase = (typeof JOURNEY_ASYNC_PHASE)[keyof typeof JOURNEY_ASYNC_PHASE];\n\nexport type JourneyStepAsyncState = {\n phase: JourneyAsyncPhase;\n eventType: string | null;\n transitionId: string | null;\n error: unknown | null;\n};\n\nexport type JourneyAsyncState<TStepId extends string> = {\n isLoading: boolean;\n byStep: Record<TStepId, JourneyStepAsyncState>;\n};\n\nexport type JourneyBaseEvent = {\n type: string;\n payload?: unknown;\n};\n\nexport type JourneyEventPayloadMap<TEventType extends string> = Partial<\n Record<TEventType | JourneyBuiltInEvent, unknown>\n>;\n\nexport type JourneyPayloadFor<\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType>,\n TEvent extends TEventType | JourneyBuiltInEvent\n> = TEvent extends keyof TPayloadMap ? TPayloadMap[TEvent] : unknown;\n\nexport type JourneyGoToEvent<TStepId extends string, TPayload = unknown> = {\n type: (typeof JOURNEY_EVENT)[\"GO_TO\"];\n to: TStepId;\n payload?: TPayload;\n};\n\nexport type JourneyEvent<\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> =\n | JourneyGoToEvent<\n TStepId,\n JourneyPayloadFor<TEventType, TPayloadMap, (typeof JOURNEY_EVENT)[\"GO_TO\"]>\n >\n | {\n [TType in TEventType]: {\n type: TType;\n payload?: JourneyPayloadFor<TEventType, TPayloadMap, TType>;\n };\n }[TEventType];\n\nexport type JourneyTransitionArgs<\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> = {\n context: TContext;\n from: TStepId;\n history: readonly TStepId[];\n event: JourneyEvent<TStepId, TEventType, TPayloadMap>;\n};\n\nexport type JourneyTransitionTarget<TStepId extends string> =\n | TStepId\n | JourneyTerminal\n | typeof HISTORY_TARGET;\n\nexport type JourneyTransition<\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> = {\n id?: string;\n from: TStepId | JourneyBuiltInFrom;\n event: TEventType | (typeof JOURNEY_EVENT)[\"GO_TO\"];\n to: JourneyTransitionTarget<TStepId>;\n when?: (\n args: JourneyTransitionArgs<TContext, TStepId, TEventType, TPayloadMap>\n ) => boolean | Promise<boolean>;\n effect?: (\n args: JourneyTransitionArgs<TContext, TStepId, TEventType, TPayloadMap>\n ) => TContext | void | Promise<TContext | void>;\n};\n\nexport type JourneySnapshot<TContext, TStepId extends string> = {\n current: TStepId;\n context: TContext;\n history: readonly TStepId[];\n visited: readonly TStepId[];\n status: JourneyStatus;\n async: JourneyAsyncState<TStepId>;\n};\n\nexport type JourneyPersistedSnapshot<TContext, TStepId extends string> = {\n current: TStepId;\n context: TContext;\n history: readonly TStepId[];\n status: JourneyStatus;\n};\n\nexport type JourneyPersistedState<TContext, TStepId extends string> = {\n version: number;\n snapshot: JourneyPersistedSnapshot<TContext, TStepId>;\n};\n\nexport type JourneyHistoryOverflowReason = \"auto\" | \"hydrate\" | \"manual\";\n\nexport type JourneyHistoryOverflow<TStepId extends string> = {\n previous: readonly TStepId[];\n next: readonly TStepId[];\n trimmed: readonly TStepId[];\n maxHistory: number | null;\n reason: JourneyHistoryOverflowReason;\n};\n\nexport type JourneyHistoryOptions<TStepId extends string> = {\n maxHistory?: number | null;\n onOverflow?: (info: JourneyHistoryOverflow<TStepId>) => void;\n};\n\nexport type JourneyStorage = {\n getItem: (key: string) => string | null;\n setItem: (key: string, value: string) => void;\n removeItem: (key: string) => void;\n};\n\nexport type JourneyPersistenceOptions<TContext, TStepId extends string> = {\n key: string;\n storage?: JourneyStorage;\n version?: number;\n clearOnReset?: boolean;\n serialize?: (value: JourneyPersistedState<TContext, TStepId>) => string;\n deserialize?: (value: string) => unknown;\n migrate?: (\n value: unknown,\n persistedVersion: number\n ) => JourneyPersistedSnapshot<TContext, TStepId>;\n onError?: (error: unknown) => void;\n};\n\nexport type JourneyDefinition<\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> = {\n initial: TStepId;\n context: TContext;\n steps: Record<TStepId, unknown>;\n transitions: readonly JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>[];\n};\n\nexport type JourneyMachineOptions<TContext, TStepId extends string> = {\n persistence?: JourneyPersistenceOptions<TContext, TStepId>;\n history?: JourneyHistoryOptions<TStepId>;\n};\n\nexport type JourneySendResult<TContext, TStepId extends string> = {\n transitioned: boolean;\n transitionId?: string;\n snapshot: JourneySnapshot<TContext, TStepId>;\n};\n\nexport type JourneyMachine<\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> = {\n getSnapshot: () => JourneySnapshot<TContext, TStepId>;\n send: (\n event: JourneyEvent<TStepId, TEventType, TPayloadMap>\n ) => Promise<JourneySendResult<TContext, TStepId>>;\n updateContext: (updater: (context: TContext) => TContext) => JourneySnapshot<TContext, TStepId>;\n clearStepError: (stepId?: TStepId) => JourneySnapshot<TContext, TStepId>;\n reset: () => JourneySnapshot<TContext, TStepId>;\n trimHistory: (maxHistory?: number | null) => JourneySnapshot<TContext, TStepId>;\n clearHistory: () => JourneySnapshot<TContext, TStepId>;\n subscribe: (listener: () => void) => () => void;\n};\n", "import { JOURNEY_ASYNC_PHASE, JOURNEY_EVENT, JOURNEY_TERMINAL, JOURNEY_WILDCARD } from \"./types\";\nimport type {\n JourneyAsyncState,\n JourneyEvent,\n JourneyEventPayloadMap,\n JourneyGoToEvent,\n JourneyPayloadFor,\n JourneySendResult,\n JourneySnapshot,\n JourneyStatus,\n JourneyStepAsyncState,\n JourneyTerminal,\n JourneyTransition\n} from \"./types\";\n\nexport const assertStepExists = <TStepId extends string>(\n steps: Record<TStepId, unknown>,\n stepId: TStepId,\n message: string\n) => {\n if (!(stepId in steps)) {\n throw new Error(message);\n }\n};\n\nconst unique = <T>(items: readonly T[]): T[] => [...new Set(items)];\n\nexport const isPromiseLike = <T>(value: T | PromiseLike<T>): value is PromiseLike<T> =>\n typeof value === \"object\" &&\n value !== null &&\n \"then\" in value &&\n typeof (value as { then: unknown }).then === \"function\";\n\nexport const buildIdleStepAsyncState = (): JourneyStepAsyncState => ({\n phase: JOURNEY_ASYNC_PHASE.IDLE,\n eventType: null,\n transitionId: null,\n error: null\n});\n\nexport const buildInitialAsyncState = <TStepId extends string>(\n steps: Record<TStepId, unknown>\n): JourneyAsyncState<TStepId> => {\n const byStep = Object.fromEntries(\n Object.keys(steps).map((stepId) => [stepId, buildIdleStepAsyncState()])\n ) as Record<TStepId, JourneyStepAsyncState>;\n\n return {\n isLoading: false,\n byStep\n };\n};\n\nexport const isGoToEvent = <\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType>\n>(\n event: JourneyEvent<TStepId, TEventType, TPayloadMap>\n): event is JourneyGoToEvent<\n TStepId,\n JourneyPayloadFor<TEventType, TPayloadMap, (typeof JOURNEY_EVENT)[\"GO_TO\"]>\n> => event.type === JOURNEY_EVENT.GO_TO && \"to\" in event;\n\nexport const isTerminalTarget = <TStepId extends string>(\n target: TStepId | JourneyTerminal | \"__HISTORY__\"\n): target is JourneyTerminal =>\n target === JOURNEY_TERMINAL.COMPLETE || target === JOURNEY_TERMINAL.CLOSE;\n\nexport const buildSendResult = <TContext, TStepId extends string>(\n snapshot: JourneySnapshot<TContext, TStepId>,\n transitioned: boolean,\n transitionId?: string\n): JourneySendResult<TContext, TStepId> =>\n transitionId ? { transitioned, transitionId, snapshot } : { transitioned, snapshot };\n\nexport const buildSnapshot = <TContext, TStepId extends string>(\n current: TStepId,\n context: TContext,\n history: readonly TStepId[],\n status: JourneyStatus,\n asyncState: JourneyAsyncState<TStepId>\n): JourneySnapshot<TContext, TStepId> => ({\n status,\n current,\n context,\n history,\n visited: unique([...history, current]),\n async: asyncState\n});\n\nexport const resolveHistoryTarget = <TContext, TStepId extends string>(\n snapshot: JourneySnapshot<TContext, TStepId>,\n steps: Record<TStepId, unknown>\n): { target: TStepId; history: TStepId[] } => {\n const cloned = [...snapshot.history];\n\n while (cloned.length > 0) {\n const candidate = cloned.pop();\n if (!candidate) {\n break;\n }\n if (candidate in steps) {\n return {\n target: candidate,\n history: cloned\n };\n }\n }\n\n return {\n target: snapshot.current,\n history: [...snapshot.history]\n };\n};\n\nexport const selectTransition = async <\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType>\n>(\n transitions: readonly JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>[],\n snapshot: JourneySnapshot<TContext, TStepId>,\n event: JourneyEvent<TStepId, TEventType, TPayloadMap>,\n hooks?: {\n onAsyncGuardStart?: (\n transition: JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>\n ) => void;\n onAsyncGuardSuccess?: (\n transition: JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>\n ) => void;\n onAsyncGuardError?: (\n transition: JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>,\n error: unknown\n ) => void;\n }\n): Promise<JourneyTransition<TContext, TStepId, TEventType, TPayloadMap> | null> => {\n for (const transition of transitions) {\n const fromMatches =\n transition.from === JOURNEY_WILDCARD || transition.from === snapshot.current;\n const eventMatches = transition.event === event.type;\n\n if (!fromMatches || !eventMatches) {\n continue;\n }\n\n if (!transition.when) {\n return transition;\n }\n\n const guardResult = transition.when({\n context: snapshot.context,\n from: snapshot.current,\n history: snapshot.history,\n event\n });\n const asyncGuard = isPromiseLike(guardResult);\n if (asyncGuard) {\n hooks?.onAsyncGuardStart?.(transition);\n }\n\n let allowed: boolean;\n try {\n allowed = await guardResult;\n } catch (error) {\n if (asyncGuard) {\n hooks?.onAsyncGuardError?.(transition, error);\n }\n throw error;\n }\n\n if (asyncGuard) {\n hooks?.onAsyncGuardSuccess?.(transition);\n }\n\n if (allowed) {\n return transition;\n }\n }\n\n return null;\n};\n\nexport const transitionSnapshot = <TContext, TStepId extends string>(\n snapshot: JourneySnapshot<TContext, TStepId>,\n nextCurrent: TStepId,\n nextContext: TContext\n): JourneySnapshot<TContext, TStepId> => {\n const history =\n nextCurrent === snapshot.current\n ? [...snapshot.history]\n : [...snapshot.history, snapshot.current];\n\n return buildSnapshot(nextCurrent, nextContext, history, snapshot.status, snapshot.async);\n};\n", "import { JOURNEY_STATUS } from \"./types\";\nimport type {\n JourneyMachineOptions,\n JourneyPersistedSnapshot,\n JourneyPersistedState,\n JourneyStatus,\n JourneySnapshot,\n JourneyStorage\n} from \"./types\";\nimport { buildInitialAsyncState, buildSnapshot } from \"./machine-helpers\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isStatusValue = (value: unknown): value is JourneyStatus =>\n value === JOURNEY_STATUS.RUNNING ||\n value === JOURNEY_STATUS.COMPLETE ||\n value === JOURNEY_STATUS.CLOSED;\n\nconst resolveDefaultStorage = (): JourneyStorage | null => {\n const localStorageCandidate = (globalThis as { localStorage?: Partial<JourneyStorage> })\n .localStorage;\n\n if (\n !localStorageCandidate ||\n typeof localStorageCandidate.getItem !== \"function\" ||\n typeof localStorageCandidate.setItem !== \"function\" ||\n typeof localStorageCandidate.removeItem !== \"function\"\n ) {\n return null;\n }\n\n return localStorageCandidate as JourneyStorage;\n};\n\ntype ResolvedPersistence<TContext, TStepId extends string> = {\n key: string;\n storage: JourneyStorage;\n version: number;\n clearOnReset: boolean;\n serialize: (value: JourneyPersistedState<TContext, TStepId>) => string;\n deserialize: (value: string) => unknown;\n migrate?: (\n value: unknown,\n persistedVersion: number\n ) => JourneyPersistedSnapshot<TContext, TStepId>;\n onError?: (error: unknown) => void;\n};\n\nconst resolvePersistence = <TContext, TStepId extends string>(\n options?: JourneyMachineOptions<TContext, TStepId>[\"persistence\"]\n): ResolvedPersistence<TContext, TStepId> | null => {\n if (!options) {\n return null;\n }\n\n const storage = options.storage ?? resolveDefaultStorage();\n if (!storage) {\n return null;\n }\n\n return {\n key: options.key,\n storage,\n version: options.version ?? 1,\n clearOnReset: options.clearOnReset ?? true,\n serialize: options.serialize ?? JSON.stringify,\n deserialize: options.deserialize ?? JSON.parse,\n ...(options.migrate ? { migrate: options.migrate } : {}),\n ...(options.onError ? { onError: options.onError } : {})\n };\n};\n\nconst coercePersistedSnapshot = <TContext, TStepId extends string>(\n value: unknown,\n steps: Record<TStepId, unknown>,\n fallbackContext: TContext\n): JourneyPersistedSnapshot<TContext, TStepId> | null => {\n if (!isRecord(value)) {\n return null;\n }\n\n const currentValue = value.current;\n if (typeof currentValue !== \"string\" || !(currentValue in steps)) {\n return null;\n }\n const current = currentValue as TStepId;\n\n const history = Array.isArray(value.history)\n ? (value.history.filter(\n (step): step is TStepId => typeof step === \"string\" && step in steps\n ) as TStepId[])\n : [];\n\n const status = isStatusValue(value.status) ? value.status : JOURNEY_STATUS.RUNNING;\n\n return {\n current,\n context: (\"context\" in value ? value.context : fallbackContext) as TContext,\n history,\n status\n };\n};\n\n/**\n * Creates a persistence controller for snapshots, including hydration,\n * serialization, and storage error handling.\n */\nexport const createPersistenceController = <TContext, TStepId extends string>(args: {\n initial: TStepId;\n context: TContext;\n steps: Record<TStepId, unknown>;\n options?: JourneyMachineOptions<TContext, TStepId>;\n}) => {\n const { initial, context, steps, options } = args;\n const persistence = resolvePersistence(options?.persistence);\n\n const reportPersistenceError = (error: unknown) => {\n persistence?.onError?.(error);\n };\n\n const persistSnapshot = (snapshot: JourneySnapshot<TContext, TStepId>) => {\n if (!persistence) {\n return;\n }\n\n try {\n const persistedState: JourneyPersistedState<TContext, TStepId> = {\n version: persistence.version,\n snapshot: {\n current: snapshot.current,\n context: snapshot.context,\n history: [...snapshot.history],\n status: snapshot.status\n }\n };\n persistence.storage.setItem(persistence.key, persistence.serialize(persistedState));\n } catch (error) {\n reportPersistenceError(error);\n }\n };\n\n const removePersistedSnapshot = () => {\n if (!persistence) {\n return;\n }\n\n try {\n persistence.storage.removeItem(persistence.key);\n } catch (error) {\n reportPersistenceError(error);\n }\n };\n\n const hydrateSnapshot = (): JourneySnapshot<TContext, TStepId> => {\n const initialSnapshot = buildSnapshot(\n initial,\n context,\n [],\n JOURNEY_STATUS.RUNNING,\n buildInitialAsyncState(steps)\n );\n if (!persistence) {\n return initialSnapshot;\n }\n\n try {\n const rawPersisted = persistence.storage.getItem(persistence.key);\n if (!rawPersisted) {\n return initialSnapshot;\n }\n\n const parsed = persistence.deserialize(rawPersisted);\n if (!isRecord(parsed)) {\n return initialSnapshot;\n }\n\n const persistedVersion = parsed.version;\n if (typeof persistedVersion !== \"number\") {\n return initialSnapshot;\n }\n\n let persistedSnapshot: JourneyPersistedSnapshot<TContext, TStepId> | null = null;\n let shouldRewritePersisted = false;\n\n if (persistedVersion === persistence.version) {\n persistedSnapshot = coercePersistedSnapshot(parsed.snapshot, steps, context);\n } else if (persistence.migrate) {\n const migrated = persistence.migrate(parsed.snapshot, persistedVersion);\n persistedSnapshot = coercePersistedSnapshot(migrated, steps, context);\n shouldRewritePersisted = persistedSnapshot !== null;\n }\n\n if (!persistedSnapshot) {\n return initialSnapshot;\n }\n\n const hydratedSnapshot = buildSnapshot(\n persistedSnapshot.current,\n persistedSnapshot.context,\n persistedSnapshot.history,\n persistedSnapshot.status,\n buildInitialAsyncState(steps)\n );\n\n if (shouldRewritePersisted) {\n persistSnapshot(hydratedSnapshot);\n }\n\n return hydratedSnapshot;\n } catch (error) {\n reportPersistenceError(error);\n return initialSnapshot;\n }\n };\n\n return {\n clearOnReset: persistence?.clearOnReset ?? true,\n hydrateSnapshot,\n persistSnapshot,\n removePersistedSnapshot\n };\n};\n", "import {\n JOURNEY_ASYNC_PHASE,\n JOURNEY_EVENT,\n JOURNEY_STATUS,\n JOURNEY_TERMINAL,\n JOURNEY_WILDCARD,\n HISTORY_TARGET\n} from \"./types\";\nimport type {\n JourneyAsyncState,\n JourneyAsyncPhase,\n JourneyEventPayloadMap,\n JourneyDefinition,\n JourneyHistoryOverflowReason,\n JourneyHistoryOptions,\n JourneyMachine,\n JourneyMachineOptions,\n JourneySendResult,\n JourneySnapshot\n} from \"./types\";\nimport {\n assertStepExists,\n buildIdleStepAsyncState,\n buildInitialAsyncState,\n buildSendResult,\n isGoToEvent,\n isPromiseLike,\n isTerminalTarget,\n resolveHistoryTarget,\n selectTransition,\n transitionSnapshot,\n buildSnapshot\n} from \"./machine-helpers\";\nimport { createPersistenceController } from \"./persistence\";\n\nconst DEFAULT_MAX_HISTORY = 50;\n\nconst resolveMaxHistory = (value: number | null | undefined): number | null => {\n if (value === null) {\n return null;\n }\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return Math.max(0, Math.trunc(value));\n }\n return DEFAULT_MAX_HISTORY;\n};\n\nconst applyHistoryLimit = <TStepId extends string>(\n history: readonly TStepId[],\n maxHistory: number | null\n): { next: TStepId[]; trimmed: TStepId[] } => {\n if (maxHistory === null || history.length <= maxHistory) {\n return { next: [...history], trimmed: [] };\n }\n\n const trimCount = history.length - maxHistory;\n return {\n next: history.slice(trimCount),\n trimmed: history.slice(0, trimCount)\n };\n};\n\n/**\n * Creates a journey machine from a journey definition.\n * Validates steps/transitions, hydrates persisted state (if configured),\n * and returns an API for sending events and reading snapshots.\n */\nexport const createJourneyMachine = <\n TContext,\n TStepId extends string,\n TEventType extends string = \"next\" | \"back\" | \"close\" | \"submit\",\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n>(\n journey: JourneyDefinition<TContext, TStepId, TEventType, TPayloadMap>,\n options?: JourneyMachineOptions<TContext, TStepId>\n): JourneyMachine<TContext, TStepId, TEventType, TPayloadMap> => {\n if (!journey.steps || typeof journey.steps !== \"object\") {\n throw new Error(\"Journey steps must be a record object.\");\n }\n\n if (!Array.isArray(journey.transitions)) {\n throw new Error(\"Journey transitions must be an array.\");\n }\n\n assertStepExists(\n journey.steps,\n journey.initial,\n `Journey initial step \"${journey.initial}\" does not exist in steps registry.`\n );\n\n for (const [index, transition] of journey.transitions.entries()) {\n if (!transition || typeof transition !== \"object\") {\n throw new Error(`Journey transition at index ${index} must be an object.`);\n }\n\n if (typeof transition.from !== \"string\" || typeof transition.event !== \"string\") {\n throw new Error(\n `Journey transition at index ${index} must define string \"from\" and \"event\".`\n );\n }\n\n if (\n transition.from !== JOURNEY_WILDCARD &&\n !((transition.from as string) in (journey.steps as Record<string, unknown>))\n ) {\n throw new Error(\n `Journey transition at index ${index} references unknown from step \"${transition.from}\".`\n );\n }\n\n if (\n transition.to !== HISTORY_TARGET &&\n !isTerminalTarget(transition.to) &&\n !((transition.to as string) in (journey.steps as Record<string, unknown>))\n ) {\n throw new Error(\n `Journey transition at index ${index} points to unknown step \"${transition.to}\".`\n );\n }\n }\n\n const { clearOnReset, hydrateSnapshot, persistSnapshot, removePersistedSnapshot } =\n createPersistenceController({\n initial: journey.initial,\n context: journey.context,\n steps: journey.steps,\n ...(options ? { options } : {})\n });\n\n const historyOptions: JourneyHistoryOptions<TStepId> | undefined = options?.history;\n\n const runHistoryTrim = (\n nextSnapshot: JourneySnapshot<TContext, TStepId>,\n reason: JourneyHistoryOverflowReason,\n overrideMaxHistory?: number | null\n ): {\n snapshot: JourneySnapshot<TContext, TStepId>;\n trimmed: TStepId[];\n maxHistory: number | null;\n } => {\n const resolvedMaxHistory = resolveMaxHistory(overrideMaxHistory ?? historyOptions?.maxHistory);\n const { next, trimmed } = applyHistoryLimit(nextSnapshot.history, resolvedMaxHistory);\n if (trimmed.length === 0) {\n return {\n snapshot: nextSnapshot,\n trimmed,\n maxHistory: resolvedMaxHistory\n };\n }\n\n const rebuilt = buildSnapshot(\n nextSnapshot.current,\n nextSnapshot.context,\n next,\n nextSnapshot.status,\n nextSnapshot.async\n );\n\n historyOptions?.onOverflow?.({\n previous: nextSnapshot.history,\n next,\n trimmed,\n maxHistory: resolvedMaxHistory,\n reason\n });\n\n return {\n snapshot: rebuilt,\n trimmed,\n maxHistory: resolvedMaxHistory\n };\n };\n\n let snapshot = hydrateSnapshot();\n const hydratedTrim = runHistoryTrim(snapshot, \"hydrate\");\n snapshot = hydratedTrim.snapshot;\n if (hydratedTrim.trimmed.length > 0) {\n persistSnapshot(snapshot);\n }\n const listeners = new Set<() => void>();\n let sendQueue: Promise<void> = Promise.resolve();\n snapshot = {\n ...snapshot,\n async: buildInitialAsyncState(journey.steps)\n };\n\n const notify = () => {\n for (const listener of listeners) {\n listener();\n }\n };\n\n const isAsyncLoadingPhase = (phase: JourneyAsyncPhase): boolean =>\n phase === JOURNEY_ASYNC_PHASE.EVALUATING_WHEN || phase === JOURNEY_ASYNC_PHASE.RUNNING_EFFECT;\n\n const updateStepAsync = (\n stepId: TStepId,\n updater: (\n current: JourneyAsyncState<TStepId>[\"byStep\"][TStepId]\n ) => JourneyAsyncState<TStepId>[\"byStep\"][TStepId]\n ) => {\n const current = snapshot.async.byStep[stepId] ?? buildIdleStepAsyncState();\n const next = updater(current);\n if (\n current.phase === next.phase &&\n current.eventType === next.eventType &&\n current.transitionId === next.transitionId &&\n current.error === next.error\n ) {\n return;\n }\n const nextByStep = {\n ...snapshot.async.byStep,\n [stepId]: next\n };\n const isLoading = Object.values(nextByStep).some((state) => isAsyncLoadingPhase(state.phase));\n snapshot = {\n ...snapshot,\n async: {\n isLoading,\n byStep: nextByStep\n }\n };\n notify();\n };\n\n const setStepLoading = (\n stepId: TStepId,\n phase: JourneyAsyncPhase,\n eventType: string,\n transitionId?: string\n ) => {\n updateStepAsync(stepId, () => ({\n phase,\n eventType,\n transitionId: transitionId ?? null,\n error: null\n }));\n };\n\n const setStepIdle = (stepId: TStepId) => {\n updateStepAsync(stepId, () => buildIdleStepAsyncState());\n };\n\n const setStepError = (\n stepId: TStepId,\n eventType: string,\n error: unknown,\n transitionId?: string\n ) => {\n updateStepAsync(stepId, () => ({\n phase: JOURNEY_ASYNC_PHASE.ERROR,\n eventType,\n transitionId: transitionId ?? null,\n error\n }));\n };\n\n return {\n getSnapshot: () => snapshot,\n subscribe: (listener) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n reset: () => {\n snapshot = buildSnapshot(\n journey.initial,\n journey.context,\n [],\n JOURNEY_STATUS.RUNNING,\n buildInitialAsyncState(journey.steps)\n );\n if (clearOnReset) {\n removePersistedSnapshot();\n } else {\n persistSnapshot(snapshot);\n }\n notify();\n return snapshot;\n },\n updateContext: (updater) => {\n snapshot = {\n ...snapshot,\n context: updater(snapshot.context)\n };\n persistSnapshot(snapshot);\n notify();\n return snapshot;\n },\n clearStepError: (stepId) => {\n const resolvedStep = stepId ?? snapshot.current;\n if (!(resolvedStep in journey.steps)) {\n return snapshot;\n }\n\n setStepIdle(resolvedStep);\n return snapshot;\n },\n trimHistory: (maxHistory) => {\n const result = runHistoryTrim(snapshot, \"manual\", maxHistory);\n if (result.trimmed.length === 0) {\n return snapshot;\n }\n snapshot = result.snapshot;\n persistSnapshot(snapshot);\n notify();\n return snapshot;\n },\n clearHistory: () => {\n if (snapshot.history.length === 0) {\n return snapshot;\n }\n snapshot = buildSnapshot(\n snapshot.current,\n snapshot.context,\n [],\n snapshot.status,\n snapshot.async\n );\n persistSnapshot(snapshot);\n notify();\n return snapshot;\n },\n send: (event) => {\n const run = async (): Promise<JourneySendResult<TContext, TStepId>> => {\n if (snapshot.status !== JOURNEY_STATUS.RUNNING) {\n return { transitioned: false, snapshot };\n }\n\n const fromStep = snapshot.current;\n\n if (isGoToEvent(event)) {\n assertStepExists(journey.steps, event.to, `Cannot goTo unknown step \"${event.to}\".`);\n setStepIdle(fromStep);\n snapshot = transitionSnapshot(snapshot, event.to, snapshot.context);\n snapshot = runHistoryTrim(snapshot, \"auto\").snapshot;\n persistSnapshot(snapshot);\n notify();\n return buildSendResult(snapshot, true, JOURNEY_EVENT.GO_TO);\n }\n\n let transition;\n try {\n transition = await selectTransition(journey.transitions, snapshot, event, {\n onAsyncGuardStart: (currentTransition) => {\n setStepLoading(\n fromStep,\n JOURNEY_ASYNC_PHASE.EVALUATING_WHEN,\n event.type,\n currentTransition.id\n );\n },\n onAsyncGuardSuccess: () => {\n setStepIdle(fromStep);\n },\n onAsyncGuardError: (currentTransition, error) => {\n setStepError(fromStep, event.type, error, currentTransition.id);\n }\n });\n } catch (error) {\n setStepError(fromStep, event.type, error);\n throw error;\n }\n\n if (!transition) {\n return buildSendResult(snapshot, false);\n }\n\n let nextContext = snapshot.context;\n if (transition.effect) {\n const effectResultPromise = transition.effect({\n context: snapshot.context,\n from: snapshot.current,\n history: snapshot.history,\n event\n });\n if (isPromiseLike(effectResultPromise)) {\n setStepLoading(\n fromStep,\n JOURNEY_ASYNC_PHASE.RUNNING_EFFECT,\n event.type as string,\n transition.id\n );\n }\n\n let effectResult: TContext | void;\n try {\n effectResult = await effectResultPromise;\n } catch (error) {\n setStepError(fromStep, event.type, error, transition.id);\n throw error;\n }\n\n if (effectResult !== undefined) {\n nextContext = effectResult;\n }\n }\n\n setStepIdle(fromStep);\n\n if (isTerminalTarget(transition.to)) {\n snapshot = {\n ...snapshot,\n context: nextContext,\n status:\n transition.to === JOURNEY_TERMINAL.COMPLETE\n ? JOURNEY_STATUS.COMPLETE\n : JOURNEY_STATUS.CLOSED\n };\n snapshot = runHistoryTrim(snapshot, \"auto\").snapshot;\n persistSnapshot(snapshot);\n notify();\n return buildSendResult(snapshot, true, transition.id);\n }\n\n if (transition.to === HISTORY_TARGET) {\n const { target, history } = resolveHistoryTarget(snapshot, journey.steps);\n assertStepExists(journey.steps, target, `Transition points to unknown step \"${target}\".`);\n snapshot = buildSnapshot(target, nextContext, history, snapshot.status, snapshot.async);\n snapshot = runHistoryTrim(snapshot, \"auto\").snapshot;\n persistSnapshot(snapshot);\n notify();\n return buildSendResult(snapshot, true, transition.id);\n }\n\n const resolvedTarget = transition.to;\n\n assertStepExists(\n journey.steps,\n resolvedTarget,\n `Transition points to unknown step \"${resolvedTarget}\".`\n );\n\n const nextSnapshot = transitionSnapshot(snapshot, resolvedTarget, nextContext);\n snapshot = runHistoryTrim(nextSnapshot, \"auto\").snapshot;\n persistSnapshot(snapshot);\n notify();\n\n return buildSendResult(snapshot, true, transition.id);\n };\n\n const resultPromise = sendQueue.then(run, run);\n sendQueue = resultPromise.then(\n () => undefined,\n () => undefined\n );\n return resultPromise;\n }\n };\n};\n"],
5
- "mappings": "6aAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,oBAAAE,EAAA,wBAAAC,EAAA,kBAAAC,EAAA,mBAAAC,EAAA,qBAAAC,EAAA,qBAAAC,EAAA,yBAAAC,EAAA,gCAAAC,IAAA,eAAAC,GAAAV,ICAO,IAAMW,EAAmB,CAC9B,SAAU,WACV,MAAO,OACT,EAIaC,EAAiB,CAC5B,QAAS,UACT,SAAU,WACV,OAAQ,QACV,EAIaC,EAAiB,cACjBC,EAAmB,IAEnBC,EAAgB,CAC3B,MAAO,MACT,EAKaC,EAAsB,CACjC,KAAM,OACN,gBAAiB,kBACjB,eAAgB,iBAChB,MAAO,OACT,ECfO,IAAMC,EAAmB,CAC9BC,EACAC,EACAC,IACG,CACH,GAAI,EAAED,KAAUD,GACd,MAAM,IAAI,MAAME,CAAO,CAE3B,EAEMC,GAAaC,GAA6B,C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AM,EAAE,SAChDL,EAAgBa,CAAQ,EACxBK,EAAO,EAEA2B,EAAgBhC,EAAU,GAAMnB,EAAW,EAAE,CACtD,EAEM+D,EAAgBzC,EAAU,KAAKyB,EAAKA,CAAG,EAC7C,OAAAzB,EAAYyC,EAAc,KACxB,IAAG,GACH,IAAG,EACL,EACOA,CACT,CACF,CACF",
6
- "names": ["index_exports", "__export", "HISTORY_TARGET", "JOURNEY_ASYNC_PHASE", "JOURNEY_EVENT", "JOURNEY_STATUS", "JOURNEY_TERMINAL", "JOURNEY_WILDCARD", "createJourneyMachine", "createPersistenceController", "__toCommonJS", "JOURNEY_TERMINAL", "JOURNEY_STATUS", "HISTORY_TARGET", "JOURNEY_WILDCARD", "JOURNEY_EVENT", "JOURNEY_ASYNC_PHASE", "assertStepExists", "steps", "stepId", "message", "unique", "items", "isPromiseLike", "value", "buildIdleStepAsyncState", "JOURNEY_ASYNC_PHASE", "buildInitialAsyncState", "isGoToEvent", "event", "JOURNEY_EVENT", "isTerminalTarget", "target", "JOURNEY_TERMINAL", "buildSendResult", "snapshot", "transitioned", "transitionId", "buildSnapshot", "current", "context", "history", "status", "asyncState", "resolveHistoryTarget", "cloned", "candidate", "selectTransition", "transitions", "hooks", "transition", "fromMatches", "JOURNEY_WILDCARD", "eventMatches", "guardResult", "asyncGuard", "allowed", "error", "transitionSnapshot", "nextCurrent", "nextContext", "isRecord", "value", "isStatusValue", "JOURNEY_STATUS", "resolveDefaultStorage", "localStorageCandidate", "resolvePersistence", "options", "storage", "coercePersistedSnapshot", "steps", "fallbackContext", "currentValue", "current", "history", "step", "status", "createPersistenceController", "args", "initial", "context", "persistence", "reportPersistenceError", "error", "persistSnapshot", "snapshot", "persistedState", "removePersistedSnapshot", "hydrateSnapshot", "initialSnapshot", "buildSnapshot", "buildInitialAsyncState", "rawPersisted", "parsed", "persistedVersion", "persistedSnapshot", "shouldRewritePersisted", "migrated", "hydratedSnapshot", "DEFAULT_MAX_HISTORY", "resolveMaxHistory", "value", "applyHistoryLimit", "history", "maxHistory", "trimCount", "createJourneyMachine", "journey", "options", "assertStepExists", "index", "transition", "JOURNEY_WILDCARD", "HISTORY_TARGET", "isTerminalTarget", "clearOnReset", "hydrateSnapshot", "persistSnapshot", "removePersistedSnapshot", "createPersistenceController", "historyOptions", "runHistoryTrim", "nextSnapshot", "reason", "overrideMaxHistory", "resolvedMaxHistory", "next", "trimmed", "rebuilt", "buildSnapshot", "snapshot", "hydratedTrim", "listeners", "sendQueue", "buildInitialAsyncState", "notify", "listener", "isAsyncLoadingPhase", "phase", "JOURNEY_ASYNC_PHASE", "updateStepAsync", "stepId", "updater", "current", "buildIdleStepAsyncState", "nextByStep", "isLoading", "state", "setStepLoading", "eventType", "transitionId", "setStepIdle", "setStepError", "error", "JOURNEY_STATUS", "resolvedStep", "result", "event", "run", "fromStep", "isGoToEvent", "transitionSnapshot", "buildSendResult", "JOURNEY_EVENT", "selectTransition", "currentTransition", "nextContext", "effectResultPromise", "isPromiseLike", "effectResult", "JOURNEY_TERMINAL", "target", "resolveHistoryTarget", "resolvedTarget", "resultPromise"]
4
+ "sourcesContent": ["export { createJourneyMachine } from \"./machine\";\nexport { createPersistenceController } from \"./persistence\";\nexport {\n JOURNEY_EVENT,\n JOURNEY_ASYNC_PHASE,\n JOURNEY_STATUS,\n JOURNEY_WILDCARD,\n HISTORY_TARGET,\n JOURNEY_TERMINAL,\n type JourneyBuiltInEvent,\n type JourneyBuiltInFrom,\n type JourneyAsyncPhase,\n type JourneyStatus,\n type JourneyAsyncState,\n type JourneyStepAsyncState,\n type JourneyEvent,\n type JourneyEventPayloadMap,\n type JourneyDefinition,\n type JourneyHistoryOptions,\n type JourneyHistoryOverflow,\n type JourneyHistoryOverflowReason,\n type JourneyMachineOptions,\n type JourneyGoToEvent,\n type JourneyMachine,\n type JourneyPayloadFor,\n type JourneyPersistedSnapshot,\n type JourneyPersistedState,\n type JourneyPersistenceOptions,\n type JourneyStorage,\n type JourneySendResult,\n type JourneySnapshot,\n type JourneyTerminal,\n type JourneyTransition,\n type JourneyTransitionArgs,\n type JourneyTransitionTarget\n} from \"./types\";\n", "export const JOURNEY_TERMINAL = {\n COMPLETE: \"COMPLETE\",\n CLOSE: \"CLOSE\"\n} as const;\n\nexport type JourneyTerminal = (typeof JOURNEY_TERMINAL)[keyof typeof JOURNEY_TERMINAL];\n\nexport const JOURNEY_STATUS = {\n RUNNING: \"running\",\n COMPLETE: \"complete\",\n CLOSED: \"closed\"\n} as const;\n\nexport type JourneyStatus = (typeof JOURNEY_STATUS)[keyof typeof JOURNEY_STATUS];\n\nexport const HISTORY_TARGET = \"__HISTORY__\" as const;\nexport const JOURNEY_WILDCARD = \"*\" as const;\n\nexport const JOURNEY_EVENT = {\n GO_TO: \"goTo\"\n} as const;\n\nexport type JourneyBuiltInEvent = (typeof JOURNEY_EVENT)[keyof typeof JOURNEY_EVENT];\nexport type JourneyBuiltInFrom = typeof JOURNEY_WILDCARD;\n\nexport const JOURNEY_ASYNC_PHASE = {\n IDLE: \"idle\",\n EVALUATING_WHEN: \"evaluating-when\",\n RUNNING_EFFECT: \"running-effect\",\n ERROR: \"error\"\n} as const;\n\nexport type JourneyAsyncPhase = (typeof JOURNEY_ASYNC_PHASE)[keyof typeof JOURNEY_ASYNC_PHASE];\n\nexport type JourneyStepAsyncState = {\n phase: JourneyAsyncPhase;\n eventType: string | null;\n transitionId: string | null;\n error: unknown | null;\n};\n\nexport type JourneyAsyncState<TStepId extends string> = {\n isLoading: boolean;\n byStep: Record<TStepId, JourneyStepAsyncState>;\n};\n\nexport type JourneyBaseEvent = {\n type: string;\n payload?: unknown;\n};\n\nexport type JourneyEventPayloadMap<TEventType extends string> = Partial<\n Record<TEventType | JourneyBuiltInEvent, unknown>\n>;\n\nexport type JourneyPayloadFor<\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType>,\n TEvent extends TEventType | JourneyBuiltInEvent\n> = TEvent extends keyof TPayloadMap ? TPayloadMap[TEvent] : unknown;\n\nexport type JourneyGoToEvent<TStepId extends string, TPayload = unknown> = {\n type: (typeof JOURNEY_EVENT)[\"GO_TO\"];\n to: TStepId;\n payload?: TPayload;\n};\n\nexport type JourneyEvent<\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> =\n | JourneyGoToEvent<\n TStepId,\n JourneyPayloadFor<TEventType, TPayloadMap, (typeof JOURNEY_EVENT)[\"GO_TO\"]>\n >\n | {\n [TType in TEventType]: {\n type: TType;\n payload?: JourneyPayloadFor<TEventType, TPayloadMap, TType>;\n };\n }[TEventType];\n\nexport type JourneyTransitionArgs<\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> = {\n context: TContext;\n from: TStepId;\n history: readonly TStepId[];\n event: JourneyEvent<TStepId, TEventType, TPayloadMap>;\n};\n\nexport type JourneyTransitionTarget<TStepId extends string> =\n | TStepId\n | JourneyTerminal\n | typeof HISTORY_TARGET;\n\nexport type JourneyTransition<\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> = {\n id?: string;\n from: TStepId | JourneyBuiltInFrom;\n event: TEventType | (typeof JOURNEY_EVENT)[\"GO_TO\"];\n to: JourneyTransitionTarget<TStepId>;\n when?: (\n args: JourneyTransitionArgs<TContext, TStepId, TEventType, TPayloadMap>\n ) => boolean | Promise<boolean>;\n effect?: (\n args: JourneyTransitionArgs<TContext, TStepId, TEventType, TPayloadMap>\n ) => TContext | void | Promise<TContext | void>;\n};\n\nexport type JourneySnapshot<TContext, TStepId extends string> = {\n current: TStepId;\n context: TContext;\n history: readonly TStepId[];\n visited: readonly TStepId[];\n status: JourneyStatus;\n async: JourneyAsyncState<TStepId>;\n};\n\nexport type JourneyPersistedSnapshot<TContext, TStepId extends string> = {\n current: TStepId;\n context: TContext;\n history: readonly TStepId[];\n status: JourneyStatus;\n visited: readonly TStepId[];\n};\n\nexport type JourneyPersistedState<TContext, TStepId extends string> = {\n version: number;\n snapshot: JourneyPersistedSnapshot<TContext, TStepId>;\n};\n\nexport type JourneyHistoryOverflowReason = \"auto\" | \"hydrate\" | \"manual\";\n\nexport type JourneyHistoryOverflow<TStepId extends string> = {\n previous: readonly TStepId[];\n next: readonly TStepId[];\n trimmed: readonly TStepId[];\n maxHistory: number | null;\n reason: JourneyHistoryOverflowReason;\n};\n\nexport type JourneyHistoryOptions<TStepId extends string> = {\n maxHistory?: number | null;\n onOverflow?: (info: JourneyHistoryOverflow<TStepId>) => void;\n};\n\nexport type JourneyStorage = {\n getItem: (key: string) => string | null;\n setItem: (key: string, value: string) => void;\n removeItem: (key: string) => void;\n};\n\nexport type JourneyPersistenceOptions<TContext, TStepId extends string> = {\n key: string;\n storage?: JourneyStorage;\n version?: number;\n clearOnReset?: boolean;\n serialize?: (value: JourneyPersistedState<TContext, TStepId>) => string;\n deserialize?: (value: string) => unknown;\n migrate?: (\n value: unknown,\n persistedVersion: number\n ) => JourneyPersistedSnapshot<TContext, TStepId>;\n onError?: (error: unknown) => void;\n};\n\nexport type JourneyDefinition<\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> = {\n initial: TStepId;\n context: TContext;\n steps: Record<TStepId, unknown>;\n transitions: readonly JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>[];\n};\n\nexport type JourneyMachineOptions<TContext, TStepId extends string> = {\n persistence?: JourneyPersistenceOptions<TContext, TStepId>;\n history?: JourneyHistoryOptions<TStepId>;\n};\n\nexport type JourneySendResult<TContext, TStepId extends string> = {\n transitioned: boolean;\n transitionId?: string;\n snapshot: JourneySnapshot<TContext, TStepId>;\n};\n\nexport type JourneyMachine<\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> = {\n getSnapshot: () => JourneySnapshot<TContext, TStepId>;\n send: (\n event: JourneyEvent<TStepId, TEventType, TPayloadMap>\n ) => Promise<JourneySendResult<TContext, TStepId>>;\n updateContext: (updater: (context: TContext) => TContext) => JourneySnapshot<TContext, TStepId>;\n clearStepError: (stepId?: TStepId) => JourneySnapshot<TContext, TStepId>;\n reset: () => JourneySnapshot<TContext, TStepId>;\n trimHistory: (maxHistory?: number | null) => JourneySnapshot<TContext, TStepId>;\n clearHistory: () => JourneySnapshot<TContext, TStepId>;\n subscribe: (listener: () => void) => () => void;\n};\n", "import { JOURNEY_ASYNC_PHASE, JOURNEY_EVENT, JOURNEY_TERMINAL, JOURNEY_WILDCARD } from \"./types\";\nimport type {\n JourneyAsyncState,\n JourneyEvent,\n JourneyEventPayloadMap,\n JourneyGoToEvent,\n JourneyPayloadFor,\n JourneySendResult,\n JourneySnapshot,\n JourneyStatus,\n JourneyStepAsyncState,\n JourneyTerminal,\n JourneyTransition\n} from \"./types\";\n\nexport const assertStepExists = <TStepId extends string>(\n steps: Record<TStepId, unknown>,\n stepId: TStepId,\n message: string\n) => {\n if (!(stepId in steps)) {\n throw new Error(message);\n }\n};\n\nconst unique = <T>(items: readonly T[]): T[] => [...new Set(items)];\n\nexport const buildVisited = <TStepId extends string>(\n history: readonly TStepId[],\n current: TStepId\n): TStepId[] => unique([...history, current]);\n\nexport const appendVisited = <TStepId extends string>(\n visited: readonly TStepId[],\n current: TStepId\n): TStepId[] => (visited.includes(current) ? [...visited] : [...visited, current]);\n\nexport const isPromiseLike = <T>(value: T | PromiseLike<T>): value is PromiseLike<T> =>\n typeof value === \"object\" &&\n value !== null &&\n \"then\" in value &&\n typeof (value as { then: unknown }).then === \"function\";\n\nexport const buildIdleStepAsyncState = (): JourneyStepAsyncState => ({\n phase: JOURNEY_ASYNC_PHASE.IDLE,\n eventType: null,\n transitionId: null,\n error: null\n});\n\nexport const buildInitialAsyncState = <TStepId extends string>(\n steps: Record<TStepId, unknown>\n): JourneyAsyncState<TStepId> => {\n const byStep = Object.fromEntries(\n Object.keys(steps).map((stepId) => [stepId, buildIdleStepAsyncState()])\n ) as Record<TStepId, JourneyStepAsyncState>;\n\n return {\n isLoading: false,\n byStep\n };\n};\n\nexport const isGoToEvent = <\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType>\n>(\n event: JourneyEvent<TStepId, TEventType, TPayloadMap>\n): event is JourneyGoToEvent<\n TStepId,\n JourneyPayloadFor<TEventType, TPayloadMap, (typeof JOURNEY_EVENT)[\"GO_TO\"]>\n> => event.type === JOURNEY_EVENT.GO_TO && \"to\" in event;\n\nexport const isTerminalTarget = <TStepId extends string>(\n target: TStepId | JourneyTerminal | \"__HISTORY__\"\n): target is JourneyTerminal =>\n target === JOURNEY_TERMINAL.COMPLETE || target === JOURNEY_TERMINAL.CLOSE;\n\nexport const buildSendResult = <TContext, TStepId extends string>(\n snapshot: JourneySnapshot<TContext, TStepId>,\n transitioned: boolean,\n transitionId?: string\n): JourneySendResult<TContext, TStepId> =>\n transitionId ? { transitioned, transitionId, snapshot } : { transitioned, snapshot };\n\nexport const buildSnapshot = <TContext, TStepId extends string>(\n current: TStepId,\n context: TContext,\n history: readonly TStepId[],\n status: JourneyStatus,\n asyncState: JourneyAsyncState<TStepId>,\n visited?: readonly TStepId[]\n): JourneySnapshot<TContext, TStepId> => ({\n status,\n current,\n context,\n history,\n visited: visited ? [...visited] : buildVisited(history, current),\n async: asyncState\n});\n\nexport const resolveHistoryTarget = <TContext, TStepId extends string>(\n snapshot: JourneySnapshot<TContext, TStepId>,\n steps: Record<TStepId, unknown>\n): { target: TStepId; history: TStepId[] } => {\n const cloned = [...snapshot.history];\n\n while (cloned.length > 0) {\n const candidate = cloned.pop();\n if (!candidate) {\n break;\n }\n if (candidate in steps) {\n return {\n target: candidate,\n history: cloned\n };\n }\n }\n\n return {\n target: snapshot.current,\n history: [...snapshot.history]\n };\n};\n\nexport const selectTransition = async <\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType>\n>(\n transitions: readonly JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>[],\n snapshot: JourneySnapshot<TContext, TStepId>,\n event: JourneyEvent<TStepId, TEventType, TPayloadMap>,\n hooks?: {\n onAsyncGuardStart?: (\n transition: JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>\n ) => void;\n onAsyncGuardSuccess?: (\n transition: JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>\n ) => void;\n onAsyncGuardError?: (\n transition: JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>,\n error: unknown\n ) => void;\n }\n): Promise<JourneyTransition<TContext, TStepId, TEventType, TPayloadMap> | null> => {\n for (const transition of transitions) {\n const fromMatches =\n transition.from === JOURNEY_WILDCARD || transition.from === snapshot.current;\n const eventMatches = transition.event === event.type;\n\n if (!fromMatches || !eventMatches) {\n continue;\n }\n\n if (!transition.when) {\n return transition;\n }\n\n const guardResult = transition.when({\n context: snapshot.context,\n from: snapshot.current,\n history: snapshot.history,\n event\n });\n const asyncGuard = isPromiseLike(guardResult);\n if (asyncGuard) {\n hooks?.onAsyncGuardStart?.(transition);\n }\n\n let allowed: boolean;\n try {\n allowed = await guardResult;\n } catch (error) {\n if (asyncGuard) {\n hooks?.onAsyncGuardError?.(transition, error);\n }\n throw error;\n }\n\n if (asyncGuard) {\n hooks?.onAsyncGuardSuccess?.(transition);\n }\n\n if (allowed) {\n return transition;\n }\n }\n\n return null;\n};\n\nexport const transitionSnapshot = <TContext, TStepId extends string>(\n snapshot: JourneySnapshot<TContext, TStepId>,\n nextCurrent: TStepId,\n nextContext: TContext\n): JourneySnapshot<TContext, TStepId> => {\n const history =\n nextCurrent === snapshot.current\n ? [...snapshot.history]\n : [...snapshot.history, snapshot.current];\n\n const visited = appendVisited(snapshot.visited, nextCurrent);\n\n return buildSnapshot(nextCurrent, nextContext, history, snapshot.status, snapshot.async, visited);\n};\n", "import { JOURNEY_STATUS } from \"./types\";\nimport type {\n JourneyMachineOptions,\n JourneyPersistedSnapshot,\n JourneyPersistedState,\n JourneyStatus,\n JourneySnapshot,\n JourneyStorage\n} from \"./types\";\nimport { buildInitialAsyncState, buildSnapshot, buildVisited } from \"./machine-helpers\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isStatusValue = (value: unknown): value is JourneyStatus =>\n value === JOURNEY_STATUS.RUNNING ||\n value === JOURNEY_STATUS.COMPLETE ||\n value === JOURNEY_STATUS.CLOSED;\n\nconst resolveDefaultStorage = (): JourneyStorage | null => {\n const localStorageCandidate = (globalThis as { localStorage?: Partial<JourneyStorage> })\n .localStorage;\n\n if (\n !localStorageCandidate ||\n typeof localStorageCandidate.getItem !== \"function\" ||\n typeof localStorageCandidate.setItem !== \"function\" ||\n typeof localStorageCandidate.removeItem !== \"function\"\n ) {\n return null;\n }\n\n return localStorageCandidate as JourneyStorage;\n};\n\ntype ResolvedPersistence<TContext, TStepId extends string> = {\n key: string;\n storage: JourneyStorage;\n version: number;\n clearOnReset: boolean;\n serialize: (value: JourneyPersistedState<TContext, TStepId>) => string;\n deserialize: (value: string) => unknown;\n migrate?: (\n value: unknown,\n persistedVersion: number\n ) => JourneyPersistedSnapshot<TContext, TStepId>;\n onError?: (error: unknown) => void;\n};\n\nconst resolvePersistence = <TContext, TStepId extends string>(\n options?: JourneyMachineOptions<TContext, TStepId>[\"persistence\"]\n): ResolvedPersistence<TContext, TStepId> | null => {\n if (!options) {\n return null;\n }\n\n const storage = options.storage ?? resolveDefaultStorage();\n if (!storage) {\n return null;\n }\n\n return {\n key: options.key,\n storage,\n version: options.version ?? 1,\n clearOnReset: options.clearOnReset ?? true,\n serialize: options.serialize ?? JSON.stringify,\n deserialize: options.deserialize ?? JSON.parse,\n ...(options.migrate ? { migrate: options.migrate } : {}),\n ...(options.onError ? { onError: options.onError } : {})\n };\n};\n\nconst coercePersistedSnapshot = <TContext, TStepId extends string>(\n value: unknown,\n steps: Record<TStepId, unknown>,\n fallbackContext: TContext\n): { snapshot: JourneyPersistedSnapshot<TContext, TStepId>; needsRewrite: boolean } | null => {\n if (!isRecord(value)) {\n return null;\n }\n\n const currentValue = value.current;\n if (typeof currentValue !== \"string\" || !(currentValue in steps)) {\n return null;\n }\n const current = currentValue as TStepId;\n\n const history = Array.isArray(value.history)\n ? (value.history.filter(\n (step): step is TStepId => typeof step === \"string\" && step in steps\n ) as TStepId[])\n : [];\n\n const status = isStatusValue(value.status) ? value.status : JOURNEY_STATUS.RUNNING;\n\n const visitedRaw = Array.isArray(value.visited)\n ? (value.visited.filter(\n (step): step is TStepId => typeof step === \"string\" && step in steps\n ) as TStepId[])\n : null;\n const visited = visitedRaw && visitedRaw.length > 0 ? visitedRaw : buildVisited(history, current);\n const needsRewrite = !visitedRaw || visitedRaw.length === 0;\n\n return {\n snapshot: {\n current,\n context: (\"context\" in value ? value.context : fallbackContext) as TContext,\n history,\n status,\n visited\n },\n needsRewrite\n };\n};\n\n/**\n * Creates a persistence controller for snapshots, including hydration,\n * serialization, and storage error handling.\n */\nexport const createPersistenceController = <TContext, TStepId extends string>(args: {\n initial: TStepId;\n context: TContext;\n steps: Record<TStepId, unknown>;\n options?: JourneyMachineOptions<TContext, TStepId>;\n}) => {\n const { initial, context, steps, options } = args;\n const persistence = resolvePersistence(options?.persistence);\n\n const reportPersistenceError = (error: unknown) => {\n persistence?.onError?.(error);\n };\n\n const persistSnapshot = (snapshot: JourneySnapshot<TContext, TStepId>) => {\n if (!persistence) {\n return;\n }\n\n try {\n const persistedState: JourneyPersistedState<TContext, TStepId> = {\n version: persistence.version,\n snapshot: {\n current: snapshot.current,\n context: snapshot.context,\n history: [...snapshot.history],\n status: snapshot.status,\n visited: [...snapshot.visited]\n }\n };\n persistence.storage.setItem(persistence.key, persistence.serialize(persistedState));\n } catch (error) {\n reportPersistenceError(error);\n }\n };\n\n const removePersistedSnapshot = () => {\n if (!persistence) {\n return;\n }\n\n try {\n persistence.storage.removeItem(persistence.key);\n } catch (error) {\n reportPersistenceError(error);\n }\n };\n\n const hydrateSnapshot = (): JourneySnapshot<TContext, TStepId> => {\n const initialSnapshot = buildSnapshot(\n initial,\n context,\n [],\n JOURNEY_STATUS.RUNNING,\n buildInitialAsyncState(steps)\n );\n if (!persistence) {\n return initialSnapshot;\n }\n\n try {\n const rawPersisted = persistence.storage.getItem(persistence.key);\n if (!rawPersisted) {\n return initialSnapshot;\n }\n\n const parsed = persistence.deserialize(rawPersisted);\n if (!isRecord(parsed)) {\n return initialSnapshot;\n }\n\n const persistedVersion = parsed.version;\n if (typeof persistedVersion !== \"number\") {\n return initialSnapshot;\n }\n\n let persistedSnapshot: JourneyPersistedSnapshot<TContext, TStepId> | null = null;\n let shouldRewritePersisted = false;\n\n if (persistedVersion === persistence.version) {\n const coerced = coercePersistedSnapshot(parsed.snapshot, steps, context);\n persistedSnapshot = coerced?.snapshot ?? null;\n shouldRewritePersisted = Boolean(coerced?.needsRewrite);\n } else if (persistence.migrate) {\n const migrated = persistence.migrate(parsed.snapshot, persistedVersion);\n const coerced = coercePersistedSnapshot(migrated, steps, context);\n persistedSnapshot = coerced?.snapshot ?? null;\n shouldRewritePersisted = persistedSnapshot !== null;\n }\n\n if (!persistedSnapshot) {\n return initialSnapshot;\n }\n\n const hydratedSnapshot = buildSnapshot(\n persistedSnapshot.current,\n persistedSnapshot.context,\n persistedSnapshot.history,\n persistedSnapshot.status,\n buildInitialAsyncState(steps),\n persistedSnapshot.visited\n );\n\n if (shouldRewritePersisted) {\n persistSnapshot(hydratedSnapshot);\n }\n\n return hydratedSnapshot;\n } catch (error) {\n reportPersistenceError(error);\n return initialSnapshot;\n }\n };\n\n return {\n clearOnReset: persistence?.clearOnReset ?? true,\n hydrateSnapshot,\n persistSnapshot,\n removePersistedSnapshot\n };\n};\n", "import {\n JOURNEY_ASYNC_PHASE,\n JOURNEY_EVENT,\n JOURNEY_STATUS,\n JOURNEY_TERMINAL,\n JOURNEY_WILDCARD,\n HISTORY_TARGET\n} from \"./types\";\nimport type {\n JourneyAsyncState,\n JourneyAsyncPhase,\n JourneyEventPayloadMap,\n JourneyDefinition,\n JourneyHistoryOverflowReason,\n JourneyHistoryOptions,\n JourneyMachine,\n JourneyMachineOptions,\n JourneySendResult,\n JourneySnapshot\n} from \"./types\";\nimport {\n appendVisited,\n assertStepExists,\n buildIdleStepAsyncState,\n buildInitialAsyncState,\n buildSendResult,\n isGoToEvent,\n isPromiseLike,\n isTerminalTarget,\n resolveHistoryTarget,\n selectTransition,\n transitionSnapshot,\n buildSnapshot\n} from \"./machine-helpers\";\nimport { createPersistenceController } from \"./persistence\";\n\nconst DEFAULT_MAX_HISTORY = 50;\n\nconst resolveMaxHistory = (value: number | null | undefined): number | null => {\n if (value === null) {\n return null;\n }\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return Math.max(0, Math.trunc(value));\n }\n return DEFAULT_MAX_HISTORY;\n};\n\nconst applyHistoryLimit = <TStepId extends string>(\n history: readonly TStepId[],\n maxHistory: number | null\n): { next: TStepId[]; trimmed: TStepId[] } => {\n if (maxHistory === null || history.length <= maxHistory) {\n return { next: [...history], trimmed: [] };\n }\n\n const trimCount = history.length - maxHistory;\n return {\n next: history.slice(trimCount),\n trimmed: history.slice(0, trimCount)\n };\n};\n\n/**\n * Creates a journey machine from a journey definition.\n * Validates steps/transitions, hydrates persisted state (if configured),\n * and returns an API for sending events and reading snapshots.\n */\nexport const createJourneyMachine = <\n TContext,\n TStepId extends string,\n TEventType extends string = \"next\" | \"back\" | \"close\" | \"submit\",\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n>(\n journey: JourneyDefinition<TContext, TStepId, TEventType, TPayloadMap>,\n options?: JourneyMachineOptions<TContext, TStepId>\n): JourneyMachine<TContext, TStepId, TEventType, TPayloadMap> => {\n if (!journey.steps || typeof journey.steps !== \"object\") {\n throw new Error(\"Journey steps must be a record object.\");\n }\n\n if (!Array.isArray(journey.transitions)) {\n throw new Error(\"Journey transitions must be an array.\");\n }\n\n assertStepExists(\n journey.steps,\n journey.initial,\n `Journey initial step \"${journey.initial}\" does not exist in steps registry.`\n );\n\n for (const [index, transition] of journey.transitions.entries()) {\n if (!transition || typeof transition !== \"object\") {\n throw new Error(`Journey transition at index ${index} must be an object.`);\n }\n\n if (typeof transition.from !== \"string\" || typeof transition.event !== \"string\") {\n throw new Error(\n `Journey transition at index ${index} must define string \"from\" and \"event\".`\n );\n }\n\n if (\n transition.from !== JOURNEY_WILDCARD &&\n !((transition.from as string) in (journey.steps as Record<string, unknown>))\n ) {\n throw new Error(\n `Journey transition at index ${index} references unknown from step \"${transition.from}\".`\n );\n }\n\n if (\n transition.to !== HISTORY_TARGET &&\n !isTerminalTarget(transition.to) &&\n !((transition.to as string) in (journey.steps as Record<string, unknown>))\n ) {\n throw new Error(\n `Journey transition at index ${index} points to unknown step \"${transition.to}\".`\n );\n }\n }\n\n const { clearOnReset, hydrateSnapshot, persistSnapshot, removePersistedSnapshot } =\n createPersistenceController({\n initial: journey.initial,\n context: journey.context,\n steps: journey.steps,\n ...(options ? { options } : {})\n });\n\n const historyOptions: JourneyHistoryOptions<TStepId> | undefined = options?.history;\n\n const runHistoryTrim = (\n nextSnapshot: JourneySnapshot<TContext, TStepId>,\n reason: JourneyHistoryOverflowReason,\n overrideMaxHistory?: number | null\n ): {\n snapshot: JourneySnapshot<TContext, TStepId>;\n trimmed: TStepId[];\n maxHistory: number | null;\n } => {\n const resolvedMaxHistory = resolveMaxHistory(overrideMaxHistory ?? historyOptions?.maxHistory);\n const { next, trimmed } = applyHistoryLimit(nextSnapshot.history, resolvedMaxHistory);\n if (trimmed.length === 0) {\n return {\n snapshot: nextSnapshot,\n trimmed,\n maxHistory: resolvedMaxHistory\n };\n }\n\n const rebuilt = buildSnapshot(\n nextSnapshot.current,\n nextSnapshot.context,\n next,\n nextSnapshot.status,\n nextSnapshot.async,\n nextSnapshot.visited\n );\n\n historyOptions?.onOverflow?.({\n previous: nextSnapshot.history,\n next,\n trimmed,\n maxHistory: resolvedMaxHistory,\n reason\n });\n\n return {\n snapshot: rebuilt,\n trimmed,\n maxHistory: resolvedMaxHistory\n };\n };\n\n let snapshot = hydrateSnapshot();\n const hydratedTrim = runHistoryTrim(snapshot, \"hydrate\");\n snapshot = hydratedTrim.snapshot;\n if (hydratedTrim.trimmed.length > 0) {\n persistSnapshot(snapshot);\n }\n const listeners = new Set<() => void>();\n let sendQueue: Promise<void> = Promise.resolve();\n snapshot = {\n ...snapshot,\n async: buildInitialAsyncState(journey.steps)\n };\n\n const notify = () => {\n for (const listener of listeners) {\n listener();\n }\n };\n\n const isAsyncLoadingPhase = (phase: JourneyAsyncPhase): boolean =>\n phase === JOURNEY_ASYNC_PHASE.EVALUATING_WHEN || phase === JOURNEY_ASYNC_PHASE.RUNNING_EFFECT;\n\n const updateStepAsync = (\n stepId: TStepId,\n updater: (\n current: JourneyAsyncState<TStepId>[\"byStep\"][TStepId]\n ) => JourneyAsyncState<TStepId>[\"byStep\"][TStepId]\n ) => {\n const current = snapshot.async.byStep[stepId] ?? buildIdleStepAsyncState();\n const next = updater(current);\n if (\n current.phase === next.phase &&\n current.eventType === next.eventType &&\n current.transitionId === next.transitionId &&\n current.error === next.error\n ) {\n return;\n }\n const nextByStep = {\n ...snapshot.async.byStep,\n [stepId]: next\n };\n const isLoading = Object.values(nextByStep).some((state) => isAsyncLoadingPhase(state.phase));\n snapshot = {\n ...snapshot,\n async: {\n isLoading,\n byStep: nextByStep\n }\n };\n notify();\n };\n\n const setStepLoading = (\n stepId: TStepId,\n phase: JourneyAsyncPhase,\n eventType: string,\n transitionId?: string\n ) => {\n updateStepAsync(stepId, () => ({\n phase,\n eventType,\n transitionId: transitionId ?? null,\n error: null\n }));\n };\n\n const setStepIdle = (stepId: TStepId) => {\n updateStepAsync(stepId, () => buildIdleStepAsyncState());\n };\n\n const setStepError = (\n stepId: TStepId,\n eventType: string,\n error: unknown,\n transitionId?: string\n ) => {\n updateStepAsync(stepId, () => ({\n phase: JOURNEY_ASYNC_PHASE.ERROR,\n eventType,\n transitionId: transitionId ?? null,\n error\n }));\n };\n\n return {\n getSnapshot: () => snapshot,\n subscribe: (listener) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n reset: () => {\n snapshot = buildSnapshot(\n journey.initial,\n journey.context,\n [],\n JOURNEY_STATUS.RUNNING,\n buildInitialAsyncState(journey.steps)\n );\n if (clearOnReset) {\n removePersistedSnapshot();\n } else {\n persistSnapshot(snapshot);\n }\n notify();\n return snapshot;\n },\n updateContext: (updater) => {\n snapshot = {\n ...snapshot,\n context: updater(snapshot.context)\n };\n persistSnapshot(snapshot);\n notify();\n return snapshot;\n },\n clearStepError: (stepId) => {\n const resolvedStep = stepId ?? snapshot.current;\n if (!(resolvedStep in journey.steps)) {\n return snapshot;\n }\n\n setStepIdle(resolvedStep);\n return snapshot;\n },\n trimHistory: (maxHistory) => {\n const result = runHistoryTrim(snapshot, \"manual\", maxHistory);\n if (result.trimmed.length === 0) {\n return snapshot;\n }\n snapshot = result.snapshot;\n persistSnapshot(snapshot);\n notify();\n return snapshot;\n },\n clearHistory: () => {\n if (snapshot.history.length === 0) {\n return snapshot;\n }\n snapshot = buildSnapshot(\n snapshot.current,\n snapshot.context,\n [],\n snapshot.status,\n snapshot.async,\n snapshot.visited\n );\n persistSnapshot(snapshot);\n notify();\n return snapshot;\n },\n send: (event) => {\n const run = async (): Promise<JourneySendResult<TContext, TStepId>> => {\n if (snapshot.status !== JOURNEY_STATUS.RUNNING) {\n return { transitioned: false, snapshot };\n }\n\n const fromStep = snapshot.current;\n\n if (isGoToEvent(event)) {\n assertStepExists(journey.steps, event.to, `Cannot goTo unknown step \"${event.to}\".`);\n setStepIdle(fromStep);\n snapshot = transitionSnapshot(snapshot, event.to, snapshot.context);\n snapshot = runHistoryTrim(snapshot, \"auto\").snapshot;\n persistSnapshot(snapshot);\n notify();\n return buildSendResult(snapshot, true, JOURNEY_EVENT.GO_TO);\n }\n\n let transition;\n try {\n transition = await selectTransition(journey.transitions, snapshot, event, {\n onAsyncGuardStart: (currentTransition) => {\n setStepLoading(\n fromStep,\n JOURNEY_ASYNC_PHASE.EVALUATING_WHEN,\n event.type,\n currentTransition.id\n );\n },\n onAsyncGuardSuccess: () => {\n setStepIdle(fromStep);\n },\n onAsyncGuardError: (currentTransition, error) => {\n setStepError(fromStep, event.type, error, currentTransition.id);\n }\n });\n } catch (error) {\n setStepError(fromStep, event.type, error);\n throw error;\n }\n\n if (!transition) {\n return buildSendResult(snapshot, false);\n }\n\n let nextContext = snapshot.context;\n if (transition.effect) {\n const effectResultPromise = transition.effect({\n context: snapshot.context,\n from: snapshot.current,\n history: snapshot.history,\n event\n });\n if (isPromiseLike(effectResultPromise)) {\n setStepLoading(\n fromStep,\n JOURNEY_ASYNC_PHASE.RUNNING_EFFECT,\n event.type as string,\n transition.id\n );\n }\n\n let effectResult: TContext | void;\n try {\n effectResult = await effectResultPromise;\n } catch (error) {\n setStepError(fromStep, event.type, error, transition.id);\n throw error;\n }\n\n if (effectResult !== undefined) {\n nextContext = effectResult;\n }\n }\n\n setStepIdle(fromStep);\n\n if (isTerminalTarget(transition.to)) {\n snapshot = {\n ...snapshot,\n context: nextContext,\n status:\n transition.to === JOURNEY_TERMINAL.COMPLETE\n ? JOURNEY_STATUS.COMPLETE\n : JOURNEY_STATUS.CLOSED\n };\n snapshot = runHistoryTrim(snapshot, \"auto\").snapshot;\n persistSnapshot(snapshot);\n notify();\n return buildSendResult(snapshot, true, transition.id);\n }\n\n if (transition.to === HISTORY_TARGET) {\n const { target, history } = resolveHistoryTarget(snapshot, journey.steps);\n assertStepExists(journey.steps, target, `Transition points to unknown step \"${target}\".`);\n const visited = appendVisited(snapshot.visited, target);\n snapshot = buildSnapshot(\n target,\n nextContext,\n history,\n snapshot.status,\n snapshot.async,\n visited\n );\n snapshot = runHistoryTrim(snapshot, \"auto\").snapshot;\n persistSnapshot(snapshot);\n notify();\n return buildSendResult(snapshot, true, transition.id);\n }\n\n const resolvedTarget = transition.to;\n\n assertStepExists(\n journey.steps,\n resolvedTarget,\n `Transition points to unknown step \"${resolvedTarget}\".`\n );\n\n const nextSnapshot = transitionSnapshot(snapshot, resolvedTarget, nextContext);\n snapshot = runHistoryTrim(nextSnapshot, \"auto\").snapshot;\n persistSnapshot(snapshot);\n notify();\n\n return buildSendResult(snapshot, true, transition.id);\n };\n\n const resultPromise = sendQueue.then(run, run);\n sendQueue = resultPromise.then(\n () => undefined,\n () => undefined\n );\n return resultPromise;\n }\n };\n};\n"],
5
+ "mappings": "ibAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,oBAAAE,EAAA,wBAAAC,EAAA,kBAAAC,EAAA,mBAAAC,EAAA,qBAAAC,EAAA,qBAAAC,EAAA,yBAAAC,EAAA,gCAAAC,IAAA,eAAAC,GAAAV,ICAO,IAAMW,EAAmB,CAC9B,SAAU,WACV,MAAO,OACT,EAIaC,EAAiB,CAC5B,QAAS,UACT,SAAU,WACV,OAAQ,QACV,EAIaC,EAAiB,cACjBC,EAAmB,IAEnBC,EAAgB,CAC3B,MAAO,MACT,EAKaC,EAAsB,CACjC,KAAM,OACN,gBAAiB,kBACjB,eAAgB,iBAChB,MAAO,OACT,ECfO,IAAMC,EAAmB,CAC9BC,EACAC,EACAC,IACG,CACH,GAAI,EAAED,KAAUD,GACd,MAAM,IAAI,MAAME,CAAO,CAE3B,EAEMC,GAAaC,GAA6B,CAAC,GAAG,IAAI,IAAIA,CAAK,CAAC,EAErDC,EAAe,CAC1BC,EACAC,IACcJ,GAAO,CAAC,GAAGG,EAASC,CAAO,CAAC,EAE/BC,EAAgB,CAC3BC,EACAF,IACeE,EAAQ,SAASF,CAAO,EAAI,CAAC,GAAGE,CAAO,EAAI,CAAC,GAAGA,EAASF,CAAO,EAEnEG,EAAoBC,GAC/B,OAAOA,GAAU,UACjBA,IAAU,MACV,SAAUA,GACV,OAAQA,EAA4B,MAAS,WAElCC,EAA0B,KAA8B,CACnE,MAAOC,EAAoB,KAC3B,UAAW,KACX,aAAc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AzC,EAAWD,EACT0C,EACAL,EACA/D,EACA2B,EAAS,OACTA,EAAS,MACT2C,CACF,EACA3C,EAAWT,EAAeS,EAAU,MAAM,EAAE,SAC5Cb,EAAgBa,CAAQ,EACxBK,EAAO,EACA2B,EAAgBhC,EAAU,GAAMnB,EAAW,EAAE,CACtD,CAEA,IAAMgE,EAAiBhE,EAAW,GAElCF,EACEF,EAAQ,MACRoE,EACA,sCAAsCA,CAAc,IACtD,EAEA,IAAMrD,EAAeuC,EAAmB/B,EAAU6C,EAAgBT,CAAW,EAC7E,OAAApC,EAAWT,EAAeC,EAAc,MAAM,EAAE,SAChDL,EAAgBa,CAAQ,EACxBK,EAAO,EAEA2B,EAAgBhC,EAAU,GAAMnB,EAAW,EAAE,CACtD,EAEMiE,EAAgB3C,EAAU,KAAKyB,EAAKA,CAAG,EAC7C,OAAAzB,EAAY2C,EAAc,KACxB,IAAG,GACH,IAAG,EACL,EACOA,CACT,CACF,CACF",
6
+ "names": ["index_exports", "__export", "HISTORY_TARGET", "JOURNEY_ASYNC_PHASE", "JOURNEY_EVENT", "JOURNEY_STATUS", "JOURNEY_TERMINAL", "JOURNEY_WILDCARD", "createJourneyMachine", "createPersistenceController", "__toCommonJS", "JOURNEY_TERMINAL", "JOURNEY_STATUS", "HISTORY_TARGET", "JOURNEY_WILDCARD", "JOURNEY_EVENT", "JOURNEY_ASYNC_PHASE", "assertStepExists", "steps", "stepId", "message", "unique", "items", "buildVisited", "history", "current", "appendVisited", "visited", "isPromiseLike", "value", "buildIdleStepAsyncState", "JOURNEY_ASYNC_PHASE", "buildInitialAsyncState", "isGoToEvent", "event", "JOURNEY_EVENT", "isTerminalTarget", "target", "JOURNEY_TERMINAL", "buildSendResult", "snapshot", "transitioned", "transitionId", "buildSnapshot", "context", "status", "asyncState", "resolveHistoryTarget", "cloned", "candidate", "selectTransition", "transitions", "hooks", "transition", "fromMatches", "JOURNEY_WILDCARD", "eventMatches", "guardResult", "asyncGuard", "allowed", "error", "transitionSnapshot", "nextCurrent", "nextContext", "isRecord", "value", "isStatusValue", "JOURNEY_STATUS", "resolveDefaultStorage", "localStorageCandidate", "resolvePersistence", "options", "storage", "coercePersistedSnapshot", "steps", "fallbackContext", "currentValue", "current", "history", "step", "status", "visitedRaw", "visited", "buildVisited", "needsRewrite", "createPersistenceController", "args", "initial", "context", "persistence", "reportPersistenceError", "error", "persistSnapshot", "snapshot", "persistedState", "removePersistedSnapshot", "hydrateSnapshot", "initialSnapshot", "buildSnapshot", "buildInitialAsyncState", "rawPersisted", "parsed", "persistedVersion", "persistedSnapshot", "shouldRewritePersisted", "coerced", "migrated", "hydratedSnapshot", "DEFAULT_MAX_HISTORY", "resolveMaxHistory", "value", "applyHistoryLimit", "history", "maxHistory", "trimCount", "createJourneyMachine", "journey", "options", "assertStepExists", "index", "transition", "JOURNEY_WILDCARD", "HISTORY_TARGET", "isTerminalTarget", "clearOnReset", "hydrateSnapshot", "persistSnapshot", "removePersistedSnapshot", "createPersistenceController", "historyOptions", "runHistoryTrim", "nextSnapshot", "reason", "overrideMaxHistory", "resolvedMaxHistory", "next", "trimmed", "rebuilt", "buildSnapshot", "snapshot", "hydratedTrim", "listeners", "sendQueue", "buildInitialAsyncState", "notify", "listener", "isAsyncLoadingPhase", "phase", "JOURNEY_ASYNC_PHASE", "updateStepAsync", "stepId", "updater", "current", "buildIdleStepAsyncState", "nextByStep", "isLoading", "state", "setStepLoading", "eventType", "transitionId", "setStepIdle", "setStepError", "error", "JOURNEY_STATUS", "resolvedStep", "result", "event", "run", "fromStep", "isGoToEvent", "transitionSnapshot", "buildSendResult", "JOURNEY_EVENT", "selectTransition", "currentTransition", "nextContext", "effectResultPromise", "isPromiseLike", "effectResult", "JOURNEY_TERMINAL", "target", "resolveHistoryTarget", "visited", "appendVisited", "resolvedTarget", "resultPromise"]
7
7
  }
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var C={COMPLETE:"COMPLETE",CLOSE:"CLOSE"},J={RUNNING:"running",COMPLETE:"complete",CLOSED:"closed"},U="__HISTORY__",_="*",b={GO_TO:"goTo"},g={IDLE:"idle",EVALUATING_WHEN:"evaluating-when",RUNNING_EFFECT:"running-effect",ERROR:"error"};var k=(e,r,o)=>{if(!(r in e))throw new Error(o)},Q=e=>[...new Set(e)],H=e=>typeof e=="object"&&e!==null&&"then"in e&&typeof e.then=="function",Y=()=>({phase:g.IDLE,eventType:null,transitionId:null,error:null}),O=e=>({isLoading:!1,byStep:Object.fromEntries(Object.keys(e).map(o=>[o,Y()]))}),F=e=>e.type===b.GO_TO&&"to"in e,G=e=>e===C.COMPLETE||e===C.CLOSE,N=(e,r,o)=>o?{transitioned:r,transitionId:o,snapshot:e}:{transitioned:r,snapshot:e},v=(e,r,o,p,i)=>({status:p,current:e,context:r,history:o,visited:Q([...o,e]),async:i}),z=(e,r)=>{let o=[...e.history];for(;o.length>0;){let p=o.pop();if(!p)break;if(p in r)return{target:p,history:o}}return{target:e.current,history:[...e.history]}},$=async(e,r,o,p)=>{for(let i of e){let a=i.from===_||i.from===r.current,f=i.event===o.type;if(!a||!f)continue;if(!i.when)return i;let u=i.when({context:r.context,from:r.current,history:r.history,event:o}),t=H(u);t&&p?.onAsyncGuardStart?.(i);let m;try{m=await u}catch(T){throw t&&p?.onAsyncGuardError?.(i,T),T}if(t&&p?.onAsyncGuardSuccess?.(i),m)return i}return null},L=(e,r,o)=>{let p=r===e.current?[...e.history]:[...e.history,e.current];return v(r,o,p,e.status,e.async)};var W=e=>typeof e=="object"&&e!==null,X=e=>e===J.RUNNING||e===J.COMPLETE||e===J.CLOSED,K=()=>{let e=globalThis.localStorage;return!e||typeof e.getItem!="function"||typeof e.setItem!="function"||typeof e.removeItem!="function"?null:e},Z=e=>{if(!e)return null;let r=e.storage??K();return r?{key:e.key,storage:r,version:e.version??1,clearOnReset:e.clearOnReset??!0,serialize:e.serialize??JSON.stringify,deserialize:e.deserialize??JSON.parse,...e.migrate?{migrate:e.migrate}:{},...e.onError?{onError:e.onError}:{}}:null},B=(e,r,o)=>{if(!W(e))return null;let p=e.current;if(typeof p!="string"||!(p in r))return null;let i=p,a=Array.isArray(e.history)?e.history.filter(u=>typeof u=="string"&&u in r):[],f=X(e.status)?e.status:J.RUNNING;return{current:i,context:"context"in e?e.context:o,history:a,status:f}},D=e=>{let{initial:r,context:o,steps:p,options:i}=e,a=Z(i?.persistence),f=T=>{a?.onError?.(T)},u=T=>{if(a)try{let E={version:a.version,snapshot:{current:T.current,context:T.context,history:[...T.history],status:T.status}};a.storage.setItem(a.key,a.serialize(E))}catch(E){f(E)}},t=()=>{if(a)try{a.storage.removeItem(a.key)}catch(T){f(T)}},m=()=>{let T=v(r,o,[],J.RUNNING,O(p));if(!a)return T;try{let E=a.storage.getItem(a.key);if(!E)return T;let c=a.deserialize(E);if(!W(c))return T;let A=c.version;if(typeof A!="number")return T;let x=null,M=!1;if(A===a.version)x=B(c.snapshot,p,o);else if(a.migrate){let w=a.migrate(c.snapshot,A);x=B(w,p,o),M=x!==null}if(!x)return T;let h=v(x.current,x.context,x.history,x.status,O(p));return M&&u(h),h}catch(E){return f(E),T}};return{clearOnReset:a?.clearOnReset??!0,hydrateSnapshot:m,persistSnapshot:u,removePersistedSnapshot:t}};var j=50,ee=e=>e===null?null:typeof e=="number"&&Number.isFinite(e)?Math.max(0,Math.trunc(e)):j,te=(e,r)=>{if(r===null||e.length<=r)return{next:[...e],trimmed:[]};let o=e.length-r;return{next:e.slice(o),trimmed:e.slice(0,o)}},ne=(e,r)=>{if(!e.steps||typeof e.steps!="object")throw new Error("Journey steps must be a record object.");if(!Array.isArray(e.transitions))throw new Error("Journey transitions must be an array.");k(e.steps,e.initial,`Journey initial step "${e.initial}" does not exist in steps registry.`);for(let[n,s]of e.transitions.entries()){if(!s||typeof s!="object")throw new Error(`Journey transition at index ${n} must be an object.`);if(typeof s.from!="string"||typeof s.event!="string")throw new Error(`Journey transition at index ${n} must define string "from" and "event".`);if(s.from!==_&&!(s.from in e.steps))throw new Error(`Journey transition at index ${n} references unknown from step "${s.from}".`);if(s.to!==U&&!G(s.to)&&!(s.to in e.steps))throw new Error(`Journey transition at index ${n} points to unknown step "${s.to}".`)}let{clearOnReset:o,hydrateSnapshot:p,persistSnapshot:i,removePersistedSnapshot:a}=D({initial:e.initial,context:e.context,steps:e.steps,...r?{options:r}:{}}),f=r?.history,u=(n,s,S)=>{let y=ee(S??f?.maxHistory),{next:d,trimmed:I}=te(n.history,y);if(I.length===0)return{snapshot:n,trimmed:I,maxHistory:y};let R=v(n.current,n.context,d,n.status,n.async);return f?.onOverflow?.({previous:n.history,next:d,trimmed:I,maxHistory:y,reason:s}),{snapshot:R,trimmed:I,maxHistory:y}},t=p(),m=u(t,"hydrate");t=m.snapshot,m.trimmed.length>0&&i(t);let T=new Set,E=Promise.resolve();t={...t,async:O(e.steps)};let c=()=>{for(let n of T)n()},A=n=>n===g.EVALUATING_WHEN||n===g.RUNNING_EFFECT,x=(n,s)=>{let S=t.async.byStep[n]??Y(),y=s(S);if(S.phase===y.phase&&S.eventType===y.eventType&&S.transitionId===y.transitionId&&S.error===y.error)return;let d={...t.async.byStep,[n]:y},I=Object.values(d).some(R=>A(R.phase));t={...t,async:{isLoading:I,byStep:d}},c()},M=(n,s,S,y)=>{x(n,()=>({phase:s,eventType:S,transitionId:y??null,error:null}))},h=n=>{x(n,()=>Y())},w=(n,s,S,y)=>{x(n,()=>({phase:g.ERROR,eventType:s,transitionId:y??null,error:S}))};return{getSnapshot:()=>t,subscribe:n=>(T.add(n),()=>{T.delete(n)}),reset:()=>(t=v(e.initial,e.context,[],J.RUNNING,O(e.steps)),o?a():i(t),c(),t),updateContext:n=>(t={...t,context:n(t.context)},i(t),c(),t),clearStepError:n=>{let s=n??t.current;return s in e.steps&&h(s),t},trimHistory:n=>{let s=u(t,"manual",n);return s.trimmed.length===0||(t=s.snapshot,i(t),c()),t},clearHistory:()=>(t.history.length===0||(t=v(t.current,t.context,[],t.status,t.async),i(t),c()),t),send:n=>{let s=async()=>{if(t.status!==J.RUNNING)return{transitioned:!1,snapshot:t};let y=t.current;if(F(n))return k(e.steps,n.to,`Cannot goTo unknown step "${n.to}".`),h(y),t=L(t,n.to,t.context),t=u(t,"auto").snapshot,i(t),c(),N(t,!0,b.GO_TO);let d;try{d=await $(e.transitions,t,n,{onAsyncGuardStart:l=>{M(y,g.EVALUATING_WHEN,n.type,l.id)},onAsyncGuardSuccess:()=>{h(y)},onAsyncGuardError:(l,P)=>{w(y,n.type,P,l.id)}})}catch(l){throw w(y,n.type,l),l}if(!d)return N(t,!1);let I=t.context;if(d.effect){let l=d.effect({context:t.context,from:t.current,history:t.history,event:n});H(l)&&M(y,g.RUNNING_EFFECT,n.type,d.id);let P;try{P=await l}catch(V){throw w(y,n.type,V,d.id),V}P!==void 0&&(I=P)}if(h(y),G(d.to))return t={...t,context:I,status:d.to===C.COMPLETE?J.COMPLETE:J.CLOSED},t=u(t,"auto").snapshot,i(t),c(),N(t,!0,d.id);if(d.to===U){let{target:l,history:P}=z(t,e.steps);return k(e.steps,l,`Transition points to unknown step "${l}".`),t=v(l,I,P,t.status,t.async),t=u(t,"auto").snapshot,i(t),c(),N(t,!0,d.id)}let R=d.to;k(e.steps,R,`Transition points to unknown step "${R}".`);let q=L(t,R,I);return t=u(q,"auto").snapshot,i(t),c(),N(t,!0,d.id)},S=E.then(s,s);return E=S.then(()=>{},()=>{}),S}}};export{U as HISTORY_TARGET,g as JOURNEY_ASYNC_PHASE,b as JOURNEY_EVENT,J as JOURNEY_STATUS,C as JOURNEY_TERMINAL,_ as JOURNEY_WILDCARD,ne as createJourneyMachine,D as createPersistenceController};
1
+ var N={COMPLETE:"COMPLETE",CLOSE:"CLOSE"},J={RUNNING:"running",COMPLETE:"complete",CLOSED:"closed"},Y="__HISTORY__",b="*",_={GO_TO:"goTo"},v={IDLE:"idle",EVALUATING_WHEN:"evaluating-when",RUNNING_EFFECT:"running-effect",ERROR:"error"};var k=(e,o,r)=>{if(!(o in e))throw new Error(r)},K=e=>[...new Set(e)],G=(e,o)=>K([...e,o]),L=(e,o)=>e.includes(o)?[...e]:[...e,o],V=e=>typeof e=="object"&&e!==null&&"then"in e&&typeof e.then=="function",H=()=>({phase:v.IDLE,eventType:null,transitionId:null,error:null}),A=e=>({isLoading:!1,byStep:Object.fromEntries(Object.keys(e).map(r=>[r,H()]))}),B=e=>e.type===_.GO_TO&&"to"in e,D=e=>e===N.COMPLETE||e===N.CLOSE,w=(e,o,r)=>r?{transitioned:o,transitionId:r,snapshot:e}:{transitioned:o,snapshot:e},h=(e,o,r,d,s,p)=>({status:d,current:e,context:o,history:r,visited:p?[...p]:G(r,e),async:s}),$=(e,o)=>{let r=[...e.history];for(;r.length>0;){let d=r.pop();if(!d)break;if(d in o)return{target:d,history:r}}return{target:e.current,history:[...e.history]}},W=async(e,o,r,d)=>{for(let s of e){let p=s.from===b||s.from===o.current,f=s.event===r.type;if(!p||!f)continue;if(!s.when)return s;let u=s.when({context:o.context,from:o.current,history:o.history,event:r}),t=V(u);t&&d?.onAsyncGuardStart?.(s);let g;try{g=await u}catch(i){throw t&&d?.onAsyncGuardError?.(s,i),i}if(t&&d?.onAsyncGuardSuccess?.(s),g)return s}return null},F=(e,o,r)=>{let d=o===e.current?[...e.history]:[...e.history,e.current],s=L(e.visited,o);return h(o,r,d,e.status,e.async,s)};var Q=e=>typeof e=="object"&&e!==null,Z=e=>e===J.RUNNING||e===J.COMPLETE||e===J.CLOSED,j=()=>{let e=globalThis.localStorage;return!e||typeof e.getItem!="function"||typeof e.setItem!="function"||typeof e.removeItem!="function"?null:e},ee=e=>{if(!e)return null;let o=e.storage??j();return o?{key:e.key,storage:o,version:e.version??1,clearOnReset:e.clearOnReset??!0,serialize:e.serialize??JSON.stringify,deserialize:e.deserialize??JSON.parse,...e.migrate?{migrate:e.migrate}:{},...e.onError?{onError:e.onError}:{}}:null},q=(e,o,r)=>{if(!Q(e))return null;let d=e.current;if(typeof d!="string"||!(d in o))return null;let s=d,p=Array.isArray(e.history)?e.history.filter(i=>typeof i=="string"&&i in o):[],f=Z(e.status)?e.status:J.RUNNING,u=Array.isArray(e.visited)?e.visited.filter(i=>typeof i=="string"&&i in o):null,t=u&&u.length>0?u:G(p,s),g=!u||u.length===0;return{snapshot:{current:s,context:"context"in e?e.context:r,history:p,status:f,visited:t},needsRewrite:g}},z=e=>{let{initial:o,context:r,steps:d,options:s}=e,p=ee(s?.persistence),f=i=>{p?.onError?.(i)},u=i=>{if(p)try{let E={version:p.version,snapshot:{current:i.current,context:i.context,history:[...i.history],status:i.status,visited:[...i.visited]}};p.storage.setItem(p.key,p.serialize(E))}catch(E){f(E)}},t=()=>{if(p)try{p.storage.removeItem(p.key)}catch(i){f(i)}},g=()=>{let i=h(o,r,[],J.RUNNING,A(d));if(!p)return i;try{let E=p.storage.getItem(p.key);if(!E)return i;let c=p.deserialize(E);if(!Q(c))return i;let M=c.version;if(typeof M!="number")return i;let x=null,O=!1;if(M===p.version){let m=q(c.snapshot,d,r);x=m?.snapshot??null,O=!!m?.needsRewrite}else if(p.migrate){let m=p.migrate(c.snapshot,M);x=q(m,d,r)?.snapshot??null,O=x!==null}if(!x)return i;let R=h(x.current,x.context,x.history,x.status,A(d),x.visited);return O&&u(R),R}catch(E){return f(E),i}};return{clearOnReset:p?.clearOnReset??!0,hydrateSnapshot:g,persistSnapshot:u,removePersistedSnapshot:t}};var te=50,ne=e=>e===null?null:typeof e=="number"&&Number.isFinite(e)?Math.max(0,Math.trunc(e)):te,oe=(e,o)=>{if(o===null||e.length<=o)return{next:[...e],trimmed:[]};let r=e.length-o;return{next:e.slice(r),trimmed:e.slice(0,r)}},re=(e,o)=>{if(!e.steps||typeof e.steps!="object")throw new Error("Journey steps must be a record object.");if(!Array.isArray(e.transitions))throw new Error("Journey transitions must be an array.");k(e.steps,e.initial,`Journey initial step "${e.initial}" does not exist in steps registry.`);for(let[n,a]of e.transitions.entries()){if(!a||typeof a!="object")throw new Error(`Journey transition at index ${n} must be an object.`);if(typeof a.from!="string"||typeof a.event!="string")throw new Error(`Journey transition at index ${n} must define string "from" and "event".`);if(a.from!==b&&!(a.from in e.steps))throw new Error(`Journey transition at index ${n} references unknown from step "${a.from}".`);if(a.to!==Y&&!D(a.to)&&!(a.to in e.steps))throw new Error(`Journey transition at index ${n} points to unknown step "${a.to}".`)}let{clearOnReset:r,hydrateSnapshot:d,persistSnapshot:s,removePersistedSnapshot:p}=z({initial:e.initial,context:e.context,steps:e.steps,...o?{options:o}:{}}),f=o?.history,u=(n,a,S)=>{let y=ne(S??f?.maxHistory),{next:T,trimmed:I}=oe(n.history,y);if(I.length===0)return{snapshot:n,trimmed:I,maxHistory:y};let P=h(n.current,n.context,T,n.status,n.async,n.visited);return f?.onOverflow?.({previous:n.history,next:T,trimmed:I,maxHistory:y,reason:a}),{snapshot:P,trimmed:I,maxHistory:y}},t=d(),g=u(t,"hydrate");t=g.snapshot,g.trimmed.length>0&&s(t);let i=new Set,E=Promise.resolve();t={...t,async:A(e.steps)};let c=()=>{for(let n of i)n()},M=n=>n===v.EVALUATING_WHEN||n===v.RUNNING_EFFECT,x=(n,a)=>{let S=t.async.byStep[n]??H(),y=a(S);if(S.phase===y.phase&&S.eventType===y.eventType&&S.transitionId===y.transitionId&&S.error===y.error)return;let T={...t.async.byStep,[n]:y},I=Object.values(T).some(P=>M(P.phase));t={...t,async:{isLoading:I,byStep:T}},c()},O=(n,a,S,y)=>{x(n,()=>({phase:a,eventType:S,transitionId:y??null,error:null}))},R=n=>{x(n,()=>H())},m=(n,a,S,y)=>{x(n,()=>({phase:v.ERROR,eventType:a,transitionId:y??null,error:S}))};return{getSnapshot:()=>t,subscribe:n=>(i.add(n),()=>{i.delete(n)}),reset:()=>(t=h(e.initial,e.context,[],J.RUNNING,A(e.steps)),r?p():s(t),c(),t),updateContext:n=>(t={...t,context:n(t.context)},s(t),c(),t),clearStepError:n=>{let a=n??t.current;return a in e.steps&&R(a),t},trimHistory:n=>{let a=u(t,"manual",n);return a.trimmed.length===0||(t=a.snapshot,s(t),c()),t},clearHistory:()=>(t.history.length===0||(t=h(t.current,t.context,[],t.status,t.async,t.visited),s(t),c()),t),send:n=>{let a=async()=>{if(t.status!==J.RUNNING)return{transitioned:!1,snapshot:t};let y=t.current;if(B(n))return k(e.steps,n.to,`Cannot goTo unknown step "${n.to}".`),R(y),t=F(t,n.to,t.context),t=u(t,"auto").snapshot,s(t),c(),w(t,!0,_.GO_TO);let T;try{T=await W(e.transitions,t,n,{onAsyncGuardStart:l=>{O(y,v.EVALUATING_WHEN,n.type,l.id)},onAsyncGuardSuccess:()=>{R(y)},onAsyncGuardError:(l,C)=>{m(y,n.type,C,l.id)}})}catch(l){throw m(y,n.type,l),l}if(!T)return w(t,!1);let I=t.context;if(T.effect){let l=T.effect({context:t.context,from:t.current,history:t.history,event:n});V(l)&&O(y,v.RUNNING_EFFECT,n.type,T.id);let C;try{C=await l}catch(U){throw m(y,n.type,U,T.id),U}C!==void 0&&(I=C)}if(R(y),D(T.to))return t={...t,context:I,status:T.to===N.COMPLETE?J.COMPLETE:J.CLOSED},t=u(t,"auto").snapshot,s(t),c(),w(t,!0,T.id);if(T.to===Y){let{target:l,history:C}=$(t,e.steps);k(e.steps,l,`Transition points to unknown step "${l}".`);let U=L(t.visited,l);return t=h(l,I,C,t.status,t.async,U),t=u(t,"auto").snapshot,s(t),c(),w(t,!0,T.id)}let P=T.to;k(e.steps,P,`Transition points to unknown step "${P}".`);let X=F(t,P,I);return t=u(X,"auto").snapshot,s(t),c(),w(t,!0,T.id)},S=E.then(a,a);return E=S.then(()=>{},()=>{}),S}}};export{Y as HISTORY_TARGET,v as JOURNEY_ASYNC_PHASE,_ as JOURNEY_EVENT,J as JOURNEY_STATUS,N as JOURNEY_TERMINAL,b as JOURNEY_WILDCARD,re as createJourneyMachine,z as createPersistenceController};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/types.ts", "../src/machine-helpers.ts", "../src/persistence.ts", "../src/machine.ts"],
4
- "sourcesContent": ["export const JOURNEY_TERMINAL = {\n COMPLETE: \"COMPLETE\",\n CLOSE: \"CLOSE\"\n} as const;\n\nexport type JourneyTerminal = (typeof JOURNEY_TERMINAL)[keyof typeof JOURNEY_TERMINAL];\n\nexport const JOURNEY_STATUS = {\n RUNNING: \"running\",\n COMPLETE: \"complete\",\n CLOSED: \"closed\"\n} as const;\n\nexport type JourneyStatus = (typeof JOURNEY_STATUS)[keyof typeof JOURNEY_STATUS];\n\nexport const HISTORY_TARGET = \"__HISTORY__\" as const;\nexport const JOURNEY_WILDCARD = \"*\" as const;\n\nexport const JOURNEY_EVENT = {\n GO_TO: \"goTo\"\n} as const;\n\nexport type JourneyBuiltInEvent = (typeof JOURNEY_EVENT)[keyof typeof JOURNEY_EVENT];\nexport type JourneyBuiltInFrom = typeof JOURNEY_WILDCARD;\n\nexport const JOURNEY_ASYNC_PHASE = {\n IDLE: \"idle\",\n EVALUATING_WHEN: \"evaluating-when\",\n RUNNING_EFFECT: \"running-effect\",\n ERROR: \"error\"\n} as const;\n\nexport type JourneyAsyncPhase = (typeof JOURNEY_ASYNC_PHASE)[keyof typeof JOURNEY_ASYNC_PHASE];\n\nexport type JourneyStepAsyncState = {\n phase: JourneyAsyncPhase;\n eventType: string | null;\n transitionId: string | null;\n error: unknown | null;\n};\n\nexport type JourneyAsyncState<TStepId extends string> = {\n isLoading: boolean;\n byStep: Record<TStepId, JourneyStepAsyncState>;\n};\n\nexport type JourneyBaseEvent = {\n type: string;\n payload?: unknown;\n};\n\nexport type JourneyEventPayloadMap<TEventType extends string> = Partial<\n Record<TEventType | JourneyBuiltInEvent, unknown>\n>;\n\nexport type JourneyPayloadFor<\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType>,\n TEvent extends TEventType | JourneyBuiltInEvent\n> = TEvent extends keyof TPayloadMap ? TPayloadMap[TEvent] : unknown;\n\nexport type JourneyGoToEvent<TStepId extends string, TPayload = unknown> = {\n type: (typeof JOURNEY_EVENT)[\"GO_TO\"];\n to: TStepId;\n payload?: TPayload;\n};\n\nexport type JourneyEvent<\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> =\n | JourneyGoToEvent<\n TStepId,\n JourneyPayloadFor<TEventType, TPayloadMap, (typeof JOURNEY_EVENT)[\"GO_TO\"]>\n >\n | {\n [TType in TEventType]: {\n type: TType;\n payload?: JourneyPayloadFor<TEventType, TPayloadMap, TType>;\n };\n }[TEventType];\n\nexport type JourneyTransitionArgs<\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> = {\n context: TContext;\n from: TStepId;\n history: readonly TStepId[];\n event: JourneyEvent<TStepId, TEventType, TPayloadMap>;\n};\n\nexport type JourneyTransitionTarget<TStepId extends string> =\n | TStepId\n | JourneyTerminal\n | typeof HISTORY_TARGET;\n\nexport type JourneyTransition<\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> = {\n id?: string;\n from: TStepId | JourneyBuiltInFrom;\n event: TEventType | (typeof JOURNEY_EVENT)[\"GO_TO\"];\n to: JourneyTransitionTarget<TStepId>;\n when?: (\n args: JourneyTransitionArgs<TContext, TStepId, TEventType, TPayloadMap>\n ) => boolean | Promise<boolean>;\n effect?: (\n args: JourneyTransitionArgs<TContext, TStepId, TEventType, TPayloadMap>\n ) => TContext | void | Promise<TContext | void>;\n};\n\nexport type JourneySnapshot<TContext, TStepId extends string> = {\n current: TStepId;\n context: TContext;\n history: readonly TStepId[];\n visited: readonly TStepId[];\n status: JourneyStatus;\n async: JourneyAsyncState<TStepId>;\n};\n\nexport type JourneyPersistedSnapshot<TContext, TStepId extends string> = {\n current: TStepId;\n context: TContext;\n history: readonly TStepId[];\n status: JourneyStatus;\n};\n\nexport type JourneyPersistedState<TContext, TStepId extends string> = {\n version: number;\n snapshot: JourneyPersistedSnapshot<TContext, TStepId>;\n};\n\nexport type JourneyHistoryOverflowReason = \"auto\" | \"hydrate\" | \"manual\";\n\nexport type JourneyHistoryOverflow<TStepId extends string> = {\n previous: readonly TStepId[];\n next: readonly TStepId[];\n trimmed: readonly TStepId[];\n maxHistory: number | null;\n reason: JourneyHistoryOverflowReason;\n};\n\nexport type JourneyHistoryOptions<TStepId extends string> = {\n maxHistory?: number | null;\n onOverflow?: (info: JourneyHistoryOverflow<TStepId>) => void;\n};\n\nexport type JourneyStorage = {\n getItem: (key: string) => string | null;\n setItem: (key: string, value: string) => void;\n removeItem: (key: string) => void;\n};\n\nexport type JourneyPersistenceOptions<TContext, TStepId extends string> = {\n key: string;\n storage?: JourneyStorage;\n version?: number;\n clearOnReset?: boolean;\n serialize?: (value: JourneyPersistedState<TContext, TStepId>) => string;\n deserialize?: (value: string) => unknown;\n migrate?: (\n value: unknown,\n persistedVersion: number\n ) => JourneyPersistedSnapshot<TContext, TStepId>;\n onError?: (error: unknown) => void;\n};\n\nexport type JourneyDefinition<\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> = {\n initial: TStepId;\n context: TContext;\n steps: Record<TStepId, unknown>;\n transitions: readonly JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>[];\n};\n\nexport type JourneyMachineOptions<TContext, TStepId extends string> = {\n persistence?: JourneyPersistenceOptions<TContext, TStepId>;\n history?: JourneyHistoryOptions<TStepId>;\n};\n\nexport type JourneySendResult<TContext, TStepId extends string> = {\n transitioned: boolean;\n transitionId?: string;\n snapshot: JourneySnapshot<TContext, TStepId>;\n};\n\nexport type JourneyMachine<\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> = {\n getSnapshot: () => JourneySnapshot<TContext, TStepId>;\n send: (\n event: JourneyEvent<TStepId, TEventType, TPayloadMap>\n ) => Promise<JourneySendResult<TContext, TStepId>>;\n updateContext: (updater: (context: TContext) => TContext) => JourneySnapshot<TContext, TStepId>;\n clearStepError: (stepId?: TStepId) => JourneySnapshot<TContext, TStepId>;\n reset: () => JourneySnapshot<TContext, TStepId>;\n trimHistory: (maxHistory?: number | null) => JourneySnapshot<TContext, TStepId>;\n clearHistory: () => JourneySnapshot<TContext, TStepId>;\n subscribe: (listener: () => void) => () => void;\n};\n", "import { JOURNEY_ASYNC_PHASE, JOURNEY_EVENT, JOURNEY_TERMINAL, JOURNEY_WILDCARD } from \"./types\";\nimport type {\n JourneyAsyncState,\n JourneyEvent,\n JourneyEventPayloadMap,\n JourneyGoToEvent,\n JourneyPayloadFor,\n JourneySendResult,\n JourneySnapshot,\n JourneyStatus,\n JourneyStepAsyncState,\n JourneyTerminal,\n JourneyTransition\n} from \"./types\";\n\nexport const assertStepExists = <TStepId extends string>(\n steps: Record<TStepId, unknown>,\n stepId: TStepId,\n message: string\n) => {\n if (!(stepId in steps)) {\n throw new Error(message);\n }\n};\n\nconst unique = <T>(items: readonly T[]): T[] => [...new Set(items)];\n\nexport const isPromiseLike = <T>(value: T | PromiseLike<T>): value is PromiseLike<T> =>\n typeof value === \"object\" &&\n value !== null &&\n \"then\" in value &&\n typeof (value as { then: unknown }).then === \"function\";\n\nexport const buildIdleStepAsyncState = (): JourneyStepAsyncState => ({\n phase: JOURNEY_ASYNC_PHASE.IDLE,\n eventType: null,\n transitionId: null,\n error: null\n});\n\nexport const buildInitialAsyncState = <TStepId extends string>(\n steps: Record<TStepId, unknown>\n): JourneyAsyncState<TStepId> => {\n const byStep = Object.fromEntries(\n Object.keys(steps).map((stepId) => [stepId, buildIdleStepAsyncState()])\n ) as Record<TStepId, JourneyStepAsyncState>;\n\n return {\n isLoading: false,\n byStep\n };\n};\n\nexport const isGoToEvent = <\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType>\n>(\n event: JourneyEvent<TStepId, TEventType, TPayloadMap>\n): event is JourneyGoToEvent<\n TStepId,\n JourneyPayloadFor<TEventType, TPayloadMap, (typeof JOURNEY_EVENT)[\"GO_TO\"]>\n> => event.type === JOURNEY_EVENT.GO_TO && \"to\" in event;\n\nexport const isTerminalTarget = <TStepId extends string>(\n target: TStepId | JourneyTerminal | \"__HISTORY__\"\n): target is JourneyTerminal =>\n target === JOURNEY_TERMINAL.COMPLETE || target === JOURNEY_TERMINAL.CLOSE;\n\nexport const buildSendResult = <TContext, TStepId extends string>(\n snapshot: JourneySnapshot<TContext, TStepId>,\n transitioned: boolean,\n transitionId?: string\n): JourneySendResult<TContext, TStepId> =>\n transitionId ? { transitioned, transitionId, snapshot } : { transitioned, snapshot };\n\nexport const buildSnapshot = <TContext, TStepId extends string>(\n current: TStepId,\n context: TContext,\n history: readonly TStepId[],\n status: JourneyStatus,\n asyncState: JourneyAsyncState<TStepId>\n): JourneySnapshot<TContext, TStepId> => ({\n status,\n current,\n context,\n history,\n visited: unique([...history, current]),\n async: asyncState\n});\n\nexport const resolveHistoryTarget = <TContext, TStepId extends string>(\n snapshot: JourneySnapshot<TContext, TStepId>,\n steps: Record<TStepId, unknown>\n): { target: TStepId; history: TStepId[] } => {\n const cloned = [...snapshot.history];\n\n while (cloned.length > 0) {\n const candidate = cloned.pop();\n if (!candidate) {\n break;\n }\n if (candidate in steps) {\n return {\n target: candidate,\n history: cloned\n };\n }\n }\n\n return {\n target: snapshot.current,\n history: [...snapshot.history]\n };\n};\n\nexport const selectTransition = async <\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType>\n>(\n transitions: readonly JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>[],\n snapshot: JourneySnapshot<TContext, TStepId>,\n event: JourneyEvent<TStepId, TEventType, TPayloadMap>,\n hooks?: {\n onAsyncGuardStart?: (\n transition: JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>\n ) => void;\n onAsyncGuardSuccess?: (\n transition: JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>\n ) => void;\n onAsyncGuardError?: (\n transition: JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>,\n error: unknown\n ) => void;\n }\n): Promise<JourneyTransition<TContext, TStepId, TEventType, TPayloadMap> | null> => {\n for (const transition of transitions) {\n const fromMatches =\n transition.from === JOURNEY_WILDCARD || transition.from === snapshot.current;\n const eventMatches = transition.event === event.type;\n\n if (!fromMatches || !eventMatches) {\n continue;\n }\n\n if (!transition.when) {\n return transition;\n }\n\n const guardResult = transition.when({\n context: snapshot.context,\n from: snapshot.current,\n history: snapshot.history,\n event\n });\n const asyncGuard = isPromiseLike(guardResult);\n if (asyncGuard) {\n hooks?.onAsyncGuardStart?.(transition);\n }\n\n let allowed: boolean;\n try {\n allowed = await guardResult;\n } catch (error) {\n if (asyncGuard) {\n hooks?.onAsyncGuardError?.(transition, error);\n }\n throw error;\n }\n\n if (asyncGuard) {\n hooks?.onAsyncGuardSuccess?.(transition);\n }\n\n if (allowed) {\n return transition;\n }\n }\n\n return null;\n};\n\nexport const transitionSnapshot = <TContext, TStepId extends string>(\n snapshot: JourneySnapshot<TContext, TStepId>,\n nextCurrent: TStepId,\n nextContext: TContext\n): JourneySnapshot<TContext, TStepId> => {\n const history =\n nextCurrent === snapshot.current\n ? [...snapshot.history]\n : [...snapshot.history, snapshot.current];\n\n return buildSnapshot(nextCurrent, nextContext, history, snapshot.status, snapshot.async);\n};\n", "import { JOURNEY_STATUS } from \"./types\";\nimport type {\n JourneyMachineOptions,\n JourneyPersistedSnapshot,\n JourneyPersistedState,\n JourneyStatus,\n JourneySnapshot,\n JourneyStorage\n} from \"./types\";\nimport { buildInitialAsyncState, buildSnapshot } from \"./machine-helpers\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isStatusValue = (value: unknown): value is JourneyStatus =>\n value === JOURNEY_STATUS.RUNNING ||\n value === JOURNEY_STATUS.COMPLETE ||\n value === JOURNEY_STATUS.CLOSED;\n\nconst resolveDefaultStorage = (): JourneyStorage | null => {\n const localStorageCandidate = (globalThis as { localStorage?: Partial<JourneyStorage> })\n .localStorage;\n\n if (\n !localStorageCandidate ||\n typeof localStorageCandidate.getItem !== \"function\" ||\n typeof localStorageCandidate.setItem !== \"function\" ||\n typeof localStorageCandidate.removeItem !== \"function\"\n ) {\n return null;\n }\n\n return localStorageCandidate as JourneyStorage;\n};\n\ntype ResolvedPersistence<TContext, TStepId extends string> = {\n key: string;\n storage: JourneyStorage;\n version: number;\n clearOnReset: boolean;\n serialize: (value: JourneyPersistedState<TContext, TStepId>) => string;\n deserialize: (value: string) => unknown;\n migrate?: (\n value: unknown,\n persistedVersion: number\n ) => JourneyPersistedSnapshot<TContext, TStepId>;\n onError?: (error: unknown) => void;\n};\n\nconst resolvePersistence = <TContext, TStepId extends string>(\n options?: JourneyMachineOptions<TContext, TStepId>[\"persistence\"]\n): ResolvedPersistence<TContext, TStepId> | null => {\n if (!options) {\n return null;\n }\n\n const storage = options.storage ?? resolveDefaultStorage();\n if (!storage) {\n return null;\n }\n\n return {\n key: options.key,\n storage,\n version: options.version ?? 1,\n clearOnReset: options.clearOnReset ?? true,\n serialize: options.serialize ?? JSON.stringify,\n deserialize: options.deserialize ?? JSON.parse,\n ...(options.migrate ? { migrate: options.migrate } : {}),\n ...(options.onError ? { onError: options.onError } : {})\n };\n};\n\nconst coercePersistedSnapshot = <TContext, TStepId extends string>(\n value: unknown,\n steps: Record<TStepId, unknown>,\n fallbackContext: TContext\n): JourneyPersistedSnapshot<TContext, TStepId> | null => {\n if (!isRecord(value)) {\n return null;\n }\n\n const currentValue = value.current;\n if (typeof currentValue !== \"string\" || !(currentValue in steps)) {\n return null;\n }\n const current = currentValue as TStepId;\n\n const history = Array.isArray(value.history)\n ? (value.history.filter(\n (step): step is TStepId => typeof step === \"string\" && step in steps\n ) as TStepId[])\n : [];\n\n const status = isStatusValue(value.status) ? value.status : JOURNEY_STATUS.RUNNING;\n\n return {\n current,\n context: (\"context\" in value ? value.context : fallbackContext) as TContext,\n history,\n status\n };\n};\n\n/**\n * Creates a persistence controller for snapshots, including hydration,\n * serialization, and storage error handling.\n */\nexport const createPersistenceController = <TContext, TStepId extends string>(args: {\n initial: TStepId;\n context: TContext;\n steps: Record<TStepId, unknown>;\n options?: JourneyMachineOptions<TContext, TStepId>;\n}) => {\n const { initial, context, steps, options } = args;\n const persistence = resolvePersistence(options?.persistence);\n\n const reportPersistenceError = (error: unknown) => {\n persistence?.onError?.(error);\n };\n\n const persistSnapshot = (snapshot: JourneySnapshot<TContext, TStepId>) => {\n if (!persistence) {\n return;\n }\n\n try {\n const persistedState: JourneyPersistedState<TContext, TStepId> = {\n version: persistence.version,\n snapshot: {\n current: snapshot.current,\n context: snapshot.context,\n history: [...snapshot.history],\n status: snapshot.status\n }\n };\n persistence.storage.setItem(persistence.key, persistence.serialize(persistedState));\n } catch (error) {\n reportPersistenceError(error);\n }\n };\n\n const removePersistedSnapshot = () => {\n if (!persistence) {\n return;\n }\n\n try {\n persistence.storage.removeItem(persistence.key);\n } catch (error) {\n reportPersistenceError(error);\n }\n };\n\n const hydrateSnapshot = (): JourneySnapshot<TContext, TStepId> => {\n const initialSnapshot = buildSnapshot(\n initial,\n context,\n [],\n JOURNEY_STATUS.RUNNING,\n buildInitialAsyncState(steps)\n );\n if (!persistence) {\n return initialSnapshot;\n }\n\n try {\n const rawPersisted = persistence.storage.getItem(persistence.key);\n if (!rawPersisted) {\n return initialSnapshot;\n }\n\n const parsed = persistence.deserialize(rawPersisted);\n if (!isRecord(parsed)) {\n return initialSnapshot;\n }\n\n const persistedVersion = parsed.version;\n if (typeof persistedVersion !== \"number\") {\n return initialSnapshot;\n }\n\n let persistedSnapshot: JourneyPersistedSnapshot<TContext, TStepId> | null = null;\n let shouldRewritePersisted = false;\n\n if (persistedVersion === persistence.version) {\n persistedSnapshot = coercePersistedSnapshot(parsed.snapshot, steps, context);\n } else if (persistence.migrate) {\n const migrated = persistence.migrate(parsed.snapshot, persistedVersion);\n persistedSnapshot = coercePersistedSnapshot(migrated, steps, context);\n shouldRewritePersisted = persistedSnapshot !== null;\n }\n\n if (!persistedSnapshot) {\n return initialSnapshot;\n }\n\n const hydratedSnapshot = buildSnapshot(\n persistedSnapshot.current,\n persistedSnapshot.context,\n persistedSnapshot.history,\n persistedSnapshot.status,\n buildInitialAsyncState(steps)\n );\n\n if (shouldRewritePersisted) {\n persistSnapshot(hydratedSnapshot);\n }\n\n return hydratedSnapshot;\n } catch (error) {\n reportPersistenceError(error);\n return initialSnapshot;\n }\n };\n\n return {\n clearOnReset: persistence?.clearOnReset ?? true,\n hydrateSnapshot,\n persistSnapshot,\n removePersistedSnapshot\n };\n};\n", "import {\n JOURNEY_ASYNC_PHASE,\n JOURNEY_EVENT,\n JOURNEY_STATUS,\n JOURNEY_TERMINAL,\n JOURNEY_WILDCARD,\n HISTORY_TARGET\n} from \"./types\";\nimport type {\n JourneyAsyncState,\n JourneyAsyncPhase,\n JourneyEventPayloadMap,\n JourneyDefinition,\n JourneyHistoryOverflowReason,\n JourneyHistoryOptions,\n JourneyMachine,\n JourneyMachineOptions,\n JourneySendResult,\n JourneySnapshot\n} from \"./types\";\nimport {\n assertStepExists,\n buildIdleStepAsyncState,\n buildInitialAsyncState,\n buildSendResult,\n isGoToEvent,\n isPromiseLike,\n isTerminalTarget,\n resolveHistoryTarget,\n selectTransition,\n transitionSnapshot,\n buildSnapshot\n} from \"./machine-helpers\";\nimport { createPersistenceController } from \"./persistence\";\n\nconst DEFAULT_MAX_HISTORY = 50;\n\nconst resolveMaxHistory = (value: number | null | undefined): number | null => {\n if (value === null) {\n return null;\n }\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return Math.max(0, Math.trunc(value));\n }\n return DEFAULT_MAX_HISTORY;\n};\n\nconst applyHistoryLimit = <TStepId extends string>(\n history: readonly TStepId[],\n maxHistory: number | null\n): { next: TStepId[]; trimmed: TStepId[] } => {\n if (maxHistory === null || history.length <= maxHistory) {\n return { next: [...history], trimmed: [] };\n }\n\n const trimCount = history.length - maxHistory;\n return {\n next: history.slice(trimCount),\n trimmed: history.slice(0, trimCount)\n };\n};\n\n/**\n * Creates a journey machine from a journey definition.\n * Validates steps/transitions, hydrates persisted state (if configured),\n * and returns an API for sending events and reading snapshots.\n */\nexport const createJourneyMachine = <\n TContext,\n TStepId extends string,\n TEventType extends string = \"next\" | \"back\" | \"close\" | \"submit\",\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n>(\n journey: JourneyDefinition<TContext, TStepId, TEventType, TPayloadMap>,\n options?: JourneyMachineOptions<TContext, TStepId>\n): JourneyMachine<TContext, TStepId, TEventType, TPayloadMap> => {\n if (!journey.steps || typeof journey.steps !== \"object\") {\n throw new Error(\"Journey steps must be a record object.\");\n }\n\n if (!Array.isArray(journey.transitions)) {\n throw new Error(\"Journey transitions must be an array.\");\n }\n\n assertStepExists(\n journey.steps,\n journey.initial,\n `Journey initial step \"${journey.initial}\" does not exist in steps registry.`\n );\n\n for (const [index, transition] of journey.transitions.entries()) {\n if (!transition || typeof transition !== \"object\") {\n throw new Error(`Journey transition at index ${index} must be an object.`);\n }\n\n if (typeof transition.from !== \"string\" || typeof transition.event !== \"string\") {\n throw new Error(\n `Journey transition at index ${index} must define string \"from\" and \"event\".`\n );\n }\n\n if (\n transition.from !== JOURNEY_WILDCARD &&\n !((transition.from as string) in (journey.steps as Record<string, unknown>))\n ) {\n throw new Error(\n `Journey transition at index ${index} references unknown from step \"${transition.from}\".`\n );\n }\n\n if (\n transition.to !== HISTORY_TARGET &&\n !isTerminalTarget(transition.to) &&\n !((transition.to as string) in (journey.steps as Record<string, unknown>))\n ) {\n throw new Error(\n `Journey transition at index ${index} points to unknown step \"${transition.to}\".`\n );\n }\n }\n\n const { clearOnReset, hydrateSnapshot, persistSnapshot, removePersistedSnapshot } =\n createPersistenceController({\n initial: journey.initial,\n context: journey.context,\n steps: journey.steps,\n ...(options ? { options } : {})\n });\n\n const historyOptions: JourneyHistoryOptions<TStepId> | undefined = options?.history;\n\n const runHistoryTrim = (\n nextSnapshot: JourneySnapshot<TContext, TStepId>,\n reason: JourneyHistoryOverflowReason,\n overrideMaxHistory?: number | null\n ): {\n snapshot: JourneySnapshot<TContext, TStepId>;\n trimmed: TStepId[];\n maxHistory: number | null;\n } => {\n const resolvedMaxHistory = resolveMaxHistory(overrideMaxHistory ?? historyOptions?.maxHistory);\n const { next, trimmed } = applyHistoryLimit(nextSnapshot.history, resolvedMaxHistory);\n if (trimmed.length === 0) {\n return {\n snapshot: nextSnapshot,\n trimmed,\n maxHistory: resolvedMaxHistory\n };\n }\n\n const rebuilt = buildSnapshot(\n nextSnapshot.current,\n nextSnapshot.context,\n next,\n nextSnapshot.status,\n nextSnapshot.async\n );\n\n historyOptions?.onOverflow?.({\n previous: nextSnapshot.history,\n next,\n trimmed,\n maxHistory: resolvedMaxHistory,\n reason\n });\n\n return {\n snapshot: rebuilt,\n trimmed,\n maxHistory: resolvedMaxHistory\n };\n };\n\n let snapshot = hydrateSnapshot();\n const hydratedTrim = runHistoryTrim(snapshot, \"hydrate\");\n snapshot = hydratedTrim.snapshot;\n if (hydratedTrim.trimmed.length > 0) {\n persistSnapshot(snapshot);\n }\n const listeners = new Set<() => void>();\n let sendQueue: Promise<void> = Promise.resolve();\n snapshot = {\n ...snapshot,\n async: buildInitialAsyncState(journey.steps)\n };\n\n const notify = () => {\n for (const listener of listeners) {\n listener();\n }\n };\n\n const isAsyncLoadingPhase = (phase: JourneyAsyncPhase): boolean =>\n phase === JOURNEY_ASYNC_PHASE.EVALUATING_WHEN || phase === JOURNEY_ASYNC_PHASE.RUNNING_EFFECT;\n\n const updateStepAsync = (\n stepId: TStepId,\n updater: (\n current: JourneyAsyncState<TStepId>[\"byStep\"][TStepId]\n ) => JourneyAsyncState<TStepId>[\"byStep\"][TStepId]\n ) => {\n const current = snapshot.async.byStep[stepId] ?? buildIdleStepAsyncState();\n const next = updater(current);\n if (\n current.phase === next.phase &&\n current.eventType === next.eventType &&\n current.transitionId === next.transitionId &&\n current.error === next.error\n ) {\n return;\n }\n const nextByStep = {\n ...snapshot.async.byStep,\n [stepId]: next\n };\n const isLoading = Object.values(nextByStep).some((state) => isAsyncLoadingPhase(state.phase));\n snapshot = {\n ...snapshot,\n async: {\n isLoading,\n byStep: nextByStep\n }\n };\n notify();\n };\n\n const setStepLoading = (\n stepId: TStepId,\n phase: JourneyAsyncPhase,\n eventType: string,\n transitionId?: string\n ) => {\n updateStepAsync(stepId, () => ({\n phase,\n eventType,\n transitionId: transitionId ?? null,\n error: null\n }));\n };\n\n const setStepIdle = (stepId: TStepId) => {\n updateStepAsync(stepId, () => buildIdleStepAsyncState());\n };\n\n const setStepError = (\n stepId: TStepId,\n eventType: string,\n error: unknown,\n transitionId?: string\n ) => {\n updateStepAsync(stepId, () => ({\n phase: JOURNEY_ASYNC_PHASE.ERROR,\n eventType,\n transitionId: transitionId ?? null,\n error\n }));\n };\n\n return {\n getSnapshot: () => snapshot,\n subscribe: (listener) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n reset: () => {\n snapshot = buildSnapshot(\n journey.initial,\n journey.context,\n [],\n JOURNEY_STATUS.RUNNING,\n buildInitialAsyncState(journey.steps)\n );\n if (clearOnReset) {\n removePersistedSnapshot();\n } else {\n persistSnapshot(snapshot);\n }\n notify();\n return snapshot;\n },\n updateContext: (updater) => {\n snapshot = {\n ...snapshot,\n context: updater(snapshot.context)\n };\n persistSnapshot(snapshot);\n notify();\n return snapshot;\n },\n clearStepError: (stepId) => {\n const resolvedStep = stepId ?? snapshot.current;\n if (!(resolvedStep in journey.steps)) {\n return snapshot;\n }\n\n setStepIdle(resolvedStep);\n return snapshot;\n },\n trimHistory: (maxHistory) => {\n const result = runHistoryTrim(snapshot, \"manual\", maxHistory);\n if (result.trimmed.length === 0) {\n return snapshot;\n }\n snapshot = result.snapshot;\n persistSnapshot(snapshot);\n notify();\n return snapshot;\n },\n clearHistory: () => {\n if (snapshot.history.length === 0) {\n return snapshot;\n }\n snapshot = buildSnapshot(\n snapshot.current,\n snapshot.context,\n [],\n snapshot.status,\n snapshot.async\n );\n persistSnapshot(snapshot);\n notify();\n return snapshot;\n },\n send: (event) => {\n const run = async (): Promise<JourneySendResult<TContext, TStepId>> => {\n if (snapshot.status !== JOURNEY_STATUS.RUNNING) {\n return { transitioned: false, snapshot };\n }\n\n const fromStep = snapshot.current;\n\n if (isGoToEvent(event)) {\n assertStepExists(journey.steps, event.to, `Cannot goTo unknown step \"${event.to}\".`);\n setStepIdle(fromStep);\n snapshot = transitionSnapshot(snapshot, event.to, snapshot.context);\n snapshot = runHistoryTrim(snapshot, \"auto\").snapshot;\n persistSnapshot(snapshot);\n notify();\n return buildSendResult(snapshot, true, JOURNEY_EVENT.GO_TO);\n }\n\n let transition;\n try {\n transition = await selectTransition(journey.transitions, snapshot, event, {\n onAsyncGuardStart: (currentTransition) => {\n setStepLoading(\n fromStep,\n JOURNEY_ASYNC_PHASE.EVALUATING_WHEN,\n event.type,\n currentTransition.id\n );\n },\n onAsyncGuardSuccess: () => {\n setStepIdle(fromStep);\n },\n onAsyncGuardError: (currentTransition, error) => {\n setStepError(fromStep, event.type, error, currentTransition.id);\n }\n });\n } catch (error) {\n setStepError(fromStep, event.type, error);\n throw error;\n }\n\n if (!transition) {\n return buildSendResult(snapshot, false);\n }\n\n let nextContext = snapshot.context;\n if (transition.effect) {\n const effectResultPromise = transition.effect({\n context: snapshot.context,\n from: snapshot.current,\n history: snapshot.history,\n event\n });\n if (isPromiseLike(effectResultPromise)) {\n setStepLoading(\n fromStep,\n JOURNEY_ASYNC_PHASE.RUNNING_EFFECT,\n event.type as string,\n transition.id\n );\n }\n\n let effectResult: TContext | void;\n try {\n effectResult = await effectResultPromise;\n } catch (error) {\n setStepError(fromStep, event.type, error, transition.id);\n throw error;\n }\n\n if (effectResult !== undefined) {\n nextContext = effectResult;\n }\n }\n\n setStepIdle(fromStep);\n\n if (isTerminalTarget(transition.to)) {\n snapshot = {\n ...snapshot,\n context: nextContext,\n status:\n transition.to === JOURNEY_TERMINAL.COMPLETE\n ? JOURNEY_STATUS.COMPLETE\n : JOURNEY_STATUS.CLOSED\n };\n snapshot = runHistoryTrim(snapshot, \"auto\").snapshot;\n persistSnapshot(snapshot);\n notify();\n return buildSendResult(snapshot, true, transition.id);\n }\n\n if (transition.to === HISTORY_TARGET) {\n const { target, history } = resolveHistoryTarget(snapshot, journey.steps);\n assertStepExists(journey.steps, target, `Transition points to unknown step \"${target}\".`);\n snapshot = buildSnapshot(target, nextContext, history, snapshot.status, snapshot.async);\n snapshot = runHistoryTrim(snapshot, \"auto\").snapshot;\n persistSnapshot(snapshot);\n notify();\n return buildSendResult(snapshot, true, transition.id);\n }\n\n const resolvedTarget = transition.to;\n\n assertStepExists(\n journey.steps,\n resolvedTarget,\n `Transition points to unknown step \"${resolvedTarget}\".`\n );\n\n const nextSnapshot = transitionSnapshot(snapshot, resolvedTarget, nextContext);\n snapshot = runHistoryTrim(nextSnapshot, \"auto\").snapshot;\n persistSnapshot(snapshot);\n notify();\n\n return buildSendResult(snapshot, true, transition.id);\n };\n\n const resultPromise = sendQueue.then(run, run);\n sendQueue = resultPromise.then(\n () => undefined,\n () => undefined\n );\n return resultPromise;\n }\n };\n};\n"],
5
- "mappings": "AAAO,IAAMA,EAAmB,CAC9B,SAAU,WACV,MAAO,OACT,EAIaC,EAAiB,CAC5B,QAAS,UACT,SAAU,WACV,OAAQ,QACV,EAIaC,EAAiB,cACjBC,EAAmB,IAEnBC,EAAgB,CAC3B,MAAO,MACT,EAKaC,EAAsB,CACjC,KAAM,OACN,gBAAiB,kBACjB,eAAgB,iBAChB,MAAO,OACT,ECfO,IAAMC,EAAmB,CAC9BC,EACAC,EACAC,IACG,CACH,GAAI,EAAED,KAAUD,GACd,MAAM,IAAI,MAAME,CAAO,CAE3B,EAEMC,EAAaC,GAA6B,CAAC,GAAG,IAAI,IAAIA,CAAK,CAAC,EAErDC,EAAoBC,GA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EAAgBhC,EAAU,GAAMnB,EAAW,EAAE,CACtD,EAEM+D,EAAgBzC,EAAU,KAAKyB,EAAKA,CAAG,EAC7C,OAAAzB,EAAYyC,EAAc,KACxB,IAAG,GACH,IAAG,EACL,EACOA,CACT,CACF,CACF",
6
- "names": ["JOURNEY_TERMINAL", "JOURNEY_STATUS", "HISTORY_TARGET", "JOURNEY_WILDCARD", "JOURNEY_EVENT", "JOURNEY_ASYNC_PHASE", "assertStepExists", "steps", "stepId", "message", "unique", "items", "isPromiseLike", "value", "buildIdleStepAsyncState", "JOURNEY_ASYNC_PHASE", "buildInitialAsyncState", "isGoToEvent", "event", "JOURNEY_EVENT", "isTerminalTarget", "target", "JOURNEY_TERMINAL", "buildSendResult", "snapshot", "transitioned", "transitionId", "buildSnapshot", "current", "context", "history", "status", "asyncState", "resolveHistoryTarget", "cloned", "candidate", "selectTransition", "transitions", "hooks", "transition", "fromMatches", "JOURNEY_WILDCARD", "eventMatches", "guardResult", "asyncGuard", "allowed", "error", "transitionSnapshot", "nextCurrent", "nextContext", "isRecord", "value", "isStatusValue", "JOURNEY_STATUS", "resolveDefaultStorage", "localStorageCandidate", "resolvePersistence", "options", "storage", "coercePersistedSnapshot", "steps", "fallbackContext", "currentValue", "current", "history", "step", "status", "createPersistenceController", "args", "initial", "context", "persistence", "reportPersistenceError", "error", "persistSnapshot", "snapshot", "persistedState", "removePersistedSnapshot", "hydrateSnapshot", "initialSnapshot", "buildSnapshot", "buildInitialAsyncState", "rawPersisted", "parsed", "persistedVersion", "persistedSnapshot", "shouldRewritePersisted", "migrated", "hydratedSnapshot", "DEFAULT_MAX_HISTORY", "resolveMaxHistory", "value", "applyHistoryLimit", "history", "maxHistory", "trimCount", "createJourneyMachine", "journey", "options", "assertStepExists", "index", "transition", "JOURNEY_WILDCARD", "HISTORY_TARGET", "isTerminalTarget", "clearOnReset", "hydrateSnapshot", "persistSnapshot", "removePersistedSnapshot", "createPersistenceController", "historyOptions", "runHistoryTrim", "nextSnapshot", "reason", "overrideMaxHistory", "resolvedMaxHistory", "next", "trimmed", "rebuilt", "buildSnapshot", "snapshot", "hydratedTrim", "listeners", "sendQueue", "buildInitialAsyncState", "notify", "listener", "isAsyncLoadingPhase", "phase", "JOURNEY_ASYNC_PHASE", "updateStepAsync", "stepId", "updater", "current", "buildIdleStepAsyncState", "nextByStep", "isLoading", "state", "setStepLoading", "eventType", "transitionId", "setStepIdle", "setStepError", "error", "JOURNEY_STATUS", "resolvedStep", "result", "event", "run", "fromStep", "isGoToEvent", "transitionSnapshot", "buildSendResult", "JOURNEY_EVENT", "selectTransition", "currentTransition", "nextContext", "effectResultPromise", "isPromiseLike", "effectResult", "JOURNEY_TERMINAL", "target", "resolveHistoryTarget", "resolvedTarget", "resultPromise"]
4
+ "sourcesContent": ["export const JOURNEY_TERMINAL = {\n COMPLETE: \"COMPLETE\",\n CLOSE: \"CLOSE\"\n} as const;\n\nexport type JourneyTerminal = (typeof JOURNEY_TERMINAL)[keyof typeof JOURNEY_TERMINAL];\n\nexport const JOURNEY_STATUS = {\n RUNNING: \"running\",\n COMPLETE: \"complete\",\n CLOSED: \"closed\"\n} as const;\n\nexport type JourneyStatus = (typeof JOURNEY_STATUS)[keyof typeof JOURNEY_STATUS];\n\nexport const HISTORY_TARGET = \"__HISTORY__\" as const;\nexport const JOURNEY_WILDCARD = \"*\" as const;\n\nexport const JOURNEY_EVENT = {\n GO_TO: \"goTo\"\n} as const;\n\nexport type JourneyBuiltInEvent = (typeof JOURNEY_EVENT)[keyof typeof JOURNEY_EVENT];\nexport type JourneyBuiltInFrom = typeof JOURNEY_WILDCARD;\n\nexport const JOURNEY_ASYNC_PHASE = {\n IDLE: \"idle\",\n EVALUATING_WHEN: \"evaluating-when\",\n RUNNING_EFFECT: \"running-effect\",\n ERROR: \"error\"\n} as const;\n\nexport type JourneyAsyncPhase = (typeof JOURNEY_ASYNC_PHASE)[keyof typeof JOURNEY_ASYNC_PHASE];\n\nexport type JourneyStepAsyncState = {\n phase: JourneyAsyncPhase;\n eventType: string | null;\n transitionId: string | null;\n error: unknown | null;\n};\n\nexport type JourneyAsyncState<TStepId extends string> = {\n isLoading: boolean;\n byStep: Record<TStepId, JourneyStepAsyncState>;\n};\n\nexport type JourneyBaseEvent = {\n type: string;\n payload?: unknown;\n};\n\nexport type JourneyEventPayloadMap<TEventType extends string> = Partial<\n Record<TEventType | JourneyBuiltInEvent, unknown>\n>;\n\nexport type JourneyPayloadFor<\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType>,\n TEvent extends TEventType | JourneyBuiltInEvent\n> = TEvent extends keyof TPayloadMap ? TPayloadMap[TEvent] : unknown;\n\nexport type JourneyGoToEvent<TStepId extends string, TPayload = unknown> = {\n type: (typeof JOURNEY_EVENT)[\"GO_TO\"];\n to: TStepId;\n payload?: TPayload;\n};\n\nexport type JourneyEvent<\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> =\n | JourneyGoToEvent<\n TStepId,\n JourneyPayloadFor<TEventType, TPayloadMap, (typeof JOURNEY_EVENT)[\"GO_TO\"]>\n >\n | {\n [TType in TEventType]: {\n type: TType;\n payload?: JourneyPayloadFor<TEventType, TPayloadMap, TType>;\n };\n }[TEventType];\n\nexport type JourneyTransitionArgs<\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> = {\n context: TContext;\n from: TStepId;\n history: readonly TStepId[];\n event: JourneyEvent<TStepId, TEventType, TPayloadMap>;\n};\n\nexport type JourneyTransitionTarget<TStepId extends string> =\n | TStepId\n | JourneyTerminal\n | typeof HISTORY_TARGET;\n\nexport type JourneyTransition<\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> = {\n id?: string;\n from: TStepId | JourneyBuiltInFrom;\n event: TEventType | (typeof JOURNEY_EVENT)[\"GO_TO\"];\n to: JourneyTransitionTarget<TStepId>;\n when?: (\n args: JourneyTransitionArgs<TContext, TStepId, TEventType, TPayloadMap>\n ) => boolean | Promise<boolean>;\n effect?: (\n args: JourneyTransitionArgs<TContext, TStepId, TEventType, TPayloadMap>\n ) => TContext | void | Promise<TContext | void>;\n};\n\nexport type JourneySnapshot<TContext, TStepId extends string> = {\n current: TStepId;\n context: TContext;\n history: readonly TStepId[];\n visited: readonly TStepId[];\n status: JourneyStatus;\n async: JourneyAsyncState<TStepId>;\n};\n\nexport type JourneyPersistedSnapshot<TContext, TStepId extends string> = {\n current: TStepId;\n context: TContext;\n history: readonly TStepId[];\n status: JourneyStatus;\n visited: readonly TStepId[];\n};\n\nexport type JourneyPersistedState<TContext, TStepId extends string> = {\n version: number;\n snapshot: JourneyPersistedSnapshot<TContext, TStepId>;\n};\n\nexport type JourneyHistoryOverflowReason = \"auto\" | \"hydrate\" | \"manual\";\n\nexport type JourneyHistoryOverflow<TStepId extends string> = {\n previous: readonly TStepId[];\n next: readonly TStepId[];\n trimmed: readonly TStepId[];\n maxHistory: number | null;\n reason: JourneyHistoryOverflowReason;\n};\n\nexport type JourneyHistoryOptions<TStepId extends string> = {\n maxHistory?: number | null;\n onOverflow?: (info: JourneyHistoryOverflow<TStepId>) => void;\n};\n\nexport type JourneyStorage = {\n getItem: (key: string) => string | null;\n setItem: (key: string, value: string) => void;\n removeItem: (key: string) => void;\n};\n\nexport type JourneyPersistenceOptions<TContext, TStepId extends string> = {\n key: string;\n storage?: JourneyStorage;\n version?: number;\n clearOnReset?: boolean;\n serialize?: (value: JourneyPersistedState<TContext, TStepId>) => string;\n deserialize?: (value: string) => unknown;\n migrate?: (\n value: unknown,\n persistedVersion: number\n ) => JourneyPersistedSnapshot<TContext, TStepId>;\n onError?: (error: unknown) => void;\n};\n\nexport type JourneyDefinition<\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> = {\n initial: TStepId;\n context: TContext;\n steps: Record<TStepId, unknown>;\n transitions: readonly JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>[];\n};\n\nexport type JourneyMachineOptions<TContext, TStepId extends string> = {\n persistence?: JourneyPersistenceOptions<TContext, TStepId>;\n history?: JourneyHistoryOptions<TStepId>;\n};\n\nexport type JourneySendResult<TContext, TStepId extends string> = {\n transitioned: boolean;\n transitionId?: string;\n snapshot: JourneySnapshot<TContext, TStepId>;\n};\n\nexport type JourneyMachine<\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n> = {\n getSnapshot: () => JourneySnapshot<TContext, TStepId>;\n send: (\n event: JourneyEvent<TStepId, TEventType, TPayloadMap>\n ) => Promise<JourneySendResult<TContext, TStepId>>;\n updateContext: (updater: (context: TContext) => TContext) => JourneySnapshot<TContext, TStepId>;\n clearStepError: (stepId?: TStepId) => JourneySnapshot<TContext, TStepId>;\n reset: () => JourneySnapshot<TContext, TStepId>;\n trimHistory: (maxHistory?: number | null) => JourneySnapshot<TContext, TStepId>;\n clearHistory: () => JourneySnapshot<TContext, TStepId>;\n subscribe: (listener: () => void) => () => void;\n};\n", "import { JOURNEY_ASYNC_PHASE, JOURNEY_EVENT, JOURNEY_TERMINAL, JOURNEY_WILDCARD } from \"./types\";\nimport type {\n JourneyAsyncState,\n JourneyEvent,\n JourneyEventPayloadMap,\n JourneyGoToEvent,\n JourneyPayloadFor,\n JourneySendResult,\n JourneySnapshot,\n JourneyStatus,\n JourneyStepAsyncState,\n JourneyTerminal,\n JourneyTransition\n} from \"./types\";\n\nexport const assertStepExists = <TStepId extends string>(\n steps: Record<TStepId, unknown>,\n stepId: TStepId,\n message: string\n) => {\n if (!(stepId in steps)) {\n throw new Error(message);\n }\n};\n\nconst unique = <T>(items: readonly T[]): T[] => [...new Set(items)];\n\nexport const buildVisited = <TStepId extends string>(\n history: readonly TStepId[],\n current: TStepId\n): TStepId[] => unique([...history, current]);\n\nexport const appendVisited = <TStepId extends string>(\n visited: readonly TStepId[],\n current: TStepId\n): TStepId[] => (visited.includes(current) ? [...visited] : [...visited, current]);\n\nexport const isPromiseLike = <T>(value: T | PromiseLike<T>): value is PromiseLike<T> =>\n typeof value === \"object\" &&\n value !== null &&\n \"then\" in value &&\n typeof (value as { then: unknown }).then === \"function\";\n\nexport const buildIdleStepAsyncState = (): JourneyStepAsyncState => ({\n phase: JOURNEY_ASYNC_PHASE.IDLE,\n eventType: null,\n transitionId: null,\n error: null\n});\n\nexport const buildInitialAsyncState = <TStepId extends string>(\n steps: Record<TStepId, unknown>\n): JourneyAsyncState<TStepId> => {\n const byStep = Object.fromEntries(\n Object.keys(steps).map((stepId) => [stepId, buildIdleStepAsyncState()])\n ) as Record<TStepId, JourneyStepAsyncState>;\n\n return {\n isLoading: false,\n byStep\n };\n};\n\nexport const isGoToEvent = <\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType>\n>(\n event: JourneyEvent<TStepId, TEventType, TPayloadMap>\n): event is JourneyGoToEvent<\n TStepId,\n JourneyPayloadFor<TEventType, TPayloadMap, (typeof JOURNEY_EVENT)[\"GO_TO\"]>\n> => event.type === JOURNEY_EVENT.GO_TO && \"to\" in event;\n\nexport const isTerminalTarget = <TStepId extends string>(\n target: TStepId | JourneyTerminal | \"__HISTORY__\"\n): target is JourneyTerminal =>\n target === JOURNEY_TERMINAL.COMPLETE || target === JOURNEY_TERMINAL.CLOSE;\n\nexport const buildSendResult = <TContext, TStepId extends string>(\n snapshot: JourneySnapshot<TContext, TStepId>,\n transitioned: boolean,\n transitionId?: string\n): JourneySendResult<TContext, TStepId> =>\n transitionId ? { transitioned, transitionId, snapshot } : { transitioned, snapshot };\n\nexport const buildSnapshot = <TContext, TStepId extends string>(\n current: TStepId,\n context: TContext,\n history: readonly TStepId[],\n status: JourneyStatus,\n asyncState: JourneyAsyncState<TStepId>,\n visited?: readonly TStepId[]\n): JourneySnapshot<TContext, TStepId> => ({\n status,\n current,\n context,\n history,\n visited: visited ? [...visited] : buildVisited(history, current),\n async: asyncState\n});\n\nexport const resolveHistoryTarget = <TContext, TStepId extends string>(\n snapshot: JourneySnapshot<TContext, TStepId>,\n steps: Record<TStepId, unknown>\n): { target: TStepId; history: TStepId[] } => {\n const cloned = [...snapshot.history];\n\n while (cloned.length > 0) {\n const candidate = cloned.pop();\n if (!candidate) {\n break;\n }\n if (candidate in steps) {\n return {\n target: candidate,\n history: cloned\n };\n }\n }\n\n return {\n target: snapshot.current,\n history: [...snapshot.history]\n };\n};\n\nexport const selectTransition = async <\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType>\n>(\n transitions: readonly JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>[],\n snapshot: JourneySnapshot<TContext, TStepId>,\n event: JourneyEvent<TStepId, TEventType, TPayloadMap>,\n hooks?: {\n onAsyncGuardStart?: (\n transition: JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>\n ) => void;\n onAsyncGuardSuccess?: (\n transition: JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>\n ) => void;\n onAsyncGuardError?: (\n transition: JourneyTransition<TContext, TStepId, TEventType, TPayloadMap>,\n error: unknown\n ) => void;\n }\n): Promise<JourneyTransition<TContext, TStepId, TEventType, TPayloadMap> | null> => {\n for (const transition of transitions) {\n const fromMatches =\n transition.from === JOURNEY_WILDCARD || transition.from === snapshot.current;\n const eventMatches = transition.event === event.type;\n\n if (!fromMatches || !eventMatches) {\n continue;\n }\n\n if (!transition.when) {\n return transition;\n }\n\n const guardResult = transition.when({\n context: snapshot.context,\n from: snapshot.current,\n history: snapshot.history,\n event\n });\n const asyncGuard = isPromiseLike(guardResult);\n if (asyncGuard) {\n hooks?.onAsyncGuardStart?.(transition);\n }\n\n let allowed: boolean;\n try {\n allowed = await guardResult;\n } catch (error) {\n if (asyncGuard) {\n hooks?.onAsyncGuardError?.(transition, error);\n }\n throw error;\n }\n\n if (asyncGuard) {\n hooks?.onAsyncGuardSuccess?.(transition);\n }\n\n if (allowed) {\n return transition;\n }\n }\n\n return null;\n};\n\nexport const transitionSnapshot = <TContext, TStepId extends string>(\n snapshot: JourneySnapshot<TContext, TStepId>,\n nextCurrent: TStepId,\n nextContext: TContext\n): JourneySnapshot<TContext, TStepId> => {\n const history =\n nextCurrent === snapshot.current\n ? [...snapshot.history]\n : [...snapshot.history, snapshot.current];\n\n const visited = appendVisited(snapshot.visited, nextCurrent);\n\n return buildSnapshot(nextCurrent, nextContext, history, snapshot.status, snapshot.async, visited);\n};\n", "import { JOURNEY_STATUS } from \"./types\";\nimport type {\n JourneyMachineOptions,\n JourneyPersistedSnapshot,\n JourneyPersistedState,\n JourneyStatus,\n JourneySnapshot,\n JourneyStorage\n} from \"./types\";\nimport { buildInitialAsyncState, buildSnapshot, buildVisited } from \"./machine-helpers\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isStatusValue = (value: unknown): value is JourneyStatus =>\n value === JOURNEY_STATUS.RUNNING ||\n value === JOURNEY_STATUS.COMPLETE ||\n value === JOURNEY_STATUS.CLOSED;\n\nconst resolveDefaultStorage = (): JourneyStorage | null => {\n const localStorageCandidate = (globalThis as { localStorage?: Partial<JourneyStorage> })\n .localStorage;\n\n if (\n !localStorageCandidate ||\n typeof localStorageCandidate.getItem !== \"function\" ||\n typeof localStorageCandidate.setItem !== \"function\" ||\n typeof localStorageCandidate.removeItem !== \"function\"\n ) {\n return null;\n }\n\n return localStorageCandidate as JourneyStorage;\n};\n\ntype ResolvedPersistence<TContext, TStepId extends string> = {\n key: string;\n storage: JourneyStorage;\n version: number;\n clearOnReset: boolean;\n serialize: (value: JourneyPersistedState<TContext, TStepId>) => string;\n deserialize: (value: string) => unknown;\n migrate?: (\n value: unknown,\n persistedVersion: number\n ) => JourneyPersistedSnapshot<TContext, TStepId>;\n onError?: (error: unknown) => void;\n};\n\nconst resolvePersistence = <TContext, TStepId extends string>(\n options?: JourneyMachineOptions<TContext, TStepId>[\"persistence\"]\n): ResolvedPersistence<TContext, TStepId> | null => {\n if (!options) {\n return null;\n }\n\n const storage = options.storage ?? resolveDefaultStorage();\n if (!storage) {\n return null;\n }\n\n return {\n key: options.key,\n storage,\n version: options.version ?? 1,\n clearOnReset: options.clearOnReset ?? true,\n serialize: options.serialize ?? JSON.stringify,\n deserialize: options.deserialize ?? JSON.parse,\n ...(options.migrate ? { migrate: options.migrate } : {}),\n ...(options.onError ? { onError: options.onError } : {})\n };\n};\n\nconst coercePersistedSnapshot = <TContext, TStepId extends string>(\n value: unknown,\n steps: Record<TStepId, unknown>,\n fallbackContext: TContext\n): { snapshot: JourneyPersistedSnapshot<TContext, TStepId>; needsRewrite: boolean } | null => {\n if (!isRecord(value)) {\n return null;\n }\n\n const currentValue = value.current;\n if (typeof currentValue !== \"string\" || !(currentValue in steps)) {\n return null;\n }\n const current = currentValue as TStepId;\n\n const history = Array.isArray(value.history)\n ? (value.history.filter(\n (step): step is TStepId => typeof step === \"string\" && step in steps\n ) as TStepId[])\n : [];\n\n const status = isStatusValue(value.status) ? value.status : JOURNEY_STATUS.RUNNING;\n\n const visitedRaw = Array.isArray(value.visited)\n ? (value.visited.filter(\n (step): step is TStepId => typeof step === \"string\" && step in steps\n ) as TStepId[])\n : null;\n const visited = visitedRaw && visitedRaw.length > 0 ? visitedRaw : buildVisited(history, current);\n const needsRewrite = !visitedRaw || visitedRaw.length === 0;\n\n return {\n snapshot: {\n current,\n context: (\"context\" in value ? value.context : fallbackContext) as TContext,\n history,\n status,\n visited\n },\n needsRewrite\n };\n};\n\n/**\n * Creates a persistence controller for snapshots, including hydration,\n * serialization, and storage error handling.\n */\nexport const createPersistenceController = <TContext, TStepId extends string>(args: {\n initial: TStepId;\n context: TContext;\n steps: Record<TStepId, unknown>;\n options?: JourneyMachineOptions<TContext, TStepId>;\n}) => {\n const { initial, context, steps, options } = args;\n const persistence = resolvePersistence(options?.persistence);\n\n const reportPersistenceError = (error: unknown) => {\n persistence?.onError?.(error);\n };\n\n const persistSnapshot = (snapshot: JourneySnapshot<TContext, TStepId>) => {\n if (!persistence) {\n return;\n }\n\n try {\n const persistedState: JourneyPersistedState<TContext, TStepId> = {\n version: persistence.version,\n snapshot: {\n current: snapshot.current,\n context: snapshot.context,\n history: [...snapshot.history],\n status: snapshot.status,\n visited: [...snapshot.visited]\n }\n };\n persistence.storage.setItem(persistence.key, persistence.serialize(persistedState));\n } catch (error) {\n reportPersistenceError(error);\n }\n };\n\n const removePersistedSnapshot = () => {\n if (!persistence) {\n return;\n }\n\n try {\n persistence.storage.removeItem(persistence.key);\n } catch (error) {\n reportPersistenceError(error);\n }\n };\n\n const hydrateSnapshot = (): JourneySnapshot<TContext, TStepId> => {\n const initialSnapshot = buildSnapshot(\n initial,\n context,\n [],\n JOURNEY_STATUS.RUNNING,\n buildInitialAsyncState(steps)\n );\n if (!persistence) {\n return initialSnapshot;\n }\n\n try {\n const rawPersisted = persistence.storage.getItem(persistence.key);\n if (!rawPersisted) {\n return initialSnapshot;\n }\n\n const parsed = persistence.deserialize(rawPersisted);\n if (!isRecord(parsed)) {\n return initialSnapshot;\n }\n\n const persistedVersion = parsed.version;\n if (typeof persistedVersion !== \"number\") {\n return initialSnapshot;\n }\n\n let persistedSnapshot: JourneyPersistedSnapshot<TContext, TStepId> | null = null;\n let shouldRewritePersisted = false;\n\n if (persistedVersion === persistence.version) {\n const coerced = coercePersistedSnapshot(parsed.snapshot, steps, context);\n persistedSnapshot = coerced?.snapshot ?? null;\n shouldRewritePersisted = Boolean(coerced?.needsRewrite);\n } else if (persistence.migrate) {\n const migrated = persistence.migrate(parsed.snapshot, persistedVersion);\n const coerced = coercePersistedSnapshot(migrated, steps, context);\n persistedSnapshot = coerced?.snapshot ?? null;\n shouldRewritePersisted = persistedSnapshot !== null;\n }\n\n if (!persistedSnapshot) {\n return initialSnapshot;\n }\n\n const hydratedSnapshot = buildSnapshot(\n persistedSnapshot.current,\n persistedSnapshot.context,\n persistedSnapshot.history,\n persistedSnapshot.status,\n buildInitialAsyncState(steps),\n persistedSnapshot.visited\n );\n\n if (shouldRewritePersisted) {\n persistSnapshot(hydratedSnapshot);\n }\n\n return hydratedSnapshot;\n } catch (error) {\n reportPersistenceError(error);\n return initialSnapshot;\n }\n };\n\n return {\n clearOnReset: persistence?.clearOnReset ?? true,\n hydrateSnapshot,\n persistSnapshot,\n removePersistedSnapshot\n };\n};\n", "import {\n JOURNEY_ASYNC_PHASE,\n JOURNEY_EVENT,\n JOURNEY_STATUS,\n JOURNEY_TERMINAL,\n JOURNEY_WILDCARD,\n HISTORY_TARGET\n} from \"./types\";\nimport type {\n JourneyAsyncState,\n JourneyAsyncPhase,\n JourneyEventPayloadMap,\n JourneyDefinition,\n JourneyHistoryOverflowReason,\n JourneyHistoryOptions,\n JourneyMachine,\n JourneyMachineOptions,\n JourneySendResult,\n JourneySnapshot\n} from \"./types\";\nimport {\n appendVisited,\n assertStepExists,\n buildIdleStepAsyncState,\n buildInitialAsyncState,\n buildSendResult,\n isGoToEvent,\n isPromiseLike,\n isTerminalTarget,\n resolveHistoryTarget,\n selectTransition,\n transitionSnapshot,\n buildSnapshot\n} from \"./machine-helpers\";\nimport { createPersistenceController } from \"./persistence\";\n\nconst DEFAULT_MAX_HISTORY = 50;\n\nconst resolveMaxHistory = (value: number | null | undefined): number | null => {\n if (value === null) {\n return null;\n }\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return Math.max(0, Math.trunc(value));\n }\n return DEFAULT_MAX_HISTORY;\n};\n\nconst applyHistoryLimit = <TStepId extends string>(\n history: readonly TStepId[],\n maxHistory: number | null\n): { next: TStepId[]; trimmed: TStepId[] } => {\n if (maxHistory === null || history.length <= maxHistory) {\n return { next: [...history], trimmed: [] };\n }\n\n const trimCount = history.length - maxHistory;\n return {\n next: history.slice(trimCount),\n trimmed: history.slice(0, trimCount)\n };\n};\n\n/**\n * Creates a journey machine from a journey definition.\n * Validates steps/transitions, hydrates persisted state (if configured),\n * and returns an API for sending events and reading snapshots.\n */\nexport const createJourneyMachine = <\n TContext,\n TStepId extends string,\n TEventType extends string = \"next\" | \"back\" | \"close\" | \"submit\",\n TPayloadMap extends JourneyEventPayloadMap<TEventType> = Record<never, never>\n>(\n journey: JourneyDefinition<TContext, TStepId, TEventType, TPayloadMap>,\n options?: JourneyMachineOptions<TContext, TStepId>\n): JourneyMachine<TContext, TStepId, TEventType, TPayloadMap> => {\n if (!journey.steps || typeof journey.steps !== \"object\") {\n throw new Error(\"Journey steps must be a record object.\");\n }\n\n if (!Array.isArray(journey.transitions)) {\n throw new Error(\"Journey transitions must be an array.\");\n }\n\n assertStepExists(\n journey.steps,\n journey.initial,\n `Journey initial step \"${journey.initial}\" does not exist in steps registry.`\n );\n\n for (const [index, transition] of journey.transitions.entries()) {\n if (!transition || typeof transition !== \"object\") {\n throw new Error(`Journey transition at index ${index} must be an object.`);\n }\n\n if (typeof transition.from !== \"string\" || typeof transition.event !== \"string\") {\n throw new Error(\n `Journey transition at index ${index} must define string \"from\" and \"event\".`\n );\n }\n\n if (\n transition.from !== JOURNEY_WILDCARD &&\n !((transition.from as string) in (journey.steps as Record<string, unknown>))\n ) {\n throw new Error(\n `Journey transition at index ${index} references unknown from step \"${transition.from}\".`\n );\n }\n\n if (\n transition.to !== HISTORY_TARGET &&\n !isTerminalTarget(transition.to) &&\n !((transition.to as string) in (journey.steps as Record<string, unknown>))\n ) {\n throw new Error(\n `Journey transition at index ${index} points to unknown step \"${transition.to}\".`\n );\n }\n }\n\n const { clearOnReset, hydrateSnapshot, persistSnapshot, removePersistedSnapshot } =\n createPersistenceController({\n initial: journey.initial,\n context: journey.context,\n steps: journey.steps,\n ...(options ? { options } : {})\n });\n\n const historyOptions: JourneyHistoryOptions<TStepId> | undefined = options?.history;\n\n const runHistoryTrim = (\n nextSnapshot: JourneySnapshot<TContext, TStepId>,\n reason: JourneyHistoryOverflowReason,\n overrideMaxHistory?: number | null\n ): {\n snapshot: JourneySnapshot<TContext, TStepId>;\n trimmed: TStepId[];\n maxHistory: number | null;\n } => {\n const resolvedMaxHistory = resolveMaxHistory(overrideMaxHistory ?? historyOptions?.maxHistory);\n const { next, trimmed } = applyHistoryLimit(nextSnapshot.history, resolvedMaxHistory);\n if (trimmed.length === 0) {\n return {\n snapshot: nextSnapshot,\n trimmed,\n maxHistory: resolvedMaxHistory\n };\n }\n\n const rebuilt = buildSnapshot(\n nextSnapshot.current,\n nextSnapshot.context,\n next,\n nextSnapshot.status,\n nextSnapshot.async,\n nextSnapshot.visited\n );\n\n historyOptions?.onOverflow?.({\n previous: nextSnapshot.history,\n next,\n trimmed,\n maxHistory: resolvedMaxHistory,\n reason\n });\n\n return {\n snapshot: rebuilt,\n trimmed,\n maxHistory: resolvedMaxHistory\n };\n };\n\n let snapshot = hydrateSnapshot();\n const hydratedTrim = runHistoryTrim(snapshot, \"hydrate\");\n snapshot = hydratedTrim.snapshot;\n if (hydratedTrim.trimmed.length > 0) {\n persistSnapshot(snapshot);\n }\n const listeners = new Set<() => void>();\n let sendQueue: Promise<void> = Promise.resolve();\n snapshot = {\n ...snapshot,\n async: buildInitialAsyncState(journey.steps)\n };\n\n const notify = () => {\n for (const listener of listeners) {\n listener();\n }\n };\n\n const isAsyncLoadingPhase = (phase: JourneyAsyncPhase): boolean =>\n phase === JOURNEY_ASYNC_PHASE.EVALUATING_WHEN || phase === JOURNEY_ASYNC_PHASE.RUNNING_EFFECT;\n\n const updateStepAsync = (\n stepId: TStepId,\n updater: (\n current: JourneyAsyncState<TStepId>[\"byStep\"][TStepId]\n ) => JourneyAsyncState<TStepId>[\"byStep\"][TStepId]\n ) => {\n const current = snapshot.async.byStep[stepId] ?? buildIdleStepAsyncState();\n const next = updater(current);\n if (\n current.phase === next.phase &&\n current.eventType === next.eventType &&\n current.transitionId === next.transitionId &&\n current.error === next.error\n ) {\n return;\n }\n const nextByStep = {\n ...snapshot.async.byStep,\n [stepId]: next\n };\n const isLoading = Object.values(nextByStep).some((state) => isAsyncLoadingPhase(state.phase));\n snapshot = {\n ...snapshot,\n async: {\n isLoading,\n byStep: nextByStep\n }\n };\n notify();\n };\n\n const setStepLoading = (\n stepId: TStepId,\n phase: JourneyAsyncPhase,\n eventType: string,\n transitionId?: string\n ) => {\n updateStepAsync(stepId, () => ({\n phase,\n eventType,\n transitionId: transitionId ?? null,\n error: null\n }));\n };\n\n const setStepIdle = (stepId: TStepId) => {\n updateStepAsync(stepId, () => buildIdleStepAsyncState());\n };\n\n const setStepError = (\n stepId: TStepId,\n eventType: string,\n error: unknown,\n transitionId?: string\n ) => {\n updateStepAsync(stepId, () => ({\n phase: JOURNEY_ASYNC_PHASE.ERROR,\n eventType,\n transitionId: transitionId ?? null,\n error\n }));\n };\n\n return {\n getSnapshot: () => snapshot,\n subscribe: (listener) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n reset: () => {\n snapshot = buildSnapshot(\n journey.initial,\n journey.context,\n [],\n JOURNEY_STATUS.RUNNING,\n buildInitialAsyncState(journey.steps)\n );\n if (clearOnReset) {\n removePersistedSnapshot();\n } else {\n persistSnapshot(snapshot);\n }\n notify();\n return snapshot;\n },\n updateContext: (updater) => {\n snapshot = {\n ...snapshot,\n context: updater(snapshot.context)\n };\n persistSnapshot(snapshot);\n notify();\n return snapshot;\n },\n clearStepError: (stepId) => {\n const resolvedStep = stepId ?? snapshot.current;\n if (!(resolvedStep in journey.steps)) {\n return snapshot;\n }\n\n setStepIdle(resolvedStep);\n return snapshot;\n },\n trimHistory: (maxHistory) => {\n const result = runHistoryTrim(snapshot, \"manual\", maxHistory);\n if (result.trimmed.length === 0) {\n return snapshot;\n }\n snapshot = result.snapshot;\n persistSnapshot(snapshot);\n notify();\n return snapshot;\n },\n clearHistory: () => {\n if (snapshot.history.length === 0) {\n return snapshot;\n }\n snapshot = buildSnapshot(\n snapshot.current,\n snapshot.context,\n [],\n snapshot.status,\n snapshot.async,\n snapshot.visited\n );\n persistSnapshot(snapshot);\n notify();\n return snapshot;\n },\n send: (event) => {\n const run = async (): Promise<JourneySendResult<TContext, TStepId>> => {\n if (snapshot.status !== JOURNEY_STATUS.RUNNING) {\n return { transitioned: false, snapshot };\n }\n\n const fromStep = snapshot.current;\n\n if (isGoToEvent(event)) {\n assertStepExists(journey.steps, event.to, `Cannot goTo unknown step \"${event.to}\".`);\n setStepIdle(fromStep);\n snapshot = transitionSnapshot(snapshot, event.to, snapshot.context);\n snapshot = runHistoryTrim(snapshot, \"auto\").snapshot;\n persistSnapshot(snapshot);\n notify();\n return buildSendResult(snapshot, true, JOURNEY_EVENT.GO_TO);\n }\n\n let transition;\n try {\n transition = await selectTransition(journey.transitions, snapshot, event, {\n onAsyncGuardStart: (currentTransition) => {\n setStepLoading(\n fromStep,\n JOURNEY_ASYNC_PHASE.EVALUATING_WHEN,\n event.type,\n currentTransition.id\n );\n },\n onAsyncGuardSuccess: () => {\n setStepIdle(fromStep);\n },\n onAsyncGuardError: (currentTransition, error) => {\n setStepError(fromStep, event.type, error, currentTransition.id);\n }\n });\n } catch (error) {\n setStepError(fromStep, event.type, error);\n throw error;\n }\n\n if (!transition) {\n return buildSendResult(snapshot, false);\n }\n\n let nextContext = snapshot.context;\n if (transition.effect) {\n const effectResultPromise = transition.effect({\n context: snapshot.context,\n from: snapshot.current,\n history: snapshot.history,\n event\n });\n if (isPromiseLike(effectResultPromise)) {\n setStepLoading(\n fromStep,\n JOURNEY_ASYNC_PHASE.RUNNING_EFFECT,\n event.type as string,\n transition.id\n );\n }\n\n let effectResult: TContext | void;\n try {\n effectResult = await effectResultPromise;\n } catch (error) {\n setStepError(fromStep, event.type, error, transition.id);\n throw error;\n }\n\n if (effectResult !== undefined) {\n nextContext = effectResult;\n }\n }\n\n setStepIdle(fromStep);\n\n if (isTerminalTarget(transition.to)) {\n snapshot = {\n ...snapshot,\n context: nextContext,\n status:\n transition.to === JOURNEY_TERMINAL.COMPLETE\n ? JOURNEY_STATUS.COMPLETE\n : JOURNEY_STATUS.CLOSED\n };\n snapshot = runHistoryTrim(snapshot, \"auto\").snapshot;\n persistSnapshot(snapshot);\n notify();\n return buildSendResult(snapshot, true, transition.id);\n }\n\n if (transition.to === HISTORY_TARGET) {\n const { target, history } = resolveHistoryTarget(snapshot, journey.steps);\n assertStepExists(journey.steps, target, `Transition points to unknown step \"${target}\".`);\n const visited = appendVisited(snapshot.visited, target);\n snapshot = buildSnapshot(\n target,\n nextContext,\n history,\n snapshot.status,\n snapshot.async,\n visited\n );\n snapshot = runHistoryTrim(snapshot, \"auto\").snapshot;\n persistSnapshot(snapshot);\n notify();\n return buildSendResult(snapshot, true, transition.id);\n }\n\n const resolvedTarget = transition.to;\n\n assertStepExists(\n journey.steps,\n resolvedTarget,\n `Transition points to unknown step \"${resolvedTarget}\".`\n );\n\n const nextSnapshot = transitionSnapshot(snapshot, resolvedTarget, nextContext);\n snapshot = runHistoryTrim(nextSnapshot, \"auto\").snapshot;\n persistSnapshot(snapshot);\n notify();\n\n return buildSendResult(snapshot, true, transition.id);\n };\n\n const resultPromise = sendQueue.then(run, run);\n sendQueue = resultPromise.then(\n () => undefined,\n () => undefined\n );\n return resultPromise;\n }\n };\n};\n"],
5
+ "mappings": "AAAO,IAAMA,EAAmB,CAC9B,SAAU,WACV,MAAO,OACT,EAIaC,EAAiB,CAC5B,QAAS,UACT,SAAU,WACV,OAAQ,QACV,EAIaC,EAAiB,cACjBC,EAAmB,IAEnBC,EAAgB,CAC3B,MAAO,MACT,EAKaC,EAAsB,CACjC,KAAM,OACN,gBAAiB,kBACjB,eAAgB,iBAChB,MAAO,OACT,ECfO,IAAMC,EAAmB,CAC9BC,EACAC,EACAC,IACG,CACH,GAAI,EAAED,KAAUD,GACd,MAAM,IAAI,MAAME,CAAO,CAE3B,EAEMC,EAAaC,GAA6B,CAAC,GAAG,IAAI,IAAIA,CAAK,CAAC,EAErDC,EAAe,CAC1BC,EACAC,IACcJ,EAAO,CAAC,GAAGG,EAASC,CAAO,CAAC,EAE/BC,EAAgB,CAC3BC,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,EAGtD,GAAIA,EAAW,KAAOE,EAAgB,CACpC,GAAM,CAAE,OAAA0D,EAAQ,QAAApE,CAAQ,EAAIqE,EAAqB1C,EAAUvB,EAAQ,KAAK,EACxEE,EAAiBF,EAAQ,MAAOgE,EAAQ,sCAAsCA,CAAM,IAAI,EACxF,IAAME,EAAUC,EAAc5C,EAAS,QAASyC,CAAM,EACtD,OAAAzC,EAAWD,EACT0C,EACAL,EACA/D,EACA2B,EAAS,OACTA,EAAS,MACT2C,CACF,EACA3C,EAAWT,EAAeS,EAAU,MAAM,EAAE,SAC5Cb,EAAgBa,CAAQ,EACxBK,EAAO,EACA2B,EAAgBhC,EAAU,GAAMnB,EAAW,EAAE,CACtD,CAEA,IAAMgE,EAAiBhE,EAAW,GAElCF,EACEF,EAAQ,MACRoE,EACA,sCAAsCA,CAAc,IACtD,EAEA,IAAMrD,EAAeuC,EAAmB/B,EAAU6C,EAAgBT,CAAW,EAC7E,OAAApC,EAAWT,EAAeC,EAAc,MAAM,EAAE,SAChDL,EAAgBa,CAAQ,EACxBK,EAAO,EAEA2B,EAAgBhC,EAAU,GAAMnB,EAAW,EAAE,CACtD,EAEMiE,EAAgB3C,EAAU,KAAKyB,EAAKA,CAAG,EAC7C,OAAAzB,EAAY2C,EAAc,KACxB,IAAG,GACH,IAAG,EACL,EACOA,CACT,CACF,CACF",
6
+ "names": ["JOURNEY_TERMINAL", "JOURNEY_STATUS", "HISTORY_TARGET", "JOURNEY_WILDCARD", "JOURNEY_EVENT", "JOURNEY_ASYNC_PHASE", "assertStepExists", "steps", "stepId", "message", "unique", "items", "buildVisited", "history", "current", "appendVisited", "visited", "isPromiseLike", "value", "buildIdleStepAsyncState", "JOURNEY_ASYNC_PHASE", "buildInitialAsyncState", "isGoToEvent", "event", "JOURNEY_EVENT", "isTerminalTarget", "target", "JOURNEY_TERMINAL", "buildSendResult", "snapshot", "transitioned", "transitionId", "buildSnapshot", "context", "status", "asyncState", "resolveHistoryTarget", "cloned", "candidate", "selectTransition", "transitions", "hooks", "transition", "fromMatches", "JOURNEY_WILDCARD", "eventMatches", "guardResult", "asyncGuard", "allowed", "error", "transitionSnapshot", "nextCurrent", "nextContext", "isRecord", "value", "isStatusValue", "JOURNEY_STATUS", "resolveDefaultStorage", "localStorageCandidate", "resolvePersistence", "options", "storage", "coercePersistedSnapshot", "steps", "fallbackContext", "currentValue", "current", "history", "step", "status", "visitedRaw", "visited", "buildVisited", "needsRewrite", "createPersistenceController", "args", "initial", "context", "persistence", "reportPersistenceError", "error", "persistSnapshot", "snapshot", "persistedState", "removePersistedSnapshot", "hydrateSnapshot", "initialSnapshot", "buildSnapshot", "buildInitialAsyncState", "rawPersisted", "parsed", "persistedVersion", "persistedSnapshot", "shouldRewritePersisted", "coerced", "migrated", "hydratedSnapshot", "DEFAULT_MAX_HISTORY", "resolveMaxHistory", "value", "applyHistoryLimit", "history", "maxHistory", "trimCount", "createJourneyMachine", "journey", "options", "assertStepExists", "index", "transition", "JOURNEY_WILDCARD", "HISTORY_TARGET", "isTerminalTarget", "clearOnReset", "hydrateSnapshot", "persistSnapshot", "removePersistedSnapshot", "createPersistenceController", "historyOptions", "runHistoryTrim", "nextSnapshot", "reason", "overrideMaxHistory", "resolvedMaxHistory", "next", "trimmed", "rebuilt", "buildSnapshot", "snapshot", "hydratedTrim", "listeners", "sendQueue", "buildInitialAsyncState", "notify", "listener", "isAsyncLoadingPhase", "phase", "JOURNEY_ASYNC_PHASE", "updateStepAsync", "stepId", "updater", "current", "buildIdleStepAsyncState", "nextByStep", "isLoading", "state", "setStepLoading", "eventType", "transitionId", "setStepIdle", "setStepError", "error", "JOURNEY_STATUS", "resolvedStep", "result", "event", "run", "fromStep", "isGoToEvent", "transitionSnapshot", "buildSendResult", "JOURNEY_EVENT", "selectTransition", "currentTransition", "nextContext", "effectResultPromise", "isPromiseLike", "effectResult", "JOURNEY_TERMINAL", "target", "resolveHistoryTarget", "visited", "appendVisited", "resolvedTarget", "resultPromise"]
7
7
  }
@@ -1,13 +1,15 @@
1
1
  import { JOURNEY_EVENT } from "./types";
2
2
  import type { JourneyAsyncState, JourneyEvent, JourneyEventPayloadMap, JourneyGoToEvent, JourneyPayloadFor, JourneySendResult, JourneySnapshot, JourneyStatus, JourneyStepAsyncState, JourneyTerminal, JourneyTransition } from "./types";
3
3
  export declare const assertStepExists: <TStepId extends string>(steps: Record<TStepId, unknown>, stepId: TStepId, message: string) => void;
4
+ export declare const buildVisited: <TStepId extends string>(history: readonly TStepId[], current: TStepId) => TStepId[];
5
+ export declare const appendVisited: <TStepId extends string>(visited: readonly TStepId[], current: TStepId) => TStepId[];
4
6
  export declare const isPromiseLike: <T>(value: T | PromiseLike<T>) => value is PromiseLike<T>;
5
7
  export declare const buildIdleStepAsyncState: () => JourneyStepAsyncState;
6
8
  export declare const buildInitialAsyncState: <TStepId extends string>(steps: Record<TStepId, unknown>) => JourneyAsyncState<TStepId>;
7
9
  export declare const isGoToEvent: <TStepId extends string, TEventType extends string, TPayloadMap extends JourneyEventPayloadMap<TEventType>>(event: JourneyEvent<TStepId, TEventType, TPayloadMap>) => event is JourneyGoToEvent<TStepId, JourneyPayloadFor<TEventType, TPayloadMap, (typeof JOURNEY_EVENT)["GO_TO"]>>;
8
10
  export declare const isTerminalTarget: <TStepId extends string>(target: TStepId | JourneyTerminal | "__HISTORY__") => target is JourneyTerminal;
9
11
  export declare const buildSendResult: <TContext, TStepId extends string>(snapshot: JourneySnapshot<TContext, TStepId>, transitioned: boolean, transitionId?: string) => JourneySendResult<TContext, TStepId>;
10
- export declare const buildSnapshot: <TContext, TStepId extends string>(current: TStepId, context: TContext, history: readonly TStepId[], status: JourneyStatus, asyncState: JourneyAsyncState<TStepId>) => JourneySnapshot<TContext, TStepId>;
12
+ export declare const buildSnapshot: <TContext, TStepId extends string>(current: TStepId, context: TContext, history: readonly TStepId[], status: JourneyStatus, asyncState: JourneyAsyncState<TStepId>, visited?: readonly TStepId[]) => JourneySnapshot<TContext, TStepId>;
11
13
  export declare const resolveHistoryTarget: <TContext, TStepId extends string>(snapshot: JourneySnapshot<TContext, TStepId>, steps: Record<TStepId, unknown>) => {
12
14
  target: TStepId;
13
15
  history: TStepId[];
@@ -1 +1 @@
1
- {"version":3,"file":"machine-helpers.d.ts","sourceRoot":"","sources":["../src/machine-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,aAAa,EAAsC,MAAM,SAAS,CAAC;AACjG,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,gBAAgB,GAAI,OAAO,SAAS,MAAM,EACrD,OAAO,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,EAC/B,QAAQ,OAAO,EACf,SAAS,MAAM,SAKhB,CAAC;AAIF,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,OAAO,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAG,KAAK,IAAI,WAAW,CAAC,CAAC,CAI1B,CAAC;AAE1D,eAAO,MAAM,uBAAuB,QAAO,qBAKzC,CAAC;AAEH,eAAO,MAAM,sBAAsB,GAAI,OAAO,SAAS,MAAM,EAC3D,OAAO,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,KAC9B,iBAAiB,CAAC,OAAO,CAS3B,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,OAAO,SAAS,MAAM,EACtB,UAAU,SAAS,MAAM,EACzB,WAAW,SAAS,sBAAsB,CAAC,UAAU,CAAC,EAEtD,OAAO,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,KACpD,KAAK,IAAI,gBAAgB,CAC1B,OAAO,EACP,iBAAiB,CAAC,UAAU,EAAE,WAAW,EAAE,CAAC,OAAO,aAAa,EAAE,OAAO,CAAC,CAAC,CACrB,CAAC;AAEzD,e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F,eAAO,MAAM,kBAAkB,GAAI,QAAQ,EAAE,OAAO,SAAS,MAAM,EACjE,UAAU,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,EAC5C,aAAa,OAAO,EACpB,aAAa,QAAQ,KACpB,eAAe,CAAC,QAAQ,EAAE,OAAO,CASnC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../src/machine.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAGV,sBAAsB,EACtB,iBAAiB,EAGjB,cAAc,EACd,qBAAqB,EAGtB,MAAM,SAAS,CAAC;AA2CjB;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,EACR,OAAO,SAAS,MAAM,EACtB,UAAU,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,EAChE,WAAW,SAAS,sBAAsB,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAE7E,SAAS,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,EACtE,UAAU,qBAAqB,CAAC,QAAQ,EAAE,OAAO,CAAC,KACjD,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAwX3D,CAAC"}
1
+ {"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../src/machine.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAGV,sBAAsB,EACtB,iBAAiB,EAGjB,cAAc,EACd,qBAAqB,EAGtB,MAAM,SAAS,CAAC;AA4CjB;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,EACR,OAAO,SAAS,MAAM,EACtB,UAAU,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,EAChE,WAAW,SAAS,sBAAsB,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAE7E,SAAS,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,EACtE,UAAU,qBAAqB,CAAC,QAAQ,EAAE,OAAO,CAAC,KACjD,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAkY3D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../src/persistence.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EAIrB,eAAe,EAEhB,MAAM,SAAS,CAAC;AAgGjB;;;GAGG;AACH,eAAO,MAAM,2BAA2B,GAAI,QAAQ,EAAE,OAAO,SAAS,MAAM,EAAE,MAAM;IAClF,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,QAAQ,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,qBAAqB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;CACpD;;2BAyC6B,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC;gCAjC3B,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC;;CAqGtE,CAAC"}
1
+ {"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../src/persistence.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EAIrB,eAAe,EAEhB,MAAM,SAAS,CAAC;AA4GjB;;;GAGG;AACH,eAAO,MAAM,2BAA2B,GAAI,QAAQ,EAAE,OAAO,SAAS,MAAM,EAAE,MAAM;IAClF,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,QAAQ,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,qBAAqB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;CACpD;;2BA0C6B,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC;gCAlC3B,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC;;CA0GtE,CAAC"}
@@ -1 +1 @@
1
- {"fileNames":["../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.dom.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.scripthost.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.full.d.ts","../src/types.ts","../src/machine-helpers.ts","../src/persistence.ts","../src/machine.ts","../src/index.ts"],"fileIdsList":[[52,54,55],[52],[52,53,54],[52,53]],"fileInfos":[{"version":"c430d44666289dae81f30fa7b2edebf186ecc91a2d4c71266ea6ae76388792e1","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"080941d9f9ff9307f7e27a83bcd888b7c8270716c39af943532438932ec1d0b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"2e80ee7a49e8ac312cc11b77f1475804bee36b3b2bc896bead8b6e1266befb43","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7a3c8b952931daebdfc7a2897c53c0a1c73624593fa070e46bd537e64dcd20a","affectsGlobalScope":true,"impliedFormat":1},{"version":"80e18897e5884b6723488d4f5652167e7bb5024f946743134ecc4aa4ee731f89","affectsGlobalScope":true,"impliedFormat":1},{"version":"cd034f499c6cdca722b60c04b5b1b78e058487a7085a8e0d6fb50809947ee573","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"fb0f136d372979348d59b3f5020b4cdb81b5504192b1cacff5d1fbba29378aa1","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"a680117f487a4d2f30ea46f1b4b7f58bef1480456e18ba53ee85c2746eeca012","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"d6d7ae4d1f1f3772e2a3cde568ed08991a8ae34a080ff1151af28b7f798e22ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"1305d1e76ca44e30fb8b2b8075fa522b83f60c0bcf5d4326a9d2cf79b53724f8","impliedFormat":1},{"version":"3fd372717c7c15022bc1c6ad1f431f86b3350bcfa77c5927f1b737cd7b941add","signature":"3518fd87b0f1b2225d6e121f84794d75c0f9f2fc6ae4683ea0b2e96e0a6ef0f6"},{"version":"05801c11e1e9f163401117a753fdddeb49857a1c382f6ed3fe70b7e54e1883d5","signature":"7c12eeb8675fb066a04c79038ec56775e7a806e55d71d42abb3419cf3a8b30ff"},{"version":"bc265e74cf92d75de52cb617e2295c65ddf53eaa07ae31033c5a82b9f386e1e9","signature":"64a4320c603b4e6640d2813fd4817ab65f14fe57327373634a10ddc0016b6435"},{"version":"02aa1a03cdbd41bef5cc4ba9d0032a6e423fc6a86f687fe0c7790e32134c67f5","signature":"3d3e7b4efbe8891f0b0f37b832ce6adf587b32c4de869b557c2e2613d5363a65"},{"version":"6a2076fef6db705767a4ecbc9128e84718f9d0977ac8062b58f69751b7ed39e3","signature":"bdd8041fa7979a7f7a52eea92f4ecafc4155db4f964e0339b57ea05ca57afb8d"}],"root":[[52,56]],"options":{"composite":true,"declaration":true,"declarationDir":"./","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"exactOptionalPropertyTypes":true,"jsx":4,"module":99,"noFallthroughCasesInSwitch":true,"noUncheckedIndexedAccess":true,"outDir":"./","rootDir":"../src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":7,"tsBuildInfoFile":"./tsconfig.build.tsbuildinfo"},"referencedMap":[[56,1],[53,2],[55,3],[54,4]],"latestChangedDtsFile":"./index.d.ts","version":"5.9.3"}
1
+ {"fileNames":["../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.dom.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.scripthost.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.full.d.ts","../src/types.ts","../src/machine-helpers.ts","../src/persistence.ts","../src/machine.ts","../src/index.ts"],"fileIdsList":[[52,54,55],[52],[52,53,54],[52,53]],"fileInfos":[{"version":"c430d44666289dae81f30fa7b2edebf186ecc91a2d4c71266ea6ae76388792e1","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"080941d9f9ff9307f7e27a83bcd888b7c8270716c39af943532438932ec1d0b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"2e80ee7a49e8ac312cc11b77f1475804bee36b3b2bc896bead8b6e1266befb43","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7a3c8b952931daebdfc7a2897c53c0a1c73624593fa070e46bd537e64dcd20a","affectsGlobalScope":true,"impliedFormat":1},{"version":"80e18897e5884b6723488d4f5652167e7bb5024f946743134ecc4aa4ee731f89","affectsGlobalScope":true,"impliedFormat":1},{"version":"cd034f499c6cdca722b60c04b5b1b78e058487a7085a8e0d6fb50809947ee573","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"fb0f136d372979348d59b3f5020b4cdb81b5504192b1cacff5d1fbba29378aa1","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"a680117f487a4d2f30ea46f1b4b7f58bef1480456e18ba53ee85c2746eeca012","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"d6d7ae4d1f1f3772e2a3cde568ed08991a8ae34a080ff1151af28b7f798e22ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"1305d1e76ca44e30fb8b2b8075fa522b83f60c0bcf5d4326a9d2cf79b53724f8","impliedFormat":1},{"version":"0282259a9b4880387d809220971a0128142022c12658af02f5f7192da18114e7","signature":"b9dc4534a8b8abf7a231fdee9aeba909fe6a5d9d8ffc64336eb662c28164af1c"},{"version":"fe1063af7b4570276eaff494ec43b2096643c189acb1ab1af1378d049545155d","signature":"b8ba6d3320b991b5963822da9a59899f73addad8024074ba18c44a42a8df66c1"},{"version":"f31cd9847f04512bbe3a77d4094f75782b21917e540a151d3458a2667c93765d","signature":"64a4320c603b4e6640d2813fd4817ab65f14fe57327373634a10ddc0016b6435"},{"version":"045c2e73eb112bd2caa2c45d75a0ef39814bd69a757de167128cc19edb949d16","signature":"3d3e7b4efbe8891f0b0f37b832ce6adf587b32c4de869b557c2e2613d5363a65"},{"version":"6a2076fef6db705767a4ecbc9128e84718f9d0977ac8062b58f69751b7ed39e3","signature":"bdd8041fa7979a7f7a52eea92f4ecafc4155db4f964e0339b57ea05ca57afb8d"}],"root":[[52,56]],"options":{"composite":true,"declaration":true,"declarationDir":"./","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"exactOptionalPropertyTypes":true,"jsx":4,"module":99,"noFallthroughCasesInSwitch":true,"noUncheckedIndexedAccess":true,"outDir":"./","rootDir":"../src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":7,"tsBuildInfoFile":"./tsconfig.build.tsbuildinfo"},"referencedMap":[[56,1],[53,2],[55,3],[54,4]],"latestChangedDtsFile":"./index.d.ts","version":"5.9.3"}
package/dist/types.d.ts CHANGED
@@ -78,6 +78,7 @@ export type JourneyPersistedSnapshot<TContext, TStepId extends string> = {
78
78
  context: TContext;
79
79
  history: readonly TStepId[];
80
80
  status: JourneyStatus;
81
+ visited: readonly TStepId[];
81
82
  };
82
83
  export type JourneyPersistedState<TContext, TStepId extends string> = {
83
84
  version: number;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;CAGnB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAEvF,eAAO,MAAM,cAAc;;;;CAIjB,CAA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AAM,MAAM,cAAc,CACxB,QAAQ,EACR,OAAO,SAAS,MAAM,EACtB,UAAU,SAAS,MAAM,EACzB,WAAW,SAAS,sBAAsB,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAC3E;IACF,WAAW,EAAE,MAAM,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACtD,IAAI,EAAE,CACJ,KAAK,EAAE,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,KAClD,OAAO,CAAC,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,aAAa,EAAE,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,QAAQ,KAAK,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAChG,cAAc,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACzE,KAAK,EAAE,MAAM,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAChD,WAAW,EAAE,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAChF,YAAY,EAAE,MAAM,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvD,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;CACjD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rxova/journey-core",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Journey core state machine.",
5
5
  "keywords": [
6
6
  "journey",