@statelyai/inspect
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -60,3 +60,3 @@ "use strict"; | ||
name: "@statelyai/inspect", | ||
version: "0.1.0", | ||
version: "0.2.0", | ||
description: "Inspection utilities for state, actors, workflows, and state machines.", | ||
@@ -77,2 +77,5 @@ main: "dist/index.js", | ||
prepublishOnly: "tsup src/index.ts --dts" | ||
}, | ||
publishConfig: { | ||
access: "public" | ||
} | ||
@@ -337,2 +340,16 @@ }; | ||
var import_fast_safe_stringify2 = __toESM(require("fast-safe-stringify")); | ||
// src/useless.ts | ||
var UselessAdapter = class { | ||
constructor() { | ||
} | ||
start() { | ||
} | ||
stop() { | ||
} | ||
send(_event) { | ||
} | ||
}; | ||
// src/browser.ts | ||
var CONNECTION_EVENT = "@statelyai.connected"; | ||
@@ -346,2 +363,7 @@ function isEventObject(event) { | ||
function createBrowserInspector(options) { | ||
const resolvedWindow = options?.window ?? (typeof window === "undefined" ? void 0 : window); | ||
if (!resolvedWindow) { | ||
console.error("Window does not exist; inspector cannot be started."); | ||
return new UselessAdapter(); | ||
} | ||
const resolvedOptions = { | ||
@@ -354,3 +376,3 @@ url: "https://stately.ai/inspect", | ||
...options, | ||
window: options?.window ?? window | ||
window: resolvedWindow | ||
}; | ||
@@ -357,0 +379,0 @@ const adapter = new BrowserAdapter(resolvedOptions); |
@@ -11,3 +11,3 @@ { | ||
"name": "@statelyai/inspect", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Inspection utilities for state, actors, workflows, and state machines.", | ||
@@ -28,3 +28,6 @@ "main": "dist/index.js", | ||
"prepublishOnly": "tsup src/index.ts --dts" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
@@ -68,1 +68,14 @@ import { expect, test } from 'vitest'; | ||
}); | ||
test('inspector works with window undefined', async () => { | ||
const inspector = createBrowserInspector({ | ||
window: undefined, | ||
}); | ||
const machine = createMachine({}); | ||
const actor = createActor(machine, { inspect: inspector.inspect }); | ||
expect(() => { | ||
actor.start(); | ||
}).not.toThrow(); | ||
}); |
@@ -5,2 +5,3 @@ import { AnyEventObject, Observer, Subscribable, toObserver } from 'xstate'; | ||
import safeStringify from 'fast-safe-stringify'; | ||
import { UselessAdapter } from './useless'; | ||
@@ -43,2 +44,11 @@ interface BrowserReceiver extends Subscribable<StatelyInspectionEvent> {} | ||
): Inspector<BrowserAdapter> { | ||
const resolvedWindow = | ||
options?.window ?? (typeof window === 'undefined' ? undefined : window); | ||
if (!resolvedWindow) { | ||
console.error('Window does not exist; inspector cannot be started.'); | ||
return new UselessAdapter() as any; | ||
} | ||
const resolvedOptions = { | ||
@@ -51,3 +61,3 @@ url: 'https://stately.ai/inspect', | ||
...options, | ||
window: options?.window ?? window, | ||
window: resolvedWindow, | ||
} satisfies Required<BrowserInspectorOptions>; | ||
@@ -54,0 +64,0 @@ const adapter = new BrowserAdapter(resolvedOptions); |
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
61021
21
1589