what-compiler 0.14.0 → 0.15.0
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/LICENSE +21 -0
- package/README.md +181 -2
- package/babel.d.ts +78 -2
- package/dist/babel/auto-selector.min.js +94 -0
- package/dist/babel/common.min.js +2053 -0
- package/dist/babel/dev-metadata.min.js +106 -0
- package/dist/babel/dom.min.js +1669 -0
- package/dist/babel/jsx-root.min.js +13 -0
- package/dist/babel/lists.min.js +492 -0
- package/dist/babel/nesting.min.js +328 -0
- package/dist/babel/reactivity.min.js +1218 -0
- package/dist/babel/server-actions.min.js +85 -0
- package/dist/babel/ssr.min.js +496 -0
- package/dist/babel/types.min.js +9 -0
- package/dist/babel-plugin.min.js +101 -1
- package/dist/file-router.min.js +368 -12
- package/dist/framework-files.min.js +62 -0
- package/dist/hot.min.js +315 -0
- package/dist/index.min.js +13 -414
- package/dist/release.min.js +78 -0
- package/dist/runtime.min.js +9 -1
- package/dist/tables/import-changes.min.js +272 -0
- package/dist/tables/markup-rules.min.js +213 -0
- package/dist/vite-plugin.min.js +432 -399
- package/file-router.d.ts +3 -1
- package/index.d.ts +1 -1
- package/package.json +11 -2
- package/runtime.d.ts +2 -1
- package/src/babel/auto-selector.js +248 -0
- package/src/babel/common.js +3800 -0
- package/src/babel/dev-metadata.js +167 -0
- package/src/babel/dom.js +3386 -0
- package/src/babel/jsx-root.js +27 -0
- package/src/babel/lists.js +704 -0
- package/src/babel/nesting.js +260 -0
- package/src/babel/reactivity.js +1998 -0
- package/src/babel/server-actions.js +144 -0
- package/src/babel/ssr.js +870 -0
- package/src/babel/types.js +10 -0
- package/src/babel-plugin.js +185 -3598
- package/src/file-router.js +58 -38
- package/src/framework-files.js +106 -0
- package/src/hot.js +523 -0
- package/src/release.js +127 -0
- package/src/runtime.js +7 -7
- package/src/tables/import-changes.js +157 -0
- package/src/tables/markup-rules.js +388 -0
- package/src/vite-plugin.js +460 -175
- package/vite.d.ts +47 -3
- package/src/error-overlay.js +0 -428
|
@@ -0,0 +1,1218 @@
|
|
|
1
|
+
// src/babel/reactivity.js
|
|
2
|
+
import { t as i } from "./types.min.js";
|
|
3
|
+
import { isWhatModuleSource as Le } from "./common.min.js";
|
|
4
|
+
var A = /* @__PURE__ */ new Set([
|
|
5
|
+
"Math",
|
|
6
|
+
"Number",
|
|
7
|
+
"String",
|
|
8
|
+
"Boolean",
|
|
9
|
+
"parseInt",
|
|
10
|
+
"parseFloat",
|
|
11
|
+
"isNaN",
|
|
12
|
+
"isFinite",
|
|
13
|
+
"encodeURIComponent",
|
|
14
|
+
"decodeURIComponent",
|
|
15
|
+
"encodeURI",
|
|
16
|
+
"decodeURI",
|
|
17
|
+
"JSON",
|
|
18
|
+
"Date",
|
|
19
|
+
"Array",
|
|
20
|
+
"Object",
|
|
21
|
+
"console",
|
|
22
|
+
"RegExp"
|
|
23
|
+
]), te = /* @__PURE__ */ new Set([
|
|
24
|
+
"toString",
|
|
25
|
+
"toLocaleString",
|
|
26
|
+
"valueOf",
|
|
27
|
+
"toJSON",
|
|
28
|
+
"toUpperCase",
|
|
29
|
+
"toLowerCase",
|
|
30
|
+
"toLocaleUpperCase",
|
|
31
|
+
"toLocaleLowerCase",
|
|
32
|
+
"trim",
|
|
33
|
+
"trimStart",
|
|
34
|
+
"trimEnd",
|
|
35
|
+
"toFixed",
|
|
36
|
+
"toPrecision",
|
|
37
|
+
"toExponential",
|
|
38
|
+
"toISOString",
|
|
39
|
+
"toUTCString",
|
|
40
|
+
"toDateString",
|
|
41
|
+
"toTimeString",
|
|
42
|
+
"toLocaleDateString",
|
|
43
|
+
"toLocaleTimeString",
|
|
44
|
+
"slice",
|
|
45
|
+
"reverse",
|
|
46
|
+
"sort",
|
|
47
|
+
"flat",
|
|
48
|
+
"concat",
|
|
49
|
+
"join"
|
|
50
|
+
]), ge = /* @__PURE__ */ new Set([
|
|
51
|
+
"at",
|
|
52
|
+
"charAt",
|
|
53
|
+
"charCodeAt",
|
|
54
|
+
"codePointAt",
|
|
55
|
+
"includes",
|
|
56
|
+
"indexOf",
|
|
57
|
+
"lastIndexOf",
|
|
58
|
+
"startsWith",
|
|
59
|
+
"endsWith",
|
|
60
|
+
"padStart",
|
|
61
|
+
"padEnd",
|
|
62
|
+
"repeat",
|
|
63
|
+
"replace",
|
|
64
|
+
"replaceAll",
|
|
65
|
+
"split",
|
|
66
|
+
"substring",
|
|
67
|
+
"localeCompare",
|
|
68
|
+
"normalize",
|
|
69
|
+
"match",
|
|
70
|
+
"matchAll",
|
|
71
|
+
"search",
|
|
72
|
+
"map",
|
|
73
|
+
"filter",
|
|
74
|
+
"find",
|
|
75
|
+
"findIndex",
|
|
76
|
+
"findLast",
|
|
77
|
+
"findLastIndex",
|
|
78
|
+
"some",
|
|
79
|
+
"every",
|
|
80
|
+
"reduce",
|
|
81
|
+
"reduceRight",
|
|
82
|
+
"flatMap",
|
|
83
|
+
"forEach",
|
|
84
|
+
"toSorted",
|
|
85
|
+
"toReversed",
|
|
86
|
+
"toSpliced",
|
|
87
|
+
"with"
|
|
88
|
+
]), Ce = /* @__PURE__ */ new Set([
|
|
89
|
+
"useSignal",
|
|
90
|
+
"signal",
|
|
91
|
+
"computed",
|
|
92
|
+
"useComputed",
|
|
93
|
+
"useState",
|
|
94
|
+
"useReducer",
|
|
95
|
+
"createResource",
|
|
96
|
+
"useSWR",
|
|
97
|
+
"useQuery",
|
|
98
|
+
"useInfiniteQuery"
|
|
99
|
+
]);
|
|
100
|
+
function I(e, t) {
|
|
101
|
+
return t.has(e);
|
|
102
|
+
}
|
|
103
|
+
function Et(e) {
|
|
104
|
+
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
105
|
+
t.fromDestructuredProps = n;
|
|
106
|
+
let r = /* @__PURE__ */ new Set();
|
|
107
|
+
t.propsObjects = r, t.scope = e.scope;
|
|
108
|
+
let s = e.scope;
|
|
109
|
+
for (; s; ) {
|
|
110
|
+
let o = L !== null ? L.get(s) : void 0, { signals: a, props: u, propsObject: l } = o || Re(s);
|
|
111
|
+
L !== null && o === void 0 && L.set(s, { signals: a, props: u, propsObject: l });
|
|
112
|
+
for (let d of a) t.add(d);
|
|
113
|
+
for (let d of u) n.add(d);
|
|
114
|
+
if (l !== null) for (let d of l) r.add(d);
|
|
115
|
+
s = s.parent;
|
|
116
|
+
}
|
|
117
|
+
return t;
|
|
118
|
+
}
|
|
119
|
+
function Re(e) {
|
|
120
|
+
let t = [], n = [];
|
|
121
|
+
function r(u) {
|
|
122
|
+
let l = u.init;
|
|
123
|
+
if (!l || !i.isCallExpression(l)) return;
|
|
124
|
+
let d = l.callee, m = "";
|
|
125
|
+
if (i.isIdentifier(d)) {
|
|
126
|
+
m = d.name;
|
|
127
|
+
let g = e.getBinding(d.name), y = g && g.kind === "module" ? g.path.node : null;
|
|
128
|
+
i.isImportSpecifier(y) && i.isImportDeclaration(g.path.parent) && Le(g.path.parent.source.value) && (m = i.isIdentifier(y.imported) ? y.imported.name : y.imported.value);
|
|
129
|
+
} else i.isMemberExpression(d) && i.isIdentifier(d.property) && (m = d.property.name);
|
|
130
|
+
if (Ce.has(m)) {
|
|
131
|
+
let g = u.id;
|
|
132
|
+
if (i.isIdentifier(g))
|
|
133
|
+
t.push(g.name);
|
|
134
|
+
else if (i.isArrayPattern(g))
|
|
135
|
+
for (let y of g.elements)
|
|
136
|
+
i.isIdentifier(y) && t.push(y.name);
|
|
137
|
+
else if (i.isObjectPattern(g))
|
|
138
|
+
for (let y of g.properties)
|
|
139
|
+
i.isObjectProperty(y) && i.isIdentifier(y.value) && t.push(y.value.name);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function s(u) {
|
|
143
|
+
if (i.isObjectPattern(u))
|
|
144
|
+
for (let l of u.properties)
|
|
145
|
+
i.isObjectProperty(l) && i.isIdentifier(l.value) ? (t.push(l.value.name), n.push(l.value.name)) : i.isRestElement(l) && i.isIdentifier(l.argument) && (t.push(l.argument.name), n.push(l.argument.name));
|
|
146
|
+
}
|
|
147
|
+
for (let u of Object.values(e.bindings))
|
|
148
|
+
u.path.isVariableDeclarator() && r(u.path.node);
|
|
149
|
+
let o = e.path && e.path.node;
|
|
150
|
+
if (o) {
|
|
151
|
+
if (o.params)
|
|
152
|
+
for (let u of o.params) s(u);
|
|
153
|
+
o._whatMovedProps && s(o._whatMovedProps);
|
|
154
|
+
}
|
|
155
|
+
let a = o && o._whatPropsParam ? [o._whatPropsParam] : [];
|
|
156
|
+
return o && o._whatPropsParam && o._whatPropsRests && a.push(...o._whatPropsRests), { signals: t, props: n, propsObject: a.length > 0 ? a : null };
|
|
157
|
+
}
|
|
158
|
+
function Ae(e, t) {
|
|
159
|
+
let n = t.propsObjects;
|
|
160
|
+
if (n === void 0 || n.size === 0) return !1;
|
|
161
|
+
let r = e;
|
|
162
|
+
for (; i.isMemberExpression(r) || i.isOptionalMemberExpression(r); ) r = r.object;
|
|
163
|
+
if (!i.isIdentifier(r) || !n.has(r.name)) return !1;
|
|
164
|
+
let s = S(r, t.scope);
|
|
165
|
+
return s !== null && s.path.node._whatPropsRest === !0 ? s.constantViolations.length === 0 : s !== null && s.kind === "param" && s.path.parentPath != null && s.path.parentPath.node._whatPropsParam === r.name;
|
|
166
|
+
}
|
|
167
|
+
function Te(e, t) {
|
|
168
|
+
let n = e;
|
|
169
|
+
for (; i.isMemberExpression(n) || i.isOptionalMemberExpression(n); ) n = n.object;
|
|
170
|
+
if (!i.isIdentifier(n)) return !1;
|
|
171
|
+
let r = S(n, t.scope);
|
|
172
|
+
return r !== null && r.path.node._whatHookResult === !0;
|
|
173
|
+
}
|
|
174
|
+
function Fe(e) {
|
|
175
|
+
return i.isMemberExpression(e.callee) && !e.callee.computed && i.isIdentifier(e.callee.property) && te.has(e.callee.property.name);
|
|
176
|
+
}
|
|
177
|
+
function Be(e, t) {
|
|
178
|
+
if (!i.isCallExpression(e)) return !1;
|
|
179
|
+
let n = e.callee, r = i.isMemberExpression(n) ? n.object : n;
|
|
180
|
+
return !i.isIdentifier(r) || !A.has(r.name) ? !1 : !S(r, t);
|
|
181
|
+
}
|
|
182
|
+
function St(e, t, n) {
|
|
183
|
+
if (!t) return !1;
|
|
184
|
+
if (i.isCallExpression(e) && !e.callee._whatPlace) {
|
|
185
|
+
if (i.isIdentifier(e.callee) && I(e.callee.name, t) || n && i.isIdentifier(e.callee) && n.has(e.callee.name) && !A.has(e.callee.name) || i.isMemberExpression(e.callee) && i.isIdentifier(e.callee.object) && I(e.callee.object.name, t) || Be(e, t.scope)) return !1;
|
|
186
|
+
if (e.arguments.some((r) => h(r, t, n)))
|
|
187
|
+
return !0;
|
|
188
|
+
}
|
|
189
|
+
return !1;
|
|
190
|
+
}
|
|
191
|
+
function h(e, t, n) {
|
|
192
|
+
return t || (t = /* @__PURE__ */ new Set()), e?._whatLive === !0 ? !0 : i.isCallExpression(e) && e.callee._whatPlace ? !i.isIdentifier(e.arguments[0]) && h(e.arguments[0], t, n) : i.isCallExpression(e) || i.isOptionalCallExpression(e) ? i.isIdentifier(e.callee) && I(e.callee.name, t) || e.callee._whatSelector || e.callee._whatRowItem || n && i.isIdentifier(e.callee) && n.has(e.callee.name) && !A.has(e.callee.name) || (i.isMemberExpression(e.callee) || i.isOptionalMemberExpression(e.callee)) && i.isIdentifier(e.callee.object) && I(e.callee.object.name, t) || e.arguments.length === 0 && !Fe(e) || h(e.callee, t, n) || e.arguments.some((r) => h(r, t, n)) ? !0 : Ue(e, t, n) : i.isIdentifier(e) ? I(e.name, t) || n && n.has(e.name) : i.isMemberExpression(e) || i.isOptionalMemberExpression(e) ? Ae(e, t) || Te(e, t) || h(e.object, t, n) || e.computed && h(e.property, t, n) || ue(e, t.scope, n) : i.isConditionalExpression(e) ? h(e.test, t, n) || h(e.consequent, t, n) || h(e.alternate, t, n) : i.isBinaryExpression(e) || i.isLogicalExpression(e) ? h(e.left, t, n) || h(e.right, t, n) : i.isUnaryExpression(e) ? h(e.argument, t, n) : i.isAssignmentExpression(e) ? h(e.right, t, n) || i.isMemberExpression(e.left) && (ue(e.left, t.scope, n) || e.left.computed && h(e.left.property, t, n)) : i.isSequenceExpression(e) ? e.expressions.some((r) => h(r, t, n)) : i.isTemplateLiteral(e) ? e.expressions.some((r) => h(r, t, n)) : i.isTaggedTemplateExpression(e) ? h(e.tag, t, n) || e.quasi.expressions.some((r) => h(r, t, n)) || V(e, t, n) : i.isObjectExpression(e) ? e.properties.some(
|
|
193
|
+
(r) => i.isObjectProperty(r) ? h(r.value, t, n) : i.isSpreadElement(r) && h(r.argument, t, n)
|
|
194
|
+
) || e.properties.some((r) => i.isSpreadElement(r)) && V(e, t, n) : i.isArrayExpression(e) ? e.elements.some((r) => r && h(i.isSpreadElement(r) ? r.argument : r, t, n)) || e.elements.some((r) => i.isSpreadElement(r)) && V(e, t, n) : (i.isArrowFunctionExpression(e) || i.isFunctionExpression(e), !1);
|
|
195
|
+
}
|
|
196
|
+
var c = "p", E = "a", M = "b", T = "d", f = "u", he = /* @__PURE__ */ new Set(["Date", "RegExp", "Intl"]), Ee = /* @__PURE__ */ new Set([
|
|
197
|
+
"Error",
|
|
198
|
+
"TypeError",
|
|
199
|
+
"RangeError",
|
|
200
|
+
"SyntaxError",
|
|
201
|
+
"ReferenceError",
|
|
202
|
+
"EvalError",
|
|
203
|
+
"URIError",
|
|
204
|
+
"AggregateError",
|
|
205
|
+
"Map",
|
|
206
|
+
"Set",
|
|
207
|
+
"WeakMap",
|
|
208
|
+
"WeakSet",
|
|
209
|
+
"Promise",
|
|
210
|
+
"URL",
|
|
211
|
+
"URLSearchParams"
|
|
212
|
+
]), De = /* @__PURE__ */ new Set([
|
|
213
|
+
...te,
|
|
214
|
+
...ge,
|
|
215
|
+
"concat",
|
|
216
|
+
"isWellFormed",
|
|
217
|
+
"toWellFormed"
|
|
218
|
+
]), Ne = /* @__PURE__ */ new Set([
|
|
219
|
+
...te,
|
|
220
|
+
...ge,
|
|
221
|
+
"keys",
|
|
222
|
+
"values",
|
|
223
|
+
"entries",
|
|
224
|
+
"fill",
|
|
225
|
+
"copyWithin",
|
|
226
|
+
"push",
|
|
227
|
+
"pop",
|
|
228
|
+
"shift",
|
|
229
|
+
"unshift",
|
|
230
|
+
"splice"
|
|
231
|
+
]), Se = /* @__PURE__ */ new Set(["push", "pop", "shift", "unshift", "splice", "fill", "copyWithin", "sort", "reverse"]), We = /* @__PURE__ */ new Set(["slice", "reverse", "sort", "flat", "concat", "filter", "toSorted", "toReversed", "toSpliced", "with", "fill", "copyWithin", "splice"]), ae = /* @__PURE__ */ new Set(["hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "toLocaleString", "toString", "valueOf"]), Y = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new WeakMap();
|
|
232
|
+
function Ue(e, t, n) {
|
|
233
|
+
let r = v.get(e);
|
|
234
|
+
return r !== void 0 ? r : V(e, t, n);
|
|
235
|
+
}
|
|
236
|
+
function V(e, t, n) {
|
|
237
|
+
let r = G(null, null, f, t.scope, n);
|
|
238
|
+
return p(e, r), ne(r);
|
|
239
|
+
}
|
|
240
|
+
function ne(e) {
|
|
241
|
+
if (e.reads) return !0;
|
|
242
|
+
for (let t of e.edges) if (mt(t)) return !0;
|
|
243
|
+
return !1;
|
|
244
|
+
}
|
|
245
|
+
function G(e, t, n, r, s) {
|
|
246
|
+
return { fn: e, outer: t, thisKind: n, scope: r, importedIds: s, env: /* @__PURE__ */ new Map(), params: /* @__PURE__ */ new Map(), written: /* @__PURE__ */ new Map(), reads: !1, edges: [] };
|
|
247
|
+
}
|
|
248
|
+
var _e = 5e4, ye = null;
|
|
249
|
+
function ue(e, t, n) {
|
|
250
|
+
ye = n || null;
|
|
251
|
+
let r = [], s = e;
|
|
252
|
+
for (; i.isMemberExpression(s) || i.isOptionalMemberExpression(s); )
|
|
253
|
+
r.unshift(j(s)), s = s.object;
|
|
254
|
+
let o = [{ node: s, scope: t, path: r, args: null }], a = /* @__PURE__ */ new Set(), u = (l) => {
|
|
255
|
+
let d = `${N(l.node)}|${l.path.join("\0")}|${l.args === null ? 0 : N(l.args)}`;
|
|
256
|
+
a.has(d) || (a.add(d), o.push(l));
|
|
257
|
+
};
|
|
258
|
+
for (let l = 0; o.length > 0; l++)
|
|
259
|
+
if (l > _e || Ve(
|
|
260
|
+
/** @type {any} */
|
|
261
|
+
o.pop(),
|
|
262
|
+
u
|
|
263
|
+
)) return !0;
|
|
264
|
+
return !1;
|
|
265
|
+
}
|
|
266
|
+
function Ve(e, t) {
|
|
267
|
+
let { node: n, scope: r, path: s, args: o } = e;
|
|
268
|
+
if (s.length === 0) return !1;
|
|
269
|
+
let a = (u) => t({ node: u, scope: r, path: s, args: o });
|
|
270
|
+
switch (n.type) {
|
|
271
|
+
case "Identifier":
|
|
272
|
+
return qe(e, t);
|
|
273
|
+
case "ObjectExpression":
|
|
274
|
+
return He(e, t);
|
|
275
|
+
case "ArrayExpression":
|
|
276
|
+
return Je(e, t);
|
|
277
|
+
case "MemberExpression":
|
|
278
|
+
case "OptionalMemberExpression":
|
|
279
|
+
return i.isSuper(n.object) ? !0 : (t({ node: n.object, scope: r, path: [j(n), ...s], args: o }), !1);
|
|
280
|
+
case "ConditionalExpression":
|
|
281
|
+
return a(n.consequent), a(n.alternate), !1;
|
|
282
|
+
case "LogicalExpression":
|
|
283
|
+
return a(n.left), a(n.right), !1;
|
|
284
|
+
case "SequenceExpression":
|
|
285
|
+
return a(n.expressions[n.expressions.length - 1]), !1;
|
|
286
|
+
case "AssignmentExpression":
|
|
287
|
+
return a(n.right), !1;
|
|
288
|
+
case "ParenthesizedExpression":
|
|
289
|
+
case "TSAsExpression":
|
|
290
|
+
case "TSSatisfiesExpression":
|
|
291
|
+
case "TSNonNullExpression":
|
|
292
|
+
case "TypeCastExpression":
|
|
293
|
+
return a(n.expression), !1;
|
|
294
|
+
case "NewExpression":
|
|
295
|
+
return !re(n.callee, r) && !(i.isIdentifier(n.callee) && !S(n.callee, r) && Ee.has(n.callee.name));
|
|
296
|
+
case "CallExpression":
|
|
297
|
+
case "OptionalCallExpression":
|
|
298
|
+
return Ge(e, t);
|
|
299
|
+
case "ClassExpression":
|
|
300
|
+
return xe(n, e, t);
|
|
301
|
+
case "StringLiteral":
|
|
302
|
+
case "NumericLiteral":
|
|
303
|
+
case "BooleanLiteral":
|
|
304
|
+
case "NullLiteral":
|
|
305
|
+
case "BigIntLiteral":
|
|
306
|
+
case "RegExpLiteral":
|
|
307
|
+
case "TemplateLiteral":
|
|
308
|
+
case "UnaryExpression":
|
|
309
|
+
case "BinaryExpression":
|
|
310
|
+
case "UpdateExpression":
|
|
311
|
+
case "ArrowFunctionExpression":
|
|
312
|
+
case "FunctionExpression":
|
|
313
|
+
return !1;
|
|
314
|
+
default:
|
|
315
|
+
return !0;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
function qe(e, t) {
|
|
319
|
+
let { node: n, scope: r, path: s, args: o } = e;
|
|
320
|
+
if (n.name === "undefined" && !S(n, r)) return !1;
|
|
321
|
+
let a = S(n, r);
|
|
322
|
+
if (a === null) return !1;
|
|
323
|
+
if (o !== null && o.has(a)) {
|
|
324
|
+
let d = o.get(a);
|
|
325
|
+
return d === null || t({ ...d, path: s }), !1;
|
|
326
|
+
}
|
|
327
|
+
if (a.kind === "param") return !1;
|
|
328
|
+
if (a.kind === "module") return !0;
|
|
329
|
+
let u = a.path;
|
|
330
|
+
if (u.isFunctionDeclaration()) return !1;
|
|
331
|
+
if (u.isClassDeclaration()) return xe(u.node, e, t);
|
|
332
|
+
if (!u.isVariableDeclarator()) return !0;
|
|
333
|
+
let l = u.parentPath && u.parentPath.parentPath;
|
|
334
|
+
if (l && (l.isForOfStatement() || l.isForInStatement()) && l.node.left === u.parentPath.node || Ke(a)) return !0;
|
|
335
|
+
if (i.isIdentifier(u.node.id))
|
|
336
|
+
u.node.init && t({ node: u.node.init, scope: u.scope, path: s, args: null });
|
|
337
|
+
else {
|
|
338
|
+
let d = ze(u.node.id, a.identifier);
|
|
339
|
+
if (d === null || !u.node.init) return !0;
|
|
340
|
+
t({ node: u.node.init, scope: u.scope, path: [...d.keys, ...s], args: null });
|
|
341
|
+
for (let { at: m, node: g } of d.defaults) t({ node: g, scope: u.scope, path: [...d.keys.slice(m), ...s], args: null });
|
|
342
|
+
}
|
|
343
|
+
for (let d of a.constantViolations) {
|
|
344
|
+
if (d.isUpdateExpression()) continue;
|
|
345
|
+
if (!d.isAssignmentExpression() || !i.isIdentifier(d.node.left)) return !0;
|
|
346
|
+
let m = d.node.operator;
|
|
347
|
+
(m === "=" || m === "||=" || m === "&&=" || m === "??=") && t({ node: d.node.right, scope: d.scope, path: s, args: null });
|
|
348
|
+
}
|
|
349
|
+
return !1;
|
|
350
|
+
}
|
|
351
|
+
function ze(e, t) {
|
|
352
|
+
let n = [], r = [], s = (a) => {
|
|
353
|
+
if (a === t) return !0;
|
|
354
|
+
if (i.isAssignmentPattern(a))
|
|
355
|
+
return r.push({ at: n.length, node: a.right }), s(a.left) ? !0 : (r.pop(), !1);
|
|
356
|
+
if (i.isObjectPattern(a)) {
|
|
357
|
+
for (let u of a.properties) {
|
|
358
|
+
if (i.isRestElement(u)) {
|
|
359
|
+
if (s(u.argument)) return "rest";
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
n.push(u.computed && !i.isStringLiteral(u.key) && !i.isNumericLiteral(u.key) ? null : W(u));
|
|
363
|
+
let l = s(u.value);
|
|
364
|
+
if (l) return l;
|
|
365
|
+
n.pop();
|
|
366
|
+
}
|
|
367
|
+
return !1;
|
|
368
|
+
}
|
|
369
|
+
if (i.isArrayPattern(a))
|
|
370
|
+
for (let u = 0; u < a.elements.length; u++) {
|
|
371
|
+
let l = a.elements[u];
|
|
372
|
+
if (l === null) continue;
|
|
373
|
+
if (i.isRestElement(l)) {
|
|
374
|
+
if (s(l.argument)) return "rest";
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
n.push(String(u));
|
|
378
|
+
let d = s(l);
|
|
379
|
+
if (d) return d;
|
|
380
|
+
n.pop();
|
|
381
|
+
}
|
|
382
|
+
return !1;
|
|
383
|
+
};
|
|
384
|
+
return s(e) === !0 && !n.includes(null) ? { keys: n, defaults: r } : null;
|
|
385
|
+
}
|
|
386
|
+
function He(e, t) {
|
|
387
|
+
let { node: n, scope: r, path: s, args: o } = e, a = s[0];
|
|
388
|
+
for (let l of n.properties) {
|
|
389
|
+
let d = i.isObjectMethod(l) ? l : i.isObjectProperty(l) && i.isFunctionExpression(l.value) ? l.value : null;
|
|
390
|
+
if (d === null) continue;
|
|
391
|
+
let m = C.get(d);
|
|
392
|
+
if (!m || !Me(m)) return !0;
|
|
393
|
+
}
|
|
394
|
+
if (a === null) {
|
|
395
|
+
for (let l of n.properties) {
|
|
396
|
+
if (i.isSpreadElement(l) || i.isObjectMethod(l) && l.kind !== "method") return !0;
|
|
397
|
+
i.isObjectProperty(l) && t({ node: l.value, scope: r, path: s.slice(1), args: o });
|
|
398
|
+
}
|
|
399
|
+
return !1;
|
|
400
|
+
}
|
|
401
|
+
let u = null;
|
|
402
|
+
for (let l of n.properties) {
|
|
403
|
+
if (i.isSpreadElement(l) || l.computed && !i.isStringLiteral(l.key) && !i.isNumericLiteral(l.key)) {
|
|
404
|
+
u = "unknown";
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
W(l) === a && (u = i.isObjectMethod(l) && l.kind === "set" ? null : l);
|
|
408
|
+
}
|
|
409
|
+
if (u === "unknown") return !0;
|
|
410
|
+
if (u !== null && typeof u == "object") {
|
|
411
|
+
if (u.type === "ObjectMethod") return u.kind === "get" && be(u, e, t);
|
|
412
|
+
t({ node: u.value, scope: r, path: s.slice(1), args: o });
|
|
413
|
+
}
|
|
414
|
+
return !1;
|
|
415
|
+
}
|
|
416
|
+
function be(e, t, n) {
|
|
417
|
+
let r = C.get(e);
|
|
418
|
+
if (!r) return !0;
|
|
419
|
+
let s = G(null, null, f, r.scope, ye);
|
|
420
|
+
return R(r, [], f, s), ne(s) ? !0 : (t.path.length > 1 && we(r, t.path.slice(1), null, n), !1);
|
|
421
|
+
}
|
|
422
|
+
function we(e, t, n, r) {
|
|
423
|
+
let s = e.node.body;
|
|
424
|
+
if (!i.isBlockStatement(s)) {
|
|
425
|
+
r({ node: s, scope: e.scope, path: t, args: n });
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
e.traverse({
|
|
429
|
+
ReturnStatement(o) {
|
|
430
|
+
o.node.argument && r({ node: o.node.argument, scope: o.scope, path: t, args: n });
|
|
431
|
+
},
|
|
432
|
+
Function(o) {
|
|
433
|
+
o.skip();
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
function Je(e, t) {
|
|
438
|
+
let { node: n, scope: r, path: s, args: o } = e, a = s[0];
|
|
439
|
+
if (a !== null && !/^\d+$/.test(a)) return !1;
|
|
440
|
+
for (let u = 0; u < n.elements.length; u++) {
|
|
441
|
+
let l = n.elements[u];
|
|
442
|
+
if (i.isSpreadElement(l)) return !0;
|
|
443
|
+
l !== null && (a === null || String(u) === a) && t({ node: l, scope: r, path: s.slice(1), args: o });
|
|
444
|
+
}
|
|
445
|
+
return !1;
|
|
446
|
+
}
|
|
447
|
+
function xe(e, t, n) {
|
|
448
|
+
if (e.superClass) return !0;
|
|
449
|
+
let r = t.path[0];
|
|
450
|
+
for (let s of e.body.body) {
|
|
451
|
+
if (i.isStaticBlock(s)) return !0;
|
|
452
|
+
if (!s.static) continue;
|
|
453
|
+
if (s.computed) return !0;
|
|
454
|
+
let o = i.isIdentifier(s.key) ? s.key.name : i.isStringLiteral(s.key) ? s.key.value : null;
|
|
455
|
+
if (!(r !== null && o !== r)) {
|
|
456
|
+
if (i.isClassMethod(s) && s.kind === "get" && r !== null) {
|
|
457
|
+
if (be(s, t, n)) return !0;
|
|
458
|
+
} else if (i.isClassMethod(s) && s.kind !== "method") return !0;
|
|
459
|
+
i.isClassProperty(s) && s.value && n({ node: s.value, scope: t.scope, path: t.path.slice(1), args: null });
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
return !1;
|
|
463
|
+
}
|
|
464
|
+
function Ge(e, t) {
|
|
465
|
+
let { node: n, scope: r, path: s } = e, o = n.callee;
|
|
466
|
+
if (i.isMemberExpression(o) || i.isOptionalMemberExpression(o)) {
|
|
467
|
+
let d = o.object;
|
|
468
|
+
for (; i.isMemberExpression(d) || i.isOptionalMemberExpression(d); ) d = d.object;
|
|
469
|
+
if (i.isStringLiteral(d) || i.isTemplateLiteral(d) || i.isNumericLiteral(d)) return !1;
|
|
470
|
+
if (!i.isIdentifier(d)) return !0;
|
|
471
|
+
let m = S(d, r);
|
|
472
|
+
if (m === null || m.kind === "param") return !1;
|
|
473
|
+
let g = H(m);
|
|
474
|
+
return !(g === c || g === E || g === M || g === T);
|
|
475
|
+
}
|
|
476
|
+
if (!i.isIdentifier(o)) return !0;
|
|
477
|
+
let a = S(o, r);
|
|
478
|
+
if (a === null || a.kind === "module" || a.kind === "param") return !1;
|
|
479
|
+
if (e.args !== null && e.args.has(a)) return !0;
|
|
480
|
+
let u = Pe(o, r);
|
|
481
|
+
if (u === null) return !0;
|
|
482
|
+
if (u.node.async || u.node.generator) return !1;
|
|
483
|
+
let l = /* @__PURE__ */ new Map();
|
|
484
|
+
for (let d = 0; d < u.node.params.length; d++) {
|
|
485
|
+
let m = u.node.params[d];
|
|
486
|
+
if (!i.isIdentifier(m)) return !0;
|
|
487
|
+
let g = u.scope.getBinding(m.name), y = n.arguments[d];
|
|
488
|
+
if (y !== void 0 && i.isSpreadElement(y)) return !0;
|
|
489
|
+
g && l.set(g, y === void 0 ? null : { node: y, scope: r, args: e.args });
|
|
490
|
+
}
|
|
491
|
+
return we(u, s, l, t), !1;
|
|
492
|
+
}
|
|
493
|
+
var F = /* @__PURE__ */ new WeakMap();
|
|
494
|
+
function Ke(e) {
|
|
495
|
+
let t = F.get(e);
|
|
496
|
+
if (t !== void 0) return t;
|
|
497
|
+
let n = !1, r = [...e.referencePaths], s = /* @__PURE__ */ new Set([e]), o = /* @__PURE__ */ new Set(), a = (l) => {
|
|
498
|
+
!l || F.get(l) === !0 ? n = !0 : !s.has(l) && F.get(l) !== !1 && (s.add(l), r.push(...l.referencePaths));
|
|
499
|
+
}, u = (l) => r.push(l);
|
|
500
|
+
for (; r.length > 0 && !n; ) {
|
|
501
|
+
let l = (
|
|
502
|
+
/** @type {any} */
|
|
503
|
+
r.pop()
|
|
504
|
+
);
|
|
505
|
+
o.has(l.node) || (o.add(l.node), $e(l, a, u) && (n = !0));
|
|
506
|
+
}
|
|
507
|
+
return F.set(e, n), n;
|
|
508
|
+
}
|
|
509
|
+
function $e(e, t, n) {
|
|
510
|
+
let r = e, s = !1;
|
|
511
|
+
for (; ; ) {
|
|
512
|
+
let a = r.parentPath;
|
|
513
|
+
if (!a) return !0;
|
|
514
|
+
if ((a.isMemberExpression() || a.isOptionalMemberExpression()) && a.node.object === r.node) {
|
|
515
|
+
if (K(a)) return !0;
|
|
516
|
+
r = a, s = !0;
|
|
517
|
+
continue;
|
|
518
|
+
}
|
|
519
|
+
if ((a.isCallExpression() || a.isOptionalCallExpression()) && a.node.callee === r.node)
|
|
520
|
+
return s && Se.has(j(r.node));
|
|
521
|
+
if (a.isConditionalExpression() && a.node.test !== r.node || a.isLogicalExpression() || a.isSequenceExpression() && a.node.expressions[a.node.expressions.length - 1] === r.node || a.isParenthesizedExpression() || a.isTSAsExpression() || a.isTSSatisfiesExpression() || a.isTSNonNullExpression()) {
|
|
522
|
+
r = a;
|
|
523
|
+
continue;
|
|
524
|
+
}
|
|
525
|
+
break;
|
|
526
|
+
}
|
|
527
|
+
let o = r.parentPath;
|
|
528
|
+
if (o.isVariableDeclarator({ init: r.node })) {
|
|
529
|
+
for (let a of Object.keys(o.getBindingIdentifiers())) t(o.scope.getBinding(a));
|
|
530
|
+
return !1;
|
|
531
|
+
}
|
|
532
|
+
if (o.isAssignmentExpression({ right: r.node }))
|
|
533
|
+
return o.node.operator !== "=" || !i.isIdentifier(o.node.left) ? !0 : (t(o.scope.getBinding(o.node.left.name)), !1);
|
|
534
|
+
if ((o.isCallExpression() || o.isOptionalCallExpression()) && o.node.callee !== r.node) {
|
|
535
|
+
let a = Pe(o.node.callee, o.scope), u = o.node.arguments.indexOf(r.node);
|
|
536
|
+
if (a === null || u === -1) return !0;
|
|
537
|
+
let l = a.node.params[u];
|
|
538
|
+
if (l === void 0) return !1;
|
|
539
|
+
for (let d of Object.keys(i.getBindingIdentifiers(l))) t(a.scope.getBinding(d));
|
|
540
|
+
return !1;
|
|
541
|
+
}
|
|
542
|
+
if (o.isReturnStatement() || o.isArrowFunctionExpression() && o.node.body === r.node) {
|
|
543
|
+
let a = o.isReturnStatement() ? o.getFunctionParent() : o, u = a && Xe(a);
|
|
544
|
+
if (!u) return !0;
|
|
545
|
+
for (let l of u.referencePaths) {
|
|
546
|
+
if (!l.parentPath.isCallExpression({ callee: l.node })) return !0;
|
|
547
|
+
n(l.parentPath);
|
|
548
|
+
}
|
|
549
|
+
return !1;
|
|
550
|
+
}
|
|
551
|
+
return o.isNewExpression({ callee: r.node }) || o.isClass() && o.node.superClass === r.node ? !1 : !(o.isBinaryExpression() || o.isUnaryExpression() || o.isTemplateLiteral() || o.isJSXExpressionContainer() || o.isIfStatement({ test: r.node }) || o.isConditionalExpression({ test: r.node }) || o.isSpreadElement() || o.isExpressionStatement() || o.isForOfStatement({ right: r.node }) || o.isForInStatement({ right: r.node }) || o.isSwitchStatement({ discriminant: r.node }));
|
|
552
|
+
}
|
|
553
|
+
function Xe(e) {
|
|
554
|
+
if (e.isFunctionDeclaration() && e.node.id) return e.scope.parent.getBinding(e.node.id.name) || null;
|
|
555
|
+
let t = e.parentPath;
|
|
556
|
+
if (t.isVariableDeclarator({ init: e.node }) && i.isIdentifier(t.node.id)) {
|
|
557
|
+
let n = t.scope.getBinding(t.node.id.name);
|
|
558
|
+
return n && n.constant ? n : null;
|
|
559
|
+
}
|
|
560
|
+
return null;
|
|
561
|
+
}
|
|
562
|
+
function Pe(e, t) {
|
|
563
|
+
if (!i.isIdentifier(e)) return null;
|
|
564
|
+
let n = S(e, t);
|
|
565
|
+
if (!n) return null;
|
|
566
|
+
if (n.path.isFunctionDeclaration()) return n.constant ? n.path : null;
|
|
567
|
+
if (!n.constant || !n.path.isVariableDeclarator()) return null;
|
|
568
|
+
let r = n.path.get("init");
|
|
569
|
+
return r.isArrowFunctionExpression() || r.isFunctionExpression() ? r : null;
|
|
570
|
+
}
|
|
571
|
+
function S(e, t) {
|
|
572
|
+
let n = Y.get(e);
|
|
573
|
+
return n !== void 0 ? n : t && t.getBinding(e.name) || null;
|
|
574
|
+
}
|
|
575
|
+
function W(e) {
|
|
576
|
+
return i.isIdentifier(e.key) ? e.key.name : i.isStringLiteral(e.key) ? e.key.value : i.isNumericLiteral(e.key) ? String(e.key.value) : null;
|
|
577
|
+
}
|
|
578
|
+
function j(e) {
|
|
579
|
+
return e.computed ? i.isStringLiteral(e.property) ? e.property.value : i.isNumericLiteral(e.property) ? String(e.property.value) : null : i.isIdentifier(e.property) ? e.property.name : null;
|
|
580
|
+
}
|
|
581
|
+
function Qe(e, t) {
|
|
582
|
+
return e === t || typeof e == "object" && typeof t == "object" && (e.f !== void 0 && e.f === t.f || e.o !== void 0 && e.o === t.o || e.g !== void 0 && e.g === t.g);
|
|
583
|
+
}
|
|
584
|
+
function z(e, t) {
|
|
585
|
+
return Qe(e, t) ? e : f;
|
|
586
|
+
}
|
|
587
|
+
var le = /* @__PURE__ */ new WeakMap(), Ye = 0;
|
|
588
|
+
function N(e) {
|
|
589
|
+
let t = le.get(e);
|
|
590
|
+
return t === void 0 && le.set(e, t = ++Ye), t;
|
|
591
|
+
}
|
|
592
|
+
function fe(e) {
|
|
593
|
+
return typeof e == "string" ? e : e.f !== void 0 ? "f" + N(e.f.node) : e.o !== void 0 ? "o" + N(e.o.identifier) : "g" + e.g;
|
|
594
|
+
}
|
|
595
|
+
function Oe(e) {
|
|
596
|
+
return e === c || e === E || e === M || e === T || typeof e == "object" && e.g !== void 0;
|
|
597
|
+
}
|
|
598
|
+
var B = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new Set();
|
|
599
|
+
function H(e) {
|
|
600
|
+
let t = B.get(e);
|
|
601
|
+
if (t !== void 0) return t;
|
|
602
|
+
if (k.has(e)) return f;
|
|
603
|
+
let n = [e];
|
|
604
|
+
k.add(e);
|
|
605
|
+
try {
|
|
606
|
+
for (; n.length > 0; ) {
|
|
607
|
+
let r = n[n.length - 1], s = null, o = Ze(r, (a) => {
|
|
608
|
+
let u = B.get(a);
|
|
609
|
+
return u !== void 0 ? u : (s === null && !k.has(a) && (s = a), f);
|
|
610
|
+
});
|
|
611
|
+
s !== null ? (n.push(s), k.add(s)) : (B.set(r, o), n.pop(), k.delete(r));
|
|
612
|
+
}
|
|
613
|
+
} finally {
|
|
614
|
+
for (let r of n) k.delete(r);
|
|
615
|
+
}
|
|
616
|
+
return (
|
|
617
|
+
/** @type {Kind} */
|
|
618
|
+
B.get(e)
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
function Ze(e, t) {
|
|
622
|
+
if (e.kind === "module" || e.kind === "param") return f;
|
|
623
|
+
let n = e.path;
|
|
624
|
+
if (!e.constant) return ve(e, t);
|
|
625
|
+
if (n.isFunctionDeclaration()) return { f: n };
|
|
626
|
+
if (!n.isVariableDeclarator() || !i.isIdentifier(n.node.id)) return f;
|
|
627
|
+
let r = n.get("init");
|
|
628
|
+
if (!r.node) return c;
|
|
629
|
+
if (r.isArrowFunctionExpression() || r.isFunctionExpression()) return { f: r };
|
|
630
|
+
if (r.isObjectExpression()) return nt(e) ? { o: e } : f;
|
|
631
|
+
let s = b(r.node, r.scope, t);
|
|
632
|
+
return s === E && !et(e) ? f : s;
|
|
633
|
+
}
|
|
634
|
+
function ve(e, t) {
|
|
635
|
+
let n = e.path;
|
|
636
|
+
return !n.isVariableDeclarator() || !i.isIdentifier(n.node.id) || n.node.init && b(n.node.init, n.scope, t) !== c ? f : e.constantViolations.every((r) => r.isUpdateExpression() || r.isAssignmentExpression() && i.isIdentifier(r.node.left) && b(r.node.right, r.scope, t) === c) ? c : f;
|
|
637
|
+
}
|
|
638
|
+
function et(e) {
|
|
639
|
+
return e.referencePaths.every((t) => {
|
|
640
|
+
let n = t.parentPath;
|
|
641
|
+
return n.isForOfStatement({ right: t.node }) || n.isSpreadElement() ? !0 : !n.isMemberExpression({ object: t.node }) || K(n) ? !1 : !(n.parentPath.isCallExpression({ callee: n.node }) && Se.has(j(n.node)));
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
function K(e) {
|
|
645
|
+
let t = e;
|
|
646
|
+
for (; ; ) {
|
|
647
|
+
let n = t.parentPath;
|
|
648
|
+
if (!n) return !1;
|
|
649
|
+
if (n.isAssignmentExpression() || n.isForInStatement() || n.isForOfStatement()) return n.node.left === t.node;
|
|
650
|
+
if (n.isUpdateExpression() || n.isUnaryExpression({ operator: "delete" })) return !0;
|
|
651
|
+
if (n.isArrayPattern() || n.isRestElement() || n.isAssignmentPattern() && n.node.left === t.node) {
|
|
652
|
+
t = n;
|
|
653
|
+
continue;
|
|
654
|
+
}
|
|
655
|
+
if (n.isObjectProperty() && n.node.value === t.node && n.parentPath.isObjectPattern()) {
|
|
656
|
+
t = n.parentPath;
|
|
657
|
+
continue;
|
|
658
|
+
}
|
|
659
|
+
return !1;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
function b(e, t, n) {
|
|
663
|
+
if (i.isStringLiteral(e) || i.isNumericLiteral(e) || i.isBooleanLiteral(e) || i.isNullLiteral(e) || i.isBigIntLiteral(e)) return c;
|
|
664
|
+
if (i.isTemplateLiteral(e)) return e.expressions.every((r) => b(r, t, n) === c) ? c : f;
|
|
665
|
+
if (i.isUnaryExpression(e)) return b(e.argument, t, n) === c ? c : f;
|
|
666
|
+
if (i.isBinaryExpression(e) || i.isLogicalExpression(e))
|
|
667
|
+
return b(e.left, t, n) === c && b(e.right, t, n) === c ? c : f;
|
|
668
|
+
if (i.isConditionalExpression(e))
|
|
669
|
+
return [e.test, e.consequent, e.alternate].every((r) => b(r, t, n) === c) ? c : f;
|
|
670
|
+
if (i.isArrayExpression(e)) return e.elements.every((r) => r !== null && !i.isSpreadElement(r) && b(r, t, n) === c) ? E : f;
|
|
671
|
+
if (i.isRegExpLiteral(e) || i.isNewExpression(e) && re(e.callee, t) && e.arguments.every((r) => !i.isSpreadElement(r) && b(r, t, n) === c)) return M;
|
|
672
|
+
if (i.isCallExpression(e)) return tt(e, t, n);
|
|
673
|
+
if (i.isIdentifier(e)) {
|
|
674
|
+
if (e.name === "undefined" || e.name === "NaN" || e.name === "Infinity") return S(e, t) ? f : c;
|
|
675
|
+
let r = S(e, t);
|
|
676
|
+
return r ? n(r) : f;
|
|
677
|
+
}
|
|
678
|
+
return f;
|
|
679
|
+
}
|
|
680
|
+
function tt(e, t, n) {
|
|
681
|
+
let r = e.callee;
|
|
682
|
+
if (!i.isMemberExpression(r) || r.computed || !i.isIdentifier(r.object, { name: "Array" }) || S(r.object, t) || e.arguments.some((m) => i.isSpreadElement(m))) return f;
|
|
683
|
+
let s = r.property.name;
|
|
684
|
+
if (s === "of") return e.arguments.every((m) => b(m, t, n) === c) ? E : f;
|
|
685
|
+
if (s !== "from" || e.arguments.length === 0 || e.arguments.length > 2) return f;
|
|
686
|
+
let [o, a] = e.arguments;
|
|
687
|
+
if (!(i.isObjectExpression(o) && o.properties.length === 1 && i.isObjectProperty(o.properties[0]) && !o.properties[0].computed && W(o.properties[0]) === "length" && b(o.properties[0].value, t, n) === c)) {
|
|
688
|
+
let m = b(o, t, n);
|
|
689
|
+
if (m !== E && m !== c) return f;
|
|
690
|
+
}
|
|
691
|
+
if (a === void 0) return E;
|
|
692
|
+
if (!i.isArrowFunctionExpression(a) || a.async || i.isBlockStatement(a.body) || !a.params.every((m) => i.isIdentifier(m))) return f;
|
|
693
|
+
let l = C.get(a);
|
|
694
|
+
if (!l) return f;
|
|
695
|
+
let d = (m) => m.kind === "param" && m.scope === l.scope ? c : n(m);
|
|
696
|
+
return b(a.body, l.scope, d) === c ? E : f;
|
|
697
|
+
}
|
|
698
|
+
function re(e, t) {
|
|
699
|
+
let n = e;
|
|
700
|
+
return i.isMemberExpression(n) && !n.computed && (n = n.object), i.isIdentifier(n) && he.has(n.name) && !S(n, t);
|
|
701
|
+
}
|
|
702
|
+
var ce = /* @__PURE__ */ new WeakMap();
|
|
703
|
+
function nt(e) {
|
|
704
|
+
let t = ce.get(e);
|
|
705
|
+
return t !== void 0 || (t = e.referencePaths.every((n) => {
|
|
706
|
+
let r = n.parentPath;
|
|
707
|
+
return r && r.isMemberExpression({ object: n.node }) && !r.node.computed && !K(r);
|
|
708
|
+
}) && e.path.get("init.properties").every((n) => {
|
|
709
|
+
let r = n.isObjectMethod() ? n : n.isObjectProperty() && n.get("value").isFunctionExpression() ? n.get("value") : null;
|
|
710
|
+
return r === null || Me(r);
|
|
711
|
+
}), ce.set(e, t)), t;
|
|
712
|
+
}
|
|
713
|
+
var de = /* @__PURE__ */ new WeakMap();
|
|
714
|
+
function Me(e) {
|
|
715
|
+
let t = de.get(e.node);
|
|
716
|
+
if (t !== void 0) return t;
|
|
717
|
+
let n = !0;
|
|
718
|
+
return e.traverse({
|
|
719
|
+
ThisExpression(r) {
|
|
720
|
+
let s = r.parentPath;
|
|
721
|
+
(!s.isMemberExpression({ object: r.node }) || s.node.computed || K(s)) && (n = !1);
|
|
722
|
+
},
|
|
723
|
+
Function(r) {
|
|
724
|
+
r.isArrowFunctionExpression() || r.skip();
|
|
725
|
+
}
|
|
726
|
+
}), de.set(e.node, n), n;
|
|
727
|
+
}
|
|
728
|
+
function ie(e, t, n) {
|
|
729
|
+
let r = { inherited: !0 };
|
|
730
|
+
for (let s of e.path.get("init.properties")) {
|
|
731
|
+
if (s.isSpreadElement() || s.node.computed) {
|
|
732
|
+
r = null;
|
|
733
|
+
continue;
|
|
734
|
+
}
|
|
735
|
+
W(s.node) === t && (s.isObjectMethod() ? s.node.kind === "method" ? r = { value: s } : s.node.kind === "set" === n && (r = s.node.kind === "set" ? { set: s } : { get: s }) : r = { value: s.get("value") });
|
|
736
|
+
}
|
|
737
|
+
return r;
|
|
738
|
+
}
|
|
739
|
+
var rt = 600, X = 0;
|
|
740
|
+
function p(e, t) {
|
|
741
|
+
if (e == null) return c;
|
|
742
|
+
if (X >= rt)
|
|
743
|
+
return t.reads = !0, f;
|
|
744
|
+
X++;
|
|
745
|
+
try {
|
|
746
|
+
return it(e, t);
|
|
747
|
+
} finally {
|
|
748
|
+
X--;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
function it(e, t) {
|
|
752
|
+
switch (e.type) {
|
|
753
|
+
case "StringLiteral":
|
|
754
|
+
case "NumericLiteral":
|
|
755
|
+
case "BooleanLiteral":
|
|
756
|
+
case "NullLiteral":
|
|
757
|
+
case "BigIntLiteral":
|
|
758
|
+
return c;
|
|
759
|
+
case "RegExpLiteral":
|
|
760
|
+
return M;
|
|
761
|
+
case "TemplateLiteral":
|
|
762
|
+
for (let n of e.expressions) x(p(n, t), t);
|
|
763
|
+
return c;
|
|
764
|
+
case "Identifier":
|
|
765
|
+
return st(e, t);
|
|
766
|
+
case "ThisExpression":
|
|
767
|
+
return t.thisKind;
|
|
768
|
+
case "ParenthesizedExpression":
|
|
769
|
+
case "TSAsExpression":
|
|
770
|
+
case "TSSatisfiesExpression":
|
|
771
|
+
case "TSNonNullExpression":
|
|
772
|
+
case "TypeCastExpression":
|
|
773
|
+
case "TSTypeAssertion":
|
|
774
|
+
return p(e.expression, t);
|
|
775
|
+
case "SequenceExpression": {
|
|
776
|
+
let n = c;
|
|
777
|
+
for (let r of e.expressions) n = p(r, t);
|
|
778
|
+
return n;
|
|
779
|
+
}
|
|
780
|
+
case "ArrayExpression": {
|
|
781
|
+
let n = !0;
|
|
782
|
+
for (let r of e.elements)
|
|
783
|
+
r !== null && (i.isSpreadElement(r) ? ($(p(r.argument, t), t), n = !1) : p(r, t) !== c && (n = !1));
|
|
784
|
+
return n ? E : f;
|
|
785
|
+
}
|
|
786
|
+
case "ObjectExpression": {
|
|
787
|
+
let n = !0;
|
|
788
|
+
for (let r of e.properties)
|
|
789
|
+
i.isSpreadElement(r) ? (Ie(p(r.argument, t), t), n = !1) : (r.computed && x(p(r.key, t), t), (!i.isObjectProperty(r) || p(r.value, t) !== c) && (n = !1));
|
|
790
|
+
return n ? T : f;
|
|
791
|
+
}
|
|
792
|
+
case "ArrowFunctionExpression":
|
|
793
|
+
case "FunctionExpression": {
|
|
794
|
+
let n = C.get(e);
|
|
795
|
+
return n ? { f: n } : f;
|
|
796
|
+
}
|
|
797
|
+
case "UnaryExpression": {
|
|
798
|
+
let n = p(e.argument, t);
|
|
799
|
+
return (e.operator === "-" || e.operator === "+" || e.operator === "~") && x(n, t), c;
|
|
800
|
+
}
|
|
801
|
+
case "BinaryExpression": {
|
|
802
|
+
let n = i.isPrivateName(e.left) ? c : p(e.left, t), r = p(e.right, t);
|
|
803
|
+
return e.operator === "===" || e.operator === "!==" || (e.operator === "in" ? r === f && (t.reads = !0) : e.operator === "instanceof" ? (typeof r != "object" || /** @type {any} */
|
|
804
|
+
r.g === void 0) && (t.reads = !0) : (x(n, t), x(r, t))), c;
|
|
805
|
+
}
|
|
806
|
+
case "LogicalExpression":
|
|
807
|
+
return z(p(e.left, t), p(e.right, t));
|
|
808
|
+
case "ConditionalExpression":
|
|
809
|
+
return p(e.test, t), z(p(e.consequent, t), p(e.alternate, t));
|
|
810
|
+
case "AssignmentExpression":
|
|
811
|
+
return lt(e, t);
|
|
812
|
+
case "UpdateExpression":
|
|
813
|
+
return i.isIdentifier(e.argument) ? x(p(e.argument, t), t) : i.isMemberExpression(e.argument) ? (x(ee(e.argument, t), t), se(U(e.argument, t), t)) : t.reads = !0, c;
|
|
814
|
+
case "MemberExpression":
|
|
815
|
+
case "OptionalMemberExpression":
|
|
816
|
+
return ee(e, t);
|
|
817
|
+
case "CallExpression":
|
|
818
|
+
case "OptionalCallExpression":
|
|
819
|
+
return ft(e, t);
|
|
820
|
+
case "NewExpression":
|
|
821
|
+
return ct(e, t);
|
|
822
|
+
case "TaggedTemplateExpression": {
|
|
823
|
+
let n = [E, ...e.quasi.expressions.map((r) => p(r, t))];
|
|
824
|
+
return i.isMemberExpression(e.tag) ? je(p(e.tag.object, t), j(e.tag), n, t) : D(p(e.tag, t), n, f, t);
|
|
825
|
+
}
|
|
826
|
+
// JSX the body builds tracks its own holes once it is lowered.
|
|
827
|
+
case "JSXElement":
|
|
828
|
+
case "JSXFragment":
|
|
829
|
+
return f;
|
|
830
|
+
default:
|
|
831
|
+
return t.reads = !0, f;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
function st(e, t) {
|
|
835
|
+
let n = S(e, t.scope);
|
|
836
|
+
if (n === null)
|
|
837
|
+
return e.name === "undefined" || e.name === "NaN" || e.name === "Infinity" ? c : A.has(e.name) || he.has(e.name) ? { g: e.name } : (t.reads = !0, f);
|
|
838
|
+
for (let r = t; r !== null; r = r.outer) {
|
|
839
|
+
let s = r.env.get(n);
|
|
840
|
+
if (s !== void 0) return s;
|
|
841
|
+
}
|
|
842
|
+
if (!n.constant) {
|
|
843
|
+
let r = n.scope.getFunctionParent();
|
|
844
|
+
for (let s = t; s !== null; s = s.outer)
|
|
845
|
+
if (r !== null && s.fn !== null && s.fn.node === r.block) return at(n, s);
|
|
846
|
+
}
|
|
847
|
+
return H(n);
|
|
848
|
+
}
|
|
849
|
+
var ot = 200, Q = 0;
|
|
850
|
+
function at(e, t) {
|
|
851
|
+
if (t.written.has(e)) return t.written.get(e);
|
|
852
|
+
if (Q >= ot)
|
|
853
|
+
return t.reads = !0, f;
|
|
854
|
+
Q++;
|
|
855
|
+
try {
|
|
856
|
+
return ut(e, t);
|
|
857
|
+
} finally {
|
|
858
|
+
Q--;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
function ut(e, t) {
|
|
862
|
+
let n = e.path, r = f;
|
|
863
|
+
e.kind === "param" ? r = t.params.get(e) ?? f : n.isVariableDeclarator() && i.isIdentifier(n.node.id) && (r = n.node.init ? pe(n.node.init, t) : c), t.written.set(e, r);
|
|
864
|
+
for (let s of e.constantViolations) {
|
|
865
|
+
if (s.isUpdateExpression()) continue;
|
|
866
|
+
if (!s.isAssignmentExpression() || !i.isIdentifier(s.node.left)) {
|
|
867
|
+
r = f;
|
|
868
|
+
break;
|
|
869
|
+
}
|
|
870
|
+
let o = s.node.operator;
|
|
871
|
+
r = z(r, o === "=" || o === "||=" || o === "&&=" || o === "??=" ? pe(s.node.right, t) : c), t.written.set(e, r);
|
|
872
|
+
}
|
|
873
|
+
return t.written.set(e, r), r;
|
|
874
|
+
}
|
|
875
|
+
function pe(e, t) {
|
|
876
|
+
return p(e, { ...t, reads: !1, edges: [] });
|
|
877
|
+
}
|
|
878
|
+
function x(e, t) {
|
|
879
|
+
if (e === f) t.reads = !0;
|
|
880
|
+
else if (typeof e == "object" && e.o !== void 0)
|
|
881
|
+
for (let n of ["valueOf", "toString"]) {
|
|
882
|
+
let r = ie(e.o, n, !1);
|
|
883
|
+
(r === null || r.inherited !== !0) && (t.reads = !0);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
function $(e, t) {
|
|
887
|
+
e !== c && e !== E && e !== T && (t.reads = !0);
|
|
888
|
+
}
|
|
889
|
+
function Ie(e, t) {
|
|
890
|
+
(e === f || typeof e == "object" && e.o !== void 0 && e.o.path.node.init.properties.some((n) => i.isSpreadElement(n) || n.computed || i.isObjectMethod(n) && n.kind !== "method")) && (t.reads = !0);
|
|
891
|
+
}
|
|
892
|
+
function se(e, t) {
|
|
893
|
+
(e === f || typeof e == "object" && e.o !== void 0) && (t.reads = !0);
|
|
894
|
+
}
|
|
895
|
+
function U(e, t) {
|
|
896
|
+
if (i.isSuper(e.object))
|
|
897
|
+
return t.reads = !0, f;
|
|
898
|
+
let n = p(e.object, t);
|
|
899
|
+
return e.computed && x(p(e.property, t), t), n;
|
|
900
|
+
}
|
|
901
|
+
function ee(e, t) {
|
|
902
|
+
let n = U(e, t);
|
|
903
|
+
return oe(n, j(e), t);
|
|
904
|
+
}
|
|
905
|
+
function oe(e, t, n) {
|
|
906
|
+
if (e === c || e === E || e === M || e === T) return c;
|
|
907
|
+
if (typeof e == "object") {
|
|
908
|
+
if (e.g !== void 0 || e.f !== void 0) return c;
|
|
909
|
+
let r = t === null ? null : ie(e.o, t, !1);
|
|
910
|
+
if (r === null)
|
|
911
|
+
return n.reads = !0, f;
|
|
912
|
+
if (r.inherited === !0) return c;
|
|
913
|
+
if (r.get !== void 0)
|
|
914
|
+
return R(r.get, [], e, n), f;
|
|
915
|
+
let s = r.value;
|
|
916
|
+
if (s.isObjectMethod() || s.isFunctionExpression() || s.isArrowFunctionExpression()) return { f: s };
|
|
917
|
+
if (s.isIdentifier()) {
|
|
918
|
+
let o = S(s.node, s.scope);
|
|
919
|
+
return o ? H(o) : f;
|
|
920
|
+
}
|
|
921
|
+
return b(s.node, s.scope, H);
|
|
922
|
+
}
|
|
923
|
+
return n.reads = !0, f;
|
|
924
|
+
}
|
|
925
|
+
function lt(e, t) {
|
|
926
|
+
let n = p(e.right, t), r = e.left;
|
|
927
|
+
if (i.isIdentifier(r)) {
|
|
928
|
+
if (e.operator !== "=") {
|
|
929
|
+
let s = p(r, t);
|
|
930
|
+
e.operator !== "||=" && e.operator !== "&&=" && e.operator !== "??=" && (x(s, t), x(n, t));
|
|
931
|
+
}
|
|
932
|
+
return n;
|
|
933
|
+
}
|
|
934
|
+
if (i.isMemberExpression(r)) {
|
|
935
|
+
if (e.operator !== "=") {
|
|
936
|
+
let s = ee(r, t);
|
|
937
|
+
e.operator !== "||=" && e.operator !== "&&=" && e.operator !== "??=" && (x(s, t), x(n, t));
|
|
938
|
+
}
|
|
939
|
+
return se(U(r, t), t), n;
|
|
940
|
+
}
|
|
941
|
+
return P(r, n, t), n;
|
|
942
|
+
}
|
|
943
|
+
function P(e, t, n) {
|
|
944
|
+
if (i.isIdentifier(e)) {
|
|
945
|
+
let r = S(e, n.scope) || (n.fn ? n.fn.scope.getBinding(e.name) : null);
|
|
946
|
+
r && r.constant ? n.env.set(r, t) : r && r.kind === "param" && n.params.set(r, t);
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
if (i.isAssignmentPattern(e)) {
|
|
950
|
+
P(e.left, z(t, p(e.right, n)), n);
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
if (i.isArrayPattern(e)) {
|
|
954
|
+
$(t, n);
|
|
955
|
+
for (let r of e.elements) r && P(r, t === E || t === c ? c : f, n);
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
if (i.isObjectPattern(e)) {
|
|
959
|
+
for (let r of e.properties)
|
|
960
|
+
i.isRestElement(r) ? (Ie(t, n), P(r.argument, f, n)) : (r.computed && x(p(r.key, n), n), P(r.value, oe(t, r.computed ? null : W(r), n), n));
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
if (i.isRestElement(e)) {
|
|
964
|
+
P(e.argument, f, n);
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
if (i.isMemberExpression(e)) {
|
|
968
|
+
se(U(e, n), n);
|
|
969
|
+
return;
|
|
970
|
+
}
|
|
971
|
+
n.reads = !0;
|
|
972
|
+
}
|
|
973
|
+
function q(e, t) {
|
|
974
|
+
let n = [];
|
|
975
|
+
for (let r of e.arguments)
|
|
976
|
+
i.isSpreadElement(r) ? ($(p(r.argument, t), t), n.push(f)) : n.push(p(r, t));
|
|
977
|
+
return n;
|
|
978
|
+
}
|
|
979
|
+
function ft(e, t) {
|
|
980
|
+
let n = e.callee;
|
|
981
|
+
if (i.isMemberExpression(n) || i.isOptionalMemberExpression(n)) {
|
|
982
|
+
let s = U(n, t);
|
|
983
|
+
return je(s, j(n), q(e, t), t);
|
|
984
|
+
}
|
|
985
|
+
if (i.isIdentifier(n)) {
|
|
986
|
+
let s = S(n, t.scope);
|
|
987
|
+
if (s && s.kind === "module") {
|
|
988
|
+
let o = q(e, t);
|
|
989
|
+
return t.importedIds && t.importedIds.has(n.name) ? t.reads = !0 : O(o, t), f;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
let r = p(n, t);
|
|
993
|
+
return D(r, q(e, t), f, t);
|
|
994
|
+
}
|
|
995
|
+
function O(e, t) {
|
|
996
|
+
for (let n of e)
|
|
997
|
+
typeof n == "object" && n.f !== void 0 ? R(n.f, n.f.node.params.map(() => f), f, t) : Oe(n) || (t.reads = !0);
|
|
998
|
+
}
|
|
999
|
+
function D(e, t, n, r) {
|
|
1000
|
+
return typeof e == "object" && e.f !== void 0 ? (R(e.f, t, n, r), f) : typeof e == "object" && e.g !== void 0 && A.has(e.g) ? (O(t, r), c) : (r.reads = !0, f);
|
|
1001
|
+
}
|
|
1002
|
+
function je(e, t, n, r) {
|
|
1003
|
+
if (e === c)
|
|
1004
|
+
return (t === null || !De.has(t)) && (r.reads = !0), O(n, r), t === "split" || t === "match" ? E : c;
|
|
1005
|
+
if (e === E) {
|
|
1006
|
+
(t === null || !Ne.has(t)) && (r.reads = !0);
|
|
1007
|
+
for (let s of n)
|
|
1008
|
+
typeof s == "object" && s.f !== void 0 ? R(s.f, t === "reduce" || t === "reduceRight" ? [f, c, c, E] : [c, c, E], f, r) : Oe(s) || (r.reads = !0);
|
|
1009
|
+
return t === "join" || t === "toString" || t === "indexOf" || t === "lastIndexOf" || t === "includes" || t === "some" || t === "every" || t === "find" || t === "findLast" || t === "at" || t === "findIndex" || t === "findLastIndex" ? c : t !== null && We.has(t) ? E : f;
|
|
1010
|
+
}
|
|
1011
|
+
if (e === M)
|
|
1012
|
+
return O(n, r), c;
|
|
1013
|
+
if (e === T)
|
|
1014
|
+
return (t === null || !ae.has(t)) && (r.reads = !0), O(n, r), c;
|
|
1015
|
+
if (typeof e == "object") {
|
|
1016
|
+
if (e.g !== void 0)
|
|
1017
|
+
return O(n, r), e.g === "Math" || e.g === "Number" || e.g === "String" || e.g === "JSON" || e.g === "Date" ? c : f;
|
|
1018
|
+
if (e.f !== void 0)
|
|
1019
|
+
return t === "call" ? D(e, n.slice(1), n[0] ?? c, r) : t === "apply" ? D(e, n[1] === E || n[1] === void 0 ? [c, c, c] : [f, f, f], n[0] ?? c, r) : (t !== "bind" && (r.reads = !0), O(n, r), f);
|
|
1020
|
+
let s = t === null ? null : ie(e.o, t, !1);
|
|
1021
|
+
if (s === null)
|
|
1022
|
+
return r.reads = !0, f;
|
|
1023
|
+
if (s.inherited === !0)
|
|
1024
|
+
return ae.has(
|
|
1025
|
+
/** @type {string} */
|
|
1026
|
+
t
|
|
1027
|
+
) || (r.reads = !0), O(n, r), c;
|
|
1028
|
+
if (s.get !== void 0)
|
|
1029
|
+
return R(s.get, [], e, r), r.reads = !0, f;
|
|
1030
|
+
let o = s.value, a = oe(e, t, r);
|
|
1031
|
+
return D(a, n, o.isArrowFunctionExpression() ? f : e, r);
|
|
1032
|
+
}
|
|
1033
|
+
return r.reads = !0, f;
|
|
1034
|
+
}
|
|
1035
|
+
function ct(e, t) {
|
|
1036
|
+
let n = q(e, t);
|
|
1037
|
+
return re(e.callee, t.scope) ? (O(n, t), M) : i.isIdentifier(e.callee) && !S(e.callee, t.scope) && (A.has(e.callee.name) || Ee.has(e.callee.name)) ? (O(n, t), f) : (t.reads = !0, f);
|
|
1038
|
+
}
|
|
1039
|
+
function R(e, t, n, r) {
|
|
1040
|
+
let s = e.node;
|
|
1041
|
+
if (s.async || s.generator) {
|
|
1042
|
+
r.reads = !0;
|
|
1043
|
+
return;
|
|
1044
|
+
}
|
|
1045
|
+
let o = e.parentPath && e.parentPath.getFunctionParent(), a = null;
|
|
1046
|
+
for (let u = r; u !== null; u = u.outer)
|
|
1047
|
+
if (o && u.fn !== null && u.fn.node === o.node) {
|
|
1048
|
+
a = u;
|
|
1049
|
+
break;
|
|
1050
|
+
}
|
|
1051
|
+
r.edges.push(dt(e, t, n, a, r.importedIds));
|
|
1052
|
+
}
|
|
1053
|
+
var me = /* @__PURE__ */ new WeakMap();
|
|
1054
|
+
function dt(e, t, n, r, s) {
|
|
1055
|
+
let o = me.get(e.node);
|
|
1056
|
+
o || me.set(e.node, o = /* @__PURE__ */ new Map());
|
|
1057
|
+
let a = t.map(fe).join() + "|" + fe(n) + "|" + (r === null ? "" : N(r)), u = o.get(a);
|
|
1058
|
+
return u || o.set(a, u = { path: e, argKinds: t, thisKind: n, outer: r, importedIds: s, edges: null, direct: !1, reads: void 0 }), u;
|
|
1059
|
+
}
|
|
1060
|
+
function pt(e) {
|
|
1061
|
+
let t = e.path, n = G(t, e.outer, e.thisKind, t.scope, e.importedIds);
|
|
1062
|
+
t.node.params.forEach((s, o) => P(s, e.argKinds[o] ?? c, n)), t.node._whatMovedProps && P(t.node._whatMovedProps, e.argKinds[0] ?? c, n);
|
|
1063
|
+
let r = t.node.body;
|
|
1064
|
+
i.isBlockStatement(r) ? w(r, n) : p(r, n), e.direct = n.reads, e.edges = n.edges;
|
|
1065
|
+
}
|
|
1066
|
+
function w(e, t) {
|
|
1067
|
+
switch (e.type) {
|
|
1068
|
+
case "BlockStatement":
|
|
1069
|
+
for (let n of e.body) w(n, t);
|
|
1070
|
+
return;
|
|
1071
|
+
case "ExpressionStatement":
|
|
1072
|
+
p(e.expression, t);
|
|
1073
|
+
return;
|
|
1074
|
+
case "ReturnStatement":
|
|
1075
|
+
case "ThrowStatement":
|
|
1076
|
+
p(e.argument, t);
|
|
1077
|
+
return;
|
|
1078
|
+
case "VariableDeclaration":
|
|
1079
|
+
for (let n of e.declarations) {
|
|
1080
|
+
let r = p(n.init, t), s = t.scope;
|
|
1081
|
+
t.scope = Z.get(n)?.scope ?? s, P(n.id, n.init == null ? c : r, t), t.scope = s;
|
|
1082
|
+
}
|
|
1083
|
+
return;
|
|
1084
|
+
case "IfStatement":
|
|
1085
|
+
p(e.test, t), w(e.consequent, t), e.alternate && w(e.alternate, t);
|
|
1086
|
+
return;
|
|
1087
|
+
case "ForStatement":
|
|
1088
|
+
e.init && (i.isVariableDeclaration(e.init) ? w(e.init, t) : p(e.init, t)), p(e.test, t), p(e.update, t), w(e.body, t);
|
|
1089
|
+
return;
|
|
1090
|
+
case "ForOfStatement": {
|
|
1091
|
+
let n = p(e.right, t);
|
|
1092
|
+
$(n, t), e.await && (t.reads = !0);
|
|
1093
|
+
let r = i.isVariableDeclaration(e.left) ? e.left.declarations[0].id : e.left;
|
|
1094
|
+
P(r, n === E || n === c ? c : f, t), w(e.body, t);
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
case "ForInStatement": {
|
|
1098
|
+
p(e.right, t) === f && (t.reads = !0);
|
|
1099
|
+
let n = i.isVariableDeclaration(e.left) ? e.left.declarations[0].id : e.left;
|
|
1100
|
+
P(n, c, t), w(e.body, t);
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
case "WhileStatement":
|
|
1104
|
+
case "DoWhileStatement":
|
|
1105
|
+
p(e.test, t), w(e.body, t);
|
|
1106
|
+
return;
|
|
1107
|
+
case "SwitchStatement":
|
|
1108
|
+
p(e.discriminant, t);
|
|
1109
|
+
for (let n of e.cases) {
|
|
1110
|
+
n.test && p(n.test, t);
|
|
1111
|
+
for (let r of n.consequent) w(r, t);
|
|
1112
|
+
}
|
|
1113
|
+
return;
|
|
1114
|
+
case "TryStatement":
|
|
1115
|
+
w(e.block, t), e.handler && (e.handler.param && P(e.handler.param, f, t), w(e.handler.body, t)), e.finalizer && w(e.finalizer, t);
|
|
1116
|
+
return;
|
|
1117
|
+
case "LabeledStatement":
|
|
1118
|
+
w(e.body, t);
|
|
1119
|
+
return;
|
|
1120
|
+
case "FunctionDeclaration":
|
|
1121
|
+
case "EmptyStatement":
|
|
1122
|
+
case "BreakStatement":
|
|
1123
|
+
case "ContinueStatement":
|
|
1124
|
+
case "DebuggerStatement":
|
|
1125
|
+
return;
|
|
1126
|
+
default:
|
|
1127
|
+
t.reads = !0;
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
function mt(e) {
|
|
1131
|
+
if (e.reads !== void 0) return e.reads;
|
|
1132
|
+
let t = [e], n = [0], r = new Set(t), s = () => {
|
|
1133
|
+
for (let o of t) o.reads = !0;
|
|
1134
|
+
return !0;
|
|
1135
|
+
};
|
|
1136
|
+
for (; t.length > 0; ) {
|
|
1137
|
+
let o = t.length - 1, a = t[o];
|
|
1138
|
+
if (a.edges === null && pt(a), a.direct) return s();
|
|
1139
|
+
if (n[o] === a.edges.length) {
|
|
1140
|
+
t.pop(), n.pop();
|
|
1141
|
+
continue;
|
|
1142
|
+
}
|
|
1143
|
+
let u = a.edges[n[o]++];
|
|
1144
|
+
if (u.reads === !0) return s();
|
|
1145
|
+
u.reads === !1 || r.has(u) || (r.add(u), t.push(u), n.push(0));
|
|
1146
|
+
}
|
|
1147
|
+
for (let o of r) o.reads = !1;
|
|
1148
|
+
return !1;
|
|
1149
|
+
}
|
|
1150
|
+
function yt(e, t, n) {
|
|
1151
|
+
Y = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), e.traverse({
|
|
1152
|
+
ReferencedIdentifier(r) {
|
|
1153
|
+
r.isIdentifier() && Y.set(r.node, r.scope.getBinding(r.node.name) || null);
|
|
1154
|
+
},
|
|
1155
|
+
Function(r) {
|
|
1156
|
+
C.set(r.node, r);
|
|
1157
|
+
},
|
|
1158
|
+
VariableDeclarator(r) {
|
|
1159
|
+
Z.set(r.node, r);
|
|
1160
|
+
}
|
|
1161
|
+
}), L = /* @__PURE__ */ new WeakMap();
|
|
1162
|
+
try {
|
|
1163
|
+
for (let r of t) {
|
|
1164
|
+
let s = G(null, null, f, r.scope, n);
|
|
1165
|
+
p(r.node, s), v.set(r.node, ne(s));
|
|
1166
|
+
}
|
|
1167
|
+
} finally {
|
|
1168
|
+
L = null;
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
var L = null;
|
|
1172
|
+
function bt(e, t) {
|
|
1173
|
+
if (i.isCallExpression(e)) return e;
|
|
1174
|
+
if (i.isArrowFunctionExpression(e) && i.isExpression(e.body)) return e.body;
|
|
1175
|
+
let n = t.signalNames && t.signalNames.fromDestructuredProps, r = (a) => n && n.has(a) || t.importedIdentifiers && t.importedIdentifiers.has(a);
|
|
1176
|
+
if (i.isIdentifier(e))
|
|
1177
|
+
return r(e.name) ? J(e) : t.signalNames && I(e.name, t.signalNames) ? i.callExpression(e, []) : e;
|
|
1178
|
+
let s = ke(e), o = s && t.signalNames && t.signalNames.propsObjects && t.signalNames.propsObjects.has(s.name);
|
|
1179
|
+
return s && (r(s.name) || o) ? J(e) : e;
|
|
1180
|
+
}
|
|
1181
|
+
function _(e, t) {
|
|
1182
|
+
if (i.isConditionalExpression(e))
|
|
1183
|
+
return i.conditionalExpression(e.test, _(e.consequent, t), _(e.alternate, t));
|
|
1184
|
+
if (i.isLogicalExpression(e))
|
|
1185
|
+
return i.logicalExpression(e.operator, _(e.left, t), _(e.right, t));
|
|
1186
|
+
if (i.isIdentifier(e)) {
|
|
1187
|
+
if (e.name === "undefined") return e;
|
|
1188
|
+
let n = t.signalNames && t.signalNames.fromDestructuredProps;
|
|
1189
|
+
return t.signalNames && I(e.name, t.signalNames) && !(n && n.has(e.name)) && !(t.importedIdentifiers && t.importedIdentifiers.has(e.name)) ? i.callExpression(e, []) : J(e);
|
|
1190
|
+
}
|
|
1191
|
+
return ke(e) ? J(e) : e;
|
|
1192
|
+
}
|
|
1193
|
+
function ke(e) {
|
|
1194
|
+
if (!i.isMemberExpression(e)) return null;
|
|
1195
|
+
let t = e;
|
|
1196
|
+
for (; i.isMemberExpression(t); ) {
|
|
1197
|
+
if (t.computed || !i.isIdentifier(t.property)) return null;
|
|
1198
|
+
t = t.object;
|
|
1199
|
+
}
|
|
1200
|
+
return i.isIdentifier(t) ? t : null;
|
|
1201
|
+
}
|
|
1202
|
+
function J(e) {
|
|
1203
|
+
return i.conditionalExpression(
|
|
1204
|
+
i.binaryExpression("===", i.unaryExpression("typeof", e), i.stringLiteral("function")),
|
|
1205
|
+
i.callExpression(i.cloneNode(e), []),
|
|
1206
|
+
i.cloneNode(e)
|
|
1207
|
+
);
|
|
1208
|
+
}
|
|
1209
|
+
export {
|
|
1210
|
+
_ as buildEachValue,
|
|
1211
|
+
bt as buildWhenCondition,
|
|
1212
|
+
Et as collectSignalNamesFromScope,
|
|
1213
|
+
Te as isHookResultRead,
|
|
1214
|
+
h as isPotentiallyReactive,
|
|
1215
|
+
I as isSignalIdentifier,
|
|
1216
|
+
St as isUncertainReactive,
|
|
1217
|
+
yt as resolveCallees
|
|
1218
|
+
};
|