@processmaker/screen-builder 3.8.6 → 3.8.8

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.
@@ -0,0 +1,62 @@
1
+ export default {
2
+ props: {
3
+ configRef: null,
4
+ loopContext: null
5
+ },
6
+ data() {
7
+ return {
8
+ };
9
+ },
10
+ methods: {
11
+ loadFormDynamicPanelProperties({ properties, element }) {
12
+ const variableName = element.config.settings.varname;
13
+ const index = element.config.settings.indexName;
14
+
15
+ // Add itemData to the properties of FormDynamicPanel
16
+ properties[':itemData'] = `${variableName} && ${variableName}[${index}]`;
17
+ this.registerVariable(element.config.settings.varname, element);
18
+ },
19
+ loadFormDynamicPanelItems({ element, node, definition }) {
20
+ const nested = {
21
+ config: [
22
+ {
23
+ items: element.items,
24
+ }
25
+ ],
26
+ watchers: [],
27
+ isMobile: false
28
+ };
29
+
30
+
31
+ const variableName = element.config.settings.varname;
32
+ const index = element.config.settings.indexName;
33
+
34
+ // Add nested component inside dynamic panel
35
+ const child = this.createComponent("ScreenRenderer", {
36
+ ":definition": this.byRef(nested),
37
+ ":value": `${variableName} && ${variableName}[${index}]`,
38
+ ":loop-context": `'${variableName} && ${variableName}[${index}]'`,
39
+ ":_parent": "getValidationData()",
40
+ ":components": this.byRef(this.components),
41
+ ":config-ref": this.byRef(this.configRef || definition.config),
42
+ "@submit": "submitForm"
43
+ });
44
+ node.appendChild(child);
45
+ }
46
+ },
47
+ mounted() {
48
+ // Convert the FormDynamicPanel to a div
49
+ this.extensions.push({
50
+ onloadproperties(params) {
51
+ if (params.element.container && params.componentName === "FormDynamicPanel") {
52
+ this.loadFormDynamicPanelProperties(params);
53
+ }
54
+ },
55
+ onloaditems(params) {
56
+ if (params.element.container && params.componentName === "FormDynamicPanel") {
57
+ this.loadFormDynamicPanelItems(params);
58
+ }
59
+ }
60
+ });
61
+ }
62
+ };
@@ -0,0 +1,66 @@
1
+ // worker.js
2
+ import { parse } from 'flatted';
3
+
4
+ self.onmessage = async function (e) {
5
+ const { fn, dataRefs } = e.data;
6
+ const { data, scope, parent } = parse(dataRefs);
7
+
8
+ try {
9
+ // Validate inputs
10
+ if (!fn || typeof fn !== 'string') {
11
+ throw new Error('Function code must be a string');
12
+ }
13
+
14
+ // Check if the code is asynchronous
15
+ const isAsync = detectAsyncCode(fn);
16
+
17
+ // If the code contains await, wrap it in an async function
18
+ const functionBody = isAsync
19
+ ? `return (async () => { ${fn} })();`
20
+ : fn;
21
+
22
+ // Use Function constructor with explicit parameter and body
23
+ // eslint-disable-next-line no-new-func
24
+ const userFunc = new Function('data', 'parent', functionBody);
25
+ const result = isAsync ? await userFunc.apply(scope, [data, parent]) : userFunc.apply(scope, [data, parent]);
26
+
27
+ self.postMessage({ result });
28
+ } catch (error) {
29
+ console.error('❌ Error executing handler:', error);
30
+
31
+ self.postMessage({
32
+ error: error.message || error.toString(),
33
+ stack: error.stack
34
+ });
35
+ }
36
+ };
37
+
38
+ function detectAsyncCode(code) {
39
+ // Remove comments and strings to avoid false positives
40
+ const cleanCode = code
41
+ .replace(/\/\*[\s\S]*?\*\//g, '') // Remove block comments
42
+ .replace(/\/\/.*$/gm, '') // Remove line comments
43
+ .replace(/"[^"]*"/g, '""') // Replace string content
44
+ .replace(/'[^']*'/g, "''") // Replace string content
45
+ .replace(/`[^`]*`/g, '``'); // Replace template literals
46
+
47
+ // Check for async patterns
48
+ const asyncPatterns = [
49
+ /\bawait\b/, // await keyword
50
+ /\bPromise\b/, // Promise constructor
51
+ /\bfetch\b/, // fetch API
52
+ /\bsetTimeout\b/, // setTimeout
53
+ /\bsetInterval\b/, // setInterval
54
+ /\brequestAnimationFrame\b/, // requestAnimationFrame
55
+ /\brequestIdleCallback\b/, // requestIdleCallback
56
+ /\bnew\s+Promise/, // new Promise
57
+ /\b\.then\s*\(/, // .then() method
58
+ /\b\.catch\s*\(/, // .catch() method
59
+ /\b\.finally\s*\(/, // .finally() method
60
+ /\bPromise\./, // Promise static methods
61
+ /\basync\b/, // async keyword (in case it's used)
62
+ ];
63
+
64
+ // Check if any async pattern is found
65
+ return asyncPatterns.some((pattern) => pattern.test(cleanCode));
66
+ }