@xstate/inspect
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -13,2 +13,3 @@ var __assign = (this && this.__assign) || function () { | ||
import { createMachine, assign, interpret } from 'xstate'; | ||
import { toSCXMLEvent, toEventObject } from 'xstate/lib/utils'; | ||
var serviceMap = new Map(); | ||
@@ -140,2 +141,19 @@ export function createDevTools() { | ||
}); | ||
inspectService.send({ | ||
type: 'service.event', | ||
event: JSON.stringify((service.state || service.initialState)._event), | ||
id: service.id | ||
}); | ||
// 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) { | ||
inspectService.send({ | ||
type: 'service.event', | ||
event: JSON.stringify(toSCXMLEvent(toEventObject(event))), | ||
id: service.id | ||
}); | ||
return originalSend(event); | ||
}; | ||
service.subscribe(function (state) { | ||
@@ -142,0 +160,0 @@ inspectService.send({ |
@@ -16,2 +16,3 @@ "use strict"; | ||
var xstate_1 = require("xstate"); | ||
var utils_1 = require("xstate/lib/utils"); | ||
var serviceMap = new Map(); | ||
@@ -144,2 +145,19 @@ function createDevTools() { | ||
}); | ||
inspectService.send({ | ||
type: 'service.event', | ||
event: JSON.stringify((service.state || service.initialState)._event), | ||
id: service.id | ||
}); | ||
// 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) { | ||
inspectService.send({ | ||
type: 'service.event', | ||
event: JSON.stringify(utils_1.toSCXMLEvent(utils_1.toEventObject(event))), | ||
id: service.id | ||
}); | ||
return originalSend(event); | ||
}; | ||
service.subscribe(function (state) { | ||
@@ -146,0 +164,0 @@ inspectService.send({ |
{ | ||
"name": "@xstate/inspect", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "XState inspection utilities", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
24839
671
0