@logicflow/engine 0.0.11-beta.0 → 0.0.12-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/es/EventEmitter.d.ts +34 -4
- package/es/EventEmitter.js +70 -48
- package/es/EventEmitter.js.map +1 -0
- package/es/FlowModel.d.ts +75 -73
- package/es/FlowModel.js +130 -173
- package/es/FlowModel.js.map +1 -0
- package/es/Scheduler.d.ts +50 -34
- package/es/Scheduler.js +134 -209
- package/es/Scheduler.js.map +1 -0
- package/es/constant/{constant.js → index.js} +8 -7
- package/es/constant/index.js.map +1 -0
- package/es/constant/logCode.js +29 -0
- package/es/constant/logCode.js.map +1 -0
- package/es/index.d.ts +135 -38
- package/es/index.js +92 -144
- package/es/index.js.map +1 -0
- package/es/nodes/base.d.ts +108 -0
- package/es/nodes/base.js +151 -0
- package/es/nodes/base.js.map +1 -0
- package/es/nodes/index.d.ts +3 -0
- package/es/nodes/index.js +4 -0
- package/es/nodes/index.js.map +1 -0
- package/es/nodes/{StartNode.d.ts → start.d.ts} +3 -2
- package/es/nodes/start.js +11 -0
- package/es/nodes/start.js.map +1 -0
- package/es/nodes/{TaskNode.d.ts → task.d.ts} +3 -2
- package/es/nodes/task.js +11 -0
- package/es/nodes/task.js.map +1 -0
- package/es/platform/browser/browserVm.d.ts +1 -0
- package/es/platform/browser/browserVm.js +66 -0
- package/es/platform/browser/browserVm.js.map +1 -0
- package/es/platform/browser/index.d.ts +4 -0
- package/es/platform/browser/index.js +23 -0
- package/es/platform/browser/index.js.map +1 -0
- package/es/platform/index.d.ts +1 -0
- package/es/platform/index.js +2 -0
- package/es/platform/index.js.map +1 -0
- package/es/platform/node/index.d.ts +4 -0
- package/es/platform/node/index.js +23 -0
- package/es/platform/node/index.js.map +1 -0
- package/es/platform/node/nodeVm.d.ts +1 -0
- package/es/platform/node/nodeVm.js +9 -0
- package/es/platform/node/nodeVm.js.map +1 -0
- package/es/recorder/index.d.ts +36 -10
- package/es/recorder/index.js +82 -135
- package/es/recorder/index.js.map +1 -0
- package/es/utils/global.d.ts +5 -0
- package/es/utils/global.js +27 -0
- package/es/utils/global.js.map +1 -0
- package/es/utils/id.js +14 -0
- package/es/utils/id.js.map +1 -0
- package/es/utils/index.d.ts +4 -0
- package/es/utils/index.js +5 -0
- package/es/utils/index.js.map +1 -0
- package/es/{util → utils}/storage.js +17 -16
- package/es/utils/storage.js.map +1 -0
- package/lib/EventEmitter.d.ts +37 -0
- package/lib/EventEmitter.js +94 -0
- package/lib/EventEmitter.js.map +1 -0
- package/lib/FlowModel.d.ts +146 -0
- package/lib/FlowModel.js +236 -0
- package/lib/FlowModel.js.map +1 -0
- package/lib/Scheduler.d.ts +78 -0
- package/lib/Scheduler.js +179 -0
- package/lib/Scheduler.js.map +1 -0
- package/lib/constant/index.d.ts +16 -0
- package/{cjs/constant/constant.js → lib/constant/index.js} +4 -3
- package/lib/constant/index.js.map +1 -0
- package/lib/constant/logCode.d.ts +12 -0
- package/{cjs/constant/LogCode.js → lib/constant/logCode.js} +16 -13
- package/lib/constant/logCode.js.map +1 -0
- package/lib/index.d.ts +157 -0
- package/lib/index.js +159 -0
- package/lib/index.js.map +1 -0
- package/lib/nodes/base.d.ts +108 -0
- package/lib/nodes/base.js +154 -0
- package/lib/nodes/base.js.map +1 -0
- package/lib/nodes/index.d.ts +3 -0
- package/lib/nodes/index.js +7 -0
- package/lib/nodes/index.js.map +1 -0
- package/lib/nodes/start.d.ts +6 -0
- package/lib/nodes/start.js +15 -0
- package/lib/nodes/start.js.map +1 -0
- package/lib/nodes/task.d.ts +6 -0
- package/lib/nodes/task.js +15 -0
- package/lib/nodes/task.js.map +1 -0
- package/lib/platform/browser/browserVm.d.ts +1 -0
- package/lib/platform/browser/browserVm.js +70 -0
- package/lib/platform/browser/browserVm.js.map +1 -0
- package/lib/platform/browser/index.d.ts +4 -0
- package/lib/platform/browser/index.js +28 -0
- package/lib/platform/browser/index.js.map +1 -0
- package/lib/platform/index.d.ts +1 -0
- package/lib/platform/index.js +5 -0
- package/lib/platform/index.js.map +1 -0
- package/lib/platform/node/index.d.ts +4 -0
- package/lib/platform/node/index.js +28 -0
- package/lib/platform/node/index.js.map +1 -0
- package/lib/platform/node/nodeVm.d.ts +1 -0
- package/lib/platform/node/nodeVm.js +13 -0
- package/lib/platform/node/nodeVm.js.map +1 -0
- package/lib/recorder/index.d.ts +46 -0
- package/lib/recorder/index.js +117 -0
- package/lib/recorder/index.js.map +1 -0
- package/lib/utils/global.d.ts +5 -0
- package/lib/utils/global.js +31 -0
- package/lib/utils/global.js.map +1 -0
- package/lib/utils/id.d.ts +3 -0
- package/lib/utils/id.js +20 -0
- package/lib/utils/id.js.map +1 -0
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/index.js +9 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/storage.d.ts +7 -0
- package/{cjs/util → lib/utils}/storage.js +18 -17
- package/lib/utils/storage.js.map +1 -0
- package/package.json +31 -71
- package/src/EventEmitter.ts +103 -0
- package/src/FlowModel.ts +325 -0
- package/src/Scheduler.ts +244 -0
- package/src/constant/index.ts +23 -0
- package/src/constant/logCode.ts +34 -0
- package/src/index.ts +300 -0
- package/src/nodes/base.ts +236 -0
- package/src/nodes/index.ts +3 -0
- package/src/nodes/start.ts +8 -0
- package/src/nodes/task.ts +8 -0
- package/src/platform/browser/browserVm.ts +68 -0
- package/src/platform/browser/index.ts +28 -0
- package/src/platform/index.ts +1 -0
- package/src/platform/node/index.ts +28 -0
- package/src/platform/node/nodeVm.ts +12 -0
- package/src/recorder/index.ts +137 -0
- package/src/typings.d.ts +0 -0
- package/src/utils/global.ts +41 -0
- package/src/utils/id.ts +16 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/storage.ts +55 -0
- package/cjs/EventEmitter.js +0 -70
- package/cjs/FlowModel.js +0 -277
- package/cjs/Scheduler.js +0 -252
- package/cjs/expression/browserVm.js +0 -81
- package/cjs/expression/index.js +0 -57
- package/cjs/index.js +0 -210
- package/cjs/nodes/BaseNode.js +0 -252
- package/cjs/nodes/StartNode.js +0 -27
- package/cjs/nodes/TaskNode.js +0 -27
- package/cjs/recorder/index.js +0 -168
- package/cjs/util/ID.js +0 -16
- package/cjs/util/global.js +0 -32
- package/es/constant/LogCode.js +0 -28
- package/es/expression/browserVm.d.ts +0 -4
- package/es/expression/browserVm.js +0 -76
- package/es/expression/index.d.ts +0 -2
- package/es/expression/index.js +0 -54
- package/es/nodes/BaseNode.d.ts +0 -110
- package/es/nodes/BaseNode.js +0 -250
- package/es/nodes/StartNode.js +0 -25
- package/es/nodes/TaskNode.js +0 -25
- package/es/util/ID.js +0 -13
- package/es/util/global.d.ts +0 -5
- package/es/util/global.js +0 -26
- package/lib/main.js +0 -1
- /package/es/constant/{constant.d.ts → index.d.ts} +0 -0
- /package/es/constant/{LogCode.d.ts → logCode.d.ts} +0 -0
- /package/es/{util/ID.d.ts → utils/id.d.ts} +0 -0
- /package/es/{util → utils}/storage.d.ts +0 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// import {
|
|
2
|
+
// ErrorCode,
|
|
3
|
+
// getErrorMsg,
|
|
4
|
+
// getWarningMsg,
|
|
5
|
+
// WarningCode,
|
|
6
|
+
// } from '../../constant/logCode'
|
|
7
|
+
//
|
|
8
|
+
// const createContext = (globalData: Record<string, unknown>) => {
|
|
9
|
+
// const iframe = document.createElement('iframe')
|
|
10
|
+
// iframe.style.display = 'none'
|
|
11
|
+
// if (!document || !document.body) {
|
|
12
|
+
// console.error(getErrorMsg(ErrorCode.NO_DOCUMENT_BODY))
|
|
13
|
+
// }
|
|
14
|
+
// document.body.appendChild(iframe)
|
|
15
|
+
// const iframeWindow = iframe.contentWindow
|
|
16
|
+
// if (iframeWindow) {
|
|
17
|
+
// // TODO: 确认是否需要该代码,parent 置为空是为了解决什么问题
|
|
18
|
+
// // @ts-ignore
|
|
19
|
+
// ;(iframeWindow!.parent as any) = null
|
|
20
|
+
// Object.keys(globalData).forEach((key) => {
|
|
21
|
+
// iframeWindow[key] = globalData[key]
|
|
22
|
+
// })
|
|
23
|
+
// }
|
|
24
|
+
// return iframeWindow
|
|
25
|
+
// }
|
|
26
|
+
//
|
|
27
|
+
// const runInContext = (code: string, context: any) => {
|
|
28
|
+
// try {
|
|
29
|
+
// const iframeEval = context.eval
|
|
30
|
+
// iframeEval.call(context, code)
|
|
31
|
+
// console.log('context --->>> ===>>>', context)
|
|
32
|
+
// if (context.frameElement) {
|
|
33
|
+
// document.body.removeChild(context.frameElement)
|
|
34
|
+
// }
|
|
35
|
+
// } catch (e) {
|
|
36
|
+
// console.warn(getWarningMsg(WarningCode.EXPRESSION_EXEC_ERROR), {
|
|
37
|
+
// code,
|
|
38
|
+
// context,
|
|
39
|
+
// e,
|
|
40
|
+
// })
|
|
41
|
+
// }
|
|
42
|
+
// }
|
|
43
|
+
//
|
|
44
|
+
// const runInBrowserContext = async (
|
|
45
|
+
// code: string,
|
|
46
|
+
// globalData = {},
|
|
47
|
+
// ): Promise<any> => {
|
|
48
|
+
// const context = createContext(globalData)
|
|
49
|
+
// runInContext(code, context)
|
|
50
|
+
// return context
|
|
51
|
+
// }
|
|
52
|
+
//
|
|
53
|
+
// export { createContext, runInContext, runInBrowserContext }
|
|
54
|
+
import { __awaiter } from "tslib";
|
|
55
|
+
import Sandbox from '@nyariv/sandboxjs';
|
|
56
|
+
export const runInBrowserContext = (code, globalData = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
try {
|
|
58
|
+
const sandbox = new Sandbox();
|
|
59
|
+
const exec = sandbox.compile(code);
|
|
60
|
+
return yield exec(globalData).run();
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
console.log('runInBrowserContext error --->>>', e);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=browserVm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browserVm.js","sourceRoot":"","sources":["../../../src/platform/browser/browserVm.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,eAAe;AACf,iBAAiB;AACjB,mBAAmB;AACnB,iBAAiB;AACjB,kCAAkC;AAClC,EAAE;AACF,mEAAmE;AACnE,oDAAoD;AACpD,kCAAkC;AAClC,uCAAuC;AACvC,6DAA6D;AAC7D,MAAM;AACN,sCAAsC;AACtC,8CAA8C;AAC9C,wBAAwB;AACxB,6CAA6C;AAC7C,oBAAoB;AACpB,4CAA4C;AAC5C,iDAAiD;AACjD,4CAA4C;AAC5C,SAAS;AACT,MAAM;AACN,wBAAwB;AACxB,IAAI;AACJ,EAAE;AACF,yDAAyD;AACzD,UAAU;AACV,sCAAsC;AACtC,qCAAqC;AACrC,oDAAoD;AACpD,kCAAkC;AAClC,wDAAwD;AACxD,QAAQ;AACR,kBAAkB;AAClB,uEAAuE;AACvE,cAAc;AACd,iBAAiB;AACjB,WAAW;AACX,SAAS;AACT,MAAM;AACN,IAAI;AACJ,EAAE;AACF,sCAAsC;AACtC,kBAAkB;AAClB,qBAAqB;AACrB,uBAAuB;AACvB,8CAA8C;AAC9C,gCAAgC;AAChC,mBAAmB;AACnB,IAAI;AACJ,EAAE;AACF,8DAA8D;;AAE9D,OAAO,OAAO,MAAM,mBAAmB,CAAC;AAExC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,IAAY,EACZ,UAAU,GAAG,EAAE,EACD,EAAE;IAChB,IAAI;QACF,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,CAAC;KACrC;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,kCAAkC,EAAE,CAAC,CAAC,CAAC;KACpD;AACH,CAAC,CAAA,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { runInBrowserContext } from './browserVm';
|
|
3
|
+
const isInBrowser = typeof window === 'object' && window.window === window;
|
|
4
|
+
const globalScope = (() => {
|
|
5
|
+
if (isInBrowser) {
|
|
6
|
+
return window;
|
|
7
|
+
}
|
|
8
|
+
if (typeof self === 'object' && self.self === self) {
|
|
9
|
+
return self;
|
|
10
|
+
}
|
|
11
|
+
if (typeof globalThis === 'object') {
|
|
12
|
+
return globalThis;
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
eval: () => undefined,
|
|
16
|
+
};
|
|
17
|
+
})();
|
|
18
|
+
const getExpressionResult = (code, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
const r = yield runInBrowserContext(code, context);
|
|
20
|
+
return r;
|
|
21
|
+
});
|
|
22
|
+
export { isInBrowser, globalScope, getExpressionResult };
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/platform/browser/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEjD,MAAM,WAAW,GAAG,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAA;AAE1E,MAAM,WAAW,GAAQ,CAAC,GAAG,EAAE;IAC7B,IAAI,WAAW,EAAE;QACf,OAAO,MAAM,CAAA;KACd;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;QAClD,OAAO,IAAI,CAAA;KACZ;IAED,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;QAClC,OAAO,UAAU,CAAA;KAClB;IAED,OAAO;QACL,IAAI,EAAE,GAAG,EAAE,CAAC,SAAS;KACK,CAAA;AAC9B,CAAC,CAAC,EAAE,CAAA;AAEJ,MAAM,mBAAmB,GAAG,CAAO,IAAY,EAAE,OAAY,EAAE,EAAE;IAC/D,MAAM,CAAC,GAAG,MAAM,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAClD,OAAO,CAAC,CAAA;AACV,CAAC,CAAA,CAAA;AAED,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './node';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/platform/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { runInNodeContext } from './nodeVm';
|
|
3
|
+
const isInNodeJS = typeof global === 'object' && global.global === global;
|
|
4
|
+
const globalScope = (() => {
|
|
5
|
+
if (typeof self === 'object' && self.self === self) {
|
|
6
|
+
return self;
|
|
7
|
+
}
|
|
8
|
+
if (isInNodeJS) {
|
|
9
|
+
return global;
|
|
10
|
+
}
|
|
11
|
+
if (typeof globalThis === 'object') {
|
|
12
|
+
return globalThis;
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
eval: () => undefined,
|
|
16
|
+
};
|
|
17
|
+
})();
|
|
18
|
+
const getExpressionResult = (code, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
const r = yield runInNodeContext(code, context);
|
|
20
|
+
return r;
|
|
21
|
+
});
|
|
22
|
+
export { isInNodeJS, globalScope, getExpressionResult };
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/platform/node/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE3C,MAAM,UAAU,GAAG,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAA;AAEzE,MAAM,WAAW,GAAQ,CAAC,GAAG,EAAE;IAC7B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;QAClD,OAAO,IAAI,CAAA;KACZ;IAED,IAAI,UAAU,EAAE;QACd,OAAO,MAAM,CAAA;KACd;IAED,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;QAClC,OAAO,UAAU,CAAA;KAClB;IAED,OAAO;QACL,IAAI,EAAE,GAAG,EAAE,CAAC,SAAS;KACK,CAAA;AAC9B,CAAC,CAAC,EAAE,CAAA;AAEJ,MAAM,mBAAmB,GAAG,CAAO,IAAY,EAAE,OAAY,EAAE,EAAE;IAC/D,MAAM,CAAC,GAAG,MAAM,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAC/C,OAAO,CAAC,CAAA;AACV,CAAC,CAAA,CAAA;AAED,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const runInNodeContext: (code: string, globalData?: Record<string, unknown>) => Promise<any>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import vm from 'node:vm';
|
|
3
|
+
// const vm = require('node:vm');
|
|
4
|
+
export const runInNodeContext = (code, globalData = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5
|
+
const context = vm.createContext(globalData);
|
|
6
|
+
vm.runInContext(code, context);
|
|
7
|
+
return context;
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=nodeVm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeVm.js","sourceRoot":"","sources":["../../../src/platform/node/nodeVm.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,iCAAiC;AAEjC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,IAAY,EACZ,aAAsC,EAAE,EAC1B,EAAE;IAChB,MAAM,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;IAC5C,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAE9B,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA,CAAA"}
|
package/es/recorder/index.d.ts
CHANGED
|
@@ -1,20 +1,46 @@
|
|
|
1
|
-
import
|
|
2
|
-
export
|
|
1
|
+
import { Engine } from '..';
|
|
2
|
+
export declare const MAX_RECORDER = 100;
|
|
3
|
+
export declare const MAX_INSTANCE = 100;
|
|
4
|
+
export declare const LOGICFLOW_ENGINE_INSTANCES = "LOGICFLOW_ENGINE_INSTANCES";
|
|
5
|
+
export declare class Recorder implements Recorder.Base {
|
|
6
|
+
instanceId: Engine.Key;
|
|
3
7
|
maxRecorder: number;
|
|
4
|
-
instanceId: number;
|
|
5
8
|
constructor({ instanceId }: {
|
|
6
9
|
instanceId: any;
|
|
7
10
|
});
|
|
8
|
-
setMaxRecorderNumber(
|
|
11
|
+
setMaxRecorderNumber(max: number): void;
|
|
9
12
|
setItem(key: string | number, value: unknown): void;
|
|
10
13
|
getItem(key: string | number): any;
|
|
11
|
-
|
|
12
|
-
getActionRecord(actionId: string): Promise<RecorderData>;
|
|
13
|
-
getExecutionActions(executionId: any): Promise<any>;
|
|
14
|
+
getExecutionActions(executionId: Engine.Key): Promise<any>;
|
|
14
15
|
getExecutionList(): Promise<any>;
|
|
15
|
-
|
|
16
|
-
clearInstance(instanceId: any): void;
|
|
17
|
-
private pushExecution;
|
|
16
|
+
private addExecution;
|
|
18
17
|
private popExecution;
|
|
19
18
|
private pushActionToExecution;
|
|
19
|
+
/**
|
|
20
|
+
* @param {Object} action
|
|
21
|
+
* {
|
|
22
|
+
* actionId: '',
|
|
23
|
+
* nodeId: '',
|
|
24
|
+
* executionId: '',
|
|
25
|
+
* nodeType: '',
|
|
26
|
+
* timestamp: '',
|
|
27
|
+
* properties: {},
|
|
28
|
+
* }
|
|
29
|
+
*/
|
|
30
|
+
addActionRecord(action: Recorder.Info): Promise<void>;
|
|
31
|
+
getActionRecord(actionId: Engine.Key): Promise<Recorder.Info>;
|
|
32
|
+
clear(): void;
|
|
33
|
+
clearInstance(instanceId: Engine.Key): void;
|
|
34
|
+
}
|
|
35
|
+
export declare namespace Recorder {
|
|
36
|
+
interface Base {
|
|
37
|
+
addActionRecord: (action: Info) => Promise<void>;
|
|
38
|
+
getActionRecord: (actionId: Engine.Key) => Promise<Info>;
|
|
39
|
+
getExecutionActions: (executionId: Engine.Key) => Promise<string[]>;
|
|
40
|
+
clear: () => void;
|
|
41
|
+
}
|
|
42
|
+
type Info = {
|
|
43
|
+
timestamp: number;
|
|
44
|
+
} & Engine.NextActionParam;
|
|
20
45
|
}
|
|
46
|
+
export default Recorder;
|
package/es/recorder/index.js
CHANGED
|
@@ -1,166 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import storage from '../util/storage';
|
|
38
|
-
var LOGICFLOW_ENGINE_INSTANCES = 'LOGICFLOW_ENGINE_INSTANCES';
|
|
39
|
-
var MAX_RECORDER = 100;
|
|
40
|
-
var MAX_INSTANCE = 100;
|
|
41
|
-
var Recorder = /** @class */ (function () {
|
|
42
|
-
function Recorder(_a) {
|
|
43
|
-
var instanceId = _a.instanceId;
|
|
44
|
-
this.maxRecorder = MAX_RECORDER;
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { storage } from '../utils';
|
|
3
|
+
export const MAX_RECORDER = 100;
|
|
4
|
+
export const MAX_INSTANCE = 100;
|
|
5
|
+
export const LOGICFLOW_ENGINE_INSTANCES = 'LOGICFLOW_ENGINE_INSTANCES';
|
|
6
|
+
export class Recorder {
|
|
7
|
+
constructor({ instanceId }) {
|
|
45
8
|
this.instanceId = instanceId;
|
|
46
|
-
|
|
9
|
+
this.maxRecorder = MAX_RECORDER;
|
|
10
|
+
const instances = this.getItem(LOGICFLOW_ENGINE_INSTANCES) || [];
|
|
47
11
|
if (instances.indexOf(instanceId) === -1) {
|
|
48
12
|
instances.push(instanceId);
|
|
49
13
|
}
|
|
50
14
|
if (instances.length > MAX_INSTANCE) {
|
|
51
|
-
|
|
15
|
+
const clearInstance = instances.shift();
|
|
52
16
|
this.clearInstance(clearInstance);
|
|
53
17
|
}
|
|
54
18
|
this.setItem(LOGICFLOW_ENGINE_INSTANCES, instances);
|
|
55
19
|
}
|
|
56
|
-
|
|
57
|
-
this.maxRecorder =
|
|
58
|
-
}
|
|
20
|
+
setMaxRecorderNumber(max) {
|
|
21
|
+
this.maxRecorder = max;
|
|
22
|
+
}
|
|
59
23
|
// 将存储 storage 的方法收敛到此处,并在此处做异常处理 - setItem
|
|
60
|
-
|
|
24
|
+
setItem(key, value) {
|
|
61
25
|
try {
|
|
62
26
|
storage.setItem(key, value);
|
|
63
27
|
}
|
|
64
28
|
catch (error) {
|
|
65
|
-
console.
|
|
29
|
+
console.error('Ops, something wrong with storage.setItem !!!');
|
|
66
30
|
storage.clear();
|
|
67
31
|
storage.setItem(key, value);
|
|
68
32
|
}
|
|
69
|
-
}
|
|
33
|
+
}
|
|
70
34
|
// getItem 方法
|
|
71
|
-
|
|
35
|
+
getItem(key) {
|
|
72
36
|
return storage.getItem(key);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
* actionId: '',
|
|
78
|
-
* nodeId: '',
|
|
79
|
-
* executionId: '',
|
|
80
|
-
* nodeType: '',
|
|
81
|
-
* timestamp: '',
|
|
82
|
-
* properties: {},
|
|
83
|
-
* }
|
|
84
|
-
*/
|
|
85
|
-
Recorder.prototype.addActionRecord = function (action) {
|
|
86
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
-
var executionId, actionId, instanceData;
|
|
88
|
-
return __generator(this, function (_a) {
|
|
89
|
-
switch (_a.label) {
|
|
90
|
-
case 0:
|
|
91
|
-
executionId = action.executionId, actionId = action.actionId;
|
|
92
|
-
return [4 /*yield*/, this.getExecutionActions(executionId)];
|
|
93
|
-
case 1:
|
|
94
|
-
instanceData = _a.sent();
|
|
95
|
-
if (!instanceData) {
|
|
96
|
-
this.pushExecution(executionId);
|
|
97
|
-
}
|
|
98
|
-
this.pushActionToExecution(executionId, actionId);
|
|
99
|
-
this.setItem(actionId, action);
|
|
100
|
-
return [2 /*return*/];
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
Recorder.prototype.getActionRecord = function (actionId) {
|
|
106
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
107
|
-
return __generator(this, function (_a) {
|
|
108
|
-
return [2 /*return*/, this.getItem(actionId)];
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
Recorder.prototype.getExecutionActions = function (executionId) {
|
|
113
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
-
return __generator(this, function (_a) {
|
|
115
|
-
return [2 /*return*/, this.getItem(executionId)];
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
Recorder.prototype.getExecutionList = function () {
|
|
120
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
121
|
-
var instances;
|
|
122
|
-
return __generator(this, function (_a) {
|
|
123
|
-
instances = this.getItem(this.instanceId) || [];
|
|
124
|
-
return [2 /*return*/, instances];
|
|
125
|
-
});
|
|
37
|
+
}
|
|
38
|
+
getExecutionActions(executionId) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
return this.getItem(executionId);
|
|
126
41
|
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
this
|
|
130
|
-
|
|
131
|
-
Recorder.prototype.clearInstance = function (instanceId) {
|
|
132
|
-
var _this = this;
|
|
133
|
-
var instanceExecutions = this.getItem(instanceId) || [];
|
|
134
|
-
instanceExecutions.forEach(function (executionId) {
|
|
135
|
-
storage.removeItem(executionId);
|
|
136
|
-
var instanceData = _this.getItem(executionId) || [];
|
|
137
|
-
instanceData.forEach(function (actionId) {
|
|
138
|
-
storage.removeItem(actionId);
|
|
139
|
-
});
|
|
42
|
+
}
|
|
43
|
+
getExecutionList() {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
return this.getItem(this.instanceId) || [];
|
|
140
46
|
});
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
var instanceExecutions = this.getItem(this.instanceId) || [];
|
|
47
|
+
}
|
|
48
|
+
addExecution(executionId) {
|
|
49
|
+
const instanceExecutions = this.getItem(this.instanceId) || [];
|
|
145
50
|
if (instanceExecutions.length >= this.maxRecorder) {
|
|
146
|
-
|
|
147
|
-
this.popExecution(
|
|
51
|
+
const toBeRemovedItem = instanceExecutions.shift();
|
|
52
|
+
this.popExecution(toBeRemovedItem);
|
|
148
53
|
}
|
|
149
54
|
instanceExecutions.push(executionId);
|
|
150
55
|
this.setItem(this.instanceId, instanceExecutions);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
instanceData.forEach(
|
|
56
|
+
}
|
|
57
|
+
popExecution(executionId) {
|
|
58
|
+
const instanceData = this.getItem(executionId) || [];
|
|
59
|
+
instanceData.forEach((actionId) => {
|
|
155
60
|
storage.removeItem(actionId);
|
|
156
61
|
});
|
|
157
62
|
storage.removeItem(executionId);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
63
|
+
}
|
|
64
|
+
pushActionToExecution(executionId, actionId) {
|
|
65
|
+
const actions = this.getItem(executionId) || [];
|
|
161
66
|
actions.push(actionId);
|
|
162
67
|
this.setItem(executionId, actions);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* @param {Object} action
|
|
71
|
+
* {
|
|
72
|
+
* actionId: '',
|
|
73
|
+
* nodeId: '',
|
|
74
|
+
* executionId: '',
|
|
75
|
+
* nodeType: '',
|
|
76
|
+
* timestamp: '',
|
|
77
|
+
* properties: {},
|
|
78
|
+
* }
|
|
79
|
+
*/
|
|
80
|
+
addActionRecord(action) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const { executionId, actionId } = action;
|
|
83
|
+
const instanceData = yield this.getExecutionActions(executionId);
|
|
84
|
+
if (!instanceData) {
|
|
85
|
+
this.addExecution(executionId);
|
|
86
|
+
}
|
|
87
|
+
this.pushActionToExecution(executionId, actionId);
|
|
88
|
+
this.setItem(actionId, action);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
getActionRecord(actionId) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
return this.getItem(actionId);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
clear() {
|
|
97
|
+
this.clearInstance(this.instanceId);
|
|
98
|
+
}
|
|
99
|
+
clearInstance(instanceId) {
|
|
100
|
+
const instanceExecutions = this.getItem(instanceId) || [];
|
|
101
|
+
// TODO: 完善类型定义
|
|
102
|
+
instanceExecutions.forEach((executionId) => {
|
|
103
|
+
storage.removeItem(executionId);
|
|
104
|
+
const instanceData = this.getItem(executionId) || [];
|
|
105
|
+
instanceData.forEach((actionId) => {
|
|
106
|
+
storage.removeItem(actionId);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
storage.removeItem(instanceId);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
166
112
|
export default Recorder;
|
|
113
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/recorder/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// 判断当前环境是否为服务端
|
|
2
|
+
// const isServer = typeof window === undefined;
|
|
3
|
+
// const isServer = process.env.BROWSER === true;
|
|
4
|
+
const isInBrowser = typeof window === 'object' && window.window === window;
|
|
5
|
+
const isInNodeJS = typeof global === 'object' && global.global === global;
|
|
6
|
+
const isInWebWorker = !isInBrowser && typeof self === 'object' && self.constructor;
|
|
7
|
+
const globalScope = (() => {
|
|
8
|
+
if (isInBrowser) {
|
|
9
|
+
return window;
|
|
10
|
+
}
|
|
11
|
+
if (typeof self === 'object' && self.self === self) {
|
|
12
|
+
return self;
|
|
13
|
+
}
|
|
14
|
+
if (isInNodeJS) {
|
|
15
|
+
return global;
|
|
16
|
+
}
|
|
17
|
+
if (typeof globalThis === 'object') {
|
|
18
|
+
return globalThis;
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
eval: () => undefined,
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
export {
|
|
25
|
+
// 环境相关方法
|
|
26
|
+
globalScope, isInWebWorker, isInBrowser, isInNodeJS, };
|
|
27
|
+
//# sourceMappingURL=global.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.js","sourceRoot":"","sources":["../../src/utils/global.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,gDAAgD;AAEhD,iDAAiD;AAEjD,MAAM,WAAW,GAAG,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAA;AAE1E,MAAM,UAAU,GAAG,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAA;AAEzE,MAAM,aAAa,GACjB,CAAC,WAAW,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,WAAW,CAAA;AAE9D,MAAM,WAAW,GAAQ,CAAC,GAAG,EAAE;IAC7B,IAAI,WAAW,EAAE;QACf,OAAO,MAAM,CAAA;KACd;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;QAClD,OAAO,IAAI,CAAA;KACZ;IAED,IAAI,UAAU,EAAE;QACd,OAAO,MAAM,CAAA;KACd;IAED,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;QAClC,OAAO,UAAU,CAAA;KAClB;IAED,OAAO;QACL,IAAI,EAAE,GAAG,EAAE,CAAC,SAAS;KACK,CAAA;AAC9B,CAAC,CAAC,EAAE,CAAA;AAEJ,OAAO;AACL,SAAS;AACT,WAAW,EACX,aAAa,EACb,WAAW,EACX,UAAU,GACX,CAAA"}
|
package/es/utils/id.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { v4 as uuidV4 } from 'uuid';
|
|
2
|
+
export const createExecId = () => {
|
|
3
|
+
const uuid = uuidV4();
|
|
4
|
+
return `exec-${uuid}`;
|
|
5
|
+
};
|
|
6
|
+
export const createActionId = () => {
|
|
7
|
+
const uuid = uuidV4();
|
|
8
|
+
return `action-${uuid}`;
|
|
9
|
+
};
|
|
10
|
+
export const createEngineId = () => {
|
|
11
|
+
const uuid = uuidV4();
|
|
12
|
+
return `engine-${uuid}`;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.js","sourceRoot":"","sources":["../../src/utils/id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AAEnC,MAAM,CAAC,MAAM,YAAY,GAAG,GAAW,EAAE;IACvC,MAAM,IAAI,GAAG,MAAM,EAAE,CAAA;IACrB,OAAO,QAAQ,IAAI,EAAE,CAAA;AACvB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,GAAW,EAAE;IACzC,MAAM,IAAI,GAAG,MAAM,EAAE,CAAA;IACrB,OAAO,UAAU,IAAI,EAAE,CAAA;AACzB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,GAAW,EAAE;IACzC,MAAM,IAAI,GAAG,MAAM,EAAE,CAAA;IACrB,OAAO,UAAU,IAAI,EAAE,CAAA;AACzB,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAA;AAE/B,cAAc,UAAU,CAAA;AACxB,cAAc,MAAM,CAAA;AACpB,OAAO,EAAE,OAAO,EAAE,CAAA"}
|
|
@@ -3,43 +3,44 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { globalScope } from './global';
|
|
5
5
|
if (!globalScope.sessionStorage) {
|
|
6
|
-
|
|
6
|
+
const storage = {
|
|
7
7
|
data: {},
|
|
8
|
-
setItem
|
|
9
|
-
|
|
8
|
+
setItem(key, value) {
|
|
9
|
+
storage.data[key] = value;
|
|
10
10
|
},
|
|
11
|
-
getItem
|
|
12
|
-
return
|
|
11
|
+
getItem(key) {
|
|
12
|
+
return storage.data[key];
|
|
13
13
|
},
|
|
14
|
-
removeItem
|
|
15
|
-
delete
|
|
14
|
+
removeItem(key) {
|
|
15
|
+
delete storage.data[key];
|
|
16
16
|
},
|
|
17
|
-
clear
|
|
18
|
-
|
|
17
|
+
clear() {
|
|
18
|
+
storage.data = {};
|
|
19
19
|
},
|
|
20
20
|
};
|
|
21
|
-
globalScope.sessionStorage =
|
|
21
|
+
globalScope.sessionStorage = storage;
|
|
22
22
|
}
|
|
23
23
|
export default {
|
|
24
|
-
setItem
|
|
24
|
+
setItem(key, value) {
|
|
25
25
|
if (typeof value === 'object') {
|
|
26
26
|
value = JSON.stringify(value);
|
|
27
27
|
}
|
|
28
28
|
globalScope.sessionStorage.setItem(key, value);
|
|
29
29
|
},
|
|
30
|
-
getItem
|
|
31
|
-
|
|
30
|
+
getItem(key) {
|
|
31
|
+
const value = globalScope.sessionStorage.getItem(key);
|
|
32
32
|
try {
|
|
33
33
|
return JSON.parse(value);
|
|
34
34
|
}
|
|
35
|
-
catch (
|
|
35
|
+
catch (error) {
|
|
36
36
|
return value;
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
|
-
removeItem
|
|
39
|
+
removeItem(key) {
|
|
40
40
|
globalScope.sessionStorage.removeItem(key);
|
|
41
41
|
},
|
|
42
|
-
clear
|
|
42
|
+
clear() {
|
|
43
43
|
globalScope.sessionStorage.clear();
|
|
44
44
|
},
|
|
45
45
|
};
|
|
46
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/utils/storage.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEtC,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE;IAC/B,MAAM,OAAO,GAAG;QACd,IAAI,EAAE,EAA6B;QAEnC,OAAO,CAAC,GAAG,EAAE,KAAK;YAChB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QAC3B,CAAC;QAED,OAAO,CAAC,GAAG;YACT,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAC1B,CAAC;QAED,UAAU,CAAC,GAAG;YACZ,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAC1B,CAAC;QAED,KAAK;YACH,OAAO,CAAC,IAAI,GAAG,EAAE,CAAA;QACnB,CAAC;KACF,CAAA;IAED,WAAW,CAAC,cAAc,GAAG,OAAO,CAAA;CACrC;AAED,eAAe;IACb,OAAO,CAAC,GAAG,EAAE,KAAK;QAChB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;SAC9B;QAED,WAAW,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IAChD,CAAC;IAED,OAAO,CAAC,GAAG;QACT,MAAM,KAAK,GAAG,WAAW,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QACrD,IAAI;YACF,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;SACzB;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,KAAK,CAAA;SACb;IACH,CAAC;IAED,UAAU,CAAC,GAAG;QACZ,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IAC5C,CAAC;IAED,KAAK;QACH,WAAW,CAAC,cAAc,CAAC,KAAK,EAAE,CAAA;IACpC,CAAC;CACF,CAAA"}
|