xstate 5.0.0-beta.11 → 5.0.0-beta.12

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 (29) 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 +1 -1
  6. package/actions/dist/xstate-actions.umd.min.js.map +1 -1
  7. package/actors/dist/xstate-actors.cjs.js +1 -1
  8. package/actors/dist/xstate-actors.development.cjs.js +1 -1
  9. package/actors/dist/xstate-actors.development.esm.js +1 -1
  10. package/actors/dist/xstate-actors.esm.js +1 -1
  11. package/actors/dist/xstate-actors.umd.min.js +1 -1
  12. package/actors/dist/xstate-actors.umd.min.js.map +1 -1
  13. package/dist/{actions-b82e841e.esm.js → actions-b34f6ce7.esm.js} +7 -21
  14. package/dist/{actions-cff79077.development.esm.js → actions-c8b9504d.development.esm.js} +7 -21
  15. package/dist/{actions-acbe7aa1.development.cjs.js → actions-d9c19f35.development.cjs.js} +7 -21
  16. package/dist/{actions-26f9aa9d.cjs.js → actions-e4c704f3.cjs.js} +7 -21
  17. package/dist/declarations/src/interpreter.d.ts +1 -6
  18. package/dist/declarations/src/types.d.ts +1 -0
  19. package/dist/xstate.cjs.js +1 -1
  20. package/dist/xstate.development.cjs.js +1 -1
  21. package/dist/xstate.development.esm.js +2 -2
  22. package/dist/xstate.esm.js +2 -2
  23. package/dist/xstate.umd.min.js +1 -1
  24. package/dist/xstate.umd.min.js.map +1 -1
  25. package/guards/dist/xstate-guards.cjs.js +1 -1
  26. package/guards/dist/xstate-guards.development.cjs.js +1 -1
  27. package/guards/dist/xstate-guards.development.esm.js +1 -1
  28. package/guards/dist/xstate-guards.esm.js +1 -1
  29. 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-26f9aa9d.cjs.js');
5
+ var actors_dist_xstateActors = require('../../dist/actions-e4c704f3.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-acbe7aa1.development.cjs.js');
5
+ var actors_dist_xstateActors = require('../../dist/actions-d9c19f35.development.cjs.js');
6
6
  require('../../dev/dist/xstate-dev.development.cjs.js');
7
7
 
8
8
 
@@ -1,2 +1,2 @@
1
- export { ai as createEmptyActor, a2 as fromCallback, a3 as fromEventObservable, a1 as fromObservable, a0 as fromPromise, a4 as fromTransition, ag as isActorRef, af as isSignal, ad as startSignal, ab as startSignalType, ae as stopSignal, ac as stopSignalType, ah as toActorRef } from '../../dist/actions-cff79077.development.esm.js';
1
+ export { ai as createEmptyActor, a2 as fromCallback, a3 as fromEventObservable, a1 as fromObservable, a0 as fromPromise, a4 as fromTransition, ag as isActorRef, af as isSignal, ad as startSignal, ab as startSignalType, ae as stopSignal, ac as stopSignalType, ah as toActorRef } from '../../dist/actions-c8b9504d.development.esm.js';
2
2
  import '../../dev/dist/xstate-dev.development.esm.js';
@@ -1,2 +1,2 @@
1
- export { ai as createEmptyActor, a2 as fromCallback, a3 as fromEventObservable, a1 as fromObservable, a0 as fromPromise, a4 as fromTransition, ag as isActorRef, af as isSignal, ad as startSignal, ab as startSignalType, ae as stopSignal, ac as stopSignalType, ah as toActorRef } from '../../dist/actions-b82e841e.esm.js';
1
+ export { ai as createEmptyActor, a2 as fromCallback, a3 as fromEventObservable, a1 as fromObservable, a0 as fromPromise, a4 as fromTransition, ag as isActorRef, af as isSignal, ad as startSignal, ab as startSignalType, ae as stopSignal, ac as stopSignalType, ah as toActorRef } from '../../dist/actions-b34f6ce7.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.Stop="xstate.stop",t.Raise="xstate.raise",t.Send="xstate.send",t.Cancel="xstate.cancel",t.Assign="xstate.assign",t.After="xstate.after",t.DoneState="done.state",t.DoneInvoke="done.invoke",t.Log="xstate.log",t.Init="xstate.init",t.Invoke="xstate.invoke",t.ErrorExecution="error.execution",t.ErrorCommunication="error.communication",t.ErrorPlatform="error.platform",t.ErrorCustom="xstate.error",t.Pure="xstate.pure",t.Choose="xstate.choose",t}({});function n(t){return"function"==typeof t}function o(t,e){const s=`${i.DoneInvoke}.${t}`,n={type:s,output:e,toString:()=>s};return n}function r(t,e){const s=`${i.ErrorPlatform}.${t}`,n={type:s,data:e,toString:()=>s};return n}function a(){const t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:window;if(t.__xstate__)return t.__xstate__}const u=t=>{const e=a();e&&e.register(t)};let d=function(t){return t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped",t}({});const c={deferEvents:!0,clock:{setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t)},logger:console.log.bind(console),devTools:!1};class h{constructor(t,e){this.behavior=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=d.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={...c,...e},{clock:n,logger:o,parent:r,id:a,systemId:u}=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 n=i.get(t);void 0!==n&&(s.delete(n),i.delete(t))},get:t=>s.get(t),_set:(t,e)=>{const n=s.get(t);if(n&&n!==e)throw new Error(`Actor with system ID '${t}' already exists.`);s.set(t,e),i.set(e,t)}}}(),u&&(this._systemId=u,this.system._set(u,this)),this.sessionId=this.system._bookId(),this.id=a??this.sessionId,this.logger=o,this.clock=n,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.behavior.restoreState?this.behavior.restoreState(this.options.state,this._actorContext):this.options.state:this.behavior.getInitialState(this._actorContext,this.options?.input)}update(t){this._state=t;const e=this.getSnapshot();let s;for(;s=this._deferred.shift();)s(t);for(const t of this.observers)t.next?.(e);const i=this.behavior.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(r(this.id,i.data)),this._error(i.data)}}subscribe(t,e,s){const i=function(t,e,s){const i=()=>{},n="object"==typeof t,o=n?t:null;return{next:((n?t.next:t)||i).bind(o),error:((n?t.error:e)||i).bind(o),complete:((n?t.complete:s)||i).bind(o)}}(t,e,s);return this.observers.add(i),this.status===d.Stopped&&(i.complete?.(),this.observers.delete(i)),{unsubscribe:()=>{this.observers.delete(i)}}}onDone(t){return this.status===d.Stopped&&this._doneEvent?t(this._doneEvent):this.observers.add({complete:()=>{this._doneEvent&&t(this._doneEvent)}}),this}start(){return this.status===d.Running||(this.system._register(this.sessionId,this),this._systemId&&this.system._set(this._systemId,this),this.status=d.Running,this.behavior.start&&this.behavior.start(this._state,this._actorContext),this.update(this._state),this.options.devTools&&this.attachDevTools(),this.mailbox.start()),this}_process(t){try{const e=this.behavior.transition(this._state,t,this._actorContext);this.update(e),t.type===f&&(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===d.Stopped?this:(this.mailbox.clear(),this.status===d.NotStarted?(this.status=d.Stopped,this):(this.mailbox.enqueue({type:f}),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!==d.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=d.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!==d.Stopped){if(this.status!==d.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(t){this.delayedEventsMap[t.params.id]=this.clock.setTimeout((()=>{"to"in t.params&&t.params.to?t.params.to.send(t.params.event):this.send(t.params.event)}),t.params.delay)}cancel(t){this.clock.clearTimeout(this.delayedEventsMap[t]),delete this.delayedEventsMap[t]}attachDevTools(){const{devTools:t}=this.options;if(t){("function"==typeof t?t:u)(this)}}toJSON(){return{id:this.id}}getPersistedState(){return this.behavior.getPersistedState?.(this._state)}[e](){return this}getSnapshot(){return this.behavior.getSnapshot?this.behavior.getSnapshot(this._state):this._state}}function p(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 l="xstate.init",f="xstate.stop";function v(t){return t===l||t===f}const _=p((t=>{}),void 0);t.createEmptyActor=function(){return new h(_,t);var t},t.fromCallback=function(t){return{config:t,start:(t,{self:e})=>{e.send({type:l})},transition:(e,s,{self:i,id:a})=>{if(s.type===l){const s=t=>{e.canceled||i._parent?.send(t)},d=t=>{e.receivers.add(t)};return e.dispose=t(s,d,{input:e.input}),((u=e.dispose)instanceof Promise||null!==u&&(n(u)||"object"==typeof u)&&n(u.then))&&e.dispose.then((t=>{i._parent?.send(o(a,t)),e.canceled=!0}),(t=>{e.canceled=!0,i._parent?.send(r(a,t))})),e}var u;return s.type===f?(e.canceled=!0,n(e.dispose)&&e.dispose(),e):(v(s.type)||v(s.type)||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 f: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:n})=>{"done"!==i.status&&(i.subscription=t({input:i.input}).subscribe({next:t=>{n._parent?.send(t)},error:t=>{n.send({type:e,data:t})},complete:()=>{n.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,n,{self:o,id:r,defer:a})=>{if("active"!==t.status)return t;switch(n.type){case e:return a((()=>{o._parent?.send({type:`xstate.snapshot.${r}`,data:n.data})})),{...t,data:n.data};case s:return{...t,status:"error",input:void 0,data:n.data,subscription:void 0};case i:return{...t,status:"done",input:void 0,subscription:void 0};case f: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:(n,{self:o})=>{"done"!==n.status&&(n.subscription=t({input:n.input}).subscribe({next:t=>{o.send({type:e,data:t})},error:t=>{o.send({type:s,data:t})},complete:()=>{o.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){const e="$$xstate.resolve",s="$$xstate.reject";return{config:t,transition:(t,i)=>{if("active"!==t.status)return t;switch(i.type){case e:return{...t,status:"done",data:i.data,input:void 0};case s:return{...t,status:"error",data:i.data,input:void 0};case f:return{...t,status:"canceled",input:void 0};default:return t}},start:(i,{self:n})=>{if("active"!==i.status)return;Promise.resolve(t({input:i.input})).then((t=>{"active"===n._state.status&&n.send({type:e,data:t})}),(t=>{"active"===n._state.status&&n.send({type:s,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=p,t.isActorRef=function(t){return!!t&&"object"==typeof t&&"function"==typeof t.send},t.isSignal=v,t.startSignal={type:"xstate.init"},t.startSignalType=l,t.stopSignal={type:"xstate.stop"},t.stopSignalType=f,t.toActorRef=function(t){return{subscribe:()=>({unsubscribe:()=>{}}),id:"anonymous",sessionId:"",getSnapshot:()=>{},[e]:function(){return this},status:d.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.Stop="xstate.stop",t.Raise="xstate.raise",t.Send="xstate.send",t.Cancel="xstate.cancel",t.Assign="xstate.assign",t.After="xstate.after",t.DoneState="done.state",t.DoneInvoke="done.invoke",t.Log="xstate.log",t.Init="xstate.init",t.Invoke="xstate.invoke",t.ErrorExecution="error.execution",t.ErrorCommunication="error.communication",t.ErrorPlatform="error.platform",t.ErrorCustom="xstate.error",t.Pure="xstate.pure",t.Choose="xstate.choose",t}({});function r(t){return"function"==typeof t}function o(t,e){const s=`${i.DoneInvoke}.${t}`,r={type:s,output:e,toString:()=>s};return r}function n(t,e){const s=`${i.ErrorPlatform}.${t}`,r={type:s,data:e,toString:()=>s};return r}function a(){const t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:window;if(t.__xstate__)return t.__xstate__}const u=t=>{const e=a();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 d={deferEvents:!0,clock:{setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t)},logger:console.log.bind(console),devTools:!1};class h{constructor(t,e){this.behavior=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={...d,...e},{clock:r,logger:o,parent:n,id:a,systemId:u}=i;this.system=n?.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 r=i.get(t);void 0!==r&&(s.delete(r),i.delete(t))},get:t=>s.get(t),_set:(t,e)=>{const r=s.get(t);if(r&&r!==e)throw new Error(`Actor with system ID '${t}' already exists.`);s.set(t,e),i.set(e,t)}}}(),u&&(this._systemId=u,this.system._set(u,this)),this.sessionId=this.system._bookId(),this.id=a??this.sessionId,this.logger=o,this.clock=r,this._parent=n,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.behavior.restoreState?this.behavior.restoreState(this.options.state,this._actorContext):this.options.state:this.behavior.getInitialState(this._actorContext,this.options?.input)}update(t){this._state=t;const e=this.getSnapshot();let s;for(;s=this._deferred.shift();)s(t);for(const t of this.observers)t.next?.(e);const i=this.behavior.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=()=>{},r="object"==typeof t,o=r?t:null;return{next:((r?t.next:t)||i).bind(o),error:((r?t.error:e)||i).bind(o),complete:((r?t.complete:s)||i).bind(o)}}(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.behavior.start&&this.behavior.start(this._state,this._actorContext),this.update(this._state),this.options.devTools&&this.attachDevTools(),this.mailbox.start()),this}_process(t){try{const e=this.behavior.transition(this._state,t,this._actorContext);this.update(e),t.type===f&&(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:f}),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(t){this.delayedEventsMap[t.params.id]=this.clock.setTimeout((()=>{"to"in t.params&&t.params.to?t.params.to.send(t.params.event):this.send(t.params.event)}),t.params.delay)}cancel(t){this.clock.clearTimeout(this.delayedEventsMap[t]),delete this.delayedEventsMap[t]}attachDevTools(){const{devTools:t}=this.options;if(t){("function"==typeof t?t:u)(this)}}toJSON(){return{id:this.id}}getPersistedState(){return this.behavior.getPersistedState?.(this._state)}[e](){return this}getSnapshot(){return this.behavior.getSnapshot?this.behavior.getSnapshot(this._state):this._state}}function p(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 l="xstate.init",f="xstate.stop";function v(t){return t===l||t===f}const _=p((t=>{}),void 0);t.createEmptyActor=function(){return new h(_,t);var t},t.fromCallback=function(t){return{config:t,start:(t,{self:e})=>{e.send({type:l})},transition:(e,s,{self:i,id:a})=>{if(s.type===l){const s=t=>{e.canceled||i._parent?.send(t)},c=t=>{e.receivers.add(t)};return e.dispose=t(s,c,{input:e.input}),((u=e.dispose)instanceof Promise||null!==u&&(r(u)||"object"==typeof u)&&r(u.then))&&e.dispose.then((t=>{i._parent?.send(o(a,t)),e.canceled=!0}),(t=>{e.canceled=!0,i._parent?.send(n(a,t))})),e}var u;return s.type===f?(e.canceled=!0,r(e.dispose)&&e.dispose(),e):(v(s.type)||v(s.type)||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 f: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:r})=>{"done"!==i.status&&(i.subscription=t({input:i.input}).subscribe({next:t=>{r._parent?.send(t)},error:t=>{r.send({type:e,data:t})},complete:()=>{r.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,r,{self:o,id:n,defer:a})=>{if("active"!==t.status)return t;switch(r.type){case e:return a((()=>{o._parent?.send({type:`xstate.snapshot.${n}`,data:r.data})})),{...t,data:r.data};case s:return{...t,status:"error",input:void 0,data:r.data,subscription:void 0};case i:return{...t,status:"done",input:void 0,subscription:void 0};case f: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:(r,{self:o})=>{"done"!==r.status&&(r.subscription=t({input:r.input}).subscribe({next:t=>{o.send({type:e,data:t})},error:t=>{o.send({type:s,data:t})},complete:()=>{o.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){const e="$$xstate.resolve",s="$$xstate.reject";return{config:t,transition:(t,i)=>{if("active"!==t.status)return t;switch(i.type){case e:return{...t,status:"done",data:i.data,input:void 0};case s:return{...t,status:"error",data:i.data,input:void 0};case f:return{...t,status:"canceled",input:void 0};default:return t}},start:(i,{self:r})=>{if("active"!==i.status)return;Promise.resolve(t({input:i.input})).then((t=>{"active"===r._state.status&&r.send({type:e,data:t})}),(t=>{"active"===r._state.status&&r.send({type:s,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=p,t.isActorRef=function(t){return!!t&&"object"==typeof t&&"function"==typeof t.send},t.isSignal=v,t.startSignal={type:"xstate.init"},t.startSignalType=l,t.stopSignal={type:"xstate.stop"},t.stopSignalType=f,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