@nocobase/plugin-flow-engine 2.1.0-beta.43 → 2.1.0-beta.45

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 (90) 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/authoring-validation.js +160 -21
  10. package/dist/server/flow-surfaces/catalog.js +9 -5
  11. package/dist/server/flow-surfaces/chart-config.js +29 -6
  12. package/dist/server/flow-surfaces/contract-guard.js +39 -5
  13. package/dist/server/flow-surfaces/default-block-actions.js +2 -0
  14. package/dist/server/flow-surfaces/errors.d.ts +15 -0
  15. package/dist/server/flow-surfaces/errors.js +49 -3
  16. package/dist/server/flow-surfaces/filter-group.d.ts +7 -1
  17. package/dist/server/flow-surfaces/filter-group.js +175 -71
  18. package/dist/server/flow-surfaces/public-data-surface-default-filter.js +2 -1
  19. package/dist/server/flow-surfaces/runjs-authoring/ast/bindings.d.ts +66 -0
  20. package/dist/server/flow-surfaces/runjs-authoring/ast/bindings.js +661 -0
  21. package/dist/server/flow-surfaces/runjs-authoring/ast/execution.d.ts +20 -0
  22. package/dist/server/flow-surfaces/runjs-authoring/ast/execution.js +275 -0
  23. package/dist/server/flow-surfaces/runjs-authoring/ast/parser.d.ts +16 -0
  24. package/dist/server/flow-surfaces/runjs-authoring/ast/parser.js +130 -0
  25. package/dist/server/flow-surfaces/runjs-authoring/ast/react-values.d.ts +20 -0
  26. package/dist/server/flow-surfaces/runjs-authoring/ast/react-values.js +401 -0
  27. package/dist/server/flow-surfaces/runjs-authoring/ast/request-config.d.ts +21 -0
  28. package/dist/server/flow-surfaces/runjs-authoring/ast/request-config.js +199 -0
  29. package/dist/server/flow-surfaces/runjs-authoring/ast/source.d.ts +70 -0
  30. package/dist/server/flow-surfaces/runjs-authoring/ast/source.js +895 -0
  31. package/dist/server/flow-surfaces/runjs-authoring/ast/static-bindings.d.ts +23 -0
  32. package/dist/server/flow-surfaces/runjs-authoring/ast/static-bindings.js +618 -0
  33. package/dist/server/flow-surfaces/runjs-authoring/ast/static-values.d.ts +196 -0
  34. package/dist/server/flow-surfaces/runjs-authoring/ast/static-values.js +1777 -0
  35. package/dist/server/flow-surfaces/runjs-authoring/ast/walk.d.ts +10 -0
  36. package/dist/server/flow-surfaces/runjs-authoring/ast/walk.js +55 -0
  37. package/dist/server/flow-surfaces/runjs-authoring/collectors.d.ts +12 -0
  38. package/dist/server/flow-surfaces/runjs-authoring/collectors.js +589 -0
  39. package/dist/server/flow-surfaces/runjs-authoring/index.d.ts +2 -25
  40. package/dist/server/flow-surfaces/runjs-authoring/index.js +5 -11138
  41. package/dist/server/flow-surfaces/runjs-authoring/inspect.d.ts +13 -0
  42. package/dist/server/flow-surfaces/runjs-authoring/inspect.js +149 -0
  43. package/dist/server/flow-surfaces/runjs-authoring/internal-types.d.ts +333 -0
  44. package/dist/server/flow-surfaces/runjs-authoring/internal-types.js +36 -0
  45. package/dist/server/flow-surfaces/runjs-authoring/rules.js +2 -0
  46. package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.d.ts +67 -0
  47. package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.js +757 -0
  48. package/dist/server/flow-surfaces/runjs-authoring/runtime/errors.d.ts +22 -0
  49. package/dist/server/flow-surfaces/runjs-authoring/runtime/errors.js +91 -0
  50. package/dist/server/flow-surfaces/runjs-authoring/runtime/source-budget.d.ts +16 -0
  51. package/dist/server/flow-surfaces/runjs-authoring/runtime/source-budget.js +115 -0
  52. package/dist/server/flow-surfaces/runjs-authoring/runtime/surface.d.ts +19 -0
  53. package/dist/server/flow-surfaces/runjs-authoring/runtime/surface.js +140 -0
  54. package/dist/server/flow-surfaces/runjs-authoring/runtime/types.d.ts +91 -0
  55. package/dist/server/flow-surfaces/runjs-authoring/runtime/types.js +24 -0
  56. package/dist/server/flow-surfaces/runjs-authoring/scan/ctx-api.d.ts +138 -0
  57. package/dist/server/flow-surfaces/runjs-authoring/scan/ctx-api.js +1779 -0
  58. package/dist/server/flow-surfaces/runjs-authoring/scan/filter.d.ts +10 -0
  59. package/dist/server/flow-surfaces/runjs-authoring/scan/filter.js +1583 -0
  60. package/dist/server/flow-surfaces/runjs-authoring/scan/index.d.ts +195 -0
  61. package/dist/server/flow-surfaces/runjs-authoring/scan/index.js +463 -0
  62. package/dist/server/flow-surfaces/runjs-authoring/scan/react-render.d.ts +48 -0
  63. package/dist/server/flow-surfaces/runjs-authoring/scan/react-render.js +379 -0
  64. package/dist/server/flow-surfaces/runjs-authoring/scan/react.d.ts +26 -0
  65. package/dist/server/flow-surfaces/runjs-authoring/scan/react.js +1441 -0
  66. package/dist/server/flow-surfaces/runjs-authoring/scan/resource.d.ts +23 -0
  67. package/dist/server/flow-surfaces/runjs-authoring/scan/resource.js +1427 -0
  68. package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.d.ts +91 -0
  69. package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.js +889 -0
  70. package/dist/server/flow-surfaces/runjs-authoring/types.d.ts +1 -1
  71. package/dist/server/flow-surfaces/runjs-authoring/unknown-global-stop/index.d.ts +10 -0
  72. package/dist/server/flow-surfaces/runjs-authoring/unknown-global-stop/index.js +40 -0
  73. package/dist/server/flow-surfaces/runjs-authoring/validators/index.d.ts +12 -0
  74. package/dist/server/flow-surfaces/runjs-authoring/validators/index.js +887 -0
  75. package/dist/server/flow-surfaces/service-helpers.d.ts +29 -0
  76. package/dist/server/flow-surfaces/service-helpers.js +105 -0
  77. package/dist/server/flow-surfaces/service-utils.d.ts +15 -3
  78. package/dist/server/flow-surfaces/service-utils.js +5 -4
  79. package/dist/server/flow-surfaces/service.d.ts +4 -0
  80. package/dist/server/flow-surfaces/service.js +360 -30
  81. package/dist/server/flow-surfaces/types.d.ts +3 -0
  82. package/dist/server/repository.d.ts +15 -1
  83. package/dist/server/repository.js +262 -23
  84. package/dist/server/template/contexts.d.ts +2 -0
  85. package/dist/server/template/contexts.js +34 -0
  86. package/dist/server/template/resolver.js +233 -22
  87. package/dist/swagger/flow-surfaces.d.ts +175 -0
  88. package/dist/swagger/flow-surfaces.js +130 -51
  89. package/dist/swagger/index.d.ts +175 -0
  90. package/package.json +2 -2
@@ -0,0 +1,48 @@
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
+ import type { AstCtxRenderCall, AstFunctionBinding, AstIdentifierBinding, CtxMethodAlias, ReactCreateElementAlias, RunJsAstInspection } from '../internal-types';
10
+ export declare function collectAstReactComponentCtxRenderCallsFromAst(renderCalls: AstCtxRenderCall[], ctxMethodAliases: CtxMethodAlias[], reactCreateElementAliases: ReactCreateElementAlias[], identifierBindings: AstIdentifierBinding[], functionBindings: AstFunctionBinding[]): RunJsAstInspection['reactComponentCtxRenderCalls'];
11
+ export declare function collectAstReactComponentUsagesFromRenderCall(renderCall: AstCtxRenderCall, reactCreateElementAliases: ReactCreateElementAlias[], identifierBindings: AstIdentifierBinding[], functionBindings: AstFunctionBinding[]): {
12
+ functionBinding: AstFunctionBinding;
13
+ index: number;
14
+ }[];
15
+ export declare function collectAstReactComponentUsagesFromNodes(nodes: any[], reactCreateElementAliases: ReactCreateElementAlias[], identifierBindings: AstIdentifierBinding[], functionBindings: AstFunctionBinding[], options?: {
16
+ nearestFunction?: any;
17
+ }): {
18
+ functionBinding: AstFunctionBinding;
19
+ index: number;
20
+ }[];
21
+ export declare function collectAstReactComponentUsagesOnFunctionRenderPath(functionNode: any, reactCreateElementAliases: ReactCreateElementAlias[], identifierBindings: AstIdentifierBinding[], functionBindings: AstFunctionBinding[], visited?: Set<any>): {
22
+ functionBinding: AstFunctionBinding;
23
+ index: number;
24
+ }[];
25
+ export declare function collectAstTopLevelReachableCtxRenderCallsFromAst(ast: any, ctxMethodAliases: CtxMethodAlias[], identifierBindings: AstIdentifierBinding[], functionBindings: AstFunctionBinding[]): AstCtxRenderCall[];
26
+ export declare function getAstJSXIdentifierName(node: any): string | undefined;
27
+ export declare function findNearestAstFunctionAncestor(ancestors: any[]): any;
28
+ export declare function collectCtxRenderCallsInFunction(functionNode: any, ctxMethodAliases: CtxMethodAlias[], identifierBindings: AstIdentifierBinding[], functionBindings: AstFunctionBinding[], options: {
29
+ bindingMode: 'initialized' | 'lexical' | 'source';
30
+ initializedIndex?: number;
31
+ }, visited?: Set<any>): AstCtxRenderCall[];
32
+ export declare function findCtxRenderCallInFunction(functionNode: any, ctxMethodAliases: CtxMethodAlias[], identifierBindings: AstIdentifierBinding[], functionBindings: AstFunctionBinding[], options: {
33
+ bindingMode: 'initialized' | 'lexical' | 'source';
34
+ initializedIndex?: number;
35
+ }): AstCtxRenderCall | undefined;
36
+ export declare function resolveAstFunctionBinding(name: string, index: number, functionBindings: AstFunctionBinding[], identifierBindings: AstIdentifierBinding[], options?: {
37
+ bindingMode?: 'initialized' | 'lexical' | 'source';
38
+ currentFunctionNode?: any;
39
+ initializedIndex?: number;
40
+ }): AstFunctionBinding;
41
+ export declare function isAstFunctionBindingScopedInsideNode(entry: AstFunctionBinding, node: any): boolean;
42
+ export declare function dedupeAstFunctionUsageEntries(entries: Array<{
43
+ functionBinding: AstFunctionBinding;
44
+ index: number;
45
+ }>): {
46
+ functionBinding: AstFunctionBinding;
47
+ index: number;
48
+ }[];
@@ -0,0 +1,379 @@
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_render_exports = {};
28
+ __export(react_render_exports, {
29
+ collectAstReactComponentCtxRenderCallsFromAst: () => collectAstReactComponentCtxRenderCallsFromAst,
30
+ collectAstReactComponentUsagesFromNodes: () => collectAstReactComponentUsagesFromNodes,
31
+ collectAstReactComponentUsagesFromRenderCall: () => collectAstReactComponentUsagesFromRenderCall,
32
+ collectAstReactComponentUsagesOnFunctionRenderPath: () => collectAstReactComponentUsagesOnFunctionRenderPath,
33
+ collectAstTopLevelReachableCtxRenderCallsFromAst: () => collectAstTopLevelReachableCtxRenderCallsFromAst,
34
+ collectCtxRenderCallsInFunction: () => collectCtxRenderCallsInFunction,
35
+ dedupeAstFunctionUsageEntries: () => dedupeAstFunctionUsageEntries,
36
+ findCtxRenderCallInFunction: () => findCtxRenderCallInFunction,
37
+ findNearestAstFunctionAncestor: () => findNearestAstFunctionAncestor,
38
+ getAstJSXIdentifierName: () => getAstJSXIdentifierName,
39
+ isAstFunctionBindingScopedInsideNode: () => isAstFunctionBindingScopedInsideNode,
40
+ resolveAstFunctionBinding: () => resolveAstFunctionBinding
41
+ });
42
+ module.exports = __toCommonJS(react_render_exports);
43
+ var import_walk = require("../ast/walk");
44
+ var import_bindings = require("../ast/bindings");
45
+ var import_static_values = require("../ast/static-values");
46
+ var import_react = require("./react");
47
+ function collectAstReactComponentCtxRenderCallsFromAst(renderCalls, ctxMethodAliases, reactCreateElementAliases, identifierBindings, functionBindings) {
48
+ if (!renderCalls.length) {
49
+ return [];
50
+ }
51
+ const entries = [];
52
+ const pending = renderCalls.flatMap(
53
+ (call) => collectAstReactComponentUsagesFromRenderCall(call, reactCreateElementAliases, identifierBindings, functionBindings)
54
+ );
55
+ const visitedComponents = /* @__PURE__ */ new Set();
56
+ while (pending.length) {
57
+ const usage = pending.shift();
58
+ if (!usage) {
59
+ continue;
60
+ }
61
+ const componentKey = `${usage.functionBinding.name}:${usage.functionBinding.declarationStart}`;
62
+ if (visitedComponents.has(componentKey)) {
63
+ continue;
64
+ }
65
+ visitedComponents.add(componentKey);
66
+ const renderCall = findCtxRenderCallInFunction(
67
+ usage.functionBinding.functionNode,
68
+ ctxMethodAliases,
69
+ identifierBindings,
70
+ functionBindings,
71
+ { bindingMode: "lexical" }
72
+ );
73
+ if (!renderCall) {
74
+ pending.push(
75
+ ...collectAstReactComponentUsagesOnFunctionRenderPath(
76
+ usage.functionBinding.functionNode,
77
+ reactCreateElementAliases,
78
+ identifierBindings,
79
+ functionBindings
80
+ )
81
+ );
82
+ continue;
83
+ }
84
+ entries.push({
85
+ capability: renderCall.capability,
86
+ component: usage.functionBinding.name,
87
+ index: renderCall.index
88
+ });
89
+ }
90
+ return (0, import_bindings.dedupeIndexedEntries)(entries).sort((left, right) => left.index - right.index);
91
+ }
92
+ function collectAstReactComponentUsagesFromRenderCall(renderCall, reactCreateElementAliases, identifierBindings, functionBindings) {
93
+ const usages = collectAstReactComponentUsagesFromNodes(
94
+ renderCall.args,
95
+ reactCreateElementAliases,
96
+ identifierBindings,
97
+ functionBindings
98
+ );
99
+ renderCall.args.forEach((arg) => {
100
+ (0, import_walk.walkAstAncestor)(arg, {
101
+ CallExpression(node) {
102
+ const callee = (0, import_bindings.unwrapAstChainExpression)(node.callee);
103
+ if ((callee == null ? void 0 : callee.type) !== "Identifier") {
104
+ return;
105
+ }
106
+ const helper = resolveAstFunctionBinding(callee.name, node.start || 0, functionBindings, identifierBindings, {
107
+ bindingMode: "initialized",
108
+ initializedIndex: renderCall.index
109
+ });
110
+ if (!helper) {
111
+ return;
112
+ }
113
+ usages.push(
114
+ ...collectAstReactComponentUsagesOnFunctionRenderPath(
115
+ helper.functionNode,
116
+ reactCreateElementAliases,
117
+ identifierBindings,
118
+ functionBindings
119
+ )
120
+ );
121
+ }
122
+ });
123
+ });
124
+ return dedupeAstFunctionUsageEntries(usages).sort((left, right) => left.index - right.index);
125
+ }
126
+ function collectAstReactComponentUsagesFromNodes(nodes, reactCreateElementAliases, identifierBindings, functionBindings, options = {}) {
127
+ const usages = [];
128
+ const addUsage = (name, index) => {
129
+ if (!name || !/^[A-Z][\w$]*$/.test(name)) {
130
+ return;
131
+ }
132
+ const functionBinding = resolveAstFunctionBinding(name, index, functionBindings, identifierBindings, {
133
+ bindingMode: "lexical"
134
+ });
135
+ if (functionBinding) {
136
+ usages.push({ functionBinding, index });
137
+ }
138
+ };
139
+ nodes.forEach((rootNode) => {
140
+ if (!rootNode) {
141
+ return;
142
+ }
143
+ (0, import_walk.walkAstAncestor)(rootNode, {
144
+ JSXOpeningElement(node, ancestors) {
145
+ if (options.nearestFunction && findNearestAstFunctionAncestor(ancestors) !== options.nearestFunction) {
146
+ return;
147
+ }
148
+ addUsage(getAstJSXIdentifierName(node.name), node.start || 0);
149
+ },
150
+ CallExpression(node, ancestors) {
151
+ var _a;
152
+ if (options.nearestFunction && findNearestAstFunctionAncestor(ancestors) !== options.nearestFunction) {
153
+ return;
154
+ }
155
+ if (!(0, import_react.getReactCreateElementCallCapabilityFromAst)(node, reactCreateElementAliases, identifierBindings)) {
156
+ return;
157
+ }
158
+ const component = (0, import_bindings.unwrapAstChainExpression)((_a = node.arguments) == null ? void 0 : _a[0]);
159
+ if ((component == null ? void 0 : component.type) === "Identifier") {
160
+ addUsage(component.name, component.start || node.start || 0);
161
+ }
162
+ }
163
+ });
164
+ });
165
+ return dedupeAstFunctionUsageEntries(usages).sort((left, right) => left.index - right.index);
166
+ }
167
+ function collectAstReactComponentUsagesOnFunctionRenderPath(functionNode, reactCreateElementAliases, identifierBindings, functionBindings, visited = /* @__PURE__ */ new Set()) {
168
+ if (visited.has(functionNode)) {
169
+ return [];
170
+ }
171
+ visited.add(functionNode);
172
+ const usages = collectAstReactComponentUsagesFromNodes(
173
+ [functionNode],
174
+ reactCreateElementAliases,
175
+ identifierBindings,
176
+ functionBindings,
177
+ { nearestFunction: functionNode }
178
+ );
179
+ (0, import_walk.walkAstAncestor)(functionNode, {
180
+ CallExpression(node, ancestors) {
181
+ const nearestFunction = findNearestAstFunctionAncestor(ancestors);
182
+ if (nearestFunction !== functionNode) {
183
+ return;
184
+ }
185
+ const callee = (0, import_bindings.unwrapAstChainExpression)(node.callee);
186
+ if ((callee == null ? void 0 : callee.type) !== "Identifier") {
187
+ return;
188
+ }
189
+ const helper = resolveAstFunctionBinding(callee.name, node.start || 0, functionBindings, identifierBindings, {
190
+ bindingMode: "lexical"
191
+ });
192
+ if (!helper) {
193
+ return;
194
+ }
195
+ usages.push(
196
+ ...collectAstReactComponentUsagesOnFunctionRenderPath(
197
+ helper.functionNode,
198
+ reactCreateElementAliases,
199
+ identifierBindings,
200
+ functionBindings,
201
+ visited
202
+ )
203
+ );
204
+ }
205
+ });
206
+ return dedupeAstFunctionUsageEntries(usages).sort((left, right) => left.index - right.index);
207
+ }
208
+ function collectAstTopLevelReachableCtxRenderCallsFromAst(ast, ctxMethodAliases, identifierBindings, functionBindings) {
209
+ const entries = [];
210
+ (0, import_walk.walkAstAncestor)(ast, {
211
+ CallExpression(node, ancestors) {
212
+ if (findNearestAstFunctionAncestor(ancestors)) {
213
+ return;
214
+ }
215
+ const method = (0, import_static_values.resolveCtxMethodCall)(node, ctxMethodAliases, identifierBindings);
216
+ if ((method == null ? void 0 : method.method) === "render") {
217
+ entries.push({
218
+ args: [...node.arguments || []],
219
+ capability: method.capability,
220
+ index: node.start || 0
221
+ });
222
+ return;
223
+ }
224
+ if (!functionBindings.length) {
225
+ return;
226
+ }
227
+ if (!(0, import_bindings.isAstAlwaysExecutedInCurrentExecutionScope)(ancestors)) {
228
+ return;
229
+ }
230
+ const callee = (0, import_bindings.unwrapAstChainExpression)(node.callee);
231
+ if ((callee == null ? void 0 : callee.type) !== "Identifier") {
232
+ return;
233
+ }
234
+ const helper = resolveAstFunctionBinding(callee.name, node.start || 0, functionBindings, identifierBindings);
235
+ if (!helper) {
236
+ return;
237
+ }
238
+ const helperRenderCalls = collectCtxRenderCallsInFunction(
239
+ helper.functionNode,
240
+ ctxMethodAliases,
241
+ identifierBindings,
242
+ functionBindings,
243
+ {
244
+ bindingMode: "initialized",
245
+ initializedIndex: node.start || 0
246
+ }
247
+ );
248
+ helperRenderCalls.forEach((renderCall) => {
249
+ entries.push({
250
+ ...renderCall,
251
+ index: node.start || renderCall.index
252
+ });
253
+ });
254
+ }
255
+ });
256
+ return (0, import_bindings.dedupeIndexedEntries)(entries).sort((left, right) => left.index - right.index);
257
+ }
258
+ function getAstJSXIdentifierName(node) {
259
+ if ((node == null ? void 0 : node.type) === "JSXIdentifier") {
260
+ return node.name;
261
+ }
262
+ return void 0;
263
+ }
264
+ function findNearestAstFunctionAncestor(ancestors) {
265
+ for (let index = ancestors.length - 1; index >= 0; index -= 1) {
266
+ if ((0, import_bindings.isAstFunctionLike)(ancestors[index])) {
267
+ return ancestors[index];
268
+ }
269
+ }
270
+ return void 0;
271
+ }
272
+ function collectCtxRenderCallsInFunction(functionNode, ctxMethodAliases, identifierBindings, functionBindings, options, visited = /* @__PURE__ */ new Set()) {
273
+ if (visited.has(functionNode)) {
274
+ return [];
275
+ }
276
+ visited.add(functionNode);
277
+ const renderCalls = [];
278
+ (0, import_walk.walkAstAncestor)(functionNode, {
279
+ CallExpression(node, ancestors) {
280
+ const nearestFunction = findNearestAstFunctionAncestor(ancestors);
281
+ if (nearestFunction !== functionNode) {
282
+ return;
283
+ }
284
+ const method = (0, import_static_values.resolveCtxMethodCall)(node, ctxMethodAliases, identifierBindings);
285
+ if ((method == null ? void 0 : method.method) === "render") {
286
+ renderCalls.push({
287
+ args: [...node.arguments || []],
288
+ capability: method.capability,
289
+ index: node.start || 0
290
+ });
291
+ return;
292
+ }
293
+ const callee = (0, import_bindings.unwrapAstChainExpression)(node.callee);
294
+ if ((callee == null ? void 0 : callee.type) !== "Identifier") {
295
+ return;
296
+ }
297
+ const helper = resolveAstFunctionBinding(callee.name, node.start || 0, functionBindings, identifierBindings, {
298
+ bindingMode: options.bindingMode,
299
+ initializedIndex: options.initializedIndex,
300
+ currentFunctionNode: functionNode
301
+ });
302
+ if (!helper) {
303
+ return;
304
+ }
305
+ renderCalls.push(
306
+ ...collectCtxRenderCallsInFunction(
307
+ helper.functionNode,
308
+ ctxMethodAliases,
309
+ identifierBindings,
310
+ functionBindings,
311
+ options,
312
+ visited
313
+ )
314
+ );
315
+ }
316
+ });
317
+ return renderCalls;
318
+ }
319
+ function findCtxRenderCallInFunction(functionNode, ctxMethodAliases, identifierBindings, functionBindings, options) {
320
+ return collectCtxRenderCallsInFunction(
321
+ functionNode,
322
+ ctxMethodAliases,
323
+ identifierBindings,
324
+ functionBindings,
325
+ options
326
+ )[0];
327
+ }
328
+ function resolveAstFunctionBinding(name, index, functionBindings, identifierBindings, options = {}) {
329
+ if (options.bindingMode === "lexical" || options.bindingMode === "initialized") {
330
+ const candidates = functionBindings.filter((entry) => entry.name === name && index >= entry.scopeStart && index < entry.end).filter((entry) => {
331
+ if (options.bindingMode !== "initialized") {
332
+ return true;
333
+ }
334
+ const initializedIndex = isAstFunctionBindingScopedInsideNode(entry, options.currentFunctionNode) ? index : options.initializedIndex ?? index;
335
+ return entry.hoisted || entry.declarationStart <= initializedIndex;
336
+ }).sort((left, right) => right.scopeStart - left.scopeStart || right.declarationStart - left.declarationStart);
337
+ return candidates.find(
338
+ (entry) => !(0, import_static_values.hasAstShadowBinding)(
339
+ name,
340
+ index,
341
+ {
342
+ start: entry.scopeStart,
343
+ end: entry.end
344
+ },
345
+ identifierBindings
346
+ )
347
+ );
348
+ }
349
+ return (0, import_static_values.resolveAstAliasBinding)(name, index, functionBindings, identifierBindings);
350
+ }
351
+ function isAstFunctionBindingScopedInsideNode(entry, node) {
352
+ return typeof (node == null ? void 0 : node.start) === "number" && typeof (node == null ? void 0 : node.end) === "number" && entry.scopeStart >= node.start && entry.end <= node.end;
353
+ }
354
+ function dedupeAstFunctionUsageEntries(entries) {
355
+ const seen = /* @__PURE__ */ new Set();
356
+ return entries.filter((entry) => {
357
+ const key = `${entry.functionBinding.name}:${entry.functionBinding.declarationStart}:${entry.index}`;
358
+ if (seen.has(key)) {
359
+ return false;
360
+ }
361
+ seen.add(key);
362
+ return true;
363
+ });
364
+ }
365
+ // Annotate the CommonJS export names for ESM import in node:
366
+ 0 && (module.exports = {
367
+ collectAstReactComponentCtxRenderCallsFromAst,
368
+ collectAstReactComponentUsagesFromNodes,
369
+ collectAstReactComponentUsagesFromRenderCall,
370
+ collectAstReactComponentUsagesOnFunctionRenderPath,
371
+ collectAstTopLevelReachableCtxRenderCallsFromAst,
372
+ collectCtxRenderCallsInFunction,
373
+ dedupeAstFunctionUsageEntries,
374
+ findCtxRenderCallInFunction,
375
+ findNearestAstFunctionAncestor,
376
+ getAstJSXIdentifierName,
377
+ isAstFunctionBindingScopedInsideNode,
378
+ resolveAstFunctionBinding
379
+ });
@@ -0,0 +1,26 @@
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
+ import type { AstIdentifierBinding, CtxRootAlias, InvalidReactRuntimeBinding, ReactAsyncComponentBinding, ReactCreateElementAlias, ReactDefaultAlias, ReactNamespaceAlias } from '../internal-types';
10
+ export declare function collectReactCreateElementAliasesFromAst(ast: any, source: string, identifierBindings: AstIdentifierBinding[], namespaceAliases: ReactNamespaceAlias[], ctxRootAliases: CtxRootAlias[]): ReactCreateElementAlias[];
11
+ export declare function collectReactNamespaceAliasesFromAst(ast: any, source: string, identifierBindings: AstIdentifierBinding[], ctxRootAliases: CtxRootAlias[]): ReactNamespaceAlias[];
12
+ export declare function collectReactDefaultAliasesFromAst(ast: any, source: string, identifierBindings: AstIdentifierBinding[], namespaceAliases: ReactNamespaceAlias[], ctxRootAliases: CtxRootAlias[]): ReactDefaultAlias[];
13
+ export declare function collectAstInvalidReactRuntimeBindingsFromAst(ast: any, source: string, identifierBindings: AstIdentifierBinding[], namespaceAliases: ReactNamespaceAlias[], ctxRootAliases: CtxRootAlias[], defaultAliases?: ReactDefaultAlias[]): InvalidReactRuntimeBinding[];
14
+ export declare function collectReactNamespaceCarrierAliasesFromAst(containerName: string, sourceNode: any, identifierBindings: AstIdentifierBinding[], namespaceAliases: ReactNamespaceAlias[], ctxRootAliases: CtxRootAlias[], addAlias: (member: string, capability: string, node?: any, precedenceStart?: number) => void): void;
15
+ export declare function collectReactDefaultCarrierAliasesFromAst(containerName: string, sourceNode: any, identifierBindings: AstIdentifierBinding[], namespaceAliases: ReactNamespaceAlias[], ctxRootAliases: CtxRootAlias[], defaultAliases: ReactDefaultAlias[], addAlias: (member: string, capability: string, node?: any, precedenceStart?: number) => void): void;
16
+ export declare function getAstNestedCarrierMemberName(containerName: string, targetAliasName: string): string;
17
+ export declare function collectReactAsyncComponentBindingsFromAst(ast: any, source: string, identifierBindings: AstIdentifierBinding[]): ReactAsyncComponentBinding[];
18
+ export declare function collectAstReactAsyncComponentReferences(node: any, asyncComponentBindings: ReactAsyncComponentBinding[], reactCreateElementAliases: ReactCreateElementAlias[], identifierBindings: AstIdentifierBinding[]): Array<{
19
+ capability: string;
20
+ component: string;
21
+ index: number;
22
+ }>;
23
+ export declare function resolveAstAsyncComponentBinding(node: any, bindings: ReactAsyncComponentBinding[], identifierBindings: AstIdentifierBinding[]): ReactAsyncComponentBinding;
24
+ export declare function getReactCreateElementCallCapabilityFromAst(node: any, aliases: ReactCreateElementAlias[], identifierBindings: AstIdentifierBinding[]): string;
25
+ export declare function getReactCreateElementCapabilityFromAst(node: any, identifierBindings: AstIdentifierBinding[], namespaceAliases: ReactNamespaceAlias[], ctxRootAliases?: CtxRootAlias[]): string;
26
+ export declare function isAstAsyncFunctionLike(node: any): boolean;