@rxova/journey-devtools-bridge 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -82
- package/dist/bridge.d.ts +1 -2
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/protocol.d.ts +15 -14
- package/package.json +5 -4
- package/dist/bridge.d.ts.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/protocol.d.ts.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -1,33 +1,6 @@
|
|
|
1
1
|
# @rxova/journey-devtools-bridge
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
<a href="https://www.npmjs.com/package/@rxova/journey-devtools-bridge">
|
|
5
|
-
<img src="https://img.shields.io/badge/npm-%40rxova%2Fjourney--devtools--bridge-CB3837?logo=npm&logoColor=white" alt="npm package @rxova/journey-devtools-bridge" />
|
|
6
|
-
</a>
|
|
7
|
-
<a href="https://rxova.org/docs/devtool/bridge-api">
|
|
8
|
-
<img src="https://img.shields.io/badge/docs-devtool%20bridge-0f8f6a" alt="Bridge docs" />
|
|
9
|
-
</a>
|
|
10
|
-
<a href="https://github.com/rxova/journey/actions/workflows/ci.yml">
|
|
11
|
-
<img src="https://github.com/rxova/journey/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI" />
|
|
12
|
-
</a>
|
|
13
|
-
<img src="https://img.shields.io/badge/TypeScript-strict-3178C6?logo=typescript&logoColor=white" alt="TypeScript" />
|
|
14
|
-
<img src="https://img.shields.io/badge/coverage%20(bridge)-95.64%25-yellowgreen" alt="Bridge coverage" />
|
|
15
|
-
<a href="https://www.npmjs.com/package/@rxova/journey-devtools-bridge">
|
|
16
|
-
<img src="https://img.shields.io/npm/v/@rxova/journey-devtools-bridge" alt="npm version" />
|
|
17
|
-
</a>
|
|
18
|
-
<a href="https://www.npmjs.com/package/@rxova/journey-devtools-bridge">
|
|
19
|
-
<img src="https://img.shields.io/npm/dm/@rxova/journey-devtools-bridge" alt="npm downloads" />
|
|
20
|
-
</a>
|
|
21
|
-
<a href="https://bundlephobia.com/package/@rxova/journey-devtools-bridge">
|
|
22
|
-
<img src="https://img.shields.io/bundlephobia/minzip/%40rxova%2Fjourney-devtools-bridge" alt="Bundlephobia" />
|
|
23
|
-
</a>
|
|
24
|
-
</p>
|
|
25
|
-
|
|
26
|
-
Explicit bridge that connects Journey machines to browser DevTools integrations.
|
|
27
|
-
|
|
28
|
-
Use this when you want runtime inspection and command controls from a DevTools panel.
|
|
29
|
-
|
|
30
|
-
`[OVERVIEW](https://rxova.org/docs/devtool/overview) | [GETTING STARTED](https://rxova.org/docs/devtool/getting-started) | [BRIDGE API](https://rxova.org/docs/devtool/bridge-api) | [PANEL GUIDE](https://rxova.org/docs/devtool/panel-guide) | [PROTOCOL](https://rxova.org/docs/devtool/protocol) | [TROUBLESHOOTING](https://rxova.org/docs/devtool/troubleshooting)`
|
|
3
|
+
Bridge that connects Journey machines to the browser devtools extension.
|
|
31
4
|
|
|
32
5
|
## Install
|
|
33
6
|
|
|
@@ -35,7 +8,7 @@ Use this when you want runtime inspection and command controls from a DevTools p
|
|
|
35
8
|
npm i @rxova/journey-devtools-bridge
|
|
36
9
|
```
|
|
37
10
|
|
|
38
|
-
##
|
|
11
|
+
## Usage
|
|
39
12
|
|
|
40
13
|
```ts
|
|
41
14
|
import { createJourneyMachine } from "@rxova/journey-core";
|
|
@@ -43,67 +16,27 @@ import { attachJourneyDevtools } from "@rxova/journey-devtools-bridge";
|
|
|
43
16
|
|
|
44
17
|
const machine = createJourneyMachine(journey);
|
|
45
18
|
|
|
46
|
-
// Attach once after machine creation.
|
|
47
19
|
const detach = attachJourneyDevtools(machine, {
|
|
48
20
|
label: "Checkout Flow"
|
|
49
21
|
});
|
|
50
|
-
|
|
51
|
-
// Call detach() when unmounting or disposing the machine.
|
|
52
|
-
// detach();
|
|
53
22
|
```
|
|
54
23
|
|
|
55
|
-
##
|
|
56
|
-
|
|
57
|
-
```tsx
|
|
58
|
-
import { useEffect } from "react";
|
|
59
|
-
import { useJourneyMachine } from "@rxova/journey-react";
|
|
60
|
-
import { attachJourneyDevtools } from "@rxova/journey-devtools-bridge";
|
|
61
|
-
|
|
62
|
-
export const JourneyDevtoolsBridge = () => {
|
|
63
|
-
const machine = useJourneyMachine();
|
|
24
|
+
## Protocol Notes
|
|
64
25
|
|
|
65
|
-
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
return attachJourneyDevtools(machine, { label: "Signup Flow" });
|
|
68
|
-
}, [machine]);
|
|
26
|
+
Bridge command support includes:
|
|
69
27
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
28
|
+
- `goToNextStep`, `terminateMachine`, `completeJourney`, `resetMachine`
|
|
29
|
+
- `goToStepById`
|
|
30
|
+
- `goToPreviousStep`
|
|
31
|
+
- `goToLastVisitedStep`
|
|
32
|
+
- `updateStepMetadata`
|
|
33
|
+
- `send` (custom event)
|
|
34
|
+
- `clearStepError`
|
|
73
35
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
- `attachJourneyDevtools(machine, options?) => detach`
|
|
77
|
-
- `JourneyDevtoolsBridgeOptions`
|
|
78
|
-
- `JourneyDevtoolsCommand`
|
|
79
|
-
- `JourneyDevtoolsEnvelope`
|
|
36
|
+
Snapshots include `history.timeline`, `history.index`, `currentStepId`, `visited`, `stepMeta`, `status`, and `async`.
|
|
80
37
|
|
|
81
38
|
## Runtime Defaults
|
|
82
39
|
|
|
83
|
-
- Enabled in non-production
|
|
84
|
-
- Disabled in production
|
|
85
|
-
-
|
|
86
|
-
- Commands enabled in non-production and disabled by default in production.
|
|
87
|
-
|
|
88
|
-
## Production Opt-In Example
|
|
89
|
-
|
|
90
|
-
```ts
|
|
91
|
-
attachJourneyDevtools(machine, { enabled: true, commandsEnabled: true });
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
Use explicit opts if your bundle does not provide `process.env.NODE_ENV`.
|
|
95
|
-
|
|
96
|
-
## Security Notes
|
|
97
|
-
|
|
98
|
-
- Same-page scripts can observe and emit page-level `postMessage` traffic.
|
|
99
|
-
- Keep command execution disabled in production unless explicitly required.
|
|
100
|
-
- Prefer inspect-only mode for sensitive environments (`commandsEnabled: false`).
|
|
101
|
-
- Bridge validation includes origin checks, payload validation, and rate limiting.
|
|
102
|
-
|
|
103
|
-
## Coverage Notes
|
|
104
|
-
|
|
105
|
-
Coverage badge is package-specific (`packages/devtools-bridge/test` against `packages/devtools-bridge/src`), not monorepo-wide.
|
|
106
|
-
|
|
107
|
-
## License
|
|
108
|
-
|
|
109
|
-
MIT
|
|
40
|
+
- Enabled in non-production by default.
|
|
41
|
+
- Disabled in production unless `enabled: true`.
|
|
42
|
+
- Commands disabled in production unless `commandsEnabled: true`.
|
package/dist/bridge.d.ts
CHANGED
|
@@ -6,5 +6,4 @@ export type JourneyDevtoolsBridgeOptions = {
|
|
|
6
6
|
appName?: string;
|
|
7
7
|
commandsEnabled?: boolean;
|
|
8
8
|
};
|
|
9
|
-
export declare const attachJourneyDevtools: <TContext, TStepId extends string, TEventType extends string, TPayloadMap extends JourneyEventPayloadMap<TEventType
|
|
10
|
-
//# sourceMappingURL=bridge.d.ts.map
|
|
9
|
+
export declare const attachJourneyDevtools: <TContext, TStepId extends string, TEventType extends string, TPayloadMap extends JourneyEventPayloadMap<TEventType>, TStepMeta>(machine: JourneyMachine<TContext, TStepId, TEventType, TPayloadMap, TStepMeta>, options?: JourneyDevtoolsBridgeOptions) => (() => void);
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var P=(e,t)=>{for(var n in t)f(e,n,{get:t[n],enumerable:!0})},Y=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of U(t))!A.call(e,r)&&r!==n&&f(e,r,{get:()=>t[r],enumerable:!(o=L(t,r))||o.enumerable});return e};var V=e=>Y(f({},"__esModule",{value:!0}),e);var Q={};P(Q,{JOURNEY_DEVTOOLS_BRIDGE_SOURCE:()=>c,JOURNEY_DEVTOOLS_CHANNEL:()=>g,JOURNEY_DEVTOOLS_EXTENSION_SOURCE:()=>E,JOURNEY_DEVTOOLS_PROTOCOL_VERSION:()=>m,attachJourneyDevtools:()=>b,isJourneyDevtoolsBridgeEnvelope:()=>O,isJourneyDevtoolsCommand:()=>D,isJourneyDevtoolsEnvelope:()=>v,isJourneyDevtoolsExtensionEnvelope:()=>h});module.exports=V(Q);var m=3,g="__RXOVA_JOURNEY_DEVTOOLS__",c="rxova-journey-bridge",E="rxova-journey-extension",p=e=>typeof e=="object"&&e!==null,j=e=>e===c||e===E;var d=(e,t=0)=>{if(t>10)return!1;if(e==null||["string","number","boolean"].includes(typeof e))return!0;if(typeof e=="object"){try{if(JSON.stringify(e).length>5e5)return!1}catch{return!1}return Array.isArray(e)?e.every(o=>d(o,t+1)):Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null?!1:Object.values(e).every(o=>d(o,t+1))}return!1},x=e=>p(e)?e.channel===g&&e.version===3&&j(e.source)&&typeof e.kind=="string"&&typeof e.machineId=="string"&&typeof e.timestamp=="number":!1,q=e=>!p(e)||typeof e.type!="string"||e.type.length===0||e.type.length>100?!1:"payload"in e&&e.payload!==void 0?d(e.payload):!0,D=e=>{if(!p(e)||typeof e.type!="string"||e.type.length===0||e.type.length>50)return!1;switch(e.type){case"goToNextStep":case"terminateMachine":case"completeJourney":case"resetMachine":case"goToLastVisitedStep":return Object.keys(e).length===1;case"goToStepById":return typeof e.stepId=="string"&&e.stepId.length>0&&e.stepId.length<=100&&Object.keys(e).length===2;case"goToPreviousStep":return(e.steps===void 0||typeof e.steps=="number"&&Number.isInteger(e.steps)&&e.steps>=1&&e.steps<=1e4)&&Object.keys(e).length<=2;case"send":return q(e.event)&&Object.keys(e).length===2;case"updateStepMetadata":return typeof e.stepId=="string"&&e.stepId.length>0&&e.stepId.length<=100&&d(e.metadata)&&Object.keys(e).length===3;case"clearStepError":return(e.stepId===void 0||typeof e.stepId=="string"&&e.stepId.length<=100)&&Object.keys(e).length<=2;default:return!1}},O=e=>{if(!x(e)||e.source!==c)return!1;let t=e;switch(e.kind){case"register":return p(t.meta)&&p(t.snapshot)&&d(t.meta)&&d(t.snapshot);case"unregister":return!0;case"snapshot":return p(t.snapshot)&&d(t.snapshot);case"commandResult":return typeof t.requestId=="string"&&t.requestId.length>0&&t.requestId.length<=100&&p(t.snapshot)&&d(t.snapshot);case"commandError":return typeof t.requestId=="string"&&t.requestId.length>0&&t.requestId.length<=100&&p(t.error);default:return!1}},h=e=>{if(!x(e)||e.source!==E||e.kind!=="command")return!1;let t=e;return typeof t.requestId=="string"&&t.requestId.length>0&&t.requestId.length<=100&&D(t.command)},v=e=>O(e)||h(e);var z="Journey Machine",X=e=>typeof e=="object"&&e!==null,G=e=>e==="idle"||e==="evaluating-when"||e==="running-effect"||e==="error",H=()=>{let e=typeof process<"u"?process.env?.NODE_ENV:void 0;return typeof e!="string"?!1:e!=="production"},W=()=>{let e=typeof process<"u"?process.env?.NODE_ENV:void 0;return typeof e!="string"?!1:e!=="production"},F=()=>typeof window>"u"||window.location.origin==="null"?"*":window.location.origin,K=e=>{if(e.length===0||typeof window>"u")return!1;let t=window.location.origin;return t==="null"?e==="null":e===t},$=()=>`journey-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`,w=class{constructor(t=100,n=1e4){this.commandTimestamps=[];this.maxCommandsPerWindow=t,this.windowMs=n}isAllowed(){let t=Date.now(),n=t-this.windowMs;return this.commandTimestamps=this.commandTimestamps.filter(o=>o>n),this.commandTimestamps.length>=this.maxCommandsPerWindow?!1:(this.commandTimestamps.push(t),!0)}reset(){this.commandTimestamps=[]}},S=e=>{if(typeof structuredClone=="function")try{return structuredClone(e)}catch{}let t=new WeakSet;try{let n=JSON.stringify(e,(o,r)=>{if(typeof r=="bigint")return r.toString();if(typeof r=="function")return`[Function ${r.name||"anonymous"}]`;if(typeof r=="symbol")return r.toString();if(typeof r=="object"&&r!==null){if(t.has(r))return"[Circular]";t.add(r)}return r});return n===void 0?void 0:JSON.parse(n)}catch{return String(e)}},T=e=>{if(e instanceof Error){let t="cause"in e&&e.cause!==void 0?e.cause:null;return{name:e.name,message:e.message,stack:typeof e.stack=="string"?e.stack:null,cause:S(t)}}return{name:null,message:typeof e=="string"?e:"Unknown error",stack:null,cause:S(e)}},I=e=>{let t={};for(let[n,o]of Object.entries(e.async.byStep))X(o)&&(t[n]={phase:G(o.phase)?o.phase:"idle",eventType:typeof o.eventType=="string"?o.eventType:null,transitionId:typeof o.transitionId=="string"?o.transitionId:null,error:o.error===null?null:S(o.error)});return{currentStepId:String(e.currentStepId),context:S(e.context),history:{timeline:e.history.timeline.map(n=>String(n)),index:e.history.index},visited:Object.fromEntries(Object.entries(e.visited).map(([n,o])=>[String(n),o===!0])),stepMeta:S(e.stepMeta),status:e.status,async:{isLoading:e.async.isLoading,byStep:t}}},Z=async(e,t)=>{switch(t.type){case"goToNextStep":case"completeJourney":{let n=await e.send({type:t.type});return{snapshot:n.snapshot,transitioned:n.transitioned,...n.transitionId?{transitionId:n.transitionId}:{}}}case"terminateMachine":{let n=await e.send({type:"terminateJourney"});return{snapshot:n.snapshot,transitioned:n.transitioned,...n.transitionId?{transitionId:n.transitionId}:{}}}case"goToStepById":{let n=await e.send({type:"goToStepById",stepId:t.stepId});return{snapshot:n.snapshot,transitioned:n.transitioned,...n.transitionId?{transitionId:n.transitionId}:{}}}case"goToPreviousStep":{let n=await e.goToPreviousStep(t.steps);return{snapshot:n.snapshot,transitioned:n.transitioned,...n.transitionId?{transitionId:n.transitionId}:{}}}case"goToLastVisitedStep":{let n=await e.goToLastVisitedStep();return{snapshot:n.snapshot,transitioned:n.transitioned,...n.transitionId?{transitionId:n.transitionId}:{}}}case"send":{let n=t.event.payload===void 0?{type:t.event.type}:{type:t.event.type,payload:t.event.payload},o=await e.send(n);return{snapshot:o.snapshot,transitioned:o.transitioned,...o.transitionId?{transitionId:o.transitionId}:{}}}case"updateStepMetadata":return{snapshot:e.updateStepMetadata(t.stepId,()=>t.metadata)};case"resetMachine":return{snapshot:e.resetMachine()};case"clearStepError":return{snapshot:e.clearStepError(t.stepId)}}},b=(e,t={})=>{if(!(t.enabled??H())||typeof window>"u")return()=>{};let o=t.commandsEnabled??W(),r=t.machineId?.trim()||$(),C={machineId:r,label:t.label?.trim()||z,appName:t.appName?.trim()||(typeof document<"u"?document.title:"")||null,commandsEnabled:o},N=F(),u=s=>({channel:g,version:3,source:c,kind:s,machineId:r,timestamp:Date.now()}),l=s=>{window.postMessage(s,N)},B=s=>{let a={...u("snapshot"),snapshot:I(s)};l(a)},y=!1,_=new w,R=s=>{if(s.source!==window||!K(s.origin)||y||!v(s.data)||s.data.source!==E||s.data.kind!=="command")return;let a=s.data;if(a.machineId!==r)return;if(!_.isAllowed()){let i={...u("commandError"),requestId:a.requestId,error:T("Command rate limit exceeded. Too many commands in a short time window.")};l(i);return}if(!o){let i={...u("commandError"),requestId:a.requestId,error:T("Bridge commands are disabled by configuration.")};l(i);return}(async()=>{try{let i=await Z(e,a.command);if(y)return;let J={...u("commandResult"),requestId:a.requestId,snapshot:I(i.snapshot),...i.transitioned!==void 0?{transitioned:i.transitioned}:{},...i.transitionId?{transitionId:i.transitionId}:{}};l(J)}catch(i){if(y)return;let J={...u("commandError"),requestId:a.requestId,error:T(i)};l(J)}})()};window.addEventListener("message",R);let M=e.subscribe(()=>{y||B(e.getSnapshot())}),k={...u("register"),meta:C,snapshot:I(e.getSnapshot())};return l(k),()=>{if(y)return;y=!0,_.reset(),M(),window.removeEventListener("message",R);let s={...u("unregister")};l(s)}};0&&(module.exports={JOURNEY_DEVTOOLS_BRIDGE_SOURCE,JOURNEY_DEVTOOLS_CHANNEL,JOURNEY_DEVTOOLS_EXTENSION_SOURCE,JOURNEY_DEVTOOLS_PROTOCOL_VERSION,attachJourneyDevtools,isJourneyDevtoolsBridgeEnvelope,isJourneyDevtoolsCommand,isJourneyDevtoolsEnvelope,isJourneyDevtoolsExtensionEnvelope});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/protocol.ts", "../src/bridge.ts"],
|
|
4
|
-
"sourcesContent": ["export { attachJourneyDevtools, type JourneyDevtoolsBridgeOptions } from \"./bridge\";\n\nexport {\n JOURNEY_DEVTOOLS_CHANNEL,\n JOURNEY_DEVTOOLS_PROTOCOL_VERSION,\n JOURNEY_DEVTOOLS_BRIDGE_SOURCE,\n JOURNEY_DEVTOOLS_EXTENSION_SOURCE,\n isJourneyDevtoolsCommand,\n isJourneyDevtoolsEnvelope,\n isJourneyDevtoolsBridgeEnvelope,\n isJourneyDevtoolsExtensionEnvelope,\n type JourneyDevtoolsBridgeCommandErrorEnvelope,\n type JourneyDevtoolsBridgeCommandResultEnvelope,\n type JourneyDevtoolsBridgeEnvelope,\n type JourneyDevtoolsBridgeRegisterEnvelope,\n type JourneyDevtoolsBridgeSnapshotEnvelope,\n type JourneyDevtoolsBridgeUnregisterEnvelope,\n type JourneyDevtoolsCommand,\n type JourneyDevtoolsEnvelope,\n type JourneyDevtoolsExtensionEnvelope,\n type JourneyDevtoolsExtensionCommandEnvelope,\n type JourneyDevtoolsMachineMeta,\n type JourneyDevtoolsSerializableSnapshot,\n type JourneyDevtoolsSerializedError\n} from \"./protocol\";\n", "import type { JourneySnapshot, JourneyStepAsyncState } from \"@rxova/journey-core\";\n\nexport const JOURNEY_DEVTOOLS_PROTOCOL_VERSION = 1 as const;\nexport const JOURNEY_DEVTOOLS_CHANNEL = \"__RXOVA_JOURNEY_DEVTOOLS__\" as const;\n\nexport const JOURNEY_DEVTOOLS_BRIDGE_SOURCE = \"rxova-journey-bridge\" as const;\nexport const JOURNEY_DEVTOOLS_EXTENSION_SOURCE = \"rxova-journey-extension\" as const;\n\nexport type JourneyDevtoolsSource =\n | typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE\n | typeof JOURNEY_DEVTOOLS_EXTENSION_SOURCE;\n\nexport type JourneyDevtoolsStepAsyncState = JourneyStepAsyncState;\n\nexport type JourneyDevtoolsSerializableSnapshot = JourneySnapshot<unknown, string>;\n\nexport type JourneyDevtoolsMachineMeta = {\n machineId: string;\n label: string;\n appName: string | null;\n commandsEnabled?: boolean;\n};\n\nexport type JourneyDevtoolsSerializedError = {\n name: string | null;\n message: string;\n stack: string | null;\n cause: unknown;\n};\n\nexport type JourneyDevtoolsCommand =\n | { type: \"next\" }\n | { type: \"back\" }\n | { type: \"close\" }\n | { type: \"submit\" }\n | { type: \"goTo\"; to: string }\n | { type: \"send\"; event: { type: string; payload?: unknown } }\n | { type: \"reset\" }\n | { type: \"clearStepError\"; stepId?: string }\n | { type: \"clearHistory\" }\n | { type: \"trimHistory\"; maxHistory?: number | null };\n\nexport type JourneyDevtoolsEnvelopeBase = {\n channel: typeof JOURNEY_DEVTOOLS_CHANNEL;\n version: typeof JOURNEY_DEVTOOLS_PROTOCOL_VERSION;\n source: JourneyDevtoolsSource;\n kind: string;\n machineId: string;\n timestamp: number;\n};\n\nexport type JourneyDevtoolsBridgeRegisterEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"register\";\n meta: JourneyDevtoolsMachineMeta;\n snapshot: JourneyDevtoolsSerializableSnapshot;\n};\n\nexport type JourneyDevtoolsBridgeUnregisterEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"unregister\";\n};\n\nexport type JourneyDevtoolsBridgeSnapshotEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"snapshot\";\n snapshot: JourneyDevtoolsSerializableSnapshot;\n};\n\nexport type JourneyDevtoolsBridgeCommandResultEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"commandResult\";\n requestId: string;\n snapshot: JourneyDevtoolsSerializableSnapshot;\n transitioned?: boolean;\n transitionId?: string;\n};\n\nexport type JourneyDevtoolsBridgeCommandErrorEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"commandError\";\n requestId: string;\n error: JourneyDevtoolsSerializedError;\n};\n\nexport type JourneyDevtoolsExtensionCommandEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_EXTENSION_SOURCE;\n kind: \"command\";\n requestId: string;\n command: JourneyDevtoolsCommand;\n};\n\nexport type JourneyDevtoolsBridgeEnvelope =\n | JourneyDevtoolsBridgeRegisterEnvelope\n | JourneyDevtoolsBridgeUnregisterEnvelope\n | JourneyDevtoolsBridgeSnapshotEnvelope\n | JourneyDevtoolsBridgeCommandResultEnvelope\n | JourneyDevtoolsBridgeCommandErrorEnvelope;\n\nexport type JourneyDevtoolsExtensionEnvelope = JourneyDevtoolsExtensionCommandEnvelope;\n\nexport type JourneyDevtoolsEnvelope =\n | JourneyDevtoolsBridgeEnvelope\n | JourneyDevtoolsExtensionEnvelope;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isKnownSource = (value: unknown): value is JourneyDevtoolsSource =>\n value === JOURNEY_DEVTOOLS_BRIDGE_SOURCE || value === JOURNEY_DEVTOOLS_EXTENSION_SOURCE;\n\n/**\n * Maximum depth for nested object validation.\n * Prevents stack overflow and excessive processing from deeply nested malicious payloads.\n */\nconst MAX_PAYLOAD_DEPTH = 10;\n\n/**\n * Maximum size (in JSON string length) for serialized payloads.\n * Prevents memory exhaustion from extremely large payloads.\n */\nconst MAX_PAYLOAD_SIZE = 500_000; // 500KB\n\n/**\n * Validates that a value is safe for transport.\n * Checks depth and size constraints to prevent malicious payloads.\n */\nconst isSafePayload = (value: unknown, depth = 0): boolean => {\n if (depth > MAX_PAYLOAD_DEPTH) {\n return false;\n }\n\n if (value === null || value === undefined) {\n return true;\n }\n\n const primitiveTypes = [\"string\", \"number\", \"boolean\"];\n if (primitiveTypes.includes(typeof value)) {\n return true;\n }\n\n if (typeof value === \"object\") {\n // Check JSON serialization size\n try {\n const serialized = JSON.stringify(value);\n if (serialized.length > MAX_PAYLOAD_SIZE) {\n return false;\n }\n } catch {\n // Circular references or non-serializable objects are not safe\n return false;\n }\n\n // Recursively validate nested objects and arrays\n if (Array.isArray(value)) {\n return value.every((item) => isSafePayload(item, depth + 1));\n }\n\n // Validate plain objects (guard against prototype pollution)\n if (\n Object.getPrototypeOf(value) !== Object.prototype &&\n Object.getPrototypeOf(value) !== null\n ) {\n return false;\n }\n\n return Object.values(value).every((prop) => isSafePayload(prop, depth + 1));\n }\n\n // Reject functions, symbols, and other non-serializable types\n return false;\n};\n\nconst hasBaseEnvelopeShape = (value: unknown): value is JourneyDevtoolsEnvelopeBase => {\n if (!isRecord(value)) {\n return false;\n }\n\n return (\n value.channel === JOURNEY_DEVTOOLS_CHANNEL &&\n value.version === JOURNEY_DEVTOOLS_PROTOCOL_VERSION &&\n isKnownSource(value.source) &&\n typeof value.kind === \"string\" &&\n typeof value.machineId === \"string\" &&\n typeof value.timestamp === \"number\"\n );\n};\n\nconst isSendEvent = (value: unknown): value is { type: string; payload?: unknown } => {\n if (!isRecord(value)) {\n return false;\n }\n\n if (typeof value.type !== \"string\" || value.type.length === 0 || value.type.length > 100) {\n return false;\n }\n\n // Validate payload if present\n if (\"payload\" in value && value.payload !== undefined) {\n return isSafePayload(value.payload);\n }\n\n return true;\n};\n\nexport const isJourneyDevtoolsCommand = (value: unknown): value is JourneyDevtoolsCommand => {\n if (!isRecord(value) || typeof value.type !== \"string\") {\n return false;\n }\n\n // Validate command type is within reasonable length\n if (value.type.length === 0 || value.type.length > 50) {\n return false;\n }\n\n switch (value.type) {\n case \"next\":\n case \"back\":\n case \"close\":\n case \"submit\":\n case \"reset\":\n case \"clearHistory\":\n // These commands should have no extra properties beyond type\n return Object.keys(value).length === 1;\n case \"goTo\":\n return (\n typeof value.to === \"string\" &&\n value.to.length > 0 &&\n value.to.length <= 100 &&\n Object.keys(value).length === 2\n );\n case \"send\":\n return isSendEvent(value.event) && Object.keys(value).length === 2;\n case \"clearStepError\":\n return (\n (value.stepId === undefined ||\n (typeof value.stepId === \"string\" && value.stepId.length <= 100)) &&\n Object.keys(value).length <= 2\n );\n case \"trimHistory\":\n return (\n (value.maxHistory === undefined ||\n value.maxHistory === null ||\n (typeof value.maxHistory === \"number\" &&\n Number.isInteger(value.maxHistory) &&\n value.maxHistory >= 0 &&\n value.maxHistory <= 10000)) &&\n Object.keys(value).length <= 2\n );\n default:\n return false;\n }\n};\n\nexport const isJourneyDevtoolsBridgeEnvelope = (\n value: unknown\n): value is JourneyDevtoolsBridgeEnvelope => {\n if (!hasBaseEnvelopeShape(value) || value.source !== JOURNEY_DEVTOOLS_BRIDGE_SOURCE) {\n return false;\n }\n\n const envelope = value as Record<string, unknown>;\n\n switch (value.kind) {\n case \"register\":\n return (\n isRecord(envelope.meta) &&\n isRecord(envelope.snapshot) &&\n isSafePayload(envelope.meta) &&\n isSafePayload(envelope.snapshot)\n );\n case \"unregister\":\n return true;\n case \"snapshot\":\n return isRecord(envelope.snapshot) && isSafePayload(envelope.snapshot);\n case \"commandResult\":\n return (\n typeof envelope.requestId === \"string\" &&\n envelope.requestId.length > 0 &&\n envelope.requestId.length <= 100 &&\n isRecord(envelope.snapshot) &&\n isSafePayload(envelope.snapshot)\n );\n case \"commandError\":\n return (\n typeof envelope.requestId === \"string\" &&\n envelope.requestId.length > 0 &&\n envelope.requestId.length <= 100 &&\n isRecord(envelope.error)\n );\n default:\n return false;\n }\n};\n\nexport const isJourneyDevtoolsExtensionEnvelope = (\n value: unknown\n): value is JourneyDevtoolsExtensionEnvelope => {\n if (!hasBaseEnvelopeShape(value) || value.source !== JOURNEY_DEVTOOLS_EXTENSION_SOURCE) {\n return false;\n }\n\n if (value.kind !== \"command\") {\n return false;\n }\n\n const envelope = value as Record<string, unknown>;\n return (\n typeof envelope.requestId === \"string\" &&\n envelope.requestId.length > 0 &&\n envelope.requestId.length <= 100 &&\n isJourneyDevtoolsCommand(envelope.command)\n );\n};\n\nexport const isJourneyDevtoolsEnvelope = (value: unknown): value is JourneyDevtoolsEnvelope =>\n isJourneyDevtoolsBridgeEnvelope(value) || isJourneyDevtoolsExtensionEnvelope(value);\n", "import type {\n JourneyEventPayloadMap,\n JourneyMachine,\n JourneySendResult,\n JourneySnapshot\n} from \"@rxova/journey-core\";\nimport {\n JOURNEY_DEVTOOLS_BRIDGE_SOURCE,\n JOURNEY_DEVTOOLS_CHANNEL,\n JOURNEY_DEVTOOLS_EXTENSION_SOURCE,\n JOURNEY_DEVTOOLS_PROTOCOL_VERSION,\n isJourneyDevtoolsEnvelope,\n type JourneyDevtoolsBridgeCommandErrorEnvelope,\n type JourneyDevtoolsBridgeCommandResultEnvelope,\n type JourneyDevtoolsBridgeEnvelope,\n type JourneyDevtoolsBridgeRegisterEnvelope,\n type JourneyDevtoolsBridgeSnapshotEnvelope,\n type JourneyDevtoolsBridgeUnregisterEnvelope,\n type JourneyDevtoolsCommand,\n type JourneyDevtoolsExtensionCommandEnvelope,\n type JourneyDevtoolsMachineMeta,\n type JourneyDevtoolsSerializableSnapshot,\n type JourneyDevtoolsSerializedError\n} from \"./protocol\";\n\ndeclare const process: { env?: { NODE_ENV?: string } } | undefined;\n\nexport type JourneyDevtoolsBridgeOptions = {\n machineId?: string;\n label?: string;\n enabled?: boolean;\n appName?: string;\n commandsEnabled?: boolean;\n};\n\ntype JourneySendEvent<TStepId extends string> = Parameters<\n JourneyMachine<unknown, TStepId, string>[\"send\"]\n>[0];\n\ntype SendOutcome<TContext, TStepId extends string> = {\n snapshot: JourneySnapshot<TContext, TStepId>;\n transitioned?: boolean;\n transitionId?: string;\n};\n\nconst DEFAULT_MACHINE_LABEL = \"Journey Machine\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isJourneyAsyncPhase = (\n value: unknown\n): value is JourneyDevtoolsSerializableSnapshot[\"async\"][\"byStep\"][string][\"phase\"] =>\n value === \"idle\" ||\n value === \"evaluating-when\" ||\n value === \"running-effect\" ||\n value === \"error\";\n\nconst resolveDefaultEnabled = (): boolean => {\n const nodeEnv = typeof process !== \"undefined\" ? process.env?.NODE_ENV : undefined;\n if (typeof nodeEnv !== \"string\") {\n return false;\n }\n\n return nodeEnv !== \"production\";\n};\n\nconst resolveDefaultCommandsEnabled = (): boolean => {\n const nodeEnv = typeof process !== \"undefined\" ? process.env?.NODE_ENV : undefined;\n if (typeof nodeEnv !== \"string\") {\n return false;\n }\n\n return nodeEnv !== \"production\";\n};\n\nconst resolveWindowTargetOrigin = (): string => {\n if (typeof window === \"undefined\") {\n return \"*\";\n }\n\n return window.location.origin === \"null\" ? \"*\" : window.location.origin;\n};\n\n// No session token infrastructure needed\n\n/**\n * Validates that the message origin matches the current window origin.\n * This prevents messages from other origins from being processed.\n *\n * Note: This is part of defense-in-depth but not a hard security boundary.\n * Code running in the same origin can still send messages.\n */\nconst isExpectedWindowOrigin = (origin: string): boolean => {\n if (origin.length === 0) {\n return false;\n }\n\n if (typeof window === \"undefined\") {\n return false;\n }\n\n const expected = window.location.origin;\n if (expected === \"null\") {\n // For file:// or sandboxed contexts where origin is \"null\"\n return origin === \"null\";\n }\n\n // Strict equality check - no wildcard matching\n return origin === expected;\n};\n\nconst createMachineId = (): string =>\n `journey-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n\n/**\n * Simple rate limiter to prevent command abuse.\n * Tracks command timestamps and enforces a maximum rate.\n */\nclass CommandRateLimiter {\n private commandTimestamps: number[] = [];\n private readonly maxCommandsPerWindow: number;\n private readonly windowMs: number;\n\n constructor(maxCommandsPerWindow = 100, windowMs = 10000) {\n this.maxCommandsPerWindow = maxCommandsPerWindow;\n this.windowMs = windowMs;\n }\n\n /**\n * Checks if a command is allowed based on rate limits.\n * Returns true if allowed, false if rate limit exceeded.\n */\n isAllowed(): boolean {\n const now = Date.now();\n const windowStart = now - this.windowMs;\n\n // Remove old timestamps outside the window\n this.commandTimestamps = this.commandTimestamps.filter((ts) => ts > windowStart);\n\n if (this.commandTimestamps.length >= this.maxCommandsPerWindow) {\n return false;\n }\n\n this.commandTimestamps.push(now);\n return true;\n }\n\n reset(): void {\n this.commandTimestamps = [];\n }\n}\n\nconst cloneForTransport = (value: unknown): unknown => {\n if (typeof structuredClone === \"function\") {\n try {\n return structuredClone(value);\n } catch {\n // Fall through to the JSON serializer below.\n }\n }\n\n const seen = new WeakSet<object>();\n\n try {\n const serialized = JSON.stringify(value, (_key, currentValue) => {\n if (typeof currentValue === \"bigint\") {\n return currentValue.toString();\n }\n if (typeof currentValue === \"function\") {\n return `[Function ${currentValue.name || \"anonymous\"}]`;\n }\n if (typeof currentValue === \"symbol\") {\n return currentValue.toString();\n }\n if (typeof currentValue === \"object\" && currentValue !== null) {\n if (seen.has(currentValue)) {\n return \"[Circular]\";\n }\n seen.add(currentValue);\n }\n return currentValue;\n });\n\n if (serialized === undefined) {\n return undefined;\n }\n\n return JSON.parse(serialized) as unknown;\n } catch {\n return String(value);\n }\n};\n\nconst serializeError = (error: unknown): JourneyDevtoolsSerializedError => {\n if (error instanceof Error) {\n const cause =\n \"cause\" in error && (error as { cause?: unknown }).cause !== undefined\n ? (error as { cause?: unknown }).cause\n : null;\n return {\n name: error.name,\n message: error.message,\n stack: typeof error.stack === \"string\" ? error.stack : null,\n cause: cloneForTransport(cause)\n };\n }\n\n return {\n name: null,\n message: typeof error === \"string\" ? error : \"Unknown error\",\n stack: null,\n cause: cloneForTransport(error)\n };\n};\n\nconst serializeSnapshot = <TContext, TStepId extends string>(\n snapshot: JourneySnapshot<TContext, TStepId>\n): JourneyDevtoolsSerializableSnapshot => {\n const byStep: Record<string, JourneyDevtoolsSerializableSnapshot[\"async\"][\"byStep\"][string]> = {};\n\n for (const [stepId, stepState] of Object.entries(\n snapshot.async.byStep as Record<string, unknown>\n )) {\n if (!isRecord(stepState)) {\n continue;\n }\n\n byStep[stepId] = {\n phase: isJourneyAsyncPhase(stepState.phase) ? stepState.phase : \"idle\",\n eventType: typeof stepState.eventType === \"string\" ? stepState.eventType : null,\n transitionId: typeof stepState.transitionId === \"string\" ? stepState.transitionId : null,\n error: stepState.error === null ? null : cloneForTransport(stepState.error)\n };\n }\n\n return {\n current: String(snapshot.current),\n context: cloneForTransport(snapshot.context),\n history: snapshot.history.map((stepId) => String(stepId)),\n visited: snapshot.visited.map((stepId) => String(stepId)),\n status: snapshot.status,\n async: {\n isLoading: snapshot.async.isLoading,\n byStep\n }\n };\n};\n\nconst runCommand = async <TContext, TStepId extends string>(\n machine: JourneyMachine<TContext, TStepId, string>,\n command: JourneyDevtoolsCommand\n): Promise<SendOutcome<TContext, TStepId>> => {\n switch (command.type) {\n case \"next\":\n case \"back\":\n case \"close\":\n case \"submit\": {\n const result = await machine.send({ type: command.type } as JourneySendEvent<TStepId>);\n return {\n snapshot: result.snapshot,\n transitioned: result.transitioned,\n ...(result.transitionId ? { transitionId: result.transitionId } : {})\n };\n }\n case \"goTo\": {\n const result = await machine.send({\n type: \"goTo\",\n to: command.to\n } as JourneySendEvent<TStepId>);\n return {\n snapshot: result.snapshot,\n transitioned: result.transitioned,\n ...(result.transitionId ? { transitionId: result.transitionId } : {})\n };\n }\n case \"send\": {\n const sendEvent =\n command.event.payload === undefined\n ? { type: command.event.type }\n : { type: command.event.type, payload: command.event.payload };\n const result: JourneySendResult<TContext, TStepId> = await machine.send(\n sendEvent as JourneySendEvent<TStepId>\n );\n return {\n snapshot: result.snapshot,\n transitioned: result.transitioned,\n ...(result.transitionId ? { transitionId: result.transitionId } : {})\n };\n }\n case \"reset\":\n return {\n snapshot: machine.reset()\n };\n case \"clearStepError\":\n return {\n snapshot: machine.clearStepError(command.stepId as TStepId | undefined)\n };\n case \"clearHistory\":\n return {\n snapshot: machine.clearHistory()\n };\n case \"trimHistory\":\n return {\n snapshot: machine.trimHistory(command.maxHistory)\n };\n }\n};\n\nexport const attachJourneyDevtools = <\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType>\n>(\n machine: JourneyMachine<TContext, TStepId, TEventType, TPayloadMap>,\n options: JourneyDevtoolsBridgeOptions = {}\n): (() => void) => {\n const enabled = options.enabled ?? resolveDefaultEnabled();\n if (!enabled || typeof window === \"undefined\") {\n return () => {};\n }\n const commandsEnabled = options.commandsEnabled ?? resolveDefaultCommandsEnabled();\n\n const machineId = options.machineId?.trim() || createMachineId();\n const meta: JourneyDevtoolsMachineMeta = {\n machineId,\n label: options.label?.trim() || DEFAULT_MACHINE_LABEL,\n appName:\n options.appName?.trim() || (typeof document !== \"undefined\" ? document.title : \"\") || null,\n commandsEnabled\n };\n const targetOrigin = resolveWindowTargetOrigin();\n\n const createBaseEnvelope = <TKind extends JourneyDevtoolsBridgeEnvelope[\"kind\"]>(\n kind: TKind\n ) => ({\n channel: JOURNEY_DEVTOOLS_CHANNEL,\n version: JOURNEY_DEVTOOLS_PROTOCOL_VERSION,\n source: JOURNEY_DEVTOOLS_BRIDGE_SOURCE,\n kind,\n machineId,\n timestamp: Date.now()\n });\n\n const post = (envelope: JourneyDevtoolsBridgeEnvelope) => {\n window.postMessage(envelope, targetOrigin);\n };\n\n const postSnapshot = (snapshot: JourneySnapshot<TContext, TStepId>) => {\n const envelope: JourneyDevtoolsBridgeSnapshotEnvelope = {\n ...createBaseEnvelope(\"snapshot\"),\n snapshot: serializeSnapshot(snapshot)\n };\n post(envelope);\n };\n\n let isDetached = false;\n const rateLimiter = new CommandRateLimiter();\n\n const onMessage = (event: MessageEvent<unknown>) => {\n if (\n event.source !== window ||\n !isExpectedWindowOrigin(event.origin) ||\n isDetached ||\n !isJourneyDevtoolsEnvelope(event.data)\n ) {\n return;\n }\n\n if (event.data.source !== JOURNEY_DEVTOOLS_EXTENSION_SOURCE || event.data.kind !== \"command\") {\n return;\n }\n\n const commandEnvelope: JourneyDevtoolsExtensionCommandEnvelope = event.data;\n if (commandEnvelope.machineId !== machineId) {\n return;\n }\n\n // Rate limiting to prevent command abuse\n if (!rateLimiter.isAllowed()) {\n const errorEnvelope: JourneyDevtoolsBridgeCommandErrorEnvelope = {\n ...createBaseEnvelope(\"commandError\"),\n requestId: commandEnvelope.requestId,\n error: serializeError(\n \"Command rate limit exceeded. Too many commands in a short time window.\"\n )\n };\n post(errorEnvelope);\n return;\n }\n\n if (!commandsEnabled) {\n const errorEnvelope: JourneyDevtoolsBridgeCommandErrorEnvelope = {\n ...createBaseEnvelope(\"commandError\"),\n requestId: commandEnvelope.requestId,\n error: serializeError(\"Bridge commands are disabled by configuration.\")\n };\n post(errorEnvelope);\n return;\n }\n\n const run = async () => {\n try {\n const outcome = await runCommand(\n machine as JourneyMachine<TContext, TStepId, string>,\n commandEnvelope.command\n );\n if (isDetached) {\n return;\n }\n\n const resultEnvelope: JourneyDevtoolsBridgeCommandResultEnvelope = {\n ...createBaseEnvelope(\"commandResult\"),\n requestId: commandEnvelope.requestId,\n snapshot: serializeSnapshot(outcome.snapshot),\n ...(outcome.transitioned !== undefined ? { transitioned: outcome.transitioned } : {}),\n ...(outcome.transitionId ? { transitionId: outcome.transitionId } : {})\n };\n post(resultEnvelope);\n } catch (error) {\n if (isDetached) {\n return;\n }\n\n const errorEnvelope: JourneyDevtoolsBridgeCommandErrorEnvelope = {\n ...createBaseEnvelope(\"commandError\"),\n requestId: commandEnvelope.requestId,\n error: serializeError(error)\n };\n post(errorEnvelope);\n }\n };\n\n void run();\n };\n\n window.addEventListener(\"message\", onMessage);\n\n const unsubscribe = machine.subscribe(() => {\n if (isDetached) {\n return;\n }\n postSnapshot(machine.getSnapshot());\n });\n\n const registerEnvelope: JourneyDevtoolsBridgeRegisterEnvelope = {\n ...createBaseEnvelope(\"register\"),\n meta,\n snapshot: serializeSnapshot(machine.getSnapshot())\n };\n post(registerEnvelope);\n\n return () => {\n if (isDetached) {\n return;\n }\n\n isDetached = true;\n rateLimiter.reset();\n unsubscribe();\n window.removeEventListener(\"message\", onMessage);\n\n const unregisterEnvelope: JourneyDevtoolsBridgeUnregisterEnvelope = {\n ...createBaseEnvelope(\"unregister\")\n };\n post(unregisterEnvelope);\n };\n};\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oCAAAE,EAAA,6BAAAC,EAAA,sCAAAC,EAAA,sCAAAC,EAAA,0BAAAC,EAAA,oCAAAC,EAAA,6BAAAC,EAAA,8BAAAC,EAAA,uCAAAC,IAAA,eAAAC,EAAAX,GCEO,IAAMY,EAAoC,EACpCC,EAA2B,6BAE3BC,EAAiC,uBACjCC,EAAoC,0BAmG3CC,EAAYC,GAChB,OAAOA,GAAU,UAAYA,IAAU,KAEnCC,EAAiBD,GACrBA,IAAUH,GAAkCG,IAAUF,EAkBxD,IAAMI,EAAgB,CAACC,EAAgBC,EAAQ,IAAe,CAC5D,GAAIA,EAAQ,GACV,MAAO,GAQT,GALID,GAAU,MAIS,CAAC,SAAU,SAAU,SAAS,EAClC,SAAS,OAAOA,CAAK,EACtC,MAAO,GAGT,GAAI,OAAOA,GAAU,SAAU,CAE7B,GAAI,CAEF,GADmB,KAAK,UAAUA,CAAK,EACxB,OAAS,IACtB,MAAO,EAEX,MAAQ,CAEN,MAAO,EACT,CAGA,OAAI,MAAM,QAAQA,CAAK,EACdA,EAAM,MAAOE,GAASH,EAAcG,EAAMD,EAAQ,CAAC,CAAC,EAK3D,OAAO,eAAeD,CAAK,IAAM,OAAO,WACxC,OAAO,eAAeA,CAAK,IAAM,KAE1B,GAGF,OAAO,OAAOA,CAAK,EAAE,MAAOG,GAASJ,EAAcI,EAAMF,EAAQ,CAAC,CAAC,CAC5E,CAGA,MAAO,EACT,EAEMG,EAAwBJ,GACvBK,EAASL,CAAK,EAKjBA,EAAM,UAAYM,GAClBN,EAAM,UAAY,GAClBO,EAAcP,EAAM,MAAM,GAC1B,OAAOA,EAAM,MAAS,UACtB,OAAOA,EAAM,WAAc,UAC3B,OAAOA,EAAM,WAAc,SATpB,GAaLQ,EAAeR,GACf,CAACK,EAASL,CAAK,GAIf,OAAOA,EAAM,MAAS,UAAYA,EAAM,KAAK,SAAW,GAAKA,EAAM,KAAK,OAAS,IAC5E,GAIL,YAAaA,GAASA,EAAM,UAAY,OACnCD,EAAcC,EAAM,OAAO,EAG7B,GAGIS,EAA4BT,GAAoD,CAM3F,GALI,CAACK,EAASL,CAAK,GAAK,OAAOA,EAAM,MAAS,UAK1CA,EAAM,KAAK,SAAW,GAAKA,EAAM,KAAK,OAAS,GACjD,MAAO,GAGT,OAAQA,EAAM,KAAM,CAClB,IAAK,
|
|
6
|
-
"names": ["index_exports", "__export", "JOURNEY_DEVTOOLS_BRIDGE_SOURCE", "JOURNEY_DEVTOOLS_CHANNEL", "JOURNEY_DEVTOOLS_EXTENSION_SOURCE", "JOURNEY_DEVTOOLS_PROTOCOL_VERSION", "attachJourneyDevtools", "isJourneyDevtoolsBridgeEnvelope", "isJourneyDevtoolsCommand", "isJourneyDevtoolsEnvelope", "isJourneyDevtoolsExtensionEnvelope", "__toCommonJS", "JOURNEY_DEVTOOLS_PROTOCOL_VERSION", "JOURNEY_DEVTOOLS_CHANNEL", "JOURNEY_DEVTOOLS_BRIDGE_SOURCE", "JOURNEY_DEVTOOLS_EXTENSION_SOURCE", "isRecord", "value", "isKnownSource", "isSafePayload", "value", "depth", "item", "prop", "hasBaseEnvelopeShape", "isRecord", "JOURNEY_DEVTOOLS_CHANNEL", "isKnownSource", "isSendEvent", "isJourneyDevtoolsCommand", "isJourneyDevtoolsBridgeEnvelope", "JOURNEY_DEVTOOLS_BRIDGE_SOURCE", "envelope", "isJourneyDevtoolsExtensionEnvelope", "JOURNEY_DEVTOOLS_EXTENSION_SOURCE", "isJourneyDevtoolsEnvelope", "DEFAULT_MACHINE_LABEL", "isRecord", "value", "isJourneyAsyncPhase", "resolveDefaultEnabled", "nodeEnv", "resolveDefaultCommandsEnabled", "resolveWindowTargetOrigin", "isExpectedWindowOrigin", "origin", "expected", "createMachineId", "CommandRateLimiter", "maxCommandsPerWindow", "windowMs", "now", "windowStart", "ts", "cloneForTransport", "seen", "serialized", "_key", "currentValue", "serializeError", "error", "cause", "serializeSnapshot", "snapshot", "byStep", "stepId", "stepState", "runCommand", "machine", "command", "result", "sendEvent", "attachJourneyDevtools", "options", "commandsEnabled", "machineId", "meta", "targetOrigin", "createBaseEnvelope", "kind", "JOURNEY_DEVTOOLS_CHANNEL", "JOURNEY_DEVTOOLS_BRIDGE_SOURCE", "post", "envelope", "postSnapshot", "isDetached", "rateLimiter", "onMessage", "event", "isJourneyDevtoolsEnvelope", "JOURNEY_DEVTOOLS_EXTENSION_SOURCE", "commandEnvelope", "errorEnvelope", "outcome", "resultEnvelope", "unsubscribe", "registerEnvelope", "unregisterEnvelope"]
|
|
4
|
+
"sourcesContent": ["export { attachJourneyDevtools, type JourneyDevtoolsBridgeOptions } from \"./bridge\";\n\nexport {\n JOURNEY_DEVTOOLS_CHANNEL,\n JOURNEY_DEVTOOLS_PROTOCOL_VERSION,\n JOURNEY_DEVTOOLS_BRIDGE_SOURCE,\n JOURNEY_DEVTOOLS_EXTENSION_SOURCE,\n isJourneyDevtoolsCommand,\n isJourneyDevtoolsEnvelope,\n isJourneyDevtoolsBridgeEnvelope,\n isJourneyDevtoolsExtensionEnvelope,\n type JourneyDevtoolsBridgeCommandErrorEnvelope,\n type JourneyDevtoolsBridgeCommandResultEnvelope,\n type JourneyDevtoolsBridgeEnvelope,\n type JourneyDevtoolsBridgeRegisterEnvelope,\n type JourneyDevtoolsBridgeSnapshotEnvelope,\n type JourneyDevtoolsBridgeUnregisterEnvelope,\n type JourneyDevtoolsCommand,\n type JourneyDevtoolsEnvelope,\n type JourneyDevtoolsExtensionEnvelope,\n type JourneyDevtoolsExtensionCommandEnvelope,\n type JourneyDevtoolsMachineMeta,\n type JourneyDevtoolsSerializableSnapshot,\n type JourneyDevtoolsSerializedError\n} from \"./protocol\";\n", "import type { JourneySnapshot, JourneyStepAsyncState } from \"@rxova/journey-core\";\n\nexport const JOURNEY_DEVTOOLS_PROTOCOL_VERSION = 3 as const;\nexport const JOURNEY_DEVTOOLS_CHANNEL = \"__RXOVA_JOURNEY_DEVTOOLS__\" as const;\n\nexport const JOURNEY_DEVTOOLS_BRIDGE_SOURCE = \"rxova-journey-bridge\" as const;\nexport const JOURNEY_DEVTOOLS_EXTENSION_SOURCE = \"rxova-journey-extension\" as const;\n\nexport type JourneyDevtoolsSource =\n | typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE\n | typeof JOURNEY_DEVTOOLS_EXTENSION_SOURCE;\n\nexport type JourneyDevtoolsStepAsyncState = JourneyStepAsyncState;\n\nexport type JourneyDevtoolsSerializableSnapshot = JourneySnapshot<unknown, string>;\n\nexport type JourneyDevtoolsMachineMeta = {\n machineId: string;\n label: string;\n appName: string | null;\n commandsEnabled?: boolean;\n};\n\nexport type JourneyDevtoolsSerializedError = {\n name: string | null;\n message: string;\n stack: string | null;\n cause: unknown;\n};\n\nexport type JourneyDevtoolsCommand =\n | { type: \"goToNextStep\" }\n | { type: \"terminateMachine\" }\n | { type: \"completeJourney\" }\n | { type: \"goToStepById\"; stepId: string }\n | { type: \"goToPreviousStep\"; steps?: number }\n | { type: \"goToLastVisitedStep\" }\n | { type: \"send\"; event: { type: string; payload?: unknown } }\n | { type: \"updateStepMetadata\"; stepId: string; metadata: unknown }\n | { type: \"resetMachine\" }\n | { type: \"clearStepError\"; stepId?: string };\n\nexport type JourneyDevtoolsEnvelopeBase = {\n channel: typeof JOURNEY_DEVTOOLS_CHANNEL;\n version: typeof JOURNEY_DEVTOOLS_PROTOCOL_VERSION;\n source: JourneyDevtoolsSource;\n kind: string;\n machineId: string;\n timestamp: number;\n};\n\nexport type JourneyDevtoolsBridgeRegisterEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"register\";\n meta: JourneyDevtoolsMachineMeta;\n snapshot: JourneyDevtoolsSerializableSnapshot;\n};\n\nexport type JourneyDevtoolsBridgeUnregisterEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"unregister\";\n};\n\nexport type JourneyDevtoolsBridgeSnapshotEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"snapshot\";\n snapshot: JourneyDevtoolsSerializableSnapshot;\n};\n\nexport type JourneyDevtoolsBridgeCommandResultEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"commandResult\";\n requestId: string;\n snapshot: JourneyDevtoolsSerializableSnapshot;\n transitioned?: boolean;\n transitionId?: string;\n};\n\nexport type JourneyDevtoolsBridgeCommandErrorEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"commandError\";\n requestId: string;\n error: JourneyDevtoolsSerializedError;\n};\n\nexport type JourneyDevtoolsExtensionCommandEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_EXTENSION_SOURCE;\n kind: \"command\";\n requestId: string;\n command: JourneyDevtoolsCommand;\n};\n\nexport type JourneyDevtoolsBridgeEnvelope =\n | JourneyDevtoolsBridgeRegisterEnvelope\n | JourneyDevtoolsBridgeUnregisterEnvelope\n | JourneyDevtoolsBridgeSnapshotEnvelope\n | JourneyDevtoolsBridgeCommandResultEnvelope\n | JourneyDevtoolsBridgeCommandErrorEnvelope;\n\nexport type JourneyDevtoolsExtensionEnvelope = JourneyDevtoolsExtensionCommandEnvelope;\n\nexport type JourneyDevtoolsEnvelope =\n | JourneyDevtoolsBridgeEnvelope\n | JourneyDevtoolsExtensionEnvelope;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isKnownSource = (value: unknown): value is JourneyDevtoolsSource =>\n value === JOURNEY_DEVTOOLS_BRIDGE_SOURCE || value === JOURNEY_DEVTOOLS_EXTENSION_SOURCE;\n\n/**\n * Maximum depth for nested object validation.\n * Prevents stack overflow and excessive processing from deeply nested malicious payloads.\n */\nconst MAX_PAYLOAD_DEPTH = 10;\n\n/**\n * Maximum size (in JSON string length) for serialized payloads.\n * Prevents memory exhaustion from extremely large payloads.\n */\nconst MAX_PAYLOAD_SIZE = 500_000; // 500KB\n\n/**\n * Validates that a value is safe for transport.\n * Checks depth and size constraints to prevent malicious payloads.\n */\nconst isSafePayload = (value: unknown, depth = 0): boolean => {\n if (depth > MAX_PAYLOAD_DEPTH) {\n return false;\n }\n\n if (value === null || value === undefined) {\n return true;\n }\n\n const primitiveTypes = [\"string\", \"number\", \"boolean\"];\n if (primitiveTypes.includes(typeof value)) {\n return true;\n }\n\n if (typeof value === \"object\") {\n // Check JSON serialization size\n try {\n const serialized = JSON.stringify(value);\n if (serialized.length > MAX_PAYLOAD_SIZE) {\n return false;\n }\n } catch {\n // Circular references or non-serializable objects are not safe\n return false;\n }\n\n // Recursively validate nested objects and arrays\n if (Array.isArray(value)) {\n return value.every((item) => isSafePayload(item, depth + 1));\n }\n\n // Validate plain objects (guard against prototype pollution)\n if (\n Object.getPrototypeOf(value) !== Object.prototype &&\n Object.getPrototypeOf(value) !== null\n ) {\n return false;\n }\n\n return Object.values(value).every((prop) => isSafePayload(prop, depth + 1));\n }\n\n // Reject functions, symbols, and other non-serializable types\n return false;\n};\n\nconst hasBaseEnvelopeShape = (value: unknown): value is JourneyDevtoolsEnvelopeBase => {\n if (!isRecord(value)) {\n return false;\n }\n\n return (\n value.channel === JOURNEY_DEVTOOLS_CHANNEL &&\n value.version === JOURNEY_DEVTOOLS_PROTOCOL_VERSION &&\n isKnownSource(value.source) &&\n typeof value.kind === \"string\" &&\n typeof value.machineId === \"string\" &&\n typeof value.timestamp === \"number\"\n );\n};\n\nconst isSendEvent = (value: unknown): value is { type: string; payload?: unknown } => {\n if (!isRecord(value)) {\n return false;\n }\n\n if (typeof value.type !== \"string\" || value.type.length === 0 || value.type.length > 100) {\n return false;\n }\n\n // Validate payload if present\n if (\"payload\" in value && value.payload !== undefined) {\n return isSafePayload(value.payload);\n }\n\n return true;\n};\n\nexport const isJourneyDevtoolsCommand = (value: unknown): value is JourneyDevtoolsCommand => {\n if (!isRecord(value) || typeof value.type !== \"string\") {\n return false;\n }\n\n // Validate command type is within reasonable length\n if (value.type.length === 0 || value.type.length > 50) {\n return false;\n }\n\n switch (value.type) {\n case \"goToNextStep\":\n case \"terminateMachine\":\n case \"completeJourney\":\n case \"resetMachine\":\n case \"goToLastVisitedStep\":\n // These commands should have no extra properties beyond type\n return Object.keys(value).length === 1;\n case \"goToStepById\":\n return (\n typeof value.stepId === \"string\" &&\n value.stepId.length > 0 &&\n value.stepId.length <= 100 &&\n Object.keys(value).length === 2\n );\n case \"goToPreviousStep\":\n return (\n (value.steps === undefined ||\n (typeof value.steps === \"number\" &&\n Number.isInteger(value.steps) &&\n value.steps >= 1 &&\n value.steps <= 10000)) &&\n Object.keys(value).length <= 2\n );\n case \"send\":\n return isSendEvent(value.event) && Object.keys(value).length === 2;\n case \"updateStepMetadata\":\n return (\n typeof value.stepId === \"string\" &&\n value.stepId.length > 0 &&\n value.stepId.length <= 100 &&\n isSafePayload(value.metadata) &&\n Object.keys(value).length === 3\n );\n case \"clearStepError\":\n return (\n (value.stepId === undefined ||\n (typeof value.stepId === \"string\" && value.stepId.length <= 100)) &&\n Object.keys(value).length <= 2\n );\n default:\n return false;\n }\n};\n\nexport const isJourneyDevtoolsBridgeEnvelope = (\n value: unknown\n): value is JourneyDevtoolsBridgeEnvelope => {\n if (!hasBaseEnvelopeShape(value) || value.source !== JOURNEY_DEVTOOLS_BRIDGE_SOURCE) {\n return false;\n }\n\n const envelope = value as Record<string, unknown>;\n\n switch (value.kind) {\n case \"register\":\n return (\n isRecord(envelope.meta) &&\n isRecord(envelope.snapshot) &&\n isSafePayload(envelope.meta) &&\n isSafePayload(envelope.snapshot)\n );\n case \"unregister\":\n return true;\n case \"snapshot\":\n return isRecord(envelope.snapshot) && isSafePayload(envelope.snapshot);\n case \"commandResult\":\n return (\n typeof envelope.requestId === \"string\" &&\n envelope.requestId.length > 0 &&\n envelope.requestId.length <= 100 &&\n isRecord(envelope.snapshot) &&\n isSafePayload(envelope.snapshot)\n );\n case \"commandError\":\n return (\n typeof envelope.requestId === \"string\" &&\n envelope.requestId.length > 0 &&\n envelope.requestId.length <= 100 &&\n isRecord(envelope.error)\n );\n default:\n return false;\n }\n};\n\nexport const isJourneyDevtoolsExtensionEnvelope = (\n value: unknown\n): value is JourneyDevtoolsExtensionEnvelope => {\n if (!hasBaseEnvelopeShape(value) || value.source !== JOURNEY_DEVTOOLS_EXTENSION_SOURCE) {\n return false;\n }\n\n if (value.kind !== \"command\") {\n return false;\n }\n\n const envelope = value as Record<string, unknown>;\n return (\n typeof envelope.requestId === \"string\" &&\n envelope.requestId.length > 0 &&\n envelope.requestId.length <= 100 &&\n isJourneyDevtoolsCommand(envelope.command)\n );\n};\n\nexport const isJourneyDevtoolsEnvelope = (value: unknown): value is JourneyDevtoolsEnvelope =>\n isJourneyDevtoolsBridgeEnvelope(value) || isJourneyDevtoolsExtensionEnvelope(value);\n", "import type {\n JourneyEventPayloadMap,\n JourneyMachine,\n JourneySendResult,\n JourneySnapshot\n} from \"@rxova/journey-core\";\nimport {\n JOURNEY_DEVTOOLS_BRIDGE_SOURCE,\n JOURNEY_DEVTOOLS_CHANNEL,\n JOURNEY_DEVTOOLS_EXTENSION_SOURCE,\n JOURNEY_DEVTOOLS_PROTOCOL_VERSION,\n isJourneyDevtoolsEnvelope,\n type JourneyDevtoolsBridgeCommandErrorEnvelope,\n type JourneyDevtoolsBridgeCommandResultEnvelope,\n type JourneyDevtoolsBridgeEnvelope,\n type JourneyDevtoolsBridgeRegisterEnvelope,\n type JourneyDevtoolsBridgeSnapshotEnvelope,\n type JourneyDevtoolsBridgeUnregisterEnvelope,\n type JourneyDevtoolsCommand,\n type JourneyDevtoolsExtensionCommandEnvelope,\n type JourneyDevtoolsMachineMeta,\n type JourneyDevtoolsSerializableSnapshot,\n type JourneyDevtoolsSerializedError\n} from \"./protocol\";\n\ndeclare const process: { env?: { NODE_ENV?: string } } | undefined;\n\nexport type JourneyDevtoolsBridgeOptions = {\n machineId?: string;\n label?: string;\n enabled?: boolean;\n appName?: string;\n commandsEnabled?: boolean;\n};\n\ntype JourneySendEvent<TStepId extends string> = Parameters<\n JourneyMachine<unknown, TStepId, string, Record<never, never>, unknown>[\"send\"]\n>[0];\n\ntype SendOutcome<TContext, TStepId extends string, TStepMeta> = {\n snapshot: JourneySnapshot<TContext, TStepId, TStepMeta>;\n transitioned?: boolean;\n transitionId?: string;\n};\n\nconst DEFAULT_MACHINE_LABEL = \"Journey Machine\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isJourneyAsyncPhase = (\n value: unknown\n): value is JourneyDevtoolsSerializableSnapshot[\"async\"][\"byStep\"][string][\"phase\"] =>\n value === \"idle\" ||\n value === \"evaluating-when\" ||\n value === \"running-effect\" ||\n value === \"error\";\n\nconst resolveDefaultEnabled = (): boolean => {\n const nodeEnv = typeof process !== \"undefined\" ? process.env?.NODE_ENV : undefined;\n if (typeof nodeEnv !== \"string\") {\n return false;\n }\n\n return nodeEnv !== \"production\";\n};\n\nconst resolveDefaultCommandsEnabled = (): boolean => {\n const nodeEnv = typeof process !== \"undefined\" ? process.env?.NODE_ENV : undefined;\n if (typeof nodeEnv !== \"string\") {\n return false;\n }\n\n return nodeEnv !== \"production\";\n};\n\nconst resolveWindowTargetOrigin = (): string => {\n if (typeof window === \"undefined\") {\n return \"*\";\n }\n\n return window.location.origin === \"null\" ? \"*\" : window.location.origin;\n};\n\n// No session token infrastructure needed\n\n/**\n * Validates that the message origin matches the current window origin.\n * This prevents messages from other origins from being processed.\n *\n * Note: This is part of defense-in-depth but not a hard security boundary.\n * Code running in the same origin can still send messages.\n */\nconst isExpectedWindowOrigin = (origin: string): boolean => {\n if (origin.length === 0) {\n return false;\n }\n\n if (typeof window === \"undefined\") {\n return false;\n }\n\n const expected = window.location.origin;\n if (expected === \"null\") {\n // For file:// or sandboxed contexts where origin is \"null\"\n return origin === \"null\";\n }\n\n // Strict equality check - no wildcard matching\n return origin === expected;\n};\n\nconst createMachineId = (): string =>\n `journey-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n\n/**\n * Simple rate limiter to prevent command abuse.\n * Tracks command timestamps and enforces a maximum rate.\n */\nclass CommandRateLimiter {\n private commandTimestamps: number[] = [];\n private readonly maxCommandsPerWindow: number;\n private readonly windowMs: number;\n\n constructor(maxCommandsPerWindow = 100, windowMs = 10000) {\n this.maxCommandsPerWindow = maxCommandsPerWindow;\n this.windowMs = windowMs;\n }\n\n /**\n * Checks if a command is allowed based on rate limits.\n * Returns true if allowed, false if rate limit exceeded.\n */\n isAllowed(): boolean {\n const now = Date.now();\n const windowStart = now - this.windowMs;\n\n // Remove old timestamps outside the window\n this.commandTimestamps = this.commandTimestamps.filter((ts) => ts > windowStart);\n\n if (this.commandTimestamps.length >= this.maxCommandsPerWindow) {\n return false;\n }\n\n this.commandTimestamps.push(now);\n return true;\n }\n\n reset(): void {\n this.commandTimestamps = [];\n }\n}\n\nconst cloneForTransport = (value: unknown): unknown => {\n if (typeof structuredClone === \"function\") {\n try {\n return structuredClone(value);\n } catch {\n // Fall through to the JSON serializer below.\n }\n }\n\n const seen = new WeakSet<object>();\n\n try {\n const serialized = JSON.stringify(value, (_key, currentValue) => {\n if (typeof currentValue === \"bigint\") {\n return currentValue.toString();\n }\n if (typeof currentValue === \"function\") {\n return `[Function ${currentValue.name || \"anonymous\"}]`;\n }\n if (typeof currentValue === \"symbol\") {\n return currentValue.toString();\n }\n if (typeof currentValue === \"object\" && currentValue !== null) {\n if (seen.has(currentValue)) {\n return \"[Circular]\";\n }\n seen.add(currentValue);\n }\n return currentValue;\n });\n\n if (serialized === undefined) {\n return undefined;\n }\n\n return JSON.parse(serialized) as unknown;\n } catch {\n return String(value);\n }\n};\n\nconst serializeError = (error: unknown): JourneyDevtoolsSerializedError => {\n if (error instanceof Error) {\n const cause =\n \"cause\" in error && (error as { cause?: unknown }).cause !== undefined\n ? (error as { cause?: unknown }).cause\n : null;\n return {\n name: error.name,\n message: error.message,\n stack: typeof error.stack === \"string\" ? error.stack : null,\n cause: cloneForTransport(cause)\n };\n }\n\n return {\n name: null,\n message: typeof error === \"string\" ? error : \"Unknown error\",\n stack: null,\n cause: cloneForTransport(error)\n };\n};\n\nconst serializeSnapshot = <TContext, TStepId extends string, TStepMeta>(\n snapshot: JourneySnapshot<TContext, TStepId, TStepMeta>\n): JourneyDevtoolsSerializableSnapshot => {\n const byStep: Record<string, JourneyDevtoolsSerializableSnapshot[\"async\"][\"byStep\"][string]> = {};\n\n for (const [stepId, stepState] of Object.entries(\n snapshot.async.byStep as Record<string, unknown>\n )) {\n if (!isRecord(stepState)) {\n continue;\n }\n\n byStep[stepId] = {\n phase: isJourneyAsyncPhase(stepState.phase) ? stepState.phase : \"idle\",\n eventType: typeof stepState.eventType === \"string\" ? stepState.eventType : null,\n transitionId: typeof stepState.transitionId === \"string\" ? stepState.transitionId : null,\n error: stepState.error === null ? null : cloneForTransport(stepState.error)\n };\n }\n\n return {\n currentStepId: String(snapshot.currentStepId),\n context: cloneForTransport(snapshot.context),\n history: {\n timeline: snapshot.history.timeline.map((stepId) => String(stepId)),\n index: snapshot.history.index\n },\n visited: Object.fromEntries(\n Object.entries(snapshot.visited as Record<string, boolean>).map(([stepId, isVisited]) => [\n String(stepId),\n isVisited === true\n ])\n ),\n stepMeta: cloneForTransport(snapshot.stepMeta) as Record<string, unknown>,\n status: snapshot.status,\n async: {\n isLoading: snapshot.async.isLoading,\n byStep\n }\n };\n};\n\nconst runCommand = async <TContext, TStepId extends string, TStepMeta>(\n machine: JourneyMachine<TContext, TStepId, string, Record<never, never>, TStepMeta>,\n command: JourneyDevtoolsCommand\n): Promise<SendOutcome<TContext, TStepId, TStepMeta>> => {\n switch (command.type) {\n case \"goToNextStep\":\n case \"completeJourney\": {\n const result = await machine.send({ type: command.type } as JourneySendEvent<TStepId>);\n return {\n snapshot: result.snapshot,\n transitioned: result.transitioned,\n ...(result.transitionId ? { transitionId: result.transitionId } : {})\n };\n }\n case \"terminateMachine\": {\n const result = await machine.send({ type: \"terminateJourney\" } as JourneySendEvent<TStepId>);\n return {\n snapshot: result.snapshot,\n transitioned: result.transitioned,\n ...(result.transitionId ? { transitionId: result.transitionId } : {})\n };\n }\n case \"goToStepById\": {\n const result = await machine.send({\n type: \"goToStepById\",\n stepId: command.stepId\n } as JourneySendEvent<TStepId>);\n return {\n snapshot: result.snapshot,\n transitioned: result.transitioned,\n ...(result.transitionId ? { transitionId: result.transitionId } : {})\n };\n }\n case \"goToPreviousStep\": {\n const result = await machine.goToPreviousStep(command.steps);\n return {\n snapshot: result.snapshot,\n transitioned: result.transitioned,\n ...(result.transitionId ? { transitionId: result.transitionId } : {})\n };\n }\n case \"goToLastVisitedStep\": {\n const result = await machine.goToLastVisitedStep();\n return {\n snapshot: result.snapshot,\n transitioned: result.transitioned,\n ...(result.transitionId ? { transitionId: result.transitionId } : {})\n };\n }\n case \"send\": {\n const sendEvent =\n command.event.payload === undefined\n ? { type: command.event.type }\n : { type: command.event.type, payload: command.event.payload };\n const result: JourneySendResult<TContext, TStepId, TStepMeta> = await machine.send(\n sendEvent as JourneySendEvent<TStepId>\n );\n return {\n snapshot: result.snapshot,\n transitioned: result.transitioned,\n ...(result.transitionId ? { transitionId: result.transitionId } : {})\n };\n }\n case \"updateStepMetadata\":\n return {\n snapshot: machine.updateStepMetadata(\n command.stepId as TStepId,\n () => command.metadata as TStepMeta\n )\n };\n case \"resetMachine\":\n return {\n snapshot: machine.resetMachine()\n };\n case \"clearStepError\":\n return {\n snapshot: machine.clearStepError(command.stepId as TStepId | undefined)\n };\n }\n};\n\nexport const attachJourneyDevtools = <\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType>,\n TStepMeta\n>(\n machine: JourneyMachine<TContext, TStepId, TEventType, TPayloadMap, TStepMeta>,\n options: JourneyDevtoolsBridgeOptions = {}\n): (() => void) => {\n const enabled = options.enabled ?? resolveDefaultEnabled();\n if (!enabled || typeof window === \"undefined\") {\n return () => {};\n }\n const commandsEnabled = options.commandsEnabled ?? resolveDefaultCommandsEnabled();\n\n const machineId = options.machineId?.trim() || createMachineId();\n const meta: JourneyDevtoolsMachineMeta = {\n machineId,\n label: options.label?.trim() || DEFAULT_MACHINE_LABEL,\n appName:\n options.appName?.trim() || (typeof document !== \"undefined\" ? document.title : \"\") || null,\n commandsEnabled\n };\n const targetOrigin = resolveWindowTargetOrigin();\n\n const createBaseEnvelope = <TKind extends JourneyDevtoolsBridgeEnvelope[\"kind\"]>(\n kind: TKind\n ) => ({\n channel: JOURNEY_DEVTOOLS_CHANNEL,\n version: JOURNEY_DEVTOOLS_PROTOCOL_VERSION,\n source: JOURNEY_DEVTOOLS_BRIDGE_SOURCE,\n kind,\n machineId,\n timestamp: Date.now()\n });\n\n const post = (envelope: JourneyDevtoolsBridgeEnvelope) => {\n window.postMessage(envelope, targetOrigin);\n };\n\n const postSnapshot = (snapshot: JourneySnapshot<TContext, TStepId, TStepMeta>) => {\n const envelope: JourneyDevtoolsBridgeSnapshotEnvelope = {\n ...createBaseEnvelope(\"snapshot\"),\n snapshot: serializeSnapshot(snapshot)\n };\n post(envelope);\n };\n\n let isDetached = false;\n const rateLimiter = new CommandRateLimiter();\n\n const onMessage = (event: MessageEvent<unknown>) => {\n if (\n event.source !== window ||\n !isExpectedWindowOrigin(event.origin) ||\n isDetached ||\n !isJourneyDevtoolsEnvelope(event.data)\n ) {\n return;\n }\n\n if (event.data.source !== JOURNEY_DEVTOOLS_EXTENSION_SOURCE || event.data.kind !== \"command\") {\n return;\n }\n\n const commandEnvelope: JourneyDevtoolsExtensionCommandEnvelope = event.data;\n if (commandEnvelope.machineId !== machineId) {\n return;\n }\n\n // Rate limiting to prevent command abuse\n if (!rateLimiter.isAllowed()) {\n const errorEnvelope: JourneyDevtoolsBridgeCommandErrorEnvelope = {\n ...createBaseEnvelope(\"commandError\"),\n requestId: commandEnvelope.requestId,\n error: serializeError(\n \"Command rate limit exceeded. Too many commands in a short time window.\"\n )\n };\n post(errorEnvelope);\n return;\n }\n\n if (!commandsEnabled) {\n const errorEnvelope: JourneyDevtoolsBridgeCommandErrorEnvelope = {\n ...createBaseEnvelope(\"commandError\"),\n requestId: commandEnvelope.requestId,\n error: serializeError(\"Bridge commands are disabled by configuration.\")\n };\n post(errorEnvelope);\n return;\n }\n\n const run = async () => {\n try {\n const outcome = await runCommand(\n machine as JourneyMachine<TContext, TStepId, string, Record<never, never>, TStepMeta>,\n commandEnvelope.command\n );\n if (isDetached) {\n return;\n }\n\n const resultEnvelope: JourneyDevtoolsBridgeCommandResultEnvelope = {\n ...createBaseEnvelope(\"commandResult\"),\n requestId: commandEnvelope.requestId,\n snapshot: serializeSnapshot(outcome.snapshot),\n ...(outcome.transitioned !== undefined ? { transitioned: outcome.transitioned } : {}),\n ...(outcome.transitionId ? { transitionId: outcome.transitionId } : {})\n };\n post(resultEnvelope);\n } catch (error) {\n if (isDetached) {\n return;\n }\n\n const errorEnvelope: JourneyDevtoolsBridgeCommandErrorEnvelope = {\n ...createBaseEnvelope(\"commandError\"),\n requestId: commandEnvelope.requestId,\n error: serializeError(error)\n };\n post(errorEnvelope);\n }\n };\n\n void run();\n };\n\n window.addEventListener(\"message\", onMessage);\n\n const unsubscribe = machine.subscribe(() => {\n if (isDetached) {\n return;\n }\n postSnapshot(machine.getSnapshot());\n });\n\n const registerEnvelope: JourneyDevtoolsBridgeRegisterEnvelope = {\n ...createBaseEnvelope(\"register\"),\n meta,\n snapshot: serializeSnapshot(machine.getSnapshot())\n };\n post(registerEnvelope);\n\n return () => {\n if (isDetached) {\n return;\n }\n\n isDetached = true;\n rateLimiter.reset();\n unsubscribe();\n window.removeEventListener(\"message\", onMessage);\n\n const unregisterEnvelope: JourneyDevtoolsBridgeUnregisterEnvelope = {\n ...createBaseEnvelope(\"unregister\")\n };\n post(unregisterEnvelope);\n };\n};\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oCAAAE,EAAA,6BAAAC,EAAA,sCAAAC,EAAA,sCAAAC,EAAA,0BAAAC,EAAA,oCAAAC,EAAA,6BAAAC,EAAA,8BAAAC,EAAA,uCAAAC,IAAA,eAAAC,EAAAX,GCEO,IAAMY,EAAoC,EACpCC,EAA2B,6BAE3BC,EAAiC,uBACjCC,EAAoC,0BAmG3CC,EAAYC,GAChB,OAAOA,GAAU,UAAYA,IAAU,KAEnCC,EAAiBD,GACrBA,IAAUH,GAAkCG,IAAUF,EAkBxD,IAAMI,EAAgB,CAACC,EAAgBC,EAAQ,IAAe,CAC5D,GAAIA,EAAQ,GACV,MAAO,GAQT,GALID,GAAU,MAIS,CAAC,SAAU,SAAU,SAAS,EAClC,SAAS,OAAOA,CAAK,EACtC,MAAO,GAGT,GAAI,OAAOA,GAAU,SAAU,CAE7B,GAAI,CAEF,GADmB,KAAK,UAAUA,CAAK,EACxB,OAAS,IACtB,MAAO,EAEX,MAAQ,CAEN,M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U,MAAM1B,EACpBC,EACAuB,EAAgB,OAClB,EACA,GAAIN,EACF,OAGF,IAAMS,EAA6D,CACjE,GAAGhB,EAAmB,eAAe,EACrC,UAAWa,EAAgB,UAC3B,SAAU9B,EAAkBgC,EAAQ,QAAQ,EAC5C,GAAIA,EAAQ,eAAiB,OAAY,CAAE,aAAcA,EAAQ,YAAa,EAAI,CAAC,EACnF,GAAIA,EAAQ,aAAe,CAAE,aAAcA,EAAQ,YAAa,EAAI,CAAC,CACvE,EACAX,EAAKY,CAAc,CACrB,OAASnC,EAAO,CACd,GAAI0B,EACF,OAGF,IAAMO,EAA2D,CAC/D,GAAGd,EAAmB,cAAc,EACpC,UAAWa,EAAgB,UAC3B,MAAOjC,EAAeC,CAAK,CAC7B,EACAuB,EAAKU,CAAa,CACpB,CACF,GAES,CACX,EAEA,OAAO,iBAAiB,UAAWL,CAAS,EAE5C,IAAMQ,EAAc3B,EAAQ,UAAU,IAAM,CACtCiB,GAGJD,EAAahB,EAAQ,YAAY,CAAC,CACpC,CAAC,EAEK4B,EAA0D,CAC9D,GAAGlB,EAAmB,UAAU,EAChC,KAAAF,EACA,SAAUf,EAAkBO,EAAQ,YAAY,CAAC,CACnD,EACA,OAAAc,EAAKc,CAAgB,EAEd,IAAM,CACX,GAAIX,EACF,OAGFA,EAAa,GACbC,EAAY,MAAM,EAClBS,EAAY,EACZ,OAAO,oBAAoB,UAAWR,CAAS,EAE/C,IAAMU,EAA8D,CAClE,GAAGnB,EAAmB,YAAY,CACpC,EACAI,EAAKe,CAAkB,CACzB,CACF",
|
|
6
|
+
"names": ["index_exports", "__export", "JOURNEY_DEVTOOLS_BRIDGE_SOURCE", "JOURNEY_DEVTOOLS_CHANNEL", "JOURNEY_DEVTOOLS_EXTENSION_SOURCE", "JOURNEY_DEVTOOLS_PROTOCOL_VERSION", "attachJourneyDevtools", "isJourneyDevtoolsBridgeEnvelope", "isJourneyDevtoolsCommand", "isJourneyDevtoolsEnvelope", "isJourneyDevtoolsExtensionEnvelope", "__toCommonJS", "JOURNEY_DEVTOOLS_PROTOCOL_VERSION", "JOURNEY_DEVTOOLS_CHANNEL", "JOURNEY_DEVTOOLS_BRIDGE_SOURCE", "JOURNEY_DEVTOOLS_EXTENSION_SOURCE", "isRecord", "value", "isKnownSource", "isSafePayload", "value", "depth", "item", "prop", "hasBaseEnvelopeShape", "isRecord", "JOURNEY_DEVTOOLS_CHANNEL", "isKnownSource", "isSendEvent", "isJourneyDevtoolsCommand", "isJourneyDevtoolsBridgeEnvelope", "JOURNEY_DEVTOOLS_BRIDGE_SOURCE", "envelope", "isJourneyDevtoolsExtensionEnvelope", "JOURNEY_DEVTOOLS_EXTENSION_SOURCE", "isJourneyDevtoolsEnvelope", "DEFAULT_MACHINE_LABEL", "isRecord", "value", "isJourneyAsyncPhase", "resolveDefaultEnabled", "nodeEnv", "resolveDefaultCommandsEnabled", "resolveWindowTargetOrigin", "isExpectedWindowOrigin", "origin", "expected", "createMachineId", "CommandRateLimiter", "maxCommandsPerWindow", "windowMs", "now", "windowStart", "ts", "cloneForTransport", "seen", "serialized", "_key", "currentValue", "serializeError", "error", "cause", "serializeSnapshot", "snapshot", "byStep", "stepId", "stepState", "isVisited", "runCommand", "machine", "command", "result", "sendEvent", "attachJourneyDevtools", "options", "commandsEnabled", "machineId", "meta", "targetOrigin", "createBaseEnvelope", "kind", "JOURNEY_DEVTOOLS_CHANNEL", "JOURNEY_DEVTOOLS_BRIDGE_SOURCE", "post", "envelope", "postSnapshot", "isDetached", "rateLimiter", "onMessage", "event", "isJourneyDevtoolsEnvelope", "JOURNEY_DEVTOOLS_EXTENSION_SOURCE", "commandEnvelope", "errorEnvelope", "outcome", "resultEnvelope", "unsubscribe", "registerEnvelope", "unregisterEnvelope"]
|
|
7
7
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export { attachJourneyDevtools, type JourneyDevtoolsBridgeOptions } from "./bridge";
|
|
2
2
|
export { JOURNEY_DEVTOOLS_CHANNEL, JOURNEY_DEVTOOLS_PROTOCOL_VERSION, JOURNEY_DEVTOOLS_BRIDGE_SOURCE, JOURNEY_DEVTOOLS_EXTENSION_SOURCE, isJourneyDevtoolsCommand, isJourneyDevtoolsEnvelope, isJourneyDevtoolsBridgeEnvelope, isJourneyDevtoolsExtensionEnvelope, type JourneyDevtoolsBridgeCommandErrorEnvelope, type JourneyDevtoolsBridgeCommandResultEnvelope, type JourneyDevtoolsBridgeEnvelope, type JourneyDevtoolsBridgeRegisterEnvelope, type JourneyDevtoolsBridgeSnapshotEnvelope, type JourneyDevtoolsBridgeUnregisterEnvelope, type JourneyDevtoolsCommand, type JourneyDevtoolsEnvelope, type JourneyDevtoolsExtensionEnvelope, type JourneyDevtoolsExtensionCommandEnvelope, type JourneyDevtoolsMachineMeta, type JourneyDevtoolsSerializableSnapshot, type JourneyDevtoolsSerializedError } from "./protocol";
|
|
3
|
-
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export { attachJourneyDevtools, type JourneyDevtoolsBridgeOptions } from "./bridge";
|
|
2
2
|
export { JOURNEY_DEVTOOLS_CHANNEL, JOURNEY_DEVTOOLS_PROTOCOL_VERSION, JOURNEY_DEVTOOLS_BRIDGE_SOURCE, JOURNEY_DEVTOOLS_EXTENSION_SOURCE, isJourneyDevtoolsCommand, isJourneyDevtoolsEnvelope, isJourneyDevtoolsBridgeEnvelope, isJourneyDevtoolsExtensionEnvelope, type JourneyDevtoolsBridgeCommandErrorEnvelope, type JourneyDevtoolsBridgeCommandResultEnvelope, type JourneyDevtoolsBridgeEnvelope, type JourneyDevtoolsBridgeRegisterEnvelope, type JourneyDevtoolsBridgeSnapshotEnvelope, type JourneyDevtoolsBridgeUnregisterEnvelope, type JourneyDevtoolsCommand, type JourneyDevtoolsEnvelope, type JourneyDevtoolsExtensionEnvelope, type JourneyDevtoolsExtensionCommandEnvelope, type JourneyDevtoolsMachineMeta, type JourneyDevtoolsSerializableSnapshot, type JourneyDevtoolsSerializedError } from "./protocol";
|
|
3
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var v=3,S="__RXOVA_JOURNEY_DEVTOOLS__",c="rxova-journey-bridge",E="rxova-journey-extension",p=e=>typeof e=="object"&&e!==null,M=e=>e===c||e===E;var d=(e,t=0)=>{if(t>10)return!1;if(e==null||["string","number","boolean"].includes(typeof e))return!0;if(typeof e=="object"){try{if(JSON.stringify(e).length>5e5)return!1}catch{return!1}return Array.isArray(e)?e.every(o=>d(o,t+1)):Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null?!1:Object.values(e).every(o=>d(o,t+1))}return!1},I=e=>p(e)?e.channel===S&&e.version===3&&M(e.source)&&typeof e.kind=="string"&&typeof e.machineId=="string"&&typeof e.timestamp=="number":!1,k=e=>!p(e)||typeof e.type!="string"||e.type.length===0||e.type.length>100?!1:"payload"in e&&e.payload!==void 0?d(e.payload):!0,w=e=>{if(!p(e)||typeof e.type!="string"||e.type.length===0||e.type.length>50)return!1;switch(e.type){case"goToNextStep":case"terminateMachine":case"completeJourney":case"resetMachine":case"goToLastVisitedStep":return Object.keys(e).length===1;case"goToStepById":return typeof e.stepId=="string"&&e.stepId.length>0&&e.stepId.length<=100&&Object.keys(e).length===2;case"goToPreviousStep":return(e.steps===void 0||typeof e.steps=="number"&&Number.isInteger(e.steps)&&e.steps>=1&&e.steps<=1e4)&&Object.keys(e).length<=2;case"send":return k(e.event)&&Object.keys(e).length===2;case"updateStepMetadata":return typeof e.stepId=="string"&&e.stepId.length>0&&e.stepId.length<=100&&d(e.metadata)&&Object.keys(e).length===3;case"clearStepError":return(e.stepId===void 0||typeof e.stepId=="string"&&e.stepId.length<=100)&&Object.keys(e).length<=2;default:return!1}},_=e=>{if(!I(e)||e.source!==c)return!1;let t=e;switch(e.kind){case"register":return p(t.meta)&&p(t.snapshot)&&d(t.meta)&&d(t.snapshot);case"unregister":return!0;case"snapshot":return p(t.snapshot)&&d(t.snapshot);case"commandResult":return typeof t.requestId=="string"&&t.requestId.length>0&&t.requestId.length<=100&&p(t.snapshot)&&d(t.snapshot);case"commandError":return typeof t.requestId=="string"&&t.requestId.length>0&&t.requestId.length<=100&&p(t.error);default:return!1}},R=e=>{if(!I(e)||e.source!==E||e.kind!=="command")return!1;let t=e;return typeof t.requestId=="string"&&t.requestId.length>0&&t.requestId.length<=100&&w(t.command)},J=e=>_(e)||R(e);var L="Journey Machine",U=e=>typeof e=="object"&&e!==null,A=e=>e==="idle"||e==="evaluating-when"||e==="running-effect"||e==="error",P=()=>{let e=typeof process<"u"?process.env?.NODE_ENV:void 0;return typeof e!="string"?!1:e!=="production"},Y=()=>{let e=typeof process<"u"?process.env?.NODE_ENV:void 0;return typeof e!="string"?!1:e!=="production"},V=()=>typeof window>"u"||window.location.origin==="null"?"*":window.location.origin,j=e=>{if(e.length===0||typeof window>"u")return!1;let t=window.location.origin;return t==="null"?e==="null":e===t},q=()=>`journey-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`,O=class{constructor(t=100,n=1e4){this.commandTimestamps=[];this.maxCommandsPerWindow=t,this.windowMs=n}isAllowed(){let t=Date.now(),n=t-this.windowMs;return this.commandTimestamps=this.commandTimestamps.filter(o=>o>n),this.commandTimestamps.length>=this.maxCommandsPerWindow?!1:(this.commandTimestamps.push(t),!0)}reset(){this.commandTimestamps=[]}},g=e=>{if(typeof structuredClone=="function")try{return structuredClone(e)}catch{}let t=new WeakSet;try{let n=JSON.stringify(e,(o,r)=>{if(typeof r=="bigint")return r.toString();if(typeof r=="function")return`[Function ${r.name||"anonymous"}]`;if(typeof r=="symbol")return r.toString();if(typeof r=="object"&&r!==null){if(t.has(r))return"[Circular]";t.add(r)}return r});return n===void 0?void 0:JSON.parse(n)}catch{return String(e)}},f=e=>{if(e instanceof Error){let t="cause"in e&&e.cause!==void 0?e.cause:null;return{name:e.name,message:e.message,stack:typeof e.stack=="string"?e.stack:null,cause:g(t)}}return{name:null,message:typeof e=="string"?e:"Unknown error",stack:null,cause:g(e)}},D=e=>{let t={};for(let[n,o]of Object.entries(e.async.byStep))U(o)&&(t[n]={phase:A(o.phase)?o.phase:"idle",eventType:typeof o.eventType=="string"?o.eventType:null,transitionId:typeof o.transitionId=="string"?o.transitionId:null,error:o.error===null?null:g(o.error)});return{currentStepId:String(e.currentStepId),context:g(e.context),history:{timeline:e.history.timeline.map(n=>String(n)),index:e.history.index},visited:Object.fromEntries(Object.entries(e.visited).map(([n,o])=>[String(n),o===!0])),stepMeta:g(e.stepMeta),status:e.status,async:{isLoading:e.async.isLoading,byStep:t}}},z=async(e,t)=>{switch(t.type){case"goToNextStep":case"completeJourney":{let n=await e.send({type:t.type});return{snapshot:n.snapshot,transitioned:n.transitioned,...n.transitionId?{transitionId:n.transitionId}:{}}}case"terminateMachine":{let n=await e.send({type:"terminateJourney"});return{snapshot:n.snapshot,transitioned:n.transitioned,...n.transitionId?{transitionId:n.transitionId}:{}}}case"goToStepById":{let n=await e.send({type:"goToStepById",stepId:t.stepId});return{snapshot:n.snapshot,transitioned:n.transitioned,...n.transitionId?{transitionId:n.transitionId}:{}}}case"goToPreviousStep":{let n=await e.goToPreviousStep(t.steps);return{snapshot:n.snapshot,transitioned:n.transitioned,...n.transitionId?{transitionId:n.transitionId}:{}}}case"goToLastVisitedStep":{let n=await e.goToLastVisitedStep();return{snapshot:n.snapshot,transitioned:n.transitioned,...n.transitionId?{transitionId:n.transitionId}:{}}}case"send":{let n=t.event.payload===void 0?{type:t.event.type}:{type:t.event.type,payload:t.event.payload},o=await e.send(n);return{snapshot:o.snapshot,transitioned:o.transitioned,...o.transitionId?{transitionId:o.transitionId}:{}}}case"updateStepMetadata":return{snapshot:e.updateStepMetadata(t.stepId,()=>t.metadata)};case"resetMachine":return{snapshot:e.resetMachine()};case"clearStepError":return{snapshot:e.clearStepError(t.stepId)}}},X=(e,t={})=>{if(!(t.enabled??P())||typeof window>"u")return()=>{};let o=t.commandsEnabled??Y(),r=t.machineId?.trim()||q(),x={machineId:r,label:t.label?.trim()||L,appName:t.appName?.trim()||(typeof document<"u"?document.title:"")||null,commandsEnabled:o},b=V(),u=s=>({channel:S,version:3,source:c,kind:s,machineId:r,timestamp:Date.now()}),l=s=>{window.postMessage(s,b)},C=s=>{let a={...u("snapshot"),snapshot:D(s)};l(a)},y=!1,h=new O,T=s=>{if(s.source!==window||!j(s.origin)||y||!J(s.data)||s.data.source!==E||s.data.kind!=="command")return;let a=s.data;if(a.machineId!==r)return;if(!h.isAllowed()){let i={...u("commandError"),requestId:a.requestId,error:f("Command rate limit exceeded. Too many commands in a short time window.")};l(i);return}if(!o){let i={...u("commandError"),requestId:a.requestId,error:f("Bridge commands are disabled by configuration.")};l(i);return}(async()=>{try{let i=await z(e,a.command);if(y)return;let m={...u("commandResult"),requestId:a.requestId,snapshot:D(i.snapshot),...i.transitioned!==void 0?{transitioned:i.transitioned}:{},...i.transitionId?{transitionId:i.transitionId}:{}};l(m)}catch(i){if(y)return;let m={...u("commandError"),requestId:a.requestId,error:f(i)};l(m)}})()};window.addEventListener("message",T);let N=e.subscribe(()=>{y||C(e.getSnapshot())}),B={...u("register"),meta:x,snapshot:D(e.getSnapshot())};return l(B),()=>{if(y)return;y=!0,h.reset(),N(),window.removeEventListener("message",T);let s={...u("unregister")};l(s)}};export{c as JOURNEY_DEVTOOLS_BRIDGE_SOURCE,S as JOURNEY_DEVTOOLS_CHANNEL,E as JOURNEY_DEVTOOLS_EXTENSION_SOURCE,v as JOURNEY_DEVTOOLS_PROTOCOL_VERSION,X as attachJourneyDevtools,_ as isJourneyDevtoolsBridgeEnvelope,w as isJourneyDevtoolsCommand,J as isJourneyDevtoolsEnvelope,R as isJourneyDevtoolsExtensionEnvelope};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/protocol.ts", "../src/bridge.ts"],
|
|
4
|
-
"sourcesContent": ["import type { JourneySnapshot, JourneyStepAsyncState } from \"@rxova/journey-core\";\n\nexport const JOURNEY_DEVTOOLS_PROTOCOL_VERSION = 1 as const;\nexport const JOURNEY_DEVTOOLS_CHANNEL = \"__RXOVA_JOURNEY_DEVTOOLS__\" as const;\n\nexport const JOURNEY_DEVTOOLS_BRIDGE_SOURCE = \"rxova-journey-bridge\" as const;\nexport const JOURNEY_DEVTOOLS_EXTENSION_SOURCE = \"rxova-journey-extension\" as const;\n\nexport type JourneyDevtoolsSource =\n | typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE\n | typeof JOURNEY_DEVTOOLS_EXTENSION_SOURCE;\n\nexport type JourneyDevtoolsStepAsyncState = JourneyStepAsyncState;\n\nexport type JourneyDevtoolsSerializableSnapshot = JourneySnapshot<unknown, string>;\n\nexport type JourneyDevtoolsMachineMeta = {\n machineId: string;\n label: string;\n appName: string | null;\n commandsEnabled?: boolean;\n};\n\nexport type JourneyDevtoolsSerializedError = {\n name: string | null;\n message: string;\n stack: string | null;\n cause: unknown;\n};\n\nexport type JourneyDevtoolsCommand =\n | { type: \"next\" }\n | { type: \"back\" }\n | { type: \"close\" }\n | { type: \"submit\" }\n | { type: \"goTo\"; to: string }\n | { type: \"send\"; event: { type: string; payload?: unknown } }\n | { type: \"reset\" }\n | { type: \"clearStepError\"; stepId?: string }\n | { type: \"clearHistory\" }\n | { type: \"trimHistory\"; maxHistory?: number | null };\n\nexport type JourneyDevtoolsEnvelopeBase = {\n channel: typeof JOURNEY_DEVTOOLS_CHANNEL;\n version: typeof JOURNEY_DEVTOOLS_PROTOCOL_VERSION;\n source: JourneyDevtoolsSource;\n kind: string;\n machineId: string;\n timestamp: number;\n};\n\nexport type JourneyDevtoolsBridgeRegisterEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"register\";\n meta: JourneyDevtoolsMachineMeta;\n snapshot: JourneyDevtoolsSerializableSnapshot;\n};\n\nexport type JourneyDevtoolsBridgeUnregisterEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"unregister\";\n};\n\nexport type JourneyDevtoolsBridgeSnapshotEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"snapshot\";\n snapshot: JourneyDevtoolsSerializableSnapshot;\n};\n\nexport type JourneyDevtoolsBridgeCommandResultEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"commandResult\";\n requestId: string;\n snapshot: JourneyDevtoolsSerializableSnapshot;\n transitioned?: boolean;\n transitionId?: string;\n};\n\nexport type JourneyDevtoolsBridgeCommandErrorEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"commandError\";\n requestId: string;\n error: JourneyDevtoolsSerializedError;\n};\n\nexport type JourneyDevtoolsExtensionCommandEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_EXTENSION_SOURCE;\n kind: \"command\";\n requestId: string;\n command: JourneyDevtoolsCommand;\n};\n\nexport type JourneyDevtoolsBridgeEnvelope =\n | JourneyDevtoolsBridgeRegisterEnvelope\n | JourneyDevtoolsBridgeUnregisterEnvelope\n | JourneyDevtoolsBridgeSnapshotEnvelope\n | JourneyDevtoolsBridgeCommandResultEnvelope\n | JourneyDevtoolsBridgeCommandErrorEnvelope;\n\nexport type JourneyDevtoolsExtensionEnvelope = JourneyDevtoolsExtensionCommandEnvelope;\n\nexport type JourneyDevtoolsEnvelope =\n | JourneyDevtoolsBridgeEnvelope\n | JourneyDevtoolsExtensionEnvelope;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isKnownSource = (value: unknown): value is JourneyDevtoolsSource =>\n value === JOURNEY_DEVTOOLS_BRIDGE_SOURCE || value === JOURNEY_DEVTOOLS_EXTENSION_SOURCE;\n\n/**\n * Maximum depth for nested object validation.\n * Prevents stack overflow and excessive processing from deeply nested malicious payloads.\n */\nconst MAX_PAYLOAD_DEPTH = 10;\n\n/**\n * Maximum size (in JSON string length) for serialized payloads.\n * Prevents memory exhaustion from extremely large payloads.\n */\nconst MAX_PAYLOAD_SIZE = 500_000; // 500KB\n\n/**\n * Validates that a value is safe for transport.\n * Checks depth and size constraints to prevent malicious payloads.\n */\nconst isSafePayload = (value: unknown, depth = 0): boolean => {\n if (depth > MAX_PAYLOAD_DEPTH) {\n return false;\n }\n\n if (value === null || value === undefined) {\n return true;\n }\n\n const primitiveTypes = [\"string\", \"number\", \"boolean\"];\n if (primitiveTypes.includes(typeof value)) {\n return true;\n }\n\n if (typeof value === \"object\") {\n // Check JSON serialization size\n try {\n const serialized = JSON.stringify(value);\n if (serialized.length > MAX_PAYLOAD_SIZE) {\n return false;\n }\n } catch {\n // Circular references or non-serializable objects are not safe\n return false;\n }\n\n // Recursively validate nested objects and arrays\n if (Array.isArray(value)) {\n return value.every((item) => isSafePayload(item, depth + 1));\n }\n\n // Validate plain objects (guard against prototype pollution)\n if (\n Object.getPrototypeOf(value) !== Object.prototype &&\n Object.getPrototypeOf(value) !== null\n ) {\n return false;\n }\n\n return Object.values(value).every((prop) => isSafePayload(prop, depth + 1));\n }\n\n // Reject functions, symbols, and other non-serializable types\n return false;\n};\n\nconst hasBaseEnvelopeShape = (value: unknown): value is JourneyDevtoolsEnvelopeBase => {\n if (!isRecord(value)) {\n return false;\n }\n\n return (\n value.channel === JOURNEY_DEVTOOLS_CHANNEL &&\n value.version === JOURNEY_DEVTOOLS_PROTOCOL_VERSION &&\n isKnownSource(value.source) &&\n typeof value.kind === \"string\" &&\n typeof value.machineId === \"string\" &&\n typeof value.timestamp === \"number\"\n );\n};\n\nconst isSendEvent = (value: unknown): value is { type: string; payload?: unknown } => {\n if (!isRecord(value)) {\n return false;\n }\n\n if (typeof value.type !== \"string\" || value.type.length === 0 || value.type.length > 100) {\n return false;\n }\n\n // Validate payload if present\n if (\"payload\" in value && value.payload !== undefined) {\n return isSafePayload(value.payload);\n }\n\n return true;\n};\n\nexport const isJourneyDevtoolsCommand = (value: unknown): value is JourneyDevtoolsCommand => {\n if (!isRecord(value) || typeof value.type !== \"string\") {\n return false;\n }\n\n // Validate command type is within reasonable length\n if (value.type.length === 0 || value.type.length > 50) {\n return false;\n }\n\n switch (value.type) {\n case \"next\":\n case \"back\":\n case \"close\":\n case \"submit\":\n case \"reset\":\n case \"clearHistory\":\n // These commands should have no extra properties beyond type\n return Object.keys(value).length === 1;\n case \"goTo\":\n return (\n typeof value.to === \"string\" &&\n value.to.length > 0 &&\n value.to.length <= 100 &&\n Object.keys(value).length === 2\n );\n case \"send\":\n return isSendEvent(value.event) && Object.keys(value).length === 2;\n case \"clearStepError\":\n return (\n (value.stepId === undefined ||\n (typeof value.stepId === \"string\" && value.stepId.length <= 100)) &&\n Object.keys(value).length <= 2\n );\n case \"trimHistory\":\n return (\n (value.maxHistory === undefined ||\n value.maxHistory === null ||\n (typeof value.maxHistory === \"number\" &&\n Number.isInteger(value.maxHistory) &&\n value.maxHistory >= 0 &&\n value.maxHistory <= 10000)) &&\n Object.keys(value).length <= 2\n );\n default:\n return false;\n }\n};\n\nexport const isJourneyDevtoolsBridgeEnvelope = (\n value: unknown\n): value is JourneyDevtoolsBridgeEnvelope => {\n if (!hasBaseEnvelopeShape(value) || value.source !== JOURNEY_DEVTOOLS_BRIDGE_SOURCE) {\n return false;\n }\n\n const envelope = value as Record<string, unknown>;\n\n switch (value.kind) {\n case \"register\":\n return (\n isRecord(envelope.meta) &&\n isRecord(envelope.snapshot) &&\n isSafePayload(envelope.meta) &&\n isSafePayload(envelope.snapshot)\n );\n case \"unregister\":\n return true;\n case \"snapshot\":\n return isRecord(envelope.snapshot) && isSafePayload(envelope.snapshot);\n case \"commandResult\":\n return (\n typeof envelope.requestId === \"string\" &&\n envelope.requestId.length > 0 &&\n envelope.requestId.length <= 100 &&\n isRecord(envelope.snapshot) &&\n isSafePayload(envelope.snapshot)\n );\n case \"commandError\":\n return (\n typeof envelope.requestId === \"string\" &&\n envelope.requestId.length > 0 &&\n envelope.requestId.length <= 100 &&\n isRecord(envelope.error)\n );\n default:\n return false;\n }\n};\n\nexport const isJourneyDevtoolsExtensionEnvelope = (\n value: unknown\n): value is JourneyDevtoolsExtensionEnvelope => {\n if (!hasBaseEnvelopeShape(value) || value.source !== JOURNEY_DEVTOOLS_EXTENSION_SOURCE) {\n return false;\n }\n\n if (value.kind !== \"command\") {\n return false;\n }\n\n const envelope = value as Record<string, unknown>;\n return (\n typeof envelope.requestId === \"string\" &&\n envelope.requestId.length > 0 &&\n envelope.requestId.length <= 100 &&\n isJourneyDevtoolsCommand(envelope.command)\n );\n};\n\nexport const isJourneyDevtoolsEnvelope = (value: unknown): value is JourneyDevtoolsEnvelope =>\n isJourneyDevtoolsBridgeEnvelope(value) || isJourneyDevtoolsExtensionEnvelope(value);\n", "import type {\n JourneyEventPayloadMap,\n JourneyMachine,\n JourneySendResult,\n JourneySnapshot\n} from \"@rxova/journey-core\";\nimport {\n JOURNEY_DEVTOOLS_BRIDGE_SOURCE,\n JOURNEY_DEVTOOLS_CHANNEL,\n JOURNEY_DEVTOOLS_EXTENSION_SOURCE,\n JOURNEY_DEVTOOLS_PROTOCOL_VERSION,\n isJourneyDevtoolsEnvelope,\n type JourneyDevtoolsBridgeCommandErrorEnvelope,\n type JourneyDevtoolsBridgeCommandResultEnvelope,\n type JourneyDevtoolsBridgeEnvelope,\n type JourneyDevtoolsBridgeRegisterEnvelope,\n type JourneyDevtoolsBridgeSnapshotEnvelope,\n type JourneyDevtoolsBridgeUnregisterEnvelope,\n type JourneyDevtoolsCommand,\n type JourneyDevtoolsExtensionCommandEnvelope,\n type JourneyDevtoolsMachineMeta,\n type JourneyDevtoolsSerializableSnapshot,\n type JourneyDevtoolsSerializedError\n} from \"./protocol\";\n\ndeclare const process: { env?: { NODE_ENV?: string } } | undefined;\n\nexport type JourneyDevtoolsBridgeOptions = {\n machineId?: string;\n label?: string;\n enabled?: boolean;\n appName?: string;\n commandsEnabled?: boolean;\n};\n\ntype JourneySendEvent<TStepId extends string> = Parameters<\n JourneyMachine<unknown, TStepId, string>[\"send\"]\n>[0];\n\ntype SendOutcome<TContext, TStepId extends string> = {\n snapshot: JourneySnapshot<TContext, TStepId>;\n transitioned?: boolean;\n transitionId?: string;\n};\n\nconst DEFAULT_MACHINE_LABEL = \"Journey Machine\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isJourneyAsyncPhase = (\n value: unknown\n): value is JourneyDevtoolsSerializableSnapshot[\"async\"][\"byStep\"][string][\"phase\"] =>\n value === \"idle\" ||\n value === \"evaluating-when\" ||\n value === \"running-effect\" ||\n value === \"error\";\n\nconst resolveDefaultEnabled = (): boolean => {\n const nodeEnv = typeof process !== \"undefined\" ? process.env?.NODE_ENV : undefined;\n if (typeof nodeEnv !== \"string\") {\n return false;\n }\n\n return nodeEnv !== \"production\";\n};\n\nconst resolveDefaultCommandsEnabled = (): boolean => {\n const nodeEnv = typeof process !== \"undefined\" ? process.env?.NODE_ENV : undefined;\n if (typeof nodeEnv !== \"string\") {\n return false;\n }\n\n return nodeEnv !== \"production\";\n};\n\nconst resolveWindowTargetOrigin = (): string => {\n if (typeof window === \"undefined\") {\n return \"*\";\n }\n\n return window.location.origin === \"null\" ? \"*\" : window.location.origin;\n};\n\n// No session token infrastructure needed\n\n/**\n * Validates that the message origin matches the current window origin.\n * This prevents messages from other origins from being processed.\n *\n * Note: This is part of defense-in-depth but not a hard security boundary.\n * Code running in the same origin can still send messages.\n */\nconst isExpectedWindowOrigin = (origin: string): boolean => {\n if (origin.length === 0) {\n return false;\n }\n\n if (typeof window === \"undefined\") {\n return false;\n }\n\n const expected = window.location.origin;\n if (expected === \"null\") {\n // For file:// or sandboxed contexts where origin is \"null\"\n return origin === \"null\";\n }\n\n // Strict equality check - no wildcard matching\n return origin === expected;\n};\n\nconst createMachineId = (): string =>\n `journey-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n\n/**\n * Simple rate limiter to prevent command abuse.\n * Tracks command timestamps and enforces a maximum rate.\n */\nclass CommandRateLimiter {\n private commandTimestamps: number[] = [];\n private readonly maxCommandsPerWindow: number;\n private readonly windowMs: number;\n\n constructor(maxCommandsPerWindow = 100, windowMs = 10000) {\n this.maxCommandsPerWindow = maxCommandsPerWindow;\n this.windowMs = windowMs;\n }\n\n /**\n * Checks if a command is allowed based on rate limits.\n * Returns true if allowed, false if rate limit exceeded.\n */\n isAllowed(): boolean {\n const now = Date.now();\n const windowStart = now - this.windowMs;\n\n // Remove old timestamps outside the window\n this.commandTimestamps = this.commandTimestamps.filter((ts) => ts > windowStart);\n\n if (this.commandTimestamps.length >= this.maxCommandsPerWindow) {\n return false;\n }\n\n this.commandTimestamps.push(now);\n return true;\n }\n\n reset(): void {\n this.commandTimestamps = [];\n }\n}\n\nconst cloneForTransport = (value: unknown): unknown => {\n if (typeof structuredClone === \"function\") {\n try {\n return structuredClone(value);\n } catch {\n // Fall through to the JSON serializer below.\n }\n }\n\n const seen = new WeakSet<object>();\n\n try {\n const serialized = JSON.stringify(value, (_key, currentValue) => {\n if (typeof currentValue === \"bigint\") {\n return currentValue.toString();\n }\n if (typeof currentValue === \"function\") {\n return `[Function ${currentValue.name || \"anonymous\"}]`;\n }\n if (typeof currentValue === \"symbol\") {\n return currentValue.toString();\n }\n if (typeof currentValue === \"object\" && currentValue !== null) {\n if (seen.has(currentValue)) {\n return \"[Circular]\";\n }\n seen.add(currentValue);\n }\n return currentValue;\n });\n\n if (serialized === undefined) {\n return undefined;\n }\n\n return JSON.parse(serialized) as unknown;\n } catch {\n return String(value);\n }\n};\n\nconst serializeError = (error: unknown): JourneyDevtoolsSerializedError => {\n if (error instanceof Error) {\n const cause =\n \"cause\" in error && (error as { cause?: unknown }).cause !== undefined\n ? (error as { cause?: unknown }).cause\n : null;\n return {\n name: error.name,\n message: error.message,\n stack: typeof error.stack === \"string\" ? error.stack : null,\n cause: cloneForTransport(cause)\n };\n }\n\n return {\n name: null,\n message: typeof error === \"string\" ? error : \"Unknown error\",\n stack: null,\n cause: cloneForTransport(error)\n };\n};\n\nconst serializeSnapshot = <TContext, TStepId extends string>(\n snapshot: JourneySnapshot<TContext, TStepId>\n): JourneyDevtoolsSerializableSnapshot => {\n const byStep: Record<string, JourneyDevtoolsSerializableSnapshot[\"async\"][\"byStep\"][string]> = {};\n\n for (const [stepId, stepState] of Object.entries(\n snapshot.async.byStep as Record<string, unknown>\n )) {\n if (!isRecord(stepState)) {\n continue;\n }\n\n byStep[stepId] = {\n phase: isJourneyAsyncPhase(stepState.phase) ? stepState.phase : \"idle\",\n eventType: typeof stepState.eventType === \"string\" ? stepState.eventType : null,\n transitionId: typeof stepState.transitionId === \"string\" ? stepState.transitionId : null,\n error: stepState.error === null ? null : cloneForTransport(stepState.error)\n };\n }\n\n return {\n current: String(snapshot.current),\n context: cloneForTransport(snapshot.context),\n history: snapshot.history.map((stepId) => String(stepId)),\n visited: snapshot.visited.map((stepId) => String(stepId)),\n status: snapshot.status,\n async: {\n isLoading: snapshot.async.isLoading,\n byStep\n }\n };\n};\n\nconst runCommand = async <TContext, TStepId extends string>(\n machine: JourneyMachine<TContext, TStepId, string>,\n command: JourneyDevtoolsCommand\n): Promise<SendOutcome<TContext, TStepId>> => {\n switch (command.type) {\n case \"next\":\n case \"back\":\n case \"close\":\n case \"submit\": {\n const result = await machine.send({ type: command.type } as JourneySendEvent<TStepId>);\n return {\n snapshot: result.snapshot,\n transitioned: result.transitioned,\n ...(result.transitionId ? { transitionId: result.transitionId } : {})\n };\n }\n case \"goTo\": {\n const result = await machine.send({\n type: \"goTo\",\n to: command.to\n } as JourneySendEvent<TStepId>);\n return {\n snapshot: result.snapshot,\n transitioned: result.transitioned,\n ...(result.transitionId ? { transitionId: result.transitionId } : {})\n };\n }\n case \"send\": {\n const sendEvent =\n command.event.payload === undefined\n ? { type: command.event.type }\n : { type: command.event.type, payload: command.event.payload };\n const result: JourneySendResult<TContext, TStepId> = await machine.send(\n sendEvent as JourneySendEvent<TStepId>\n );\n return {\n snapshot: result.snapshot,\n transitioned: result.transitioned,\n ...(result.transitionId ? { transitionId: result.transitionId } : {})\n };\n }\n case \"reset\":\n return {\n snapshot: machine.reset()\n };\n case \"clearStepError\":\n return {\n snapshot: machine.clearStepError(command.stepId as TStepId | undefined)\n };\n case \"clearHistory\":\n return {\n snapshot: machine.clearHistory()\n };\n case \"trimHistory\":\n return {\n snapshot: machine.trimHistory(command.maxHistory)\n };\n }\n};\n\nexport const attachJourneyDevtools = <\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType>\n>(\n machine: JourneyMachine<TContext, TStepId, TEventType, TPayloadMap>,\n options: JourneyDevtoolsBridgeOptions = {}\n): (() => void) => {\n const enabled = options.enabled ?? resolveDefaultEnabled();\n if (!enabled || typeof window === \"undefined\") {\n return () => {};\n }\n const commandsEnabled = options.commandsEnabled ?? resolveDefaultCommandsEnabled();\n\n const machineId = options.machineId?.trim() || createMachineId();\n const meta: JourneyDevtoolsMachineMeta = {\n machineId,\n label: options.label?.trim() || DEFAULT_MACHINE_LABEL,\n appName:\n options.appName?.trim() || (typeof document !== \"undefined\" ? document.title : \"\") || null,\n commandsEnabled\n };\n const targetOrigin = resolveWindowTargetOrigin();\n\n const createBaseEnvelope = <TKind extends JourneyDevtoolsBridgeEnvelope[\"kind\"]>(\n kind: TKind\n ) => ({\n channel: JOURNEY_DEVTOOLS_CHANNEL,\n version: JOURNEY_DEVTOOLS_PROTOCOL_VERSION,\n source: JOURNEY_DEVTOOLS_BRIDGE_SOURCE,\n kind,\n machineId,\n timestamp: Date.now()\n });\n\n const post = (envelope: JourneyDevtoolsBridgeEnvelope) => {\n window.postMessage(envelope, targetOrigin);\n };\n\n const postSnapshot = (snapshot: JourneySnapshot<TContext, TStepId>) => {\n const envelope: JourneyDevtoolsBridgeSnapshotEnvelope = {\n ...createBaseEnvelope(\"snapshot\"),\n snapshot: serializeSnapshot(snapshot)\n };\n post(envelope);\n };\n\n let isDetached = false;\n const rateLimiter = new CommandRateLimiter();\n\n const onMessage = (event: MessageEvent<unknown>) => {\n if (\n event.source !== window ||\n !isExpectedWindowOrigin(event.origin) ||\n isDetached ||\n !isJourneyDevtoolsEnvelope(event.data)\n ) {\n return;\n }\n\n if (event.data.source !== JOURNEY_DEVTOOLS_EXTENSION_SOURCE || event.data.kind !== \"command\") {\n return;\n }\n\n const commandEnvelope: JourneyDevtoolsExtensionCommandEnvelope = event.data;\n if (commandEnvelope.machineId !== machineId) {\n return;\n }\n\n // Rate limiting to prevent command abuse\n if (!rateLimiter.isAllowed()) {\n const errorEnvelope: JourneyDevtoolsBridgeCommandErrorEnvelope = {\n ...createBaseEnvelope(\"commandError\"),\n requestId: commandEnvelope.requestId,\n error: serializeError(\n \"Command rate limit exceeded. Too many commands in a short time window.\"\n )\n };\n post(errorEnvelope);\n return;\n }\n\n if (!commandsEnabled) {\n const errorEnvelope: JourneyDevtoolsBridgeCommandErrorEnvelope = {\n ...createBaseEnvelope(\"commandError\"),\n requestId: commandEnvelope.requestId,\n error: serializeError(\"Bridge commands are disabled by configuration.\")\n };\n post(errorEnvelope);\n return;\n }\n\n const run = async () => {\n try {\n const outcome = await runCommand(\n machine as JourneyMachine<TContext, TStepId, string>,\n commandEnvelope.command\n );\n if (isDetached) {\n return;\n }\n\n const resultEnvelope: JourneyDevtoolsBridgeCommandResultEnvelope = {\n ...createBaseEnvelope(\"commandResult\"),\n requestId: commandEnvelope.requestId,\n snapshot: serializeSnapshot(outcome.snapshot),\n ...(outcome.transitioned !== undefined ? { transitioned: outcome.transitioned } : {}),\n ...(outcome.transitionId ? { transitionId: outcome.transitionId } : {})\n };\n post(resultEnvelope);\n } catch (error) {\n if (isDetached) {\n return;\n }\n\n const errorEnvelope: JourneyDevtoolsBridgeCommandErrorEnvelope = {\n ...createBaseEnvelope(\"commandError\"),\n requestId: commandEnvelope.requestId,\n error: serializeError(error)\n };\n post(errorEnvelope);\n }\n };\n\n void run();\n };\n\n window.addEventListener(\"message\", onMessage);\n\n const unsubscribe = machine.subscribe(() => {\n if (isDetached) {\n return;\n }\n postSnapshot(machine.getSnapshot());\n });\n\n const registerEnvelope: JourneyDevtoolsBridgeRegisterEnvelope = {\n ...createBaseEnvelope(\"register\"),\n meta,\n snapshot: serializeSnapshot(machine.getSnapshot())\n };\n post(registerEnvelope);\n\n return () => {\n if (isDetached) {\n return;\n }\n\n isDetached = true;\n rateLimiter.reset();\n unsubscribe();\n window.removeEventListener(\"message\", onMessage);\n\n const unregisterEnvelope: JourneyDevtoolsBridgeUnregisterEnvelope = {\n ...createBaseEnvelope(\"unregister\")\n };\n post(unregisterEnvelope);\n };\n};\n"],
|
|
5
|
-
"mappings": "AAEO,IAAMA,EAAoC,EACpCC,EAA2B,6BAE3BC,EAAiC,uBACjCC,EAAoC,0BAmG3CC,EAAYC,GAChB,OAAOA,GAAU,UAAYA,IAAU,KAEnCC,EAAiBD,GACrBA,IAAUH,GAAkCG,IAAUF,EAkBxD,IAAMI,EAAgB,CAACC,EAAgBC,EAAQ,IAAe,CAC5D,GAAIA,EAAQ,GACV,MAAO,GAQT,GALID,GAAU,MAIS,CAAC,SAAU,SAAU,SAAS,EAClC,SAAS,OAAOA,CAAK,EACtC,MAAO,GAGT,GAAI,OAAOA,GAAU,SAAU,CAE7B,GAAI,CAEF,GADmB,KAAK,UAAUA,CAAK,EACxB,OAAS,IACtB,MAAO,EAEX,MAAQ,CAEN,MAAO,EACT,CAGA,OAAI,MAAM,QAAQA,CAAK,EACdA,EAAM,MAAOE,GAASH,EAAcG,EAAMD,EAAQ,CAAC,CAAC,EAK3D,OAAO,eAAeD,CAAK,IAAM,OAAO,WACxC,OAAO,eAAeA,CAAK,IAAM,KAE1B,GAGF,OAAO,OAAOA,CAAK,EAAE,MAAOG,GAASJ,EAAcI,EAAMF,EAAQ,CAAC,CAAC,CAC5E,CAGA,MAAO,EACT,EAEMG,EAAwBJ,GACvBK,EAASL,CAAK,EAKjBA,EAAM,UAAYM,GAClBN,EAAM,UAAY,GAClBO,EAAcP,EAAM,MAAM,GAC1B,OAAOA,EAAM,MAAS,UACtB,OAAOA,EAAM,WAAc,UAC3B,OAAOA,EAAM,WAAc,SATpB,GAaLQ,EAAeR,GACf,CAACK,EAASL,CAAK,GAIf,OAAOA,EAAM,MAAS,UAAYA,EAAM,KAAK,SAAW,GAAKA,EAAM,KAAK,OAAS,IAC5E,GAIL,YAAaA,GAASA,EAAM,UAAY,OACnCD,EAAcC,EAAM,OAAO,EAG7B,GAGIS,EAA4BT,GAAoD,CAM3F,GALI,CAACK,EAASL,CAAK,GAAK,OAAOA,EAAM,MAAS,UAK1CA,EAAM,KAAK,SAAW,GAAKA,EAAM,KAAK,OAAS,GACjD,MAAO,GAGT,OAAQA,EAAM,KAAM,CAClB,IAAK,
|
|
6
|
-
"names": ["JOURNEY_DEVTOOLS_PROTOCOL_VERSION", "JOURNEY_DEVTOOLS_CHANNEL", "JOURNEY_DEVTOOLS_BRIDGE_SOURCE", "JOURNEY_DEVTOOLS_EXTENSION_SOURCE", "isRecord", "value", "isKnownSource", "isSafePayload", "value", "depth", "item", "prop", "hasBaseEnvelopeShape", "isRecord", "JOURNEY_DEVTOOLS_CHANNEL", "isKnownSource", "isSendEvent", "isJourneyDevtoolsCommand", "isJourneyDevtoolsBridgeEnvelope", "JOURNEY_DEVTOOLS_BRIDGE_SOURCE", "envelope", "isJourneyDevtoolsExtensionEnvelope", "JOURNEY_DEVTOOLS_EXTENSION_SOURCE", "isJourneyDevtoolsEnvelope", "DEFAULT_MACHINE_LABEL", "isRecord", "value", "isJourneyAsyncPhase", "resolveDefaultEnabled", "nodeEnv", "resolveDefaultCommandsEnabled", "resolveWindowTargetOrigin", "isExpectedWindowOrigin", "origin", "expected", "createMachineId", "CommandRateLimiter", "maxCommandsPerWindow", "windowMs", "now", "windowStart", "ts", "cloneForTransport", "seen", "serialized", "_key", "currentValue", "serializeError", "error", "cause", "serializeSnapshot", "snapshot", "byStep", "stepId", "stepState", "runCommand", "machine", "command", "result", "sendEvent", "attachJourneyDevtools", "options", "commandsEnabled", "machineId", "meta", "targetOrigin", "createBaseEnvelope", "kind", "JOURNEY_DEVTOOLS_CHANNEL", "JOURNEY_DEVTOOLS_BRIDGE_SOURCE", "post", "envelope", "postSnapshot", "isDetached", "rateLimiter", "onMessage", "event", "isJourneyDevtoolsEnvelope", "JOURNEY_DEVTOOLS_EXTENSION_SOURCE", "commandEnvelope", "errorEnvelope", "outcome", "resultEnvelope", "unsubscribe", "registerEnvelope", "unregisterEnvelope"]
|
|
4
|
+
"sourcesContent": ["import type { JourneySnapshot, JourneyStepAsyncState } from \"@rxova/journey-core\";\n\nexport const JOURNEY_DEVTOOLS_PROTOCOL_VERSION = 3 as const;\nexport const JOURNEY_DEVTOOLS_CHANNEL = \"__RXOVA_JOURNEY_DEVTOOLS__\" as const;\n\nexport const JOURNEY_DEVTOOLS_BRIDGE_SOURCE = \"rxova-journey-bridge\" as const;\nexport const JOURNEY_DEVTOOLS_EXTENSION_SOURCE = \"rxova-journey-extension\" as const;\n\nexport type JourneyDevtoolsSource =\n | typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE\n | typeof JOURNEY_DEVTOOLS_EXTENSION_SOURCE;\n\nexport type JourneyDevtoolsStepAsyncState = JourneyStepAsyncState;\n\nexport type JourneyDevtoolsSerializableSnapshot = JourneySnapshot<unknown, string>;\n\nexport type JourneyDevtoolsMachineMeta = {\n machineId: string;\n label: string;\n appName: string | null;\n commandsEnabled?: boolean;\n};\n\nexport type JourneyDevtoolsSerializedError = {\n name: string | null;\n message: string;\n stack: string | null;\n cause: unknown;\n};\n\nexport type JourneyDevtoolsCommand =\n | { type: \"goToNextStep\" }\n | { type: \"terminateMachine\" }\n | { type: \"completeJourney\" }\n | { type: \"goToStepById\"; stepId: string }\n | { type: \"goToPreviousStep\"; steps?: number }\n | { type: \"goToLastVisitedStep\" }\n | { type: \"send\"; event: { type: string; payload?: unknown } }\n | { type: \"updateStepMetadata\"; stepId: string; metadata: unknown }\n | { type: \"resetMachine\" }\n | { type: \"clearStepError\"; stepId?: string };\n\nexport type JourneyDevtoolsEnvelopeBase = {\n channel: typeof JOURNEY_DEVTOOLS_CHANNEL;\n version: typeof JOURNEY_DEVTOOLS_PROTOCOL_VERSION;\n source: JourneyDevtoolsSource;\n kind: string;\n machineId: string;\n timestamp: number;\n};\n\nexport type JourneyDevtoolsBridgeRegisterEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"register\";\n meta: JourneyDevtoolsMachineMeta;\n snapshot: JourneyDevtoolsSerializableSnapshot;\n};\n\nexport type JourneyDevtoolsBridgeUnregisterEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"unregister\";\n};\n\nexport type JourneyDevtoolsBridgeSnapshotEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"snapshot\";\n snapshot: JourneyDevtoolsSerializableSnapshot;\n};\n\nexport type JourneyDevtoolsBridgeCommandResultEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"commandResult\";\n requestId: string;\n snapshot: JourneyDevtoolsSerializableSnapshot;\n transitioned?: boolean;\n transitionId?: string;\n};\n\nexport type JourneyDevtoolsBridgeCommandErrorEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_BRIDGE_SOURCE;\n kind: \"commandError\";\n requestId: string;\n error: JourneyDevtoolsSerializedError;\n};\n\nexport type JourneyDevtoolsExtensionCommandEnvelope = JourneyDevtoolsEnvelopeBase & {\n source: typeof JOURNEY_DEVTOOLS_EXTENSION_SOURCE;\n kind: \"command\";\n requestId: string;\n command: JourneyDevtoolsCommand;\n};\n\nexport type JourneyDevtoolsBridgeEnvelope =\n | JourneyDevtoolsBridgeRegisterEnvelope\n | JourneyDevtoolsBridgeUnregisterEnvelope\n | JourneyDevtoolsBridgeSnapshotEnvelope\n | JourneyDevtoolsBridgeCommandResultEnvelope\n | JourneyDevtoolsBridgeCommandErrorEnvelope;\n\nexport type JourneyDevtoolsExtensionEnvelope = JourneyDevtoolsExtensionCommandEnvelope;\n\nexport type JourneyDevtoolsEnvelope =\n | JourneyDevtoolsBridgeEnvelope\n | JourneyDevtoolsExtensionEnvelope;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isKnownSource = (value: unknown): value is JourneyDevtoolsSource =>\n value === JOURNEY_DEVTOOLS_BRIDGE_SOURCE || value === JOURNEY_DEVTOOLS_EXTENSION_SOURCE;\n\n/**\n * Maximum depth for nested object validation.\n * Prevents stack overflow and excessive processing from deeply nested malicious payloads.\n */\nconst MAX_PAYLOAD_DEPTH = 10;\n\n/**\n * Maximum size (in JSON string length) for serialized payloads.\n * Prevents memory exhaustion from extremely large payloads.\n */\nconst MAX_PAYLOAD_SIZE = 500_000; // 500KB\n\n/**\n * Validates that a value is safe for transport.\n * Checks depth and size constraints to prevent malicious payloads.\n */\nconst isSafePayload = (value: unknown, depth = 0): boolean => {\n if (depth > MAX_PAYLOAD_DEPTH) {\n return false;\n }\n\n if (value === null || value === undefined) {\n return true;\n }\n\n const primitiveTypes = [\"string\", \"number\", \"boolean\"];\n if (primitiveTypes.includes(typeof value)) {\n return true;\n }\n\n if (typeof value === \"object\") {\n // Check JSON serialization size\n try {\n const serialized = JSON.stringify(value);\n if (serialized.length > MAX_PAYLOAD_SIZE) {\n return false;\n }\n } catch {\n // Circular references or non-serializable objects are not safe\n return false;\n }\n\n // Recursively validate nested objects and arrays\n if (Array.isArray(value)) {\n return value.every((item) => isSafePayload(item, depth + 1));\n }\n\n // Validate plain objects (guard against prototype pollution)\n if (\n Object.getPrototypeOf(value) !== Object.prototype &&\n Object.getPrototypeOf(value) !== null\n ) {\n return false;\n }\n\n return Object.values(value).every((prop) => isSafePayload(prop, depth + 1));\n }\n\n // Reject functions, symbols, and other non-serializable types\n return false;\n};\n\nconst hasBaseEnvelopeShape = (value: unknown): value is JourneyDevtoolsEnvelopeBase => {\n if (!isRecord(value)) {\n return false;\n }\n\n return (\n value.channel === JOURNEY_DEVTOOLS_CHANNEL &&\n value.version === JOURNEY_DEVTOOLS_PROTOCOL_VERSION &&\n isKnownSource(value.source) &&\n typeof value.kind === \"string\" &&\n typeof value.machineId === \"string\" &&\n typeof value.timestamp === \"number\"\n );\n};\n\nconst isSendEvent = (value: unknown): value is { type: string; payload?: unknown } => {\n if (!isRecord(value)) {\n return false;\n }\n\n if (typeof value.type !== \"string\" || value.type.length === 0 || value.type.length > 100) {\n return false;\n }\n\n // Validate payload if present\n if (\"payload\" in value && value.payload !== undefined) {\n return isSafePayload(value.payload);\n }\n\n return true;\n};\n\nexport const isJourneyDevtoolsCommand = (value: unknown): value is JourneyDevtoolsCommand => {\n if (!isRecord(value) || typeof value.type !== \"string\") {\n return false;\n }\n\n // Validate command type is within reasonable length\n if (value.type.length === 0 || value.type.length > 50) {\n return false;\n }\n\n switch (value.type) {\n case \"goToNextStep\":\n case \"terminateMachine\":\n case \"completeJourney\":\n case \"resetMachine\":\n case \"goToLastVisitedStep\":\n // These commands should have no extra properties beyond type\n return Object.keys(value).length === 1;\n case \"goToStepById\":\n return (\n typeof value.stepId === \"string\" &&\n value.stepId.length > 0 &&\n value.stepId.length <= 100 &&\n Object.keys(value).length === 2\n );\n case \"goToPreviousStep\":\n return (\n (value.steps === undefined ||\n (typeof value.steps === \"number\" &&\n Number.isInteger(value.steps) &&\n value.steps >= 1 &&\n value.steps <= 10000)) &&\n Object.keys(value).length <= 2\n );\n case \"send\":\n return isSendEvent(value.event) && Object.keys(value).length === 2;\n case \"updateStepMetadata\":\n return (\n typeof value.stepId === \"string\" &&\n value.stepId.length > 0 &&\n value.stepId.length <= 100 &&\n isSafePayload(value.metadata) &&\n Object.keys(value).length === 3\n );\n case \"clearStepError\":\n return (\n (value.stepId === undefined ||\n (typeof value.stepId === \"string\" && value.stepId.length <= 100)) &&\n Object.keys(value).length <= 2\n );\n default:\n return false;\n }\n};\n\nexport const isJourneyDevtoolsBridgeEnvelope = (\n value: unknown\n): value is JourneyDevtoolsBridgeEnvelope => {\n if (!hasBaseEnvelopeShape(value) || value.source !== JOURNEY_DEVTOOLS_BRIDGE_SOURCE) {\n return false;\n }\n\n const envelope = value as Record<string, unknown>;\n\n switch (value.kind) {\n case \"register\":\n return (\n isRecord(envelope.meta) &&\n isRecord(envelope.snapshot) &&\n isSafePayload(envelope.meta) &&\n isSafePayload(envelope.snapshot)\n );\n case \"unregister\":\n return true;\n case \"snapshot\":\n return isRecord(envelope.snapshot) && isSafePayload(envelope.snapshot);\n case \"commandResult\":\n return (\n typeof envelope.requestId === \"string\" &&\n envelope.requestId.length > 0 &&\n envelope.requestId.length <= 100 &&\n isRecord(envelope.snapshot) &&\n isSafePayload(envelope.snapshot)\n );\n case \"commandError\":\n return (\n typeof envelope.requestId === \"string\" &&\n envelope.requestId.length > 0 &&\n envelope.requestId.length <= 100 &&\n isRecord(envelope.error)\n );\n default:\n return false;\n }\n};\n\nexport const isJourneyDevtoolsExtensionEnvelope = (\n value: unknown\n): value is JourneyDevtoolsExtensionEnvelope => {\n if (!hasBaseEnvelopeShape(value) || value.source !== JOURNEY_DEVTOOLS_EXTENSION_SOURCE) {\n return false;\n }\n\n if (value.kind !== \"command\") {\n return false;\n }\n\n const envelope = value as Record<string, unknown>;\n return (\n typeof envelope.requestId === \"string\" &&\n envelope.requestId.length > 0 &&\n envelope.requestId.length <= 100 &&\n isJourneyDevtoolsCommand(envelope.command)\n );\n};\n\nexport const isJourneyDevtoolsEnvelope = (value: unknown): value is JourneyDevtoolsEnvelope =>\n isJourneyDevtoolsBridgeEnvelope(value) || isJourneyDevtoolsExtensionEnvelope(value);\n", "import type {\n JourneyEventPayloadMap,\n JourneyMachine,\n JourneySendResult,\n JourneySnapshot\n} from \"@rxova/journey-core\";\nimport {\n JOURNEY_DEVTOOLS_BRIDGE_SOURCE,\n JOURNEY_DEVTOOLS_CHANNEL,\n JOURNEY_DEVTOOLS_EXTENSION_SOURCE,\n JOURNEY_DEVTOOLS_PROTOCOL_VERSION,\n isJourneyDevtoolsEnvelope,\n type JourneyDevtoolsBridgeCommandErrorEnvelope,\n type JourneyDevtoolsBridgeCommandResultEnvelope,\n type JourneyDevtoolsBridgeEnvelope,\n type JourneyDevtoolsBridgeRegisterEnvelope,\n type JourneyDevtoolsBridgeSnapshotEnvelope,\n type JourneyDevtoolsBridgeUnregisterEnvelope,\n type JourneyDevtoolsCommand,\n type JourneyDevtoolsExtensionCommandEnvelope,\n type JourneyDevtoolsMachineMeta,\n type JourneyDevtoolsSerializableSnapshot,\n type JourneyDevtoolsSerializedError\n} from \"./protocol\";\n\ndeclare const process: { env?: { NODE_ENV?: string } } | undefined;\n\nexport type JourneyDevtoolsBridgeOptions = {\n machineId?: string;\n label?: string;\n enabled?: boolean;\n appName?: string;\n commandsEnabled?: boolean;\n};\n\ntype JourneySendEvent<TStepId extends string> = Parameters<\n JourneyMachine<unknown, TStepId, string, Record<never, never>, unknown>[\"send\"]\n>[0];\n\ntype SendOutcome<TContext, TStepId extends string, TStepMeta> = {\n snapshot: JourneySnapshot<TContext, TStepId, TStepMeta>;\n transitioned?: boolean;\n transitionId?: string;\n};\n\nconst DEFAULT_MACHINE_LABEL = \"Journey Machine\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nconst isJourneyAsyncPhase = (\n value: unknown\n): value is JourneyDevtoolsSerializableSnapshot[\"async\"][\"byStep\"][string][\"phase\"] =>\n value === \"idle\" ||\n value === \"evaluating-when\" ||\n value === \"running-effect\" ||\n value === \"error\";\n\nconst resolveDefaultEnabled = (): boolean => {\n const nodeEnv = typeof process !== \"undefined\" ? process.env?.NODE_ENV : undefined;\n if (typeof nodeEnv !== \"string\") {\n return false;\n }\n\n return nodeEnv !== \"production\";\n};\n\nconst resolveDefaultCommandsEnabled = (): boolean => {\n const nodeEnv = typeof process !== \"undefined\" ? process.env?.NODE_ENV : undefined;\n if (typeof nodeEnv !== \"string\") {\n return false;\n }\n\n return nodeEnv !== \"production\";\n};\n\nconst resolveWindowTargetOrigin = (): string => {\n if (typeof window === \"undefined\") {\n return \"*\";\n }\n\n return window.location.origin === \"null\" ? \"*\" : window.location.origin;\n};\n\n// No session token infrastructure needed\n\n/**\n * Validates that the message origin matches the current window origin.\n * This prevents messages from other origins from being processed.\n *\n * Note: This is part of defense-in-depth but not a hard security boundary.\n * Code running in the same origin can still send messages.\n */\nconst isExpectedWindowOrigin = (origin: string): boolean => {\n if (origin.length === 0) {\n return false;\n }\n\n if (typeof window === \"undefined\") {\n return false;\n }\n\n const expected = window.location.origin;\n if (expected === \"null\") {\n // For file:// or sandboxed contexts where origin is \"null\"\n return origin === \"null\";\n }\n\n // Strict equality check - no wildcard matching\n return origin === expected;\n};\n\nconst createMachineId = (): string =>\n `journey-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n\n/**\n * Simple rate limiter to prevent command abuse.\n * Tracks command timestamps and enforces a maximum rate.\n */\nclass CommandRateLimiter {\n private commandTimestamps: number[] = [];\n private readonly maxCommandsPerWindow: number;\n private readonly windowMs: number;\n\n constructor(maxCommandsPerWindow = 100, windowMs = 10000) {\n this.maxCommandsPerWindow = maxCommandsPerWindow;\n this.windowMs = windowMs;\n }\n\n /**\n * Checks if a command is allowed based on rate limits.\n * Returns true if allowed, false if rate limit exceeded.\n */\n isAllowed(): boolean {\n const now = Date.now();\n const windowStart = now - this.windowMs;\n\n // Remove old timestamps outside the window\n this.commandTimestamps = this.commandTimestamps.filter((ts) => ts > windowStart);\n\n if (this.commandTimestamps.length >= this.maxCommandsPerWindow) {\n return false;\n }\n\n this.commandTimestamps.push(now);\n return true;\n }\n\n reset(): void {\n this.commandTimestamps = [];\n }\n}\n\nconst cloneForTransport = (value: unknown): unknown => {\n if (typeof structuredClone === \"function\") {\n try {\n return structuredClone(value);\n } catch {\n // Fall through to the JSON serializer below.\n }\n }\n\n const seen = new WeakSet<object>();\n\n try {\n const serialized = JSON.stringify(value, (_key, currentValue) => {\n if (typeof currentValue === \"bigint\") {\n return currentValue.toString();\n }\n if (typeof currentValue === \"function\") {\n return `[Function ${currentValue.name || \"anonymous\"}]`;\n }\n if (typeof currentValue === \"symbol\") {\n return currentValue.toString();\n }\n if (typeof currentValue === \"object\" && currentValue !== null) {\n if (seen.has(currentValue)) {\n return \"[Circular]\";\n }\n seen.add(currentValue);\n }\n return currentValue;\n });\n\n if (serialized === undefined) {\n return undefined;\n }\n\n return JSON.parse(serialized) as unknown;\n } catch {\n return String(value);\n }\n};\n\nconst serializeError = (error: unknown): JourneyDevtoolsSerializedError => {\n if (error instanceof Error) {\n const cause =\n \"cause\" in error && (error as { cause?: unknown }).cause !== undefined\n ? (error as { cause?: unknown }).cause\n : null;\n return {\n name: error.name,\n message: error.message,\n stack: typeof error.stack === \"string\" ? error.stack : null,\n cause: cloneForTransport(cause)\n };\n }\n\n return {\n name: null,\n message: typeof error === \"string\" ? error : \"Unknown error\",\n stack: null,\n cause: cloneForTransport(error)\n };\n};\n\nconst serializeSnapshot = <TContext, TStepId extends string, TStepMeta>(\n snapshot: JourneySnapshot<TContext, TStepId, TStepMeta>\n): JourneyDevtoolsSerializableSnapshot => {\n const byStep: Record<string, JourneyDevtoolsSerializableSnapshot[\"async\"][\"byStep\"][string]> = {};\n\n for (const [stepId, stepState] of Object.entries(\n snapshot.async.byStep as Record<string, unknown>\n )) {\n if (!isRecord(stepState)) {\n continue;\n }\n\n byStep[stepId] = {\n phase: isJourneyAsyncPhase(stepState.phase) ? stepState.phase : \"idle\",\n eventType: typeof stepState.eventType === \"string\" ? stepState.eventType : null,\n transitionId: typeof stepState.transitionId === \"string\" ? stepState.transitionId : null,\n error: stepState.error === null ? null : cloneForTransport(stepState.error)\n };\n }\n\n return {\n currentStepId: String(snapshot.currentStepId),\n context: cloneForTransport(snapshot.context),\n history: {\n timeline: snapshot.history.timeline.map((stepId) => String(stepId)),\n index: snapshot.history.index\n },\n visited: Object.fromEntries(\n Object.entries(snapshot.visited as Record<string, boolean>).map(([stepId, isVisited]) => [\n String(stepId),\n isVisited === true\n ])\n ),\n stepMeta: cloneForTransport(snapshot.stepMeta) as Record<string, unknown>,\n status: snapshot.status,\n async: {\n isLoading: snapshot.async.isLoading,\n byStep\n }\n };\n};\n\nconst runCommand = async <TContext, TStepId extends string, TStepMeta>(\n machine: JourneyMachine<TContext, TStepId, string, Record<never, never>, TStepMeta>,\n command: JourneyDevtoolsCommand\n): Promise<SendOutcome<TContext, TStepId, TStepMeta>> => {\n switch (command.type) {\n case \"goToNextStep\":\n case \"completeJourney\": {\n const result = await machine.send({ type: command.type } as JourneySendEvent<TStepId>);\n return {\n snapshot: result.snapshot,\n transitioned: result.transitioned,\n ...(result.transitionId ? { transitionId: result.transitionId } : {})\n };\n }\n case \"terminateMachine\": {\n const result = await machine.send({ type: \"terminateJourney\" } as JourneySendEvent<TStepId>);\n return {\n snapshot: result.snapshot,\n transitioned: result.transitioned,\n ...(result.transitionId ? { transitionId: result.transitionId } : {})\n };\n }\n case \"goToStepById\": {\n const result = await machine.send({\n type: \"goToStepById\",\n stepId: command.stepId\n } as JourneySendEvent<TStepId>);\n return {\n snapshot: result.snapshot,\n transitioned: result.transitioned,\n ...(result.transitionId ? { transitionId: result.transitionId } : {})\n };\n }\n case \"goToPreviousStep\": {\n const result = await machine.goToPreviousStep(command.steps);\n return {\n snapshot: result.snapshot,\n transitioned: result.transitioned,\n ...(result.transitionId ? { transitionId: result.transitionId } : {})\n };\n }\n case \"goToLastVisitedStep\": {\n const result = await machine.goToLastVisitedStep();\n return {\n snapshot: result.snapshot,\n transitioned: result.transitioned,\n ...(result.transitionId ? { transitionId: result.transitionId } : {})\n };\n }\n case \"send\": {\n const sendEvent =\n command.event.payload === undefined\n ? { type: command.event.type }\n : { type: command.event.type, payload: command.event.payload };\n const result: JourneySendResult<TContext, TStepId, TStepMeta> = await machine.send(\n sendEvent as JourneySendEvent<TStepId>\n );\n return {\n snapshot: result.snapshot,\n transitioned: result.transitioned,\n ...(result.transitionId ? { transitionId: result.transitionId } : {})\n };\n }\n case \"updateStepMetadata\":\n return {\n snapshot: machine.updateStepMetadata(\n command.stepId as TStepId,\n () => command.metadata as TStepMeta\n )\n };\n case \"resetMachine\":\n return {\n snapshot: machine.resetMachine()\n };\n case \"clearStepError\":\n return {\n snapshot: machine.clearStepError(command.stepId as TStepId | undefined)\n };\n }\n};\n\nexport const attachJourneyDevtools = <\n TContext,\n TStepId extends string,\n TEventType extends string,\n TPayloadMap extends JourneyEventPayloadMap<TEventType>,\n TStepMeta\n>(\n machine: JourneyMachine<TContext, TStepId, TEventType, TPayloadMap, TStepMeta>,\n options: JourneyDevtoolsBridgeOptions = {}\n): (() => void) => {\n const enabled = options.enabled ?? resolveDefaultEnabled();\n if (!enabled || typeof window === \"undefined\") {\n return () => {};\n }\n const commandsEnabled = options.commandsEnabled ?? resolveDefaultCommandsEnabled();\n\n const machineId = options.machineId?.trim() || createMachineId();\n const meta: JourneyDevtoolsMachineMeta = {\n machineId,\n label: options.label?.trim() || DEFAULT_MACHINE_LABEL,\n appName:\n options.appName?.trim() || (typeof document !== \"undefined\" ? document.title : \"\") || null,\n commandsEnabled\n };\n const targetOrigin = resolveWindowTargetOrigin();\n\n const createBaseEnvelope = <TKind extends JourneyDevtoolsBridgeEnvelope[\"kind\"]>(\n kind: TKind\n ) => ({\n channel: JOURNEY_DEVTOOLS_CHANNEL,\n version: JOURNEY_DEVTOOLS_PROTOCOL_VERSION,\n source: JOURNEY_DEVTOOLS_BRIDGE_SOURCE,\n kind,\n machineId,\n timestamp: Date.now()\n });\n\n const post = (envelope: JourneyDevtoolsBridgeEnvelope) => {\n window.postMessage(envelope, targetOrigin);\n };\n\n const postSnapshot = (snapshot: JourneySnapshot<TContext, TStepId, TStepMeta>) => {\n const envelope: JourneyDevtoolsBridgeSnapshotEnvelope = {\n ...createBaseEnvelope(\"snapshot\"),\n snapshot: serializeSnapshot(snapshot)\n };\n post(envelope);\n };\n\n let isDetached = false;\n const rateLimiter = new CommandRateLimiter();\n\n const onMessage = (event: MessageEvent<unknown>) => {\n if (\n event.source !== window ||\n !isExpectedWindowOrigin(event.origin) ||\n isDetached ||\n !isJourneyDevtoolsEnvelope(event.data)\n ) {\n return;\n }\n\n if (event.data.source !== JOURNEY_DEVTOOLS_EXTENSION_SOURCE || event.data.kind !== \"command\") {\n return;\n }\n\n const commandEnvelope: JourneyDevtoolsExtensionCommandEnvelope = event.data;\n if (commandEnvelope.machineId !== machineId) {\n return;\n }\n\n // Rate limiting to prevent command abuse\n if (!rateLimiter.isAllowed()) {\n const errorEnvelope: JourneyDevtoolsBridgeCommandErrorEnvelope = {\n ...createBaseEnvelope(\"commandError\"),\n requestId: commandEnvelope.requestId,\n error: serializeError(\n \"Command rate limit exceeded. Too many commands in a short time window.\"\n )\n };\n post(errorEnvelope);\n return;\n }\n\n if (!commandsEnabled) {\n const errorEnvelope: JourneyDevtoolsBridgeCommandErrorEnvelope = {\n ...createBaseEnvelope(\"commandError\"),\n requestId: commandEnvelope.requestId,\n error: serializeError(\"Bridge commands are disabled by configuration.\")\n };\n post(errorEnvelope);\n return;\n }\n\n const run = async () => {\n try {\n const outcome = await runCommand(\n machine as JourneyMachine<TContext, TStepId, string, Record<never, never>, TStepMeta>,\n commandEnvelope.command\n );\n if (isDetached) {\n return;\n }\n\n const resultEnvelope: JourneyDevtoolsBridgeCommandResultEnvelope = {\n ...createBaseEnvelope(\"commandResult\"),\n requestId: commandEnvelope.requestId,\n snapshot: serializeSnapshot(outcome.snapshot),\n ...(outcome.transitioned !== undefined ? { transitioned: outcome.transitioned } : {}),\n ...(outcome.transitionId ? { transitionId: outcome.transitionId } : {})\n };\n post(resultEnvelope);\n } catch (error) {\n if (isDetached) {\n return;\n }\n\n const errorEnvelope: JourneyDevtoolsBridgeCommandErrorEnvelope = {\n ...createBaseEnvelope(\"commandError\"),\n requestId: commandEnvelope.requestId,\n error: serializeError(error)\n };\n post(errorEnvelope);\n }\n };\n\n void run();\n };\n\n window.addEventListener(\"message\", onMessage);\n\n const unsubscribe = machine.subscribe(() => {\n if (isDetached) {\n return;\n }\n postSnapshot(machine.getSnapshot());\n });\n\n const registerEnvelope: JourneyDevtoolsBridgeRegisterEnvelope = {\n ...createBaseEnvelope(\"register\"),\n meta,\n snapshot: serializeSnapshot(machine.getSnapshot())\n };\n post(registerEnvelope);\n\n return () => {\n if (isDetached) {\n return;\n }\n\n isDetached = true;\n rateLimiter.reset();\n unsubscribe();\n window.removeEventListener(\"message\", onMessage);\n\n const unregisterEnvelope: JourneyDevtoolsBridgeUnregisterEnvelope = {\n ...createBaseEnvelope(\"unregister\")\n };\n post(unregisterEnvelope);\n };\n};\n"],
|
|
5
|
+
"mappings": "AAEO,IAAMA,EAAoC,EACpCC,EAA2B,6BAE3BC,EAAiC,uBACjCC,EAAoC,0BAmG3CC,EAAYC,GAChB,OAAOA,GAAU,UAAYA,IAAU,KAEnCC,EAAiBD,GACrBA,IAAUH,GAAkCG,IAAUF,EAkBxD,IAAMI,EAAgB,CAACC,EAAgBC,EAAQ,IAAe,CAC5D,GAAIA,EAAQ,GACV,MAAO,GAQT,GALID,GAAU,MAIS,CAAC,SAAU,SAAU,SAAS,EAClC,SAAS,OAAOA,CAAK,EACtC,MAAO,GAGT,GAAI,OAAOA,GAAU,SAAU,CAE7B,GA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", "depth", "item", "prop", "hasBaseEnvelopeShape", "isRecord", "JOURNEY_DEVTOOLS_CHANNEL", "isKnownSource", "isSendEvent", "isJourneyDevtoolsCommand", "isJourneyDevtoolsBridgeEnvelope", "JOURNEY_DEVTOOLS_BRIDGE_SOURCE", "envelope", "isJourneyDevtoolsExtensionEnvelope", "JOURNEY_DEVTOOLS_EXTENSION_SOURCE", "isJourneyDevtoolsEnvelope", "DEFAULT_MACHINE_LABEL", "isRecord", "value", "isJourneyAsyncPhase", "resolveDefaultEnabled", "nodeEnv", "resolveDefaultCommandsEnabled", "resolveWindowTargetOrigin", "isExpectedWindowOrigin", "origin", "expected", "createMachineId", "CommandRateLimiter", "maxCommandsPerWindow", "windowMs", "now", "windowStart", "ts", "cloneForTransport", "seen", "serialized", "_key", "currentValue", "serializeError", "error", "cause", "serializeSnapshot", "snapshot", "byStep", "stepId", "stepState", "isVisited", "runCommand", "machine", "command", "result", "sendEvent", "attachJourneyDevtools", "options", "commandsEnabled", "machineId", "meta", "targetOrigin", "createBaseEnvelope", "kind", "JOURNEY_DEVTOOLS_CHANNEL", "JOURNEY_DEVTOOLS_BRIDGE_SOURCE", "post", "envelope", "postSnapshot", "isDetached", "rateLimiter", "onMessage", "event", "isJourneyDevtoolsEnvelope", "JOURNEY_DEVTOOLS_EXTENSION_SOURCE", "commandEnvelope", "errorEnvelope", "outcome", "resultEnvelope", "unsubscribe", "registerEnvelope", "unregisterEnvelope"]
|
|
7
7
|
}
|
package/dist/protocol.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JourneySnapshot, JourneyStepAsyncState } from "@rxova/journey-core";
|
|
2
|
-
export declare const JOURNEY_DEVTOOLS_PROTOCOL_VERSION:
|
|
2
|
+
export declare const JOURNEY_DEVTOOLS_PROTOCOL_VERSION: 3;
|
|
3
3
|
export declare const JOURNEY_DEVTOOLS_CHANNEL: "__RXOVA_JOURNEY_DEVTOOLS__";
|
|
4
4
|
export declare const JOURNEY_DEVTOOLS_BRIDGE_SOURCE: "rxova-journey-bridge";
|
|
5
5
|
export declare const JOURNEY_DEVTOOLS_EXTENSION_SOURCE: "rxova-journey-extension";
|
|
@@ -19,16 +19,19 @@ export type JourneyDevtoolsSerializedError = {
|
|
|
19
19
|
cause: unknown;
|
|
20
20
|
};
|
|
21
21
|
export type JourneyDevtoolsCommand = {
|
|
22
|
-
type: "
|
|
22
|
+
type: "goToNextStep";
|
|
23
23
|
} | {
|
|
24
|
-
type: "
|
|
24
|
+
type: "terminateMachine";
|
|
25
25
|
} | {
|
|
26
|
-
type: "
|
|
26
|
+
type: "completeJourney";
|
|
27
27
|
} | {
|
|
28
|
-
type: "
|
|
28
|
+
type: "goToStepById";
|
|
29
|
+
stepId: string;
|
|
29
30
|
} | {
|
|
30
|
-
type: "
|
|
31
|
-
|
|
31
|
+
type: "goToPreviousStep";
|
|
32
|
+
steps?: number;
|
|
33
|
+
} | {
|
|
34
|
+
type: "goToLastVisitedStep";
|
|
32
35
|
} | {
|
|
33
36
|
type: "send";
|
|
34
37
|
event: {
|
|
@@ -36,15 +39,14 @@ export type JourneyDevtoolsCommand = {
|
|
|
36
39
|
payload?: unknown;
|
|
37
40
|
};
|
|
38
41
|
} | {
|
|
39
|
-
type: "
|
|
42
|
+
type: "updateStepMetadata";
|
|
43
|
+
stepId: string;
|
|
44
|
+
metadata: unknown;
|
|
45
|
+
} | {
|
|
46
|
+
type: "resetMachine";
|
|
40
47
|
} | {
|
|
41
48
|
type: "clearStepError";
|
|
42
49
|
stepId?: string;
|
|
43
|
-
} | {
|
|
44
|
-
type: "clearHistory";
|
|
45
|
-
} | {
|
|
46
|
-
type: "trimHistory";
|
|
47
|
-
maxHistory?: number | null;
|
|
48
50
|
};
|
|
49
51
|
export type JourneyDevtoolsEnvelopeBase = {
|
|
50
52
|
channel: typeof JOURNEY_DEVTOOLS_CHANNEL;
|
|
@@ -96,4 +98,3 @@ export declare const isJourneyDevtoolsCommand: (value: unknown) => value is Jour
|
|
|
96
98
|
export declare const isJourneyDevtoolsBridgeEnvelope: (value: unknown) => value is JourneyDevtoolsBridgeEnvelope;
|
|
97
99
|
export declare const isJourneyDevtoolsExtensionEnvelope: (value: unknown) => value is JourneyDevtoolsExtensionEnvelope;
|
|
98
100
|
export declare const isJourneyDevtoolsEnvelope: (value: unknown) => value is JourneyDevtoolsEnvelope;
|
|
99
|
-
//# sourceMappingURL=protocol.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxova/journey-devtools-bridge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Bridge API to connect Journey machines to browser devtools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"journey",
|
|
@@ -45,19 +45,20 @@
|
|
|
45
45
|
],
|
|
46
46
|
"sideEffects": false,
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@rxova/journey-core": "^0.
|
|
48
|
+
"@rxova/journey-core": "^0.5.0"
|
|
49
49
|
},
|
|
50
50
|
"size-limit": [
|
|
51
51
|
{
|
|
52
52
|
"name": "devtools-bridge/attachJourneyDevtools",
|
|
53
53
|
"path": "dist/index.js",
|
|
54
54
|
"import": "{ attachJourneyDevtools }",
|
|
55
|
-
"limit": "
|
|
55
|
+
"limit": "3 kB"
|
|
56
56
|
}
|
|
57
57
|
],
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "pnpm run clean && node ./scripts/build.mjs && tsc -p tsconfig.build.json && node ../../scripts/copy-types.mjs dist",
|
|
60
|
-
"clean": "rm -rf dist",
|
|
60
|
+
"clean": "rm -rf dist tsconfig.build.tsbuildinfo",
|
|
61
|
+
"coverage": "pnpm --workspace-root vitest run --coverage --coverage.include=packages/devtools-bridge/src/** --coverage.reporter=text-summary",
|
|
61
62
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
62
63
|
"publint": "publint",
|
|
63
64
|
"attw": "attw --pack .",
|
package/dist/bridge.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,cAAc,EAGf,MAAM,qBAAqB,CAAC;AAsB7B,MAAM,MAAM,4BAA4B,GAAG;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAoRF,eAAO,MAAM,qBAAqB,GAChC,QAAQ,EACR,OAAO,SAAS,MAAM,EACtB,UAAU,SAAS,MAAM,EACzB,WAAW,SAAS,sBAAsB,CAAC,UAAU,CAAC,EAEtD,SAAS,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,EACnE,UAAS,4BAAiC,KACzC,CAAC,MAAM,IAAI,CAuJb,CAAC"}
|
package/dist/index.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,KAAK,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAEpF,OAAO,EACL,wBAAwB,EACxB,iCAAiC,EACjC,8BAA8B,EAC9B,iCAAiC,EACjC,wBAAwB,EACxB,yBAAyB,EACzB,+BAA+B,EAC/B,kCAAkC,EAClC,KAAK,yCAAyC,EAC9C,KAAK,0CAA0C,EAC/C,KAAK,6BAA6B,EAClC,KAAK,qCAAqC,EAC1C,KAAK,qCAAqC,EAC1C,KAAK,uCAAuC,EAC5C,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,gCAAgC,EACrC,KAAK,uCAAuC,EAC5C,KAAK,0BAA0B,EAC/B,KAAK,mCAAmC,EACxC,KAAK,8BAA8B,EACpC,MAAM,YAAY,CAAC"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,KAAK,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAEpF,OAAO,EACL,wBAAwB,EACxB,iCAAiC,EACjC,8BAA8B,EAC9B,iCAAiC,EACjC,wBAAwB,EACxB,yBAAyB,EACzB,+BAA+B,EAC/B,kCAAkC,EAClC,KAAK,yCAAyC,EAC9C,KAAK,0CAA0C,EAC/C,KAAK,6BAA6B,EAClC,KAAK,qCAAqC,EAC1C,KAAK,qCAAqC,EAC1C,KAAK,uCAAuC,EAC5C,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,gCAAgC,EACrC,KAAK,uCAAuC,EAC5C,KAAK,0BAA0B,EAC/B,KAAK,mCAAmC,EACxC,KAAK,8BAA8B,EACpC,MAAM,YAAY,CAAC"}
|
package/dist/protocol.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAElF,eAAO,MAAM,iCAAiC,EAAG,CAAU,CAAC;AAC5D,eAAO,MAAM,wBAAwB,EAAG,4BAAqC,CAAC;AAE9E,eAAO,MAAM,8BAA8B,EAAG,sBAA+B,CAAC;AAC9E,eAAO,MAAM,iCAAiC,EAAG,yBAAkC,CAAC;AAEpF,MAAM,MAAM,qBAAqB,GAC7B,OAAO,8BAA8B,GACrC,OAAO,iCAAiC,CAAC;AAE7C,MAAM,MAAM,6BAA6B,GAAG,qBAAqB,CAAC;AAElE,MAAM,MAAM,mCAAmC,GAA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,CAAC;AAEF,MAAM,MAAM,6BAA6B,GACrC,qCAAqC,GACrC,uCAAuC,GACvC,qCAAqC,GACrC,0CAA0C,GAC1C,yCAAyC,CAAC;AAE9C,MAAM,MAAM,gCAAgC,GAAG,uCAAuC,CAAC;AAEvF,MAAM,MAAM,uBAAuB,GAC/B,6BAA6B,GAC7B,gCAAgC,CAAC;AAsGrC,eAAO,MAAM,wBAAwB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,sBA+ClE,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAC1C,OAAO,OAAO,KACb,KAAK,IAAI,6BAqCX,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAC7C,OAAO,OAAO,KACb,KAAK,IAAI,gCAgBX,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,uBACiB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"fileNames":["../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.dom.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.scripthost.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.full.d.ts","../../core/dist/types.d.ts","../../core/dist/machine.d.ts","../../core/dist/persistence.d.ts","../../core/dist/index.d.ts","../src/protocol.ts","../src/bridge.ts","../src/index.ts"],"fileIdsList":[[52,53,54],[52],[55,56],[56,57],[55]],"fileInfos":[{"version":"c430d44666289dae81f30fa7b2edebf186ecc91a2d4c71266ea6ae76388792e1","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"080941d9f9ff9307f7e27a83bcd888b7c8270716c39af943532438932ec1d0b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"2e80ee7a49e8ac312cc11b77f1475804bee36b3b2bc896bead8b6e1266befb43","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7a3c8b952931daebdfc7a2897c53c0a1c73624593fa070e46bd537e64dcd20a","affectsGlobalScope":true,"impliedFormat":1},{"version":"80e18897e5884b6723488d4f5652167e7bb5024f946743134ecc4aa4ee731f89","affectsGlobalScope":true,"impliedFormat":1},{"version":"cd034f499c6cdca722b60c04b5b1b78e058487a7085a8e0d6fb50809947ee573","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"fb0f136d372979348d59b3f5020b4cdb81b5504192b1cacff5d1fbba29378aa1","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"a680117f487a4d2f30ea46f1b4b7f58bef1480456e18ba53ee85c2746eeca012","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"d6d7ae4d1f1f3772e2a3cde568ed08991a8ae34a080ff1151af28b7f798e22ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"1305d1e76ca44e30fb8b2b8075fa522b83f60c0bcf5d4326a9d2cf79b53724f8","impliedFormat":1},"b9dc4534a8b8abf7a231fdee9aeba909fe6a5d9d8ffc64336eb662c28164af1c","3d3e7b4efbe8891f0b0f37b832ce6adf587b32c4de869b557c2e2613d5363a65","64a4320c603b4e6640d2813fd4817ab65f14fe57327373634a10ddc0016b6435","bdd8041fa7979a7f7a52eea92f4ecafc4155db4f964e0339b57ea05ca57afb8d",{"version":"568738a9d1b96222f590d48d5bc2d14e3ab373fb8734bce4ba17710d5722571a","signature":"4ee0b9b6f5a48133815942f26006670762a6474dd19adf0e832d3e169ae3170e"},{"version":"ea895d13bb32ec03bd5b77fc0900c404a832c2815e7ecaacf3b4bc38001a4d26","signature":"203d912c803ff7c6d416349a607b31af12b251f408aa1fe16bfa16999627a85b"},{"version":"c115030defbf2713e8f30d559a8e2b00a4b4971b1ac990f7e7c6219a3793f85a","signature":"d245711e9cc3d763a5e1d4fe5ba153635a9cd37bf3e36ee9db0f8d937daf9410"}],"root":[[56,58]],"options":{"composite":true,"declaration":true,"declarationDir":"./","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"exactOptionalPropertyTypes":true,"jsx":4,"module":99,"noFallthroughCasesInSwitch":true,"noUncheckedIndexedAccess":true,"outDir":"./","rootDir":"../src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":7,"tsBuildInfoFile":"./tsconfig.build.tsbuildinfo"},"referencedMap":[[55,1],[53,2],[54,2],[57,3],[58,4],[56,5]],"latestChangedDtsFile":"./index.d.ts","version":"5.9.3"}
|