@gct-paas/render 0.1.4-dev.11 → 0.1.4-dev.13
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/index.esm.min.js +6189 -0
- package/dist/index.min.css +2 -0
- package/es/Event/Dependency/controller.mjs +81 -94
- package/es/Event/Dependency/displayRule.mjs +65 -67
- package/es/Event/Dependency/useDependency.mjs +117 -0
- package/es/Event/Dependency/useDependencyToShow.mjs +100 -96
- package/es/Event/baseEvent.d.ts +8 -7
- package/es/Event/baseEvent.mjs +382 -423
- package/es/Event/bizServiceRequest.mjs +28 -40
- package/es/Event/eventType.d.ts +1 -1
- package/es/Event/eventType.mjs +1 -0
- package/es/Event/index.d.ts +4 -3
- package/es/Event/index.mjs +5 -0
- package/es/Event/utils/appRedis.mjs +39 -49
- package/es/Event/utils/globalLoading.mjs +95 -94
- package/es/Event/utils/processRovedInfo.mjs +228 -294
- package/es/Event/utils/runGlobalByPage.mjs +297 -301
- package/es/Event/utils/verificationVar.mjs +32 -38
- package/es/_virtual/_plugin-vue_export-helper.mjs +8 -0
- package/es/_virtual/_rolldown/runtime.mjs +13 -0
- package/es/components/HandwritingPad.vue.d.ts +27 -0
- package/es/components/HandwritingPad.vue.mjs +7 -0
- package/es/components/HandwritingPad.vue_vue_type_script_setup_true_name_HandwritingPad_lang.mjs +109 -0
- package/es/components/HandwritingPad.vue_vue_type_style_index_0_scoped_d5b980b7_lang.css +9 -0
- package/es/components/index.d.ts +2 -0
- package/es/components/index.mjs +1 -0
- package/es/enums/index.mjs +17 -5
- package/es/hooks/useStorageRef.mjs +35 -31
- package/es/index.d.ts +1 -0
- package/es/index.mjs +20 -21
- package/es/register/render-register/render-register.mjs +63 -58
- package/es/utils/cacheAdapter.mjs +62 -54
- package/es/utils/expression/index.mjs +105 -122
- package/es/utils/expression/regularExpression/methods.mjs +426 -567
- package/es/utils/field-attrs/basicAttrs.mjs +56 -80
- package/es/utils/field-attrs/index.mjs +16 -13
- package/es/utils/get-ref-data.mjs +41 -59
- package/es/utils/getFieldSchema.mjs +66 -80
- package/es/utils/index.d.ts +2 -2
- package/es/utils/index.mjs +6 -0
- package/es/utils/model-transformer.mjs +74 -64
- package/es/utils/useStyle.mjs +20 -16
- package/package.json +10 -10
- package/dist/index.esm.min.mjs +0 -7042
- package/dist/index.min.cjs +0 -17
- package/dist/index.system.min.js +0 -17
|
@@ -1,133 +1,116 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { useMemoize } from
|
|
6
|
-
|
|
7
|
-
window._METHOD_DEBUG_ =
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { methods_exports } from "./regularExpression/methods.mjs";
|
|
2
|
+
import { SYSTEM_VAR_PREFIX, functionMap, innerVarIds, operator2FuncMap } from "@gct-paas/core";
|
|
3
|
+
import * as esprima from "esprima-next";
|
|
4
|
+
import estraverse from "estraverse";
|
|
5
|
+
import { useMemoize } from "@vueuse/core";
|
|
6
|
+
//#region src/utils/expression/index.ts
|
|
7
|
+
window._METHOD_DEBUG_ = methods_exports;
|
|
8
|
+
var identify = useMemoize(_identify);
|
|
9
|
+
var calculate = useMemoize(_calc);
|
|
10
10
|
function _deepCalcName(node) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return node.name;
|
|
15
|
-
}
|
|
16
|
-
return "";
|
|
11
|
+
if (node.type === esprima.Syntax.MemberExpression) return `${node.object.type === esprima.Syntax.MemberExpression ? _deepCalcName(node.object) : node.object.name}.${node.property.name}`;
|
|
12
|
+
else if (node.type === esprima.Syntax.Identifier) return node.name;
|
|
13
|
+
return "";
|
|
17
14
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
var AsyncFunction = Object.getPrototypeOf(async function() {}).constructor;
|
|
16
|
+
/**
|
|
17
|
+
* 获取系统变量值
|
|
18
|
+
* @param ids 系统变量标识
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
21
|
async function _getSystemVarValue(ids) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
keys: ids.join(",")
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
return res;
|
|
22
|
+
let res = [];
|
|
23
|
+
if (ids.length > 0) res = await _gct.api.apaas.systemVar.getGetVarByKeys({ keys: ids.join(",") });
|
|
24
|
+
return res;
|
|
29
25
|
}
|
|
30
|
-
|
|
26
|
+
var getSystemVarValue = useMemoize(_getSystemVarValue);
|
|
27
|
+
/**
|
|
28
|
+
* 表达式计算
|
|
29
|
+
* @param expr
|
|
30
|
+
* @param values
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
31
33
|
async function _calc(expr, values) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
...defs,
|
|
87
|
-
`return new Promise(async(resolve)=>{`,
|
|
88
|
-
`const res = ${runjs};`,
|
|
89
|
-
"resolve(res);",
|
|
90
|
-
"})"
|
|
91
|
-
].join("\n")
|
|
92
|
-
);
|
|
93
|
-
const result = await calcFunc(methods);
|
|
94
|
-
console.info("【表达式】", expr);
|
|
95
|
-
console.info("【参数】", values);
|
|
96
|
-
console.info("【执行语句】", calcFunc.toString());
|
|
97
|
-
console.info("【执行结果】", result);
|
|
98
|
-
return result;
|
|
34
|
+
const ids = identify(expr, true);
|
|
35
|
+
const innerIds = ids.filter((id) => innerVarIds.includes(id)).sort();
|
|
36
|
+
const systemIds = ids.filter((id) => id.startsWith(SYSTEM_VAR_PREFIX)).sort();
|
|
37
|
+
const systemValues = await getSystemVarValue([...innerIds, ...systemIds]);
|
|
38
|
+
const ast = esprima.parse(expr);
|
|
39
|
+
estraverse.replace(ast, { enter(node) {
|
|
40
|
+
if (node.type === esprima.Syntax.BinaryExpression) {
|
|
41
|
+
const { operator } = node;
|
|
42
|
+
const fnName = operator2FuncMap[operator];
|
|
43
|
+
if (!fnName) return node;
|
|
44
|
+
return {
|
|
45
|
+
type: esprima.Syntax.CallExpression,
|
|
46
|
+
arguments: [node.left, node.right],
|
|
47
|
+
callee: {
|
|
48
|
+
type: esprima.Syntax.Identifier,
|
|
49
|
+
name: fnName
|
|
50
|
+
},
|
|
51
|
+
optional: false
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return node;
|
|
55
|
+
} });
|
|
56
|
+
estraverse.traverse(ast, { enter: function(node) {
|
|
57
|
+
if (node.type === esprima.Syntax.CallExpression && node.callee.type === esprima.Syntax.Identifier) node.callee.name = `await Methods.${node.callee.name}`;
|
|
58
|
+
} });
|
|
59
|
+
const runjs = "";
|
|
60
|
+
const objNames = {};
|
|
61
|
+
const defs = [];
|
|
62
|
+
systemValues.forEach((item) => {
|
|
63
|
+
defs.push(`const ${item.key} = ${JSON.stringify(item.value)};`);
|
|
64
|
+
});
|
|
65
|
+
Object.keys(values).map((key) => {
|
|
66
|
+
if (key.includes(".")) {
|
|
67
|
+
const [obj = "", property] = key.split(".");
|
|
68
|
+
if (!objNames[obj]) {
|
|
69
|
+
defs.push(`const ${obj} = {};`);
|
|
70
|
+
objNames[obj] = true;
|
|
71
|
+
}
|
|
72
|
+
defs.push(`${obj}.${property} = ${JSON.stringify(values[key])};`);
|
|
73
|
+
} else defs.push(`const ${key} = ${JSON.stringify(values[key])};`);
|
|
74
|
+
});
|
|
75
|
+
const calcFunc = new AsyncFunction("Methods", [
|
|
76
|
+
...defs,
|
|
77
|
+
`return new Promise(async(resolve)=>{`,
|
|
78
|
+
`const res = ${runjs};`,
|
|
79
|
+
"resolve(res);",
|
|
80
|
+
"})"
|
|
81
|
+
].join("\n"));
|
|
82
|
+
const result = await calcFunc(methods_exports);
|
|
83
|
+
console.info("【表达式】", expr);
|
|
84
|
+
console.info("【参数】", values);
|
|
85
|
+
console.info("【执行语句】", calcFunc.toString());
|
|
86
|
+
console.info("【执行结果】", result);
|
|
87
|
+
return result;
|
|
99
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* 变量识别
|
|
91
|
+
* @param expr
|
|
92
|
+
* @returns
|
|
93
|
+
*/
|
|
100
94
|
function _identify(expr, isAll = false) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
identifiers = identifiers.filter(
|
|
117
|
-
(item) => !functionMap[item] && item !== "undefined"
|
|
118
|
-
);
|
|
119
|
-
} else {
|
|
120
|
-
identifiers = identifiers.filter(
|
|
121
|
-
(item) => !functionMap[item] && item !== "undefined" && !innerVarIds.includes(item) && !item.startsWith(SYSTEM_VAR_PREFIX) && !item.startsWith("undefined.")
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
return [...new Set(identifiers)];
|
|
95
|
+
const ast = esprima.parse(expr);
|
|
96
|
+
let identifiers = [];
|
|
97
|
+
estraverse.traverse(ast, { enter: function(node) {
|
|
98
|
+
if (node.type === esprima.Syntax.MemberExpression) {
|
|
99
|
+
const name = _deepCalcName(node);
|
|
100
|
+
identifiers.push(name);
|
|
101
|
+
Object.assign(node, {
|
|
102
|
+
name,
|
|
103
|
+
type: esprima.Syntax.Identifier
|
|
104
|
+
});
|
|
105
|
+
} else if (node.type === esprima.Syntax.Identifier) identifiers.push(node.name);
|
|
106
|
+
if (isAll) identifiers = identifiers.filter((item) => !functionMap[item] && item !== "undefined");
|
|
107
|
+
else identifiers = identifiers.filter((item) => !functionMap[item] && item !== "undefined" && !innerVarIds.includes(item) && !item.startsWith(SYSTEM_VAR_PREFIX) && !item.startsWith("undefined."));
|
|
108
|
+
} });
|
|
109
|
+
return [...new Set(identifiers)];
|
|
127
110
|
}
|
|
128
111
|
window.gct_expression = {
|
|
129
|
-
|
|
130
|
-
|
|
112
|
+
execute: calculate,
|
|
113
|
+
identify
|
|
131
114
|
};
|
|
132
|
-
|
|
115
|
+
//#endregion
|
|
133
116
|
export { calculate, identify };
|