Huge News!Announcing our $40M Series B led by Abstract Ventures.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.4 to 0.0.5

6

es/index.d.ts

@@ -6,3 +6,3 @@ import { Interpreter } from 'xstate';

url: string;
iframe: MaybeLazy<HTMLIFrameElement | null>;
iframe: MaybeLazy<HTMLIFrameElement | null | false>;
}

@@ -13,3 +13,5 @@ declare global {

register: (service: Interpreter<any>) => void;
onRegister: (listener: ServiceListener) => void;
onRegister: (listener: ServiceListener) => {
unsubscribe: () => void;
};
services: Set<Interpreter<any>>;

@@ -16,0 +18,0 @@ };

@@ -23,2 +23,7 @@ var __assign = (this && this.__assign) || function () {

services.forEach(function (service) { return listener(service); });
return {
unsubscribe: function () {
serviceListeners.delete(listener);
}
};
}

@@ -35,4 +40,5 @@ };

var targetWindow;
var isDeferred = true;
var postMessage = function (event) {
if (!targetWindow) {
if (isDeferred) {
deferredEvents.push(event);

@@ -44,6 +50,23 @@ }

};
if (!resolvedIframe) {
if (resolvedIframe === null) {
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.');
return;
}
window.addEventListener('message', function (event) {
if (typeof event.data === 'object' &&
event.data !== null &&
'type' in event.data &&
event.data.type === 'xstate.inspecting') {
isDeferred = false;
// TODO: use a state machine...
setTimeout(function () {
while (deferredEvents.length > 0) {
targetWindow.postMessage(deferredEvents.shift(), url);
}
}, 1000);
}
});
if (resolvedIframe === false) {
targetWindow = window.open(url, 'xstateinspector');
}
window.__xstate__.onRegister(function (service) {

@@ -64,19 +87,8 @@ postMessage({

});
window.addEventListener('message', function (event) {
if (typeof event.data === 'object' &&
event.data !== null &&
'type' in event.data &&
event.data.type === 'xstate.inspecting') {
// TODO: use a state machine...
setTimeout(function () {
while (deferredEvents.length > 0) {
targetWindow.postMessage(deferredEvents.shift(), url);
}
}, 1000);
}
});
resolvedIframe.addEventListener('load', function () {
targetWindow = resolvedIframe.contentWindow;
});
resolvedIframe.setAttribute('src', url);
if (resolvedIframe) {
resolvedIframe.addEventListener('load', function () {
targetWindow = resolvedIframe.contentWindow;
});
resolvedIframe.setAttribute('src', url);
}
}

@@ -6,3 +6,3 @@ import { Interpreter } from 'xstate';

url: string;
iframe: MaybeLazy<HTMLIFrameElement | null>;
iframe: MaybeLazy<HTMLIFrameElement | null | false>;
}

@@ -13,3 +13,5 @@ declare global {

register: (service: Interpreter<any>) => void;
onRegister: (listener: ServiceListener) => void;
onRegister: (listener: ServiceListener) => {
unsubscribe: () => void;
};
services: Set<Interpreter<any>>;

@@ -16,0 +18,0 @@ };

@@ -25,2 +25,7 @@ "use strict";

services.forEach(function (service) { return listener(service); });
return {
unsubscribe: function () {
serviceListeners.delete(listener);
}
};
}

@@ -37,4 +42,5 @@ };

var targetWindow;
var isDeferred = true;
var postMessage = function (event) {
if (!targetWindow) {
if (isDeferred) {
deferredEvents.push(event);

@@ -46,6 +52,23 @@ }

};
if (!resolvedIframe) {
if (resolvedIframe === null) {
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.');
return;
}
window.addEventListener('message', function (event) {
if (typeof event.data === 'object' &&
event.data !== null &&
'type' in event.data &&
event.data.type === 'xstate.inspecting') {
isDeferred = false;
// TODO: use a state machine...
setTimeout(function () {
while (deferredEvents.length > 0) {
targetWindow.postMessage(deferredEvents.shift(), url);
}
}, 1000);
}
});
if (resolvedIframe === false) {
targetWindow = window.open(url, 'xstateinspector');
}
window.__xstate__.onRegister(function (service) {

@@ -66,20 +89,9 @@ postMessage({

});
window.addEventListener('message', function (event) {
if (typeof event.data === 'object' &&
event.data !== null &&
'type' in event.data &&
event.data.type === 'xstate.inspecting') {
// TODO: use a state machine...
setTimeout(function () {
while (deferredEvents.length > 0) {
targetWindow.postMessage(deferredEvents.shift(), url);
}
}, 1000);
}
});
resolvedIframe.addEventListener('load', function () {
targetWindow = resolvedIframe.contentWindow;
});
resolvedIframe.setAttribute('src', url);
if (resolvedIframe) {
resolvedIframe.addEventListener('load', function () {
targetWindow = resolvedIframe.contentWindow;
});
resolvedIframe.setAttribute('src', url);
}
}
exports.inspect = inspect;
{
"name": "@xstate/inspect",
"version": "0.0.4",
"version": "0.0.5",
"description": "XState inspection utilities",

@@ -5,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