@statelyai/sdk 0.34.1 → 0.35.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.
Files changed (40) hide show
  1. package/README.md +32 -26
  2. package/dist/assetStorage.d.mts +1 -1
  3. package/dist/auth.d.mts +14 -1
  4. package/dist/bin.mjs +1 -3
  5. package/dist/editor-sync-types-DNFk7Xtj.d.mts +53 -0
  6. package/dist/editorHostProtocol.d.mts +197 -0
  7. package/dist/{editorHostProtocol-B2_t3Le7.mjs → editorHostProtocol.mjs} +1 -1
  8. package/dist/embed.d.mts +3 -3
  9. package/dist/embed.mjs +2 -2
  10. package/dist/{graph-Ciocekxl.d.mts → graph-B6xUxqR5.d.mts} +1 -1
  11. package/dist/graph.d.mts +1 -1
  12. package/dist/{index-DZivqh0u.d.mts → index-CoxF4Saw.d.mts} +36 -252
  13. package/dist/index.d.mts +8 -31
  14. package/dist/index.mjs +5 -9
  15. package/dist/{inspect-BbvfH0Q1.d.mts → inspect-DCdu0ST3.d.mts} +1 -1
  16. package/dist/{inspect-DW30GMge.mjs → inspect-GSXRhzOx.mjs} +48 -32
  17. package/dist/inspect.d.mts +2 -2
  18. package/dist/inspect.mjs +2 -2
  19. package/dist/patchTypes.d.mts +1 -1
  20. package/dist/{protocol-B7q2lWj_.d.mts → protocol-nOWsz3UV.d.mts} +3 -3
  21. package/dist/protocol.d.mts +1 -1
  22. package/dist/relay.d.mts +1 -1
  23. package/dist/relay.mjs +40 -1
  24. package/dist/{studio-CKdEPGKY.d.mts → studio-3ujfe2z0.d.mts} +2 -2
  25. package/dist/{openapi-BTDjYWXd.mjs → studio-Bn3alVku.mjs} +637 -1
  26. package/dist/studio.d.mts +1 -1
  27. package/dist/studio.mjs +2 -2
  28. package/dist/{version-BEfUEyPL.mjs → version-DECst76A.mjs} +1 -1
  29. package/package.json +21 -17
  30. package/dist/auth-CVFc85uF.d.mts +0 -15
  31. package/dist/dist-NJFkDQjK.mjs +0 -8134
  32. package/dist/editor-sync-types-D7YYz6fb.d.mts +0 -98
  33. package/dist/editorHostSession-Bj5YcijC.mjs +0 -912
  34. package/dist/editorHostSession-DBLSyHJs.d.mts +0 -325
  35. package/dist/editorHostSession.d.mts +0 -2
  36. package/dist/editorHostSession.mjs +0 -6
  37. package/dist/statelyPragma-YtVaBuIe.mjs +0 -102
  38. package/dist/studio-BZP6DaIO.mjs +0 -638
  39. package/dist/sync.d.mts +0 -86
  40. package/dist/sync.mjs +0 -4646
@@ -1,5 +1,3 @@
1
- import { UnknownMachineConfig } from "xstate";
2
-
3
1
  //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/json-schema.d.cts
4
2
  type _JSONSchema = boolean | JSONSchema;
5
3
  type JSONSchema = {
@@ -2553,6 +2551,13 @@ declare const graphPatchSchema: ZodDiscriminatedUnion<[ZodObject<{
2553
2551
  type GraphPatch = output<typeof graphPatchSchema>;
2554
2552
  /** AI-only schema: semantic ops + shared ops (no generic graph ops) */
2555
2553
  //#endregion
2554
+ //#region ../../node_modules/.pnpm/xstate@5.32.1/node_modules/xstate/dist/declarations/src/index.d.ts
2555
+ declare global {
2556
+ interface SymbolConstructor {
2557
+ readonly observable: symbol;
2558
+ }
2559
+ }
2560
+ //#endregion
2556
2561
  //#region ../../node_modules/.pnpm/xstate@6.0.0-alpha.51/node_modules/xstate/dist/declarations/src/index.d.ts
2557
2562
  declare global {
2558
2563
  interface SymbolConstructor {
@@ -2700,27 +2705,11 @@ interface JSONSchema7 {
2700
2705
  }
2701
2706
  //#endregion
2702
2707
  //#region ../graph-tools/dist/index.d.mts
2703
- declare const LEGACY_MACHINE_PROFILES: readonly ["xstate-v5", "xstate-v6-alpha"];
2704
- type LegacyMachineProfile = (typeof LEGACY_MACHINE_PROFILES)[number];
2705
2708
  //#endregion
2706
2709
  //#region src/profiles/profileRefs.d.ts
2707
2710
  type ProfileName = `@${string}/${string}`;
2708
2711
  type ProfileSpecifier = `${ProfileName}@${string}`;
2709
2712
  type ResolvedProfileRef = ProfileSpecifier;
2710
- type ProfileRefInput = ResolvedProfileRef | LegacyMachineProfile;
2711
- //#endregion
2712
- //#region src/codegenTypes.d.ts
2713
- interface CodeGenAction {
2714
- /** Graph-native block id, referenced by `@statelyai.action.*` transitions. */
2715
- id?: string;
2716
- type: string;
2717
- params?: Record<string, unknown>;
2718
- }
2719
- interface CodeGenGuard {
2720
- type: string;
2721
- code?: string;
2722
- params?: Record<string, unknown>;
2723
- }
2724
2713
  /**
2725
2714
  * Serialized inline expression directive.
2726
2715
  *
@@ -2746,186 +2735,6 @@ interface CodeImport {
2746
2735
  * A scalar `context`/`input`/`output` literal, kept verbatim from the source
2747
2736
  * instead of being wrapped as a code expression.
2748
2737
  */
2749
- type ScalarGraphValue = string | number | boolean | null;
2750
- interface CodeGenInvoke {
2751
- src: string;
2752
- /** Exact authored actor-logic expression for inline/direct actor sources. */
2753
- srcExpression?: CodeExpression;
2754
- id: string;
2755
- invocationId?: string;
2756
- registryKey?: string;
2757
- timeout?: number | string | CodeExpression;
2758
- input?: Record<string, unknown> | CodeExpression | ScalarGraphValue;
2759
- output?: Record<string, unknown> | CodeExpression | ScalarGraphValue;
2760
- }
2761
- interface CodeGenNodeData {
2762
- nodeId?: string | null;
2763
- key: string;
2764
- type?: 'normal' | 'parallel' | 'final' | 'history' | 'choice' | null;
2765
- initialId?: string | null;
2766
- initialInput?: Record<string, unknown> | CodeExpression | ScalarGraphValue;
2767
- timeout?: number | string | CodeExpression;
2768
- route?: Record<string, unknown> | CodeExpression;
2769
- history?: 'shallow' | 'deep' | boolean;
2770
- output?: Record<string, unknown> | CodeExpression | ScalarGraphValue;
2771
- schemas?: {
2772
- context?: Record<string, JSONSchema7> | null;
2773
- input?: JSONSchema7 | null;
2774
- output?: JSONSchema7 | null;
2775
- } | null;
2776
- entry?: CodeGenAction[];
2777
- exit?: CodeGenAction[];
2778
- invokes?: CodeGenInvoke[];
2779
- tags?: Array<string | {
2780
- name: string;
2781
- }>;
2782
- description?: string | null;
2783
- meta?: Record<string, unknown> | null;
2784
- color?: string;
2785
- parentId?: string | null;
2786
- temp?: unknown;
2787
- }
2788
- interface CodeGenEdgeData {
2789
- eventType: string;
2790
- /** Additional resolved targets for a parallel multi-target transition. */
2791
- additionalTargetIds?: string[];
2792
- matches?: Record<string, unknown>;
2793
- transitionType?: 'normal' | 'targetless' | 'reenter';
2794
- guard?: CodeGenGuard | null;
2795
- context?: Record<string, unknown> | CodeExpression;
2796
- input?: Record<string, unknown> | CodeExpression | ScalarGraphValue;
2797
- actions?: CodeGenAction[];
2798
- description?: string | null;
2799
- color?: string;
2800
- meta?: Record<string, unknown> | null;
2801
- temp?: unknown;
2802
- /** Derived visualization edge for a destination state's `route` config. */
2803
- route?: boolean;
2804
- }
2805
- interface CodeGenImplementation {
2806
- id: string;
2807
- name: string;
2808
- description?: string | null;
2809
- icon?: string;
2810
- paramsSchema?: JSONSchema7 | null;
2811
- code?: {
2812
- body: string;
2813
- lang?: string;
2814
- imports?: CodeImport[];
2815
- } | null;
2816
- }
2817
- interface CodeGenActorImplementation {
2818
- id: string;
2819
- name: string;
2820
- description?: string | null;
2821
- icon?: string;
2822
- inputSchema?: JSONSchema7 | null;
2823
- outputSchema?: JSONSchema7 | null;
2824
- code?: {
2825
- body: string;
2826
- lang?: string;
2827
- imports?: CodeImport[];
2828
- } | null;
2829
- }
2830
- interface CodeGenGraphData {
2831
- profile?: ProfileRefInput;
2832
- version?: string | null;
2833
- options?: {
2834
- maxIterations?: number;
2835
- } | null;
2836
- internalEvents?: string[] | null;
2837
- context?: Record<string, unknown> | `{{${string}}}` | CodeExpression | null;
2838
- schemas?: {
2839
- context?: Record<string, JSONSchema7> | null;
2840
- events?: Record<string, JSONSchema7> | null;
2841
- internalEvents?: Record<string, JSONSchema7> | null;
2842
- emitted?: Record<string, JSONSchema7> | null;
2843
- actions?: Record<string, unknown> | null;
2844
- guards?: Record<string, unknown> | null;
2845
- children?: Record<string, JSONSchema7> | null;
2846
- input?: JSONSchema7 | null;
2847
- output?: JSONSchema7 | null;
2848
- tags?: JSONSchema7 | null;
2849
- meta?: JSONSchema7 | null;
2850
- } | null;
2851
- implementations?: {
2852
- actions: CodeGenImplementation[];
2853
- guards: CodeGenImplementation[];
2854
- actors: CodeGenActorImplementation[];
2855
- delays: CodeGenImplementation[];
2856
- } | null;
2857
- }
2858
- interface CodeGenNode {
2859
- id: string;
2860
- parentId?: string | null;
2861
- data: CodeGenNodeData;
2862
- }
2863
- interface CodeGenEdge {
2864
- id: string;
2865
- sourceId: string;
2866
- targetId: string;
2867
- data: CodeGenEdgeData;
2868
- }
2869
- interface CodeGenGraph {
2870
- id: string;
2871
- nodes: CodeGenNode[];
2872
- edges: CodeGenEdge[];
2873
- data: CodeGenGraphData;
2874
- } //#endregion
2875
- //#region src/graphToMachineConfig.d.ts
2876
- interface MachineConfigOptions {
2877
- showDescriptions?: boolean;
2878
- showMeta?: boolean;
2879
- /**
2880
- * Emit inline-code guards as a `{ type }` reference instead of an inline code
2881
- * expression directive. The simulation needs this: it can't evaluate guard
2882
- * source, so it stubs each guard by `type` (see getSimImplementations). A
2883
- * code-expression guard has no `type`, so XState reads `undefined` and throws
2884
- * "Guard 'undefined' is not implemented" the moment that transition is taken.
2885
- */
2886
- inlineGuardsAsTypeRef?: boolean;
2887
- /**
2888
- * Keep `xstate.choose` as a structured `{ type, params }` action instead of
2889
- * lowering it to the v5 `enqueueActions` code expression. The v6 renderer
2890
- * needs this: v6 has neither `choose` nor `enqueueActions`, so it lowers the
2891
- * branches itself into the `enq` function body.
2892
- */
2893
- keepChooseStructured?: boolean;
2894
- }
2895
- declare function graphToMachineConfig(graph: CodeGenGraph, options?: MachineConfigOptions): UnknownMachineConfig; //#endregion
2896
- //#region src/serializeJS.d.ts
2897
- /**
2898
- * Serializes JavaScript values as JS source code (not JSON).
2899
- * - Unquoted keys for valid identifiers
2900
- * - Single-quoted strings
2901
- * - Omits undefined values
2902
- * - Supports RawCode for verbatim expressions
2903
- * - Supports inline expression directives for verbatim expressions
2904
- */
2905
- declare class RawCode {
2906
- code: string;
2907
- sourceValue?: object | undefined;
2908
- sourceSlice?: {
2909
- from: number;
2910
- to: number;
2911
- } | undefined;
2912
- constructor(code: string, sourceValue?: object | undefined, sourceSlice?: {
2913
- from: number;
2914
- to: number;
2915
- } | undefined);
2916
- }
2917
- declare function raw(code: string, sourceValue?: object, sourceSlice?: {
2918
- from: number;
2919
- to: number;
2920
- }): RawCode;
2921
- declare function serializeJS(value: unknown, indent?: number, step?: number): string; //#endregion
2922
- //#region src/textUtils.d.ts
2923
- /**
2924
- * Pure string utilities used by codegen.
2925
- */
2926
- /**
2927
- * Removes common leading whitespace from all non-empty lines.
2928
- */
2929
2738
  //#endregion
2930
2739
  //#region src/profiles/types.d.ts
2931
2740
  /**
@@ -3000,6 +2809,30 @@ type ProfileMigration = {
3000
2809
  migrate: (data: Readonly<ProfileDataSet>, context: ProfileProjectionContext) => ProfileProjectionResult;
3001
2810
  };
3002
2811
  type FormatId = string;
2812
+ type ProfileCodeLocation = {
2813
+ graph: Readonly<ProfileGraph>;
2814
+ path: readonly (string | number)[];
2815
+ parent: unknown;
2816
+ ancestors: readonly unknown[];
2817
+ };
2818
+ type ProfileCodeTarget = {
2819
+ kind: 'entity';
2820
+ id: string;
2821
+ label: string;
2822
+ } | {
2823
+ kind: 'source';
2824
+ id: string;
2825
+ label: string;
2826
+ sourceType: string;
2827
+ };
2828
+ type ProfileCodeBlock = {
2829
+ name: string;
2830
+ matches: (location: ProfileCodeLocation) => boolean;
2831
+ isValid: (code: string) => boolean;
2832
+ exportInvalid: (invalidCode: string) => string; /** Editor destination used to surface and navigate code diagnostics. */
2833
+ getTarget?: (location: ProfileCodeLocation) => ProfileCodeTarget | undefined; /** Object used by source generation to locate this block in a full document. */
2834
+ getSourceValue?: (location: ProfileCodeLocation) => object | undefined;
2835
+ };
3003
2836
  type ProfileFormatManifest = {
3004
2837
  format: FormatId;
3005
2838
  import?: boolean;
@@ -3053,7 +2886,10 @@ type ProfileManifest = {
3053
2886
  graph?: {
3054
2887
  dataSchema?: JSONSchema7;
3055
2888
  }; /** Profile-owned editor vocabulary. The canvas itself only assumes a graph. */
3056
- authoring?: ProfileAuthoringManifest;
2889
+ authoring?: ProfileAuthoringManifest; /** Profile-owned authored code locations and syntax-safe export fallbacks. */
2890
+ code?: {
2891
+ blocks: readonly ProfileCodeBlock[];
2892
+ };
3057
2893
  operations?: Partial<Record<'simulate' | 'validate' | 'export', boolean>>;
3058
2894
  restrictFormatsToListed?: boolean;
3059
2895
  features?: Record<string, boolean | Record<string, unknown>>;
@@ -3066,56 +2902,4 @@ type ProfileManifest = {
3066
2902
  editorDefaults?: Record<string, unknown>;
3067
2903
  };
3068
2904
  //#endregion
3069
- //#region src/graphToXStateTS.d.ts
3070
- interface XStateTSOptions extends MachineConfigOptions {
3071
- exportStyle?: 'named' | 'default' | 'none';
3072
- targetLanguage?: 'typescript' | 'javascript';
3073
- xstateVersion?: 5 | 6;
3074
- xstateV6SchemaFormat?: 'types' | 'zod';
3075
- }
3076
- declare function graphToXStateTS(graph: CodeGenGraph, options?: XStateTSOptions): string;
3077
- //#endregion
3078
- //#region src/graphToXStateV4TS.d.ts
3079
- interface XStateV4TSOptions extends MachineConfigOptions {
3080
- exportStyle?: 'named' | 'default' | 'none';
3081
- targetLanguage?: 'typescript' | 'javascript';
3082
- }
3083
- /**
3084
- * Emits XState **v4** (deprecated) TypeScript for a graph.
3085
- *
3086
- * The v4 surface differs from v5 in ways this emitter downgrades:
3087
- * `createMachine(config, options)` instead of `setup().createMachine()`,
3088
- * `cond` instead of `guard`, `services` instead of `actors`, `internal: false`
3089
- * instead of `reenter: true`, `done.invoke.X` / `error.platform.X` /
3090
- * `done.state.X` event names, and positional `(context, event)` implementation
3091
- * arguments (enabled by `predictableActionArguments`).
3092
- *
3093
- * Concepts with no v4 equivalent (`emit`, `spawnChild`, `enqueueActions`,
3094
- * actor-logic creators such as `fromPromise`) are emitted verbatim with a
3095
- * `// TODO: v5-only` marker rather than silently dropped.
3096
- */
3097
- declare function graphToXStateV4TS(graph: CodeGenGraph, options?: XStateV4TSOptions): string; //#endregion
3098
- //#region src/graphToXStateFSM.d.ts
3099
- interface XStateFSMOptions {
3100
- exportStyle?: 'named' | 'default' | 'none';
3101
- xstateV6SchemaFormat?: 'types' | 'zod';
3102
- }
3103
- declare function getXStateFSMCompatibilityIssues(graph: CodeGenGraph): string[];
3104
- declare function graphToXStateFSM(graph: CodeGenGraph, options?: XStateFSMOptions): string; //#endregion
3105
- //#region src/emittedNodeIds.d.ts
3106
- //#endregion
3107
- //#region src/jsonSchemaToTSType.d.ts
3108
- declare function jsonSchemaToTSType(schema: JSONSchema7 | undefined | null): string;
3109
- /**
3110
- * Build an inline context type string from the schemas.context record.
3111
- * Each key is a context property name, value is its JSONSchema7.
3112
- */
3113
- declare function contextSchemaToTSType(context: Record<string, JSONSchema7> | null | undefined): string | null;
3114
- /**
3115
- * Build an event union type from the schemas.events record.
3116
- * Each key is the event type name, value describes the payload properties.
3117
- */
3118
- declare function eventsSchemaToTSType(events: Record<string, JSONSchema7> | null | undefined): string | null; //#endregion
3119
- //#region src/jsonSchemaToZod.d.ts
3120
- //#endregion
3121
- export { ZodObject as A, ImplementationSourceType as C, ZodLiteral as D, ZodEnum as E, ZodUnknown as F, output as I, $loose as L, ZodRecord as M, ZodString as N, ZodNullable as O, ZodUnion as P, $strip as R, GraphPatch as S, ZodBoolean as T, raw as _, RawCode as a, CanvasColor as b, XStateV4TSOptions as c, getXStateFSMCompatibilityIssues as d, graphToMachineConfig as f, jsonSchemaToTSType as g, graphToXStateV4TS as h, ProfileManifest as i, ZodOptional as j, ZodNumber as k, contextSchemaToTSType as l, graphToXStateTS as m, CodeGenGraph as n, XStateFSMOptions as o, graphToXStateFSM as p, MachineConfigOptions as r, XStateTSOptions as s, CodeExpression as t, eventsSchemaToTSType as u, serializeJS as v, ZodArray as w, EditorStateType as x, ActionLocation as y };
2905
+ export { $strip as S, ZodString as _, EditorStateType as a, output as b, ZodArray as c, ZodLiteral as d, ZodNullable as f, ZodRecord as g, ZodOptional as h, CanvasColor as i, ZodBoolean as l, ZodObject as m, ProfileManifest as n, GraphPatch as o, ZodNumber as p, ActionLocation as r, ImplementationSourceType as s, CodeExpression as t, ZodEnum as u, ZodUnion as v, $loose as x, ZodUnknown as y };
package/dist/index.d.mts CHANGED
@@ -1,36 +1,13 @@
1
1
  import { StatelyApiClientOptions, StatelyApiError, StatelyApiUrlOptions, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
2
- import { S as GraphPatch, _ as raw, a as RawCode, c as XStateV4TSOptions, d as getXStateFSMCompatibilityIssues, f as graphToMachineConfig, g as jsonSchemaToTSType, h as graphToXStateV4TS, l as contextSchemaToTSType, m as graphToXStateTS, n as CodeGenGraph, o as XStateFSMOptions, p as graphToXStateFSM, r as MachineConfigOptions, s as XStateTSOptions, u as eventsSchemaToTSType, v as serializeJS, y as ActionLocation } from "./index-DZivqh0u.mjs";
3
- import { C as EventTypeData, S as DigraphNodeConfig, _ as studioMachineConverter, a as StatelyGraphData, b as DigraphConfig, c as StatelyInvoke, d as StudioAction, f as StudioEdge, g as fromStudioMachine, h as StudioNode, i as StatelyGraph, l as StatelyNodeData, m as StudioMachine, o as StatelyGuard, r as StatelyEdgeData, t as StatelyAction, v as toStudioMachine, w as StateNodeJSONData, x as DigraphEdgeConfig, y as DigraphAction } from "./graph-Ciocekxl.mjs";
4
- import { $t as createInspectionRoomUrls, B as InspectionSentEvent, D as ExportCallOptions, F as InitOptions, Gt as UploadResult, H as InspectorLoadedEvent, J as MachineVersionAutoSaveOptions, L as InspectionAction, M as INSPECTION_PROTOCOL_VERSION, N as INSPECTION_ROOM_QUERY_PARAM, O as ExportFormat, Q as ProjectEmbedMachine, Qt as createInspectionActorId, U as InspectorSettings, V as InspectionTakenTransition, Yt as ViewerOptions, Zt as assertEmbedExamples, _ as EmbedDocumentLanguage, an as EmbedPanelConfig, at as ProjectWorkspaceAction, b as EmbedEventName, ct as ProjectWorkspaceCapabilities, d as CommentsConfig, dt as ProjectWorkspaceMachineOrigin, en as getInspectionRoomId, f as EMBED_DOCUMENT_LANGUAGES, g as EmbedDocument, in as resolveInspectorSettings, k as ExportFormatMap, lt as ProjectWorkspaceConfig, m as EditorCapabilities, n as CapabilityDeniedCapability, nn as isEmbedExampleMachine, on as EmbedPanelPosition, ot as ProjectWorkspaceActionIcon, p as EMBED_DOCUMENT_LIMITS, pt as ProjectWorkspaceProject, r as CapabilityDeniedEvent, rn as mergeInspectorSettings, tn as isEmbedExample, ut as ProjectWorkspaceMachine, v as EmbedEventHandler, w as EmbedMode, x as EmbedExample, y as EmbedEventMap } from "./protocol-B7q2lWj_.mjs";
2
+ import { o as GraphPatch, r as ActionLocation } from "./index-CoxF4Saw.mjs";
3
+ import { C as EventTypeData, S as DigraphNodeConfig, _ as studioMachineConverter, a as StatelyGraphData, b as DigraphConfig, c as StatelyInvoke, d as StudioAction, f as StudioEdge, g as fromStudioMachine, h as StudioNode, i as StatelyGraph, l as StatelyNodeData, m as StudioMachine, o as StatelyGuard, r as StatelyEdgeData, t as StatelyAction, v as toStudioMachine, w as StateNodeJSONData, x as DigraphEdgeConfig, y as DigraphAction } from "./graph-B6xUxqR5.mjs";
4
+ import { $t as createInspectionRoomUrls, B as InspectionSentEvent, D as ExportCallOptions, F as InitOptions, Gt as UploadResult, H as InspectorLoadedEvent, J as MachineVersionAutoSaveOptions, L as InspectionAction, M as INSPECTION_PROTOCOL_VERSION, N as INSPECTION_ROOM_QUERY_PARAM, O as ExportFormat, Q as ProjectEmbedMachine, Qt as createInspectionActorId, U as InspectorSettings, V as InspectionTakenTransition, Yt as ViewerOptions, Zt as assertEmbedExamples, _ as EmbedDocumentLanguage, an as EmbedPanelConfig, at as ProjectWorkspaceAction, b as EmbedEventName, ct as ProjectWorkspaceCapabilities, d as CommentsConfig, dt as ProjectWorkspaceMachineOrigin, en as getInspectionRoomId, f as EMBED_DOCUMENT_LANGUAGES, g as EmbedDocument, in as resolveInspectorSettings, k as ExportFormatMap, lt as ProjectWorkspaceConfig, m as EditorCapabilities, n as CapabilityDeniedCapability, nn as isEmbedExampleMachine, on as EmbedPanelPosition, ot as ProjectWorkspaceActionIcon, p as EMBED_DOCUMENT_LIMITS, pt as ProjectWorkspaceProject, r as CapabilityDeniedEvent, rn as mergeInspectorSettings, tn as isEmbedExample, ut as ProjectWorkspaceMachine, v as EmbedEventHandler, w as EmbedMode, x as EmbedExample, y as EmbedEventMap } from "./protocol-nOWsz3UV.mjs";
5
5
  import { AssetUploadAdapter, AssetUploadContext, AssetUploadRequest, CreateS3AssetUploadAdapterOptions, CreateSupabaseAssetUploadAdapterOptions, S3UploadTarget, SupabaseStorageClient, createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
6
- import { i as getCredentialToken, n as StatelyCredential, r as createAuthorizationHeader, t as StatelyAuthMode } from "./auth-CVFc85uF.mjs";
7
- import { _ as EditorHostOutboundMessage, a as EditorHostWorkspaceSessionOptions, d as fetchEditorSyncAccess, f as EDITOR_PROTOCOL_VERSION, g as EditorHostInitOptions, h as EditorHostInboundMessage, i as EditorHostWorkspaceSession, l as RemoteEditorSyncBackendOptions, m as EditorHostExportFormat, n as EditorHostSessionOptions, o as EditorSourceHost, p as EditorHostDiagnostic, r as EditorHostWorkspaceMachine, s as EditorSyncBackend, t as EditorHostSession, u as createRemoteEditorSyncBackend, v as EditorHostValidationIssue } from "./editorHostSession-DBLSyHJs.mjs";
6
+ import { StatelyAuthMode, StatelyCredential, createAuthorizationHeader, getCredentialToken } from "./auth.mjs";
7
+ import { EDITOR_PROTOCOL_VERSION, EditorHostDiagnostic, EditorHostExportFormat, EditorHostInboundMessage, EditorHostInitOptions, EditorHostOutboundMessage, EditorHostValidationIssue } from "./editorHostProtocol.mjs";
8
8
  import { AssetConfig, EmbedEntity, EmbedFormatContext, EmbedFormatDefinition, EmbedGraph, EmbedProfileDefinition, StatelyEmbed, StatelyEmbedOptions, createStatelyEmbed } from "./embed.mjs";
9
- import { _ as createWebSocketTransport, a as InspectedTransition, c as InspectorDiscoveryEntry, d as ManualActorOptions, f as createInspector, g as createPostMessageTransport, h as TransportFailure, i as InspectedSnapshot, l as InspectorEvents, m as Transport, n as CreateInspectorOptions, o as Inspector, p as createStatelyInspector, r as InspectedEvent, s as InspectorConnection, t as AdoptedActor, u as InspectorInspectionEvent } from "./inspect-BbvfH0Q1.mjs";
10
- import { A as Machine, C as StudioMachineRecord, D as VerifyApiKeyResponse, E as UpdateProjectInput, F as ProjectVisibility, I as VerifyResult, L as XStateVersion, M as Project, N as ProjectMachineSummary, O as createStatelyClient, P as ProjectSummary, R as ResourceErrorCode, S as StudioClientOptions, T as UpdateMachineInput, _ as ProjectMachine, a as CreateMachineTemplate, b as StudioApiErrorOptions, c as EnsureProjectInput, d as ExtractedMachine, f as GetMachineOptions, g as ProjectData, h as LegacyUpdateMachineInput, i as CreateMachineInput, j as MachineVersion, k as ExtractedMachines, l as ExtractMachinesInput, m as LegacyProjectVisibility, n as CreateMachineFromDefinitionInput, o as CreateProjectInput, r as CreateMachineFromTemplateInput, s as DEFAULT_STATELY_BASE_URL, t as ConnectedRepo, u as ExtractMachinesResponse, v as RepoType, w as StudioRequestOptions, x as StudioClient, y as StudioApiError } from "./studio-CKdEPGKY.mjs";
9
+ import { _ as createWebSocketTransport, a as InspectedTransition, c as InspectorDiscoveryEntry, d as ManualActorOptions, f as createInspector, g as createPostMessageTransport, h as TransportFailure, i as InspectedSnapshot, l as InspectorEvents, m as Transport, n as CreateInspectorOptions, o as Inspector, p as createStatelyInspector, r as InspectedEvent, s as InspectorConnection, t as AdoptedActor, u as InspectorInspectionEvent } from "./inspect-DCdu0ST3.mjs";
10
+ import { A as Machine, C as StudioMachineRecord, D as VerifyApiKeyResponse, E as UpdateProjectInput, F as ProjectVisibility, I as VerifyResult, L as XStateVersion, M as Project, N as ProjectMachineSummary, O as createStatelyClient, P as ProjectSummary, R as ResourceErrorCode, S as StudioClientOptions, T as UpdateMachineInput, _ as ProjectMachine, a as CreateMachineTemplate, b as StudioApiErrorOptions, c as EnsureProjectInput, d as ExtractedMachine, f as GetMachineOptions, g as ProjectData, h as LegacyUpdateMachineInput, i as CreateMachineInput, j as MachineVersion, k as ExtractedMachines, l as ExtractMachinesInput, m as LegacyProjectVisibility, n as CreateMachineFromDefinitionInput, o as CreateProjectInput, r as CreateMachineFromTemplateInput, s as DEFAULT_STATELY_BASE_URL, t as ConnectedRepo, u as ExtractMachinesResponse, v as RepoType, w as StudioRequestOptions, x as StudioClient, y as StudioApiError } from "./studio-3ujfe2z0.mjs";
11
11
  import { OAuthAuthorizationServerMetadata, OAuthClientRegistrationResponse, OAuthProtectedResourceMetadata, OAuthTokenResponse, PkcePair, buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
12
- import { PlanSyncOptions, PullSyncResult, PushLocalMachineLinksResult, PushSyncOptions, PushSyncProjectOptions, PushSyncResult, ResolvedSyncInput, SyncInputFormat, SyncPlan, SyncPlanSummary } from "./sync.mjs";
13
12
  import { CreateInspectionRelayOptions, InspectionRelay, InspectionRelayEffect, InspectionRelayPeer, InspectionRelayRole, InspectionRelaySnapshot, createInspectionRelay } from "./relay.mjs";
14
- //#region src/statelyPragma.d.ts
15
- interface StatelyPragma {
16
- tag: '@statelyai';
17
- id?: string;
18
- fields: Record<string, string>;
19
- start: number;
20
- end: number;
21
- }
22
- interface StatelyPragmaAttachment {
23
- machineStart: number;
24
- attachStart: number;
25
- pragma?: StatelyPragma;
26
- }
27
- interface UpsertStatelyPragmaOptions {
28
- fileName?: string;
29
- machineIndex?: number;
30
- lineEnding?: '\n' | '\r\n';
31
- }
32
- declare function findStatelyPragmaAttachments(sourceText: string, fileName?: string): StatelyPragmaAttachment[];
33
- declare function getStatelyPragma(sourceText: string, fileName?: string, machineIndex?: number): StatelyPragma | undefined;
34
- declare function upsertStatelyPragma(sourceText: string, id: string, options?: UpsertStatelyPragmaOptions): string;
35
- //#endregion
36
- export { type ActionLocation, type AdoptedActor, type AssetConfig, type AssetUploadAdapter, type AssetUploadContext, type AssetUploadRequest, type CapabilityDeniedCapability, type CapabilityDeniedEvent, type CodeGenGraph, type CommentsConfig, type ConnectedRepo, type CreateInspectionRelayOptions, type CreateInspectorOptions, type CreateMachineFromDefinitionInput, type CreateMachineFromTemplateInput, type CreateMachineInput, type CreateMachineTemplate, type CreateProjectInput, type CreateS3AssetUploadAdapterOptions, type CreateSupabaseAssetUploadAdapterOptions, DEFAULT_STATELY_BASE_URL, type DigraphAction, type DigraphConfig, type DigraphEdgeConfig, type DigraphNodeConfig, EDITOR_PROTOCOL_VERSION, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, type EditorCapabilities, type EditorHostDiagnostic, type EditorHostExportFormat, type EditorHostInboundMessage, type EditorHostInitOptions, type EditorHostOutboundMessage, EditorHostSession, type EditorHostSessionOptions, type EditorHostValidationIssue, type EditorHostWorkspaceMachine, EditorHostWorkspaceSession, type EditorHostWorkspaceSessionOptions, type EditorSourceHost, type EditorSyncBackend, type EmbedDocument, type EmbedDocumentLanguage, type EmbedEntity, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedExample, type EmbedFormatContext, type EmbedFormatDefinition, type EmbedGraph, type EmbedMode, type EmbedPanelConfig, type EmbedPanelPosition, type EmbedProfileDefinition, type EnsureProjectInput, type EventTypeData, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type ExtractMachinesInput, type ExtractMachinesResponse, type ExtractedMachine, type ExtractedMachines, type GetMachineOptions, type GraphPatch, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, type InitOptions, type InspectedEvent, type InspectedSnapshot, type InspectedTransition, type InspectionAction, type InspectionRelay, type InspectionRelayEffect, type InspectionRelayPeer, type InspectionRelayRole, type InspectionRelaySnapshot, type InspectionSentEvent, type InspectionTakenTransition, type Inspector, type InspectorConnection, type InspectorDiscoveryEntry, type InspectorEvents, type InspectorInspectionEvent, type InspectorLoadedEvent, type InspectorSettings, type LegacyProjectVisibility, type LegacyUpdateMachineInput, type Machine, type MachineConfigOptions, type MachineVersion, type MachineVersionAutoSaveOptions, type ManualActorOptions, type OAuthAuthorizationServerMetadata, type OAuthClientRegistrationResponse, type OAuthProtectedResourceMetadata, type OAuthTokenResponse, type PkcePair, type PlanSyncOptions, type Project, type ProjectData, type ProjectEmbedMachine, type ProjectMachine, type ProjectMachineSummary, type ProjectSummary, type ProjectVisibility, type ProjectWorkspaceAction, type ProjectWorkspaceActionIcon, type ProjectWorkspaceCapabilities, type ProjectWorkspaceConfig, type ProjectWorkspaceMachine, type ProjectWorkspaceMachineOrigin, type ProjectWorkspaceProject, type PullSyncResult, type PushLocalMachineLinksResult, type PushSyncOptions, type PushSyncProjectOptions, type PushSyncResult, RawCode, type RemoteEditorSyncBackendOptions, type RepoType, type ResolvedSyncInput, type ResourceErrorCode, type S3UploadTarget, type StateNodeJSONData, type StatelyAction, type StatelyApiClientOptions, StatelyApiError, type StatelyApiUrlOptions, type StatelyAuthMode, type StatelyCredential, type StatelyEdgeData, type StatelyEmbed, type StatelyEmbedOptions, type StatelyGraph, type StatelyGraphData, type StatelyGuard, type StatelyInvoke, type StatelyNodeData, type StatelyPragma, type StatelyPragmaAttachment, type StudioAction, StudioApiError, type StudioApiErrorOptions, type StudioClient, type StudioClientOptions, type StudioEdge, type StudioMachine, type StudioMachineRecord, type StudioNode, type StudioRequestOptions, type SupabaseStorageClient, type SyncInputFormat, type SyncPlan, type SyncPlanSummary, type Transport, type TransportFailure, type UpdateMachineInput, type UpdateProjectInput, type UploadResult, type UpsertStatelyPragmaOptions, type VerifyApiKeyResponse, type VerifyResult, type ViewerOptions, type XStateFSMOptions, type XStateTSOptions, type XStateV4TSOptions, type XStateVersion, assertEmbedExamples, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createInspectionActorId, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createRemoteEditorSyncBackend, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, fetchEditorSyncAccess, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getInspectionRoomId, getStatelyPragma, getXStateFSMCompatibilityIssues, graphToMachineConfig, graphToXStateFSM, graphToXStateTS, graphToXStateV4TS, isEmbedExample, isEmbedExampleMachine, jsonSchemaToTSType, mergeInspectorSettings, raw, refreshToken, registerOAuthClient, resolveInspectorSettings, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
13
+ export { type ActionLocation, type AdoptedActor, type AssetConfig, type AssetUploadAdapter, type AssetUploadContext, type AssetUploadRequest, type CapabilityDeniedCapability, type CapabilityDeniedEvent, type CommentsConfig, type ConnectedRepo, type CreateInspectionRelayOptions, type CreateInspectorOptions, type CreateMachineFromDefinitionInput, type CreateMachineFromTemplateInput, type CreateMachineInput, type CreateMachineTemplate, type CreateProjectInput, type CreateS3AssetUploadAdapterOptions, type CreateSupabaseAssetUploadAdapterOptions, DEFAULT_STATELY_BASE_URL, type DigraphAction, type DigraphConfig, type DigraphEdgeConfig, type DigraphNodeConfig, EDITOR_PROTOCOL_VERSION, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, type EditorCapabilities, type EditorHostDiagnostic, type EditorHostExportFormat, type EditorHostInboundMessage, type EditorHostInitOptions, type EditorHostOutboundMessage, type EditorHostValidationIssue, type EmbedDocument, type EmbedDocumentLanguage, type EmbedEntity, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedExample, type EmbedFormatContext, type EmbedFormatDefinition, type EmbedGraph, type EmbedMode, type EmbedPanelConfig, type EmbedPanelPosition, type EmbedProfileDefinition, type EnsureProjectInput, type EventTypeData, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type ExtractMachinesInput, type ExtractMachinesResponse, type ExtractedMachine, type ExtractedMachines, type GetMachineOptions, type GraphPatch, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, type InitOptions, type InspectedEvent, type InspectedSnapshot, type InspectedTransition, type InspectionAction, type InspectionRelay, type InspectionRelayEffect, type InspectionRelayPeer, type InspectionRelayRole, type InspectionRelaySnapshot, type InspectionSentEvent, type InspectionTakenTransition, type Inspector, type InspectorConnection, type InspectorDiscoveryEntry, type InspectorEvents, type InspectorInspectionEvent, type InspectorLoadedEvent, type InspectorSettings, type LegacyProjectVisibility, type LegacyUpdateMachineInput, type Machine, type MachineVersion, type MachineVersionAutoSaveOptions, type ManualActorOptions, type OAuthAuthorizationServerMetadata, type OAuthClientRegistrationResponse, type OAuthProtectedResourceMetadata, type OAuthTokenResponse, type PkcePair, type Project, type ProjectData, type ProjectEmbedMachine, type ProjectMachine, type ProjectMachineSummary, type ProjectSummary, type ProjectVisibility, type ProjectWorkspaceAction, type ProjectWorkspaceActionIcon, type ProjectWorkspaceCapabilities, type ProjectWorkspaceConfig, type ProjectWorkspaceMachine, type ProjectWorkspaceMachineOrigin, type ProjectWorkspaceProject, type RepoType, type ResourceErrorCode, type S3UploadTarget, type StateNodeJSONData, type StatelyAction, type StatelyApiClientOptions, StatelyApiError, type StatelyApiUrlOptions, type StatelyAuthMode, type StatelyCredential, type StatelyEdgeData, type StatelyEmbed, type StatelyEmbedOptions, type StatelyGraph, type StatelyGraphData, type StatelyGuard, type StatelyInvoke, type StatelyNodeData, type StudioAction, StudioApiError, type StudioApiErrorOptions, type StudioClient, type StudioClientOptions, type StudioEdge, type StudioMachine, type StudioMachineRecord, type StudioNode, type StudioRequestOptions, type SupabaseStorageClient, type Transport, type TransportFailure, type UpdateMachineInput, type UpdateProjectInput, type UploadResult, type VerifyApiKeyResponse, type VerifyResult, type ViewerOptions, type XStateVersion, assertEmbedExamples, buildAuthorizeUrl, createAuthorizationHeader, createInspectionActorId, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, fromStudioMachine, getCredentialToken, getInspectionRoomId, isEmbedExample, isEmbedExampleMachine, mergeInspectorSettings, refreshToken, registerOAuthClient, resolveInspectorSettings, studioMachineConverter, toStudioMachine };
package/dist/index.mjs CHANGED
@@ -1,18 +1,14 @@
1
- import "./openapi-BTDjYWXd.mjs";
1
+ import { n as StudioApiError, r as createStatelyClient, t as DEFAULT_STATELY_BASE_URL } from "./studio-Bn3alVku.mjs";
2
2
  import { c as createInspectionRoomUrls, d as isEmbedExampleMachine, f as mergeInspectorSettings, i as INSPECTION_ROOM_QUERY_PARAM, l as getInspectionRoomId, n as EMBED_DOCUMENT_LIMITS, o as assertEmbedExamples, p as resolveInspectorSettings, r as INSPECTION_PROTOCOL_VERSION, s as createInspectionActorId, t as EMBED_DOCUMENT_LANGUAGES, u as isEmbedExample } from "./protocol-BsBGRISR.mjs";
3
- import { i as createWebSocketTransport, r as createPostMessageTransport } from "./version-BEfUEyPL.mjs";
4
- import { t as EDITOR_PROTOCOL_VERSION } from "./editorHostProtocol-B2_t3Le7.mjs";
3
+ import { i as createWebSocketTransport, r as createPostMessageTransport } from "./version-DECst76A.mjs";
4
+ import { EDITOR_PROTOCOL_VERSION } from "./editorHostProtocol.mjs";
5
5
  import { createStatelyEmbed } from "./embed.mjs";
6
- import { a as fetchEditorSyncAccess, i as createRemoteEditorSyncBackend, n as EditorHostWorkspaceSession, t as EditorHostSession } from "./editorHostSession-Bj5YcijC.mjs";
7
- import { n as StudioApiError, r as createStatelyClient, t as DEFAULT_STATELY_BASE_URL } from "./studio-BZP6DaIO.mjs";
8
- import { S as serializeJS, _ as graphToXStateV4TS, f as getXStateFSMCompatibilityIssues, g as graphToXStateTS, h as graphToXStateFSM, l as eventsSchemaToTSType, m as graphToMachineConfig, n as RawCode, o as contextSchemaToTSType, x as raw, y as jsonSchemaToTSType } from "./dist-NJFkDQjK.mjs";
9
6
  import { createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
10
- import { n as createStatelyInspector, t as createInspector } from "./inspect-DW30GMge.mjs";
7
+ import { n as createStatelyInspector, t as createInspector } from "./inspect-GSXRhzOx.mjs";
11
8
  import { createAuthorizationHeader, getCredentialToken } from "./auth.mjs";
12
9
  import { buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
13
10
  import { StatelyApiError, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
14
- import { n as getStatelyPragma, r as upsertStatelyPragma, t as findStatelyPragmaAttachments } from "./statelyPragma-YtVaBuIe.mjs";
15
11
  import { fromStudioMachine, studioMachineConverter, toStudioMachine } from "./graph.mjs";
16
12
  import { createInspectionRelay } from "./relay.mjs";
17
13
 
18
- export { DEFAULT_STATELY_BASE_URL, EDITOR_PROTOCOL_VERSION, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, EditorHostSession, EditorHostWorkspaceSession, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, RawCode, StatelyApiError, StudioApiError, assertEmbedExamples, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createInspectionActorId, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createRemoteEditorSyncBackend, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, fetchEditorSyncAccess, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getInspectionRoomId, getStatelyPragma, getXStateFSMCompatibilityIssues, graphToMachineConfig, graphToXStateFSM, graphToXStateTS, graphToXStateV4TS, isEmbedExample, isEmbedExampleMachine, jsonSchemaToTSType, mergeInspectorSettings, raw, refreshToken, registerOAuthClient, resolveInspectorSettings, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
14
+ export { DEFAULT_STATELY_BASE_URL, EDITOR_PROTOCOL_VERSION, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, StatelyApiError, StudioApiError, assertEmbedExamples, buildAuthorizeUrl, createAuthorizationHeader, createInspectionActorId, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, fromStudioMachine, getCredentialToken, getInspectionRoomId, isEmbedExample, isEmbedExampleMachine, mergeInspectorSettings, refreshToken, registerOAuthClient, resolveInspectorSettings, studioMachineConverter, toStudioMachine };
@@ -1,4 +1,4 @@
1
- import { B as InspectionSentEvent, D as ExportCallOptions, H as InspectorLoadedEvent, K as MachinePayload, L as InspectionAction, O as ExportFormat, R as InspectionClientMetadata, U as InspectorSettings, V as InspectionTakenTransition, Yt as ViewerOptions, k as ExportFormatMap, mt as ProtocolMessage, y as EmbedEventMap } from "./protocol-B7q2lWj_.mjs";
1
+ import { B as InspectionSentEvent, D as ExportCallOptions, H as InspectorLoadedEvent, K as MachinePayload, L as InspectionAction, O as ExportFormat, R as InspectionClientMetadata, U as InspectorSettings, V as InspectionTakenTransition, Yt as ViewerOptions, k as ExportFormatMap, mt as ProtocolMessage, y as EmbedEventMap } from "./protocol-nOWsz3UV.mjs";
2
2
 
3
3
  //#region src/transport.d.ts
4
4
  interface TransportFailure {
@@ -1,5 +1,5 @@
1
1
  import { c as createInspectionRoomUrls, f as mergeInspectorSettings, l as getInspectionRoomId, p as resolveInspectorSettings, r as INSPECTION_PROTOCOL_VERSION } from "./protocol-BsBGRISR.mjs";
2
- import { a as assertEmbedDocuments, c as createPendingExportManager, i as createWebSocketTransport, n as inspectionRuntime, o as assertEmbedPanels, s as createEventRegistry, t as SDK_VERSION } from "./version-BEfUEyPL.mjs";
2
+ import { a as assertEmbedDocuments, c as createPendingExportManager, i as createWebSocketTransport, n as inspectionRuntime, o as assertEmbedPanels, s as createEventRegistry, t as SDK_VERSION } from "./version-DECst76A.mjs";
3
3
 
4
4
  //#region src/openBrowser.ts
5
5
  async function openBrowser(url) {
@@ -252,12 +252,19 @@ function createInspector(options = {}) {
252
252
  function emitLocal(event, data) {
253
253
  const set = localListeners[event];
254
254
  if (!set) return;
255
- for (const handler of set) handler(data);
255
+ for (const handler of set) try {
256
+ handler(data);
257
+ } catch (cause) {
258
+ if (event === "error") console.error("Inspector error listener failed:", cause);
259
+ else emitLocal("error", {
260
+ code: "inspection_failed",
261
+ message: cause instanceof Error ? cause.message : String(cause)
262
+ });
263
+ }
256
264
  }
257
265
  const actors = /* @__PURE__ */ new Map();
258
266
  const resolvedSessionIds = /* @__PURE__ */ new WeakMap();
259
267
  const actorsByResolvedSessionId = /* @__PURE__ */ new Map();
260
- const runtimeRoots = /* @__PURE__ */ new WeakMap();
261
268
  const terminatedActors = /* @__PURE__ */ new WeakSet();
262
269
  const reboundActors = /* @__PURE__ */ new WeakSet();
263
270
  const manualSessionIds = /* @__PURE__ */ new Map();
@@ -265,28 +272,21 @@ function createInspector(options = {}) {
265
272
  const locallyRegistered = /* @__PURE__ */ new Set();
266
273
  /** v5 emits transition facets separately; accumulate them until snapshot. */
267
274
  const pendingTransitions = /* @__PURE__ */ new Map();
268
- function runtimeRootOf(actorRef, parentRef) {
269
- const known = runtimeRoots.get(actorRef);
270
- if (known) return known;
271
- let rootRef = parentRef ?? actorRef;
272
- while (rootRef._parent) rootRef = rootRef._parent;
273
- runtimeRoots.set(actorRef, rootRef);
274
- return rootRef;
275
- }
276
- function sessionIdOf(actorRef, parentRef = actorRef._parent, runtimeRoot) {
275
+ function sessionIdOf(actorRef, parentRef = actorRef._parent) {
277
276
  const existing = resolvedSessionIds.get(actorRef);
278
277
  if (existing) return existing;
279
- const parentSessionId = parentRef ? sessionIdOf(parentRef, parentRef._parent, runtimeRoot) : null;
278
+ const parentSessionId = parentRef ? sessionIdOf(parentRef, parentRef._parent) : null;
280
279
  const resolved = options.resolveSessionId?.(actorRef, actorRef.sessionId, parentSessionId) ?? actorRef.sessionId;
281
280
  if (typeof resolved !== "string" || resolved.length === 0) throw new Error("createInspector(): resolveSessionId must return a non-empty string.");
282
- assertSessionIdAvailable(actorRef, resolved, runtimeRoot ?? runtimeRootOf(actorRef, parentRef));
281
+ for (let ancestor = parentRef; ancestor; ancestor = ancestor._parent) if (sessionIdOf(ancestor, ancestor._parent) === resolved) throw new Error(`createInspector(): resolveSessionId returned duplicate id "${resolved}".`);
282
+ assertSessionIdAvailable(actorRef, resolved);
283
283
  return claimSessionId(actorRef, resolved);
284
284
  }
285
- function assertSessionIdAvailable(actorRef, resolved, nextRoot) {
285
+ function assertSessionIdAvailable(actorRef, resolved) {
286
286
  const claimedBy = actorsByResolvedSessionId.get(resolved);
287
287
  const claimedEntry = actors.get(resolved);
288
288
  if (claimedBy !== void 0 && claimedBy !== actorRef) {
289
- if (runtimeRootOf(claimedBy) === nextRoot || !terminatedActors.has(claimedBy) && sessionIdReuse !== "always") throw new Error(`createInspector(): resolveSessionId returned duplicate id "${resolved}".`);
289
+ if (!terminatedActors.has(claimedBy) && !isStoppedSnapshot(readSnapshot(claimedBy)) && sessionIdReuse !== "always") throw new Error(`createInspector(): resolveSessionId returned duplicate id "${resolved}".`);
290
290
  }
291
291
  if (claimedBy === void 0 && claimedEntry) throw new Error(`createInspector(): resolveSessionId returned duplicate id "${resolved}".`);
292
292
  }
@@ -310,7 +310,7 @@ function createInspector(options = {}) {
310
310
  function rootSessionIdOf(runtimeRootId, actorRef) {
311
311
  let rootRef = actorRef;
312
312
  while (rootRef._parent) rootRef = rootRef._parent;
313
- return rootRef.sessionId === runtimeRootId ? sessionIdOf(rootRef, void 0, rootRef) : runtimeRootId;
313
+ return rootRef.sessionId === runtimeRootId ? sessionIdOf(rootRef, void 0) : runtimeRootId;
314
314
  }
315
315
  function emitRegisterOnce(entry) {
316
316
  if (locallyRegistered.has(entry.sessionId)) return;
@@ -335,9 +335,9 @@ function createInspector(options = {}) {
335
335
  function toEntry(actorRef, rootActorId, details) {
336
336
  const parentRef = details?.parentRef ?? actorRef._parent;
337
337
  const sessionId = sessionIdOf(actorRef, parentRef);
338
- const snapshot = details?.snapshot ?? readSnapshot(actorRef);
339
- const serialized = snapshot === void 0 ? null : serializeSnapshot(snapshot);
340
- if (snapshot !== void 0) trackTermination(actorRef, snapshot);
338
+ const snapshot = details?.snapshot === null ? null : details?.snapshot ?? readSnapshot(actorRef);
339
+ const serialized = snapshot == null ? null : serializeSnapshot(snapshot);
340
+ if (snapshot != null) trackTermination(actorRef, snapshot);
341
341
  return {
342
342
  sessionId,
343
343
  actorId: details?.id ?? actorRef.id ?? sessionId,
@@ -364,27 +364,30 @@ function createInspector(options = {}) {
364
364
  function resolveActorTreeSessionIds(rootRef) {
365
365
  const pending = /* @__PURE__ */ new Map();
366
366
  const owners = /* @__PURE__ */ new Map();
367
- function visit(actorRef, parentRef) {
367
+ function visit(actorRef, parentRef, ancestorIds = /* @__PURE__ */ new Set()) {
368
368
  const existing = resolvedSessionIds.get(actorRef);
369
369
  const parentSessionId = parentRef ? resolvedSessionIds.get(parentRef) ?? pending.get(parentRef)?.resolved : null;
370
370
  const resolved = existing ?? options.resolveSessionId?.(actorRef, actorRef.sessionId, parentSessionId ?? null) ?? actorRef.sessionId;
371
371
  if (typeof resolved !== "string" || resolved.length === 0) throw new Error("createInspector(): resolveSessionId must return a non-empty string.");
372
+ if (ancestorIds.has(resolved)) throw new Error(`createInspector(): resolveSessionId returned duplicate id "${resolved}".`);
372
373
  const localOwner = owners.get(resolved);
373
- if (localOwner && localOwner !== actorRef) throw new Error(`createInspector(): resolveSessionId returned duplicate id "${resolved}".`);
374
+ if (localOwner && localOwner !== actorRef) {
375
+ if (sessionIdReuse !== "always" && !isStoppedSnapshot(readSnapshot(localOwner))) throw new Error(`createInspector(): resolveSessionId returned duplicate id "${resolved}".`);
376
+ }
374
377
  owners.set(resolved, actorRef);
375
378
  if (!existing) pending.set(actorRef, {
376
379
  resolved,
377
380
  parentRef
378
381
  });
379
- assertSessionIdAvailable(actorRef, resolved, rootRef);
382
+ assertSessionIdAvailable(actorRef, resolved);
380
383
  const children = actorRef.getSnapshot()?.children ?? {};
381
- for (const child of Object.values(children)) if (child) visit(child, actorRef);
384
+ const childAncestorIds = new Set(ancestorIds);
385
+ childAncestorIds.add(resolved);
386
+ for (const child of Object.values(children)) if (child) visit(child, actorRef, childAncestorIds);
382
387
  }
383
388
  visit(rootRef);
384
- for (const [actorRef, { resolved }] of pending) {
385
- runtimeRoots.set(actorRef, rootRef);
386
- claimSessionId(actorRef, resolved);
387
- }
389
+ for (const [actorRef, { resolved }] of pending) if (owners.get(resolved) === actorRef) claimSessionId(actorRef, resolved);
390
+ else resolvedSessionIds.set(actorRef, resolved);
388
391
  }
389
392
  /**
390
393
  * Walk the actor tree and populate the local `actors` map. Idempotent —
@@ -409,6 +412,7 @@ function createInspector(options = {}) {
409
412
  }
410
413
  function backfillActorTree(actorRef, rootActorId, publish = false) {
411
414
  const sessionId = sessionIdOf(actorRef);
415
+ if (!isCurrentOwner(actorRef)) return;
412
416
  const existing = actors.get(sessionId);
413
417
  const replaces = reboundActors.delete(actorRef);
414
418
  const entry = !existing || replaces ? toEntry(actorRef, rootActorId) : existing;
@@ -585,14 +589,16 @@ function createInspector(options = {}) {
585
589
  const isNewRoot = !observedRootIds.has(rootActorId);
586
590
  observedRootIds.add(rootActorId);
587
591
  switch (event.type) {
588
- case "@xstate.actor":
592
+ case "@xstate.actor": {
593
+ const initialSnapshot = event.snapshot ?? readSnapshot(event.actorRef);
589
594
  handleActor(event.actorRef, rootActorId, {
590
595
  parentRef: event.parentRef,
591
596
  id: event.id,
592
597
  source: event.src,
593
- snapshot: event.snapshot
598
+ snapshot: isStoppedSnapshot(initialSnapshot) ? initialSnapshot : null
594
599
  });
595
600
  break;
601
+ }
596
602
  case "@xstate.event": {
597
603
  const sessionId = sessionIdOf(event.actorRef);
598
604
  if (!actors.has(sessionId)) handleActor(event.actorRef, rootActorId);
@@ -626,6 +632,16 @@ function createInspector(options = {}) {
626
632
  }
627
633
  if (isNewRoot && !initSent) sendInit();
628
634
  }
635
+ function safelyHandleInspectionEvent(event) {
636
+ try {
637
+ handleInspectionEvent(event);
638
+ } catch (cause) {
639
+ emitLocal("error", {
640
+ code: "inspection_failed",
641
+ message: cause instanceof Error ? cause.message : String(cause)
642
+ });
643
+ }
644
+ }
629
645
  function attachActor(actor) {
630
646
  const root = actor;
631
647
  resolveActorTreeSessionIds(root);
@@ -638,7 +654,7 @@ function createInspector(options = {}) {
638
654
  }
639
655
  materializePendingInit();
640
656
  observedRootIds.add(rootActorId);
641
- const subscription = root.system.inspect(handleInspectionEvent);
657
+ const subscription = root.system.inspect(safelyHandleInspectionEvent);
642
658
  inspectedRoots.set(rootActorId, {
643
659
  actor: root,
644
660
  subscription
@@ -764,7 +780,7 @@ function createInspector(options = {}) {
764
780
  },
765
781
  inspectorUrl,
766
782
  ready,
767
- inspect: handleInspectionEvent,
783
+ inspect: safelyHandleInspectionEvent,
768
784
  attach: attachActor,
769
785
  on(event, handler) {
770
786
  if (!localListeners[event]) localListeners[event] = /* @__PURE__ */ new Set();
@@ -1,3 +1,3 @@
1
- import { B as InspectionSentEvent, D as ExportCallOptions, H as InspectorLoadedEvent, K as MachinePayload, L as InspectionAction, O as ExportFormat, U as InspectorSettings, V as InspectionTakenTransition, Yt as ViewerOptions, an as EmbedPanelConfig, b as EmbedEventName, g as EmbedDocument, k as ExportFormatMap, m as EditorCapabilities, v as EmbedEventHandler, w as EmbedMode, y as EmbedEventMap } from "./protocol-B7q2lWj_.mjs";
2
- import { a as InspectedTransition, c as InspectorDiscoveryEntry, d as ManualActorOptions, f as createInspector, i as InspectedSnapshot, l as InspectorEvents, m as Transport, n as CreateInspectorOptions, o as Inspector, p as createStatelyInspector, r as InspectedEvent, s as InspectorConnection, t as AdoptedActor, u as InspectorInspectionEvent } from "./inspect-BbvfH0Q1.mjs";
1
+ import { B as InspectionSentEvent, D as ExportCallOptions, H as InspectorLoadedEvent, K as MachinePayload, L as InspectionAction, O as ExportFormat, U as InspectorSettings, V as InspectionTakenTransition, Yt as ViewerOptions, an as EmbedPanelConfig, b as EmbedEventName, g as EmbedDocument, k as ExportFormatMap, m as EditorCapabilities, v as EmbedEventHandler, w as EmbedMode, y as EmbedEventMap } from "./protocol-nOWsz3UV.mjs";
2
+ import { a as InspectedTransition, c as InspectorDiscoveryEntry, d as ManualActorOptions, f as createInspector, i as InspectedSnapshot, l as InspectorEvents, m as Transport, n as CreateInspectorOptions, o as Inspector, p as createStatelyInspector, r as InspectedEvent, s as InspectorConnection, t as AdoptedActor, u as InspectorInspectionEvent } from "./inspect-DCdu0ST3.mjs";
3
3
  export { AdoptedActor, CreateInspectorOptions, EditorCapabilities, EmbedDocument, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, EmbedPanelConfig, ExportCallOptions, ExportFormat, ExportFormatMap, InspectedEvent, InspectedSnapshot, InspectedTransition, InspectionAction, InspectionSentEvent, InspectionTakenTransition, Inspector, InspectorConnection, InspectorDiscoveryEntry, InspectorEvents, InspectorInspectionEvent, InspectorLoadedEvent, InspectorSettings, MachinePayload, ManualActorOptions, Transport, ViewerOptions, createInspector, createStatelyInspector };
package/dist/inspect.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./protocol-BsBGRISR.mjs";
2
- import "./version-BEfUEyPL.mjs";
3
- import { n as createStatelyInspector, t as createInspector } from "./inspect-DW30GMge.mjs";
2
+ import "./version-DECst76A.mjs";
3
+ import { n as createStatelyInspector, t as createInspector } from "./inspect-GSXRhzOx.mjs";
4
4
 
5
5
  export { createInspector, createStatelyInspector };