New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@xstate/inspect

Package Overview
Dependencies
Maintainers
1
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.0.1 to 0.0.2

53

es/index.js

@@ -25,4 +25,3 @@ var __assign = (this && this.__assign) || function () {

var defaultInspectorOptions = {
// url: 'https://statecharts.io/embed'
url: 'http://localhost:3001',
url: 'https://embed.statecharts.io',
iframe: function () { return document.querySelector('iframe[data-xstate]'); }

@@ -33,2 +32,12 @@ };

var resolvedIframe = typeof iframe === 'function' ? iframe() : iframe;
var deferredEvents = [];
var targetWindow;
var postMessage = function (event) {
if (!targetWindow) {
deferredEvents.push(event);
}
else {
targetWindow.postMessage(event, '*');
}
};
if (!resolvedIframe) {

@@ -38,22 +47,32 @@ 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.');

}
resolvedIframe.addEventListener('load', function () {
window.__xstate__.onRegister(function (service) {
var _a;
(_a = resolvedIframe.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage({
type: 'service.register',
machine: JSON.stringify(service.machine),
state: JSON.stringify(service.state || service.initialState),
window.__xstate__.onRegister(function (service) {
postMessage({
type: 'service.register',
machine: JSON.stringify(service.machine),
state: JSON.stringify(service.state || service.initialState),
id: service.id
});
service.subscribe(function (state) {
postMessage({
type: 'service.state',
state: JSON.stringify(state),
id: service.id
}, '*');
service.subscribe(function (state) {
var _a;
(_a = resolvedIframe.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage({
type: 'service.state',
state: JSON.stringify(state),
id: service.id
}, '*');
});
});
});
resolvedIframe.addEventListener('load', function () {
targetWindow = resolvedIframe.contentWindow;
var handler = function (event) {
if (typeof event.data === 'object' &&
event.data !== null &&
'type' in event.data &&
event.data.type === 'xstate.inspecting') {
while (deferredEvents.length > 0) {
targetWindow.postMessage(deferredEvents.shift(), url);
}
}
};
window.addEventListener('message', handler);
});
resolvedIframe.setAttribute('src', url);
}

@@ -27,4 +27,3 @@ "use strict";

var defaultInspectorOptions = {
// url: 'https://statecharts.io/embed'
url: 'http://localhost:3001',
url: 'https://embed.statecharts.io',
iframe: function () { return document.querySelector('iframe[data-xstate]'); }

@@ -35,2 +34,12 @@ };

var resolvedIframe = typeof iframe === 'function' ? iframe() : iframe;
var deferredEvents = [];
var targetWindow;
var postMessage = function (event) {
if (!targetWindow) {
deferredEvents.push(event);
}
else {
targetWindow.postMessage(event, '*');
}
};
if (!resolvedIframe) {

@@ -40,23 +49,33 @@ 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.');

}
resolvedIframe.addEventListener('load', function () {
window.__xstate__.onRegister(function (service) {
var _a;
(_a = resolvedIframe.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage({
type: 'service.register',
machine: JSON.stringify(service.machine),
state: JSON.stringify(service.state || service.initialState),
window.__xstate__.onRegister(function (service) {
postMessage({
type: 'service.register',
machine: JSON.stringify(service.machine),
state: JSON.stringify(service.state || service.initialState),
id: service.id
});
service.subscribe(function (state) {
postMessage({
type: 'service.state',
state: JSON.stringify(state),
id: service.id
}, '*');
service.subscribe(function (state) {
var _a;
(_a = resolvedIframe.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage({
type: 'service.state',
state: JSON.stringify(state),
id: service.id
}, '*');
});
});
});
resolvedIframe.addEventListener('load', function () {
targetWindow = resolvedIframe.contentWindow;
var handler = function (event) {
if (typeof event.data === 'object' &&
event.data !== null &&
'type' in event.data &&
event.data.type === 'xstate.inspecting') {
while (deferredEvents.length > 0) {
targetWindow.postMessage(deferredEvents.shift(), url);
}
}
};
window.addEventListener('message', handler);
});
resolvedIframe.setAttribute('src', url);
}
exports.inspect = inspect;
{
"name": "@xstate/inspect",
"version": "0.0.01",
"private": false,
"version": "0.0.2",
"description": "XState inspection utilities",

@@ -6,0 +5,0 @@ "keywords": [

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