xstate 5.0.0-beta.18 → 5.0.0-beta.19

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.
Files changed (31) hide show
  1. package/actions/dist/xstate-actions.cjs.js +1 -1
  2. package/actions/dist/xstate-actions.development.cjs.js +1 -1
  3. package/actions/dist/xstate-actions.development.esm.js +1 -1
  4. package/actions/dist/xstate-actions.esm.js +1 -1
  5. package/actions/dist/xstate-actions.umd.min.js.map +1 -1
  6. package/actors/dist/xstate-actors.cjs.js +1 -1
  7. package/actors/dist/xstate-actors.development.cjs.js +1 -1
  8. package/actors/dist/xstate-actors.development.esm.js +1 -1
  9. package/actors/dist/xstate-actors.esm.js +1 -1
  10. package/actors/dist/xstate-actors.umd.min.js +1 -1
  11. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  12. package/dist/{actions-5fb9f10d.cjs.js → actions-2d912781.cjs.js} +8 -4
  13. package/dist/{actions-4d6514d2.esm.js → actions-3b74fb92.esm.js} +8 -4
  14. package/dist/{actions-13190b25.development.esm.js → actions-72105f77.development.esm.js} +8 -4
  15. package/dist/{actions-40bd643f.development.cjs.js → actions-bce11b97.development.cjs.js} +8 -4
  16. package/dist/declarations/src/actors/callback.d.ts +4 -2
  17. package/dist/declarations/src/actors/observable.d.ts +8 -4
  18. package/dist/declarations/src/actors/promise.d.ts +5 -2
  19. package/dist/declarations/src/actors/transition.d.ts +6 -3
  20. package/dist/declarations/src/types.d.ts +9 -4
  21. package/dist/xstate.cjs.js +1 -1
  22. package/dist/xstate.development.cjs.js +1 -1
  23. package/dist/xstate.development.esm.js +2 -2
  24. package/dist/xstate.esm.js +2 -2
  25. package/dist/xstate.umd.min.js +1 -1
  26. package/dist/xstate.umd.min.js.map +1 -1
  27. package/guards/dist/xstate-guards.cjs.js +1 -1
  28. package/guards/dist/xstate-guards.development.cjs.js +1 -1
  29. package/guards/dist/xstate-guards.development.esm.js +1 -1
  30. package/guards/dist/xstate-guards.esm.js +1 -1
  31. package/package.json +1 -1
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var actors_dist_xstateActors = require('../../dist/actions-5fb9f10d.cjs.js');
5
+ var actors_dist_xstateActors = require('../../dist/actions-2d912781.cjs.js');
6
6
  require('../../dev/dist/xstate-dev.cjs.js');
7
7
 
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var actors_dist_xstateActors = require('../../dist/actions-40bd643f.development.cjs.js');
5
+ var actors_dist_xstateActors = require('../../dist/actions-bce11b97.development.cjs.js');
6
6
  require('../../dev/dist/xstate-dev.development.cjs.js');
7
7
 
8
8
 
@@ -1,2 +1,2 @@
1
- export { ae as createEmptyActor, _ as fromCallback, $ as fromEventObservable, Z as fromObservable, Y as fromPromise, a0 as fromTransition, ac as isActorRef, ab as isSignal, a9 as startSignal, a7 as startSignalType, aa as stopSignal, a8 as stopSignalType, ad as toActorRef } from '../../dist/actions-13190b25.development.esm.js';
1
+ export { ae as createEmptyActor, _ as fromCallback, $ as fromEventObservable, Z as fromObservable, Y as fromPromise, a0 as fromTransition, ac as isActorRef, ab as isSignal, a9 as startSignal, a7 as startSignalType, aa as stopSignal, a8 as stopSignalType, ad as toActorRef } from '../../dist/actions-72105f77.development.esm.js';
2
2
  import '../../dev/dist/xstate-dev.development.esm.js';
@@ -1,2 +1,2 @@
1
- export { ae as createEmptyActor, _ as fromCallback, $ as fromEventObservable, Z as fromObservable, Y as fromPromise, a0 as fromTransition, ac as isActorRef, ab as isSignal, a9 as startSignal, a7 as startSignalType, aa as stopSignal, a8 as stopSignalType, ad as toActorRef } from '../../dist/actions-4d6514d2.esm.js';
1
+ export { ae as createEmptyActor, _ as fromCallback, $ as fromEventObservable, Z as fromObservable, Y as fromPromise, a0 as fromTransition, ac as isActorRef, ab as isSignal, a9 as startSignal, a7 as startSignalType, aa as stopSignal, a8 as stopSignalType, ad as toActorRef } from '../../dist/actions-3b74fb92.esm.js';
2
2
  import '../../dev/dist/xstate-dev.esm.js';
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).XStateActors={})}(this,(function(t){"use strict";const e="function"==typeof Symbol&&Symbol.observable||"@@observable";class s{constructor(t){this._process=t,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}prepend(t){this._current?this._current={value:t,next:this._current}:this.enqueue(t)}enqueue(t){const e={value:t,next:null};if(this._current)return this._last.next=e,void(this._last=e);this._current=e,this._last=e,this._active&&this.flush()}flush(){for(;this._current;){const t=this._current;this._process(t.value),t===this._current&&(this._current=this._current.next)}this._last=null}}let i=function(t){return t.After="xstate.after",t.DoneState="done.state",t.DoneInvoke="done.invoke",t.ErrorExecution="error.execution",t.ErrorCommunication="error.communication",t.ErrorPlatform="error.platform",t.ErrorCustom="xstate.error",t}({});function o(t,e){const s=`${i.DoneInvoke}.${t}`,o={type:s,output:e,toString:()=>s};return o}function n(t,e){const s=`${i.ErrorPlatform}.${t}`,o={type:s,data:e,toString:()=>s};return o}function r(){const t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:window;if(t.__xstate__)return t.__xstate__}const a=t=>{const e=r();e&&e.register(t)};let c=function(t){return t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped",t}({});const u={deferEvents:!0,clock:{setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t)},logger:console.log.bind(console),devTools:!1};class d{constructor(t,e){this.logic=t,this._state=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new s(this._process.bind(this)),this.delayedEventsMap={},this.observers=new Set,this.logger=void 0,this.status=c.NotStarted,this._parent=void 0,this.ref=void 0,this._actorContext=void 0,this._systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];const i={...u,...e},{clock:o,logger:n,parent:r,id:a,systemId:d}=i;this.system=r?.system??function(){let t=0;const e=new Map,s=new Map,i=new WeakMap;return{_bookId:()=>"x:"+t++,_register:(t,s)=>(e.set(t,s),t),_unregister:t=>{e.delete(t.sessionId);const o=i.get(t);void 0!==o&&(s.delete(o),i.delete(t))},get:t=>s.get(t),_set:(t,e)=>{const o=s.get(t);if(o&&o!==e)throw new Error(`Actor with system ID '${t}' already exists.`);s.set(t,e),i.set(e,t)}}}(),d&&(this._systemId=d,this.system._set(d,this)),this.sessionId=this.system._bookId(),this.id=a??this.sessionId,this.logger=n,this.clock=o,this._parent=r,this.options=i,this.src=i.src,this.ref=this,this._actorContext={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:t=>{this._deferred.push(t)},system:this.system,stopChild:t=>{if(t._parent!==this)throw new Error(`Cannot stop child actor ${t.id} of ${this.id} because it is not a child`);t._stop()}},this.send=this.send.bind(this),this._initState()}_initState(){this._state=this.options.state?this.logic.restoreState?this.logic.restoreState(this.options.state,this._actorContext):this.options.state:this.logic.getInitialState(this._actorContext,this.options?.input)}update(t){this._state=t;const e=this.getSnapshot();let s;for(;s=this._deferred.shift();)s();for(const t of this.observers)t.next?.(e);const i=this.logic.getStatus?.(t);switch(i?.status){case"done":this._stopProcedure(),this._doneEvent=o(this.id,i.data),this._parent?.send(this._doneEvent),this._complete();break;case"error":this._stopProcedure(),this._parent?.send(n(this.id,i.data)),this._error(i.data)}}subscribe(t,e,s){const i=function(t,e,s){const i=()=>{},o="object"==typeof t,n=o?t:null;return{next:((o?t.next:t)||i).bind(n),error:((o?t.error:e)||i).bind(n),complete:((o?t.complete:s)||i).bind(n)}}(t,e,s);return this.observers.add(i),this.status===c.Stopped&&(i.complete?.(),this.observers.delete(i)),{unsubscribe:()=>{this.observers.delete(i)}}}start(){return this.status===c.Running||(this.system._register(this.sessionId,this),this._systemId&&this.system._set(this._systemId,this),this.status=c.Running,this.logic.start&&this.logic.start(this._state,this._actorContext),this.update(this._state),this.options.devTools&&this.attachDevTools(),this.mailbox.start()),this}_process(t){try{const e=this.logic.transition(this._state,t,this._actorContext);this.update(e),t.type===v&&(this._stopProcedure(),this._complete())}catch(t){if(!(this.observers.size>0))throw t;this.observers.forEach((e=>{e.error?.(t)})),this.stop()}}_stop(){return this.status===c.Stopped?this:(this.mailbox.clear(),this.status===c.NotStarted?(this.status=c.Stopped,this):(this.mailbox.enqueue({type:v}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(const t of this.observers)t.complete?.();this.observers.clear()}_error(t){for(const e of this.observers)e.error?.(t);this.observers.clear()}_stopProcedure(){if(this.status!==c.Running)return this;for(const t of Object.keys(this.delayedEventsMap))this.clock.clearTimeout(this.delayedEventsMap[t]);return this.mailbox.clear(),this.mailbox=new s(this._process.bind(this)),this.status=c.Stopped,this.system._unregister(this),this}send(t){if("string"==typeof t)throw new Error(`Only event objects may be sent to actors; use .send({ type: "${t}" }) instead`);if(this.status!==c.Stopped){if(this.status!==c.Running&&!this.options.deferEvents)throw new Error(`Event "${t.type}" was sent to uninitialized actor "${this.id}". Make sure .start() is called for this actor, or set { deferEvents: true } in the actor options.\nEvent: ${JSON.stringify(t)}`);this.mailbox.enqueue(t)}}delaySend({event:t,id:e,delay:s,to:i}){const o=this.clock.setTimeout((()=>{i?i.send(t):this.send(t)}),s);e&&(this.delayedEventsMap[e]=o)}cancel(t){this.clock.clearTimeout(this.delayedEventsMap[t]),delete this.delayedEventsMap[t]}attachDevTools(){const{devTools:t}=this.options;if(t){("function"==typeof t?t:a)(this)}}toJSON(){return{id:this.id}}getPersistedState(){return this.logic.getPersistedState?.(this._state)}[e](){return this}getSnapshot(){return this.logic.getSnapshot?this.logic.getSnapshot(this._state):this._state}}function h(t,e){return{config:t,transition:(e,s,i)=>t(e,s,i),getInitialState:(t,s)=>"function"==typeof e?e({input:s}):e,getSnapshot:t=>t,getPersistedState:t=>t,restoreState:t=>t}}const p="$$xstate.resolve",l="$$xstate.reject";const f="xstate.init",v="xstate.stop";function _(t){return t.type===f||t.type===v}const y=h((t=>{}),void 0);t.createEmptyActor=function(){return new d(y,t);var t},t.fromCallback=function(t){return{config:t,start:(t,{self:e})=>{e.send({type:f})},transition:(e,s,{self:i,id:r,system:a})=>{if(s.type===f){const s=t=>{e.canceled||i._parent?.send(t)},u=t=>{e.receivers.add(t)};return e.dispose=t(s,u,{input:e.input,system:a}),((c=e.dispose)instanceof Promise||null!==c&&("function"==typeof c||"object"==typeof c)&&"function"==typeof c.then)&&e.dispose.then((t=>{i._parent?.send(o(r,t)),e.canceled=!0}),(t=>{e.canceled=!0,i._parent?.send(n(r,t))})),e}var c;return s.type===v?(e.canceled=!0,"function"==typeof e.dispose&&e.dispose(),e):(_(s)||e.receivers.forEach((t=>t(s))),e)},getInitialState:(t,e)=>({canceled:!1,receivers:new Set,dispose:void 0,input:e}),getSnapshot:()=>{},getPersistedState:({input:t})=>t}},t.fromEventObservable=function(t){const e="$$xstate.error",s="$$xstate.complete";return{config:t,transition:(t,i)=>{if("active"!==t.status)return t;switch(i.type){case e:return{...t,status:"error",input:void 0,data:i.data,subscription:void 0};case s:return{...t,status:"done",input:void 0,subscription:void 0};case v:return t.subscription.unsubscribe(),{...t,status:"canceled",input:void 0,subscription:void 0};default:return t}},getInitialState:(t,e)=>({subscription:void 0,status:"active",data:void 0,input:e}),start:(i,{self:o,system:n})=>{"done"!==i.status&&(i.subscription=t({input:i.input,system:n}).subscribe({next:t=>{o._parent?.send(t)},error:t=>{o.send({type:e,data:t})},complete:()=>{o.send({type:s})}}))},getSnapshot:t=>{},getPersistedState:({status:t,data:e,input:s})=>({status:t,data:e,input:s}),getStatus:t=>t,restoreState:t=>({...t,subscription:void 0})}},t.fromObservable=function(t){const e="$$xstate.next",s="$$xstate.error",i="$$xstate.complete";return{config:t,transition:(t,o,{self:n,id:r,defer:a})=>{if("active"!==t.status)return t;switch(o.type){case e:return a((()=>{n._parent?.send({type:`xstate.snapshot.${r}`,data:o.data})})),{...t,data:o.data};case s:return{...t,status:"error",input:void 0,data:o.data,subscription:void 0};case i:return{...t,status:"done",input:void 0,subscription:void 0};case v:return t.subscription.unsubscribe(),{...t,status:"canceled",input:void 0,subscription:void 0};default:return t}},getInitialState:(t,e)=>({subscription:void 0,status:"active",data:void 0,input:e}),start:(o,{self:n,system:r})=>{"done"!==o.status&&(o.subscription=t({input:o.input,system:r}).subscribe({next:t=>{n.send({type:e,data:t})},error:t=>{n.send({type:s,data:t})},complete:()=>{n.send({type:i})}}))},getSnapshot:t=>t.data,getPersistedState:({status:t,data:e,input:s})=>({status:t,data:e,input:s}),getStatus:t=>t,restoreState:t=>({...t,subscription:void 0})}},t.fromPromise=function(t){return{config:t,transition:(t,e)=>{if("active"!==t.status)return t;switch(e.type){case p:return{...t,status:"done",data:e.data,input:void 0};case l:return{...t,status:"error",data:e.data,input:void 0};case v:return{...t,status:"canceled",input:void 0};default:return t}},start:(e,{self:s,system:i})=>{if("active"!==e.status)return;Promise.resolve(t({input:e.input,system:i})).then((t=>{"active"===s._state.status&&s.send({type:p,data:t})}),(t=>{"active"===s._state.status&&s.send({type:l,data:t})}))},getInitialState:(t,e)=>({status:"active",data:void 0,input:e}),getSnapshot:t=>t.data,getStatus:t=>t,getPersistedState:t=>t,restoreState:t=>t}},t.fromTransition=h,t.isActorRef=function(t){return!!t&&"object"==typeof t&&"function"==typeof t.send},t.isSignal=_,t.startSignal={type:"xstate.init"},t.startSignalType=f,t.stopSignal={type:"xstate.stop"},t.stopSignalType=v,t.toActorRef=function(t){return{subscribe:()=>({unsubscribe:()=>{}}),id:"anonymous",sessionId:"",getSnapshot:()=>{},[e]:function(){return this},status:c.Running,stop:()=>{},...t}},Object.defineProperty(t,"__esModule",{value:!0})}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).XStateActors={})}(this,(function(t){"use strict";const e="function"==typeof Symbol&&Symbol.observable||"@@observable";class s{constructor(t){this._process=t,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}prepend(t){this._current?this._current={value:t,next:this._current}:this.enqueue(t)}enqueue(t){const e={value:t,next:null};if(this._current)return this._last.next=e,void(this._last=e);this._current=e,this._last=e,this._active&&this.flush()}flush(){for(;this._current;){const t=this._current;this._process(t.value),t===this._current&&(this._current=this._current.next)}this._last=null}}let i=function(t){return t.After="xstate.after",t.DoneState="done.state",t.DoneInvoke="done.invoke",t.ErrorExecution="error.execution",t.ErrorCommunication="error.communication",t.ErrorPlatform="error.platform",t.ErrorCustom="xstate.error",t}({});function o(t,e){const s=`${i.DoneInvoke}.${t}`,o={type:s,output:e,toString:()=>s};return o}function n(t,e){const s=`${i.ErrorPlatform}.${t}`,o={type:s,data:e,toString:()=>s};return o}function r(){const t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:window;if(t.__xstate__)return t.__xstate__}const a=t=>{const e=r();e&&e.register(t)};let c=function(t){return t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped",t}({});const u={deferEvents:!0,clock:{setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t)},logger:console.log.bind(console),devTools:!1};class d{constructor(t,e){this.logic=t,this._state=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new s(this._process.bind(this)),this.delayedEventsMap={},this.observers=new Set,this.logger=void 0,this.status=c.NotStarted,this._parent=void 0,this.ref=void 0,this._actorContext=void 0,this._systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];const i={...u,...e},{clock:o,logger:n,parent:r,id:a,systemId:d}=i;this.system=r?.system??function(){let t=0;const e=new Map,s=new Map,i=new WeakMap;return{_bookId:()=>"x:"+t++,_register:(t,s)=>(e.set(t,s),t),_unregister:t=>{e.delete(t.sessionId);const o=i.get(t);void 0!==o&&(s.delete(o),i.delete(t))},get:t=>s.get(t),_set:(t,e)=>{const o=s.get(t);if(o&&o!==e)throw new Error(`Actor with system ID '${t}' already exists.`);s.set(t,e),i.set(e,t)}}}(),d&&(this._systemId=d,this.system._set(d,this)),this.sessionId=this.system._bookId(),this.id=a??this.sessionId,this.logger=n,this.clock=o,this._parent=r,this.options=i,this.src=i.src,this.ref=this,this._actorContext={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:t=>{this._deferred.push(t)},system:this.system,stopChild:t=>{if(t._parent!==this)throw new Error(`Cannot stop child actor ${t.id} of ${this.id} because it is not a child`);t._stop()}},this.send=this.send.bind(this),this._initState()}_initState(){this._state=this.options.state?this.logic.restoreState?this.logic.restoreState(this.options.state,this._actorContext):this.options.state:this.logic.getInitialState(this._actorContext,this.options?.input)}update(t){this._state=t;const e=this.getSnapshot();let s;for(;s=this._deferred.shift();)s();for(const t of this.observers)t.next?.(e);const i=this.logic.getStatus?.(t);switch(i?.status){case"done":this._stopProcedure(),this._doneEvent=o(this.id,i.data),this._parent?.send(this._doneEvent),this._complete();break;case"error":this._stopProcedure(),this._parent?.send(n(this.id,i.data)),this._error(i.data)}}subscribe(t,e,s){const i=function(t,e,s){const i=()=>{},o="object"==typeof t,n=o?t:null;return{next:((o?t.next:t)||i).bind(n),error:((o?t.error:e)||i).bind(n),complete:((o?t.complete:s)||i).bind(n)}}(t,e,s);return this.observers.add(i),this.status===c.Stopped&&(i.complete?.(),this.observers.delete(i)),{unsubscribe:()=>{this.observers.delete(i)}}}start(){return this.status===c.Running||(this.system._register(this.sessionId,this),this._systemId&&this.system._set(this._systemId,this),this.status=c.Running,this.logic.start&&this.logic.start(this._state,this._actorContext),this.update(this._state),this.options.devTools&&this.attachDevTools(),this.mailbox.start()),this}_process(t){try{const e=this.logic.transition(this._state,t,this._actorContext);this.update(e),t.type===v&&(this._stopProcedure(),this._complete())}catch(t){if(!(this.observers.size>0))throw t;this.observers.forEach((e=>{e.error?.(t)})),this.stop()}}_stop(){return this.status===c.Stopped?this:(this.mailbox.clear(),this.status===c.NotStarted?(this.status=c.Stopped,this):(this.mailbox.enqueue({type:v}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(const t of this.observers)t.complete?.();this.observers.clear()}_error(t){for(const e of this.observers)e.error?.(t);this.observers.clear()}_stopProcedure(){if(this.status!==c.Running)return this;for(const t of Object.keys(this.delayedEventsMap))this.clock.clearTimeout(this.delayedEventsMap[t]);return this.mailbox.clear(),this.mailbox=new s(this._process.bind(this)),this.status=c.Stopped,this.system._unregister(this),this}send(t){if("string"==typeof t)throw new Error(`Only event objects may be sent to actors; use .send({ type: "${t}" }) instead`);if(this.status!==c.Stopped){if(this.status!==c.Running&&!this.options.deferEvents)throw new Error(`Event "${t.type}" was sent to uninitialized actor "${this.id}". Make sure .start() is called for this actor, or set { deferEvents: true } in the actor options.\nEvent: ${JSON.stringify(t)}`);this.mailbox.enqueue(t)}}delaySend({event:t,id:e,delay:s,to:i}){const o=this.clock.setTimeout((()=>{i?i.send(t):this.send(t)}),s);e&&(this.delayedEventsMap[e]=o)}cancel(t){this.clock.clearTimeout(this.delayedEventsMap[t]),delete this.delayedEventsMap[t]}attachDevTools(){const{devTools:t}=this.options;if(t){("function"==typeof t?t:a)(this)}}toJSON(){return{id:this.id}}getPersistedState(){return this.logic.getPersistedState?.(this._state)}[e](){return this}getSnapshot(){return this.logic.getSnapshot?this.logic.getSnapshot(this._state):this._state}}function h(t,e){return{config:t,transition:(e,s,i)=>t(e,s,i),getInitialState:(t,s)=>"function"==typeof e?e({input:s}):e,getSnapshot:t=>t,getPersistedState:t=>t,restoreState:t=>t}}const p="$$xstate.resolve",l="$$xstate.reject";const f="xstate.init",v="xstate.stop";function _(t){return t.type===f||t.type===v}const y=h((t=>{}),void 0);t.createEmptyActor=function(){return new d(y,t);var t},t.fromCallback=function(t){return{config:t,start:(t,{self:e})=>{e.send({type:f})},transition:(e,s,{self:i,id:r,system:a})=>{if(s.type===f){const s=t=>{e.canceled||i._parent?.send(t)},u=t=>{e.receivers.add(t)};return e.dispose=t(s,u,{input:e.input,system:a,self:i}),((c=e.dispose)instanceof Promise||null!==c&&("function"==typeof c||"object"==typeof c)&&"function"==typeof c.then)&&e.dispose.then((t=>{i._parent?.send(o(r,t)),e.canceled=!0}),(t=>{e.canceled=!0,i._parent?.send(n(r,t))})),e}var c;return s.type===v?(e.canceled=!0,"function"==typeof e.dispose&&e.dispose(),e):(_(s)||e.receivers.forEach((t=>t(s))),e)},getInitialState:(t,e)=>({canceled:!1,receivers:new Set,dispose:void 0,input:e}),getSnapshot:()=>{},getPersistedState:({input:t})=>t}},t.fromEventObservable=function(t){const e="$$xstate.error",s="$$xstate.complete";return{config:t,transition:(t,i)=>{if("active"!==t.status)return t;switch(i.type){case e:return{...t,status:"error",input:void 0,data:i.data,subscription:void 0};case s:return{...t,status:"done",input:void 0,subscription:void 0};case v:return t.subscription.unsubscribe(),{...t,status:"canceled",input:void 0,subscription:void 0};default:return t}},getInitialState:(t,e)=>({subscription:void 0,status:"active",data:void 0,input:e}),start:(i,{self:o,system:n})=>{"done"!==i.status&&(i.subscription=t({input:i.input,system:n,self:o}).subscribe({next:t=>{o._parent?.send(t)},error:t=>{o.send({type:e,data:t})},complete:()=>{o.send({type:s})}}))},getSnapshot:t=>{},getPersistedState:({status:t,data:e,input:s})=>({status:t,data:e,input:s}),getStatus:t=>t,restoreState:t=>({...t,subscription:void 0})}},t.fromObservable=function(t){const e="$$xstate.next",s="$$xstate.error",i="$$xstate.complete";return{config:t,transition:(t,o,{self:n,id:r,defer:a})=>{if("active"!==t.status)return t;switch(o.type){case e:return a((()=>{n._parent?.send({type:`xstate.snapshot.${r}`,data:o.data})})),{...t,data:o.data};case s:return{...t,status:"error",input:void 0,data:o.data,subscription:void 0};case i:return{...t,status:"done",input:void 0,subscription:void 0};case v:return t.subscription.unsubscribe(),{...t,status:"canceled",input:void 0,subscription:void 0};default:return t}},getInitialState:(t,e)=>({subscription:void 0,status:"active",data:void 0,input:e}),start:(o,{self:n,system:r})=>{"done"!==o.status&&(o.subscription=t({input:o.input,system:r,self:n}).subscribe({next:t=>{n.send({type:e,data:t})},error:t=>{n.send({type:s,data:t})},complete:()=>{n.send({type:i})}}))},getSnapshot:t=>t.data,getPersistedState:({status:t,data:e,input:s})=>({status:t,data:e,input:s}),getStatus:t=>t,restoreState:t=>({...t,subscription:void 0})}},t.fromPromise=function(t){return{config:t,transition:(t,e)=>{if("active"!==t.status)return t;switch(e.type){case p:return{...t,status:"done",data:e.data,input:void 0};case l:return{...t,status:"error",data:e.data,input:void 0};case v:return{...t,status:"canceled",input:void 0};default:return t}},start:(e,{self:s,system:i})=>{if("active"!==e.status)return;Promise.resolve(t({input:e.input,system:i,self:s})).then((t=>{"active"===s._state.status&&s.send({type:p,data:t})}),(t=>{"active"===s._state.status&&s.send({type:l,data:t})}))},getInitialState:(t,e)=>({status:"active",data:void 0,input:e}),getSnapshot:t=>t.data,getStatus:t=>t,getPersistedState:t=>t,restoreState:t=>t}},t.fromTransition=h,t.isActorRef=function(t){return!!t&&"object"==typeof t&&"function"==typeof t.send},t.isSignal=_,t.startSignal={type:"xstate.init"},t.startSignalType=f,t.stopSignal={type:"xstate.stop"},t.stopSignalType=v,t.toActorRef=function(t){return{subscribe:()=>({unsubscribe:()=>{}}),id:"anonymous",sessionId:"",getSnapshot:()=>{},[e]:function(){return this},status:c.Running,stop:()=>{},...t}},Object.defineProperty(t,"__esModule",{value:!0})}));
2
2
  //# sourceMappingURL=xstate-actors.umd.min.js.map