@nocobase/plugin-flow-engine 2.1.0-beta.43 → 2.1.0-beta.44
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/externalVersion.js +9 -9
- package/dist/node_modules/@ant-design/icons-svg/package.json +1 -1
- package/dist/node_modules/acorn/package.json +1 -1
- package/dist/node_modules/acorn-jsx/package.json +1 -1
- package/dist/node_modules/acorn-walk/package.json +1 -1
- package/dist/node_modules/ses/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/flow-surfaces/authoring-validation.js +160 -21
- package/dist/server/flow-surfaces/catalog.js +9 -5
- package/dist/server/flow-surfaces/chart-config.js +29 -6
- package/dist/server/flow-surfaces/contract-guard.js +39 -5
- package/dist/server/flow-surfaces/default-block-actions.js +2 -0
- package/dist/server/flow-surfaces/errors.d.ts +15 -0
- package/dist/server/flow-surfaces/errors.js +49 -3
- package/dist/server/flow-surfaces/filter-group.d.ts +7 -1
- package/dist/server/flow-surfaces/filter-group.js +175 -71
- package/dist/server/flow-surfaces/public-data-surface-default-filter.js +2 -1
- package/dist/server/flow-surfaces/runjs-authoring/ast/bindings.d.ts +66 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/bindings.js +661 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/execution.d.ts +20 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/execution.js +275 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/parser.d.ts +16 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/parser.js +130 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/react-values.d.ts +20 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/react-values.js +401 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/request-config.d.ts +21 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/request-config.js +199 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/source.d.ts +70 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/source.js +895 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/static-bindings.d.ts +23 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/static-bindings.js +618 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/static-values.d.ts +196 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/static-values.js +1777 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/walk.d.ts +10 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/walk.js +55 -0
- package/dist/server/flow-surfaces/runjs-authoring/collectors.d.ts +12 -0
- package/dist/server/flow-surfaces/runjs-authoring/collectors.js +589 -0
- package/dist/server/flow-surfaces/runjs-authoring/index.d.ts +2 -25
- package/dist/server/flow-surfaces/runjs-authoring/index.js +5 -11138
- package/dist/server/flow-surfaces/runjs-authoring/inspect.d.ts +13 -0
- package/dist/server/flow-surfaces/runjs-authoring/inspect.js +149 -0
- package/dist/server/flow-surfaces/runjs-authoring/internal-types.d.ts +333 -0
- package/dist/server/flow-surfaces/runjs-authoring/internal-types.js +36 -0
- package/dist/server/flow-surfaces/runjs-authoring/rules.js +2 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.d.ts +67 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.js +757 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/errors.d.ts +22 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/errors.js +91 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/source-budget.d.ts +16 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/source-budget.js +115 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/surface.d.ts +19 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/surface.js +140 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/types.d.ts +91 -0
- package/dist/server/flow-surfaces/runjs-authoring/runtime/types.js +24 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/ctx-api.d.ts +138 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/ctx-api.js +1779 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/filter.d.ts +10 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/filter.js +1583 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/index.d.ts +195 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/index.js +463 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/react-render.d.ts +48 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/react-render.js +379 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/react.d.ts +26 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/react.js +1441 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/resource.d.ts +23 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/resource.js +1427 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.d.ts +91 -0
- package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.js +889 -0
- package/dist/server/flow-surfaces/runjs-authoring/types.d.ts +1 -1
- package/dist/server/flow-surfaces/runjs-authoring/unknown-global-stop/index.d.ts +10 -0
- package/dist/server/flow-surfaces/runjs-authoring/unknown-global-stop/index.js +40 -0
- package/dist/server/flow-surfaces/runjs-authoring/validators/index.d.ts +12 -0
- package/dist/server/flow-surfaces/runjs-authoring/validators/index.js +887 -0
- package/dist/server/flow-surfaces/service-helpers.d.ts +29 -0
- package/dist/server/flow-surfaces/service-helpers.js +105 -0
- package/dist/server/flow-surfaces/service-utils.d.ts +15 -3
- package/dist/server/flow-surfaces/service-utils.js +5 -4
- package/dist/server/flow-surfaces/service.d.ts +4 -0
- package/dist/server/flow-surfaces/service.js +360 -30
- package/dist/server/flow-surfaces/types.d.ts +3 -0
- package/dist/server/repository.d.ts +12 -1
- package/dist/server/repository.js +195 -23
- package/dist/swagger/flow-surfaces.d.ts +175 -0
- package/dist/swagger/flow-surfaces.js +130 -51
- package/dist/swagger/index.d.ts +175 -0
- package/package.json +2 -2
|
@@ -0,0 +1,895 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var source_exports = {};
|
|
28
|
+
__export(source_exports, {
|
|
29
|
+
collectArrowExpressionRanges: () => collectArrowExpressionRanges,
|
|
30
|
+
collectBraceRanges: () => collectBraceRanges,
|
|
31
|
+
collectComputedMethodCandidates: () => collectComputedMethodCandidates,
|
|
32
|
+
collectFunctionRanges: () => collectFunctionRanges,
|
|
33
|
+
collectMethodCandidates: () => collectMethodCandidates,
|
|
34
|
+
collectMethodFunctionRanges: () => collectMethodFunctionRanges,
|
|
35
|
+
collectStaticBlockRanges: () => collectStaticBlockRanges,
|
|
36
|
+
escapeRegExp: () => escapeRegExp,
|
|
37
|
+
findArrowExpressionEnd: () => findArrowExpressionEnd,
|
|
38
|
+
findBraceBodyAfter: () => findBraceBodyAfter,
|
|
39
|
+
findFunctionRanges: () => findFunctionRanges,
|
|
40
|
+
findMatches: () => findMatches,
|
|
41
|
+
findMatchingBrace: () => findMatchingBrace,
|
|
42
|
+
findMatchingDelimiter: () => findMatchingDelimiter,
|
|
43
|
+
findMethodPrefixToken: () => findMethodPrefixToken,
|
|
44
|
+
findTemplateExpressionEnd: () => findTemplateExpressionEnd,
|
|
45
|
+
findTopLevelChar: () => findTopLevelChar,
|
|
46
|
+
getAstSource: () => getAstSource,
|
|
47
|
+
getCallArgumentSource: () => getCallArgumentSource,
|
|
48
|
+
getCallArgumentSources: () => getCallArgumentSources,
|
|
49
|
+
getCallFirstArgumentSource: () => getCallFirstArgumentSource,
|
|
50
|
+
getPreviousSignificantToken: () => getPreviousSignificantToken,
|
|
51
|
+
getPreviousSignificantTokenInfo: () => getPreviousSignificantTokenInfo,
|
|
52
|
+
isInsideRanges: () => isInsideRanges,
|
|
53
|
+
isRegexLiteralStart: () => isRegexLiteralStart,
|
|
54
|
+
maskJavaScriptComments: () => maskJavaScriptComments,
|
|
55
|
+
maskJavaScriptSource: () => maskJavaScriptSource,
|
|
56
|
+
maskTemplateLiteral: () => maskTemplateLiteral,
|
|
57
|
+
maskTemplateLiteralComments: () => maskTemplateLiteralComments,
|
|
58
|
+
mergeRanges: () => mergeRanges,
|
|
59
|
+
readCompleteStringLiteral: () => readCompleteStringLiteral,
|
|
60
|
+
readLeadingStringLiteral: () => readLeadingStringLiteral,
|
|
61
|
+
skipJavaScriptTrivia: () => skipJavaScriptTrivia,
|
|
62
|
+
skipQuotedLiteral: () => skipQuotedLiteral,
|
|
63
|
+
skipRegexLiteral: () => skipRegexLiteral,
|
|
64
|
+
skipTemplateLiteral: () => skipTemplateLiteral,
|
|
65
|
+
splitTopLevel: () => splitTopLevel,
|
|
66
|
+
splitTopLevelWithRanges: () => splitTopLevelWithRanges,
|
|
67
|
+
stripEnclosure: () => stripEnclosure,
|
|
68
|
+
trimBindingElement: () => trimBindingElement
|
|
69
|
+
});
|
|
70
|
+
module.exports = __toCommonJS(source_exports);
|
|
71
|
+
var import_constants = require("../runtime/constants");
|
|
72
|
+
function maskJavaScriptSource(source) {
|
|
73
|
+
const chars = source.split("");
|
|
74
|
+
const maskRange = (start, end) => {
|
|
75
|
+
for (let index2 = start; index2 < end; index2 += 1) {
|
|
76
|
+
if (chars[index2] !== "\n" && chars[index2] !== "\r") {
|
|
77
|
+
chars[index2] = " ";
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
let index = 0;
|
|
82
|
+
while (index < source.length) {
|
|
83
|
+
const char = source[index];
|
|
84
|
+
const next = source[index + 1];
|
|
85
|
+
if (char === "/" && next === "/") {
|
|
86
|
+
const start = index;
|
|
87
|
+
index += 2;
|
|
88
|
+
while (index < source.length && source[index] !== "\n") {
|
|
89
|
+
index += 1;
|
|
90
|
+
}
|
|
91
|
+
maskRange(start, index);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (char === "/" && next === "*") {
|
|
95
|
+
const start = index;
|
|
96
|
+
index += 2;
|
|
97
|
+
while (index < source.length && !(source[index] === "*" && source[index + 1] === "/")) {
|
|
98
|
+
index += 1;
|
|
99
|
+
}
|
|
100
|
+
index = Math.min(source.length, index + 2);
|
|
101
|
+
maskRange(start, index);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (char === "`") {
|
|
105
|
+
index = maskTemplateLiteral(source, chars, index);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (char === "/" && isRegexLiteralStart(chars, index)) {
|
|
109
|
+
const start = index;
|
|
110
|
+
index = skipRegexLiteral(source, index);
|
|
111
|
+
maskRange(start, index);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (char === '"' || char === "'") {
|
|
115
|
+
const quote = char;
|
|
116
|
+
const start = index;
|
|
117
|
+
index += 1;
|
|
118
|
+
while (index < source.length) {
|
|
119
|
+
if (source[index] === "\\") {
|
|
120
|
+
index += 2;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (source[index] === quote) {
|
|
124
|
+
index += 1;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
index += 1;
|
|
128
|
+
}
|
|
129
|
+
maskRange(start, index);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
index += 1;
|
|
133
|
+
}
|
|
134
|
+
return chars.join("");
|
|
135
|
+
}
|
|
136
|
+
function maskJavaScriptComments(source) {
|
|
137
|
+
const chars = source.split("");
|
|
138
|
+
const maskRange = (start, end) => {
|
|
139
|
+
for (let index2 = start; index2 < end; index2 += 1) {
|
|
140
|
+
if (chars[index2] !== "\n" && chars[index2] !== "\r") {
|
|
141
|
+
chars[index2] = " ";
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
let index = 0;
|
|
146
|
+
while (index < source.length) {
|
|
147
|
+
const char = source[index];
|
|
148
|
+
const next = source[index + 1];
|
|
149
|
+
if (char === "/" && next === "/") {
|
|
150
|
+
const start = index;
|
|
151
|
+
index += 2;
|
|
152
|
+
while (index < source.length && source[index] !== "\n") {
|
|
153
|
+
index += 1;
|
|
154
|
+
}
|
|
155
|
+
maskRange(start, index);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (char === "/" && next === "*") {
|
|
159
|
+
const start = index;
|
|
160
|
+
index += 2;
|
|
161
|
+
while (index < source.length && !(source[index] === "*" && source[index + 1] === "/")) {
|
|
162
|
+
index += 1;
|
|
163
|
+
}
|
|
164
|
+
index = Math.min(source.length, index + 2);
|
|
165
|
+
maskRange(start, index);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (char === "`") {
|
|
169
|
+
index = maskTemplateLiteralComments(source, chars, index);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (char === "/" && isRegexLiteralStart(chars, index)) {
|
|
173
|
+
index = skipRegexLiteral(source, index);
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
if (char === '"' || char === "'") {
|
|
177
|
+
index = skipQuotedLiteral(source, index, char);
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
index += 1;
|
|
181
|
+
}
|
|
182
|
+
return chars.join("");
|
|
183
|
+
}
|
|
184
|
+
function maskTemplateLiteralComments(source, chars, start) {
|
|
185
|
+
let index = start + 1;
|
|
186
|
+
while (index < source.length) {
|
|
187
|
+
if (source[index] === "\\") {
|
|
188
|
+
index += 2;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (source[index] === "`") {
|
|
192
|
+
return index + 1;
|
|
193
|
+
}
|
|
194
|
+
if (source[index] === "$" && source[index + 1] === "{") {
|
|
195
|
+
const expressionStart = index + 2;
|
|
196
|
+
const expressionEnd = findTemplateExpressionEnd(source, expressionStart);
|
|
197
|
+
const expressionMasked = maskJavaScriptComments(source.slice(expressionStart, expressionEnd));
|
|
198
|
+
for (let offset = 0; offset < expressionMasked.length; offset += 1) {
|
|
199
|
+
chars[expressionStart + offset] = expressionMasked[offset];
|
|
200
|
+
}
|
|
201
|
+
index = Math.min(source.length, expressionEnd + 1);
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
index += 1;
|
|
205
|
+
}
|
|
206
|
+
return source.length;
|
|
207
|
+
}
|
|
208
|
+
function maskTemplateLiteral(source, chars, start) {
|
|
209
|
+
const maskRange = (from, to) => {
|
|
210
|
+
for (let index2 = from; index2 < to; index2 += 1) {
|
|
211
|
+
if (chars[index2] !== "\n" && chars[index2] !== "\r") {
|
|
212
|
+
chars[index2] = " ";
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
maskRange(start, start + 1);
|
|
217
|
+
let index = start + 1;
|
|
218
|
+
let chunkStart = index;
|
|
219
|
+
while (index < source.length) {
|
|
220
|
+
if (source[index] === "\\") {
|
|
221
|
+
index += 2;
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
if (source[index] === "`") {
|
|
225
|
+
maskRange(chunkStart, index + 1);
|
|
226
|
+
return index + 1;
|
|
227
|
+
}
|
|
228
|
+
if (source[index] === "$" && source[index + 1] === "{") {
|
|
229
|
+
maskRange(chunkStart, index + 2);
|
|
230
|
+
const expressionStart = index + 2;
|
|
231
|
+
const expressionEnd = findTemplateExpressionEnd(source, expressionStart);
|
|
232
|
+
const expressionMasked = maskJavaScriptSource(source.slice(expressionStart, expressionEnd));
|
|
233
|
+
for (let offset = 0; offset < expressionMasked.length; offset += 1) {
|
|
234
|
+
chars[expressionStart + offset] = expressionMasked[offset];
|
|
235
|
+
}
|
|
236
|
+
if (expressionEnd < source.length) {
|
|
237
|
+
maskRange(expressionEnd, expressionEnd + 1);
|
|
238
|
+
}
|
|
239
|
+
index = Math.min(source.length, expressionEnd + 1);
|
|
240
|
+
chunkStart = index;
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
index += 1;
|
|
244
|
+
}
|
|
245
|
+
maskRange(chunkStart, source.length);
|
|
246
|
+
return source.length;
|
|
247
|
+
}
|
|
248
|
+
function findTemplateExpressionEnd(source, start) {
|
|
249
|
+
let depth = 1;
|
|
250
|
+
let index = start;
|
|
251
|
+
while (index < source.length) {
|
|
252
|
+
const char = source[index];
|
|
253
|
+
const next = source[index + 1];
|
|
254
|
+
if (char === "/" && next === "/") {
|
|
255
|
+
index += 2;
|
|
256
|
+
while (index < source.length && source[index] !== "\n") {
|
|
257
|
+
index += 1;
|
|
258
|
+
}
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
if (char === "/" && next === "*") {
|
|
262
|
+
index += 2;
|
|
263
|
+
while (index < source.length && !(source[index] === "*" && source[index + 1] === "/")) {
|
|
264
|
+
index += 1;
|
|
265
|
+
}
|
|
266
|
+
index = Math.min(source.length, index + 2);
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
if (char === '"' || char === "'") {
|
|
270
|
+
index = skipQuotedLiteral(source, index, char);
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
if (char === "`") {
|
|
274
|
+
index = skipTemplateLiteral(source, index);
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
if (char === "/" && isRegexLiteralStart(source, index)) {
|
|
278
|
+
index = skipRegexLiteral(source, index);
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
if (char === "{") {
|
|
282
|
+
depth += 1;
|
|
283
|
+
} else if (char === "}") {
|
|
284
|
+
depth -= 1;
|
|
285
|
+
if (depth === 0) {
|
|
286
|
+
return index;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
index += 1;
|
|
290
|
+
}
|
|
291
|
+
return source.length;
|
|
292
|
+
}
|
|
293
|
+
function skipRegexLiteral(source, start) {
|
|
294
|
+
let index = start + 1;
|
|
295
|
+
let inCharacterClass = false;
|
|
296
|
+
while (index < source.length) {
|
|
297
|
+
const char = source[index];
|
|
298
|
+
if (char === "\\") {
|
|
299
|
+
index += 2;
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
if (char === "[") {
|
|
303
|
+
inCharacterClass = true;
|
|
304
|
+
index += 1;
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
if (char === "]" && inCharacterClass) {
|
|
308
|
+
inCharacterClass = false;
|
|
309
|
+
index += 1;
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
if ((char === "\n" || char === "\r") && !inCharacterClass) {
|
|
313
|
+
return index;
|
|
314
|
+
}
|
|
315
|
+
if (char === "/" && !inCharacterClass) {
|
|
316
|
+
index += 1;
|
|
317
|
+
while (index < source.length && /[A-Za-z]/.test(source[index])) {
|
|
318
|
+
index += 1;
|
|
319
|
+
}
|
|
320
|
+
return index;
|
|
321
|
+
}
|
|
322
|
+
index += 1;
|
|
323
|
+
}
|
|
324
|
+
return source.length;
|
|
325
|
+
}
|
|
326
|
+
function isRegexLiteralStart(sourceLike, slashIndex) {
|
|
327
|
+
const previous = getPreviousSignificantToken(sourceLike, slashIndex);
|
|
328
|
+
if (!previous) {
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
if (/^[([{=,:;!~?&|^+\-*%<>]$/.test(previous)) {
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
return ["return", "throw", "case", "delete", "void", "typeof", "instanceof", "yield", "await", "else"].includes(
|
|
335
|
+
previous
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
function getPreviousSignificantToken(sourceLike, beforeIndex) {
|
|
339
|
+
var _a;
|
|
340
|
+
return ((_a = getPreviousSignificantTokenInfo(sourceLike, beforeIndex)) == null ? void 0 : _a.token) || "";
|
|
341
|
+
}
|
|
342
|
+
function getPreviousSignificantTokenInfo(sourceLike, beforeIndex) {
|
|
343
|
+
let index = beforeIndex - 1;
|
|
344
|
+
while (index >= 0 && /\s/.test(sourceLike[index])) {
|
|
345
|
+
index -= 1;
|
|
346
|
+
}
|
|
347
|
+
if (index < 0) {
|
|
348
|
+
return void 0;
|
|
349
|
+
}
|
|
350
|
+
const char = sourceLike[index];
|
|
351
|
+
if (/[A-Za-z_$]/.test(char)) {
|
|
352
|
+
let start = index;
|
|
353
|
+
while (start > 0 && /[\w$]/.test(sourceLike[start - 1])) {
|
|
354
|
+
start -= 1;
|
|
355
|
+
}
|
|
356
|
+
return {
|
|
357
|
+
token: Array.isArray(sourceLike) ? sourceLike.slice(start, index + 1).join("") : sourceLike.slice(start, index + 1),
|
|
358
|
+
start,
|
|
359
|
+
end: index + 1
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
return {
|
|
363
|
+
token: char,
|
|
364
|
+
start: index,
|
|
365
|
+
end: index + 1
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
function skipQuotedLiteral(source, start, quote) {
|
|
369
|
+
let index = start + 1;
|
|
370
|
+
while (index < source.length) {
|
|
371
|
+
if (source[index] === "\\") {
|
|
372
|
+
index += 2;
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
if (source[index] === quote) {
|
|
376
|
+
return index + 1;
|
|
377
|
+
}
|
|
378
|
+
index += 1;
|
|
379
|
+
}
|
|
380
|
+
return source.length;
|
|
381
|
+
}
|
|
382
|
+
function skipTemplateLiteral(source, start) {
|
|
383
|
+
let index = start + 1;
|
|
384
|
+
while (index < source.length) {
|
|
385
|
+
if (source[index] === "\\") {
|
|
386
|
+
index += 2;
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
if (source[index] === "`") {
|
|
390
|
+
return index + 1;
|
|
391
|
+
}
|
|
392
|
+
if (source[index] === "$" && source[index + 1] === "{") {
|
|
393
|
+
const expressionEnd = findTemplateExpressionEnd(source, index + 2);
|
|
394
|
+
index = Math.min(source.length, expressionEnd + 1);
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
index += 1;
|
|
398
|
+
}
|
|
399
|
+
return source.length;
|
|
400
|
+
}
|
|
401
|
+
function findFunctionRanges(masked) {
|
|
402
|
+
const ranges = [];
|
|
403
|
+
collectFunctionRanges(masked, /\bfunction\b[^{]*\{/g, ranges);
|
|
404
|
+
collectFunctionRanges(masked, /=>\s*\{/g, ranges);
|
|
405
|
+
collectArrowExpressionRanges(masked, ranges);
|
|
406
|
+
collectMethodFunctionRanges(masked, ranges);
|
|
407
|
+
return mergeRanges(ranges);
|
|
408
|
+
}
|
|
409
|
+
function collectFunctionRanges(masked, pattern, ranges) {
|
|
410
|
+
for (const match of masked.matchAll(pattern)) {
|
|
411
|
+
const openBrace = masked.indexOf("{", match.index || 0);
|
|
412
|
+
if (openBrace < 0) {
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
const closeBrace = findMatchingBrace(masked, openBrace);
|
|
416
|
+
if (closeBrace > openBrace) {
|
|
417
|
+
ranges.push({ start: openBrace, end: closeBrace + 1 });
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
function collectArrowExpressionRanges(masked, ranges) {
|
|
422
|
+
for (const match of masked.matchAll(/=>/g)) {
|
|
423
|
+
let start = (match.index || 0) + match[0].length;
|
|
424
|
+
while (start < masked.length && /\s/.test(masked[start])) {
|
|
425
|
+
start += 1;
|
|
426
|
+
}
|
|
427
|
+
if (masked[start] === "{") {
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
const end = findArrowExpressionEnd(masked, start);
|
|
431
|
+
if (end > start) {
|
|
432
|
+
ranges.push({ start, end });
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
function collectMethodFunctionRanges(masked, ranges) {
|
|
437
|
+
collectMethodCandidates(masked).forEach((candidate) => {
|
|
438
|
+
ranges.push(candidate.bodyRange);
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
function findBraceBodyAfter(masked, afterIndex) {
|
|
442
|
+
let cursor = afterIndex + 1;
|
|
443
|
+
while (cursor < masked.length && /\s/.test(masked[cursor])) {
|
|
444
|
+
cursor += 1;
|
|
445
|
+
}
|
|
446
|
+
if (masked[cursor] !== "{") {
|
|
447
|
+
return void 0;
|
|
448
|
+
}
|
|
449
|
+
const closeBrace = findMatchingDelimiter(masked, cursor);
|
|
450
|
+
return closeBrace > cursor ? { start: cursor, end: closeBrace + 1 } : void 0;
|
|
451
|
+
}
|
|
452
|
+
function collectMethodCandidates(masked) {
|
|
453
|
+
const candidates = [];
|
|
454
|
+
const pattern = /\b(?:(?:static|async|get|set)\s+)*(?:\*\s*)?([A-Za-z_$][\w$]*)\s*\(/g;
|
|
455
|
+
for (const match of masked.matchAll(pattern)) {
|
|
456
|
+
const matchIndex = match.index || 0;
|
|
457
|
+
const methodName = match[1];
|
|
458
|
+
if (import_constants.NON_METHOD_CALL_KEYWORDS.has(methodName)) {
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
const previous = getPreviousSignificantToken(masked, matchIndex);
|
|
462
|
+
if (!["{", ",", ";", "}"].includes(previous)) {
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
const openParen = masked.indexOf("(", matchIndex);
|
|
466
|
+
const closeParen = findMatchingDelimiter(masked, openParen);
|
|
467
|
+
const bodyRange = findBraceBodyAfter(masked, closeParen);
|
|
468
|
+
if (closeParen > openParen && bodyRange) {
|
|
469
|
+
candidates.push({
|
|
470
|
+
paramsStart: openParen + 1,
|
|
471
|
+
paramsEnd: closeParen,
|
|
472
|
+
bodyRange
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
collectComputedMethodCandidates(masked, candidates);
|
|
477
|
+
return candidates;
|
|
478
|
+
}
|
|
479
|
+
function collectComputedMethodCandidates(masked, candidates) {
|
|
480
|
+
for (const match of masked.matchAll(/\[/g)) {
|
|
481
|
+
const openBracket = match.index || 0;
|
|
482
|
+
const previous = findMethodPrefixToken(masked, openBracket);
|
|
483
|
+
if (!["{", ",", ";", "}"].includes(previous)) {
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
const closeBracket = findMatchingDelimiter(masked, openBracket);
|
|
487
|
+
if (closeBracket <= openBracket) {
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
let openParen = closeBracket + 1;
|
|
491
|
+
while (openParen < masked.length && /\s/.test(masked[openParen])) {
|
|
492
|
+
openParen += 1;
|
|
493
|
+
}
|
|
494
|
+
if (masked[openParen] !== "(") {
|
|
495
|
+
continue;
|
|
496
|
+
}
|
|
497
|
+
const closeParen = findMatchingDelimiter(masked, openParen);
|
|
498
|
+
const bodyRange = findBraceBodyAfter(masked, closeParen);
|
|
499
|
+
if (closeParen > openParen && bodyRange) {
|
|
500
|
+
candidates.push({
|
|
501
|
+
paramsStart: openParen + 1,
|
|
502
|
+
paramsEnd: closeParen,
|
|
503
|
+
bodyRange
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
function findMethodPrefixToken(masked, beforeIndex) {
|
|
509
|
+
let previous = getPreviousSignificantTokenInfo(masked, beforeIndex);
|
|
510
|
+
while (previous && ["static", "async", "get", "set", "*"].includes(previous.token)) {
|
|
511
|
+
previous = getPreviousSignificantTokenInfo(masked, previous.start);
|
|
512
|
+
}
|
|
513
|
+
return (previous == null ? void 0 : previous.token) || "";
|
|
514
|
+
}
|
|
515
|
+
function findArrowExpressionEnd(masked, start) {
|
|
516
|
+
let parenDepth = 0;
|
|
517
|
+
let bracketDepth = 0;
|
|
518
|
+
let braceDepth = 0;
|
|
519
|
+
for (let index = start; index < masked.length; index += 1) {
|
|
520
|
+
const char = masked[index];
|
|
521
|
+
if (parenDepth === 0 && bracketDepth === 0 && braceDepth === 0) {
|
|
522
|
+
if (char === ";" || char === "," || char === "\n" || char === "\r") {
|
|
523
|
+
return index;
|
|
524
|
+
}
|
|
525
|
+
if (char === ")") {
|
|
526
|
+
return index;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
if (char === "(") {
|
|
530
|
+
parenDepth += 1;
|
|
531
|
+
} else if (char === "[") {
|
|
532
|
+
bracketDepth += 1;
|
|
533
|
+
} else if (char === "{") {
|
|
534
|
+
braceDepth += 1;
|
|
535
|
+
} else if (char === ")" && parenDepth > 0) {
|
|
536
|
+
parenDepth -= 1;
|
|
537
|
+
} else if (char === "]" && bracketDepth > 0) {
|
|
538
|
+
bracketDepth -= 1;
|
|
539
|
+
} else if (char === "}" && braceDepth > 0) {
|
|
540
|
+
braceDepth -= 1;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
return masked.length;
|
|
544
|
+
}
|
|
545
|
+
function findMatchingBrace(masked, openBrace) {
|
|
546
|
+
return findMatchingDelimiter(masked, openBrace);
|
|
547
|
+
}
|
|
548
|
+
function findMatchingDelimiter(masked, openIndex) {
|
|
549
|
+
const closeByOpen = {
|
|
550
|
+
"(": ")",
|
|
551
|
+
"[": "]",
|
|
552
|
+
"{": "}"
|
|
553
|
+
};
|
|
554
|
+
const stack = [closeByOpen[masked[openIndex]]];
|
|
555
|
+
if (!stack[0]) {
|
|
556
|
+
return -1;
|
|
557
|
+
}
|
|
558
|
+
for (let index = openIndex + 1; index < masked.length; index += 1) {
|
|
559
|
+
const char = masked[index];
|
|
560
|
+
if (closeByOpen[char]) {
|
|
561
|
+
stack.push(closeByOpen[char]);
|
|
562
|
+
continue;
|
|
563
|
+
}
|
|
564
|
+
if (char === stack[stack.length - 1]) {
|
|
565
|
+
stack.pop();
|
|
566
|
+
if (!stack.length) {
|
|
567
|
+
return index;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
return -1;
|
|
572
|
+
}
|
|
573
|
+
function collectBraceRanges(masked) {
|
|
574
|
+
const ranges = [];
|
|
575
|
+
for (let index = 0; index < masked.length; index += 1) {
|
|
576
|
+
if (masked[index] !== "{") {
|
|
577
|
+
continue;
|
|
578
|
+
}
|
|
579
|
+
const closeBrace = findMatchingDelimiter(masked, index);
|
|
580
|
+
if (closeBrace > index) {
|
|
581
|
+
ranges.push({ start: index, end: closeBrace + 1 });
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
return ranges;
|
|
585
|
+
}
|
|
586
|
+
function collectStaticBlockRanges(masked) {
|
|
587
|
+
const ranges = [];
|
|
588
|
+
for (const match of masked.matchAll(/\bstatic\s*\{/g)) {
|
|
589
|
+
const openBrace = masked.indexOf("{", match.index || 0);
|
|
590
|
+
const closeBrace = findMatchingDelimiter(masked, openBrace);
|
|
591
|
+
if (closeBrace > openBrace) {
|
|
592
|
+
ranges.push({ start: openBrace, end: closeBrace + 1 });
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
return mergeRanges(ranges);
|
|
596
|
+
}
|
|
597
|
+
function mergeRanges(ranges) {
|
|
598
|
+
const sorted = ranges.slice().sort((left, right) => left.start - right.start);
|
|
599
|
+
const merged = [];
|
|
600
|
+
sorted.forEach((range) => {
|
|
601
|
+
const last = merged[merged.length - 1];
|
|
602
|
+
if (last && range.start <= last.end) {
|
|
603
|
+
last.end = Math.max(last.end, range.end);
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
merged.push({ ...range });
|
|
607
|
+
});
|
|
608
|
+
return merged;
|
|
609
|
+
}
|
|
610
|
+
function isInsideRanges(index, ranges) {
|
|
611
|
+
return ranges.some((range) => index >= range.start && index < range.end);
|
|
612
|
+
}
|
|
613
|
+
function findMatches(masked, pattern) {
|
|
614
|
+
return [...masked.matchAll(pattern)].map((match) => ({
|
|
615
|
+
index: match.index || 0,
|
|
616
|
+
match: match[0]
|
|
617
|
+
}));
|
|
618
|
+
}
|
|
619
|
+
function trimBindingElement(pattern) {
|
|
620
|
+
const withoutRest = pattern.trim().replace(/^\.\.\./, "").trim();
|
|
621
|
+
const equal = findTopLevelChar(withoutRest, "=");
|
|
622
|
+
return (equal >= 0 ? withoutRest.slice(0, equal) : withoutRest).trim();
|
|
623
|
+
}
|
|
624
|
+
function stripEnclosure(pattern, open, close) {
|
|
625
|
+
const trimmed = pattern.trim();
|
|
626
|
+
return trimmed.startsWith(open) && trimmed.endsWith(close) ? trimmed.slice(1, -1) : trimmed;
|
|
627
|
+
}
|
|
628
|
+
function splitTopLevel(value, separator) {
|
|
629
|
+
const parts = [];
|
|
630
|
+
let start = 0;
|
|
631
|
+
let parenDepth = 0;
|
|
632
|
+
let bracketDepth = 0;
|
|
633
|
+
let braceDepth = 0;
|
|
634
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
635
|
+
const char = value[index];
|
|
636
|
+
if (char === "(") {
|
|
637
|
+
parenDepth += 1;
|
|
638
|
+
} else if (char === ")" && parenDepth > 0) {
|
|
639
|
+
parenDepth -= 1;
|
|
640
|
+
} else if (char === "[") {
|
|
641
|
+
bracketDepth += 1;
|
|
642
|
+
} else if (char === "]" && bracketDepth > 0) {
|
|
643
|
+
bracketDepth -= 1;
|
|
644
|
+
} else if (char === "{") {
|
|
645
|
+
braceDepth += 1;
|
|
646
|
+
} else if (char === "}" && braceDepth > 0) {
|
|
647
|
+
braceDepth -= 1;
|
|
648
|
+
} else if (char === separator && parenDepth === 0 && bracketDepth === 0 && braceDepth === 0) {
|
|
649
|
+
parts.push(value.slice(start, index));
|
|
650
|
+
start = index + 1;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
parts.push(value.slice(start));
|
|
654
|
+
return parts;
|
|
655
|
+
}
|
|
656
|
+
function splitTopLevelWithRanges(value, separator) {
|
|
657
|
+
const parts = [];
|
|
658
|
+
let start = 0;
|
|
659
|
+
let parenDepth = 0;
|
|
660
|
+
let bracketDepth = 0;
|
|
661
|
+
let braceDepth = 0;
|
|
662
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
663
|
+
const char = value[index];
|
|
664
|
+
if (char === "(") {
|
|
665
|
+
parenDepth += 1;
|
|
666
|
+
} else if (char === ")" && parenDepth > 0) {
|
|
667
|
+
parenDepth -= 1;
|
|
668
|
+
} else if (char === "[") {
|
|
669
|
+
bracketDepth += 1;
|
|
670
|
+
} else if (char === "]" && bracketDepth > 0) {
|
|
671
|
+
bracketDepth -= 1;
|
|
672
|
+
} else if (char === "{") {
|
|
673
|
+
braceDepth += 1;
|
|
674
|
+
} else if (char === "}" && braceDepth > 0) {
|
|
675
|
+
braceDepth -= 1;
|
|
676
|
+
} else if (char === separator && parenDepth === 0 && bracketDepth === 0 && braceDepth === 0) {
|
|
677
|
+
parts.push({ source: value.slice(start, index), start, end: index });
|
|
678
|
+
start = index + 1;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
parts.push({ source: value.slice(start), start, end: value.length });
|
|
682
|
+
return parts;
|
|
683
|
+
}
|
|
684
|
+
function findTopLevelChar(value, target) {
|
|
685
|
+
let parenDepth = 0;
|
|
686
|
+
let bracketDepth = 0;
|
|
687
|
+
let braceDepth = 0;
|
|
688
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
689
|
+
const char = value[index];
|
|
690
|
+
if (char === "(") {
|
|
691
|
+
parenDepth += 1;
|
|
692
|
+
} else if (char === ")" && parenDepth > 0) {
|
|
693
|
+
parenDepth -= 1;
|
|
694
|
+
} else if (char === "[") {
|
|
695
|
+
bracketDepth += 1;
|
|
696
|
+
} else if (char === "]" && bracketDepth > 0) {
|
|
697
|
+
bracketDepth -= 1;
|
|
698
|
+
} else if (char === "{") {
|
|
699
|
+
braceDepth += 1;
|
|
700
|
+
} else if (char === "}" && braceDepth > 0) {
|
|
701
|
+
braceDepth -= 1;
|
|
702
|
+
} else if (char === target && parenDepth === 0 && bracketDepth === 0 && braceDepth === 0) {
|
|
703
|
+
return index;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
return -1;
|
|
707
|
+
}
|
|
708
|
+
function readLeadingStringLiteral(value) {
|
|
709
|
+
const index = skipJavaScriptTrivia(value, 0);
|
|
710
|
+
const quote = value[index];
|
|
711
|
+
if (quote !== '"' && quote !== "'" && quote !== "`") {
|
|
712
|
+
return void 0;
|
|
713
|
+
}
|
|
714
|
+
let cursor = index + 1;
|
|
715
|
+
let output = "";
|
|
716
|
+
while (cursor < value.length) {
|
|
717
|
+
const char = value[cursor];
|
|
718
|
+
if (char === "\\") {
|
|
719
|
+
output += value.slice(cursor, Math.min(value.length, cursor + 2));
|
|
720
|
+
cursor += 2;
|
|
721
|
+
continue;
|
|
722
|
+
}
|
|
723
|
+
if (char === quote) {
|
|
724
|
+
return {
|
|
725
|
+
value: output,
|
|
726
|
+
end: cursor + 1
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
output += char;
|
|
730
|
+
cursor += 1;
|
|
731
|
+
}
|
|
732
|
+
return void 0;
|
|
733
|
+
}
|
|
734
|
+
function readCompleteStringLiteral(value) {
|
|
735
|
+
const index = skipJavaScriptTrivia(value, 0);
|
|
736
|
+
const literal = readLeadingStringLiteral(value);
|
|
737
|
+
if (!literal) {
|
|
738
|
+
return void 0;
|
|
739
|
+
}
|
|
740
|
+
const rawLiteral = value.slice(index, literal.end);
|
|
741
|
+
if (rawLiteral.startsWith("`") && rawLiteral.includes("${")) {
|
|
742
|
+
return void 0;
|
|
743
|
+
}
|
|
744
|
+
const rest = value.slice(literal.end);
|
|
745
|
+
if (/^[ \t]*(?:\r\n|\r|\n)/.test(rest)) {
|
|
746
|
+
return literal;
|
|
747
|
+
}
|
|
748
|
+
const restIndex = skipJavaScriptTrivia(rest, 0);
|
|
749
|
+
const next = rest[restIndex];
|
|
750
|
+
if (!next || /[,;)\]}]/.test(next)) {
|
|
751
|
+
return literal;
|
|
752
|
+
}
|
|
753
|
+
return void 0;
|
|
754
|
+
}
|
|
755
|
+
function skipJavaScriptTrivia(value, start) {
|
|
756
|
+
let index = start;
|
|
757
|
+
while (index < value.length) {
|
|
758
|
+
while (index < value.length && /\s/.test(value[index])) {
|
|
759
|
+
index += 1;
|
|
760
|
+
}
|
|
761
|
+
if (value[index] === "/" && value[index + 1] === "/") {
|
|
762
|
+
index += 2;
|
|
763
|
+
while (index < value.length && value[index] !== "\n" && value[index] !== "\r") {
|
|
764
|
+
index += 1;
|
|
765
|
+
}
|
|
766
|
+
continue;
|
|
767
|
+
}
|
|
768
|
+
if (value[index] === "/" && value[index + 1] === "*") {
|
|
769
|
+
index += 2;
|
|
770
|
+
while (index < value.length && !(value[index] === "*" && value[index + 1] === "/")) {
|
|
771
|
+
index += 1;
|
|
772
|
+
}
|
|
773
|
+
index = Math.min(value.length, index + 2);
|
|
774
|
+
continue;
|
|
775
|
+
}
|
|
776
|
+
return index;
|
|
777
|
+
}
|
|
778
|
+
return index;
|
|
779
|
+
}
|
|
780
|
+
function getCallFirstArgumentSource(source, masked, index) {
|
|
781
|
+
var _a;
|
|
782
|
+
return ((_a = getCallArgumentSources(source, masked, index)[0]) == null ? void 0 : _a.source) || "";
|
|
783
|
+
}
|
|
784
|
+
function getCallArgumentSources(source, masked, index) {
|
|
785
|
+
const args = [];
|
|
786
|
+
const openParen = masked.indexOf("(", index);
|
|
787
|
+
if (openParen < 0) {
|
|
788
|
+
return args;
|
|
789
|
+
}
|
|
790
|
+
let parenDepth = 1;
|
|
791
|
+
let bracketDepth = 0;
|
|
792
|
+
let braceDepth = 0;
|
|
793
|
+
let argStart = openParen + 1;
|
|
794
|
+
for (let cursor = openParen + 1; cursor < masked.length; cursor += 1) {
|
|
795
|
+
const char = masked[cursor];
|
|
796
|
+
if (char === "(") {
|
|
797
|
+
parenDepth += 1;
|
|
798
|
+
} else if (char === ")" && parenDepth > 0) {
|
|
799
|
+
parenDepth -= 1;
|
|
800
|
+
if (parenDepth === 0) {
|
|
801
|
+
if (cursor > argStart || source.slice(argStart, cursor).trim()) {
|
|
802
|
+
args.push({
|
|
803
|
+
source: source.slice(argStart, cursor),
|
|
804
|
+
start: argStart,
|
|
805
|
+
end: cursor
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
return args;
|
|
809
|
+
}
|
|
810
|
+
} else if (char === "[") {
|
|
811
|
+
bracketDepth += 1;
|
|
812
|
+
} else if (char === "]" && bracketDepth > 0) {
|
|
813
|
+
bracketDepth -= 1;
|
|
814
|
+
} else if (char === "{") {
|
|
815
|
+
braceDepth += 1;
|
|
816
|
+
} else if (char === "}" && braceDepth > 0) {
|
|
817
|
+
braceDepth -= 1;
|
|
818
|
+
} else if (char === "," && parenDepth === 1 && bracketDepth === 0 && braceDepth === 0) {
|
|
819
|
+
args.push({
|
|
820
|
+
source: source.slice(argStart, cursor),
|
|
821
|
+
start: argStart,
|
|
822
|
+
end: cursor
|
|
823
|
+
});
|
|
824
|
+
argStart = cursor + 1;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
return args;
|
|
828
|
+
}
|
|
829
|
+
function getCallArgumentSource(source, masked, index) {
|
|
830
|
+
const openParen = masked.indexOf("(", index);
|
|
831
|
+
if (openParen < 0) {
|
|
832
|
+
return "";
|
|
833
|
+
}
|
|
834
|
+
let depth = 0;
|
|
835
|
+
for (let cursor = openParen; cursor < masked.length; cursor += 1) {
|
|
836
|
+
if (masked[cursor] === "(") {
|
|
837
|
+
depth += 1;
|
|
838
|
+
} else if (masked[cursor] === ")") {
|
|
839
|
+
depth -= 1;
|
|
840
|
+
if (depth === 0) {
|
|
841
|
+
return source.slice(openParen + 1, cursor);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
return "";
|
|
846
|
+
}
|
|
847
|
+
function escapeRegExp(value) {
|
|
848
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
849
|
+
}
|
|
850
|
+
function getAstSource(node, source) {
|
|
851
|
+
return source.slice((node == null ? void 0 : node.start) || 0, (node == null ? void 0 : node.end) || (node == null ? void 0 : node.start) || 0).trim();
|
|
852
|
+
}
|
|
853
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
854
|
+
0 && (module.exports = {
|
|
855
|
+
collectArrowExpressionRanges,
|
|
856
|
+
collectBraceRanges,
|
|
857
|
+
collectComputedMethodCandidates,
|
|
858
|
+
collectFunctionRanges,
|
|
859
|
+
collectMethodCandidates,
|
|
860
|
+
collectMethodFunctionRanges,
|
|
861
|
+
collectStaticBlockRanges,
|
|
862
|
+
escapeRegExp,
|
|
863
|
+
findArrowExpressionEnd,
|
|
864
|
+
findBraceBodyAfter,
|
|
865
|
+
findFunctionRanges,
|
|
866
|
+
findMatches,
|
|
867
|
+
findMatchingBrace,
|
|
868
|
+
findMatchingDelimiter,
|
|
869
|
+
findMethodPrefixToken,
|
|
870
|
+
findTemplateExpressionEnd,
|
|
871
|
+
findTopLevelChar,
|
|
872
|
+
getAstSource,
|
|
873
|
+
getCallArgumentSource,
|
|
874
|
+
getCallArgumentSources,
|
|
875
|
+
getCallFirstArgumentSource,
|
|
876
|
+
getPreviousSignificantToken,
|
|
877
|
+
getPreviousSignificantTokenInfo,
|
|
878
|
+
isInsideRanges,
|
|
879
|
+
isRegexLiteralStart,
|
|
880
|
+
maskJavaScriptComments,
|
|
881
|
+
maskJavaScriptSource,
|
|
882
|
+
maskTemplateLiteral,
|
|
883
|
+
maskTemplateLiteralComments,
|
|
884
|
+
mergeRanges,
|
|
885
|
+
readCompleteStringLiteral,
|
|
886
|
+
readLeadingStringLiteral,
|
|
887
|
+
skipJavaScriptTrivia,
|
|
888
|
+
skipQuotedLiteral,
|
|
889
|
+
skipRegexLiteral,
|
|
890
|
+
skipTemplateLiteral,
|
|
891
|
+
splitTopLevel,
|
|
892
|
+
splitTopLevelWithRanges,
|
|
893
|
+
stripEnclosure,
|
|
894
|
+
trimBindingElement
|
|
895
|
+
});
|