@statewalker/fsm 0.20.2 → 0.22.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/dist/index.d.ts +2 -20
- package/dist/index.js +23 -96
- package/dist/utils/index.d.ts +23 -0
- package/dist/utils/index.js +78 -0
- package/package.json +3 -4
- package/src/FsmBaseClass.ts +8 -2
- package/src/FsmProcess.ts +11 -7
- package/src/FsmState.ts +1 -2
- package/src/index.ts +0 -1
- package/src/{context → utils}/handlers.ts +1 -1
- package/src/{context → utils}/printer.ts +7 -7
- package/src/{context → utils}/tracer.ts +2 -2
- package/src/utils/bindMethods.ts +0 -7
- /package/src/{context → utils}/index.ts +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -77,6 +77,7 @@ declare class FsmProcess extends FsmBaseClass {
|
|
|
77
77
|
config: FsmStateConfig;
|
|
78
78
|
rootDescriptor: FsmStateDescriptor;
|
|
79
79
|
constructor(config: FsmStateConfig);
|
|
80
|
+
shutdown(event?: string): Promise<void>;
|
|
80
81
|
dispatch(event: string, mask?: number): Promise<boolean>;
|
|
81
82
|
dump(...args: unknown[]): Promise<FsmProcessDump>;
|
|
82
83
|
restore(dump: FsmProcessDump, ...args: unknown[]): Promise<this>;
|
|
@@ -89,23 +90,4 @@ declare class FsmProcess extends FsmBaseClass {
|
|
|
89
90
|
_update(): boolean;
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
|
|
93
|
-
declare function callStateHandlers(state: FsmState): void;
|
|
94
|
-
declare function addSubstateHandlers(state: FsmState, handlers: Record<string, FsmStateHandler>): void;
|
|
95
|
-
|
|
96
|
-
type Printer = (...args: any[]) => void;
|
|
97
|
-
type PrinterConfig = {
|
|
98
|
-
prefix?: string;
|
|
99
|
-
print?: (...args: any[]) => void;
|
|
100
|
-
lineNumbers?: boolean;
|
|
101
|
-
};
|
|
102
|
-
declare const KEY_PRINTER = "printer";
|
|
103
|
-
declare function preparePrinter(process: FsmProcess, { prefix, print, lineNumbers }: PrinterConfig): Printer;
|
|
104
|
-
declare function setPrinter(state: FsmState, config?: PrinterConfig): void;
|
|
105
|
-
declare function setProcessPrinter(process: FsmProcess, config?: PrinterConfig): void;
|
|
106
|
-
declare function getPrinter(state: FsmState): Printer;
|
|
107
|
-
|
|
108
|
-
declare function setProcessTracer(process: FsmProcess, print?: Printer): () => void;
|
|
109
|
-
declare function setStateTracer(state: FsmState, print?: Printer): void;
|
|
110
|
-
|
|
111
|
-
export { EVENT_ANY, EVENT_EMPTY, type FsmEventKey, FsmProcess, type FsmProcessDump, type FsmProcessDumpHandler, type FsmProcessHandler, FsmState, type FsmStateConfig, FsmStateDescriptor, type FsmStateDump, type FsmStateDumpHandler, type FsmStateErrorHandler, type FsmStateHandler, type FsmStateKey, type FsmStateSyncHandler, KEY_HANDLERS, KEY_PRINTER, type Printer, type PrinterConfig, STATE_ANY, STATE_FINAL, STATE_INITIAL, STATUS_ENTER, STATUS_EXIT, STATUS_FINISHED, STATUS_FIRST, STATUS_LAST, STATUS_LEAF, STATUS_NEXT, STATUS_NONE, addSubstateHandlers, callStateHandlers, getPrinter, preparePrinter, setPrinter, setProcessPrinter, setProcessTracer, setStateTracer };
|
|
93
|
+
export { EVENT_ANY, EVENT_EMPTY, type FsmEventKey, FsmProcess, type FsmProcessDump, type FsmProcessDumpHandler, type FsmProcessHandler, FsmState, type FsmStateConfig, FsmStateDescriptor, type FsmStateDump, type FsmStateDumpHandler, type FsmStateErrorHandler, type FsmStateHandler, type FsmStateKey, type FsmStateSyncHandler, STATE_ANY, STATE_FINAL, STATE_INITIAL, STATUS_ENTER, STATUS_EXIT, STATUS_FINISHED, STATUS_FIRST, STATUS_LAST, STATUS_LEAF, STATUS_NEXT, STATUS_NONE };
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
// src/utils/bindMethods.ts
|
|
2
|
-
function bindMethods(obj, ...methods) {
|
|
3
|
-
const o = obj;
|
|
4
|
-
methods.forEach((methodName) => {
|
|
5
|
-
o[methodName] = o[methodName].bind(o);
|
|
6
|
-
});
|
|
7
|
-
return obj;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
1
|
// src/FsmBaseClass.ts
|
|
11
2
|
var FsmBaseClass = class {
|
|
12
|
-
handlers = {};
|
|
13
|
-
data = {};
|
|
14
3
|
constructor() {
|
|
4
|
+
this.handlers = {};
|
|
5
|
+
this.data = {};
|
|
15
6
|
bindMethods(this, "setData", "getData");
|
|
16
7
|
}
|
|
17
8
|
setData(key, value) {
|
|
@@ -56,13 +47,16 @@ var FsmBaseClass = class {
|
|
|
56
47
|
console.error(error);
|
|
57
48
|
}
|
|
58
49
|
};
|
|
50
|
+
function bindMethods(obj, ...methods) {
|
|
51
|
+
const o = obj;
|
|
52
|
+
methods.forEach((methodName) => {
|
|
53
|
+
o[methodName] = o[methodName].bind(o);
|
|
54
|
+
});
|
|
55
|
+
return obj;
|
|
56
|
+
}
|
|
59
57
|
|
|
60
58
|
// src/FsmState.ts
|
|
61
59
|
var FsmState = class extends FsmBaseClass {
|
|
62
|
-
process;
|
|
63
|
-
key;
|
|
64
|
-
parent;
|
|
65
|
-
descriptor;
|
|
66
60
|
constructor(process, parent, key, descriptor) {
|
|
67
61
|
super();
|
|
68
62
|
this.process = process;
|
|
@@ -118,8 +112,10 @@ var EVENT_EMPTY = "";
|
|
|
118
112
|
|
|
119
113
|
// src/FsmStateDescriptor.ts
|
|
120
114
|
var FsmStateDescriptor = class _FsmStateDescriptor {
|
|
121
|
-
|
|
122
|
-
|
|
115
|
+
constructor() {
|
|
116
|
+
this.transitions = {};
|
|
117
|
+
this.states = {};
|
|
118
|
+
}
|
|
123
119
|
static build(config) {
|
|
124
120
|
const descriptor = new _FsmStateDescriptor();
|
|
125
121
|
for (const [from, event, to] of config.transitions || []) {
|
|
@@ -161,17 +157,21 @@ var STATUS_FINISHED = 16;
|
|
|
161
157
|
var STATUS_ENTER = STATUS_FIRST | STATUS_NEXT;
|
|
162
158
|
var STATUS_EXIT = STATUS_LEAF | STATUS_LAST;
|
|
163
159
|
var FsmProcess = class extends FsmBaseClass {
|
|
164
|
-
state;
|
|
165
|
-
event;
|
|
166
|
-
status = 0;
|
|
167
|
-
config;
|
|
168
|
-
rootDescriptor;
|
|
169
160
|
constructor(config) {
|
|
170
161
|
super();
|
|
162
|
+
this.status = 0;
|
|
171
163
|
this.rootDescriptor = FsmStateDescriptor.build(config);
|
|
172
164
|
this.config = config;
|
|
173
165
|
bindMethods(this, "dispatch", "dump", "restore");
|
|
174
166
|
}
|
|
167
|
+
async shutdown(event) {
|
|
168
|
+
while (this.state) {
|
|
169
|
+
this.event = event;
|
|
170
|
+
this.status = STATUS_FINISHED;
|
|
171
|
+
await this.state?._runHandler("onExit", this.state);
|
|
172
|
+
this.state = this.state.parent;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
175
|
async dispatch(event, mask = STATUS_LEAF) {
|
|
176
176
|
this.event = event;
|
|
177
177
|
while (true) {
|
|
@@ -272,77 +272,12 @@ var FsmProcess = class extends FsmBaseClass {
|
|
|
272
272
|
return !(this.status & STATUS_FINISHED);
|
|
273
273
|
}
|
|
274
274
|
};
|
|
275
|
-
|
|
276
|
-
// src/context/handlers.ts
|
|
277
|
-
var KEY_HANDLERS = "handlers";
|
|
278
|
-
function callStateHandlers(state) {
|
|
279
|
-
const key = state.key;
|
|
280
|
-
for (let parent = state.parent; !!parent; parent = parent?.parent) {
|
|
281
|
-
const handlers = parent.getData(KEY_HANDLERS)?.[key];
|
|
282
|
-
handlers?.forEach((handler) => handler(state));
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
function addSubstateHandlers(state, handlers) {
|
|
286
|
-
const oldIndex = state.getData(KEY_HANDLERS);
|
|
287
|
-
const index = oldIndex ? { ...oldIndex } : {};
|
|
288
|
-
for (const [key, handler] of Object.entries(handlers)) {
|
|
289
|
-
const list = index[key] = index[key] || [];
|
|
290
|
-
list.push(handler);
|
|
291
|
-
}
|
|
292
|
-
state.setData(KEY_HANDLERS, index);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// src/context/printer.ts
|
|
296
|
-
var KEY_PRINTER = "printer";
|
|
297
|
-
function preparePrinter(process, { prefix = "", print = console.log, lineNumbers = false }) {
|
|
298
|
-
let lineCounter = 0;
|
|
299
|
-
const shift = () => {
|
|
300
|
-
let prefix2 = "";
|
|
301
|
-
for (let s = process.state?.parent; !!s; s = s.parent) {
|
|
302
|
-
prefix2 += " ";
|
|
303
|
-
}
|
|
304
|
-
return prefix2;
|
|
305
|
-
};
|
|
306
|
-
const getPrefix = lineNumbers ? () => `[${++lineCounter}]${shift()}` : shift;
|
|
307
|
-
const printer = (...args) => print(prefix, getPrefix(), ...args);
|
|
308
|
-
return printer;
|
|
309
|
-
}
|
|
310
|
-
function setPrinter(state, config = {}) {
|
|
311
|
-
const printer = preparePrinter(state.process, config);
|
|
312
|
-
state.setData(KEY_PRINTER, printer);
|
|
313
|
-
}
|
|
314
|
-
function setProcessPrinter(process, config = {}) {
|
|
315
|
-
const printer = preparePrinter(process, config);
|
|
316
|
-
process.setData(KEY_PRINTER, printer);
|
|
317
|
-
}
|
|
318
|
-
function getPrinter(state) {
|
|
319
|
-
return state.getData(KEY_PRINTER, true) || state.process.getData(KEY_PRINTER) || console.log;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
// src/context/tracer.ts
|
|
323
|
-
function setProcessTracer(process, print) {
|
|
324
|
-
return process.onStateCreate((state) => {
|
|
325
|
-
setStateTracer(state, print);
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
function setStateTracer(state, print) {
|
|
329
|
-
state.onEnter(() => {
|
|
330
|
-
const printLine = print || getPrinter(state);
|
|
331
|
-
printLine(`<${state?.key} event="${state.process.event}">`);
|
|
332
|
-
});
|
|
333
|
-
state.onExit(() => {
|
|
334
|
-
const printLine = print || getPrinter(state);
|
|
335
|
-
printLine(`</${state.key}> <!-- event="${state.process.event}" -->`);
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
275
|
export {
|
|
339
276
|
EVENT_ANY,
|
|
340
277
|
EVENT_EMPTY,
|
|
341
278
|
FsmProcess,
|
|
342
279
|
FsmState,
|
|
343
280
|
FsmStateDescriptor,
|
|
344
|
-
KEY_HANDLERS,
|
|
345
|
-
KEY_PRINTER,
|
|
346
281
|
STATE_ANY,
|
|
347
282
|
STATE_FINAL,
|
|
348
283
|
STATE_INITIAL,
|
|
@@ -353,13 +288,5 @@ export {
|
|
|
353
288
|
STATUS_LAST,
|
|
354
289
|
STATUS_LEAF,
|
|
355
290
|
STATUS_NEXT,
|
|
356
|
-
STATUS_NONE
|
|
357
|
-
addSubstateHandlers,
|
|
358
|
-
callStateHandlers,
|
|
359
|
-
getPrinter,
|
|
360
|
-
preparePrinter,
|
|
361
|
-
setPrinter,
|
|
362
|
-
setProcessPrinter,
|
|
363
|
-
setProcessTracer,
|
|
364
|
-
setStateTracer
|
|
291
|
+
STATUS_NONE
|
|
365
292
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FsmState, FsmStateHandler, FsmProcess } from '../index.js';
|
|
2
|
+
|
|
3
|
+
declare const KEY_HANDLERS = "handlers";
|
|
4
|
+
declare function callStateHandlers(state: FsmState): void;
|
|
5
|
+
declare function addSubstateHandlers(state: FsmState, handlers: Record<string, FsmStateHandler>): void;
|
|
6
|
+
|
|
7
|
+
type Printer = (...args: any[]) => void;
|
|
8
|
+
type PrinterConfig = {
|
|
9
|
+
prefix?: string;
|
|
10
|
+
print?: (...args: any[]) => void;
|
|
11
|
+
lineNumbers?: boolean;
|
|
12
|
+
};
|
|
13
|
+
declare const KEY_PRINTER = "printer";
|
|
14
|
+
declare function preparePrinter(process: FsmProcess, { prefix, print, lineNumbers }: PrinterConfig): Printer;
|
|
15
|
+
declare function setPrinter(state: FsmState, config?: PrinterConfig): void;
|
|
16
|
+
declare function setProcessPrinter(process: FsmProcess, config?: PrinterConfig): void;
|
|
17
|
+
declare function getProcessPrinter(process: FsmProcess): Printer;
|
|
18
|
+
declare function getPrinter(state: FsmState): Printer;
|
|
19
|
+
|
|
20
|
+
declare function setProcessTracer(process: FsmProcess, print?: Printer): () => void;
|
|
21
|
+
declare function setStateTracer(state: FsmState, print?: Printer): void;
|
|
22
|
+
|
|
23
|
+
export { KEY_HANDLERS, KEY_PRINTER, type Printer, type PrinterConfig, addSubstateHandlers, callStateHandlers, getPrinter, getProcessPrinter, preparePrinter, setPrinter, setProcessPrinter, setProcessTracer, setStateTracer };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// src/utils/handlers.ts
|
|
2
|
+
var KEY_HANDLERS = "handlers";
|
|
3
|
+
function callStateHandlers(state) {
|
|
4
|
+
const key = state.key;
|
|
5
|
+
for (let parent = state.parent; !!parent; parent = parent?.parent) {
|
|
6
|
+
const handlers = parent.getData(KEY_HANDLERS)?.[key];
|
|
7
|
+
handlers?.forEach((handler) => handler(state));
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function addSubstateHandlers(state, handlers) {
|
|
11
|
+
const oldIndex = state.getData(KEY_HANDLERS);
|
|
12
|
+
const index = oldIndex ? { ...oldIndex } : {};
|
|
13
|
+
for (const [key, handler] of Object.entries(handlers)) {
|
|
14
|
+
const list = index[key] = index[key] || [];
|
|
15
|
+
list.push(handler);
|
|
16
|
+
}
|
|
17
|
+
state.setData(KEY_HANDLERS, index);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// src/utils/printer.ts
|
|
21
|
+
var KEY_PRINTER = "printer";
|
|
22
|
+
function preparePrinter(process, { prefix = "", print = console.log, lineNumbers = false }) {
|
|
23
|
+
let lineCounter = 0;
|
|
24
|
+
const shift = () => {
|
|
25
|
+
let prefix2 = "";
|
|
26
|
+
for (let s = process.state?.parent; !!s; s = s.parent) {
|
|
27
|
+
prefix2 += " ";
|
|
28
|
+
}
|
|
29
|
+
return prefix2;
|
|
30
|
+
};
|
|
31
|
+
const getPrefix = lineNumbers ? () => `[${++lineCounter}]${shift()}` : shift;
|
|
32
|
+
const printer = (...args) => print(prefix, getPrefix(), ...args);
|
|
33
|
+
return printer;
|
|
34
|
+
}
|
|
35
|
+
function setPrinter(state, config = {}) {
|
|
36
|
+
const printer = preparePrinter(state.process, config);
|
|
37
|
+
state.setData(KEY_PRINTER, printer);
|
|
38
|
+
}
|
|
39
|
+
function setProcessPrinter(process, config = {}) {
|
|
40
|
+
const printer = preparePrinter(process, config);
|
|
41
|
+
process.setData(KEY_PRINTER, printer);
|
|
42
|
+
}
|
|
43
|
+
function getProcessPrinter(process) {
|
|
44
|
+
return process.getData(KEY_PRINTER) || console.log;
|
|
45
|
+
}
|
|
46
|
+
function getPrinter(state) {
|
|
47
|
+
return state.getData(KEY_PRINTER, true) || getProcessPrinter(state.process);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/utils/tracer.ts
|
|
51
|
+
function setProcessTracer(process, print) {
|
|
52
|
+
return process.onStateCreate((state) => {
|
|
53
|
+
setStateTracer(state, print);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function setStateTracer(state, print) {
|
|
57
|
+
state.onEnter(() => {
|
|
58
|
+
const printLine = print || getPrinter(state);
|
|
59
|
+
printLine(`<${state?.key} event="${state.process.event}">`);
|
|
60
|
+
});
|
|
61
|
+
state.onExit(() => {
|
|
62
|
+
const printLine = print || getPrinter(state);
|
|
63
|
+
printLine(`</${state.key}> <!-- event="${state.process.event}" -->`);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
KEY_HANDLERS,
|
|
68
|
+
KEY_PRINTER,
|
|
69
|
+
addSubstateHandlers,
|
|
70
|
+
callStateHandlers,
|
|
71
|
+
getPrinter,
|
|
72
|
+
getProcessPrinter,
|
|
73
|
+
preparePrinter,
|
|
74
|
+
setPrinter,
|
|
75
|
+
setProcessPrinter,
|
|
76
|
+
setProcessTracer,
|
|
77
|
+
setStateTracer
|
|
78
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statewalker/fsm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "HFSM Implementation",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/statewalker/statewalker-fsm",
|
|
@@ -20,9 +20,8 @@
|
|
|
20
20
|
"unpkg": "./dist/index.js",
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
22
|
"exports": {
|
|
23
|
-
".":
|
|
24
|
-
|
|
25
|
-
}
|
|
23
|
+
".": "./dist/index.js",
|
|
24
|
+
"./utils": "./dist/utils/index.js"
|
|
26
25
|
},
|
|
27
26
|
"devDependencies": {
|
|
28
27
|
"@changesets/cli": "^2.27.7",
|
package/src/FsmBaseClass.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { bindMethods } from "./utils/bindMethods.ts";
|
|
2
|
-
|
|
3
1
|
export class FsmBaseClass {
|
|
4
2
|
handlers: Record<string, Function[]> = {};
|
|
5
3
|
data: Record<string, unknown> = {};
|
|
@@ -50,3 +48,11 @@ export class FsmBaseClass {
|
|
|
50
48
|
console.error(error);
|
|
51
49
|
}
|
|
52
50
|
}
|
|
51
|
+
|
|
52
|
+
export function bindMethods<T>(obj: T, ...methods: string[]) {
|
|
53
|
+
const o = obj as any;
|
|
54
|
+
methods.forEach((methodName) => {
|
|
55
|
+
o[methodName] = (o[methodName] as Function).bind(o);
|
|
56
|
+
});
|
|
57
|
+
return obj;
|
|
58
|
+
}
|
package/src/FsmProcess.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { bindMethods } from "./
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
FsmState,
|
|
5
|
-
FsmStateDump,
|
|
6
|
-
FsmStateSyncHandler,
|
|
7
|
-
} from "./FsmState.ts";
|
|
1
|
+
import { FsmBaseClass, bindMethods } from "./FsmBaseClass.ts";
|
|
2
|
+
import { FsmState, FsmStateDump, FsmStateSyncHandler } from "./FsmState.ts";
|
|
8
3
|
import {
|
|
9
4
|
EVENT_EMPTY,
|
|
10
5
|
FsmStateConfig,
|
|
@@ -54,6 +49,15 @@ export class FsmProcess extends FsmBaseClass {
|
|
|
54
49
|
bindMethods(this, "dispatch", "dump", "restore");
|
|
55
50
|
}
|
|
56
51
|
|
|
52
|
+
async shutdown(event?: string) {
|
|
53
|
+
while (this.state) {
|
|
54
|
+
this.event = event;
|
|
55
|
+
this.status = STATUS_FINISHED;
|
|
56
|
+
await this.state?._runHandler("onExit", this.state);
|
|
57
|
+
this.state = this.state.parent;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
57
61
|
async dispatch(event: string, mask: number = STATUS_LEAF) {
|
|
58
62
|
this.event = event;
|
|
59
63
|
while (true) {
|
package/src/FsmState.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { bindMethods } from "./
|
|
2
|
-
import { FsmBaseClass } from "./FsmBaseClass.ts";
|
|
1
|
+
import { FsmBaseClass, bindMethods } from "./FsmBaseClass.ts";
|
|
3
2
|
import { FsmProcess } from "./FsmProcess.ts";
|
|
4
3
|
import { FsmStateDescriptor } from "./FsmStateDescriptor.ts";
|
|
5
4
|
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { FsmProcess } from "../FsmProcess.ts";
|
|
2
|
+
import type { FsmState } from "../FsmState.ts";
|
|
3
3
|
export type Printer = (...args: any[]) => void;
|
|
4
4
|
export type PrinterConfig = {
|
|
5
5
|
prefix?: string;
|
|
@@ -39,10 +39,10 @@ export function setProcessPrinter(
|
|
|
39
39
|
process.setData(KEY_PRINTER, printer);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
export function getProcessPrinter(process: FsmProcess): Printer {
|
|
43
|
+
return process.getData(KEY_PRINTER) || console.log;
|
|
44
|
+
}
|
|
45
|
+
|
|
42
46
|
export function getPrinter(state: FsmState): Printer {
|
|
43
|
-
return (
|
|
44
|
-
state.getData(KEY_PRINTER, true) ||
|
|
45
|
-
state.process.getData(KEY_PRINTER) ||
|
|
46
|
-
console.log
|
|
47
|
-
);
|
|
47
|
+
return state.getData(KEY_PRINTER, true) || getProcessPrinter(state.process);
|
|
48
48
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FsmProcess } from "../FsmProcess.ts";
|
|
2
|
-
import { FsmState } from "../FsmState.ts";
|
|
1
|
+
import type { FsmProcess } from "../FsmProcess.ts";
|
|
2
|
+
import type { FsmState } from "../FsmState.ts";
|
|
3
3
|
import { getPrinter, type Printer } from "./printer.ts";
|
|
4
4
|
|
|
5
5
|
export function setProcessTracer(process: FsmProcess, print?: Printer) {
|
package/src/utils/bindMethods.ts
DELETED
|
File without changes
|