Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@xstate/inspect

Package Overview
Dependencies
Maintainers
3
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xstate/inspect - npm Package Compare versions

Comparing version 0.6.4 to 0.6.5

10

CHANGELOG.md
# @xstate/inspect
## 0.6.5
### Patch Changes
- [#3198](https://github.com/statelyai/xstate/pull/3198) [`09e2130df`](https://github.com/statelyai/xstate/commit/09e2130dff80815c10df38496a761fe8ae0d9f6e) Thanks [@Andarist](https://github.com/Andarist)! - Fixed an issue that prevented some states from being sent correctly to the inspector when serializable values hold references to objects throwing on `toJSON` property access (like `obj.toJSON`). This property is accessed by the native algorithm before the value gets passed to the custom `serializer`. Because of a bug we couldn't correctly serialize such values even when a custom `serializer` was implemented that was meant to replace it in a custom way from within its parent's level.
* [#3199](https://github.com/statelyai/xstate/pull/3199) [`f3d63147d`](https://github.com/statelyai/xstate/commit/f3d63147d36791344d55fa9c945af32daeefa2fa) Thanks [@Andarist](https://github.com/Andarist)! - Fixed an issue that caused sending the same event multiple times to the inspector for restarted services.
- [#3076](https://github.com/statelyai/xstate/pull/3076) [`34f3d9be7`](https://github.com/statelyai/xstate/commit/34f3d9be74d2bd9db51b2db06c5a65d980aec9c4) Thanks [@SimeonC](https://github.com/SimeonC)! - Fixed an issue with "maximum call stack size exceeded" errors being thrown when registering a machine with a very deep object in its context despite using a serializer capable of replacing such an object.
## 0.6.4

@@ -4,0 +14,0 @@

4

dist/xstate-inspect.umd.min.js

@@ -1,2 +0,2 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("xstate")):"function"==typeof define&&define.amd?define(["exports","xstate"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).XStateInspect={},e.XState)}(this,(function(e,n){"use strict";
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("xstate")):"function"==typeof define&&define.amd?define(["exports","xstate"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).XStateInspect={},e.XState)}(this,(function(e,t){"use strict";
/*! *****************************************************************************

@@ -15,2 +15,2 @@ Copyright (c) Microsoft Corporation.

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var t=function(){return(t=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e}).apply(this,arguments)};var r=s;s.default=s,s.stable=a,s.stableStringify=a;var i=[],o=[];function s(e,n,t){var r;for(!function e(n,t,r,s){var c;if("object"==typeof n&&null!==n){for(c=0;c<r.length;c++)if(r[c]===n){var a=Object.getOwnPropertyDescriptor(s,t);return void(void 0!==a.get?a.configurable?(Object.defineProperty(s,t,{value:"[Circular]"}),i.push([s,t,n,a])):o.push([n,t]):(s[t]="[Circular]",i.push([s,t,n])))}if(r.push(n),Array.isArray(n))for(c=0;c<n.length;c++)e(n[c],c,r,n);else{var u=Object.keys(n);for(c=0;c<u.length;c++){var f=u[c];e(n[f],f,r,n)}}r.pop()}}(e,"",[],void 0),r=0===o.length?JSON.stringify(e,n,t):JSON.stringify(e,u(n),t);0!==i.length;){var s=i.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}return r}function c(e,n){return e<n?-1:e>n?1:0}function a(e,n,t){var r,s=function e(n,t,r,s){var a;if("object"==typeof n&&null!==n){for(a=0;a<r.length;a++)if(r[a]===n){var u=Object.getOwnPropertyDescriptor(s,t);return void(void 0!==u.get?u.configurable?(Object.defineProperty(s,t,{value:"[Circular]"}),i.push([s,t,n,u])):o.push([n,t]):(s[t]="[Circular]",i.push([s,t,n])))}if("function"==typeof n.toJSON)return;if(r.push(n),Array.isArray(n))for(a=0;a<n.length;a++)e(n[a],a,r,n);else{var f={},d=Object.keys(n).sort(c);for(a=0;a<d.length;a++){var l=d[a];e(n[l],l,r,n),f[l]=n[l]}if(void 0===s)return f;i.push([s,t,n]),s[t]=f}r.pop()}}(e,"",[],void 0)||e;for(r=0===o.length?JSON.stringify(s,n,t):JSON.stringify(s,u(n),t);0!==i.length;){var a=i.pop();4===a.length?Object.defineProperty(a[0],a[1],a[3]):a[0][a[1]]=a[2]}return r}function u(e){return e=void 0!==e?e:function(e,n){return n},function(n,t){if(o.length>0)for(var r=0;r<o.length;r++){var i=o[r];if(i[1]===n&&i[0]===t){t="[Circular]",o.splice(r,1);break}}return e.call(this,n,t)}}function f(e){return"function"==typeof e?e():e}function d(e,n){try{return JSON.stringify(e,n)}catch(t){return r(e,n)}}function l(e){if(!e)return!1;try{if("object"==typeof e&&"type"in e&&e.type.startsWith("service."))return!0}catch(e){return!1}return!1}function v(e){var t=n.State.create(JSON.parse(e));return delete t.history,t}function p(e){switch(e.type){case"service.event":return t(t({},e),{event:JSON.parse(e.event)});case"service.register":return t(t({},e),{machine:n.createMachine(JSON.parse(e.machine)),state:v(e.state)});case"service.state":return t(t({},e),{state:v(e.state)});default:return e}}function g(e,n,r){var i,o,s={};try{for(var c=function(e){var n="function"==typeof Symbol&&Symbol.iterator,t=n&&e[n],r=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}(n),a=c.next();!a.done;a=c.next()){var u=a.value;s[u]=e[u]}}catch(e){i={error:e}}finally{try{a&&!a.done&&(o=c.return)&&o.call(c)}finally{if(i)throw i.error}}var f=JSON.parse(d(s,r));return d(t(t({},e),f))}function b(e,n){return g(e,["context","event","_event"],n)}function y(e,n){return g(e,["context"],n)}var h=new Map;function w(){var e=new Set,n=new Set;return{services:e,register:function(t){e.add(t),h.set(t.sessionId,t),n.forEach((function(e){return e(t)})),t.onStop((function(){e.delete(t),h.delete(t.sessionId)}))},unregister:function(n){e.delete(n),h.delete(n.sessionId)},onRegister:function(t){return n.add(t),e.forEach((function(e){return t(e)})),{unsubscribe:function(){n.delete(t)}}}}}var S={url:"https://statecharts.io/inspect",iframe:function(){return document.querySelector("iframe[data-xstate]")},devTools:function(){var e=w();return globalThis.__xstate__=e,e},serialize:void 0};e.createDevTools=w,e.createWebSocketReceiver=function(e){var t,r=e.protocol,i=new WebSocket("".concat(void 0===r?"ws":r,"://").concat(e.server)),o=new Set,s=n.toActorRef({id:"xstate.webSocketReceiver",send:function(n){i.send(d(n,e.serialize))},subscribe:function(e,t,r){var i=n.toObserver(e,t,r);return o.add(i),{unsubscribe:function(){o.delete(i)}}},getSnapshot:function(){return t}});return i.onopen=function(){s.send({type:"xstate.inspecting"})},i.onmessage=function(e){if("string"==typeof e.data)try{var n=JSON.parse(e.data);l(n)&&(t=p(n),o.forEach((function(e){e.next(t)})))}catch(e){console.error(e)}},i.onerror=function(e){o.forEach((function(n){var t;null===(t=n.error)||void 0===t||t.call(n,e)}))},s},e.createWindowReceiver=function(e){var t,r=e||{},i=r.window,o=void 0===i?window:i,s=r.targetWindow,c=void 0===s?window.self===window.top?window.opener:window.parent:s,a=new Set,u=function(e){var n=e.data;l(n)&&(t=p(n),a.forEach((function(e){return e.next(t)})))};o.addEventListener("message",u);var f=n.toActorRef({id:"xstate.windowReceiver",send:function(e){c&&c.postMessage(e,"*")},subscribe:function(e,t,r){var i=n.toObserver(e,t,r);return a.add(i),{unsubscribe:function(){a.delete(i)}}},stop:function(){a.clear(),o.removeEventListener("message",u)},getSnapshot:function(){return t}});return f.send({type:"xstate.inspecting"}),f},e.inspect=function(e){var r=function(e){var n=t(t({},S),e);return t(t({},n),{url:new URL(n.url),iframe:f(n.iframe),devTools:f(n.devTools)})}(e),i=r.iframe,o=r.url,s=r.devTools;if(null!==i){var c,a,u=function(e,t){void 0===e&&(e=globalThis.__xstate__);var r=new Map,i=e.onRegister((function(e){r.set(e.sessionId,e)}));return n.createMachine({initial:"pendingConnection",context:{client:void 0},states:{pendingConnection:{},connected:{on:{"service.state":{actions:function(e,n){return e.client.send(n)}},"service.event":{actions:function(e,n){return e.client.send(n)}},"service.register":{actions:function(e,n){return e.client.send(n)}},"service.stop":{actions:function(e,n){return e.client.send(n)}},"xstate.event":{actions:function(e,n){var t=n.event,i=JSON.parse(t),o=r.get(i.origin);null==o||o.send(i)}},unload:{actions:function(e){e.client.send({type:"xstate.disconnect"})}},disconnect:"disconnected"}},disconnected:{entry:function(){i.unsubscribe()},type:"final"}},on:{"xstate.inspecting":{target:".connected",actions:[n.assign({client:function(e,n){return n.client}}),function(n){e.services.forEach((function(e){var r;null===(r=n.client)||void 0===r||r.send({type:"service.register",machine:y(e.machine,null==t?void 0:t.serialize),state:b(e.state||e.initialState,null==t?void 0:t.serialize),sessionId:e.sessionId})}))}]}}})}(s,e),l=n.interpret(u).start(),v=new Set,p=l.subscribe((function(e){v.forEach((function(n){return n.next(e)}))})),g=function(e){if("object"==typeof e.data&&null!==e.data&&"type"in e.data){i&&!c&&(c=i.contentWindow),a||(a={send:function(e){c.postMessage(e,o.origin)}});var n=t(t({},e.data),{client:a});l.send(n)}};window.addEventListener("message",g),window.addEventListener("unload",(function(){l.send({type:"unload"})}));var h=function(n){return d(n,null==e?void 0:e.serialize)};return s.onRegister((function(t){var r,i=t.state||t.initialState;l.send({type:"service.register",machine:y(t.machine,null==e?void 0:e.serialize),state:b(i,null==e?void 0:e.serialize),sessionId:t.sessionId,id:t.id,parent:null===(r=t.parent)||void 0===r?void 0:r.sessionId}),l.send({type:"service.event",event:h(i._event),sessionId:t.sessionId});var o=t.send.bind(t);t.send=function(e,r){return l.send({type:"service.event",event:h(n.toSCXMLEvent(n.toEventObject(e,r))),sessionId:t.sessionId}),o(e,r)},t.subscribe((function(n){void 0!==n&&l.send({type:"service.state",state:b(n,null==e?void 0:e.serialize),sessionId:t.sessionId})})),t.onStop((function(){l.send({type:"service.stop",sessionId:t.sessionId})}))})),i?(i.addEventListener("load",(function(){c=i.contentWindow})),i.setAttribute("src",String(o))):c=window.open(String(o),"xstateinspector"),{send:function(e){l.send(e)},subscribe:function(e,t,r){var i=n.toObserver(e,t,r);return v.add(i),i.next(l.state),{unsubscribe:function(){v.delete(i)}}},disconnect:function(){l.send("disconnect"),window.removeEventListener("message",g),p.unsubscribe()}}}console.warn("No suitable <iframe> found to embed the inspector. Please pass an <iframe> element to `inspect(iframe)` or create an <iframe data-xstate></iframe> element.")},Object.defineProperty(e,"__esModule",{value:!0})}));
***************************************************************************** */var n=function(){return(n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};var r=c;c.default=c,c.stable=f,c.stableStringify=f;var i=[],o=[];function s(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function c(e,t,n,r){var c;void 0===r&&(r=s()),function e(t,n,r,i,o,s,c){var u;if(s+=1,"object"==typeof t&&null!==t){for(u=0;u<i.length;u++)if(i[u]===t)return void a("[Circular]",t,n,o);if(void 0!==c.depthLimit&&s>c.depthLimit)return void a("[...]",t,n,o);if(void 0!==c.edgesLimit&&r+1>c.edgesLimit)return void a("[...]",t,n,o);if(i.push(t),Array.isArray(t))for(u=0;u<t.length;u++)e(t[u],u,u,i,t,s,c);else{var f=Object.keys(t);for(u=0;u<f.length;u++){var d=f[u];e(t[d],d,u,i,t,s,c)}}i.pop()}}(e,"",0,[],void 0,0,r);try{c=0===o.length?JSON.stringify(e,t,n):JSON.stringify(e,d(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==i.length;){var u=i.pop();4===u.length?Object.defineProperty(u[0],u[1],u[3]):u[0][u[1]]=u[2]}}return c}function a(e,t,n,r){var s=Object.getOwnPropertyDescriptor(r,n);void 0!==s.get?s.configurable?(Object.defineProperty(r,n,{value:e}),i.push([r,n,t,s])):o.push([t,n,e]):(r[n]=e,i.push([r,n,t]))}function u(e,t){return e<t?-1:e>t?1:0}function f(e,t,n,r){void 0===r&&(r=s());var c,f=function e(t,n,r,o,s,c,f){var d;if(c+=1,"object"==typeof t&&null!==t){for(d=0;d<o.length;d++)if(o[d]===t)return void a("[Circular]",t,n,s);try{if("function"==typeof t.toJSON)return}catch(e){return}if(void 0!==f.depthLimit&&c>f.depthLimit)return void a("[...]",t,n,s);if(void 0!==f.edgesLimit&&r+1>f.edgesLimit)return void a("[...]",t,n,s);if(o.push(t),Array.isArray(t))for(d=0;d<t.length;d++)e(t[d],d,d,o,t,c,f);else{var l={},v=Object.keys(t).sort(u);for(d=0;d<v.length;d++){var p=v[d];e(t[p],p,d,o,t,c,f),l[p]=t[p]}if(void 0===s)return l;i.push([s,n,t]),s[n]=l}o.pop()}}(e,"",0,[],void 0,0,r)||e;try{c=0===o.length?JSON.stringify(f,t,n):JSON.stringify(f,d(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==i.length;){var l=i.pop();4===l.length?Object.defineProperty(l[0],l[1],l[3]):l[0][l[1]]=l[2]}}return c}function d(e){return e=void 0!==e?e:function(e,t){return t},function(t,n){if(o.length>0)for(var r=0;r<o.length;r++){var i=o[r];if(i[1]===t&&i[0]===n){n=i[2],o.splice(r,1);break}}return e.call(this,t,n)}}function l(e){return"function"==typeof e?e():e}function v(e,t){try{return JSON.stringify(e,t)}catch(n){return r(e,t)}}function p(e){if(!e)return!1;try{if("object"==typeof e&&"type"in e&&e.type.startsWith("service."))return!0}catch(e){return!1}return!1}function y(e){var n=t.State.create(JSON.parse(e));return delete n.history,n}function g(e){switch(e.type){case"service.event":return n(n({},e),{event:JSON.parse(e.event)});case"service.register":return n(n({},e),{machine:t.createMachine(JSON.parse(e.machine)),state:y(e.state)});case"service.state":return n(n({},e),{state:y(e.state)});default:return e}}function h(e,t,r){var i,o,s={};try{for(var c=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(t),a=c.next();!a.done;a=c.next()){var u=a.value;s[u]=e[u]}}catch(e){i={error:e}}finally{try{a&&!a.done&&(o=c.return)&&o.call(c)}finally{if(i)throw i.error}}var f=JSON.parse(v(s,r));return v(n(n({},e),f))}function b(e,t){return e.machine,e.configuration,e.history,h(function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}(e,["machine","configuration","history"]),["context","event","_event"],t)}function m(e,t){return h(e.definition,["context"],t)}var w=new Map;function S(){var e=new Set,t=new Set;return{services:e,register:function(n){e.add(n),w.set(n.sessionId,n),t.forEach((function(e){return e(n)})),n.onStop((function(){e.delete(n),w.delete(n.sessionId)}))},unregister:function(t){e.delete(t),w.delete(t.sessionId)},onRegister:function(n){return t.add(n),e.forEach((function(e){return n(e)})),{unsubscribe:function(){t.delete(n)}}}}}var O={url:"https://statecharts.io/inspect",iframe:function(){return document.querySelector("iframe[data-xstate]")},devTools:function(){var e=S();return globalThis.__xstate__=e,e},serialize:void 0},x=new Set;e.createDevTools=S,e.createWebSocketReceiver=function(e){var n,r=e.protocol,i=new WebSocket("".concat(void 0===r?"ws":r,"://").concat(e.server)),o=new Set,s=t.toActorRef({id:"xstate.webSocketReceiver",send:function(t){i.send(v(t,e.serialize))},subscribe:function(e,n,r){var i=t.toObserver(e,n,r);return o.add(i),{unsubscribe:function(){o.delete(i)}}},getSnapshot:function(){return n}});return i.onopen=function(){s.send({type:"xstate.inspecting"})},i.onmessage=function(e){if("string"==typeof e.data)try{var t=JSON.parse(e.data);p(t)&&(n=g(t),o.forEach((function(e){e.next(n)})))}catch(e){console.error(e)}},i.onerror=function(e){o.forEach((function(t){var n;null===(n=t.error)||void 0===n||n.call(t,e)}))},s},e.createWindowReceiver=function(e){var n,r=e||{},i=r.window,o=void 0===i?window:i,s=r.targetWindow,c=void 0===s?window.self===window.top?window.opener:window.parent:s,a=new Set,u=function(e){var t=e.data;p(t)&&(n=g(t),a.forEach((function(e){return e.next(n)})))};o.addEventListener("message",u);var f=t.toActorRef({id:"xstate.windowReceiver",send:function(e){c&&c.postMessage(e,"*")},subscribe:function(e,n,r){var i=t.toObserver(e,n,r);return a.add(i),{unsubscribe:function(){a.delete(i)}}},stop:function(){a.clear(),o.removeEventListener("message",u)},getSnapshot:function(){return n}});return f.send({type:"xstate.inspecting"}),f},e.inspect=function(e){var r=function(e){var t=n(n({},O),e);return n(n({},t),{url:new URL(t.url),iframe:l(t.iframe),devTools:l(t.devTools)})}(e),i=r.iframe,o=r.url,s=r.devTools;if(null!==i){var c,a,u=function(e,n){void 0===e&&(e=globalThis.__xstate__);var r=new Map,i=e.onRegister((function(e){r.set(e.sessionId,e)}));return t.createMachine({initial:"pendingConnection",context:{client:void 0},states:{pendingConnection:{},connected:{on:{"service.state":{actions:function(e,t){return e.client.send(t)}},"service.event":{actions:function(e,t){return e.client.send(t)}},"service.register":{actions:function(e,t){return e.client.send(t)}},"service.stop":{actions:function(e,t){return e.client.send(t)}},"xstate.event":{actions:function(e,t){var n=t.event,i=JSON.parse(n),o=r.get(i.origin);null==o||o.send(i)}},unload:{actions:function(e){e.client.send({type:"xstate.disconnect"})}},disconnect:"disconnected"}},disconnected:{entry:function(){i.unsubscribe()},type:"final"}},on:{"xstate.inspecting":{target:".connected",actions:[t.assign({client:function(e,t){return t.client}}),function(t){e.services.forEach((function(e){var r;null===(r=t.client)||void 0===r||r.send({type:"service.register",machine:m(e.machine,null==n?void 0:n.serialize),state:b(e.state||e.initialState,null==n?void 0:n.serialize),sessionId:e.sessionId})}))}]}}})}(s,e),f=t.interpret(u).start(),d=new Set,p=f.subscribe((function(e){d.forEach((function(t){return t.next(e)}))})),y=function(e){if("object"==typeof e.data&&null!==e.data&&"type"in e.data){i&&!c&&(c=i.contentWindow),a||(a={send:function(e){c.postMessage(e,o.origin)}});var t=n(n({},e.data),{client:a});f.send(t)}};window.addEventListener("message",y),window.addEventListener("unload",(function(){f.send({type:"unload"})}));var g=function(t){return v(t,null==e?void 0:e.serialize)};return s.onRegister((function(n){var r,i=n.state||n.initialState;if(f.send({type:"service.register",machine:m(n.machine,null==e?void 0:e.serialize),state:b(i,null==e?void 0:e.serialize),sessionId:n.sessionId,id:n.id,parent:null===(r=n.parent)||void 0===r?void 0:r.sessionId}),f.send({type:"service.event",event:g(i._event),sessionId:n.sessionId}),!x.has(n)){x.add(n);var o=n.send.bind(n);n.send=function(e,r){return f.send({type:"service.event",event:g(t.toSCXMLEvent(t.toEventObject(e,r))),sessionId:n.sessionId}),o(e,r)}}n.subscribe((function(t){void 0!==t&&f.send({type:"service.state",state:b(t,null==e?void 0:e.serialize),sessionId:n.sessionId})})),n.onStop((function(){f.send({type:"service.stop",sessionId:n.sessionId})}))})),i?(i.addEventListener("load",(function(){c=i.contentWindow})),i.setAttribute("src",String(o))):c=window.open(String(o),"xstateinspector"),{send:function(e){f.send(e)},subscribe:function(e,n,r){var i=t.toObserver(e,n,r);return d.add(i),i.next(f.state),{unsubscribe:function(){d.delete(i)}}},disconnect:function(){f.send("disconnect"),window.removeEventListener("message",y),p.unsubscribe()}}}console.warn("No suitable <iframe> found to embed the inspector. Please pass an <iframe> element to `inspect(iframe)` or create an <iframe data-xstate></iframe> element.")},Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -27,2 +27,14 @@ /*! *****************************************************************************

function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
function __values(o) {

@@ -40,2 +52,2 @@ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;

export { __assign, __values };
export { __assign, __rest, __values };

@@ -53,2 +53,3 @@ import { __assign } from './_virtual/_tslib.js';

};
var patchedInterpreters = new Set();
function inspect(options) {

@@ -109,14 +110,17 @@ var _a = getFinalOptions(options), iframe = _a.iframe, url = _a.url, devTools = _a.devTools;

});
// monkey-patch service.send so that we know when an event was sent
// to a service *before* it is processed, since other events might occur
// while the sent one is being processed, which throws the order off
var originalSend = service.send.bind(service);
service.send = function inspectSend(event, payload) {
inspectService.send({
type: 'service.event',
event: stringifyWithSerializer(toSCXMLEvent(toEventObject(event, payload))),
sessionId: service.sessionId
});
return originalSend(event, payload);
};
if (!patchedInterpreters.has(service)) {
patchedInterpreters.add(service);
// monkey-patch service.send so that we know when an event was sent
// to a service *before* it is processed, since other events might occur
// while the sent one is being processed, which throws the order off
var originalSend_1 = service.send.bind(service);
service.send = function inspectSend(event, payload) {
inspectService.send({
type: 'service.event',
event: stringifyWithSerializer(toSCXMLEvent(toEventObject(event, payload))),
sessionId: service.sessionId
});
return originalSend_1(event, payload);
};
}
service.subscribe(function (state) {

@@ -123,0 +127,0 @@ // filter out synchronous notification from within `.start()` call

@@ -24,23 +24,3 @@ import { ActorRef, XStateDevInterface } from 'xstate';

};
}, import("xstate").BaseActionObject, import("xstate").ServiceMap, import("xstate").TypegenDisabled & {
missingImplementations: {
actions: never;
delays: never;
guards: never;
services: never;
};
} & {
eventsCausingActions: Record<string, string>;
eventsCausingDelays: Record<string, string>;
eventsCausingGuards: Record<string, string>;
eventsCausingServices: Record<string, string>;
} & {
indexedActions: import("xstate").IndexByType<import("xstate").BaseActionObject>;
indexedEvents: Record<string, InspectMachineEvent> & {
__XSTATE_ALLOW_ANY_INVOKE_DATA_HACK__: {
data: any;
};
};
invokeSrcNameMap: Record<string, "__XSTATE_ALLOW_ANY_INVOKE_DATA_HACK__">;
}>;
}, import("xstate").BaseActionObject, import("xstate").ServiceMap, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, InspectMachineEvent, import("xstate").BaseActionObject, import("xstate").ServiceMap>>;
//# sourceMappingURL=inspectMachine.d.ts.map

@@ -1,2 +0,2 @@

import { __assign, __values } from './_virtual/_tslib.js';
import { __assign, __values, __rest } from './_virtual/_tslib.js';
import { stringify } from './utils.js';

@@ -24,8 +24,9 @@

function stringifyState(state, replacer) {
return selectivelyStringify(state, ['context', 'event', '_event'], replacer);
state.machine; state.configuration; state.history; var stateToStringify = __rest(state, ["machine", "configuration", "history"]);
return selectivelyStringify(stateToStringify, ['context', 'event', '_event'], replacer);
}
function stringifyMachine(machine, replacer) {
return selectivelyStringify(machine, ['context'], replacer);
return selectivelyStringify(machine.definition, ['context'], replacer);
}
export { selectivelyStringify, stringifyMachine, stringifyState };

@@ -31,2 +31,14 @@ 'use strict';

function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
function __values(o) {

@@ -44,2 +56,3 @@ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;

exports.__rest = __rest;
exports.__values = __values;

@@ -57,2 +57,3 @@ 'use strict';

};
var patchedInterpreters = new Set();
function inspect(options) {

@@ -113,14 +114,17 @@ var _a = getFinalOptions(options), iframe = _a.iframe, url = _a.url, devTools = _a.devTools;

});
// monkey-patch service.send so that we know when an event was sent
// to a service *before* it is processed, since other events might occur
// while the sent one is being processed, which throws the order off
var originalSend = service.send.bind(service);
service.send = function inspectSend(event, payload) {
inspectService.send({
type: 'service.event',
event: stringifyWithSerializer(xstate.toSCXMLEvent(xstate.toEventObject(event, payload))),
sessionId: service.sessionId
});
return originalSend(event, payload);
};
if (!patchedInterpreters.has(service)) {
patchedInterpreters.add(service);
// monkey-patch service.send so that we know when an event was sent
// to a service *before* it is processed, since other events might occur
// while the sent one is being processed, which throws the order off
var originalSend_1 = service.send.bind(service);
service.send = function inspectSend(event, payload) {
inspectService.send({
type: 'service.event',
event: stringifyWithSerializer(xstate.toSCXMLEvent(xstate.toEventObject(event, payload))),
sessionId: service.sessionId
});
return originalSend_1(event, payload);
};
}
service.subscribe(function (state) {

@@ -127,0 +131,0 @@ // filter out synchronous notification from within `.start()` call

@@ -24,23 +24,3 @@ import { ActorRef, XStateDevInterface } from 'xstate';

};
}, import("xstate").BaseActionObject, import("xstate").ServiceMap, import("xstate").TypegenDisabled & {
missingImplementations: {
actions: never;
delays: never;
guards: never;
services: never;
};
} & {
eventsCausingActions: Record<string, string>;
eventsCausingDelays: Record<string, string>;
eventsCausingGuards: Record<string, string>;
eventsCausingServices: Record<string, string>;
} & {
indexedActions: import("xstate").IndexByType<import("xstate").BaseActionObject>;
indexedEvents: Record<string, InspectMachineEvent> & {
__XSTATE_ALLOW_ANY_INVOKE_DATA_HACK__: {
data: any;
};
};
invokeSrcNameMap: Record<string, "__XSTATE_ALLOW_ANY_INVOKE_DATA_HACK__">;
}>;
}, import("xstate").BaseActionObject, import("xstate").ServiceMap, import("xstate").ResolveTypegenMeta<import("xstate").TypegenDisabled, InspectMachineEvent, import("xstate").BaseActionObject, import("xstate").ServiceMap>>;
//# sourceMappingURL=inspectMachine.d.ts.map

@@ -28,6 +28,7 @@ 'use strict';

function stringifyState(state, replacer) {
return selectivelyStringify(state, ['context', 'event', '_event'], replacer);
state.machine; state.configuration; state.history; var stateToStringify = _tslib.__rest(state, ["machine", "configuration", "history"]);
return selectivelyStringify(stateToStringify, ['context', 'event', '_event'], replacer);
}
function stringifyMachine(machine, replacer) {
return selectivelyStringify(machine, ['context'], replacer);
return selectivelyStringify(machine.definition, ['context'], replacer);
}

@@ -34,0 +35,0 @@

{
"name": "@xstate/inspect",
"version": "0.6.4",
"version": "0.6.5",
"description": "XState inspection utilities",

@@ -56,3 +56,3 @@ "keywords": [

"ws": "^8.0.0",
"xstate": "^4.30.6"
"xstate": "^4.31.0"
},

@@ -65,4 +65,4 @@ "peerDependenciesMeta": {

"dependencies": {
"fast-safe-stringify": "^2.0.7"
"fast-safe-stringify": "^2.1.1"
}
}

@@ -29,2 +29,3 @@ # @xstate/inspect

**Via CDN**
```html

@@ -36,4 +37,2 @@ <script src="https://unpkg.com/@xstate/inspect/dist/xstate-inspect.umd.min.js"></script>

2. Import it at the beginning of your project, before any other code is called:

@@ -40,0 +39,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc