@tinyactors/scxmljs 0.1.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/LICENSE +21 -0
- package/README.md +174 -0
- package/THIRD_PARTY_NOTICES +63 -0
- package/dist/bridge.d.ts +44 -0
- package/dist/bridge.js +254 -0
- package/dist/bridge.js.map +1 -0
- package/dist/clock.d.ts +113 -0
- package/dist/clock.js +310 -0
- package/dist/clock.js.map +1 -0
- package/dist/common.d.ts +15 -0
- package/dist/common.js +14 -0
- package/dist/common.js.map +1 -0
- package/dist/datamodel-base.d.ts +122 -0
- package/dist/datamodel-base.js +268 -0
- package/dist/datamodel-base.js.map +1 -0
- package/dist/datamodel-quickjs.d.ts +21 -0
- package/dist/datamodel-quickjs.js +286 -0
- package/dist/datamodel-quickjs.js.map +1 -0
- package/dist/datamodel-trusted.d.ts +1 -0
- package/dist/datamodel-trusted.js +149 -0
- package/dist/datamodel-trusted.js.map +1 -0
- package/dist/diagnostics.d.ts +39 -0
- package/dist/diagnostics.js +154 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/element-events.d.ts +85 -0
- package/dist/element-events.js +129 -0
- package/dist/element-events.js.map +1 -0
- package/dist/events.d.ts +31 -0
- package/dist/events.js +33 -0
- package/dist/events.js.map +1 -0
- package/dist/explorer/element.d.ts +150 -0
- package/dist/explorer/element.js +1791 -0
- package/dist/explorer/element.js.map +1 -0
- package/dist/explorer/layout.d.ts +43 -0
- package/dist/explorer/layout.js +50 -0
- package/dist/explorer/layout.js.map +1 -0
- package/dist/explorer/strings.d.ts +275 -0
- package/dist/explorer/strings.js +135 -0
- package/dist/explorer/strings.js.map +1 -0
- package/dist/explorer/styles.d.ts +10 -0
- package/dist/explorer/styles.js +265 -0
- package/dist/explorer/styles.js.map +1 -0
- package/dist/explorer/viewmodel.d.ts +284 -0
- package/dist/explorer/viewmodel.js +481 -0
- package/dist/explorer/viewmodel.js.map +1 -0
- package/dist/explorer.d.ts +21 -0
- package/dist/explorer.js +22 -0
- package/dist/explorer.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/model.d.ts +157 -0
- package/dist/model.js +485 -0
- package/dist/model.js.map +1 -0
- package/dist/session-events.d.ts +136 -0
- package/dist/session-events.js +114 -0
- package/dist/session-events.js.map +1 -0
- package/dist/session.d.ts +412 -0
- package/dist/session.js +1399 -0
- package/dist/session.js.map +1 -0
- package/dist/themes/tinyactors.css +44 -0
- package/dist/trusted.d.ts +15 -0
- package/dist/trusted.js +30 -0
- package/dist/trusted.js.map +1 -0
- package/dist/ui/announcer.d.ts +22 -0
- package/dist/ui/announcer.js +31 -0
- package/dist/ui/announcer.js.map +1 -0
- package/dist/ui/svg.d.ts +8 -0
- package/dist/ui/svg.js +29 -0
- package/dist/ui/svg.js.map +1 -0
- package/dist/ui/theme.d.ts +34 -0
- package/dist/ui/theme.js +151 -0
- package/dist/ui/theme.js.map +1 -0
- package/dist/view/element.d.ts +172 -0
- package/dist/view/element.js +1045 -0
- package/dist/view/element.js.map +1 -0
- package/dist/view/layout.d.ts +154 -0
- package/dist/view/layout.js +1122 -0
- package/dist/view/layout.js.map +1 -0
- package/dist/view/strings.d.ts +72 -0
- package/dist/view/strings.js +48 -0
- package/dist/view/strings.js.map +1 -0
- package/dist/view/styles.d.ts +1 -0
- package/dist/view/styles.js +115 -0
- package/dist/view/styles.js.map +1 -0
- package/dist/view.d.ts +20 -0
- package/dist/view.js +21 -0
- package/dist/view.js.map +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Events dispatched by an SCXMLSession. They are plain `Event` subclasses (not
|
|
3
|
+
* CustomEvent), with typed fields, so hosts can write
|
|
4
|
+
*
|
|
5
|
+
* session.addEventListener("microstep", (e) => e.entered)
|
|
6
|
+
*
|
|
7
|
+
* without casts. None of them bubble or are cancelable: a host observes a
|
|
8
|
+
* session and influences it only by sending events.
|
|
9
|
+
*/
|
|
10
|
+
import type { SCXMLEvent } from "./events.js";
|
|
11
|
+
import type { StateNode, TransitionNode } from "./model.js";
|
|
12
|
+
import type { OutboundSend, SCXMLSession } from "./session.js";
|
|
13
|
+
declare abstract class SessionEvent extends Event {
|
|
14
|
+
/** The session that dispatched the event. */
|
|
15
|
+
readonly session: SCXMLSession;
|
|
16
|
+
constructor(type: string, session: SCXMLSession);
|
|
17
|
+
}
|
|
18
|
+
/** One microstep: transitions taken, states exited and entered (in exit / entry order). */
|
|
19
|
+
export declare class MicrostepEvent extends SessionEvent {
|
|
20
|
+
/** The event being processed, or `undefined` for eventless transitions (and the initial step). */
|
|
21
|
+
readonly event?: SCXMLEvent;
|
|
22
|
+
/** The transitions taken, in document order. */
|
|
23
|
+
readonly transitions: TransitionNode[];
|
|
24
|
+
/** States exited, in exit order (innermost first). */
|
|
25
|
+
readonly exited: StateNode[];
|
|
26
|
+
/** States entered, in entry order (outermost first). */
|
|
27
|
+
readonly entered: StateNode[];
|
|
28
|
+
constructor(session: SCXMLSession, init: {
|
|
29
|
+
event?: SCXMLEvent;
|
|
30
|
+
transitions: TransitionNode[];
|
|
31
|
+
exited: StateNode[];
|
|
32
|
+
entered: StateNode[];
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/** The session is stable again (a macrostep finished); `event` is the external event that started it, if any. */
|
|
36
|
+
export declare class MacrostepEvent extends SessionEvent {
|
|
37
|
+
/** The external event that started the macrostep; `undefined` for the initial one. */
|
|
38
|
+
readonly event?: SCXMLEvent;
|
|
39
|
+
/** The active states, in document order. */
|
|
40
|
+
readonly configuration: StateNode[];
|
|
41
|
+
constructor(session: SCXMLSession, init: {
|
|
42
|
+
event?: SCXMLEvent;
|
|
43
|
+
configuration: StateNode[];
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/** `<log label expr>` */
|
|
47
|
+
export declare class LogEvent extends SessionEvent {
|
|
48
|
+
/** The `label` attribute (empty when absent). */
|
|
49
|
+
readonly label: string;
|
|
50
|
+
/** The value of `expr`, copied out of the data model (`undefined` when absent or empty). */
|
|
51
|
+
readonly value: unknown;
|
|
52
|
+
constructor(session: SCXMLSession, init: {
|
|
53
|
+
label: string;
|
|
54
|
+
value: unknown;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** The SCXML error events a session raises (spec §5.10.1). */
|
|
58
|
+
export type SCXMLErrorKind = "error.execution" | "error.communication" | "error.platform";
|
|
59
|
+
/**
|
|
60
|
+
* The session raised an SCXML error (`kind`). The chart can react to it with
|
|
61
|
+
* a transition on `error.*`; this event tells the host about it too.
|
|
62
|
+
*/
|
|
63
|
+
export declare class SCXMLErrorEvent extends SessionEvent {
|
|
64
|
+
/** Which error event the session placed on its internal queue. */
|
|
65
|
+
readonly kind: SCXMLErrorKind;
|
|
66
|
+
/** What went wrong, for people (not a stable format). */
|
|
67
|
+
readonly message: string;
|
|
68
|
+
/** The element whose evaluation failed, when known (for example the `<assign>`). */
|
|
69
|
+
readonly element: Element | null;
|
|
70
|
+
constructor(session: SCXMLSession, init: {
|
|
71
|
+
kind: SCXMLErrorKind;
|
|
72
|
+
message: string;
|
|
73
|
+
element?: Element | null;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/** A `<send>` was dispatched (after any delay) — to the SCXML processor or a custom one. */
|
|
77
|
+
export declare class SendEvent extends SessionEvent {
|
|
78
|
+
/** What was sent: event, target, type, data and sendid. */
|
|
79
|
+
readonly message: OutboundSend;
|
|
80
|
+
constructor(session: SCXMLSession, init: {
|
|
81
|
+
message: OutboundSend;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/** An `<invoke>` started. */
|
|
85
|
+
export declare class InvokeEvent extends SessionEvent {
|
|
86
|
+
/** The invocation's id (the `id` attribute, or a generated `stateid.platformid`). */
|
|
87
|
+
readonly invokeid: string;
|
|
88
|
+
/** The invoke type (for example the SCXML type URI or a custom invoker's name). */
|
|
89
|
+
readonly invokeType: string;
|
|
90
|
+
/** The state whose `<invoke>` started it. */
|
|
91
|
+
readonly state: StateNode;
|
|
92
|
+
constructor(session: SCXMLSession, init: {
|
|
93
|
+
invokeid: string;
|
|
94
|
+
invokeType: string;
|
|
95
|
+
state: StateNode;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/** An invoked SCXML child session was created (fires before it starts, so listeners see its first step). */
|
|
99
|
+
export declare class ChildSessionEvent extends SessionEvent {
|
|
100
|
+
/** The invocation's id. */
|
|
101
|
+
readonly invokeid: string;
|
|
102
|
+
/** The child session; add listeners now to see its first step. */
|
|
103
|
+
readonly child: SCXMLSession;
|
|
104
|
+
constructor(session: SCXMLSession, init: {
|
|
105
|
+
invokeid: string;
|
|
106
|
+
child: SCXMLSession;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/** The session terminated; `data` is the top-level final state's donedata, if any. */
|
|
110
|
+
export declare class DoneEvent extends SessionEvent {
|
|
111
|
+
/** The top-level final state's `<donedata>`, or `undefined` (always `undefined` after a cancel). */
|
|
112
|
+
readonly data: unknown;
|
|
113
|
+
constructor(session: SCXMLSession, init: {
|
|
114
|
+
data: unknown;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/** Event names → event classes, for `session.addEventListener(type, listener)` without casts. */
|
|
118
|
+
export interface SessionEventMap {
|
|
119
|
+
/** After every microstep. */
|
|
120
|
+
microstep: MicrostepEvent;
|
|
121
|
+
/** When the session is stable again after an external event (and after the initial step). */
|
|
122
|
+
macrostep: MacrostepEvent;
|
|
123
|
+
/** A `<log>` executed. */
|
|
124
|
+
log: LogEvent;
|
|
125
|
+
/** An `error.*` event was raised. */
|
|
126
|
+
error: SCXMLErrorEvent;
|
|
127
|
+
/** A `<send>` was dispatched. */
|
|
128
|
+
send: SendEvent;
|
|
129
|
+
/** An `<invoke>` started. */
|
|
130
|
+
invoke: InvokeEvent;
|
|
131
|
+
/** An invoked SCXML child session was created. */
|
|
132
|
+
child: ChildSessionEvent;
|
|
133
|
+
/** The session terminated. */
|
|
134
|
+
done: DoneEvent;
|
|
135
|
+
}
|
|
136
|
+
export {};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
class SessionEvent extends Event {
|
|
2
|
+
/** The session that dispatched the event. */
|
|
3
|
+
session;
|
|
4
|
+
constructor(type, session) {
|
|
5
|
+
super(type);
|
|
6
|
+
this.session = session;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/** One microstep: transitions taken, states exited and entered (in exit / entry order). */
|
|
10
|
+
export class MicrostepEvent extends SessionEvent {
|
|
11
|
+
/** The event being processed, or `undefined` for eventless transitions (and the initial step). */
|
|
12
|
+
event;
|
|
13
|
+
/** The transitions taken, in document order. */
|
|
14
|
+
transitions;
|
|
15
|
+
/** States exited, in exit order (innermost first). */
|
|
16
|
+
exited;
|
|
17
|
+
/** States entered, in entry order (outermost first). */
|
|
18
|
+
entered;
|
|
19
|
+
constructor(session, init) {
|
|
20
|
+
super("microstep", session);
|
|
21
|
+
this.event = init.event;
|
|
22
|
+
this.transitions = init.transitions;
|
|
23
|
+
this.exited = init.exited;
|
|
24
|
+
this.entered = init.entered;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** The session is stable again (a macrostep finished); `event` is the external event that started it, if any. */
|
|
28
|
+
export class MacrostepEvent extends SessionEvent {
|
|
29
|
+
/** The external event that started the macrostep; `undefined` for the initial one. */
|
|
30
|
+
event;
|
|
31
|
+
/** The active states, in document order. */
|
|
32
|
+
configuration;
|
|
33
|
+
constructor(session, init) {
|
|
34
|
+
super("macrostep", session);
|
|
35
|
+
this.event = init.event;
|
|
36
|
+
this.configuration = init.configuration;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** `<log label expr>` */
|
|
40
|
+
export class LogEvent extends SessionEvent {
|
|
41
|
+
/** The `label` attribute (empty when absent). */
|
|
42
|
+
label;
|
|
43
|
+
/** The value of `expr`, copied out of the data model (`undefined` when absent or empty). */
|
|
44
|
+
value;
|
|
45
|
+
constructor(session, init) {
|
|
46
|
+
super("log", session);
|
|
47
|
+
this.label = init.label;
|
|
48
|
+
this.value = init.value;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The session raised an SCXML error (`kind`). The chart can react to it with
|
|
53
|
+
* a transition on `error.*`; this event tells the host about it too.
|
|
54
|
+
*/
|
|
55
|
+
export class SCXMLErrorEvent extends SessionEvent {
|
|
56
|
+
/** Which error event the session placed on its internal queue. */
|
|
57
|
+
kind;
|
|
58
|
+
/** What went wrong, for people (not a stable format). */
|
|
59
|
+
message;
|
|
60
|
+
/** The element whose evaluation failed, when known (for example the `<assign>`). */
|
|
61
|
+
element;
|
|
62
|
+
constructor(session, init) {
|
|
63
|
+
super("error", session);
|
|
64
|
+
this.kind = init.kind;
|
|
65
|
+
this.message = init.message;
|
|
66
|
+
this.element = init.element ?? null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** A `<send>` was dispatched (after any delay) — to the SCXML processor or a custom one. */
|
|
70
|
+
export class SendEvent extends SessionEvent {
|
|
71
|
+
/** What was sent: event, target, type, data and sendid. */
|
|
72
|
+
message;
|
|
73
|
+
constructor(session, init) {
|
|
74
|
+
super("send", session);
|
|
75
|
+
this.message = init.message;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** An `<invoke>` started. */
|
|
79
|
+
export class InvokeEvent extends SessionEvent {
|
|
80
|
+
/** The invocation's id (the `id` attribute, or a generated `stateid.platformid`). */
|
|
81
|
+
invokeid;
|
|
82
|
+
/** The invoke type (for example the SCXML type URI or a custom invoker's name). */
|
|
83
|
+
invokeType;
|
|
84
|
+
/** The state whose `<invoke>` started it. */
|
|
85
|
+
state;
|
|
86
|
+
constructor(session, init) {
|
|
87
|
+
super("invoke", session);
|
|
88
|
+
this.invokeid = init.invokeid;
|
|
89
|
+
this.invokeType = init.invokeType;
|
|
90
|
+
this.state = init.state;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/** An invoked SCXML child session was created (fires before it starts, so listeners see its first step). */
|
|
94
|
+
export class ChildSessionEvent extends SessionEvent {
|
|
95
|
+
/** The invocation's id. */
|
|
96
|
+
invokeid;
|
|
97
|
+
/** The child session; add listeners now to see its first step. */
|
|
98
|
+
child;
|
|
99
|
+
constructor(session, init) {
|
|
100
|
+
super("child", session);
|
|
101
|
+
this.invokeid = init.invokeid;
|
|
102
|
+
this.child = init.child;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/** The session terminated; `data` is the top-level final state's donedata, if any. */
|
|
106
|
+
export class DoneEvent extends SessionEvent {
|
|
107
|
+
/** The top-level final state's `<donedata>`, or `undefined` (always `undefined` after a cancel). */
|
|
108
|
+
data;
|
|
109
|
+
constructor(session, init) {
|
|
110
|
+
super("done", session);
|
|
111
|
+
this.data = init.data;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=session-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-events.js","sourceRoot":"","sources":["../src/session-events.ts"],"names":[],"mappings":"AAaA,MAAe,YAAa,SAAQ,KAAK;IACvC,6CAA6C;IACpC,OAAO,CAAe;IAC/B,YAAY,IAAY,EAAE,OAAqB;QAC7C,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED,2FAA2F;AAC3F,MAAM,OAAO,cAAe,SAAQ,YAAY;IAC9C,kGAAkG;IACzF,KAAK,CAAc;IAC5B,gDAAgD;IACvC,WAAW,CAAmB;IACvC,sDAAsD;IAC7C,MAAM,CAAc;IAC7B,wDAAwD;IAC/C,OAAO,CAAc;IAC9B,YACE,OAAqB,EACrB,IAAsG;QAEtG,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,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AAC;CACF","sourcesContent":["/**\n * Events dispatched by an SCXMLSession. They are plain `Event` subclasses (not\n * CustomEvent), with typed fields, so hosts can write\n *\n * session.addEventListener(\"microstep\", (e) => e.entered)\n *\n * without casts. None of them bubble or are cancelable: a host observes a\n * session and influences it only by sending events.\n */\nimport type { SCXMLEvent } from \"./events.ts\";\nimport type { StateNode, TransitionNode } from \"./model.ts\";\nimport type { OutboundSend, SCXMLSession } from \"./session.ts\";\n\nabstract class SessionEvent extends Event {\n /** The session that dispatched the event. */\n readonly session: SCXMLSession;\n constructor(type: string, session: SCXMLSession) {\n super(type);\n this.session = session;\n }\n}\n\n/** One microstep: transitions taken, states exited and entered (in exit / entry order). */\nexport class MicrostepEvent extends SessionEvent {\n /** The event being processed, or `undefined` for eventless transitions (and the initial step). */\n readonly event?: SCXMLEvent;\n /** The transitions taken, in document order. */\n readonly transitions: TransitionNode[];\n /** States exited, in exit order (innermost first). */\n readonly exited: StateNode[];\n /** States entered, in entry order (outermost first). */\n readonly entered: StateNode[];\n constructor(\n session: SCXMLSession,\n init: { event?: SCXMLEvent; transitions: TransitionNode[]; exited: StateNode[]; entered: StateNode[] },\n ) {\n super(\"microstep\", session);\n this.event = init.event;\n this.transitions = init.transitions;\n this.exited = init.exited;\n this.entered = init.entered;\n }\n}\n\n/** The session is stable again (a macrostep finished); `event` is the external event that started it, if any. */\nexport class MacrostepEvent extends SessionEvent {\n /** The external event that started the macrostep; `undefined` for the initial one. */\n readonly event?: SCXMLEvent;\n /** The active states, in document order. */\n readonly configuration: StateNode[];\n constructor(session: SCXMLSession, init: { event?: SCXMLEvent; configuration: StateNode[] }) {\n super(\"macrostep\", session);\n this.event = init.event;\n this.configuration = init.configuration;\n }\n}\n\n/** `<log label expr>` */\nexport class LogEvent extends SessionEvent {\n /** The `label` attribute (empty when absent). */\n readonly label: string;\n /** The value of `expr`, copied out of the data model (`undefined` when absent or empty). */\n readonly value: unknown;\n constructor(session: SCXMLSession, init: { label: string; value: unknown }) {\n super(\"log\", session);\n this.label = init.label;\n this.value = init.value;\n }\n}\n\n/** The SCXML error events a session raises (spec §5.10.1). */\nexport type SCXMLErrorKind = \"error.execution\" | \"error.communication\" | \"error.platform\";\n\n/**\n * The session raised an SCXML error (`kind`). The chart can react to it with\n * a transition on `error.*`; this event tells the host about it too.\n */\nexport class SCXMLErrorEvent extends SessionEvent {\n /** Which error event the session placed on its internal queue. */\n readonly kind: SCXMLErrorKind;\n /** What went wrong, for people (not a stable format). */\n readonly message: string;\n /** The element whose evaluation failed, when known (for example the `<assign>`). */\n readonly element: Element | null;\n constructor(session: SCXMLSession, init: { kind: SCXMLErrorKind; message: string; element?: Element | null }) {\n super(\"error\", session);\n this.kind = init.kind;\n this.message = init.message;\n this.element = init.element ?? null;\n }\n}\n\n/** A `<send>` was dispatched (after any delay) — to the SCXML processor or a custom one. */\nexport class SendEvent extends SessionEvent {\n /** What was sent: event, target, type, data and sendid. */\n readonly message: OutboundSend;\n constructor(session: SCXMLSession, init: { message: OutboundSend }) {\n super(\"send\", session);\n this.message = init.message;\n }\n}\n\n/** An `<invoke>` started. */\nexport class InvokeEvent extends SessionEvent {\n /** The invocation's id (the `id` attribute, or a generated `stateid.platformid`). */\n readonly invokeid: string;\n /** The invoke type (for example the SCXML type URI or a custom invoker's name). */\n readonly invokeType: string;\n /** The state whose `<invoke>` started it. */\n readonly state: StateNode;\n constructor(session: SCXMLSession, init: { invokeid: string; invokeType: string; state: StateNode }) {\n super(\"invoke\", session);\n this.invokeid = init.invokeid;\n this.invokeType = init.invokeType;\n this.state = init.state;\n }\n}\n\n/** An invoked SCXML child session was created (fires before it starts, so listeners see its first step). */\nexport class ChildSessionEvent extends SessionEvent {\n /** The invocation's id. */\n readonly invokeid: string;\n /** The child session; add listeners now to see its first step. */\n readonly child: SCXMLSession;\n constructor(session: SCXMLSession, init: { invokeid: string; child: SCXMLSession }) {\n super(\"child\", session);\n this.invokeid = init.invokeid;\n this.child = init.child;\n }\n}\n\n/** The session terminated; `data` is the top-level final state's donedata, if any. */\nexport class DoneEvent extends SessionEvent {\n /** The top-level final state's `<donedata>`, or `undefined` (always `undefined` after a cancel). */\n readonly data: unknown;\n constructor(session: SCXMLSession, init: { data: unknown }) {\n super(\"done\", session);\n this.data = init.data;\n }\n}\n\n/** Event names → event classes, for `session.addEventListener(type, listener)` without casts. */\nexport interface SessionEventMap {\n /** After every microstep. */\n microstep: MicrostepEvent;\n /** When the session is stable again after an external event (and after the initial step). */\n macrostep: MacrostepEvent;\n /** A `<log>` executed. */\n log: LogEvent;\n /** An `error.*` event was raised. */\n error: SCXMLErrorEvent;\n /** A `<send>` was dispatched. */\n send: SendEvent;\n /** An `<invoke>` started. */\n invoke: InvokeEvent;\n /** An invoked SCXML child session was created. */\n child: ChildSessionEvent;\n /** The session terminated. */\n done: DoneEvent;\n}\n"]}
|