@kissflow/lowcode-client-sdk 1.0.16-beta-1 → 1.0.16-beta-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/worker.js +40 -0
- package/package.json +1 -1
package/dist/worker.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import KF_LC_SDK from "./kf.lowcodeworkersdk.es.js";
|
|
2
|
+
import KF_NC_SDK from "./kf.nocodeworkersdk.es.js";
|
|
3
|
+
|
|
4
|
+
const SDK_KIND = {
|
|
5
|
+
LOWCODE: "lowcode",
|
|
6
|
+
NOCODE: "nocode"
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
onmessage = async function (e) {
|
|
10
|
+
if (!self.kf) {
|
|
11
|
+
let { kind = SDK_KIND.LOWCODE } = e.data?.executionContext;
|
|
12
|
+
let lib = KF_LC_SDK;
|
|
13
|
+
if (kind === SDK_KIND.NOCODE) {
|
|
14
|
+
lib = KF_NC_SDK;
|
|
15
|
+
}
|
|
16
|
+
self.kf = lib(e?.data.executionContext);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (e.data?.eventParameters) {
|
|
20
|
+
let { eventParameters } = e.data;
|
|
21
|
+
if (eventParameters) {
|
|
22
|
+
self.kf.eventParameters = { ...eventParameters };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (e.data.command !== "EXECUTE") return;
|
|
27
|
+
const func = new Function(`
|
|
28
|
+
return (async () => {
|
|
29
|
+
${e.data.code}
|
|
30
|
+
})()`);
|
|
31
|
+
|
|
32
|
+
(async function () {
|
|
33
|
+
await func();
|
|
34
|
+
postMessage({
|
|
35
|
+
_id: Math.floor(Date.now() + 999).toString(36),
|
|
36
|
+
command: "RETURN",
|
|
37
|
+
data: {}
|
|
38
|
+
});
|
|
39
|
+
})();
|
|
40
|
+
};
|