@logicflow/engine 0.0.8 → 0.0.10-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/expression/brewserVm.d.ts +2 -0
- package/es/expression/brewserVm.js +30 -0
- package/es/expression/brewserVm.js.map +1 -0
- package/es/expression/index.d.ts +1 -1
- package/es/expression/index.js +16 -59
- package/es/expression/index.js.map +1 -0
- package/es/expression/nodeVm.d.ts +4 -2
- package/es/expression/nodeVm.js +10 -50
- package/es/expression/nodeVm.js.map +1 -0
- package/es/index.d.ts +135 -38
- package/es/index.js +93 -145
- package/es/index.js.map +1 -0
- package/es/nodes/base.d.ts +108 -0
- package/es/nodes/base.js +149 -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 +4 -0
- package/es/platform/browser/browserVm.js +44 -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/expression/brewserVm.d.ts +2 -0
- package/lib/expression/brewserVm.js +33 -0
- package/lib/expression/brewserVm.js.map +1 -0
- package/lib/expression/index.d.ts +2 -0
- package/lib/expression/index.js +20 -0
- package/lib/expression/index.js.map +1 -0
- package/lib/expression/nodeVm.d.ts +4 -0
- package/lib/expression/nodeVm.js +13 -0
- package/lib/expression/nodeVm.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 +152 -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 +4 -0
- package/lib/platform/browser/browserVm.js +49 -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 +30 -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/expression/brewserVm.ts +36 -0
- package/src/expression/index.ts +17 -0
- package/src/expression/nodeVm.ts +14 -0
- package/src/index.ts +300 -0
- package/src/nodes/base.ts +234 -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 +52 -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 -63
- package/cjs/expression/nodeVm.js +0 -53
- 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/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,152 @@
|
|
|
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
|
+
const result = yield (0, platform_1.getExpressionResult)(`isPassResult = (${conditionExpression})`, Object.assign({}, this.globalData));
|
|
62
|
+
return result.isPassResult;
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 获取当前节点执行的下一个节点
|
|
71
|
+
*/
|
|
72
|
+
getOutgoing() {
|
|
73
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const outgoing = [];
|
|
75
|
+
const expressions = [];
|
|
76
|
+
for (const item of this.outgoing) {
|
|
77
|
+
const { properties } = item;
|
|
78
|
+
expressions.push(this.isPass(properties));
|
|
79
|
+
}
|
|
80
|
+
const result = yield Promise.all(expressions);
|
|
81
|
+
result.forEach((item, index) => {
|
|
82
|
+
const out = this.outgoing[index];
|
|
83
|
+
out.result = item;
|
|
84
|
+
outgoing.push(out);
|
|
85
|
+
});
|
|
86
|
+
return outgoing;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* 节点的每一次执行都会生成一个唯一的 actionId
|
|
91
|
+
*/
|
|
92
|
+
execute(params) {
|
|
93
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const { executionId, actionId } = params;
|
|
95
|
+
const res = yield this.action({
|
|
96
|
+
nodeId: this.nodeId,
|
|
97
|
+
executionId,
|
|
98
|
+
actionId,
|
|
99
|
+
});
|
|
100
|
+
const status = res ? res.status : 'success';
|
|
101
|
+
if (status === constant_1.ActionStatus.SUCCESS) {
|
|
102
|
+
const outgoing = yield this.getOutgoing();
|
|
103
|
+
const detail = res ? res.detail : {};
|
|
104
|
+
params.next({
|
|
105
|
+
status: constant_1.ActionStatus.SUCCESS,
|
|
106
|
+
detail,
|
|
107
|
+
nodeId: this.nodeId,
|
|
108
|
+
nodeType: this.type,
|
|
109
|
+
properties: this.properties,
|
|
110
|
+
executionId,
|
|
111
|
+
actionId,
|
|
112
|
+
outgoing,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
status,
|
|
117
|
+
detail: res === null || res === void 0 ? void 0 : res.detail,
|
|
118
|
+
executionId,
|
|
119
|
+
actionId,
|
|
120
|
+
nodeId: this.nodeId,
|
|
121
|
+
nodeType: this.type,
|
|
122
|
+
properties: this.properties,
|
|
123
|
+
outgoing: [],
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
resume(params) {
|
|
128
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
const outgoing = yield this.getOutgoing();
|
|
130
|
+
yield this.onResume({
|
|
131
|
+
executionId: params.executionId,
|
|
132
|
+
actionId: params.actionId,
|
|
133
|
+
nodeId: params.nodeId,
|
|
134
|
+
data: params.data,
|
|
135
|
+
});
|
|
136
|
+
params.next({
|
|
137
|
+
executionId: params.executionId,
|
|
138
|
+
actionId: params.actionId,
|
|
139
|
+
nodeId: this.nodeId,
|
|
140
|
+
nodeType: this.type,
|
|
141
|
+
properties: this.properties,
|
|
142
|
+
outgoing,
|
|
143
|
+
status: constant_1.ActionStatus.SUCCESS,
|
|
144
|
+
});
|
|
145
|
+
return undefined;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
BaseNode.nodeTypeName = 'BaseNode';
|
|
150
|
+
exports.BaseNode = BaseNode;
|
|
151
|
+
exports.default = BaseNode;
|
|
152
|
+
//# 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,EAAkB;QAC7D,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,UAAU,CAAA;QAC/D,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAA;QACtB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAE5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAED;;;;;;;;;OASG;IACU,MAAM,CACjB,KAA0B;;YAE1B,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAA;YACzC,OAAO,SAAS,CAAA;QAClB,CAAC;KAAA;IAED;;;;;;OAMG;IACU,QAAQ,CAAC,MAA0B;;YAC9C,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAA;YAC7C,OAAO,SAAS,CAAA;QAClB,CAAC;KAAA;IAED;;OAEG;IACW,MAAM,CAAC,UAAoC;;YACvD,IAAI,CAAC,UAAU;gB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gBACV,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,QAAQ,EAAE,IAAI,CAAC,IAAI;gBACnB,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,QAAQ;gBACR,MAAM,EAAE,uBAAY,CAAC,OAAO;aAC7B,CAAC,CAAA;YACF,OAAO,SAAS,CAAA;QAClB,CAAC;KAAA;;AA5KM,qBAAY,GAAG,UAAU,CAAA;AAFrB,4BAAQ;AA+NrB,kBAAe,QAAQ,CAAA"}
|
|
@@ -0,0 +1,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,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,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,4 @@
|
|
|
1
|
+
declare const createContext: (globalData: Record<string, unknown>) => Window | null;
|
|
2
|
+
declare const runInContext: (code: string, context: any) => void;
|
|
3
|
+
declare const runInBrowserContext: (code: string, globalData?: {}) => Promise<any>;
|
|
4
|
+
export { createContext, runInContext, runInBrowserContext };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runInBrowserContext = exports.runInContext = exports.createContext = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const logCode_1 = require("../../constant/logCode");
|
|
6
|
+
const createContext = (globalData) => {
|
|
7
|
+
const iframe = document.createElement('iframe');
|
|
8
|
+
iframe.style.display = 'none';
|
|
9
|
+
if (!document || !document.body) {
|
|
10
|
+
console.error((0, logCode_1.getErrorMsg)(logCode_1.ErrorCode.NO_DOCUMENT_BODY));
|
|
11
|
+
}
|
|
12
|
+
document.body.appendChild(iframe);
|
|
13
|
+
const iframeWindow = iframe.contentWindow;
|
|
14
|
+
if (iframeWindow) {
|
|
15
|
+
// TODO: 确认是否需要该代码,parent 置为空是为了解决什么问题
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
;
|
|
18
|
+
iframeWindow.parent = null;
|
|
19
|
+
Object.keys(globalData).forEach((key) => {
|
|
20
|
+
iframeWindow[key] = globalData[key];
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return iframeWindow;
|
|
24
|
+
};
|
|
25
|
+
exports.createContext = createContext;
|
|
26
|
+
const runInContext = (code, context) => {
|
|
27
|
+
try {
|
|
28
|
+
const iframeEval = context.eval;
|
|
29
|
+
iframeEval.call(context, code);
|
|
30
|
+
if (context.iframeElement) {
|
|
31
|
+
document.body.removeChild(context.iframeElement);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
console.warn((0, logCode_1.getWarningMsg)(logCode_1.WarningCode.EXPRESSION_EXEC_ERROR), {
|
|
36
|
+
code,
|
|
37
|
+
context,
|
|
38
|
+
e,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
exports.runInContext = runInContext;
|
|
43
|
+
const runInBrowserContext = (code, globalData = {}) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
+
const context = createContext(globalData);
|
|
45
|
+
runInContext(code, context);
|
|
46
|
+
return context;
|
|
47
|
+
});
|
|
48
|
+
exports.runInBrowserContext = runInBrowserContext;
|
|
49
|
+
//# sourceMappingURL=browserVm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browserVm.js","sourceRoot":"","sources":["../../../src/platform/browser/browserVm.ts"],"names":[],"mappings":";;;;AAAA,oDAK+B;AAE/B,MAAM,aAAa,GAAG,CAAC,UAAmC,EAAE,EAAE;IAC5D,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;IAC/C,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAA;IAC7B,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;QAC/B,OAAO,CAAC,KAAK,CAAC,IAAA,qBAAW,EAAC,mBAAS,CAAC,gBAAgB,CAAC,CAAC,CAAA;KACvD;IACD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IACjC,MAAM,YAAY,GAAG,MAAM,CAAC,aAAa,CAAA;IACzC,IAAI,YAAY,EAAE;QAChB,sCAAsC;QACtC,aAAa;QACb,CAAC;QAAC,YAAa,CAAC,MAAc,GAAG,IAAI,CAAA;QACrC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACtC,YAAY,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAA;QACrC,CAAC,CAAC,CAAA;KACH;IACD,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA;AA2BQ,sCAAa;AAzBtB,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,OAAO,EAAE,EAAE;IAC7C,IAAI;QACF,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAA;QAC/B,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QAC9B,IAAI,OAAO,CAAC,aAAa,EAAE;YACzB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;SACjD;KACF;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,IAAI,CAAC,IAAA,uBAAa,EAAC,qBAAW,CAAC,qBAAqB,CAAC,EAAE;YAC7D,IAAI;YACJ,OAAO;YACP,CAAC;SACF,CAAC,CAAA;KACH;AACH,CAAC,CAAA;AAWuB,oCAAY;AATpC,MAAM,mBAAmB,GAAG,CAC1B,IAAY,EACZ,UAAU,GAAG,EAAE,EACD,EAAE;IAChB,MAAM,OAAO,GAAG,aAAa,CAAC,UAAU,CAAC,CAAA;IACzC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAC3B,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA,CAAA;AAEqC,kDAAmB"}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/platform/index.ts"],"names":[],"mappings":";;;AAAA,iDAAsB"}
|
|
@@ -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;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Recorder = exports.LOGICFLOW_ENGINE_INSTANCES = exports.MAX_INSTANCE = exports.MAX_RECORDER = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
exports.MAX_RECORDER = 100;
|
|
7
|
+
exports.MAX_INSTANCE = 100;
|
|
8
|
+
exports.LOGICFLOW_ENGINE_INSTANCES = 'LOGICFLOW_ENGINE_INSTANCES';
|
|
9
|
+
class Recorder {
|
|
10
|
+
constructor({ instanceId }) {
|
|
11
|
+
this.instanceId = instanceId;
|
|
12
|
+
this.maxRecorder = exports.MAX_RECORDER;
|
|
13
|
+
const instances = this.getItem(exports.LOGICFLOW_ENGINE_INSTANCES) || [];
|
|
14
|
+
if (instances.indexOf(instanceId) === -1) {
|
|
15
|
+
instances.push(instanceId);
|
|
16
|
+
}
|
|
17
|
+
if (instances.length > exports.MAX_INSTANCE) {
|
|
18
|
+
const clearInstance = instances.shift();
|
|
19
|
+
this.clearInstance(clearInstance);
|
|
20
|
+
}
|
|
21
|
+
this.setItem(exports.LOGICFLOW_ENGINE_INSTANCES, instances);
|
|
22
|
+
}
|
|
23
|
+
setMaxRecorderNumber(max) {
|
|
24
|
+
this.maxRecorder = max;
|
|
25
|
+
}
|
|
26
|
+
// 将存储 storage 的方法收敛到此处,并在此处做异常处理 - setItem
|
|
27
|
+
setItem(key, value) {
|
|
28
|
+
try {
|
|
29
|
+
utils_1.storage.setItem(key, value);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error('Ops, something wrong with storage.setItem !!!');
|
|
33
|
+
utils_1.storage.clear();
|
|
34
|
+
utils_1.storage.setItem(key, value);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// getItem 方法
|
|
38
|
+
getItem(key) {
|
|
39
|
+
return utils_1.storage.getItem(key);
|
|
40
|
+
}
|
|
41
|
+
getExecutionActions(executionId) {
|
|
42
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
return this.getItem(executionId);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
getExecutionList() {
|
|
47
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
return this.getItem(this.instanceId) || [];
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
addExecution(executionId) {
|
|
52
|
+
const instanceExecutions = this.getItem(this.instanceId) || [];
|
|
53
|
+
if (instanceExecutions.length >= this.maxRecorder) {
|
|
54
|
+
const toBeRemovedItem = instanceExecutions.shift();
|
|
55
|
+
this.popExecution(toBeRemovedItem);
|
|
56
|
+
}
|
|
57
|
+
instanceExecutions.push(executionId);
|
|
58
|
+
this.setItem(this.instanceId, instanceExecutions);
|
|
59
|
+
}
|
|
60
|
+
popExecution(executionId) {
|
|
61
|
+
const instanceData = this.getItem(executionId) || [];
|
|
62
|
+
instanceData.forEach((actionId) => {
|
|
63
|
+
utils_1.storage.removeItem(actionId);
|
|
64
|
+
});
|
|
65
|
+
utils_1.storage.removeItem(executionId);
|
|
66
|
+
}
|
|
67
|
+
pushActionToExecution(executionId, actionId) {
|
|
68
|
+
const actions = this.getItem(executionId) || [];
|
|
69
|
+
actions.push(actionId);
|
|
70
|
+
this.setItem(executionId, actions);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @param {Object} action
|
|
74
|
+
* {
|
|
75
|
+
* actionId: '',
|
|
76
|
+
* nodeId: '',
|
|
77
|
+
* executionId: '',
|
|
78
|
+
* nodeType: '',
|
|
79
|
+
* timestamp: '',
|
|
80
|
+
* properties: {},
|
|
81
|
+
* }
|
|
82
|
+
*/
|
|
83
|
+
addActionRecord(action) {
|
|
84
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
const { executionId, actionId } = action;
|
|
86
|
+
const instanceData = yield this.getExecutionActions(executionId);
|
|
87
|
+
if (!instanceData) {
|
|
88
|
+
this.addExecution(executionId);
|
|
89
|
+
}
|
|
90
|
+
this.pushActionToExecution(executionId, actionId);
|
|
91
|
+
this.setItem(actionId, action);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
getActionRecord(actionId) {
|
|
95
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
return this.getItem(actionId);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
clear() {
|
|
100
|
+
this.clearInstance(this.instanceId);
|
|
101
|
+
}
|
|
102
|
+
clearInstance(instanceId) {
|
|
103
|
+
const instanceExecutions = this.getItem(instanceId) || [];
|
|
104
|
+
// TODO: 完善类型定义
|
|
105
|
+
instanceExecutions.forEach((executionId) => {
|
|
106
|
+
utils_1.storage.removeItem(executionId);
|
|
107
|
+
const instanceData = this.getItem(executionId) || [];
|
|
108
|
+
instanceData.forEach((actionId) => {
|
|
109
|
+
utils_1.storage.removeItem(actionId);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
utils_1.storage.removeItem(instanceId);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.Recorder = Recorder;
|
|
116
|
+
exports.default = Recorder;
|
|
117
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/recorder/index.ts"],"names":[],"mappings":";;;;AACA,oCAAkC;AAErB,QAAA,YAAY,GAAG,GAAG,CAAA;AAClB,QAAA,YAAY,GAAG,GAAG,CAAA;AAClB,QAAA,0BAA0B,GAAG,4BAA4B,CAAA;AAEtE,MAAa,QAAQ;IAInB,YAAY,EAAE,UAAU,EAAE;QACxB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B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AAW,EAAE,QAAQ,CAAC,CAAA;YACjD,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QAChC,CAAC;KAAA;IAEK,eAAe,CAAC,QAAoB;;YACxC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QAC/B,CAAC;KAAA;IAED,KAAK;QACH,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACrC,CAAC;IAED,aAAa,CAAC,UAAsB;QAClC,MAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,CAAA;QACzD,eAAe;QACf,kBAAkB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;YACzC,eAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAA;YAC/B,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,CAAA;YACpD,YAAY,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;gBAChC,eAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;YAC9B,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QAEF,eAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;IAChC,CAAC;CACF;AAlHD,4BAkHC;AAeD,kBAAe,QAAQ,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// 判断当前环境是否为服务端
|
|
3
|
+
// const isServer = typeof window === undefined;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.isInNodeJS = exports.isInBrowser = exports.isInWebWorker = exports.globalScope = void 0;
|
|
6
|
+
// const isServer = process.env.BROWSER === true;
|
|
7
|
+
const isInBrowser = typeof window === 'object' && window.window === window;
|
|
8
|
+
exports.isInBrowser = isInBrowser;
|
|
9
|
+
const isInNodeJS = typeof global === 'object' && global.global === global;
|
|
10
|
+
exports.isInNodeJS = isInNodeJS;
|
|
11
|
+
const isInWebWorker = !isInBrowser && typeof self === 'object' && self.constructor;
|
|
12
|
+
exports.isInWebWorker = isInWebWorker;
|
|
13
|
+
const globalScope = (() => {
|
|
14
|
+
if (isInBrowser) {
|
|
15
|
+
return window;
|
|
16
|
+
}
|
|
17
|
+
if (typeof self === 'object' && self.self === self) {
|
|
18
|
+
return self;
|
|
19
|
+
}
|
|
20
|
+
if (isInNodeJS) {
|
|
21
|
+
return global;
|
|
22
|
+
}
|
|
23
|
+
if (typeof globalThis === 'object') {
|
|
24
|
+
return globalThis;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
eval: () => undefined,
|
|
28
|
+
};
|
|
29
|
+
})();
|
|
30
|
+
exports.globalScope = globalScope;
|
|
31
|
+
//# 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;AAiCxE,kCAAW;AA/Bb,MAAM,UAAU,GAAG,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAA;AAgCvE,gCAAU;AA9BZ,MAAM,aAAa,GACjB,CAAC,WAAW,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,WAAW,CAAA;AA2B5D,sCAAa;AAzBf,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;AAIF,kCAAW"}
|
package/lib/utils/id.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createEngineId = exports.createActionId = exports.createExecId = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
const createExecId = () => {
|
|
6
|
+
const uuid = (0, uuid_1.v4)();
|
|
7
|
+
return `exec-${uuid}`;
|
|
8
|
+
};
|
|
9
|
+
exports.createExecId = createExecId;
|
|
10
|
+
const createActionId = () => {
|
|
11
|
+
const uuid = (0, uuid_1.v4)();
|
|
12
|
+
return `action-${uuid}`;
|
|
13
|
+
};
|
|
14
|
+
exports.createActionId = createActionId;
|
|
15
|
+
const createEngineId = () => {
|
|
16
|
+
const uuid = (0, uuid_1.v4)();
|
|
17
|
+
return `engine-${uuid}`;
|
|
18
|
+
};
|
|
19
|
+
exports.createEngineId = createEngineId;
|
|
20
|
+
//# sourceMappingURL=id.js.map
|