@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.
Files changed (170) hide show
  1. package/README.md +5 -2
  2. package/dist/index.js +2 -0
  3. package/dist/index.js.map +1 -0
  4. package/es/EventEmitter.d.ts +34 -4
  5. package/es/EventEmitter.js +70 -48
  6. package/es/EventEmitter.js.map +1 -0
  7. package/es/FlowModel.d.ts +75 -73
  8. package/es/FlowModel.js +130 -173
  9. package/es/FlowModel.js.map +1 -0
  10. package/es/Scheduler.d.ts +50 -34
  11. package/es/Scheduler.js +134 -209
  12. package/es/Scheduler.js.map +1 -0
  13. package/es/constant/{constant.js → index.js} +8 -7
  14. package/es/constant/index.js.map +1 -0
  15. package/es/constant/logCode.js +29 -0
  16. package/es/constant/logCode.js.map +1 -0
  17. package/es/index.d.ts +135 -38
  18. package/es/index.js +92 -144
  19. package/es/index.js.map +1 -0
  20. package/es/nodes/base.d.ts +108 -0
  21. package/es/nodes/base.js +151 -0
  22. package/es/nodes/base.js.map +1 -0
  23. package/es/nodes/index.d.ts +3 -0
  24. package/es/nodes/index.js +4 -0
  25. package/es/nodes/index.js.map +1 -0
  26. package/es/nodes/{StartNode.d.ts → start.d.ts} +3 -2
  27. package/es/nodes/start.js +11 -0
  28. package/es/nodes/start.js.map +1 -0
  29. package/es/nodes/{TaskNode.d.ts → task.d.ts} +3 -2
  30. package/es/nodes/task.js +11 -0
  31. package/es/nodes/task.js.map +1 -0
  32. package/es/platform/browser/browserVm.d.ts +1 -0
  33. package/es/platform/browser/browserVm.js +66 -0
  34. package/es/platform/browser/browserVm.js.map +1 -0
  35. package/es/platform/browser/index.d.ts +4 -0
  36. package/es/platform/browser/index.js +23 -0
  37. package/es/platform/browser/index.js.map +1 -0
  38. package/es/platform/index.d.ts +1 -0
  39. package/es/platform/index.js +2 -0
  40. package/es/platform/index.js.map +1 -0
  41. package/es/platform/node/index.d.ts +4 -0
  42. package/es/platform/node/index.js +23 -0
  43. package/es/platform/node/index.js.map +1 -0
  44. package/es/platform/node/nodeVm.d.ts +1 -0
  45. package/es/platform/node/nodeVm.js +9 -0
  46. package/es/platform/node/nodeVm.js.map +1 -0
  47. package/es/recorder/index.d.ts +36 -10
  48. package/es/recorder/index.js +82 -135
  49. package/es/recorder/index.js.map +1 -0
  50. package/es/utils/global.d.ts +5 -0
  51. package/es/utils/global.js +27 -0
  52. package/es/utils/global.js.map +1 -0
  53. package/es/utils/id.js +14 -0
  54. package/es/utils/id.js.map +1 -0
  55. package/es/utils/index.d.ts +4 -0
  56. package/es/utils/index.js +5 -0
  57. package/es/utils/index.js.map +1 -0
  58. package/es/{util → utils}/storage.js +17 -16
  59. package/es/utils/storage.js.map +1 -0
  60. package/lib/EventEmitter.d.ts +37 -0
  61. package/lib/EventEmitter.js +94 -0
  62. package/lib/EventEmitter.js.map +1 -0
  63. package/lib/FlowModel.d.ts +146 -0
  64. package/lib/FlowModel.js +236 -0
  65. package/lib/FlowModel.js.map +1 -0
  66. package/lib/Scheduler.d.ts +78 -0
  67. package/lib/Scheduler.js +179 -0
  68. package/lib/Scheduler.js.map +1 -0
  69. package/lib/constant/index.d.ts +16 -0
  70. package/{cjs/constant/constant.js → lib/constant/index.js} +4 -3
  71. package/lib/constant/index.js.map +1 -0
  72. package/lib/constant/logCode.d.ts +12 -0
  73. package/{cjs/constant/LogCode.js → lib/constant/logCode.js} +16 -13
  74. package/lib/constant/logCode.js.map +1 -0
  75. package/lib/index.d.ts +157 -0
  76. package/lib/index.js +159 -0
  77. package/lib/index.js.map +1 -0
  78. package/lib/nodes/base.d.ts +108 -0
  79. package/lib/nodes/base.js +154 -0
  80. package/lib/nodes/base.js.map +1 -0
  81. package/lib/nodes/index.d.ts +3 -0
  82. package/lib/nodes/index.js +7 -0
  83. package/lib/nodes/index.js.map +1 -0
  84. package/lib/nodes/start.d.ts +6 -0
  85. package/lib/nodes/start.js +15 -0
  86. package/lib/nodes/start.js.map +1 -0
  87. package/lib/nodes/task.d.ts +6 -0
  88. package/lib/nodes/task.js +15 -0
  89. package/lib/nodes/task.js.map +1 -0
  90. package/lib/platform/browser/browserVm.d.ts +1 -0
  91. package/lib/platform/browser/browserVm.js +70 -0
  92. package/lib/platform/browser/browserVm.js.map +1 -0
  93. package/lib/platform/browser/index.d.ts +4 -0
  94. package/lib/platform/browser/index.js +28 -0
  95. package/lib/platform/browser/index.js.map +1 -0
  96. package/lib/platform/index.d.ts +1 -0
  97. package/lib/platform/index.js +5 -0
  98. package/lib/platform/index.js.map +1 -0
  99. package/lib/platform/node/index.d.ts +4 -0
  100. package/lib/platform/node/index.js +28 -0
  101. package/lib/platform/node/index.js.map +1 -0
  102. package/lib/platform/node/nodeVm.d.ts +1 -0
  103. package/lib/platform/node/nodeVm.js +13 -0
  104. package/lib/platform/node/nodeVm.js.map +1 -0
  105. package/lib/recorder/index.d.ts +46 -0
  106. package/lib/recorder/index.js +117 -0
  107. package/lib/recorder/index.js.map +1 -0
  108. package/lib/utils/global.d.ts +5 -0
  109. package/lib/utils/global.js +31 -0
  110. package/lib/utils/global.js.map +1 -0
  111. package/lib/utils/id.d.ts +3 -0
  112. package/lib/utils/id.js +20 -0
  113. package/lib/utils/id.js.map +1 -0
  114. package/lib/utils/index.d.ts +4 -0
  115. package/lib/utils/index.js +9 -0
  116. package/lib/utils/index.js.map +1 -0
  117. package/lib/utils/storage.d.ts +7 -0
  118. package/{cjs/util → lib/utils}/storage.js +18 -17
  119. package/lib/utils/storage.js.map +1 -0
  120. package/package.json +31 -71
  121. package/src/EventEmitter.ts +103 -0
  122. package/src/FlowModel.ts +325 -0
  123. package/src/Scheduler.ts +244 -0
  124. package/src/constant/index.ts +23 -0
  125. package/src/constant/logCode.ts +34 -0
  126. package/src/index.ts +300 -0
  127. package/src/nodes/base.ts +236 -0
  128. package/src/nodes/index.ts +3 -0
  129. package/src/nodes/start.ts +8 -0
  130. package/src/nodes/task.ts +8 -0
  131. package/src/platform/browser/browserVm.ts +68 -0
  132. package/src/platform/browser/index.ts +28 -0
  133. package/src/platform/index.ts +1 -0
  134. package/src/platform/node/index.ts +28 -0
  135. package/src/platform/node/nodeVm.ts +12 -0
  136. package/src/recorder/index.ts +137 -0
  137. package/src/typings.d.ts +0 -0
  138. package/src/utils/global.ts +41 -0
  139. package/src/utils/id.ts +16 -0
  140. package/src/utils/index.ts +5 -0
  141. package/src/utils/storage.ts +55 -0
  142. package/cjs/EventEmitter.js +0 -70
  143. package/cjs/FlowModel.js +0 -277
  144. package/cjs/Scheduler.js +0 -252
  145. package/cjs/expression/browserVm.js +0 -81
  146. package/cjs/expression/index.js +0 -57
  147. package/cjs/index.js +0 -210
  148. package/cjs/nodes/BaseNode.js +0 -252
  149. package/cjs/nodes/StartNode.js +0 -27
  150. package/cjs/nodes/TaskNode.js +0 -27
  151. package/cjs/recorder/index.js +0 -168
  152. package/cjs/util/ID.js +0 -16
  153. package/cjs/util/global.js +0 -32
  154. package/es/constant/LogCode.js +0 -28
  155. package/es/expression/browserVm.d.ts +0 -4
  156. package/es/expression/browserVm.js +0 -76
  157. package/es/expression/index.d.ts +0 -2
  158. package/es/expression/index.js +0 -54
  159. package/es/nodes/BaseNode.d.ts +0 -110
  160. package/es/nodes/BaseNode.js +0 -250
  161. package/es/nodes/StartNode.js +0 -25
  162. package/es/nodes/TaskNode.js +0 -25
  163. package/es/util/ID.js +0 -13
  164. package/es/util/global.d.ts +0 -5
  165. package/es/util/global.js +0 -26
  166. package/lib/main.js +0 -1
  167. /package/es/constant/{constant.d.ts → index.d.ts} +0 -0
  168. /package/es/constant/{LogCode.d.ts → logCode.d.ts} +0 -0
  169. /package/es/{util/ID.d.ts → utils/id.d.ts} +0 -0
  170. /package/es/{util → utils}/storage.d.ts +0 -0
@@ -0,0 +1,108 @@
1
+ import { Engine } from '..';
2
+ import { ActionStatus } from '../constant';
3
+ export interface IBaseNodeProps {
4
+ nodeConfig: BaseNode.NodeConfig;
5
+ context: Record<string, any>;
6
+ globalData: Record<string, unknown>;
7
+ }
8
+ export declare class BaseNode implements BaseNode.Base {
9
+ readonly baseType: string;
10
+ static nodeTypeName: string;
11
+ /**
12
+ * 节点的入边
13
+ */
14
+ incoming: BaseNode.IncomingConfig[];
15
+ /**
16
+ * 节点的出边
17
+ */
18
+ outgoing: BaseNode.OutgoingConfig[];
19
+ /**
20
+ * 节点的属性
21
+ */
22
+ properties?: Record<string, unknown>;
23
+ nodeId: Engine.Key;
24
+ type: string;
25
+ /**
26
+ * 节点的上下文,是调用流程时传入的上下文
27
+ */
28
+ context: Record<string, any>;
29
+ /**
30
+ * 节点的全局数据,是调用流程时传入的全局数据
31
+ * 在计算表达式时,即基于全局数据进行计算
32
+ */
33
+ globalData: Record<string, unknown>;
34
+ constructor({ nodeConfig, context, globalData }: IBaseNodeProps);
35
+ /**
36
+ * 节点的执行逻辑
37
+ * @overridable 可以自定义节点重写此方法
38
+ * @param param.executionId 流程执行记录 ID
39
+ * @param param.actionId 此节点执行记录 ID
40
+ * @param param.nodeId 节点 ID
41
+ * @return 返回下一步的执行参数
42
+ * 当不返回时,表示此节点执行成功,流程会继续执行下一步。
43
+ * 当返回时,返回格式为
44
+ */
45
+ action(param?: Engine.ActionParam): Promise<BaseNode.ActionResult | undefined>;
46
+ /**
47
+ * 节点重新恢复执行的逻辑
48
+ * @overridable 可以自定义节点重写此方法
49
+ * @param params.executionId 流程执行记录 ID
50
+ * @param params.actionId 此节点执行记录 ID
51
+ * @param params.nodeId 节点 ID
52
+ */
53
+ onResume(params: Engine.ResumeParam): Promise<void>;
54
+ /**
55
+ * 判断该节点是否满足条件
56
+ */
57
+ private isPass;
58
+ /**
59
+ * 获取当前节点执行的下一个节点
60
+ */
61
+ private getOutgoing;
62
+ /**
63
+ * 节点的每一次执行都会生成一个唯一的 actionId
64
+ */
65
+ execute(params: Engine.ExecParam): Promise<Engine.NextActionParam>;
66
+ resume(params: Engine.ExecResumeParam): Promise<undefined>;
67
+ }
68
+ export declare namespace BaseNode {
69
+ interface Base {
70
+ incoming: IncomingConfig[];
71
+ outgoing: OutgoingConfig[];
72
+ properties?: Record<string, unknown>;
73
+ nodeId: Engine.Key;
74
+ type: string;
75
+ readonly baseType: string;
76
+ execute(actionParam: Engine.ActionParam): Promise<Engine.NextActionParam>;
77
+ }
78
+ type IncomingConfig = {
79
+ id: Engine.Key;
80
+ source: string;
81
+ properties?: Record<string, unknown>;
82
+ };
83
+ type OutgoingConfig = {
84
+ id: Engine.Key;
85
+ target: string;
86
+ properties?: Record<string, unknown>;
87
+ result?: string | boolean;
88
+ };
89
+ type NodeConfig = {
90
+ id: Engine.Key;
91
+ type: string;
92
+ properties?: Record<string, unknown>;
93
+ incoming: IncomingConfig[];
94
+ outgoing: OutgoingConfig[];
95
+ };
96
+ type NodeConstructor = {
97
+ new (config: {
98
+ nodeConfig: NodeConfig;
99
+ context: Record<string, any>;
100
+ globalData: Record<string, unknown>;
101
+ }): BaseNode;
102
+ };
103
+ type ActionResult = {
104
+ status: ActionStatus;
105
+ detail?: Record<string, unknown>;
106
+ };
107
+ }
108
+ export default BaseNode;
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseNode = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const constant_1 = require("../constant");
6
+ const platform_1 = require("../platform");
7
+ class BaseNode {
8
+ constructor({ nodeConfig, context, globalData }) {
9
+ const { outgoing, incoming, id, type, properties } = nodeConfig;
10
+ this.baseType = 'base';
11
+ this.outgoing = outgoing;
12
+ this.incoming = incoming;
13
+ this.nodeId = id;
14
+ this.type = type;
15
+ this.properties = properties;
16
+ this.context = context;
17
+ this.globalData = globalData;
18
+ }
19
+ /**
20
+ * 节点的执行逻辑
21
+ * @overridable 可以自定义节点重写此方法
22
+ * @param param.executionId 流程执行记录 ID
23
+ * @param param.actionId 此节点执行记录 ID
24
+ * @param param.nodeId 节点 ID
25
+ * @return 返回下一步的执行参数
26
+ * 当不返回时,表示此节点执行成功,流程会继续执行下一步。
27
+ * 当返回时,返回格式为
28
+ */
29
+ action(param) {
30
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
31
+ console.log('action param --->>>', param);
32
+ return undefined;
33
+ });
34
+ }
35
+ /**
36
+ * 节点重新恢复执行的逻辑
37
+ * @overridable 可以自定义节点重写此方法
38
+ * @param params.executionId 流程执行记录 ID
39
+ * @param params.actionId 此节点执行记录 ID
40
+ * @param params.nodeId 节点 ID
41
+ */
42
+ onResume(params) {
43
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
44
+ console.log('onResume params --->>>', params);
45
+ return undefined;
46
+ });
47
+ }
48
+ /**
49
+ * 判断该节点是否满足条件
50
+ */
51
+ isPass(properties) {
52
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
53
+ if (!properties)
54
+ return true;
55
+ const { conditionExpression } = properties;
56
+ if (!conditionExpression)
57
+ return true;
58
+ try {
59
+ // bug:uuid 创建的 NodeId 为 xxxx-xxxx-xxxx-zzzz 格式,eval 执行时会将 - 识别为数学减号,导致执行报错
60
+ // 解决方案: 赋值变量直接命名为 isPassResult, 因为每次执行 getExpressionResult 时,都会重新射程一个 context
61
+ return yield (0, platform_1.getExpressionResult)(`
62
+ const isPassResult = (${conditionExpression})
63
+ return isPassResult
64
+ `, Object.assign({}, this.globalData));
65
+ }
66
+ catch (error) {
67
+ return false;
68
+ }
69
+ });
70
+ }
71
+ /**
72
+ * 获取当前节点执行的下一个节点
73
+ */
74
+ getOutgoing() {
75
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
76
+ const outgoing = [];
77
+ const expressions = [];
78
+ for (const item of this.outgoing) {
79
+ const { properties } = item;
80
+ expressions.push(this.isPass(properties));
81
+ }
82
+ const result = yield Promise.all(expressions);
83
+ result.forEach((item, index) => {
84
+ const out = this.outgoing[index];
85
+ out.result = item;
86
+ outgoing.push(out);
87
+ });
88
+ return outgoing;
89
+ });
90
+ }
91
+ /**
92
+ * 节点的每一次执行都会生成一个唯一的 actionId
93
+ */
94
+ execute(params) {
95
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
96
+ const { executionId, actionId } = params;
97
+ const res = yield this.action({
98
+ nodeId: this.nodeId,
99
+ executionId,
100
+ actionId,
101
+ });
102
+ const status = res ? res.status : 'success';
103
+ if (status === constant_1.ActionStatus.SUCCESS) {
104
+ const outgoing = yield this.getOutgoing();
105
+ const detail = res ? res.detail : {};
106
+ params.next({
107
+ status: constant_1.ActionStatus.SUCCESS,
108
+ detail,
109
+ nodeId: this.nodeId,
110
+ nodeType: this.type,
111
+ properties: this.properties,
112
+ executionId,
113
+ actionId,
114
+ outgoing,
115
+ });
116
+ }
117
+ return {
118
+ status,
119
+ detail: res === null || res === void 0 ? void 0 : res.detail,
120
+ executionId,
121
+ actionId,
122
+ nodeId: this.nodeId,
123
+ nodeType: this.type,
124
+ properties: this.properties,
125
+ outgoing: [],
126
+ };
127
+ });
128
+ }
129
+ resume(params) {
130
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
131
+ const outgoing = yield this.getOutgoing();
132
+ yield this.onResume({
133
+ executionId: params.executionId,
134
+ actionId: params.actionId,
135
+ nodeId: params.nodeId,
136
+ data: params.data,
137
+ });
138
+ params.next({
139
+ executionId: params.executionId,
140
+ actionId: params.actionId,
141
+ nodeId: this.nodeId,
142
+ nodeType: this.type,
143
+ properties: this.properties,
144
+ outgoing,
145
+ status: constant_1.ActionStatus.SUCCESS,
146
+ });
147
+ return undefined;
148
+ });
149
+ }
150
+ }
151
+ BaseNode.nodeTypeName = 'BaseNode';
152
+ exports.BaseNode = BaseNode;
153
+ exports.default = BaseNode;
154
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/nodes/base.ts"],"names":[],"mappings":";;;;AACA,0CAA0C;AAC1C,0CAAiD;AAQjD,MAAa,QAAQ;IA4BnB,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAk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,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./base"), exports);
5
+ tslib_1.__exportStar(require("./start"), exports);
6
+ tslib_1.__exportStar(require("./task"), exports);
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/nodes/index.ts"],"names":[],"mappings":";;;AAAA,iDAAsB;AACtB,kDAAuB;AACvB,iDAAsB"}
@@ -0,0 +1,6 @@
1
+ import BaseNode from './base';
2
+ export default class StartNode extends BaseNode {
3
+ readonly baseType = "start";
4
+ static nodeTypeName: string;
5
+ }
6
+ export { StartNode };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StartNode = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const base_1 = tslib_1.__importDefault(require("./base"));
6
+ class StartNode extends base_1.default {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.baseType = 'start';
10
+ }
11
+ }
12
+ StartNode.nodeTypeName = 'StartNode';
13
+ exports.default = StartNode;
14
+ exports.StartNode = StartNode;
15
+ //# sourceMappingURL=start.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/nodes/start.ts"],"names":[],"mappings":";;;;AAAA,0DAA6B;AAE7B,MAAqB,SAAU,SAAQ,cAAQ;IAA/C;;QACW,aAAQ,GAAG,OAAO,CAAA;IAE7B,CAAC;;AADQ,sBAAY,GAAG,WAAW,AAAd,CAAc;kBAFd,SAAS;AAKrB,8BAAS"}
@@ -0,0 +1,6 @@
1
+ import BaseNode from './base';
2
+ export default class TaskNode extends BaseNode {
3
+ readonly baseType = "task";
4
+ static nodeTypeName: string;
5
+ }
6
+ export { TaskNode };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TaskNode = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const base_1 = tslib_1.__importDefault(require("./base"));
6
+ class TaskNode extends base_1.default {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.baseType = 'task';
10
+ }
11
+ }
12
+ TaskNode.nodeTypeName = 'TaskNode';
13
+ exports.default = TaskNode;
14
+ exports.TaskNode = TaskNode;
15
+ //# sourceMappingURL=task.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task.js","sourceRoot":"","sources":["../../src/nodes/task.ts"],"names":[],"mappings":";;;;AAAA,0DAA6B;AAE7B,MAAqB,QAAS,SAAQ,cAAQ;IAA9C;;QACW,aAAQ,GAAG,MAAM,CAAA;IAE5B,CAAC;;AADQ,qBAAY,GAAG,UAAU,AAAb,CAAa;kBAFb,QAAQ;AAKpB,4BAAQ"}
@@ -0,0 +1 @@
1
+ export declare const runInBrowserContext: (code: string, globalData?: {}) => Promise<any>;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ // import {
3
+ // ErrorCode,
4
+ // getErrorMsg,
5
+ // getWarningMsg,
6
+ // WarningCode,
7
+ // } from '../../constant/logCode'
8
+ //
9
+ // const createContext = (globalData: Record<string, unknown>) => {
10
+ // const iframe = document.createElement('iframe')
11
+ // iframe.style.display = 'none'
12
+ // if (!document || !document.body) {
13
+ // console.error(getErrorMsg(ErrorCode.NO_DOCUMENT_BODY))
14
+ // }
15
+ // document.body.appendChild(iframe)
16
+ // const iframeWindow = iframe.contentWindow
17
+ // if (iframeWindow) {
18
+ // // TODO: 确认是否需要该代码,parent 置为空是为了解决什么问题
19
+ // // @ts-ignore
20
+ // ;(iframeWindow!.parent as any) = null
21
+ // Object.keys(globalData).forEach((key) => {
22
+ // iframeWindow[key] = globalData[key]
23
+ // })
24
+ // }
25
+ // return iframeWindow
26
+ // }
27
+ //
28
+ // const runInContext = (code: string, context: any) => {
29
+ // try {
30
+ // const iframeEval = context.eval
31
+ // iframeEval.call(context, code)
32
+ // console.log('context --->>> ===>>>', context)
33
+ // if (context.frameElement) {
34
+ // document.body.removeChild(context.frameElement)
35
+ // }
36
+ // } catch (e) {
37
+ // console.warn(getWarningMsg(WarningCode.EXPRESSION_EXEC_ERROR), {
38
+ // code,
39
+ // context,
40
+ // e,
41
+ // })
42
+ // }
43
+ // }
44
+ //
45
+ // const runInBrowserContext = async (
46
+ // code: string,
47
+ // globalData = {},
48
+ // ): Promise<any> => {
49
+ // const context = createContext(globalData)
50
+ // runInContext(code, context)
51
+ // return context
52
+ // }
53
+ //
54
+ // export { createContext, runInContext, runInBrowserContext }
55
+ Object.defineProperty(exports, "__esModule", { value: true });
56
+ exports.runInBrowserContext = void 0;
57
+ const tslib_1 = require("tslib");
58
+ const sandboxjs_1 = tslib_1.__importDefault(require("@nyariv/sandboxjs"));
59
+ const runInBrowserContext = (code, globalData = {}) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
60
+ try {
61
+ const sandbox = new sandboxjs_1.default();
62
+ const exec = sandbox.compile(code);
63
+ return yield exec(globalData).run();
64
+ }
65
+ catch (e) {
66
+ console.log('runInBrowserContext error --->>>', e);
67
+ }
68
+ });
69
+ exports.runInBrowserContext = runInBrowserContext;
70
+ //# 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,0EAAwC;AAEjC,MAAM,mBAAmB,GAAG,CACjC,IAAY,EACZ,UAAU,GAAG,EAAE,EACD,EAAE;IAChB,IAAI;QACF,MAAM,OAAO,GAAG,IAAI,mBAAO,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;AAXY,QAAA,mBAAmB,uBAW/B"}
@@ -0,0 +1,4 @@
1
+ declare const isInBrowser: boolean;
2
+ declare const globalScope: any;
3
+ declare const getExpressionResult: (code: string, context: any) => Promise<any>;
4
+ export { isInBrowser, globalScope, getExpressionResult };
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getExpressionResult = exports.globalScope = exports.isInBrowser = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const browserVm_1 = require("./browserVm");
6
+ const isInBrowser = typeof window === 'object' && window.window === window;
7
+ exports.isInBrowser = isInBrowser;
8
+ const globalScope = (() => {
9
+ if (isInBrowser) {
10
+ return window;
11
+ }
12
+ if (typeof self === 'object' && self.self === self) {
13
+ return self;
14
+ }
15
+ if (typeof globalThis === 'object') {
16
+ return globalThis;
17
+ }
18
+ return {
19
+ eval: () => undefined,
20
+ };
21
+ })();
22
+ exports.globalScope = globalScope;
23
+ const getExpressionResult = (code, context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
24
+ const r = yield (0, browserVm_1.runInBrowserContext)(code, context);
25
+ return r;
26
+ });
27
+ exports.getExpressionResult = getExpressionResult;
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/platform/browser/index.ts"],"names":[],"mappings":";;;;AAAA,2CAAiD;AAEjD,MAAM,WAAW,GAAG,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAA;AAyBjE,kCAAW;AAvBpB,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;AAOkB,kCAAW;AALjC,MAAM,mBAAmB,GAAG,CAAO,IAAY,EAAE,OAAY,EAAE,EAAE;IAC/D,MAAM,CAAC,GAAG,MAAM,IAAA,+BAAmB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAClD,OAAO,CAAC,CAAA;AACV,CAAC,CAAA,CAAA;AAEkC,kDAAmB"}
@@ -0,0 +1 @@
1
+ export * from './node';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./node"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/platform/index.ts"],"names":[],"mappings":";;;AAAA,iDAAsB"}
@@ -0,0 +1,4 @@
1
+ declare const isInNodeJS: boolean;
2
+ declare const globalScope: any;
3
+ declare const getExpressionResult: (code: string, context: any) => Promise<any>;
4
+ export { isInNodeJS, globalScope, getExpressionResult };
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getExpressionResult = exports.globalScope = exports.isInNodeJS = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const nodeVm_1 = require("./nodeVm");
6
+ const isInNodeJS = typeof global === 'object' && global.global === global;
7
+ exports.isInNodeJS = isInNodeJS;
8
+ const globalScope = (() => {
9
+ if (typeof self === 'object' && self.self === self) {
10
+ return self;
11
+ }
12
+ if (isInNodeJS) {
13
+ return global;
14
+ }
15
+ if (typeof globalThis === 'object') {
16
+ return globalThis;
17
+ }
18
+ return {
19
+ eval: () => undefined,
20
+ };
21
+ })();
22
+ exports.globalScope = globalScope;
23
+ const getExpressionResult = (code, context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
24
+ const r = yield (0, nodeVm_1.runInNodeContext)(code, context);
25
+ return r;
26
+ });
27
+ exports.getExpressionResult = getExpressionResult;
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/platform/node/index.ts"],"names":[],"mappings":";;;;AAAA,qCAA2C;AAE3C,MAAM,UAAU,GAAG,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAA;AAyBhE,gCAAU;AAvBnB,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;AAOiB,kCAAW;AALhC,MAAM,mBAAmB,GAAG,CAAO,IAAY,EAAE,OAAY,EAAE,EAAE;IAC/D,MAAM,CAAC,GAAG,MAAM,IAAA,yBAAgB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAC/C,OAAO,CAAC,CAAA;AACV,CAAC,CAAA,CAAA;AAEiC,kDAAmB"}
@@ -0,0 +1 @@
1
+ export declare const runInNodeContext: (code: string, globalData?: Record<string, unknown>) => Promise<any>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runInNodeContext = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const node_vm_1 = tslib_1.__importDefault(require("node:vm"));
6
+ // const vm = require('node:vm');
7
+ const runInNodeContext = (code, globalData = {}) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
8
+ const context = node_vm_1.default.createContext(globalData);
9
+ node_vm_1.default.runInContext(code, context);
10
+ return context;
11
+ });
12
+ exports.runInNodeContext = runInNodeContext;
13
+ //# sourceMappingURL=nodeVm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeVm.js","sourceRoot":"","sources":["../../../src/platform/node/nodeVm.ts"],"names":[],"mappings":";;;;AAAA,8DAAwB;AACxB,iCAAiC;AAE1B,MAAM,gBAAgB,GAAG,CAC9B,IAAY,EACZ,aAAsC,EAAE,EAC1B,EAAE;IAChB,MAAM,OAAO,GAAG,iBAAE,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;IAC5C,iBAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAE9B,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA,CAAA;AARY,QAAA,gBAAgB,oBAQ5B"}
@@ -0,0 +1,46 @@
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;
7
+ maxRecorder: number;
8
+ constructor({ instanceId }: {
9
+ instanceId: any;
10
+ });
11
+ setMaxRecorderNumber(max: number): void;
12
+ setItem(key: string | number, value: unknown): void;
13
+ getItem(key: string | number): any;
14
+ getExecutionActions(executionId: Engine.Key): Promise<any>;
15
+ getExecutionList(): Promise<any>;
16
+ private addExecution;
17
+ private popExecution;
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;
45
+ }
46
+ export default Recorder;