@idooel/components 0.0.2-beta.7 → 0.0.2-beta.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.
|
@@ -1,862 +1,14 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('moment'), require('@idooel/shared'), require('vue-upload-component')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'moment', '@idooel/shared', 'vue-upload-component'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.__ele__umd__components__ = {}, global.moment, global
|
|
5
|
-
})(this, (function (exports, moment, shared, FileUpload) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@idooel/expression'), require('moment'), require('@idooel/shared'), require('vue-upload-component')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@idooel/expression', 'moment', '@idooel/shared', 'vue-upload-component'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.__ele__umd__components__ = {}, global["@idooel/expression"], global.moment, global["@idooel/shared"], global.FileUpload));
|
|
5
|
+
})(this, (function (exports, expression, moment, shared, FileUpload) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
9
|
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
10
10
|
var FileUpload__default = /*#__PURE__*/_interopDefaultLegacy(FileUpload);
|
|
11
11
|
|
|
12
|
-
var __defProp$2 = Object.defineProperty;
|
|
13
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
configurable: true,
|
|
16
|
-
writable: true,
|
|
17
|
-
value
|
|
18
|
-
}) : obj[key] = value;
|
|
19
|
-
var __publicField$2 = (obj, key, value) => {
|
|
20
|
-
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
-
return value;
|
|
22
|
-
};
|
|
23
|
-
class LexerError extends Error {
|
|
24
|
-
constructor(message, index, line, column) {
|
|
25
|
-
super(message);
|
|
26
|
-
__publicField$2(this, "index");
|
|
27
|
-
__publicField$2(this, "line");
|
|
28
|
-
__publicField$2(this, "column");
|
|
29
|
-
this.name = "LexerError";
|
|
30
|
-
this.index = index;
|
|
31
|
-
this.line = line;
|
|
32
|
-
this.column = column;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
class ParseError extends Error {
|
|
36
|
-
constructor(message, index, line, column) {
|
|
37
|
-
super(message);
|
|
38
|
-
__publicField$2(this, "index");
|
|
39
|
-
__publicField$2(this, "line");
|
|
40
|
-
__publicField$2(this, "column");
|
|
41
|
-
this.name = "ParseError";
|
|
42
|
-
this.index = index;
|
|
43
|
-
this.line = line;
|
|
44
|
-
this.column = column;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
class EvalError extends Error {
|
|
48
|
-
constructor(message) {
|
|
49
|
-
super(message);
|
|
50
|
-
this.name = "EvalError";
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
var TokenKind = /* @__PURE__ */(TokenKind2 => {
|
|
54
|
-
TokenKind2["Identifier"] = "Identifier";
|
|
55
|
-
TokenKind2["Number"] = "Number";
|
|
56
|
-
TokenKind2["String"] = "String";
|
|
57
|
-
TokenKind2["Punctuator"] = "Punctuator";
|
|
58
|
-
TokenKind2["Operator"] = "Operator";
|
|
59
|
-
TokenKind2["EOF"] = "EOF";
|
|
60
|
-
return TokenKind2;
|
|
61
|
-
})(TokenKind || {});
|
|
62
|
-
const PUNCTUATORS = /* @__PURE__ */new Set(["(", ")", "{", "}", "[", "]", ".", ",", ":", "?"]);
|
|
63
|
-
const MULTI_OPERATORS = ["?.", "??", "===", "!==", "==", "!=", "<=", ">=", "&&", "||"];
|
|
64
|
-
const SINGLE_OPERATORS = /* @__PURE__ */new Set(["+", "-", "*", "/", "%", "<", ">", "!"]);
|
|
65
|
-
function isDigit(ch) {
|
|
66
|
-
return ch >= "0" && ch <= "9";
|
|
67
|
-
}
|
|
68
|
-
function isIdentStart(ch) {
|
|
69
|
-
return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch === "_" || ch === "$";
|
|
70
|
-
}
|
|
71
|
-
function isIdentPart(ch) {
|
|
72
|
-
return isIdentStart(ch) || isDigit(ch);
|
|
73
|
-
}
|
|
74
|
-
function lex(input) {
|
|
75
|
-
if (!input && input !== "") throw new LexerError("invalid input", 0, 1, 1);
|
|
76
|
-
const tokens = [];
|
|
77
|
-
let index = 0;
|
|
78
|
-
let line = 1;
|
|
79
|
-
let column = 1;
|
|
80
|
-
function current() {
|
|
81
|
-
return input.charAt(index);
|
|
82
|
-
}
|
|
83
|
-
function advance(n = 1) {
|
|
84
|
-
for (let i = 0; i < n; i++) {
|
|
85
|
-
const ch = input.charAt(index++);
|
|
86
|
-
if (ch === "\n") {
|
|
87
|
-
line++;
|
|
88
|
-
column = 1;
|
|
89
|
-
} else {
|
|
90
|
-
column++;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function make(kind, text, value, startIndex, startLine, startColumn) {
|
|
95
|
-
return {
|
|
96
|
-
kind,
|
|
97
|
-
text,
|
|
98
|
-
value,
|
|
99
|
-
index: startIndex ?? index,
|
|
100
|
-
line: startLine ?? line,
|
|
101
|
-
column: startColumn ?? column
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
while (index < input.length) {
|
|
105
|
-
const ch = current();
|
|
106
|
-
if (ch === " " || ch === " " || ch === "\r" || ch === "\n" || ch === "\v" || ch === "\xA0") {
|
|
107
|
-
advance();
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
if (ch === "'" || ch === '"') {
|
|
111
|
-
const quote = ch;
|
|
112
|
-
const startIndex = index;
|
|
113
|
-
const startLine = line;
|
|
114
|
-
const startColumn = column;
|
|
115
|
-
advance();
|
|
116
|
-
let value = "";
|
|
117
|
-
let escaped = false;
|
|
118
|
-
while (index < input.length) {
|
|
119
|
-
const c = current();
|
|
120
|
-
if (escaped) {
|
|
121
|
-
if (c === "u") {
|
|
122
|
-
const hex = input.substring(index + 1, index + 5);
|
|
123
|
-
if (!/^[\da-f]{4}$/i.test(hex)) {
|
|
124
|
-
throw new LexerError(`invalid unicode escape \\u${hex}`, index, line, column);
|
|
125
|
-
}
|
|
126
|
-
value += String.fromCharCode(parseInt(hex, 16));
|
|
127
|
-
advance(5);
|
|
128
|
-
} else {
|
|
129
|
-
const ESCAPE = {
|
|
130
|
-
n: "\n",
|
|
131
|
-
f: "\f",
|
|
132
|
-
r: "\r",
|
|
133
|
-
t: " ",
|
|
134
|
-
v: "\v"
|
|
135
|
-
};
|
|
136
|
-
value += ESCAPE[c] ?? c;
|
|
137
|
-
advance();
|
|
138
|
-
}
|
|
139
|
-
escaped = false;
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
if (c === "\\") {
|
|
143
|
-
escaped = true;
|
|
144
|
-
advance();
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
147
|
-
if (c === quote) {
|
|
148
|
-
advance();
|
|
149
|
-
tokens.push(make("String" /* String */, input.slice(startIndex, index), value, startIndex, startLine, startColumn));
|
|
150
|
-
value = "";
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
value += c;
|
|
154
|
-
advance();
|
|
155
|
-
}
|
|
156
|
-
if (value !== "") {
|
|
157
|
-
const last = tokens[tokens.length - 1];
|
|
158
|
-
if (!last || last.index !== startIndex) {
|
|
159
|
-
throw new LexerError("unterminated string", startIndex, startLine, startColumn);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
if (isDigit(ch) || ch === "." && isDigit(input.charAt(index + 1))) {
|
|
165
|
-
const startIndex = index;
|
|
166
|
-
const startLine = line;
|
|
167
|
-
const startColumn = column;
|
|
168
|
-
let text = "";
|
|
169
|
-
while (index < input.length) {
|
|
170
|
-
let c = input.charAt(index).toLowerCase();
|
|
171
|
-
if (c === "." || isDigit(c)) {
|
|
172
|
-
text += c;
|
|
173
|
-
} else {
|
|
174
|
-
const c2 = input.charAt(index + 1);
|
|
175
|
-
if (c === "e" && (c2 === "+" || c2 === "-" || isDigit(c2))) {
|
|
176
|
-
text += c;
|
|
177
|
-
} else if ((c === "+" || c === "-") && isDigit(c2) && text.charAt(text.length - 1) === "e") {
|
|
178
|
-
text += c;
|
|
179
|
-
} else if ((c === "+" || c === "-") && (!c2 || !isDigit(c2)) && text.charAt(text.length - 1) === "e") {
|
|
180
|
-
throw new LexerError("dangling exponent", index, line, column);
|
|
181
|
-
} else {
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
advance();
|
|
186
|
-
}
|
|
187
|
-
tokens.push(make("Number" /* Number */, text, Number(text), startIndex, startLine, startColumn));
|
|
188
|
-
continue;
|
|
189
|
-
}
|
|
190
|
-
if (isIdentStart(ch)) {
|
|
191
|
-
const startIndex = index;
|
|
192
|
-
const startLine = line;
|
|
193
|
-
const startColumn = column;
|
|
194
|
-
advance();
|
|
195
|
-
while (index < input.length && isIdentPart(current())) advance();
|
|
196
|
-
const text = input.slice(startIndex, index);
|
|
197
|
-
tokens.push(make("Identifier" /* Identifier */, text, void 0, startIndex, startLine, startColumn));
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
const three = input.substring(index, index + 3);
|
|
201
|
-
const two = input.substring(index, index + 2);
|
|
202
|
-
const one = input.substring(index, index + 1);
|
|
203
|
-
const multi = MULTI_OPERATORS.find(op => input.startsWith(op, index));
|
|
204
|
-
if (multi) {
|
|
205
|
-
tokens.push(make("Operator" /* Operator */, multi, void 0, index, line, column));
|
|
206
|
-
advance(multi.length);
|
|
207
|
-
continue;
|
|
208
|
-
}
|
|
209
|
-
if (PUNCTUATORS.has(one)) {
|
|
210
|
-
tokens.push(make("Punctuator" /* Punctuator */, one, void 0, index, line, column));
|
|
211
|
-
advance();
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
if (SINGLE_OPERATORS.has(one)) {
|
|
215
|
-
tokens.push(make("Operator" /* Operator */, one, void 0, index, line, column));
|
|
216
|
-
advance();
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
throw new LexerError(`invalid token '${three || two || one}'`, index, line, column);
|
|
220
|
-
}
|
|
221
|
-
tokens.push({
|
|
222
|
-
kind: "EOF" /* EOF */,
|
|
223
|
-
text: "<eof>",
|
|
224
|
-
index,
|
|
225
|
-
line,
|
|
226
|
-
column
|
|
227
|
-
});
|
|
228
|
-
return {
|
|
229
|
-
tokens
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
var __defProp$1 = Object.defineProperty;
|
|
233
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, {
|
|
234
|
-
enumerable: true,
|
|
235
|
-
configurable: true,
|
|
236
|
-
writable: true,
|
|
237
|
-
value
|
|
238
|
-
}) : obj[key] = value;
|
|
239
|
-
var __publicField$1 = (obj, key, value) => {
|
|
240
|
-
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
241
|
-
return value;
|
|
242
|
-
};
|
|
243
|
-
class LRUCache {
|
|
244
|
-
constructor(maxSize = 100) {
|
|
245
|
-
__publicField$1(this, "cache", /* @__PURE__ */new Map());
|
|
246
|
-
__publicField$1(this, "maxSize");
|
|
247
|
-
this.maxSize = maxSize;
|
|
248
|
-
}
|
|
249
|
-
get(key) {
|
|
250
|
-
const value = this.cache.get(key);
|
|
251
|
-
if (value !== void 0) {
|
|
252
|
-
this.cache.delete(key);
|
|
253
|
-
this.cache.set(key, value);
|
|
254
|
-
}
|
|
255
|
-
return value;
|
|
256
|
-
}
|
|
257
|
-
set(key, value) {
|
|
258
|
-
if (this.cache.has(key)) {
|
|
259
|
-
this.cache.delete(key);
|
|
260
|
-
}
|
|
261
|
-
if (this.cache.size >= this.maxSize) {
|
|
262
|
-
const firstKey = this.cache.keys().next().value;
|
|
263
|
-
if (firstKey !== void 0) {
|
|
264
|
-
this.cache.delete(firstKey);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
this.cache.set(key, value);
|
|
268
|
-
}
|
|
269
|
-
clear() {
|
|
270
|
-
this.cache.clear();
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
const astCache = new LRUCache(100);
|
|
274
|
-
function parseToAst(input) {
|
|
275
|
-
const cached = astCache.get(input);
|
|
276
|
-
if (cached !== void 0) {
|
|
277
|
-
return cached;
|
|
278
|
-
}
|
|
279
|
-
const {
|
|
280
|
-
tokens
|
|
281
|
-
} = lex(input);
|
|
282
|
-
const state = new Parser(tokens, input);
|
|
283
|
-
const result = state.parse();
|
|
284
|
-
astCache.set(input, result);
|
|
285
|
-
return result;
|
|
286
|
-
}
|
|
287
|
-
class Parser {
|
|
288
|
-
constructor(tokens, input) {
|
|
289
|
-
__publicField$1(this, "tokens");
|
|
290
|
-
__publicField$1(this, "input");
|
|
291
|
-
__publicField$1(this, "i", 0);
|
|
292
|
-
this.tokens = tokens;
|
|
293
|
-
this.input = input;
|
|
294
|
-
}
|
|
295
|
-
current() {
|
|
296
|
-
return this.tokens[this.i];
|
|
297
|
-
}
|
|
298
|
-
next() {
|
|
299
|
-
return this.tokens[this.i + 1];
|
|
300
|
-
}
|
|
301
|
-
eat() {
|
|
302
|
-
return this.tokens[this.i++];
|
|
303
|
-
}
|
|
304
|
-
matchText(text) {
|
|
305
|
-
return this.current()?.text === text;
|
|
306
|
-
}
|
|
307
|
-
expectText(text) {
|
|
308
|
-
const t = this.current();
|
|
309
|
-
if (!text || t?.text === text) {
|
|
310
|
-
this.i++;
|
|
311
|
-
return t;
|
|
312
|
-
}
|
|
313
|
-
return void 0;
|
|
314
|
-
}
|
|
315
|
-
consumeText(text) {
|
|
316
|
-
const t = this.expectText(text);
|
|
317
|
-
if (!t) this.error(this.current(), `unexpected token, expect '${text ?? "<any>"}'`);
|
|
318
|
-
return t;
|
|
319
|
-
}
|
|
320
|
-
error(t, message) {
|
|
321
|
-
throw new ParseError(`${message} at ${t.line}:${t.column}`, t.index, t.line, t.column);
|
|
322
|
-
}
|
|
323
|
-
parse() {
|
|
324
|
-
const t = this.current();
|
|
325
|
-
if (t && t.kind !== TokenKind.EOF && t.text !== "}" && t.text !== ")" && t.text !== "]") {
|
|
326
|
-
const expr = this.expression();
|
|
327
|
-
return expr;
|
|
328
|
-
}
|
|
329
|
-
return void 0;
|
|
330
|
-
}
|
|
331
|
-
expression() {
|
|
332
|
-
return this.ternary();
|
|
333
|
-
}
|
|
334
|
-
ternary() {
|
|
335
|
-
const test = this.nullish();
|
|
336
|
-
if (this.expectText("?")) {
|
|
337
|
-
const consequent = this.expression();
|
|
338
|
-
this.consumeText(":");
|
|
339
|
-
const alternate = this.expression();
|
|
340
|
-
const node = {
|
|
341
|
-
type: "ConditionalExpression",
|
|
342
|
-
test,
|
|
343
|
-
consequent,
|
|
344
|
-
alternate
|
|
345
|
-
};
|
|
346
|
-
return node;
|
|
347
|
-
}
|
|
348
|
-
return test;
|
|
349
|
-
}
|
|
350
|
-
nullish() {
|
|
351
|
-
let left = this.logicalOR();
|
|
352
|
-
while (this.expectText("??")) {
|
|
353
|
-
if (isLogicalAndOr(left)) {
|
|
354
|
-
this.error(this.current(), "Cannot mix ?? with && or || without parentheses");
|
|
355
|
-
}
|
|
356
|
-
const rightStart = this.current();
|
|
357
|
-
const right = this.logicalOR();
|
|
358
|
-
if (isLogicalAndOr(right)) {
|
|
359
|
-
this.error(rightStart, "Cannot mix ?? with && or || without parentheses");
|
|
360
|
-
}
|
|
361
|
-
const node = {
|
|
362
|
-
type: "LogicalExpression",
|
|
363
|
-
operator: "??",
|
|
364
|
-
left,
|
|
365
|
-
right
|
|
366
|
-
};
|
|
367
|
-
left = node;
|
|
368
|
-
}
|
|
369
|
-
return left;
|
|
370
|
-
}
|
|
371
|
-
logicalOR() {
|
|
372
|
-
let left = this.logicalAND();
|
|
373
|
-
while (this.expectText("||")) {
|
|
374
|
-
const right = this.logicalAND();
|
|
375
|
-
const node = {
|
|
376
|
-
type: "LogicalExpression",
|
|
377
|
-
operator: "||",
|
|
378
|
-
left,
|
|
379
|
-
right
|
|
380
|
-
};
|
|
381
|
-
left = node;
|
|
382
|
-
}
|
|
383
|
-
return left;
|
|
384
|
-
}
|
|
385
|
-
logicalAND() {
|
|
386
|
-
let left = this.equality();
|
|
387
|
-
while (this.expectText("&&")) {
|
|
388
|
-
const right = this.equality();
|
|
389
|
-
const node = {
|
|
390
|
-
type: "LogicalExpression",
|
|
391
|
-
operator: "&&",
|
|
392
|
-
left,
|
|
393
|
-
right
|
|
394
|
-
};
|
|
395
|
-
left = node;
|
|
396
|
-
}
|
|
397
|
-
return left;
|
|
398
|
-
}
|
|
399
|
-
equality() {
|
|
400
|
-
let left = this.relational();
|
|
401
|
-
while (true) {
|
|
402
|
-
if (this.expectText("===")) {
|
|
403
|
-
left = this.binary(left, "===", this.relational());
|
|
404
|
-
} else if (this.expectText("!==")) {
|
|
405
|
-
left = this.binary(left, "!==", this.relational());
|
|
406
|
-
} else if (this.expectText("==")) {
|
|
407
|
-
left = this.binary(left, "==", this.relational());
|
|
408
|
-
} else if (this.expectText("!=")) {
|
|
409
|
-
left = this.binary(left, "!=", this.relational());
|
|
410
|
-
} else break;
|
|
411
|
-
}
|
|
412
|
-
return left;
|
|
413
|
-
}
|
|
414
|
-
relational() {
|
|
415
|
-
let left = this.additive();
|
|
416
|
-
while (true) {
|
|
417
|
-
if (this.expectText("<=")) {
|
|
418
|
-
left = this.binary(left, "<=", this.additive());
|
|
419
|
-
} else if (this.expectText(">=")) {
|
|
420
|
-
left = this.binary(left, ">=", this.additive());
|
|
421
|
-
} else if (this.expectText("<")) {
|
|
422
|
-
left = this.binary(left, "<", this.additive());
|
|
423
|
-
} else if (this.expectText(">")) {
|
|
424
|
-
left = this.binary(left, ">", this.additive());
|
|
425
|
-
} else break;
|
|
426
|
-
}
|
|
427
|
-
return left;
|
|
428
|
-
}
|
|
429
|
-
additive() {
|
|
430
|
-
let left = this.multiplicative();
|
|
431
|
-
while (true) {
|
|
432
|
-
if (this.expectText("+")) {
|
|
433
|
-
left = this.binary(left, "+", this.multiplicative());
|
|
434
|
-
} else if (this.expectText("-")) {
|
|
435
|
-
left = this.binary(left, "-", this.multiplicative());
|
|
436
|
-
} else break;
|
|
437
|
-
}
|
|
438
|
-
return left;
|
|
439
|
-
}
|
|
440
|
-
multiplicative() {
|
|
441
|
-
let left = this.unary();
|
|
442
|
-
while (true) {
|
|
443
|
-
if (this.expectText("*")) {
|
|
444
|
-
left = this.binary(left, "*", this.unary());
|
|
445
|
-
} else if (this.expectText("/")) {
|
|
446
|
-
left = this.binary(left, "/", this.unary());
|
|
447
|
-
} else if (this.expectText("%")) {
|
|
448
|
-
left = this.binary(left, "%", this.unary());
|
|
449
|
-
} else break;
|
|
450
|
-
}
|
|
451
|
-
return left;
|
|
452
|
-
}
|
|
453
|
-
unary() {
|
|
454
|
-
if (this.expectText("+")) {
|
|
455
|
-
return this.primary();
|
|
456
|
-
}
|
|
457
|
-
if (this.expectText("-")) {
|
|
458
|
-
const arg = this.unary();
|
|
459
|
-
const node = {
|
|
460
|
-
type: "UnaryExpression",
|
|
461
|
-
operator: "-",
|
|
462
|
-
argument: arg
|
|
463
|
-
};
|
|
464
|
-
return node;
|
|
465
|
-
}
|
|
466
|
-
if (this.expectText("!")) {
|
|
467
|
-
const arg = this.unary();
|
|
468
|
-
const node = {
|
|
469
|
-
type: "UnaryExpression",
|
|
470
|
-
operator: "!",
|
|
471
|
-
argument: arg
|
|
472
|
-
};
|
|
473
|
-
return node;
|
|
474
|
-
}
|
|
475
|
-
return this.primary();
|
|
476
|
-
}
|
|
477
|
-
primary() {
|
|
478
|
-
const t = this.current();
|
|
479
|
-
let expr;
|
|
480
|
-
if (this.expectText("(")) {
|
|
481
|
-
expr = this.expression();
|
|
482
|
-
this.consumeText(")");
|
|
483
|
-
} else if (this.expectText("[")) {
|
|
484
|
-
expr = this.array();
|
|
485
|
-
} else if (this.expectText("{")) {
|
|
486
|
-
expr = this.object();
|
|
487
|
-
} else if (t.kind === TokenKind.Identifier && (t.text === "true" || t.text === "false" || t.text === "null" || t.text === "undefined")) {
|
|
488
|
-
const tok = this.eat();
|
|
489
|
-
const map = {
|
|
490
|
-
true: true,
|
|
491
|
-
false: false,
|
|
492
|
-
null: null,
|
|
493
|
-
undefined: void 0
|
|
494
|
-
};
|
|
495
|
-
const node = {
|
|
496
|
-
type: "Literal",
|
|
497
|
-
value: map[tok.text]
|
|
498
|
-
};
|
|
499
|
-
expr = node;
|
|
500
|
-
} else if (t.kind === TokenKind.Identifier) {
|
|
501
|
-
expr = this.identifier();
|
|
502
|
-
} else if (t.kind === TokenKind.Number || t.kind === TokenKind.String) {
|
|
503
|
-
const tok = this.eat();
|
|
504
|
-
const node = {
|
|
505
|
-
type: "Literal",
|
|
506
|
-
value: tok.kind === TokenKind.Number ? Number(tok.text) : String(tok.value)
|
|
507
|
-
};
|
|
508
|
-
expr = node;
|
|
509
|
-
} else {
|
|
510
|
-
this.error(t, "unexpected token in primary");
|
|
511
|
-
}
|
|
512
|
-
while (true) {
|
|
513
|
-
if (this.expectText("(")) {
|
|
514
|
-
const args = [];
|
|
515
|
-
if (!this.matchText(")")) {
|
|
516
|
-
do {
|
|
517
|
-
args.push(this.expression());
|
|
518
|
-
} while (this.expectText(","));
|
|
519
|
-
}
|
|
520
|
-
this.consumeText(")");
|
|
521
|
-
const call = {
|
|
522
|
-
type: "CallExpression",
|
|
523
|
-
callee: expr,
|
|
524
|
-
arguments: args,
|
|
525
|
-
optional: false
|
|
526
|
-
};
|
|
527
|
-
expr = call;
|
|
528
|
-
continue;
|
|
529
|
-
}
|
|
530
|
-
if (this.expectText("?.(")) ;
|
|
531
|
-
if (this.expectText(".")) {
|
|
532
|
-
const id = this.consumeIdentifier();
|
|
533
|
-
const prop = {
|
|
534
|
-
type: "Identifier",
|
|
535
|
-
name: id
|
|
536
|
-
};
|
|
537
|
-
const mem = {
|
|
538
|
-
type: "MemberExpression",
|
|
539
|
-
object: expr,
|
|
540
|
-
property: prop,
|
|
541
|
-
computed: false,
|
|
542
|
-
optional: false
|
|
543
|
-
};
|
|
544
|
-
expr = mem;
|
|
545
|
-
continue;
|
|
546
|
-
}
|
|
547
|
-
if (this.expectText("[")) {
|
|
548
|
-
const prop = this.expression();
|
|
549
|
-
this.consumeText("]");
|
|
550
|
-
const mem = {
|
|
551
|
-
type: "MemberExpression",
|
|
552
|
-
object: expr,
|
|
553
|
-
property: prop,
|
|
554
|
-
computed: true,
|
|
555
|
-
optional: false
|
|
556
|
-
};
|
|
557
|
-
expr = mem;
|
|
558
|
-
continue;
|
|
559
|
-
}
|
|
560
|
-
if (this.matchText("?.")) {
|
|
561
|
-
this.eat();
|
|
562
|
-
if (this.expectText("(")) {
|
|
563
|
-
const args = [];
|
|
564
|
-
if (!this.matchText(")")) {
|
|
565
|
-
do {
|
|
566
|
-
args.push(this.expression());
|
|
567
|
-
} while (this.expectText(","));
|
|
568
|
-
}
|
|
569
|
-
this.consumeText(")");
|
|
570
|
-
const call = {
|
|
571
|
-
type: "CallExpression",
|
|
572
|
-
callee: expr,
|
|
573
|
-
arguments: args,
|
|
574
|
-
optional: true
|
|
575
|
-
};
|
|
576
|
-
expr = call;
|
|
577
|
-
continue;
|
|
578
|
-
}
|
|
579
|
-
if (this.expectText("[")) {
|
|
580
|
-
const prop2 = this.expression();
|
|
581
|
-
this.consumeText("]");
|
|
582
|
-
const mem2 = {
|
|
583
|
-
type: "MemberExpression",
|
|
584
|
-
object: expr,
|
|
585
|
-
property: prop2,
|
|
586
|
-
computed: true,
|
|
587
|
-
optional: true
|
|
588
|
-
};
|
|
589
|
-
expr = mem2;
|
|
590
|
-
continue;
|
|
591
|
-
}
|
|
592
|
-
const id = this.consumeIdentifier();
|
|
593
|
-
const prop = {
|
|
594
|
-
type: "Identifier",
|
|
595
|
-
name: id
|
|
596
|
-
};
|
|
597
|
-
const mem = {
|
|
598
|
-
type: "MemberExpression",
|
|
599
|
-
object: expr,
|
|
600
|
-
property: prop,
|
|
601
|
-
computed: false,
|
|
602
|
-
optional: true
|
|
603
|
-
};
|
|
604
|
-
expr = mem;
|
|
605
|
-
continue;
|
|
606
|
-
}
|
|
607
|
-
break;
|
|
608
|
-
}
|
|
609
|
-
return expr;
|
|
610
|
-
}
|
|
611
|
-
identifier() {
|
|
612
|
-
const name = this.consumeIdentifier();
|
|
613
|
-
const node = {
|
|
614
|
-
type: "Identifier",
|
|
615
|
-
name
|
|
616
|
-
};
|
|
617
|
-
return node;
|
|
618
|
-
}
|
|
619
|
-
consumeIdentifier() {
|
|
620
|
-
const t = this.current();
|
|
621
|
-
if (t.kind !== TokenKind.Identifier) this.error(t, "identifier expected");
|
|
622
|
-
this.eat();
|
|
623
|
-
return t.text;
|
|
624
|
-
}
|
|
625
|
-
array() {
|
|
626
|
-
const elements = [];
|
|
627
|
-
if (!this.matchText("]")) {
|
|
628
|
-
do {
|
|
629
|
-
if (this.matchText("]")) break;
|
|
630
|
-
elements.push(this.expression());
|
|
631
|
-
} while (this.expectText(","));
|
|
632
|
-
}
|
|
633
|
-
this.consumeText("]");
|
|
634
|
-
return {
|
|
635
|
-
type: "ArrayExpression",
|
|
636
|
-
elements
|
|
637
|
-
};
|
|
638
|
-
}
|
|
639
|
-
object() {
|
|
640
|
-
const properties = [];
|
|
641
|
-
if (!this.matchText("}")) {
|
|
642
|
-
do {
|
|
643
|
-
if (this.matchText("}")) break;
|
|
644
|
-
const keyTok = this.eat();
|
|
645
|
-
let key;
|
|
646
|
-
if (keyTok.kind === TokenKind.String) key = String(keyTok.value);else if (keyTok.kind === TokenKind.Identifier) key = keyTok.text;else this.error(keyTok, "invalid object key");
|
|
647
|
-
this.consumeText(":");
|
|
648
|
-
const value = this.expression();
|
|
649
|
-
properties.push({
|
|
650
|
-
key,
|
|
651
|
-
value
|
|
652
|
-
});
|
|
653
|
-
} while (this.expectText(","));
|
|
654
|
-
}
|
|
655
|
-
this.consumeText("}");
|
|
656
|
-
return {
|
|
657
|
-
type: "ObjectExpression",
|
|
658
|
-
properties
|
|
659
|
-
};
|
|
660
|
-
}
|
|
661
|
-
binary(left, op, right) {
|
|
662
|
-
return {
|
|
663
|
-
type: "BinaryExpression",
|
|
664
|
-
operator: op,
|
|
665
|
-
left,
|
|
666
|
-
right
|
|
667
|
-
};
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
function isLogicalAndOr(node) {
|
|
671
|
-
return node.type === "LogicalExpression" && (node.operator === "&&" || node.operator === "||");
|
|
672
|
-
}
|
|
673
|
-
const DENY_KEYS = /* @__PURE__ */new Set(["__proto__", "prototype", "constructor"]);
|
|
674
|
-
let evalOptions = {};
|
|
675
|
-
let currentDepth = 0;
|
|
676
|
-
function evaluate(ast, scope, options) {
|
|
677
|
-
if (!ast) return void 0;
|
|
678
|
-
evalOptions = options || {};
|
|
679
|
-
currentDepth = 0;
|
|
680
|
-
return exec(ast, scope);
|
|
681
|
-
}
|
|
682
|
-
function exec(node, scope) {
|
|
683
|
-
const maxDepth = evalOptions.maxDepth || 100;
|
|
684
|
-
if (++currentDepth > maxDepth) {
|
|
685
|
-
currentDepth--;
|
|
686
|
-
if (evalOptions.strict) {
|
|
687
|
-
throw new EvalError(`Maximum recursion depth (${maxDepth}) exceeded`);
|
|
688
|
-
}
|
|
689
|
-
return void 0;
|
|
690
|
-
}
|
|
691
|
-
try {
|
|
692
|
-
switch (node.type) {
|
|
693
|
-
case "Literal":
|
|
694
|
-
return node.value;
|
|
695
|
-
case "Identifier":
|
|
696
|
-
return readIdentifier(node, scope);
|
|
697
|
-
case "MemberExpression":
|
|
698
|
-
return readMember(node, scope);
|
|
699
|
-
case "CallExpression":
|
|
700
|
-
return callExpression(node, scope);
|
|
701
|
-
case "UnaryExpression":
|
|
702
|
-
return unaryExpression(node, scope);
|
|
703
|
-
case "BinaryExpression":
|
|
704
|
-
return binaryExpression(node, scope);
|
|
705
|
-
case "LogicalExpression":
|
|
706
|
-
return logicalExpression(node, scope);
|
|
707
|
-
case "ConditionalExpression":
|
|
708
|
-
return conditionalExpression(node, scope);
|
|
709
|
-
case "ArrayExpression":
|
|
710
|
-
return arrayExpression(node, scope);
|
|
711
|
-
case "ObjectExpression":
|
|
712
|
-
return objectExpression(node, scope);
|
|
713
|
-
default:
|
|
714
|
-
return void 0;
|
|
715
|
-
}
|
|
716
|
-
} finally {
|
|
717
|
-
currentDepth--;
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
function readIdentifier(node, scope) {
|
|
721
|
-
if (!scope) return void 0;
|
|
722
|
-
return scope[node.name];
|
|
723
|
-
}
|
|
724
|
-
function readMember(node, scope) {
|
|
725
|
-
const object = exec(node.object, scope);
|
|
726
|
-
if (object == null) {
|
|
727
|
-
return void 0;
|
|
728
|
-
}
|
|
729
|
-
const key = node.computed ? String(exec(node.property, scope)) : node.property.name;
|
|
730
|
-
if (DENY_KEYS.has(key)) {
|
|
731
|
-
if (evalOptions.strict) {
|
|
732
|
-
throw new EvalError(`Access to property "${key}" is not allowed`);
|
|
733
|
-
}
|
|
734
|
-
return void 0;
|
|
735
|
-
}
|
|
736
|
-
try {
|
|
737
|
-
return object[key];
|
|
738
|
-
} catch (err) {
|
|
739
|
-
if (evalOptions.strict) {
|
|
740
|
-
throw new EvalError(`Failed to access property "${key}": ${err}`);
|
|
741
|
-
}
|
|
742
|
-
return void 0;
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
function callExpression(node, scope) {
|
|
746
|
-
let fn;
|
|
747
|
-
let thisArg = void 0;
|
|
748
|
-
const calleeNode = node.callee;
|
|
749
|
-
if (calleeNode.type === "MemberExpression") {
|
|
750
|
-
const mem = calleeNode;
|
|
751
|
-
thisArg = exec(mem.object, scope);
|
|
752
|
-
if (thisArg == null) return void 0;
|
|
753
|
-
const key = mem.computed ? String(exec(mem.property, scope)) : mem.property.name;
|
|
754
|
-
if (DENY_KEYS.has(key)) {
|
|
755
|
-
if (evalOptions.strict) {
|
|
756
|
-
throw new EvalError(`Call to method "${key}" is not allowed`);
|
|
757
|
-
}
|
|
758
|
-
return void 0;
|
|
759
|
-
}
|
|
760
|
-
fn = thisArg[key];
|
|
761
|
-
} else {
|
|
762
|
-
fn = exec(node.callee, scope);
|
|
763
|
-
}
|
|
764
|
-
if (fn == null) return void 0;
|
|
765
|
-
if (typeof fn !== "function") {
|
|
766
|
-
if (evalOptions.strict) {
|
|
767
|
-
throw new EvalError(`Cannot call non-function value`);
|
|
768
|
-
}
|
|
769
|
-
return void 0;
|
|
770
|
-
}
|
|
771
|
-
const args = node.arguments.map(a => exec(a, scope));
|
|
772
|
-
try {
|
|
773
|
-
return fn.apply(thisArg, args);
|
|
774
|
-
} catch (err) {
|
|
775
|
-
if (evalOptions.strict) {
|
|
776
|
-
throw new EvalError(`Function call failed: ${err}`);
|
|
777
|
-
}
|
|
778
|
-
return void 0;
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
function unaryExpression(node, scope) {
|
|
782
|
-
const v = exec(node.argument, scope);
|
|
783
|
-
switch (node.operator) {
|
|
784
|
-
case "-":
|
|
785
|
-
return 0 - Number(v);
|
|
786
|
-
case "!":
|
|
787
|
-
return !v;
|
|
788
|
-
case "+":
|
|
789
|
-
return v;
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
function binaryExpression(node, scope) {
|
|
793
|
-
const a = exec(node.left, scope);
|
|
794
|
-
const b = exec(node.right, scope);
|
|
795
|
-
switch (node.operator) {
|
|
796
|
-
case "+":
|
|
797
|
-
return a + b;
|
|
798
|
-
case "-":
|
|
799
|
-
return a - b;
|
|
800
|
-
case "*":
|
|
801
|
-
return a * b;
|
|
802
|
-
case "/":
|
|
803
|
-
return a / b;
|
|
804
|
-
case "%":
|
|
805
|
-
return a % b;
|
|
806
|
-
case "==":
|
|
807
|
-
return a == b;
|
|
808
|
-
case "!=":
|
|
809
|
-
return a != b;
|
|
810
|
-
case "===":
|
|
811
|
-
return a === b;
|
|
812
|
-
case "!==":
|
|
813
|
-
return a !== b;
|
|
814
|
-
case "<":
|
|
815
|
-
return a < b;
|
|
816
|
-
case ">":
|
|
817
|
-
return a > b;
|
|
818
|
-
case "<=":
|
|
819
|
-
return a <= b;
|
|
820
|
-
case ">=":
|
|
821
|
-
return a >= b;
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
function logicalExpression(node, scope) {
|
|
825
|
-
if (node.operator === "&&") {
|
|
826
|
-
const left2 = exec(node.left, scope);
|
|
827
|
-
return left2 ? exec(node.right, scope) : left2;
|
|
828
|
-
}
|
|
829
|
-
if (node.operator === "||") {
|
|
830
|
-
const left2 = exec(node.left, scope);
|
|
831
|
-
return left2 ? left2 : exec(node.right, scope);
|
|
832
|
-
}
|
|
833
|
-
const left = exec(node.left, scope);
|
|
834
|
-
return left ?? exec(node.right, scope);
|
|
835
|
-
}
|
|
836
|
-
function conditionalExpression(node, scope) {
|
|
837
|
-
const test = exec(node.test, scope);
|
|
838
|
-
return test ? exec(node.consequent, scope) : exec(node.alternate, scope);
|
|
839
|
-
}
|
|
840
|
-
function arrayExpression(node, scope) {
|
|
841
|
-
return node.elements.map(e => exec(e, scope));
|
|
842
|
-
}
|
|
843
|
-
function objectExpression(node, scope) {
|
|
844
|
-
const out = {};
|
|
845
|
-
for (const p of node.properties) {
|
|
846
|
-
if (DENY_KEYS.has(p.key)) continue;
|
|
847
|
-
out[p.key] = exec(p.value, scope);
|
|
848
|
-
}
|
|
849
|
-
return out;
|
|
850
|
-
}
|
|
851
|
-
function compile(expression, options) {
|
|
852
|
-
if (!expression) throw new Error("expression is required");
|
|
853
|
-
const ast = parseToAst(expression);
|
|
854
|
-
return scope => evaluate(ast, scope, options);
|
|
855
|
-
}
|
|
856
|
-
function parse$1(expression, scope = {}, options) {
|
|
857
|
-
return compile(expression, options)(scope);
|
|
858
|
-
}
|
|
859
|
-
|
|
860
12
|
const CONTEXT = '__idooel__ele__context__';
|
|
861
13
|
const AREA_NAMES = {
|
|
862
14
|
BUTTON_GROUP: 'BUTTON_GROUP'
|
|
@@ -908,7 +60,7 @@
|
|
|
908
60
|
const parseFieldMap = (fieldMap = {}, dataSource = {}) => {
|
|
909
61
|
let ret = {};
|
|
910
62
|
Object.keys(fieldMap).forEach(key => {
|
|
911
|
-
ret[fieldMap[key]] = parse
|
|
63
|
+
ret[fieldMap[key]] = expression.parse(key, dataSource);
|
|
912
64
|
});
|
|
913
65
|
return ret;
|
|
914
66
|
};
|
|
@@ -1920,7 +1072,7 @@
|
|
|
1920
1072
|
} else if (shared.type.isBool(show)) {
|
|
1921
1073
|
if (show) return item;
|
|
1922
1074
|
} else if (shared.type.isStr(show)) {
|
|
1923
|
-
const parseRet = parse
|
|
1075
|
+
const parseRet = expression.parse(show, {
|
|
1924
1076
|
...this.record,
|
|
1925
1077
|
_route: shared.route.searchToQueryParams(window.location.search)
|
|
1926
1078
|
});
|
|
@@ -4178,10 +3330,10 @@
|
|
|
4178
3330
|
formModels(fieldNames) {
|
|
4179
3331
|
return this.$refs[this.formRef] ? this.$refs[this.formRef].getFieldsValue(fieldNames) : {};
|
|
4180
3332
|
},
|
|
4181
|
-
executeExpression(expression, dataSource = {}) {
|
|
4182
|
-
if (shared.type.isBool(expression)) return expression;
|
|
4183
|
-
if (shared.type.isEmpty(expression)) return false;
|
|
4184
|
-
return parse$1
|
|
3333
|
+
executeExpression(expression$1, dataSource = {}) {
|
|
3334
|
+
if (shared.type.isBool(expression$1)) return expression$1;
|
|
3335
|
+
if (shared.type.isEmpty(expression$1)) return false;
|
|
3336
|
+
return expression.parse(expression$1, {
|
|
4185
3337
|
...this.expressionData,
|
|
4186
3338
|
...this.formModels(),
|
|
4187
3339
|
...dataSource
|
|
@@ -4525,10 +3677,10 @@
|
|
|
4525
3677
|
this.evalShowExpressionForFooterElements();
|
|
4526
3678
|
},
|
|
4527
3679
|
methods: {
|
|
4528
|
-
executeExpression(expression) {
|
|
4529
|
-
if (shared.type.isBool(expression)) return expression;
|
|
4530
|
-
if (shared.type.isEmpty(expression)) return false;
|
|
4531
|
-
return parse$1
|
|
3680
|
+
executeExpression(expression$1) {
|
|
3681
|
+
if (shared.type.isBool(expression$1)) return expression$1;
|
|
3682
|
+
if (shared.type.isEmpty(expression$1)) return false;
|
|
3683
|
+
return expression.parse(expression$1, {
|
|
4532
3684
|
...this.expressionData
|
|
4533
3685
|
});
|
|
4534
3686
|
},
|
|
@@ -4911,10 +4063,10 @@
|
|
|
4911
4063
|
this.$set(ele, '_show', ret);
|
|
4912
4064
|
});
|
|
4913
4065
|
},
|
|
4914
|
-
executeExpression(expression) {
|
|
4915
|
-
if (shared.type.isBool(expression)) return expression;
|
|
4916
|
-
if (shared.type.isEmpty(expression)) return false;
|
|
4917
|
-
return parse$1
|
|
4066
|
+
executeExpression(expression$1) {
|
|
4067
|
+
if (shared.type.isBool(expression$1)) return expression$1;
|
|
4068
|
+
if (shared.type.isEmpty(expression$1)) return false;
|
|
4069
|
+
return expression.parse(expression$1, {
|
|
4918
4070
|
...this.getFieldsValue(),
|
|
4919
4071
|
...this.formModel,
|
|
4920
4072
|
_route: this.$route.query,
|
|
@@ -12745,7 +11897,7 @@
|
|
|
12745
11897
|
buildDefaultValue(arg) {
|
|
12746
11898
|
if (shared.type.notStr(arg)) return arg;
|
|
12747
11899
|
if (!arg || arg.charAt(0) !== '_') return arg;
|
|
12748
|
-
return parse
|
|
11900
|
+
return expression.parse(arg, {
|
|
12749
11901
|
_route: this.$route.query
|
|
12750
11902
|
});
|
|
12751
11903
|
},
|
|
@@ -13205,10 +12357,10 @@
|
|
|
13205
12357
|
} = modalConfirm;
|
|
13206
12358
|
return !this.executeExpression(show);
|
|
13207
12359
|
},
|
|
13208
|
-
executeExpression(expression) {
|
|
13209
|
-
if (shared.type.isBool(expression)) return expression;
|
|
13210
|
-
if (shared.type.isEmpty(expression)) return true;
|
|
13211
|
-
return parse$1
|
|
12360
|
+
executeExpression(expression$1) {
|
|
12361
|
+
if (shared.type.isBool(expression$1)) return expression$1;
|
|
12362
|
+
if (shared.type.isEmpty(expression$1)) return true;
|
|
12363
|
+
return expression.parse(expression$1, {
|
|
13212
12364
|
...this.currentContext,
|
|
13213
12365
|
...this.contextData
|
|
13214
12366
|
});
|
|
@@ -13509,10 +12661,10 @@
|
|
|
13509
12661
|
});
|
|
13510
12662
|
return ret;
|
|
13511
12663
|
},
|
|
13512
|
-
executeExpression(expression, dataSource = {}) {
|
|
13513
|
-
if (shared.type.isBool(expression)) return expression;
|
|
13514
|
-
if (shared.type.isEmpty(expression)) return false;
|
|
13515
|
-
return parse$1
|
|
12664
|
+
executeExpression(expression$1, dataSource = {}) {
|
|
12665
|
+
if (shared.type.isBool(expression$1)) return expression$1;
|
|
12666
|
+
if (shared.type.isEmpty(expression$1)) return false;
|
|
12667
|
+
return expression.parse(expression$1, {
|
|
13516
12668
|
...this.expressionData,
|
|
13517
12669
|
...this.formModels(),
|
|
13518
12670
|
...dataSource
|