@duxweb/dvha-core 0.1.20 → 0.1.22
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/cjs/components/auth/can.cjs +1 -1
- package/dist/cjs/components/loader/iframe.cjs +1 -1
- package/dist/cjs/components/loader/loader.cjs +1 -0
- package/dist/cjs/components/loader/remote/loader.cjs +1 -0
- package/dist/cjs/components/loader/remote/render.cjs +1 -0
- package/dist/cjs/components/overlay/overlay.cjs +1 -1
- package/dist/cjs/components/status/error.cjs +1 -1
- package/dist/cjs/components/status/exception.cjs +1 -0
- package/dist/cjs/components/status/notAuthorized.cjs +1 -1
- package/dist/cjs/components/status/notFound.cjs +1 -1
- package/dist/cjs/directive/permission.cjs +1 -1
- package/dist/cjs/hooks/auth.cjs +1 -1
- package/dist/cjs/hooks/data.cjs +1 -1
- package/dist/cjs/hooks/export.cjs +1 -1
- package/dist/cjs/hooks/form.cjs +1 -1
- package/dist/cjs/hooks/formExtend.cjs +1 -0
- package/dist/cjs/hooks/formValidate.cjs +1 -0
- package/dist/cjs/hooks/i18n.cjs +1 -1
- package/dist/cjs/hooks/importCsv.cjs +1 -1
- package/dist/cjs/hooks/json/utils/expressionParser.cjs +1 -1
- package/dist/cjs/hooks/json.cjs +1 -1
- package/dist/cjs/hooks/list.cjs +1 -0
- package/dist/cjs/hooks/manage.cjs +1 -1
- package/dist/cjs/hooks/menu.cjs +1 -1
- package/dist/cjs/hooks/overlay.cjs +1 -1
- package/dist/cjs/hooks/select.cjs +1 -1
- package/dist/cjs/hooks/theme.cjs +2 -2
- package/dist/cjs/hooks/upload.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/main.cjs +1 -1
- package/dist/cjs/preset/dataProvider.cjs +1 -1
- package/dist/cjs/preset/i18nProvider.cjs +1 -1
- package/dist/cjs/provider/app.cjs +1 -1
- package/dist/cjs/provider/tab.cjs +1 -1
- package/dist/cjs/stores/manage.cjs +1 -1
- package/dist/cjs/stores/tab.cjs +1 -1
- package/dist/cjs/stores/theme.cjs +1 -1
- package/dist/cjs/utils/theme.cjs +9 -1
- package/dist/esm/components/auth/can.js +9 -7
- package/dist/esm/components/loader/loader.js +48 -0
- package/dist/esm/components/loader/remote/loader.js +150 -0
- package/dist/esm/components/loader/remote/render.js +19 -0
- package/dist/esm/components/overlay/overlay.js +22 -31
- package/dist/esm/components/status/error.js +3 -3
- package/dist/esm/components/status/exception.js +23 -0
- package/dist/esm/components/status/notAuthorized.js +2 -2
- package/dist/esm/components/status/notFound.js +4 -4
- package/dist/esm/directive/permission.js +5 -3
- package/dist/esm/hooks/auth.js +67 -67
- package/dist/esm/hooks/data.js +164 -160
- package/dist/esm/hooks/export.js +26 -23
- package/dist/esm/hooks/form.js +38 -35
- package/dist/esm/hooks/formExtend.js +38 -0
- package/dist/esm/hooks/formValidate.js +28 -0
- package/dist/esm/hooks/i18n.js +16 -8
- package/dist/esm/hooks/json/utils/expressionParser.js +1 -1
- package/dist/esm/hooks/json.js +57 -57
- package/dist/esm/hooks/list.js +179 -0
- package/dist/esm/hooks/manage.js +18 -13
- package/dist/esm/hooks/overlay.js +6 -4
- package/dist/esm/hooks/theme.js +11 -11
- package/dist/esm/index.js +129 -113
- package/dist/esm/main.js +22 -12
- package/dist/esm/preset/i18nProvider.js +17 -18
- package/dist/esm/provider/app.js +61 -53
- package/dist/esm/provider/tab.js +1 -1
- package/dist/esm/stores/manage.js +34 -24
- package/dist/esm/stores/tab.js +58 -49
- package/dist/esm/stores/theme.js +36 -34
- package/dist/esm/utils/theme.js +89 -76
- package/dist/types/components/index.d.ts +2 -1
- package/dist/types/components/loader/loader.d.ts +2 -0
- package/dist/types/components/loader/remote/index.d.ts +2 -0
- package/dist/types/components/loader/remote/loader.d.ts +1 -0
- package/dist/types/components/loader/remote/render.d.ts +1 -0
- package/dist/types/components/status/error.d.ts +1 -2
- package/dist/types/components/status/exception.d.ts +3 -0
- package/dist/types/components/status/index.d.ts +4 -0
- package/dist/types/components/status/notAuthorized.d.ts +1 -2
- package/dist/types/components/status/notFound.d.ts +1 -2
- package/dist/types/config/index.d.ts +1 -0
- package/dist/types/hooks/auth.d.ts +6 -6
- package/dist/types/hooks/data.d.ts +216 -216
- package/dist/types/hooks/form.d.ts +6 -3
- package/dist/types/hooks/formExtend.d.ts +12 -0
- package/dist/types/hooks/formValidate.d.ts +14 -0
- package/dist/types/hooks/i18n.d.ts +2 -0
- package/dist/types/hooks/import.d.ts +1 -2
- package/dist/types/hooks/index.d.ts +4 -1
- package/dist/types/hooks/json.d.ts +1 -1
- package/dist/types/hooks/list.d.ts +66 -0
- package/dist/types/hooks/manage.d.ts +1 -0
- package/dist/types/hooks/menu.d.ts +1 -1
- package/dist/types/hooks/overlay.d.ts +1 -1
- package/dist/types/hooks/theme.d.ts +8 -8
- package/dist/types/index.d.ts +6 -5
- package/dist/types/preset/i18nProvider.d.ts +1 -1
- package/dist/types/stores/auth.d.ts +9 -24
- package/dist/types/stores/i18n.d.ts +7 -16
- package/dist/types/stores/index.d.ts +2 -2
- package/dist/types/stores/manage.d.ts +7 -16
- package/dist/types/stores/route.d.ts +12 -2538
- package/dist/types/stores/tab.d.ts +6 -1030
- package/dist/types/stores/theme.d.ts +14 -96
- package/dist/types/types/config.d.ts +9 -0
- package/dist/types/types/i18n.d.ts +1 -0
- package/dist/types/types/manage.d.ts +6 -0
- package/dist/types/types/theme.d.ts +2 -0
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/theme.d.ts +4 -49
- package/package.json +22 -15
- package/dist/cjs/node_modules/jsep/dist/jsep.cjs +0 -2
- package/dist/esm/node_modules/jsep/dist/jsep.js +0 -737
- /package/dist/cjs/{hooks/themeColor.cjs → config/color.cjs} +0 -0
- /package/dist/esm/{hooks/themeColor.js → config/color.js} +0 -0
- /package/dist/types/{hooks/themeColor.d.ts → config/color.d.ts} +0 -0
|
@@ -1,737 +0,0 @@
|
|
|
1
|
-
class x {
|
|
2
|
-
/**
|
|
3
|
-
* @callback HookCallback
|
|
4
|
-
* @this {*|Jsep} this
|
|
5
|
-
* @param {Jsep} env
|
|
6
|
-
* @returns: void
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Adds the given callback to the list of callbacks for the given hook.
|
|
10
|
-
*
|
|
11
|
-
* The callback will be invoked when the hook it is registered for is run.
|
|
12
|
-
*
|
|
13
|
-
* One callback function can be registered to multiple hooks and the same hook multiple times.
|
|
14
|
-
*
|
|
15
|
-
* @param {string|object} name The name of the hook, or an object of callbacks keyed by name
|
|
16
|
-
* @param {HookCallback|boolean} callback The callback function which is given environment variables.
|
|
17
|
-
* @param {?boolean} [first=false] Will add the hook to the top of the list (defaults to the bottom)
|
|
18
|
-
* @public
|
|
19
|
-
*/
|
|
20
|
-
add(t, i, n) {
|
|
21
|
-
if (typeof arguments[0] != "string")
|
|
22
|
-
for (let r in arguments[0])
|
|
23
|
-
this.add(r, arguments[0][r], arguments[1]);
|
|
24
|
-
else
|
|
25
|
-
(Array.isArray(t) ? t : [t]).forEach(function(r) {
|
|
26
|
-
this[r] = this[r] || [], i && this[r][n ? "unshift" : "push"](i);
|
|
27
|
-
}, this);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Runs a hook invoking all registered callbacks with the given environment variables.
|
|
31
|
-
*
|
|
32
|
-
* Callbacks will be invoked synchronously and in the order in which they were registered.
|
|
33
|
-
*
|
|
34
|
-
* @param {string} name The name of the hook.
|
|
35
|
-
* @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
|
|
36
|
-
* @public
|
|
37
|
-
*/
|
|
38
|
-
run(t, i) {
|
|
39
|
-
this[t] = this[t] || [], this[t].forEach(function(n) {
|
|
40
|
-
n.call(i && i.context ? i.context : i, i);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
class g {
|
|
45
|
-
constructor(t) {
|
|
46
|
-
this.jsep = t, this.registered = {};
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* @callback PluginSetup
|
|
50
|
-
* @this {Jsep} jsep
|
|
51
|
-
* @returns: void
|
|
52
|
-
*/
|
|
53
|
-
/**
|
|
54
|
-
* Adds the given plugin(s) to the registry
|
|
55
|
-
*
|
|
56
|
-
* @param {object} plugins
|
|
57
|
-
* @param {string} plugins.name The name of the plugin
|
|
58
|
-
* @param {PluginSetup} plugins.init The init function
|
|
59
|
-
* @public
|
|
60
|
-
*/
|
|
61
|
-
register(...t) {
|
|
62
|
-
t.forEach((i) => {
|
|
63
|
-
if (typeof i != "object" || !i.name || !i.init)
|
|
64
|
-
throw new Error("Invalid JSEP plugin format");
|
|
65
|
-
this.registered[i.name] || (i.init(this.jsep), this.registered[i.name] = i);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
class e {
|
|
70
|
-
/**
|
|
71
|
-
* @returns {string}
|
|
72
|
-
*/
|
|
73
|
-
static get version() {
|
|
74
|
-
return "1.4.0";
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* @returns {string}
|
|
78
|
-
*/
|
|
79
|
-
static toString() {
|
|
80
|
-
return "JavaScript Expression Parser (JSEP) v" + e.version;
|
|
81
|
-
}
|
|
82
|
-
// ==================== CONFIG ================================
|
|
83
|
-
/**
|
|
84
|
-
* @method addUnaryOp
|
|
85
|
-
* @param {string} op_name The name of the unary op to add
|
|
86
|
-
* @returns {Jsep}
|
|
87
|
-
*/
|
|
88
|
-
static addUnaryOp(t) {
|
|
89
|
-
return e.max_unop_len = Math.max(t.length, e.max_unop_len), e.unary_ops[t] = 1, e;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* @method jsep.addBinaryOp
|
|
93
|
-
* @param {string} op_name The name of the binary op to add
|
|
94
|
-
* @param {number} precedence The precedence of the binary op (can be a float). Higher number = higher precedence
|
|
95
|
-
* @param {boolean} [isRightAssociative=false] whether operator is right-associative
|
|
96
|
-
* @returns {Jsep}
|
|
97
|
-
*/
|
|
98
|
-
static addBinaryOp(t, i, n) {
|
|
99
|
-
return e.max_binop_len = Math.max(t.length, e.max_binop_len), e.binary_ops[t] = i, n ? e.right_associative.add(t) : e.right_associative.delete(t), e;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* @method addIdentifierChar
|
|
103
|
-
* @param {string} char The additional character to treat as a valid part of an identifier
|
|
104
|
-
* @returns {Jsep}
|
|
105
|
-
*/
|
|
106
|
-
static addIdentifierChar(t) {
|
|
107
|
-
return e.additional_identifier_chars.add(t), e;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* @method addLiteral
|
|
111
|
-
* @param {string} literal_name The name of the literal to add
|
|
112
|
-
* @param {*} literal_value The value of the literal
|
|
113
|
-
* @returns {Jsep}
|
|
114
|
-
*/
|
|
115
|
-
static addLiteral(t, i) {
|
|
116
|
-
return e.literals[t] = i, e;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* @method removeUnaryOp
|
|
120
|
-
* @param {string} op_name The name of the unary op to remove
|
|
121
|
-
* @returns {Jsep}
|
|
122
|
-
*/
|
|
123
|
-
static removeUnaryOp(t) {
|
|
124
|
-
return delete e.unary_ops[t], t.length === e.max_unop_len && (e.max_unop_len = e.getMaxKeyLen(e.unary_ops)), e;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* @method removeAllUnaryOps
|
|
128
|
-
* @returns {Jsep}
|
|
129
|
-
*/
|
|
130
|
-
static removeAllUnaryOps() {
|
|
131
|
-
return e.unary_ops = {}, e.max_unop_len = 0, e;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* @method removeIdentifierChar
|
|
135
|
-
* @param {string} char The additional character to stop treating as a valid part of an identifier
|
|
136
|
-
* @returns {Jsep}
|
|
137
|
-
*/
|
|
138
|
-
static removeIdentifierChar(t) {
|
|
139
|
-
return e.additional_identifier_chars.delete(t), e;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* @method removeBinaryOp
|
|
143
|
-
* @param {string} op_name The name of the binary op to remove
|
|
144
|
-
* @returns {Jsep}
|
|
145
|
-
*/
|
|
146
|
-
static removeBinaryOp(t) {
|
|
147
|
-
return delete e.binary_ops[t], t.length === e.max_binop_len && (e.max_binop_len = e.getMaxKeyLen(e.binary_ops)), e.right_associative.delete(t), e;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* @method removeAllBinaryOps
|
|
151
|
-
* @returns {Jsep}
|
|
152
|
-
*/
|
|
153
|
-
static removeAllBinaryOps() {
|
|
154
|
-
return e.binary_ops = {}, e.max_binop_len = 0, e;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* @method removeLiteral
|
|
158
|
-
* @param {string} literal_name The name of the literal to remove
|
|
159
|
-
* @returns {Jsep}
|
|
160
|
-
*/
|
|
161
|
-
static removeLiteral(t) {
|
|
162
|
-
return delete e.literals[t], e;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* @method removeAllLiterals
|
|
166
|
-
* @returns {Jsep}
|
|
167
|
-
*/
|
|
168
|
-
static removeAllLiterals() {
|
|
169
|
-
return e.literals = {}, e;
|
|
170
|
-
}
|
|
171
|
-
// ==================== END CONFIG ============================
|
|
172
|
-
/**
|
|
173
|
-
* @returns {string}
|
|
174
|
-
*/
|
|
175
|
-
get char() {
|
|
176
|
-
return this.expr.charAt(this.index);
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* @returns {number}
|
|
180
|
-
*/
|
|
181
|
-
get code() {
|
|
182
|
-
return this.expr.charCodeAt(this.index);
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* @param {string} expr a string with the passed in express
|
|
186
|
-
* @returns Jsep
|
|
187
|
-
*/
|
|
188
|
-
constructor(t) {
|
|
189
|
-
this.expr = t, this.index = 0;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* static top-level parser
|
|
193
|
-
* @returns {jsep.Expression}
|
|
194
|
-
*/
|
|
195
|
-
static parse(t) {
|
|
196
|
-
return new e(t).parse();
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Get the longest key length of any object
|
|
200
|
-
* @param {object} obj
|
|
201
|
-
* @returns {number}
|
|
202
|
-
*/
|
|
203
|
-
static getMaxKeyLen(t) {
|
|
204
|
-
return Math.max(0, ...Object.keys(t).map((i) => i.length));
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* `ch` is a character code in the next three functions
|
|
208
|
-
* @param {number} ch
|
|
209
|
-
* @returns {boolean}
|
|
210
|
-
*/
|
|
211
|
-
static isDecimalDigit(t) {
|
|
212
|
-
return t >= 48 && t <= 57;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Returns the precedence of a binary operator or `0` if it isn't a binary operator. Can be float.
|
|
216
|
-
* @param {string} op_val
|
|
217
|
-
* @returns {number}
|
|
218
|
-
*/
|
|
219
|
-
static binaryPrecedence(t) {
|
|
220
|
-
return e.binary_ops[t] || 0;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Looks for start of identifier
|
|
224
|
-
* @param {number} ch
|
|
225
|
-
* @returns {boolean}
|
|
226
|
-
*/
|
|
227
|
-
static isIdentifierStart(t) {
|
|
228
|
-
return t >= 65 && t <= 90 || // A...Z
|
|
229
|
-
t >= 97 && t <= 122 || // a...z
|
|
230
|
-
t >= 128 && !e.binary_ops[String.fromCharCode(t)] || // any non-ASCII that is not an operator
|
|
231
|
-
e.additional_identifier_chars.has(String.fromCharCode(t));
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* @param {number} ch
|
|
235
|
-
* @returns {boolean}
|
|
236
|
-
*/
|
|
237
|
-
static isIdentifierPart(t) {
|
|
238
|
-
return e.isIdentifierStart(t) || e.isDecimalDigit(t);
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* throw error at index of the expression
|
|
242
|
-
* @param {string} message
|
|
243
|
-
* @throws
|
|
244
|
-
*/
|
|
245
|
-
throwError(t) {
|
|
246
|
-
const i = new Error(t + " at character " + this.index);
|
|
247
|
-
throw i.index = this.index, i.description = t, i;
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Run a given hook
|
|
251
|
-
* @param {string} name
|
|
252
|
-
* @param {jsep.Expression|false} [node]
|
|
253
|
-
* @returns {?jsep.Expression}
|
|
254
|
-
*/
|
|
255
|
-
runHook(t, i) {
|
|
256
|
-
if (e.hooks[t]) {
|
|
257
|
-
const n = { context: this, node: i };
|
|
258
|
-
return e.hooks.run(t, n), n.node;
|
|
259
|
-
}
|
|
260
|
-
return i;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Runs a given hook until one returns a node
|
|
264
|
-
* @param {string} name
|
|
265
|
-
* @returns {?jsep.Expression}
|
|
266
|
-
*/
|
|
267
|
-
searchHook(t) {
|
|
268
|
-
if (e.hooks[t]) {
|
|
269
|
-
const i = { context: this };
|
|
270
|
-
return e.hooks[t].find(function(n) {
|
|
271
|
-
return n.call(i.context, i), i.node;
|
|
272
|
-
}), i.node;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Push `index` up to the next non-space character
|
|
277
|
-
*/
|
|
278
|
-
gobbleSpaces() {
|
|
279
|
-
let t = this.code;
|
|
280
|
-
for (; t === e.SPACE_CODE || t === e.TAB_CODE || t === e.LF_CODE || t === e.CR_CODE; )
|
|
281
|
-
t = this.expr.charCodeAt(++this.index);
|
|
282
|
-
this.runHook("gobble-spaces");
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Top-level method to parse all expressions and returns compound or single node
|
|
286
|
-
* @returns {jsep.Expression}
|
|
287
|
-
*/
|
|
288
|
-
parse() {
|
|
289
|
-
this.runHook("before-all");
|
|
290
|
-
const t = this.gobbleExpressions(), i = t.length === 1 ? t[0] : {
|
|
291
|
-
type: e.COMPOUND,
|
|
292
|
-
body: t
|
|
293
|
-
};
|
|
294
|
-
return this.runHook("after-all", i);
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* top-level parser (but can be reused within as well)
|
|
298
|
-
* @param {number} [untilICode]
|
|
299
|
-
* @returns {jsep.Expression[]}
|
|
300
|
-
*/
|
|
301
|
-
gobbleExpressions(t) {
|
|
302
|
-
let i = [], n, r;
|
|
303
|
-
for (; this.index < this.expr.length; )
|
|
304
|
-
if (n = this.code, n === e.SEMCOL_CODE || n === e.COMMA_CODE)
|
|
305
|
-
this.index++;
|
|
306
|
-
else if (r = this.gobbleExpression())
|
|
307
|
-
i.push(r);
|
|
308
|
-
else if (this.index < this.expr.length) {
|
|
309
|
-
if (n === t)
|
|
310
|
-
break;
|
|
311
|
-
this.throwError('Unexpected "' + this.char + '"');
|
|
312
|
-
}
|
|
313
|
-
return i;
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* The main parsing function.
|
|
317
|
-
* @returns {?jsep.Expression}
|
|
318
|
-
*/
|
|
319
|
-
gobbleExpression() {
|
|
320
|
-
const t = this.searchHook("gobble-expression") || this.gobbleBinaryExpression();
|
|
321
|
-
return this.gobbleSpaces(), this.runHook("after-expression", t);
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Search for the operation portion of the string (e.g. `+`, `===`)
|
|
325
|
-
* Start by taking the longest possible binary operations (3 characters: `===`, `!==`, `>>>`)
|
|
326
|
-
* and move down from 3 to 2 to 1 character until a matching binary operation is found
|
|
327
|
-
* then, return that binary operation
|
|
328
|
-
* @returns {string|boolean}
|
|
329
|
-
*/
|
|
330
|
-
gobbleBinaryOp() {
|
|
331
|
-
this.gobbleSpaces();
|
|
332
|
-
let t = this.expr.substr(this.index, e.max_binop_len), i = t.length;
|
|
333
|
-
for (; i > 0; ) {
|
|
334
|
-
if (e.binary_ops.hasOwnProperty(t) && (!e.isIdentifierStart(this.code) || this.index + t.length < this.expr.length && !e.isIdentifierPart(this.expr.charCodeAt(this.index + t.length))))
|
|
335
|
-
return this.index += i, t;
|
|
336
|
-
t = t.substr(0, --i);
|
|
337
|
-
}
|
|
338
|
-
return !1;
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* This function is responsible for gobbling an individual expression,
|
|
342
|
-
* e.g. `1`, `1+2`, `a+(b*2)-Math.sqrt(2)`
|
|
343
|
-
* @returns {?jsep.BinaryExpression}
|
|
344
|
-
*/
|
|
345
|
-
gobbleBinaryExpression() {
|
|
346
|
-
let t, i, n, r, s, o, l, a, E;
|
|
347
|
-
if (o = this.gobbleToken(), !o || (i = this.gobbleBinaryOp(), !i))
|
|
348
|
-
return o;
|
|
349
|
-
for (s = { value: i, prec: e.binaryPrecedence(i), right_a: e.right_associative.has(i) }, l = this.gobbleToken(), l || this.throwError("Expected expression after " + i), r = [o, s, l]; i = this.gobbleBinaryOp(); ) {
|
|
350
|
-
if (n = e.binaryPrecedence(i), n === 0) {
|
|
351
|
-
this.index -= i.length;
|
|
352
|
-
break;
|
|
353
|
-
}
|
|
354
|
-
s = { value: i, prec: n, right_a: e.right_associative.has(i) }, E = i;
|
|
355
|
-
const b = (d) => s.right_a && d.right_a ? n > d.prec : n <= d.prec;
|
|
356
|
-
for (; r.length > 2 && b(r[r.length - 2]); )
|
|
357
|
-
l = r.pop(), i = r.pop().value, o = r.pop(), t = {
|
|
358
|
-
type: e.BINARY_EXP,
|
|
359
|
-
operator: i,
|
|
360
|
-
left: o,
|
|
361
|
-
right: l
|
|
362
|
-
}, r.push(t);
|
|
363
|
-
t = this.gobbleToken(), t || this.throwError("Expected expression after " + E), r.push(s, t);
|
|
364
|
-
}
|
|
365
|
-
for (a = r.length - 1, t = r[a]; a > 1; )
|
|
366
|
-
t = {
|
|
367
|
-
type: e.BINARY_EXP,
|
|
368
|
-
operator: r[a - 1].value,
|
|
369
|
-
left: r[a - 2],
|
|
370
|
-
right: t
|
|
371
|
-
}, a -= 2;
|
|
372
|
-
return t;
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* An individual part of a binary expression:
|
|
376
|
-
* e.g. `foo.bar(baz)`, `1`, `"abc"`, `(a % 2)` (because it's in parenthesis)
|
|
377
|
-
* @returns {boolean|jsep.Expression}
|
|
378
|
-
*/
|
|
379
|
-
gobbleToken() {
|
|
380
|
-
let t, i, n, r;
|
|
381
|
-
if (this.gobbleSpaces(), r = this.searchHook("gobble-token"), r)
|
|
382
|
-
return this.runHook("after-token", r);
|
|
383
|
-
if (t = this.code, e.isDecimalDigit(t) || t === e.PERIOD_CODE)
|
|
384
|
-
return this.gobbleNumericLiteral();
|
|
385
|
-
if (t === e.SQUOTE_CODE || t === e.DQUOTE_CODE)
|
|
386
|
-
r = this.gobbleStringLiteral();
|
|
387
|
-
else if (t === e.OBRACK_CODE)
|
|
388
|
-
r = this.gobbleArray();
|
|
389
|
-
else {
|
|
390
|
-
for (i = this.expr.substr(this.index, e.max_unop_len), n = i.length; n > 0; ) {
|
|
391
|
-
if (e.unary_ops.hasOwnProperty(i) && (!e.isIdentifierStart(this.code) || this.index + i.length < this.expr.length && !e.isIdentifierPart(this.expr.charCodeAt(this.index + i.length)))) {
|
|
392
|
-
this.index += n;
|
|
393
|
-
const s = this.gobbleToken();
|
|
394
|
-
return s || this.throwError("missing unaryOp argument"), this.runHook("after-token", {
|
|
395
|
-
type: e.UNARY_EXP,
|
|
396
|
-
operator: i,
|
|
397
|
-
argument: s,
|
|
398
|
-
prefix: !0
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
i = i.substr(0, --n);
|
|
402
|
-
}
|
|
403
|
-
e.isIdentifierStart(t) ? (r = this.gobbleIdentifier(), e.literals.hasOwnProperty(r.name) ? r = {
|
|
404
|
-
type: e.LITERAL,
|
|
405
|
-
value: e.literals[r.name],
|
|
406
|
-
raw: r.name
|
|
407
|
-
} : r.name === e.this_str && (r = { type: e.THIS_EXP })) : t === e.OPAREN_CODE && (r = this.gobbleGroup());
|
|
408
|
-
}
|
|
409
|
-
return r ? (r = this.gobbleTokenProperty(r), this.runHook("after-token", r)) : this.runHook("after-token", !1);
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* Gobble properties of of identifiers/strings/arrays/groups.
|
|
413
|
-
* e.g. `foo`, `bar.baz`, `foo['bar'].baz`
|
|
414
|
-
* It also gobbles function calls:
|
|
415
|
-
* e.g. `Math.acos(obj.angle)`
|
|
416
|
-
* @param {jsep.Expression} node
|
|
417
|
-
* @returns {jsep.Expression}
|
|
418
|
-
*/
|
|
419
|
-
gobbleTokenProperty(t) {
|
|
420
|
-
this.gobbleSpaces();
|
|
421
|
-
let i = this.code;
|
|
422
|
-
for (; i === e.PERIOD_CODE || i === e.OBRACK_CODE || i === e.OPAREN_CODE || i === e.QUMARK_CODE; ) {
|
|
423
|
-
let n;
|
|
424
|
-
if (i === e.QUMARK_CODE) {
|
|
425
|
-
if (this.expr.charCodeAt(this.index + 1) !== e.PERIOD_CODE)
|
|
426
|
-
break;
|
|
427
|
-
n = !0, this.index += 2, this.gobbleSpaces(), i = this.code;
|
|
428
|
-
}
|
|
429
|
-
this.index++, i === e.OBRACK_CODE ? (t = {
|
|
430
|
-
type: e.MEMBER_EXP,
|
|
431
|
-
computed: !0,
|
|
432
|
-
object: t,
|
|
433
|
-
property: this.gobbleExpression()
|
|
434
|
-
}, t.property || this.throwError('Unexpected "' + this.char + '"'), this.gobbleSpaces(), i = this.code, i !== e.CBRACK_CODE && this.throwError("Unclosed ["), this.index++) : i === e.OPAREN_CODE ? t = {
|
|
435
|
-
type: e.CALL_EXP,
|
|
436
|
-
arguments: this.gobbleArguments(e.CPAREN_CODE),
|
|
437
|
-
callee: t
|
|
438
|
-
} : (i === e.PERIOD_CODE || n) && (n && this.index--, this.gobbleSpaces(), t = {
|
|
439
|
-
type: e.MEMBER_EXP,
|
|
440
|
-
computed: !1,
|
|
441
|
-
object: t,
|
|
442
|
-
property: this.gobbleIdentifier()
|
|
443
|
-
}), n && (t.optional = !0), this.gobbleSpaces(), i = this.code;
|
|
444
|
-
}
|
|
445
|
-
return t;
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* Parse simple numeric literals: `12`, `3.4`, `.5`. Do this by using a string to
|
|
449
|
-
* keep track of everything in the numeric literal and then calling `parseFloat` on that string
|
|
450
|
-
* @returns {jsep.Literal}
|
|
451
|
-
*/
|
|
452
|
-
gobbleNumericLiteral() {
|
|
453
|
-
let t = "", i, n;
|
|
454
|
-
for (; e.isDecimalDigit(this.code); )
|
|
455
|
-
t += this.expr.charAt(this.index++);
|
|
456
|
-
if (this.code === e.PERIOD_CODE)
|
|
457
|
-
for (t += this.expr.charAt(this.index++); e.isDecimalDigit(this.code); )
|
|
458
|
-
t += this.expr.charAt(this.index++);
|
|
459
|
-
if (i = this.char, i === "e" || i === "E") {
|
|
460
|
-
for (t += this.expr.charAt(this.index++), i = this.char, (i === "+" || i === "-") && (t += this.expr.charAt(this.index++)); e.isDecimalDigit(this.code); )
|
|
461
|
-
t += this.expr.charAt(this.index++);
|
|
462
|
-
e.isDecimalDigit(this.expr.charCodeAt(this.index - 1)) || this.throwError("Expected exponent (" + t + this.char + ")");
|
|
463
|
-
}
|
|
464
|
-
return n = this.code, e.isIdentifierStart(n) ? this.throwError("Variable names cannot start with a number (" + t + this.char + ")") : (n === e.PERIOD_CODE || t.length === 1 && t.charCodeAt(0) === e.PERIOD_CODE) && this.throwError("Unexpected period"), {
|
|
465
|
-
type: e.LITERAL,
|
|
466
|
-
value: parseFloat(t),
|
|
467
|
-
raw: t
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* Parses a string literal, staring with single or double quotes with basic support for escape codes
|
|
472
|
-
* e.g. `"hello world"`, `'this is\nJSEP'`
|
|
473
|
-
* @returns {jsep.Literal}
|
|
474
|
-
*/
|
|
475
|
-
gobbleStringLiteral() {
|
|
476
|
-
let t = "";
|
|
477
|
-
const i = this.index, n = this.expr.charAt(this.index++);
|
|
478
|
-
let r = !1;
|
|
479
|
-
for (; this.index < this.expr.length; ) {
|
|
480
|
-
let s = this.expr.charAt(this.index++);
|
|
481
|
-
if (s === n) {
|
|
482
|
-
r = !0;
|
|
483
|
-
break;
|
|
484
|
-
} else if (s === "\\")
|
|
485
|
-
switch (s = this.expr.charAt(this.index++), s) {
|
|
486
|
-
case "n":
|
|
487
|
-
t += `
|
|
488
|
-
`;
|
|
489
|
-
break;
|
|
490
|
-
case "r":
|
|
491
|
-
t += "\r";
|
|
492
|
-
break;
|
|
493
|
-
case "t":
|
|
494
|
-
t += " ";
|
|
495
|
-
break;
|
|
496
|
-
case "b":
|
|
497
|
-
t += "\b";
|
|
498
|
-
break;
|
|
499
|
-
case "f":
|
|
500
|
-
t += "\f";
|
|
501
|
-
break;
|
|
502
|
-
case "v":
|
|
503
|
-
t += "\v";
|
|
504
|
-
break;
|
|
505
|
-
default:
|
|
506
|
-
t += s;
|
|
507
|
-
}
|
|
508
|
-
else
|
|
509
|
-
t += s;
|
|
510
|
-
}
|
|
511
|
-
return r || this.throwError('Unclosed quote after "' + t + '"'), {
|
|
512
|
-
type: e.LITERAL,
|
|
513
|
-
value: t,
|
|
514
|
-
raw: this.expr.substring(i, this.index)
|
|
515
|
-
};
|
|
516
|
-
}
|
|
517
|
-
/**
|
|
518
|
-
* Gobbles only identifiers
|
|
519
|
-
* e.g.: `foo`, `_value`, `$x1`
|
|
520
|
-
* Also, this function checks if that identifier is a literal:
|
|
521
|
-
* (e.g. `true`, `false`, `null`) or `this`
|
|
522
|
-
* @returns {jsep.Identifier}
|
|
523
|
-
*/
|
|
524
|
-
gobbleIdentifier() {
|
|
525
|
-
let t = this.code, i = this.index;
|
|
526
|
-
for (e.isIdentifierStart(t) ? this.index++ : this.throwError("Unexpected " + this.char); this.index < this.expr.length && (t = this.code, e.isIdentifierPart(t)); )
|
|
527
|
-
this.index++;
|
|
528
|
-
return {
|
|
529
|
-
type: e.IDENTIFIER,
|
|
530
|
-
name: this.expr.slice(i, this.index)
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
/**
|
|
534
|
-
* Gobbles a list of arguments within the context of a function call
|
|
535
|
-
* or array literal. This function also assumes that the opening character
|
|
536
|
-
* `(` or `[` has already been gobbled, and gobbles expressions and commas
|
|
537
|
-
* until the terminator character `)` or `]` is encountered.
|
|
538
|
-
* e.g. `foo(bar, baz)`, `my_func()`, or `[bar, baz]`
|
|
539
|
-
* @param {number} termination
|
|
540
|
-
* @returns {jsep.Expression[]}
|
|
541
|
-
*/
|
|
542
|
-
gobbleArguments(t) {
|
|
543
|
-
const i = [];
|
|
544
|
-
let n = !1, r = 0;
|
|
545
|
-
for (; this.index < this.expr.length; ) {
|
|
546
|
-
this.gobbleSpaces();
|
|
547
|
-
let s = this.code;
|
|
548
|
-
if (s === t) {
|
|
549
|
-
n = !0, this.index++, t === e.CPAREN_CODE && r && r >= i.length && this.throwError("Unexpected token " + String.fromCharCode(t));
|
|
550
|
-
break;
|
|
551
|
-
} else if (s === e.COMMA_CODE) {
|
|
552
|
-
if (this.index++, r++, r !== i.length) {
|
|
553
|
-
if (t === e.CPAREN_CODE)
|
|
554
|
-
this.throwError("Unexpected token ,");
|
|
555
|
-
else if (t === e.CBRACK_CODE)
|
|
556
|
-
for (let o = i.length; o < r; o++)
|
|
557
|
-
i.push(null);
|
|
558
|
-
}
|
|
559
|
-
} else if (i.length !== r && r !== 0)
|
|
560
|
-
this.throwError("Expected comma");
|
|
561
|
-
else {
|
|
562
|
-
const o = this.gobbleExpression();
|
|
563
|
-
(!o || o.type === e.COMPOUND) && this.throwError("Expected comma"), i.push(o);
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
return n || this.throwError("Expected " + String.fromCharCode(t)), i;
|
|
567
|
-
}
|
|
568
|
-
/**
|
|
569
|
-
* Responsible for parsing a group of things within parentheses `()`
|
|
570
|
-
* that have no identifier in front (so not a function call)
|
|
571
|
-
* This function assumes that it needs to gobble the opening parenthesis
|
|
572
|
-
* and then tries to gobble everything within that parenthesis, assuming
|
|
573
|
-
* that the next thing it should see is the close parenthesis. If not,
|
|
574
|
-
* then the expression probably doesn't have a `)`
|
|
575
|
-
* @returns {boolean|jsep.Expression}
|
|
576
|
-
*/
|
|
577
|
-
gobbleGroup() {
|
|
578
|
-
this.index++;
|
|
579
|
-
let t = this.gobbleExpressions(e.CPAREN_CODE);
|
|
580
|
-
if (this.code === e.CPAREN_CODE)
|
|
581
|
-
return this.index++, t.length === 1 ? t[0] : t.length ? {
|
|
582
|
-
type: e.SEQUENCE_EXP,
|
|
583
|
-
expressions: t
|
|
584
|
-
} : !1;
|
|
585
|
-
this.throwError("Unclosed (");
|
|
586
|
-
}
|
|
587
|
-
/**
|
|
588
|
-
* Responsible for parsing Array literals `[1, 2, 3]`
|
|
589
|
-
* This function assumes that it needs to gobble the opening bracket
|
|
590
|
-
* and then tries to gobble the expressions as arguments.
|
|
591
|
-
* @returns {jsep.ArrayExpression}
|
|
592
|
-
*/
|
|
593
|
-
gobbleArray() {
|
|
594
|
-
return this.index++, {
|
|
595
|
-
type: e.ARRAY_EXP,
|
|
596
|
-
elements: this.gobbleArguments(e.CBRACK_CODE)
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
const u = new x();
|
|
601
|
-
Object.assign(e, {
|
|
602
|
-
hooks: u,
|
|
603
|
-
plugins: new g(e),
|
|
604
|
-
// Node Types
|
|
605
|
-
// ----------
|
|
606
|
-
// This is the full set of types that any JSEP node can be.
|
|
607
|
-
// Store them here to save space when minified
|
|
608
|
-
COMPOUND: "Compound",
|
|
609
|
-
SEQUENCE_EXP: "SequenceExpression",
|
|
610
|
-
IDENTIFIER: "Identifier",
|
|
611
|
-
MEMBER_EXP: "MemberExpression",
|
|
612
|
-
LITERAL: "Literal",
|
|
613
|
-
THIS_EXP: "ThisExpression",
|
|
614
|
-
CALL_EXP: "CallExpression",
|
|
615
|
-
UNARY_EXP: "UnaryExpression",
|
|
616
|
-
BINARY_EXP: "BinaryExpression",
|
|
617
|
-
ARRAY_EXP: "ArrayExpression",
|
|
618
|
-
TAB_CODE: 9,
|
|
619
|
-
LF_CODE: 10,
|
|
620
|
-
CR_CODE: 13,
|
|
621
|
-
SPACE_CODE: 32,
|
|
622
|
-
PERIOD_CODE: 46,
|
|
623
|
-
// '.'
|
|
624
|
-
COMMA_CODE: 44,
|
|
625
|
-
// ','
|
|
626
|
-
SQUOTE_CODE: 39,
|
|
627
|
-
// single quote
|
|
628
|
-
DQUOTE_CODE: 34,
|
|
629
|
-
// double quotes
|
|
630
|
-
OPAREN_CODE: 40,
|
|
631
|
-
// (
|
|
632
|
-
CPAREN_CODE: 41,
|
|
633
|
-
// )
|
|
634
|
-
OBRACK_CODE: 91,
|
|
635
|
-
// [
|
|
636
|
-
CBRACK_CODE: 93,
|
|
637
|
-
// ]
|
|
638
|
-
QUMARK_CODE: 63,
|
|
639
|
-
// ?
|
|
640
|
-
SEMCOL_CODE: 59,
|
|
641
|
-
// ;
|
|
642
|
-
COLON_CODE: 58,
|
|
643
|
-
// :
|
|
644
|
-
// Operations
|
|
645
|
-
// ----------
|
|
646
|
-
// Use a quickly-accessible map to store all of the unary operators
|
|
647
|
-
// Values are set to `1` (it really doesn't matter)
|
|
648
|
-
unary_ops: {
|
|
649
|
-
"-": 1,
|
|
650
|
-
"!": 1,
|
|
651
|
-
"~": 1,
|
|
652
|
-
"+": 1
|
|
653
|
-
},
|
|
654
|
-
// Also use a map for the binary operations but set their values to their
|
|
655
|
-
// binary precedence for quick reference (higher number = higher precedence)
|
|
656
|
-
// see [Order of operations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence)
|
|
657
|
-
binary_ops: {
|
|
658
|
-
"||": 1,
|
|
659
|
-
"??": 1,
|
|
660
|
-
"&&": 2,
|
|
661
|
-
"|": 3,
|
|
662
|
-
"^": 4,
|
|
663
|
-
"&": 5,
|
|
664
|
-
"==": 6,
|
|
665
|
-
"!=": 6,
|
|
666
|
-
"===": 6,
|
|
667
|
-
"!==": 6,
|
|
668
|
-
"<": 7,
|
|
669
|
-
">": 7,
|
|
670
|
-
"<=": 7,
|
|
671
|
-
">=": 7,
|
|
672
|
-
"<<": 8,
|
|
673
|
-
">>": 8,
|
|
674
|
-
">>>": 8,
|
|
675
|
-
"+": 9,
|
|
676
|
-
"-": 9,
|
|
677
|
-
"*": 10,
|
|
678
|
-
"/": 10,
|
|
679
|
-
"%": 10,
|
|
680
|
-
"**": 11
|
|
681
|
-
},
|
|
682
|
-
// sets specific binary_ops as right-associative
|
|
683
|
-
right_associative: /* @__PURE__ */ new Set(["**"]),
|
|
684
|
-
// Additional valid identifier chars, apart from a-z, A-Z and 0-9 (except on the starting char)
|
|
685
|
-
additional_identifier_chars: /* @__PURE__ */ new Set(["$", "_"]),
|
|
686
|
-
// Literals
|
|
687
|
-
// ----------
|
|
688
|
-
// Store the values to return for the various literals we may encounter
|
|
689
|
-
literals: {
|
|
690
|
-
true: !0,
|
|
691
|
-
false: !1,
|
|
692
|
-
null: null
|
|
693
|
-
},
|
|
694
|
-
// Except for `this`, which is special. This could be changed to something like `'self'` as well
|
|
695
|
-
this_str: "this"
|
|
696
|
-
});
|
|
697
|
-
e.max_unop_len = e.getMaxKeyLen(e.unary_ops);
|
|
698
|
-
e.max_binop_len = e.getMaxKeyLen(e.binary_ops);
|
|
699
|
-
const c = (h) => new e(h).parse(), f = Object.getOwnPropertyNames(class {
|
|
700
|
-
});
|
|
701
|
-
Object.getOwnPropertyNames(e).filter((h) => !f.includes(h) && c[h] === void 0).forEach((h) => {
|
|
702
|
-
c[h] = e[h];
|
|
703
|
-
});
|
|
704
|
-
c.Jsep = e;
|
|
705
|
-
const C = "ConditionalExpression";
|
|
706
|
-
var O = {
|
|
707
|
-
name: "ternary",
|
|
708
|
-
init(h) {
|
|
709
|
-
h.hooks.add("after-expression", function(i) {
|
|
710
|
-
if (i.node && this.code === h.QUMARK_CODE) {
|
|
711
|
-
this.index++;
|
|
712
|
-
const n = i.node, r = this.gobbleExpression();
|
|
713
|
-
if (r || this.throwError("Expected expression"), this.gobbleSpaces(), this.code === h.COLON_CODE) {
|
|
714
|
-
this.index++;
|
|
715
|
-
const s = this.gobbleExpression();
|
|
716
|
-
if (s || this.throwError("Expected expression"), i.node = {
|
|
717
|
-
type: C,
|
|
718
|
-
test: n,
|
|
719
|
-
consequent: r,
|
|
720
|
-
alternate: s
|
|
721
|
-
}, n.operator && h.binary_ops[n.operator] <= 0.9) {
|
|
722
|
-
let o = n;
|
|
723
|
-
for (; o.right.operator && h.binary_ops[o.right.operator] <= 0.9; )
|
|
724
|
-
o = o.right;
|
|
725
|
-
i.node.test = o.right, o.right = i.node, i.node = n;
|
|
726
|
-
}
|
|
727
|
-
} else
|
|
728
|
-
this.throwError("Expected :");
|
|
729
|
-
}
|
|
730
|
-
});
|
|
731
|
-
}
|
|
732
|
-
};
|
|
733
|
-
c.plugins.register(O);
|
|
734
|
-
export {
|
|
735
|
-
e as Jsep,
|
|
736
|
-
c as default
|
|
737
|
-
};
|