@nocobase/plugin-flow-engine 2.1.0-alpha.45 → 2.1.0-alpha.46

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.
Files changed (93) hide show
  1. package/dist/client/index.js +1 -1
  2. package/dist/externalVersion.js +9 -9
  3. package/dist/node_modules/@ant-design/icons-svg/package.json +1 -1
  4. package/dist/node_modules/acorn/package.json +1 -1
  5. package/dist/node_modules/acorn-jsx/package.json +1 -1
  6. package/dist/node_modules/acorn-walk/package.json +1 -1
  7. package/dist/node_modules/ses/package.json +1 -1
  8. package/dist/node_modules/zod/package.json +1 -1
  9. package/dist/server/flow-surfaces/apply/compiler.js +10 -11
  10. package/dist/server/flow-surfaces/authoring-validation.d.ts +1 -0
  11. package/dist/server/flow-surfaces/authoring-validation.js +773 -26
  12. package/dist/server/flow-surfaces/blueprint/normalize-document.js +5 -1
  13. package/dist/server/flow-surfaces/catalog.js +9 -5
  14. package/dist/server/flow-surfaces/chart-config.js +220 -16
  15. package/dist/server/flow-surfaces/contract-guard.js +40 -6
  16. package/dist/server/flow-surfaces/default-block-actions.js +2 -0
  17. package/dist/server/flow-surfaces/errors.d.ts +15 -0
  18. package/dist/server/flow-surfaces/errors.js +49 -3
  19. package/dist/server/flow-surfaces/event-flow-normalizer.d.ts +19 -0
  20. package/dist/server/flow-surfaces/event-flow-normalizer.js +128 -0
  21. package/dist/server/flow-surfaces/filter-group.d.ts +9 -1
  22. package/dist/server/flow-surfaces/filter-group.js +402 -3
  23. package/dist/server/flow-surfaces/public-data-surface-default-filter.js +2 -1
  24. package/dist/server/flow-surfaces/route-sync.js +19 -2
  25. package/dist/server/flow-surfaces/runjs-authoring/ast/bindings.d.ts +66 -0
  26. package/dist/server/flow-surfaces/runjs-authoring/ast/bindings.js +661 -0
  27. package/dist/server/flow-surfaces/runjs-authoring/ast/execution.d.ts +20 -0
  28. package/dist/server/flow-surfaces/runjs-authoring/ast/execution.js +275 -0
  29. package/dist/server/flow-surfaces/runjs-authoring/ast/parser.d.ts +16 -0
  30. package/dist/server/flow-surfaces/runjs-authoring/ast/parser.js +130 -0
  31. package/dist/server/flow-surfaces/runjs-authoring/ast/react-values.d.ts +20 -0
  32. package/dist/server/flow-surfaces/runjs-authoring/ast/react-values.js +401 -0
  33. package/dist/server/flow-surfaces/runjs-authoring/ast/request-config.d.ts +21 -0
  34. package/dist/server/flow-surfaces/runjs-authoring/ast/request-config.js +199 -0
  35. package/dist/server/flow-surfaces/runjs-authoring/ast/source.d.ts +70 -0
  36. package/dist/server/flow-surfaces/runjs-authoring/ast/source.js +895 -0
  37. package/dist/server/flow-surfaces/runjs-authoring/ast/static-bindings.d.ts +23 -0
  38. package/dist/server/flow-surfaces/runjs-authoring/ast/static-bindings.js +618 -0
  39. package/dist/server/flow-surfaces/runjs-authoring/ast/static-values.d.ts +196 -0
  40. package/dist/server/flow-surfaces/runjs-authoring/ast/static-values.js +1777 -0
  41. package/dist/server/flow-surfaces/runjs-authoring/ast/walk.d.ts +10 -0
  42. package/dist/server/flow-surfaces/runjs-authoring/ast/walk.js +55 -0
  43. package/dist/server/flow-surfaces/runjs-authoring/collectors.d.ts +12 -0
  44. package/dist/server/flow-surfaces/runjs-authoring/collectors.js +589 -0
  45. package/dist/server/flow-surfaces/runjs-authoring/index.d.ts +2 -25
  46. package/dist/server/flow-surfaces/runjs-authoring/index.js +5 -11138
  47. package/dist/server/flow-surfaces/runjs-authoring/inspect.d.ts +13 -0
  48. package/dist/server/flow-surfaces/runjs-authoring/inspect.js +149 -0
  49. package/dist/server/flow-surfaces/runjs-authoring/internal-types.d.ts +333 -0
  50. package/dist/server/flow-surfaces/runjs-authoring/internal-types.js +36 -0
  51. package/dist/server/flow-surfaces/runjs-authoring/rules.js +2 -0
  52. package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.d.ts +67 -0
  53. package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.js +757 -0
  54. package/dist/server/flow-surfaces/runjs-authoring/runtime/errors.d.ts +22 -0
  55. package/dist/server/flow-surfaces/runjs-authoring/runtime/errors.js +91 -0
  56. package/dist/server/flow-surfaces/runjs-authoring/runtime/source-budget.d.ts +16 -0
  57. package/dist/server/flow-surfaces/runjs-authoring/runtime/source-budget.js +115 -0
  58. package/dist/server/flow-surfaces/runjs-authoring/runtime/surface.d.ts +19 -0
  59. package/dist/server/flow-surfaces/runjs-authoring/runtime/surface.js +140 -0
  60. package/dist/server/flow-surfaces/runjs-authoring/runtime/types.d.ts +91 -0
  61. package/dist/server/flow-surfaces/runjs-authoring/runtime/types.js +24 -0
  62. package/dist/server/flow-surfaces/runjs-authoring/scan/ctx-api.d.ts +138 -0
  63. package/dist/server/flow-surfaces/runjs-authoring/scan/ctx-api.js +1779 -0
  64. package/dist/server/flow-surfaces/runjs-authoring/scan/filter.d.ts +10 -0
  65. package/dist/server/flow-surfaces/runjs-authoring/scan/filter.js +1583 -0
  66. package/dist/server/flow-surfaces/runjs-authoring/scan/index.d.ts +195 -0
  67. package/dist/server/flow-surfaces/runjs-authoring/scan/index.js +463 -0
  68. package/dist/server/flow-surfaces/runjs-authoring/scan/react-render.d.ts +48 -0
  69. package/dist/server/flow-surfaces/runjs-authoring/scan/react-render.js +379 -0
  70. package/dist/server/flow-surfaces/runjs-authoring/scan/react.d.ts +26 -0
  71. package/dist/server/flow-surfaces/runjs-authoring/scan/react.js +1441 -0
  72. package/dist/server/flow-surfaces/runjs-authoring/scan/resource.d.ts +23 -0
  73. package/dist/server/flow-surfaces/runjs-authoring/scan/resource.js +1427 -0
  74. package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.d.ts +91 -0
  75. package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.js +889 -0
  76. package/dist/server/flow-surfaces/runjs-authoring/types.d.ts +1 -1
  77. package/dist/server/flow-surfaces/runjs-authoring/unknown-global-stop/index.d.ts +10 -0
  78. package/dist/server/flow-surfaces/runjs-authoring/unknown-global-stop/index.js +40 -0
  79. package/dist/server/flow-surfaces/runjs-authoring/validators/index.d.ts +12 -0
  80. package/dist/server/flow-surfaces/runjs-authoring/validators/index.js +887 -0
  81. package/dist/server/flow-surfaces/service-helpers.d.ts +29 -0
  82. package/dist/server/flow-surfaces/service-helpers.js +105 -0
  83. package/dist/server/flow-surfaces/service-utils.d.ts +15 -3
  84. package/dist/server/flow-surfaces/service-utils.js +6 -5
  85. package/dist/server/flow-surfaces/service.d.ts +7 -1
  86. package/dist/server/flow-surfaces/service.js +488 -94
  87. package/dist/server/flow-surfaces/types.d.ts +3 -0
  88. package/dist/server/repository.d.ts +12 -1
  89. package/dist/server/repository.js +195 -23
  90. package/dist/swagger/flow-surfaces.d.ts +175 -0
  91. package/dist/swagger/flow-surfaces.js +130 -51
  92. package/dist/swagger/index.d.ts +175 -0
  93. package/package.json +2 -2
@@ -0,0 +1,1441 @@
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 react_exports = {};
28
+ __export(react_exports, {
29
+ collectAstInvalidReactRuntimeBindingsFromAst: () => collectAstInvalidReactRuntimeBindingsFromAst,
30
+ collectAstReactAsyncComponentReferences: () => collectAstReactAsyncComponentReferences,
31
+ collectReactAsyncComponentBindingsFromAst: () => collectReactAsyncComponentBindingsFromAst,
32
+ collectReactCreateElementAliasesFromAst: () => collectReactCreateElementAliasesFromAst,
33
+ collectReactDefaultAliasesFromAst: () => collectReactDefaultAliasesFromAst,
34
+ collectReactDefaultCarrierAliasesFromAst: () => collectReactDefaultCarrierAliasesFromAst,
35
+ collectReactNamespaceAliasesFromAst: () => collectReactNamespaceAliasesFromAst,
36
+ collectReactNamespaceCarrierAliasesFromAst: () => collectReactNamespaceCarrierAliasesFromAst,
37
+ getAstNestedCarrierMemberName: () => getAstNestedCarrierMemberName,
38
+ getReactCreateElementCallCapabilityFromAst: () => getReactCreateElementCallCapabilityFromAst,
39
+ getReactCreateElementCapabilityFromAst: () => getReactCreateElementCapabilityFromAst,
40
+ isAstAsyncFunctionLike: () => isAstAsyncFunctionLike,
41
+ resolveAstAsyncComponentBinding: () => resolveAstAsyncComponentBinding
42
+ });
43
+ module.exports = __toCommonJS(react_exports);
44
+ var import_walk = require("../ast/walk");
45
+ var import_bindings = require("../ast/bindings");
46
+ var import_execution = require("../ast/execution");
47
+ var import_static_values = require("../ast/static-values");
48
+ var import_react_values = require("../ast/react-values");
49
+ function collectReactCreateElementAliasesFromAst(ast, source, identifierBindings, namespaceAliases, ctxRootAliases) {
50
+ const aliases = [];
51
+ const addAlias = (name, capability, node, ancestors, isVar = false) => {
52
+ const scope = (0, import_bindings.getAstBindingScopeRange)(ancestors, source.length, isVar);
53
+ aliases.push({
54
+ capability,
55
+ name,
56
+ declarationStart: typeof node.start === "number" ? node.start : scope.start,
57
+ start: typeof node.start === "number" ? node.start : scope.start,
58
+ end: scope.end
59
+ });
60
+ };
61
+ (0, import_walk.walkAstAncestor)(ast, {
62
+ AssignmentExpression(node, ancestors) {
63
+ var _a;
64
+ if (node.operator !== "=" || ((_a = node.left) == null ? void 0 : _a.type) !== "Identifier") {
65
+ return;
66
+ }
67
+ const capability = getReactCreateElementCapabilityFromAst(
68
+ node.right,
69
+ identifierBindings,
70
+ namespaceAliases,
71
+ ctxRootAliases
72
+ );
73
+ if (capability) {
74
+ addAlias(node.left.name, capability, node, ancestors);
75
+ }
76
+ },
77
+ VariableDeclarator(node, ancestors) {
78
+ var _a, _b;
79
+ const declaration = (0, import_bindings.findAstAncestor)(ancestors, "VariableDeclaration");
80
+ const isVar = (declaration == null ? void 0 : declaration.kind) === "var";
81
+ if (((_a = node.id) == null ? void 0 : _a.type) === "Identifier") {
82
+ const capability = getReactCreateElementCapabilityFromAst(
83
+ node.init,
84
+ identifierBindings,
85
+ namespaceAliases,
86
+ ctxRootAliases
87
+ );
88
+ if (capability) {
89
+ addAlias(node.id.name, capability, node, ancestors, isVar);
90
+ }
91
+ return;
92
+ }
93
+ if (((_b = node.id) == null ? void 0 : _b.type) === "ObjectPattern" && (0, import_react_values.getReactNamespaceCapabilityFromAst)(node.init, identifierBindings, namespaceAliases, ctxRootAliases)) {
94
+ const namespace = (0, import_react_values.getReactNamespaceCapabilityFromAst)(
95
+ node.init,
96
+ identifierBindings,
97
+ namespaceAliases,
98
+ ctxRootAliases
99
+ );
100
+ (0, import_static_values.collectAstObjectPatternAliases)(node.id, (name, member, aliasNode) => {
101
+ if (member === "createElement") {
102
+ addAlias(name, `${namespace}.createElement`, aliasNode || node, ancestors, isVar);
103
+ }
104
+ });
105
+ }
106
+ }
107
+ });
108
+ return aliases;
109
+ }
110
+ function collectReactNamespaceAliasesFromAst(ast, source, identifierBindings, ctxRootAliases) {
111
+ const aliases = [];
112
+ const writes = (0, import_execution.collectAstIdentifierWritesFromAst)(ast, source);
113
+ const addAlias = (name, capability, node, ancestors, isVar = false, scopeOverride, precedenceStart) => {
114
+ const scope = scopeOverride || (0, import_bindings.getAstBindingScopeRange)(ancestors, source.length, isVar);
115
+ aliases.push({
116
+ capability,
117
+ name,
118
+ declarationStart: typeof node.start === "number" ? node.start : scope.start,
119
+ executionScope: (0, import_bindings.getAstExecutionScopeRange)(ancestors, source.length),
120
+ start: typeof node.start === "number" ? node.start : scope.start,
121
+ end: scope.end,
122
+ ...typeof precedenceStart === "number" ? { precedenceStart } : {}
123
+ });
124
+ };
125
+ const getActiveAliases = () => (0, import_static_values.trimAstAliasesAfterWrites)(aliases, writes, identifierBindings);
126
+ (0, import_walk.walkAstAncestor)(ast, {
127
+ AssignmentExpression(node, ancestors) {
128
+ var _a, _b, _c, _d;
129
+ if (!(0, import_static_values.isAstCtxApiAliasAssignmentOperator)(node.operator)) {
130
+ return;
131
+ }
132
+ const activeAliases = getActiveAliases();
133
+ const capability = (0, import_react_values.getReactNamespaceCapabilityFromAst)(
134
+ node.right,
135
+ identifierBindings,
136
+ activeAliases,
137
+ ctxRootAliases
138
+ );
139
+ if (((_a = node.left) == null ? void 0 : _a.type) === "Identifier" && capability) {
140
+ addAlias(
141
+ node.left.name,
142
+ capability,
143
+ node,
144
+ ancestors,
145
+ false,
146
+ (0, import_static_values.getAstAssignmentTargetScope)(node.left, ancestors, source.length, identifierBindings)
147
+ );
148
+ return;
149
+ }
150
+ if (((_b = node.left) == null ? void 0 : _b.type) === "MemberExpression" && capability) {
151
+ const memberAlias = (0, import_static_values.getAstMemberAliasLookup)(node.left);
152
+ if (memberAlias) {
153
+ addAlias(
154
+ memberAlias.aliasName,
155
+ capability,
156
+ node.left,
157
+ ancestors,
158
+ false,
159
+ (0, import_static_values.getAstMemberAssignmentTargetScope)(node.left, ancestors, source.length, identifierBindings)
160
+ );
161
+ }
162
+ return;
163
+ }
164
+ if (((_c = node.left) == null ? void 0 : _c.type) === "Identifier") {
165
+ collectReactNamespaceCarrierAliasesFromAst(
166
+ node.left.name,
167
+ node.right,
168
+ identifierBindings,
169
+ activeAliases,
170
+ ctxRootAliases,
171
+ (member, capability2, aliasNode, precedenceStart) => {
172
+ addAlias(
173
+ `${node.left.name}.${member}`,
174
+ capability2,
175
+ aliasNode || node,
176
+ ancestors,
177
+ false,
178
+ (0, import_static_values.getAstAssignmentTargetScope)(node.left, ancestors, source.length, identifierBindings),
179
+ precedenceStart
180
+ );
181
+ }
182
+ );
183
+ }
184
+ if (node.operator === "=" && ((_d = node.left) == null ? void 0 : _d.type) === "ObjectPattern" && (0, import_static_values.isCtxRootFromAst)(node.right, ctxRootAliases, identifierBindings)) {
185
+ (0, import_static_values.collectAstObjectPatternPathAliases)(node.left, (alias, members, aliasNode) => {
186
+ if (members.length === 1 && members[0] === "React") {
187
+ addAlias(
188
+ alias,
189
+ "ctx.React",
190
+ aliasNode || node,
191
+ ancestors,
192
+ false,
193
+ (0, import_static_values.getAstAssignmentTargetScope)(aliasNode, ancestors, source.length, identifierBindings)
194
+ );
195
+ }
196
+ });
197
+ }
198
+ if (node.operator === "=") {
199
+ collectReactNamespacePatternSourceAliasesFromAst(node.left, node.right, ancestors, false);
200
+ collectReactNamespacePatternDefaultAliasesFromAst(node.left, ancestors, false, void 0, node.right);
201
+ }
202
+ },
203
+ ForOfStatement(node, ancestors) {
204
+ var _a;
205
+ const target = (0, import_execution.getAstLoopPatternTarget)(node.left);
206
+ if (!target) {
207
+ return;
208
+ }
209
+ const isVar = ((_a = node.left) == null ? void 0 : _a.type) === "VariableDeclaration" && node.left.kind === "var";
210
+ const activeAliases = getActiveAliases();
211
+ (0, import_execution.collectAstForOfSourceTargets)(node.right, activeAliases, identifierBindings, (loopSourceTarget) => {
212
+ collectReactNamespacePatternSourceTargetAliasesFromAst(target, loopSourceTarget, ancestors, isVar);
213
+ collectReactNamespacePatternDefaultAliasesFromSourceTarget(
214
+ target,
215
+ ancestors,
216
+ isVar,
217
+ void 0,
218
+ loopSourceTarget
219
+ );
220
+ });
221
+ },
222
+ VariableDeclarator(node, ancestors) {
223
+ var _a, _b;
224
+ const activeAliases = getActiveAliases();
225
+ if ((0, import_execution.isAstForOfLoopVariableDeclaratorWithSourceTargets)(node, ancestors, activeAliases, identifierBindings)) {
226
+ return;
227
+ }
228
+ const declaration = (0, import_bindings.findAstAncestor)(ancestors, "VariableDeclaration");
229
+ const isVar = (declaration == null ? void 0 : declaration.kind) === "var";
230
+ if (((_a = node.id) == null ? void 0 : _a.type) === "Identifier") {
231
+ const capability = (0, import_react_values.getReactNamespaceCapabilityFromAst)(
232
+ node.init,
233
+ identifierBindings,
234
+ activeAliases,
235
+ ctxRootAliases
236
+ );
237
+ if (capability) {
238
+ addAlias(node.id.name, capability, node, ancestors, isVar);
239
+ }
240
+ collectReactNamespaceCarrierAliasesFromAst(
241
+ node.id.name,
242
+ node.init,
243
+ identifierBindings,
244
+ activeAliases,
245
+ ctxRootAliases,
246
+ (member, memberCapability, aliasNode, precedenceStart) => {
247
+ addAlias(
248
+ `${node.id.name}.${member}`,
249
+ memberCapability,
250
+ aliasNode || node,
251
+ ancestors,
252
+ isVar,
253
+ void 0,
254
+ precedenceStart
255
+ );
256
+ }
257
+ );
258
+ collectReactNamespacePatternSourceAliasesFromAst(node.id, node.init, ancestors, isVar);
259
+ return;
260
+ }
261
+ if (((_b = node.id) == null ? void 0 : _b.type) === "ObjectPattern" && (0, import_static_values.isCtxRootFromAst)(node.init, ctxRootAliases, identifierBindings)) {
262
+ (0, import_static_values.collectAstObjectPatternPathAliases)(node.id, (alias, members, aliasNode) => {
263
+ if (members.length === 1 && members[0] === "React") {
264
+ addAlias(alias, "ctx.React", aliasNode || node, ancestors, isVar);
265
+ }
266
+ });
267
+ }
268
+ collectReactNamespacePatternSourceAliasesFromAst(node.id, node.init, ancestors, isVar);
269
+ collectReactNamespacePatternDefaultAliasesFromAst(node.id, ancestors, isVar, void 0, node.init);
270
+ },
271
+ FunctionDeclaration(node, ancestors) {
272
+ collectReactNamespaceFunctionParamAliasesFromAst(node, ancestors);
273
+ },
274
+ FunctionExpression(node, ancestors) {
275
+ collectReactNamespaceFunctionParamAliasesFromAst(node, ancestors);
276
+ },
277
+ ArrowFunctionExpression(node, ancestors) {
278
+ collectReactNamespaceFunctionParamAliasesFromAst(node, ancestors);
279
+ }
280
+ });
281
+ return (0, import_static_values.trimAstAliasesAfterWrites)(aliases, writes, identifierBindings);
282
+ function collectReactNamespaceFunctionParamAliasesFromAst(node, ancestors) {
283
+ var _a, _b;
284
+ const scope = {
285
+ start: typeof node.start === "number" ? node.start : 0,
286
+ end: typeof node.end === "number" ? node.end : source.length
287
+ };
288
+ const activeAliases = getActiveAliases();
289
+ for (const param of node.params || []) {
290
+ if ((param == null ? void 0 : param.type) !== "AssignmentPattern") {
291
+ collectReactNamespacePatternDefaultAliasesFromAst(param, ancestors, false, scope);
292
+ continue;
293
+ }
294
+ collectReactNamespacePatternDefaultAliasesFromAst(param.left, ancestors, false, scope, param.right);
295
+ collectReactNamespacePatternSourceAliasesFromAst(param.left, param.right, ancestors, false, scope);
296
+ if (((_a = param.left) == null ? void 0 : _a.type) === "Identifier") {
297
+ const capability = (0, import_react_values.getReactNamespaceCapabilityFromAst)(
298
+ param.right,
299
+ identifierBindings,
300
+ activeAliases,
301
+ ctxRootAliases
302
+ );
303
+ if (capability) {
304
+ addAlias(param.left.name, capability, param.left, ancestors, false, scope);
305
+ }
306
+ continue;
307
+ }
308
+ if (((_b = param.left) == null ? void 0 : _b.type) === "ObjectPattern" && (0, import_static_values.isCtxRootFromAst)(param.right, ctxRootAliases, identifierBindings)) {
309
+ (0, import_static_values.collectAstObjectPatternPathAliases)(param.left, (alias, members, aliasNode) => {
310
+ if (members.length === 1 && members[0] === "React") {
311
+ addAlias(alias, "ctx.React", aliasNode || param, ancestors, false, scope);
312
+ }
313
+ });
314
+ }
315
+ }
316
+ }
317
+ function collectReactNamespacePatternSourceAliasesFromAst(pattern, sourceNode, ancestors, isVar = false, scopeOverride) {
318
+ collectReactNamespacePatternSourceTargetAliasesFromAst(
319
+ pattern,
320
+ (0, import_static_values.createAstPatternSourceTarget)(sourceNode),
321
+ ancestors,
322
+ isVar,
323
+ scopeOverride
324
+ );
325
+ }
326
+ function collectReactNamespacePatternSourceTargetAliasesFromAst(pattern, sourceTarget, ancestors, isVar = false, scopeOverride) {
327
+ const activeAliases = getActiveAliases();
328
+ (0, import_static_values.collectAstPatternSourceTargetsRec)(pattern, sourceTarget, (target, patternSourceTarget) => {
329
+ const capability = (0, import_react_values.getReactNamespaceCapabilityFromAstPatternSource)(
330
+ patternSourceTarget,
331
+ identifierBindings,
332
+ activeAliases,
333
+ ctxRootAliases
334
+ );
335
+ if (!capability) {
336
+ return;
337
+ }
338
+ addReactNamespaceAliasTarget(target, capability, ancestors, isVar, scopeOverride);
339
+ });
340
+ const collectCarrierTarget = (carrierTarget) => {
341
+ var _a, _b;
342
+ if (carrierTarget.sourceAlias) {
343
+ const precedenceStart = (0, import_static_values.getAstAliasPrecedenceStart)(carrierTarget.sourceAlias);
344
+ addReactNamespaceAliasByName(
345
+ carrierTarget.targetAliasName,
346
+ carrierTarget.sourceAlias.capability,
347
+ carrierTarget.target,
348
+ ancestors,
349
+ isVar,
350
+ scopeOverride,
351
+ (_a = carrierTarget.sourceTarget) == null ? void 0 : _a.node,
352
+ precedenceStart
353
+ );
354
+ return;
355
+ }
356
+ const capability = (0, import_react_values.getReactNamespaceCapabilityFromAstPatternSource)(
357
+ carrierTarget.sourceTarget,
358
+ identifierBindings,
359
+ activeAliases,
360
+ ctxRootAliases
361
+ );
362
+ if (!capability) {
363
+ return;
364
+ }
365
+ addReactNamespaceAliasByName(
366
+ carrierTarget.targetAliasName,
367
+ capability,
368
+ carrierTarget.target,
369
+ ancestors,
370
+ isVar,
371
+ scopeOverride,
372
+ (_b = carrierTarget.sourceTarget) == null ? void 0 : _b.node
373
+ );
374
+ };
375
+ (0, import_static_values.collectAstPatternCarrierSourceTargetsFromSourceTarget)(
376
+ pattern,
377
+ sourceTarget,
378
+ activeAliases,
379
+ identifierBindings,
380
+ collectCarrierTarget
381
+ );
382
+ (0, import_static_values.collectAstPatternRestCarrierSourceTargetsRec)(
383
+ pattern,
384
+ sourceTarget,
385
+ activeAliases,
386
+ identifierBindings,
387
+ collectCarrierTarget
388
+ );
389
+ }
390
+ function collectReactNamespacePatternDefaultAliasesFromAst(pattern, ancestors, isVar = false, scopeOverride, sourceNode) {
391
+ collectReactNamespacePatternDefaultAliasesFromSourceTarget(
392
+ pattern,
393
+ ancestors,
394
+ isVar,
395
+ scopeOverride,
396
+ (0, import_static_values.createMaybeAstPatternSourceTarget)(sourceNode)
397
+ );
398
+ }
399
+ function collectReactNamespacePatternDefaultAliasesFromSourceTarget(pattern, ancestors, isVar = false, scopeOverride, sourceTarget) {
400
+ (0, import_static_values.collectAstPatternDefaultValueAliasesWithSource)(
401
+ pattern,
402
+ sourceTarget,
403
+ (alias, valueNode, aliasNode, defaultPattern, sourceTarget2) => {
404
+ if ((0, import_react_values.isAstPatternDefaultValueSuppressedByReactNamespace)(sourceTarget2, identifierBindings, aliases, ctxRootAliases)) {
405
+ return;
406
+ }
407
+ const activeAliases = getActiveAliases();
408
+ const capability = (0, import_react_values.getReactNamespaceCapabilityFromAst)(
409
+ valueNode,
410
+ identifierBindings,
411
+ activeAliases,
412
+ ctxRootAliases
413
+ );
414
+ if (capability && (defaultPattern == null ? void 0 : defaultPattern.type) === "Identifier") {
415
+ addAlias(alias, capability, aliasNode || defaultPattern, ancestors, isVar, scopeOverride);
416
+ }
417
+ if ((defaultPattern == null ? void 0 : defaultPattern.type) === "Identifier") {
418
+ collectReactNamespaceCarrierAliasesFromAst(
419
+ alias,
420
+ valueNode,
421
+ identifierBindings,
422
+ activeAliases,
423
+ ctxRootAliases,
424
+ (member, memberCapability, memberAliasNode, precedenceStart) => {
425
+ addAlias(
426
+ `${alias}.${member}`,
427
+ memberCapability,
428
+ memberAliasNode || aliasNode || defaultPattern,
429
+ ancestors,
430
+ isVar,
431
+ scopeOverride,
432
+ precedenceStart
433
+ );
434
+ }
435
+ );
436
+ }
437
+ if ((defaultPattern == null ? void 0 : defaultPattern.type) === "ObjectPattern" && (0, import_static_values.isCtxRootFromAst)(valueNode, ctxRootAliases, identifierBindings)) {
438
+ (0, import_static_values.collectAstObjectPatternPathAliases)(defaultPattern, (pathAlias, members, pathAliasNode) => {
439
+ if (members.length === 1 && members[0] === "React") {
440
+ addAlias(
441
+ pathAlias,
442
+ "ctx.React",
443
+ pathAliasNode || aliasNode || defaultPattern,
444
+ ancestors,
445
+ isVar,
446
+ scopeOverride
447
+ );
448
+ }
449
+ });
450
+ }
451
+ }
452
+ );
453
+ }
454
+ function addReactNamespaceAliasTarget(target, capability, ancestors, isVar = false, scopeOverride) {
455
+ const unwrapped = (0, import_bindings.unwrapAstChainExpression)(target);
456
+ if ((unwrapped == null ? void 0 : unwrapped.type) === "Identifier") {
457
+ addAlias(
458
+ unwrapped.name,
459
+ capability,
460
+ unwrapped,
461
+ ancestors,
462
+ isVar,
463
+ scopeOverride || (0, import_static_values.getAstAssignmentTargetScope)(unwrapped, ancestors, source.length, identifierBindings)
464
+ );
465
+ return;
466
+ }
467
+ if ((unwrapped == null ? void 0 : unwrapped.type) === "MemberExpression") {
468
+ const memberAlias = (0, import_static_values.getAstMemberAliasLookup)(unwrapped);
469
+ if (!memberAlias) {
470
+ return;
471
+ }
472
+ addAlias(
473
+ memberAlias.aliasName,
474
+ capability,
475
+ unwrapped,
476
+ ancestors,
477
+ false,
478
+ scopeOverride || (0, import_static_values.getAstMemberAssignmentTargetScope)(unwrapped, ancestors, source.length, identifierBindings)
479
+ );
480
+ }
481
+ }
482
+ function addReactNamespaceAliasByName(name, capability, target, ancestors, isVar = false, scopeOverride, aliasNode, precedenceStart) {
483
+ const unwrapped = (0, import_bindings.unwrapAstChainExpression)(target);
484
+ const scope = scopeOverride || ((unwrapped == null ? void 0 : unwrapped.type) === "MemberExpression" ? (0, import_static_values.getAstMemberAssignmentTargetScope)(unwrapped, ancestors, source.length, identifierBindings) : (0, import_static_values.getAstAssignmentTargetScope)(unwrapped, ancestors, source.length, identifierBindings));
485
+ addAlias(
486
+ name,
487
+ capability,
488
+ (0, import_bindings.unwrapAstChainExpression)(aliasNode) || aliasNode || unwrapped || target,
489
+ ancestors,
490
+ isVar,
491
+ scope,
492
+ precedenceStart
493
+ );
494
+ }
495
+ }
496
+ function collectReactDefaultAliasesFromAst(ast, source, identifierBindings, namespaceAliases, ctxRootAliases) {
497
+ const aliases = [];
498
+ const writes = (0, import_execution.collectAstIdentifierWritesFromAst)(ast, source);
499
+ const addAlias = (name, capability, node, ancestors, isVar = false, scopeOverride, precedenceStart) => {
500
+ const scope = scopeOverride || (0, import_bindings.getAstBindingScopeRange)(ancestors, source.length, isVar);
501
+ aliases.push({
502
+ capability,
503
+ name,
504
+ declarationStart: typeof node.start === "number" ? node.start : scope.start,
505
+ executionScope: (0, import_bindings.getAstExecutionScopeRange)(ancestors, source.length),
506
+ start: typeof node.start === "number" ? node.start : scope.start,
507
+ end: scope.end,
508
+ ...typeof precedenceStart === "number" ? { precedenceStart } : {}
509
+ });
510
+ };
511
+ const getActiveAliases = () => (0, import_static_values.trimAstAliasesAfterWrites)(aliases, writes, identifierBindings);
512
+ (0, import_walk.walkAstAncestor)(ast, {
513
+ AssignmentExpression(node, ancestors) {
514
+ var _a, _b, _c, _d;
515
+ if (!(0, import_static_values.isAstCtxApiAliasAssignmentOperator)(node.operator)) {
516
+ return;
517
+ }
518
+ const activeAliases = getActiveAliases();
519
+ if (((_a = node.left) == null ? void 0 : _a.type) === "Identifier") {
520
+ const capability = (0, import_react_values.getReactDefaultNamespaceCapabilityFromAst)(
521
+ node.right,
522
+ identifierBindings,
523
+ namespaceAliases,
524
+ ctxRootAliases,
525
+ activeAliases
526
+ );
527
+ if (capability) {
528
+ addAlias(
529
+ node.left.name,
530
+ capability,
531
+ node,
532
+ ancestors,
533
+ false,
534
+ (0, import_static_values.getAstAssignmentTargetScope)(node.left, ancestors, source.length, identifierBindings)
535
+ );
536
+ }
537
+ collectReactDefaultCarrierAliasesFromAst(
538
+ node.left.name,
539
+ node.right,
540
+ identifierBindings,
541
+ namespaceAliases,
542
+ ctxRootAliases,
543
+ activeAliases,
544
+ (member, capability2, aliasNode, precedenceStart) => {
545
+ addAlias(
546
+ `${node.left.name}.${member}`,
547
+ capability2,
548
+ aliasNode || node,
549
+ ancestors,
550
+ false,
551
+ (0, import_static_values.getAstAssignmentTargetScope)(node.left, ancestors, source.length, identifierBindings),
552
+ precedenceStart
553
+ );
554
+ }
555
+ );
556
+ return;
557
+ }
558
+ const memberAlias = (0, import_static_values.getAstMemberAliasLookup)(node.left);
559
+ if (((_b = node.left) == null ? void 0 : _b.type) === "MemberExpression" && memberAlias) {
560
+ const capability = (0, import_react_values.getReactDefaultNamespaceCapabilityFromAst)(
561
+ node.right,
562
+ identifierBindings,
563
+ namespaceAliases,
564
+ ctxRootAliases,
565
+ activeAliases
566
+ );
567
+ if (capability) {
568
+ addAlias(
569
+ memberAlias.aliasName,
570
+ capability,
571
+ node.left,
572
+ ancestors,
573
+ false,
574
+ (0, import_static_values.getAstMemberAssignmentTargetScope)(node.left, ancestors, source.length, identifierBindings)
575
+ );
576
+ }
577
+ }
578
+ if (((_c = node.left) == null ? void 0 : _c.type) === "ObjectPattern" && (0, import_react_values.getReactNamespaceCapabilityFromAst)(node.right, identifierBindings, namespaceAliases, ctxRootAliases)) {
579
+ const namespace = (0, import_react_values.getReactNamespaceCapabilityFromAst)(
580
+ node.right,
581
+ identifierBindings,
582
+ namespaceAliases,
583
+ ctxRootAliases
584
+ );
585
+ (0, import_static_values.collectAstObjectPatternPathAliases)(node.left, (alias, members, aliasNode) => {
586
+ if (members.length === 1 && members[0] === "default") {
587
+ addAlias(
588
+ alias,
589
+ `${namespace}.default`,
590
+ aliasNode || node,
591
+ ancestors,
592
+ false,
593
+ (0, import_static_values.getAstAssignmentTargetScope)(aliasNode, ancestors, source.length, identifierBindings)
594
+ );
595
+ }
596
+ });
597
+ }
598
+ if (((_d = node.left) == null ? void 0 : _d.type) === "ObjectPattern" && (0, import_static_values.isCtxRootFromAst)(node.right, ctxRootAliases, identifierBindings)) {
599
+ (0, import_static_values.collectAstObjectPatternPathAliases)(node.left, (alias, members, aliasNode) => {
600
+ if (members.length === 2 && members[0] === "React" && members[1] === "default") {
601
+ addAlias(
602
+ alias,
603
+ "ctx.React.default",
604
+ aliasNode || node,
605
+ ancestors,
606
+ false,
607
+ (0, import_static_values.getAstAssignmentTargetScope)(aliasNode, ancestors, source.length, identifierBindings)
608
+ );
609
+ }
610
+ });
611
+ }
612
+ if (node.operator === "=") {
613
+ collectReactDefaultPatternSourceAliasesFromAst(node.left, node.right, ancestors, false);
614
+ collectReactDefaultPatternDefaultAliasesFromAst(node.left, ancestors, false, void 0, node.right);
615
+ }
616
+ },
617
+ ForOfStatement(node, ancestors) {
618
+ var _a;
619
+ const target = (0, import_execution.getAstLoopPatternTarget)(node.left);
620
+ if (!target) {
621
+ return;
622
+ }
623
+ const isVar = ((_a = node.left) == null ? void 0 : _a.type) === "VariableDeclaration" && node.left.kind === "var";
624
+ const activeAliases = getActiveAliases();
625
+ const sourceTargetAliases = [...namespaceAliases, ...activeAliases];
626
+ (0, import_execution.collectAstForOfSourceTargets)(node.right, sourceTargetAliases, identifierBindings, (loopSourceTarget) => {
627
+ collectReactDefaultPatternSourceTargetAliasesFromAst(target, loopSourceTarget, ancestors, isVar);
628
+ collectReactDefaultPatternDefaultAliasesFromSourceTarget(target, ancestors, isVar, void 0, loopSourceTarget);
629
+ });
630
+ },
631
+ VariableDeclarator(node, ancestors) {
632
+ var _a, _b, _c;
633
+ const activeAliases = getActiveAliases();
634
+ const sourceTargetAliases = [...namespaceAliases, ...activeAliases];
635
+ if ((0, import_execution.isAstForOfLoopVariableDeclaratorWithSourceTargets)(node, ancestors, sourceTargetAliases, identifierBindings)) {
636
+ return;
637
+ }
638
+ const declaration = (0, import_bindings.findAstAncestor)(ancestors, "VariableDeclaration");
639
+ const isVar = (declaration == null ? void 0 : declaration.kind) === "var";
640
+ if (((_a = node.id) == null ? void 0 : _a.type) === "Identifier") {
641
+ const capability = (0, import_react_values.getReactDefaultNamespaceCapabilityFromAst)(
642
+ node.init,
643
+ identifierBindings,
644
+ namespaceAliases,
645
+ ctxRootAliases,
646
+ getActiveAliases()
647
+ );
648
+ if (capability) {
649
+ addAlias(node.id.name, capability, node, ancestors, isVar);
650
+ }
651
+ collectReactDefaultCarrierAliasesFromAst(
652
+ node.id.name,
653
+ node.init,
654
+ identifierBindings,
655
+ namespaceAliases,
656
+ ctxRootAliases,
657
+ getActiveAliases(),
658
+ (member, memberCapability, aliasNode, precedenceStart) => {
659
+ addAlias(
660
+ `${node.id.name}.${member}`,
661
+ memberCapability,
662
+ aliasNode || node,
663
+ ancestors,
664
+ isVar,
665
+ void 0,
666
+ precedenceStart
667
+ );
668
+ }
669
+ );
670
+ collectReactDefaultPatternSourceAliasesFromAst(node.id, node.init, ancestors, isVar);
671
+ return;
672
+ }
673
+ if (((_b = node.id) == null ? void 0 : _b.type) === "ObjectPattern" && (0, import_react_values.getReactNamespaceCapabilityFromAst)(node.init, identifierBindings, namespaceAliases, ctxRootAliases)) {
674
+ const namespace = (0, import_react_values.getReactNamespaceCapabilityFromAst)(
675
+ node.init,
676
+ identifierBindings,
677
+ namespaceAliases,
678
+ ctxRootAliases
679
+ );
680
+ (0, import_static_values.collectAstObjectPatternPathAliases)(node.id, (alias, members, aliasNode) => {
681
+ if (members.length === 1 && members[0] === "default") {
682
+ addAlias(alias, `${namespace}.default`, aliasNode || node, ancestors, isVar);
683
+ }
684
+ });
685
+ collectReactDefaultPatternSourceAliasesFromAst(node.id, node.init, ancestors, isVar);
686
+ return;
687
+ }
688
+ if (((_c = node.id) == null ? void 0 : _c.type) === "ObjectPattern" && (0, import_static_values.isCtxRootFromAst)(node.init, ctxRootAliases, identifierBindings)) {
689
+ (0, import_static_values.collectAstObjectPatternPathAliases)(node.id, (alias, members, aliasNode) => {
690
+ if (members.length === 2 && members[0] === "React" && members[1] === "default") {
691
+ addAlias(alias, "ctx.React.default", aliasNode || node, ancestors, isVar);
692
+ }
693
+ });
694
+ }
695
+ collectReactDefaultPatternSourceAliasesFromAst(node.id, node.init, ancestors, isVar);
696
+ collectReactDefaultPatternDefaultAliasesFromAst(node.id, ancestors, isVar, void 0, node.init);
697
+ },
698
+ FunctionDeclaration(node, ancestors) {
699
+ collectReactDefaultFunctionParamAliasesFromAst(node, ancestors);
700
+ },
701
+ FunctionExpression(node, ancestors) {
702
+ collectReactDefaultFunctionParamAliasesFromAst(node, ancestors);
703
+ },
704
+ ArrowFunctionExpression(node, ancestors) {
705
+ collectReactDefaultFunctionParamAliasesFromAst(node, ancestors);
706
+ }
707
+ });
708
+ return (0, import_static_values.trimAstAliasesAfterWrites)(aliases, writes, identifierBindings);
709
+ function collectReactDefaultFunctionParamAliasesFromAst(node, ancestors) {
710
+ var _a, _b;
711
+ const scope = {
712
+ start: typeof node.start === "number" ? node.start : 0,
713
+ end: typeof node.end === "number" ? node.end : source.length
714
+ };
715
+ const activeAliases = getActiveAliases();
716
+ for (const param of node.params || []) {
717
+ if ((param == null ? void 0 : param.type) !== "AssignmentPattern") {
718
+ collectReactDefaultPatternDefaultAliasesFromAst(param, ancestors, false, scope);
719
+ continue;
720
+ }
721
+ collectReactDefaultPatternDefaultAliasesFromAst(param.left, ancestors, false, scope, param.right);
722
+ collectReactDefaultPatternSourceAliasesFromAst(param.left, param.right, ancestors, false, scope);
723
+ if (((_a = param.left) == null ? void 0 : _a.type) === "Identifier") {
724
+ const capability = (0, import_react_values.getReactDefaultNamespaceCapabilityFromAst)(
725
+ param.right,
726
+ identifierBindings,
727
+ namespaceAliases,
728
+ ctxRootAliases,
729
+ activeAliases
730
+ );
731
+ if (capability) {
732
+ addAlias(param.left.name, capability, param.left, ancestors, false, scope);
733
+ }
734
+ continue;
735
+ }
736
+ if (((_b = param.left) == null ? void 0 : _b.type) === "ObjectPattern") {
737
+ const namespace = (0, import_react_values.getReactNamespaceCapabilityFromAst)(
738
+ param.right,
739
+ identifierBindings,
740
+ namespaceAliases,
741
+ ctxRootAliases
742
+ );
743
+ if (namespace) {
744
+ (0, import_static_values.collectAstObjectPatternPathAliases)(param.left, (alias, members, aliasNode) => {
745
+ if (members.length === 1 && members[0] === "default") {
746
+ addAlias(alias, `${namespace}.default`, aliasNode || param, ancestors, false, scope);
747
+ }
748
+ });
749
+ }
750
+ if ((0, import_static_values.isCtxRootFromAst)(param.right, ctxRootAliases, identifierBindings)) {
751
+ (0, import_static_values.collectAstObjectPatternPathAliases)(param.left, (alias, members, aliasNode) => {
752
+ if (members.length === 2 && members[0] === "React" && members[1] === "default") {
753
+ addAlias(alias, "ctx.React.default", aliasNode || param, ancestors, false, scope);
754
+ }
755
+ });
756
+ }
757
+ }
758
+ }
759
+ }
760
+ function collectReactDefaultPatternSourceAliasesFromAst(pattern, sourceNode, ancestors, isVar = false, scopeOverride) {
761
+ collectReactDefaultPatternSourceTargetAliasesFromAst(
762
+ pattern,
763
+ (0, import_static_values.createAstPatternSourceTarget)(sourceNode),
764
+ ancestors,
765
+ isVar,
766
+ scopeOverride
767
+ );
768
+ }
769
+ function collectReactDefaultPatternSourceTargetAliasesFromAst(pattern, sourceTarget, ancestors, isVar = false, scopeOverride) {
770
+ const activeAliases = getActiveAliases();
771
+ (0, import_static_values.collectAstPatternSourceTargetsRec)(pattern, sourceTarget, (target, patternSourceTarget) => {
772
+ const capability = (0, import_react_values.getReactDefaultNamespaceCapabilityFromAstPatternSource)(
773
+ patternSourceTarget,
774
+ identifierBindings,
775
+ namespaceAliases,
776
+ ctxRootAliases,
777
+ activeAliases
778
+ );
779
+ if (!capability) {
780
+ return;
781
+ }
782
+ addReactDefaultAliasTarget(target, capability, ancestors, isVar, scopeOverride);
783
+ });
784
+ const collectCarrierTarget = (carrierTarget) => {
785
+ var _a, _b;
786
+ if (carrierTarget.sourceAlias) {
787
+ const precedenceStart = (0, import_static_values.getAstAliasPrecedenceStart)(carrierTarget.sourceAlias);
788
+ addReactDefaultAliasByName(
789
+ carrierTarget.targetAliasName,
790
+ carrierTarget.sourceAlias.capability,
791
+ carrierTarget.target,
792
+ ancestors,
793
+ isVar,
794
+ scopeOverride,
795
+ (_a = carrierTarget.sourceTarget) == null ? void 0 : _a.node,
796
+ precedenceStart
797
+ );
798
+ return;
799
+ }
800
+ const capability = (0, import_react_values.getReactDefaultNamespaceCapabilityFromAstPatternSource)(
801
+ carrierTarget.sourceTarget,
802
+ identifierBindings,
803
+ namespaceAliases,
804
+ ctxRootAliases,
805
+ activeAliases
806
+ );
807
+ if (!capability) {
808
+ return;
809
+ }
810
+ addReactDefaultAliasByName(
811
+ carrierTarget.targetAliasName,
812
+ capability,
813
+ carrierTarget.target,
814
+ ancestors,
815
+ isVar,
816
+ scopeOverride,
817
+ (_b = carrierTarget.sourceTarget) == null ? void 0 : _b.node
818
+ );
819
+ };
820
+ (0, import_static_values.collectAstPatternCarrierSourceTargetsFromSourceTarget)(
821
+ pattern,
822
+ sourceTarget,
823
+ activeAliases,
824
+ identifierBindings,
825
+ collectCarrierTarget
826
+ );
827
+ (0, import_static_values.collectAstPatternRestCarrierSourceTargetsRec)(
828
+ pattern,
829
+ sourceTarget,
830
+ activeAliases,
831
+ identifierBindings,
832
+ collectCarrierTarget
833
+ );
834
+ }
835
+ function collectReactDefaultPatternDefaultAliasesFromAst(pattern, ancestors, isVar = false, scopeOverride, sourceNode) {
836
+ collectReactDefaultPatternDefaultAliasesFromSourceTarget(
837
+ pattern,
838
+ ancestors,
839
+ isVar,
840
+ scopeOverride,
841
+ (0, import_static_values.createMaybeAstPatternSourceTarget)(sourceNode)
842
+ );
843
+ }
844
+ function collectReactDefaultPatternDefaultAliasesFromSourceTarget(pattern, ancestors, isVar = false, scopeOverride, sourceTarget) {
845
+ (0, import_static_values.collectAstPatternDefaultValueAliasesWithSource)(
846
+ pattern,
847
+ sourceTarget,
848
+ (alias, valueNode, aliasNode, defaultPattern, sourceTarget2) => {
849
+ if ((0, import_react_values.isAstPatternDefaultValueSuppressedByReactNamespace)(
850
+ sourceTarget2,
851
+ identifierBindings,
852
+ namespaceAliases,
853
+ ctxRootAliases
854
+ )) {
855
+ return;
856
+ }
857
+ const activeAliases = getActiveAliases();
858
+ const capability = (0, import_react_values.getReactDefaultNamespaceCapabilityFromAst)(
859
+ valueNode,
860
+ identifierBindings,
861
+ namespaceAliases,
862
+ ctxRootAliases,
863
+ activeAliases
864
+ );
865
+ if (capability && (defaultPattern == null ? void 0 : defaultPattern.type) === "Identifier") {
866
+ addAlias(alias, capability, aliasNode || defaultPattern, ancestors, isVar, scopeOverride);
867
+ }
868
+ if ((defaultPattern == null ? void 0 : defaultPattern.type) === "Identifier") {
869
+ collectReactDefaultCarrierAliasesFromAst(
870
+ alias,
871
+ valueNode,
872
+ identifierBindings,
873
+ namespaceAliases,
874
+ ctxRootAliases,
875
+ activeAliases,
876
+ (member, memberCapability, memberAliasNode, precedenceStart) => {
877
+ addAlias(
878
+ `${alias}.${member}`,
879
+ memberCapability,
880
+ memberAliasNode || aliasNode || defaultPattern,
881
+ ancestors,
882
+ isVar,
883
+ scopeOverride,
884
+ precedenceStart
885
+ );
886
+ }
887
+ );
888
+ }
889
+ if ((defaultPattern == null ? void 0 : defaultPattern.type) !== "ObjectPattern") {
890
+ return;
891
+ }
892
+ const namespace = (0, import_react_values.getReactNamespaceCapabilityFromAst)(
893
+ valueNode,
894
+ identifierBindings,
895
+ namespaceAliases,
896
+ ctxRootAliases
897
+ );
898
+ if (namespace) {
899
+ (0, import_static_values.collectAstObjectPatternPathAliases)(defaultPattern, (pathAlias, members, pathAliasNode) => {
900
+ if (members.length === 1 && members[0] === "default") {
901
+ addAlias(
902
+ pathAlias,
903
+ `${namespace}.default`,
904
+ pathAliasNode || aliasNode || defaultPattern,
905
+ ancestors,
906
+ isVar,
907
+ scopeOverride
908
+ );
909
+ }
910
+ });
911
+ }
912
+ if ((0, import_static_values.isCtxRootFromAst)(valueNode, ctxRootAliases, identifierBindings)) {
913
+ (0, import_static_values.collectAstObjectPatternPathAliases)(defaultPattern, (pathAlias, members, pathAliasNode) => {
914
+ if (members.length === 2 && members[0] === "React" && members[1] === "default") {
915
+ addAlias(
916
+ pathAlias,
917
+ "ctx.React.default",
918
+ pathAliasNode || aliasNode || defaultPattern,
919
+ ancestors,
920
+ isVar,
921
+ scopeOverride
922
+ );
923
+ }
924
+ });
925
+ }
926
+ }
927
+ );
928
+ }
929
+ function addReactDefaultAliasTarget(target, capability, ancestors, isVar = false, scopeOverride) {
930
+ const unwrapped = (0, import_bindings.unwrapAstChainExpression)(target);
931
+ if ((unwrapped == null ? void 0 : unwrapped.type) === "Identifier") {
932
+ addAlias(
933
+ unwrapped.name,
934
+ capability,
935
+ unwrapped,
936
+ ancestors,
937
+ isVar,
938
+ scopeOverride || (0, import_static_values.getAstAssignmentTargetScope)(unwrapped, ancestors, source.length, identifierBindings)
939
+ );
940
+ return;
941
+ }
942
+ if ((unwrapped == null ? void 0 : unwrapped.type) === "MemberExpression") {
943
+ const memberAlias = (0, import_static_values.getAstMemberAliasLookup)(unwrapped);
944
+ if (!memberAlias) {
945
+ return;
946
+ }
947
+ addAlias(
948
+ memberAlias.aliasName,
949
+ capability,
950
+ unwrapped,
951
+ ancestors,
952
+ false,
953
+ scopeOverride || (0, import_static_values.getAstMemberAssignmentTargetScope)(unwrapped, ancestors, source.length, identifierBindings)
954
+ );
955
+ }
956
+ }
957
+ function addReactDefaultAliasByName(name, capability, target, ancestors, isVar = false, scopeOverride, aliasNode, precedenceStart) {
958
+ const unwrapped = (0, import_bindings.unwrapAstChainExpression)(target);
959
+ const scope = scopeOverride || ((unwrapped == null ? void 0 : unwrapped.type) === "MemberExpression" ? (0, import_static_values.getAstMemberAssignmentTargetScope)(unwrapped, ancestors, source.length, identifierBindings) : (0, import_static_values.getAstAssignmentTargetScope)(unwrapped, ancestors, source.length, identifierBindings));
960
+ addAlias(
961
+ name,
962
+ capability,
963
+ (0, import_bindings.unwrapAstChainExpression)(aliasNode) || aliasNode || unwrapped || target,
964
+ ancestors,
965
+ isVar,
966
+ scope,
967
+ precedenceStart
968
+ );
969
+ }
970
+ }
971
+ function collectAstInvalidReactRuntimeBindingsFromAst(ast, source, identifierBindings, namespaceAliases, ctxRootAliases, defaultAliases = []) {
972
+ const entries = [];
973
+ const addEntry = (binding, capability, node, ancestors) => {
974
+ const declaration = (0, import_bindings.findAstAncestor)(ancestors, "VariableDeclaration");
975
+ const scope = (0, import_bindings.getAstBindingScopeRange)(ancestors, source.length, (declaration == null ? void 0 : declaration.kind) === "var");
976
+ entries.push({
977
+ binding,
978
+ capability,
979
+ declarationStart: typeof (node == null ? void 0 : node.start) === "number" ? node.start : scope.start,
980
+ index: typeof (node == null ? void 0 : node.start) === "number" ? node.start : scope.start,
981
+ ruleId: "runjs-react-default-alias-forbidden",
982
+ start: typeof (node == null ? void 0 : node.start) === "number" ? node.start : scope.start,
983
+ end: typeof (node == null ? void 0 : node.end) === "number" ? node.end : scope.end
984
+ });
985
+ };
986
+ (0, import_walk.walkAstAncestor)(ast, {
987
+ AssignmentExpression(node, ancestors) {
988
+ var _a, _b, _c;
989
+ if (!(0, import_static_values.isAstCtxApiAliasAssignmentOperator)(node.operator)) {
990
+ return;
991
+ }
992
+ if (((_a = node.left) == null ? void 0 : _a.type) === "Identifier" && node.left.name === "React") {
993
+ const capability = getInvalidReactDefaultCapabilityFromSource(node.right);
994
+ if (capability) {
995
+ addEntry(node.left.name, capability, node.left, ancestors);
996
+ }
997
+ return;
998
+ }
999
+ if (((_b = node.left) == null ? void 0 : _b.type) === "ObjectPattern" && (0, import_react_values.getReactNamespaceCapabilityFromAst)(node.right, identifierBindings, namespaceAliases, ctxRootAliases)) {
1000
+ const namespace = (0, import_react_values.getReactNamespaceCapabilityFromAst)(
1001
+ node.right,
1002
+ identifierBindings,
1003
+ namespaceAliases,
1004
+ ctxRootAliases
1005
+ );
1006
+ (0, import_static_values.collectAstObjectPatternPathAliases)(node.left, (alias, members, aliasNode) => {
1007
+ if (members.length === 1 && members[0] === "default" && alias === "React") {
1008
+ addEntry(alias, `${namespace}.default`, aliasNode || node, ancestors);
1009
+ }
1010
+ });
1011
+ }
1012
+ if (((_c = node.left) == null ? void 0 : _c.type) === "ObjectPattern" && (0, import_static_values.isCtxRootFromAst)(node.right, ctxRootAliases, identifierBindings)) {
1013
+ (0, import_static_values.collectAstObjectPatternPathAliases)(node.left, (alias, members, aliasNode) => {
1014
+ if (members.length === 2 && members[0] === "React" && members[1] === "default" && alias === "React") {
1015
+ addEntry(alias, "ctx.React.default", aliasNode || node, ancestors);
1016
+ }
1017
+ });
1018
+ }
1019
+ if (node.operator === "=") {
1020
+ collectInvalidReactPatternSourceBindingsFromAst(node.left, node.right, ancestors);
1021
+ collectInvalidReactPatternDefaultBindingsFromAst(node.left, ancestors, node.right);
1022
+ }
1023
+ },
1024
+ ForOfStatement(node, ancestors) {
1025
+ const target = (0, import_execution.getAstLoopPatternTarget)(node.left);
1026
+ if (!target) {
1027
+ return;
1028
+ }
1029
+ const sourceTargetAliases = [...namespaceAliases, ...defaultAliases];
1030
+ (0, import_execution.collectAstForOfSourceTargets)(node.right, sourceTargetAliases, identifierBindings, (loopSourceTarget) => {
1031
+ collectInvalidReactPatternSourceTargetBindingsFromAst(target, loopSourceTarget, ancestors);
1032
+ collectInvalidReactPatternDefaultBindingsFromSourceTarget(target, ancestors, loopSourceTarget);
1033
+ });
1034
+ },
1035
+ VariableDeclarator(node, ancestors) {
1036
+ var _a, _b, _c;
1037
+ const sourceTargetAliases = [...namespaceAliases, ...defaultAliases];
1038
+ if ((0, import_execution.isAstForOfLoopVariableDeclaratorWithSourceTargets)(node, ancestors, sourceTargetAliases, identifierBindings)) {
1039
+ return;
1040
+ }
1041
+ if (((_a = node.id) == null ? void 0 : _a.type) === "Identifier" && node.id.name === "React") {
1042
+ const capability = getInvalidReactDefaultCapabilityFromSource(node.init);
1043
+ if (capability) {
1044
+ addEntry(node.id.name, capability, node.id, ancestors);
1045
+ }
1046
+ return;
1047
+ }
1048
+ if (((_b = node.id) == null ? void 0 : _b.type) === "ObjectPattern" && (0, import_react_values.getReactNamespaceCapabilityFromAst)(node.init, identifierBindings, namespaceAliases, ctxRootAliases)) {
1049
+ const namespace = (0, import_react_values.getReactNamespaceCapabilityFromAst)(
1050
+ node.init,
1051
+ identifierBindings,
1052
+ namespaceAliases,
1053
+ ctxRootAliases
1054
+ );
1055
+ (0, import_static_values.collectAstObjectPatternPathAliases)(node.id, (alias, members, aliasNode) => {
1056
+ if (members.length === 1 && members[0] === "default" && alias === "React") {
1057
+ addEntry(alias, `${namespace}.default`, aliasNode || node, ancestors);
1058
+ }
1059
+ });
1060
+ collectInvalidReactPatternSourceBindingsFromAst(node.id, node.init, ancestors);
1061
+ return;
1062
+ }
1063
+ if (((_c = node.id) == null ? void 0 : _c.type) === "ObjectPattern" && (0, import_static_values.isCtxRootFromAst)(node.init, ctxRootAliases, identifierBindings)) {
1064
+ (0, import_static_values.collectAstObjectPatternPathAliases)(node.id, (alias, members, aliasNode) => {
1065
+ if (members.length === 2 && members[0] === "React" && members[1] === "default" && alias === "React") {
1066
+ addEntry(alias, "ctx.React.default", aliasNode || node, ancestors);
1067
+ }
1068
+ });
1069
+ }
1070
+ collectInvalidReactPatternSourceBindingsFromAst(node.id, node.init, ancestors);
1071
+ collectInvalidReactPatternDefaultBindingsFromAst(node.id, ancestors, node.init);
1072
+ },
1073
+ FunctionDeclaration(node, ancestors) {
1074
+ collectInvalidReactFunctionParamBindingsFromAst(node, ancestors);
1075
+ },
1076
+ FunctionExpression(node, ancestors) {
1077
+ collectInvalidReactFunctionParamBindingsFromAst(node, ancestors);
1078
+ },
1079
+ ArrowFunctionExpression(node, ancestors) {
1080
+ collectInvalidReactFunctionParamBindingsFromAst(node, ancestors);
1081
+ }
1082
+ });
1083
+ return entries;
1084
+ function collectInvalidReactFunctionParamBindingsFromAst(node, ancestors) {
1085
+ var _a, _b;
1086
+ for (const param of node.params || []) {
1087
+ if ((param == null ? void 0 : param.type) !== "AssignmentPattern") {
1088
+ collectInvalidReactPatternDefaultBindingsFromAst(param, ancestors);
1089
+ continue;
1090
+ }
1091
+ collectInvalidReactPatternDefaultBindingsFromAst(param.left, ancestors, param.right);
1092
+ collectInvalidReactPatternSourceBindingsFromAst(param.left, param.right, ancestors);
1093
+ if (((_a = param.left) == null ? void 0 : _a.type) === "Identifier" && param.left.name === "React") {
1094
+ const capability = getInvalidReactDefaultCapabilityFromSource(param.right);
1095
+ if (capability) {
1096
+ addEntry(param.left.name, capability, param.left, ancestors);
1097
+ }
1098
+ continue;
1099
+ }
1100
+ if (((_b = param.left) == null ? void 0 : _b.type) !== "ObjectPattern") {
1101
+ continue;
1102
+ }
1103
+ const namespace = (0, import_react_values.getReactNamespaceCapabilityFromAst)(
1104
+ param.right,
1105
+ identifierBindings,
1106
+ namespaceAliases,
1107
+ ctxRootAliases
1108
+ );
1109
+ if (namespace) {
1110
+ (0, import_static_values.collectAstObjectPatternPathAliases)(param.left, (alias, members, aliasNode) => {
1111
+ if (members.length === 1 && members[0] === "default" && alias === "React") {
1112
+ addEntry(alias, `${namespace}.default`, aliasNode || param, ancestors);
1113
+ }
1114
+ });
1115
+ }
1116
+ if ((0, import_static_values.isCtxRootFromAst)(param.right, ctxRootAliases, identifierBindings)) {
1117
+ (0, import_static_values.collectAstObjectPatternPathAliases)(param.left, (alias, members, aliasNode) => {
1118
+ if (members.length === 2 && members[0] === "React" && members[1] === "default" && alias === "React") {
1119
+ addEntry(alias, "ctx.React.default", aliasNode || param, ancestors);
1120
+ }
1121
+ });
1122
+ }
1123
+ }
1124
+ }
1125
+ function getInvalidReactDefaultCapabilityFromSource(sourceNode) {
1126
+ if (!sourceNode) {
1127
+ return "";
1128
+ }
1129
+ return (0, import_react_values.getReactDefaultNamespaceCapabilityFromAstPatternSource)(
1130
+ (0, import_static_values.createAstPatternSourceTarget)(sourceNode),
1131
+ identifierBindings,
1132
+ namespaceAliases,
1133
+ ctxRootAliases,
1134
+ defaultAliases
1135
+ );
1136
+ }
1137
+ function collectInvalidReactPatternSourceBindingsFromAst(pattern, sourceNode, ancestors) {
1138
+ collectInvalidReactPatternSourceTargetBindingsFromAst(pattern, (0, import_static_values.createAstPatternSourceTarget)(sourceNode), ancestors);
1139
+ }
1140
+ function collectInvalidReactPatternSourceTargetBindingsFromAst(pattern, sourceTarget, ancestors) {
1141
+ (0, import_static_values.collectAstPatternSourceTargetsRec)(pattern, sourceTarget, (target, patternSourceTarget) => {
1142
+ const unwrapped = (0, import_bindings.unwrapAstChainExpression)(target);
1143
+ if ((unwrapped == null ? void 0 : unwrapped.type) !== "Identifier" || unwrapped.name !== "React") {
1144
+ return;
1145
+ }
1146
+ const capability = (0, import_react_values.getReactDefaultNamespaceCapabilityFromAstPatternSource)(
1147
+ patternSourceTarget,
1148
+ identifierBindings,
1149
+ namespaceAliases,
1150
+ ctxRootAliases,
1151
+ defaultAliases
1152
+ );
1153
+ if (capability) {
1154
+ addEntry(unwrapped.name, capability, unwrapped, ancestors);
1155
+ }
1156
+ });
1157
+ }
1158
+ function collectInvalidReactPatternDefaultBindingsFromAst(pattern, ancestors, sourceNode) {
1159
+ collectInvalidReactPatternDefaultBindingsFromSourceTarget(
1160
+ pattern,
1161
+ ancestors,
1162
+ (0, import_static_values.createMaybeAstPatternSourceTarget)(sourceNode)
1163
+ );
1164
+ }
1165
+ function collectInvalidReactPatternDefaultBindingsFromSourceTarget(pattern, ancestors, sourceTarget) {
1166
+ (0, import_static_values.collectAstPatternDefaultValueAliasesWithSource)(
1167
+ pattern,
1168
+ sourceTarget,
1169
+ (alias, valueNode, aliasNode, defaultPattern, sourceTarget2) => {
1170
+ if ((0, import_react_values.isAstPatternDefaultValueSuppressedByReactNamespace)(
1171
+ sourceTarget2,
1172
+ identifierBindings,
1173
+ namespaceAliases,
1174
+ ctxRootAliases
1175
+ )) {
1176
+ return;
1177
+ }
1178
+ const capability = (0, import_react_values.getReactDefaultNamespaceCapabilityFromAst)(
1179
+ valueNode,
1180
+ identifierBindings,
1181
+ namespaceAliases,
1182
+ ctxRootAliases,
1183
+ defaultAliases
1184
+ );
1185
+ if (capability && alias === "React" && (defaultPattern == null ? void 0 : defaultPattern.type) === "Identifier") {
1186
+ addEntry(alias, capability, aliasNode || defaultPattern, ancestors);
1187
+ }
1188
+ if ((defaultPattern == null ? void 0 : defaultPattern.type) !== "ObjectPattern") {
1189
+ return;
1190
+ }
1191
+ const namespace = (0, import_react_values.getReactNamespaceCapabilityFromAst)(
1192
+ valueNode,
1193
+ identifierBindings,
1194
+ namespaceAliases,
1195
+ ctxRootAliases
1196
+ );
1197
+ if (namespace) {
1198
+ (0, import_static_values.collectAstObjectPatternPathAliases)(defaultPattern, (pathAlias, members, pathAliasNode) => {
1199
+ if (members.length === 1 && members[0] === "default" && pathAlias === "React") {
1200
+ addEntry(pathAlias, `${namespace}.default`, pathAliasNode || aliasNode || defaultPattern, ancestors);
1201
+ }
1202
+ });
1203
+ }
1204
+ if ((0, import_static_values.isCtxRootFromAst)(valueNode, ctxRootAliases, identifierBindings)) {
1205
+ (0, import_static_values.collectAstObjectPatternPathAliases)(defaultPattern, (pathAlias, members, pathAliasNode) => {
1206
+ if (members.length === 2 && members[0] === "React" && members[1] === "default" && pathAlias === "React") {
1207
+ addEntry(pathAlias, "ctx.React.default", pathAliasNode || aliasNode || defaultPattern, ancestors);
1208
+ }
1209
+ });
1210
+ }
1211
+ }
1212
+ );
1213
+ }
1214
+ }
1215
+ function collectReactNamespaceCarrierAliasesFromAst(containerName, sourceNode, identifierBindings, namespaceAliases, ctxRootAliases, addAlias) {
1216
+ const visitedTargets = /* @__PURE__ */ new Set();
1217
+ const collectAliases = (targetAliasName, sourceTarget) => {
1218
+ var _a, _b;
1219
+ if (!sourceTarget) {
1220
+ return;
1221
+ }
1222
+ const visitKey = `${targetAliasName}:${sourceTarget.aliasName || ""}:${((_a = sourceTarget.node) == null ? void 0 : _a.start) || 0}:${((_b = sourceTarget.node) == null ? void 0 : _b.end) || 0}:${sourceTarget.index || 0}`;
1223
+ if (visitedTargets.has(visitKey)) {
1224
+ return;
1225
+ }
1226
+ visitedTargets.add(visitKey);
1227
+ (0, import_static_values.collectAstCarrierSourceTargets)(
1228
+ void 0,
1229
+ targetAliasName,
1230
+ sourceTarget,
1231
+ namespaceAliases,
1232
+ identifierBindings,
1233
+ (carrierTarget) => {
1234
+ var _a2, _b2;
1235
+ const member = getAstNestedCarrierMemberName(containerName, carrierTarget.targetAliasName);
1236
+ if (!member) {
1237
+ return;
1238
+ }
1239
+ if (carrierTarget.sourceAlias) {
1240
+ addAlias(
1241
+ member,
1242
+ carrierTarget.sourceAlias.capability,
1243
+ (_a2 = carrierTarget.sourceTarget) == null ? void 0 : _a2.node,
1244
+ (0, import_static_values.getAstAliasPrecedenceStart)(carrierTarget.sourceAlias)
1245
+ );
1246
+ return;
1247
+ }
1248
+ const capability = (0, import_react_values.getReactNamespaceCapabilityFromAstPatternSource)(
1249
+ carrierTarget.sourceTarget,
1250
+ identifierBindings,
1251
+ namespaceAliases,
1252
+ ctxRootAliases
1253
+ );
1254
+ if (capability) {
1255
+ addAlias(member, capability, (_b2 = carrierTarget.sourceTarget) == null ? void 0 : _b2.node);
1256
+ }
1257
+ collectAliases(carrierTarget.targetAliasName, carrierTarget.sourceTarget);
1258
+ }
1259
+ );
1260
+ };
1261
+ collectAliases(containerName, (0, import_static_values.createAstPatternSourceTarget)(sourceNode));
1262
+ }
1263
+ function collectReactDefaultCarrierAliasesFromAst(containerName, sourceNode, identifierBindings, namespaceAliases, ctxRootAliases, defaultAliases, addAlias) {
1264
+ const carrierAliases = [...namespaceAliases, ...defaultAliases];
1265
+ const visitedTargets = /* @__PURE__ */ new Set();
1266
+ const collectAliases = (targetAliasName, sourceTarget) => {
1267
+ var _a, _b;
1268
+ if (!sourceTarget) {
1269
+ return;
1270
+ }
1271
+ const visitKey = `${targetAliasName}:${sourceTarget.aliasName || ""}:${((_a = sourceTarget.node) == null ? void 0 : _a.start) || 0}:${((_b = sourceTarget.node) == null ? void 0 : _b.end) || 0}:${sourceTarget.index || 0}`;
1272
+ if (visitedTargets.has(visitKey)) {
1273
+ return;
1274
+ }
1275
+ visitedTargets.add(visitKey);
1276
+ (0, import_static_values.collectAstCarrierSourceTargets)(
1277
+ void 0,
1278
+ targetAliasName,
1279
+ sourceTarget,
1280
+ carrierAliases,
1281
+ identifierBindings,
1282
+ (carrierTarget) => {
1283
+ var _a2, _b2;
1284
+ const member = getAstNestedCarrierMemberName(containerName, carrierTarget.targetAliasName);
1285
+ if (!member) {
1286
+ return;
1287
+ }
1288
+ if (carrierTarget.sourceAlias) {
1289
+ const capability2 = (0, import_react_values.getReactDefaultNamespaceCapabilityFromAstPatternSource)(
1290
+ {
1291
+ aliasName: carrierTarget.sourceAlias.name,
1292
+ index: carrierTarget.sourceAlias.start,
1293
+ rootName: (0, import_static_values.getAstAliasRootName)(carrierTarget.sourceAlias.name)
1294
+ },
1295
+ identifierBindings,
1296
+ namespaceAliases,
1297
+ ctxRootAliases,
1298
+ defaultAliases
1299
+ );
1300
+ if (capability2) {
1301
+ addAlias(
1302
+ member,
1303
+ capability2,
1304
+ (_a2 = carrierTarget.sourceTarget) == null ? void 0 : _a2.node,
1305
+ (0, import_static_values.getAstAliasPrecedenceStart)(carrierTarget.sourceAlias)
1306
+ );
1307
+ }
1308
+ return;
1309
+ }
1310
+ const capability = (0, import_react_values.getReactDefaultNamespaceCapabilityFromAstPatternSource)(
1311
+ carrierTarget.sourceTarget,
1312
+ identifierBindings,
1313
+ namespaceAliases,
1314
+ ctxRootAliases,
1315
+ defaultAliases
1316
+ );
1317
+ if (capability) {
1318
+ addAlias(member, capability, (_b2 = carrierTarget.sourceTarget) == null ? void 0 : _b2.node);
1319
+ }
1320
+ collectAliases(carrierTarget.targetAliasName, carrierTarget.sourceTarget);
1321
+ }
1322
+ );
1323
+ };
1324
+ collectAliases(containerName, (0, import_static_values.createAstPatternSourceTarget)(sourceNode));
1325
+ }
1326
+ function getAstNestedCarrierMemberName(containerName, targetAliasName) {
1327
+ const prefix = `${containerName}.`;
1328
+ return targetAliasName.startsWith(prefix) ? targetAliasName.slice(prefix.length) : "";
1329
+ }
1330
+ function collectReactAsyncComponentBindingsFromAst(ast, source, identifierBindings) {
1331
+ const bindings = [];
1332
+ const addBinding = (name, componentNode, scope, declarationNode) => {
1333
+ if (!/^[A-Z][\w$]*$/.test(name)) {
1334
+ return;
1335
+ }
1336
+ const declarationStart = typeof (declarationNode == null ? void 0 : declarationNode.start) === "number" ? declarationNode.start : typeof (componentNode == null ? void 0 : componentNode.start) === "number" ? componentNode.start : scope.start;
1337
+ bindings.push({
1338
+ capability: name,
1339
+ component: name,
1340
+ declarationStart,
1341
+ name,
1342
+ start: scope.start,
1343
+ end: scope.end
1344
+ });
1345
+ };
1346
+ (0, import_walk.walkAstAncestor)(ast, {
1347
+ FunctionDeclaration(node, ancestors) {
1348
+ var _a;
1349
+ if (!node.async || ((_a = node.id) == null ? void 0 : _a.type) !== "Identifier") {
1350
+ return;
1351
+ }
1352
+ const scope = (0, import_bindings.getAstBindingScopeRange)(ancestors.slice(0, -1), source.length);
1353
+ addBinding(node.id.name, node.id, scope, node);
1354
+ },
1355
+ VariableDeclarator(node, ancestors) {
1356
+ var _a;
1357
+ if (((_a = node.id) == null ? void 0 : _a.type) !== "Identifier" || !isAstAsyncFunctionLike(node.init)) {
1358
+ return;
1359
+ }
1360
+ const declaration = (0, import_bindings.findAstAncestor)(ancestors, "VariableDeclaration");
1361
+ const scope = (0, import_bindings.getAstBindingScopeRange)(ancestors, source.length, (declaration == null ? void 0 : declaration.kind) === "var");
1362
+ addBinding(node.id.name, node.id, scope, node);
1363
+ },
1364
+ AssignmentExpression(node, ancestors) {
1365
+ var _a;
1366
+ if (node.operator !== "=" || ((_a = node.left) == null ? void 0 : _a.type) !== "Identifier" || !isAstAsyncFunctionLike(node.right)) {
1367
+ return;
1368
+ }
1369
+ const scope = (0, import_bindings.getAstBindingScopeRange)(ancestors, source.length);
1370
+ addBinding(node.left.name, node.left, scope, node);
1371
+ }
1372
+ });
1373
+ return bindings;
1374
+ }
1375
+ function collectAstReactAsyncComponentReferences(node, asyncComponentBindings, reactCreateElementAliases, identifierBindings) {
1376
+ var _a, _b, _c;
1377
+ const capability = getReactCreateElementCallCapabilityFromAst(node, reactCreateElementAliases, identifierBindings);
1378
+ if (!capability) {
1379
+ return [];
1380
+ }
1381
+ const component = resolveAstAsyncComponentBinding((_a = node.arguments) == null ? void 0 : _a[0], asyncComponentBindings, identifierBindings);
1382
+ return component ? [
1383
+ {
1384
+ capability,
1385
+ component: component.component,
1386
+ index: typeof ((_c = (_b = node.arguments) == null ? void 0 : _b[0]) == null ? void 0 : _c.start) === "number" ? node.arguments[0].start : node.start || 0
1387
+ }
1388
+ ] : [];
1389
+ }
1390
+ function resolveAstAsyncComponentBinding(node, bindings, identifierBindings) {
1391
+ const unwrapped = (0, import_bindings.unwrapAstChainExpression)(node);
1392
+ if (!unwrapped || unwrapped.type !== "Identifier") {
1393
+ return void 0;
1394
+ }
1395
+ return (0, import_static_values.resolveAstAliasBinding)(unwrapped.name, unwrapped.start || 0, bindings, identifierBindings);
1396
+ }
1397
+ function getReactCreateElementCallCapabilityFromAst(node, aliases, identifierBindings) {
1398
+ const callee = (0, import_bindings.unwrapAstChainExpression)(node.callee);
1399
+ if ((callee == null ? void 0 : callee.type) === "Identifier") {
1400
+ const alias = (0, import_static_values.resolveAstAliasBinding)(callee.name, node.start || 0, aliases, identifierBindings);
1401
+ return (alias == null ? void 0 : alias.capability) || "";
1402
+ }
1403
+ return getReactCreateElementCapabilityFromAst(callee, identifierBindings, []);
1404
+ }
1405
+ function getReactCreateElementCapabilityFromAst(node, identifierBindings, namespaceAliases, ctxRootAliases = []) {
1406
+ const member = (0, import_bindings.unwrapAstChainExpression)(node);
1407
+ if (!member || member.type !== "MemberExpression") {
1408
+ return "";
1409
+ }
1410
+ const propertyName = (0, import_static_values.getAstStaticPropertyName)(member);
1411
+ if (propertyName !== "createElement") {
1412
+ return "";
1413
+ }
1414
+ const namespace = (0, import_react_values.getReactNamespaceCapabilityFromAst)(
1415
+ member.object,
1416
+ identifierBindings,
1417
+ namespaceAliases,
1418
+ ctxRootAliases
1419
+ );
1420
+ return namespace ? `${namespace}.createElement` : "";
1421
+ }
1422
+ function isAstAsyncFunctionLike(node) {
1423
+ const unwrapped = (0, import_bindings.unwrapAstChainExpression)(node);
1424
+ return !!(unwrapped == null ? void 0 : unwrapped.async) && (unwrapped.type === "FunctionExpression" || unwrapped.type === "ArrowFunctionExpression");
1425
+ }
1426
+ // Annotate the CommonJS export names for ESM import in node:
1427
+ 0 && (module.exports = {
1428
+ collectAstInvalidReactRuntimeBindingsFromAst,
1429
+ collectAstReactAsyncComponentReferences,
1430
+ collectReactAsyncComponentBindingsFromAst,
1431
+ collectReactCreateElementAliasesFromAst,
1432
+ collectReactDefaultAliasesFromAst,
1433
+ collectReactDefaultCarrierAliasesFromAst,
1434
+ collectReactNamespaceAliasesFromAst,
1435
+ collectReactNamespaceCarrierAliasesFromAst,
1436
+ getAstNestedCarrierMemberName,
1437
+ getReactCreateElementCallCapabilityFromAst,
1438
+ getReactCreateElementCapabilityFromAst,
1439
+ isAstAsyncFunctionLike,
1440
+ resolveAstAsyncComponentBinding
1441
+ });