@weapp-vite/ast 7.5.0 → 7.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/babel.d.mts +1 -2
  2. package/dist/babel.mjs +1 -2
  3. package/dist/babelCore.d.mts +0 -2
  4. package/dist/babelCore.mjs +1 -2
  5. package/dist/babelLoader.d.mts +2 -0
  6. package/dist/babelLoader.mjs +32 -0
  7. package/dist/babelNodes.d.mts +1 -3
  8. package/dist/babelNodes.mjs +1 -2
  9. package/dist/{engine-CBE2OpFp.mjs → engine-DNS4Kzzw.mjs} +3 -6
  10. package/dist/engine.d.mts +2 -4
  11. package/dist/engine.mjs +1 -1
  12. package/dist/index.d.mts +70 -13
  13. package/dist/index.mjs +70 -29
  14. package/dist/native-D8RHiEuF.mjs +358 -0
  15. package/dist/{onPageScroll-n3Vptu1_.d.mts → onPageScroll-9kwtAWzG.d.mts} +1 -11
  16. package/dist/{onPageScroll-tuvgNooK.mjs → onPageScroll-CN_ocv9l.mjs} +6 -10
  17. package/dist/operations/componentProps.d.mts +2 -4
  18. package/dist/operations/componentProps.mjs +2 -3
  19. package/dist/operations/featureFlags.d.mts +2 -4
  20. package/dist/operations/featureFlags.mjs +3 -4
  21. package/dist/operations/jsxAutoComponents.d.mts +2 -12
  22. package/dist/operations/jsxAutoComponents.mjs +4 -8
  23. package/dist/operations/onPageScroll.d.mts +1 -1
  24. package/dist/operations/onPageScroll.mjs +1 -1
  25. package/dist/operations/platformApi.d.mts +2 -4
  26. package/dist/operations/platformApi.mjs +3 -4
  27. package/dist/operations/require.d.mts +2 -4
  28. package/dist/operations/require.mjs +3 -4
  29. package/dist/operations/scriptSetupImports.d.mts +2 -4
  30. package/dist/operations/scriptSetupImports.mjs +2 -3
  31. package/dist/operations/setDataPick.d.mts +2 -4
  32. package/dist/operations/setDataPick.mjs +2 -3
  33. package/dist/{types-4qG2Ubmk.d.mts → types-urOiI-JL.d.mts} +0 -2
  34. package/dist/types.d.mts +1 -1
  35. package/package.json +18 -8
  36. package/dist/native-C-xcrMBn.mjs +0 -54
@@ -0,0 +1,358 @@
1
+ import { createRequire } from "node:module";
2
+ import process from "node:process";
3
+ // src/native/compilerAnalysis.ts
4
+ function isUtf16Boundary(code, offset) {
5
+ const before = code.charCodeAt(offset - 1);
6
+ const after = code.charCodeAt(offset);
7
+ return !(before >= 55296 && before <= 56319 && after >= 56320 && after <= 57343);
8
+ }
9
+ function readDenseArray$2(value, read) {
10
+ if (!Array.isArray(value)) return;
11
+ const length = value.length;
12
+ if (!Number.isSafeInteger(length) || length < 0) return;
13
+ const items = [];
14
+ for (let index = 0; index < length; index++) {
15
+ if (!Object.hasOwn(value, index)) return;
16
+ const item = read(value[index]);
17
+ if (item === void 0) return;
18
+ items.push(item);
19
+ }
20
+ return items;
21
+ }
22
+ function readImport(value) {
23
+ if (!value || typeof value !== "object" || Array.isArray(value)) return;
24
+ const raw = value;
25
+ const local = raw.local;
26
+ const imported = raw.imported;
27
+ const source = raw.source;
28
+ const kind = raw.kind;
29
+ const typeOnly = raw.typeOnly;
30
+ if (typeof local !== "string" || typeof source !== "string" || typeof typeOnly !== "boolean" || imported !== void 0 && typeof imported !== "string" || kind !== "default" && kind !== "namespace" && kind !== "named") return;
31
+ return {
32
+ local,
33
+ source,
34
+ kind,
35
+ typeOnly,
36
+ ...imported === void 0 ? {} : { imported }
37
+ };
38
+ }
39
+ function readComponent(value) {
40
+ if (!value || typeof value !== "object" || Array.isArray(value)) return;
41
+ const raw = value;
42
+ const name = raw.name;
43
+ const local = raw.local;
44
+ return typeof name === "string" && typeof local === "string" ? {
45
+ name,
46
+ local
47
+ } : void 0;
48
+ }
49
+ /** 只保留校验后的自有摘要,不把可选 binding 的 getter 或可变容器传到编译阶段。 */
50
+ function readNativeCompilerScriptAnalysis(value, code) {
51
+ try {
52
+ if (!value || typeof value !== "object" || Array.isArray(value)) return;
53
+ const raw = value;
54
+ const imports = readDenseArray$2(raw.imports, readImport);
55
+ const hasDefaultExport = raw.hasDefaultExport;
56
+ let previousEnd = 0;
57
+ const defineOptionsStatements = readDenseArray$2(raw.defineOptionsStatements, (value) => {
58
+ if (!value || typeof value !== "object" || Array.isArray(value)) return;
59
+ const span = value;
60
+ const start = span.start;
61
+ const end = span.end;
62
+ if (typeof start !== "number" || typeof end !== "number" || !Number.isInteger(start) || !Number.isInteger(end) || start < previousEnd || end <= start || end > code.length || !isUtf16Boundary(code, start) || !isUtf16Boundary(code, end)) return;
63
+ previousEnd = end;
64
+ return {
65
+ start,
66
+ end
67
+ };
68
+ });
69
+ const rawComponents = raw.registeredComponents;
70
+ const registeredComponents = rawComponents === void 0 ? void 0 : readDenseArray$2(rawComponents, readComponent);
71
+ if (imports === void 0 || defineOptionsStatements === void 0 || hasDefaultExport !== void 0 && typeof hasDefaultExport !== "boolean" || rawComponents !== void 0 && registeredComponents === void 0) return;
72
+ const rawDiagnostic = raw.reservedPropsDiagnostic;
73
+ let reservedPropsDiagnostic;
74
+ if (rawDiagnostic !== void 0) {
75
+ if (!rawDiagnostic || typeof rawDiagnostic !== "object" || Array.isArray(rawDiagnostic)) return;
76
+ const warningOffset = rawDiagnostic.warningOffset;
77
+ if (warningOffset !== void 0 && (typeof warningOffset !== "number" || !Number.isInteger(warningOffset) || warningOffset < 0 || warningOffset >= code.length || !isUtf16Boundary(code, warningOffset))) return;
78
+ reservedPropsDiagnostic = warningOffset === void 0 ? {} : { warningOffset };
79
+ }
80
+ return {
81
+ imports,
82
+ ...hasDefaultExport === void 0 ? {} : { hasDefaultExport },
83
+ defineOptionsStatements,
84
+ ...registeredComponents === void 0 ? {} : { registeredComponents },
85
+ ...reservedPropsDiagnostic === void 0 ? {} : { reservedPropsDiagnostic }
86
+ };
87
+ } catch {
88
+ return;
89
+ }
90
+ }
91
+ // src/native/npmChunks.ts
92
+ function record(value) {
93
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
94
+ }
95
+ function readDenseArray$1(value, read) {
96
+ if (!Array.isArray(value)) return;
97
+ const length = value.length;
98
+ if (!Number.isSafeInteger(length) || length < 0) return;
99
+ const values = [];
100
+ for (let index = 0; index < length; index++) {
101
+ if (!Object.hasOwn(value, index)) return;
102
+ const item = read(value[index]);
103
+ if (item === void 0) return;
104
+ values.push(item);
105
+ }
106
+ return values;
107
+ }
108
+ function readRange(value, code, startKey = "start", endKey = "end") {
109
+ const start = value[startKey];
110
+ const end = value[endKey];
111
+ if (typeof start !== "number" || typeof end !== "number" || !Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start < 0 || end <= start || end > code.length) return;
112
+ return {
113
+ start,
114
+ end
115
+ };
116
+ }
117
+ /** 校验并复制普通快照,避免后续消费者持有 native binding 的 getter 或稀疏数组。 */
118
+ function readNativeNpmChunkAnalysis(value, code) {
119
+ try {
120
+ const raw = record(value);
121
+ if (!raw) return;
122
+ const requires = readDenseArray$1(raw.requires, (item) => {
123
+ const fact = record(item);
124
+ const range = fact && readRange(fact, code);
125
+ const importee = fact?.importee;
126
+ if (!fact || !range || typeof importee !== "string") return;
127
+ const literal = code.slice(range.start, range.end);
128
+ if (!/^['"`]/.test(literal) || literal.at(-1) !== literal[0]) return;
129
+ if (literal.includes("\\")) {
130
+ if (literal[0] !== "\"" || JSON.parse(literal) !== importee) return;
131
+ } else if (literal.slice(1, -1) !== importee) return;
132
+ return {
133
+ ...range,
134
+ importee
135
+ };
136
+ });
137
+ const platformApiRanges = readDenseArray$1(raw.platformApiRanges, (item) => {
138
+ const fact = record(item);
139
+ const range = fact && readRange(fact, code);
140
+ if (!range || !/^(?:wx|my|tt|swan|jd|xhs)$/.test(code.slice(range.start, range.end))) return;
141
+ return range;
142
+ });
143
+ if (!requires || !platformApiRanges) return;
144
+ const localRootFacts = readDenseArray$1(raw.localRootFacts, (item) => {
145
+ const fact = record(item);
146
+ if (!fact) return;
147
+ const kind = fact.kind;
148
+ const bindingName = fact.bindingName;
149
+ const referenceName = fact.referenceName;
150
+ const importee = fact.importee;
151
+ if (kind === "require") {
152
+ const requireIndex = fact.requireIndex;
153
+ if (typeof requireIndex !== "number" || !Number.isSafeInteger(requireIndex) || requireIndex < 0 || requireIndex >= requires.length || bindingName != null && typeof bindingName !== "string") return;
154
+ return {
155
+ kind,
156
+ requireIndex,
157
+ bindingName: bindingName ?? void 0
158
+ };
159
+ }
160
+ if (kind !== "alias" && kind !== "interop") return;
161
+ if (typeof referenceName !== "string" && typeof importee !== "string" || referenceName != null && typeof referenceName !== "string" || importee != null && typeof importee !== "string") return;
162
+ const source = {
163
+ referenceName: typeof referenceName === "string" ? referenceName : void 0,
164
+ importee: typeof importee === "string" ? importee : void 0
165
+ };
166
+ if (kind === "alias") return typeof bindingName === "string" ? {
167
+ kind,
168
+ bindingName,
169
+ ...source
170
+ } : void 0;
171
+ const range = readRange(fact, code, "secondArgumentStart", "secondArgumentEnd");
172
+ if (!range || Number(code.slice(range.start, range.end)) !== 1) return;
173
+ return {
174
+ kind,
175
+ ...source,
176
+ secondArgumentStart: range.start,
177
+ secondArgumentEnd: range.end
178
+ };
179
+ });
180
+ if (!localRootFacts) return;
181
+ const seen = /* @__PURE__ */ new Set();
182
+ for (const fact of localRootFacts) if (fact.kind === "require") {
183
+ if (seen.has(fact.requireIndex)) return;
184
+ seen.add(fact.requireIndex);
185
+ }
186
+ const allRanges = [...requires, ...platformApiRanges].sort((left, right) => left.start - right.start);
187
+ if (seen.size !== requires.length || allRanges.some((range, index) => index > 0 && range.start < allRanges[index - 1].end)) return;
188
+ return {
189
+ requires,
190
+ platformApiRanges,
191
+ localRootFacts
192
+ };
193
+ } catch {
194
+ return;
195
+ }
196
+ }
197
+ // src/native/scriptAnalysis.ts
198
+ /** 批次形状读取失败时进入同一校验失败分支,避免漏记或重复记录回退。 */
199
+ function isNativeScriptAnalysisBatchShape(value, expectedLength) {
200
+ try {
201
+ return Array.isArray(value) && value.length === expectedLength;
202
+ } catch {
203
+ return false;
204
+ }
205
+ }
206
+ function readDenseArray(value, read) {
207
+ if (!Array.isArray(value)) return;
208
+ const length = value.length;
209
+ if (!Number.isSafeInteger(length) || length < 0) return;
210
+ const snapshot = [];
211
+ for (let index = 0; index < length; index++) {
212
+ if (!Object.hasOwn(value, index)) return;
213
+ const item = read(value[index]);
214
+ if (item === void 0) return;
215
+ snapshot.push(item);
216
+ }
217
+ return snapshot;
218
+ }
219
+ /** 读取并校验普通脚本摘要;缓存只持有自己的 plain snapshot,不保留 binding 的 getter 或 iterator。 */
220
+ function readNativeScriptAnalysis(value) {
221
+ try {
222
+ if (!value || typeof value !== "object" || Array.isArray(value)) return;
223
+ const raw = value;
224
+ const hasStaticRequireLiteral = raw.hasStaticRequireLiteral;
225
+ const hasPlatformApiAccess = raw.hasPlatformApiAccess;
226
+ const featureFlags = readDenseArray(raw.featureFlags, (flag) => typeof flag === "string" ? flag : void 0);
227
+ if (typeof hasStaticRequireLiteral !== "boolean" || typeof hasPlatformApiAccess !== "boolean" || featureFlags === void 0) return;
228
+ return {
229
+ hasStaticRequireLiteral,
230
+ hasPlatformApiAccess,
231
+ featureFlags
232
+ };
233
+ } catch {
234
+ return;
235
+ }
236
+ }
237
+ // src/native.ts
238
+ const require = createRequire(import.meta.url);
239
+ let binding;
240
+ let lastScriptAnalysis;
241
+ function resolveNativeAstModulePath() {
242
+ return process.env.WEAPP_VITE_NATIVE_AST_PATH?.trim() || void 0;
243
+ }
244
+ function createScriptAnalysisKey(code, filename, moduleId, hookToFeatureJson) {
245
+ return [
246
+ code,
247
+ filename,
248
+ moduleId ?? "",
249
+ hookToFeatureJson ?? ""
250
+ ].join("\0");
251
+ }
252
+ function shouldUseNativeAst() {
253
+ return process.env.WEAPP_VITE_NATIVE === "1" && Boolean(resolveNativeAstModulePath());
254
+ }
255
+ function shouldUseNativeNpmChunkAnalysis() {
256
+ return shouldUseNativeAst() && process.env.WEAPP_VITE_NATIVE_NPM_CHUNK === "1";
257
+ }
258
+ function loadNativeAstBindingSync() {
259
+ if (!shouldUseNativeAst()) return;
260
+ if (binding !== void 0) return binding || void 0;
261
+ try {
262
+ binding = require(resolveNativeAstModulePath());
263
+ } catch {
264
+ binding = false;
265
+ }
266
+ return binding || void 0;
267
+ }
268
+ function analyzeScriptWithNative(code, options) {
269
+ const analyzeNative = loadNativeAstBindingSync()?.analyzeScriptNative;
270
+ if (!analyzeNative) return;
271
+ const hookToFeatureJson = options?.hookToFeature ? JSON.stringify(options.hookToFeature) : void 0;
272
+ const filename = options?.filename ?? "inline.ts";
273
+ const key = createScriptAnalysisKey(code, filename, options?.moduleId, hookToFeatureJson);
274
+ if (lastScriptAnalysis?.key === key) return lastScriptAnalysis.result;
275
+ const result = readNativeScriptAnalysis(analyzeNative(code, options?.moduleId, hookToFeatureJson, filename));
276
+ if (!result) return;
277
+ lastScriptAnalysis = {
278
+ key,
279
+ result
280
+ };
281
+ return result;
282
+ }
283
+ function analyzeScriptsWithNative(inputs) {
284
+ const analyzeNative = loadNativeAstBindingSync()?.analyzeScriptsNative;
285
+ if (!analyzeNative) return;
286
+ const nativeInputs = inputs.map((input) => {
287
+ return {
288
+ code: input.code,
289
+ filename: input.filename ?? "inline.ts",
290
+ hookToFeatureJson: input.hookToFeature ? JSON.stringify(input.hookToFeature) : void 0,
291
+ moduleId: input.moduleId
292
+ };
293
+ });
294
+ const rawResults = analyzeNative(nativeInputs);
295
+ if (!isNativeScriptAnalysisBatchShape(rawResults, nativeInputs.length)) return;
296
+ const results = nativeInputs.map((_, index) => {
297
+ try {
298
+ const result = readNativeScriptAnalysis(rawResults[index]);
299
+ if (result) return result;
300
+ } catch {}
301
+ return null;
302
+ });
303
+ const lastInput = nativeInputs.at(-1);
304
+ const lastResult = results.at(-1);
305
+ if (lastInput && lastResult && results.length === nativeInputs.length) lastScriptAnalysis = {
306
+ key: createScriptAnalysisKey(lastInput.code, lastInput.filename, lastInput.moduleId, lastInput.hookToFeatureJson),
307
+ result: lastResult
308
+ };
309
+ return results;
310
+ }
311
+ /**
312
+ * 编译器前端批量摘要的显式 native 快速路径;失败时由调用方继续使用 Babel/Oxc。
313
+ */
314
+ function analyzeCompilerScriptsWithNative(inputs) {
315
+ if (!shouldUseNativeAst()) return;
316
+ if (!inputs.length) return [];
317
+ const fallback = () => null;
318
+ const analyzeNative = loadNativeAstBindingSync()?.analyzeCompilerScriptsNative;
319
+ if (!analyzeNative) return inputs.map(fallback);
320
+ let results;
321
+ try {
322
+ results = analyzeNative(inputs);
323
+ } catch {
324
+ return inputs.map(fallback);
325
+ }
326
+ if (!Array.isArray(results) || results.length !== inputs.length) return inputs.map(fallback);
327
+ return inputs.map((input, index) => {
328
+ try {
329
+ const result = results[index];
330
+ return readNativeCompilerScriptAnalysis(result, input.code) ?? fallback();
331
+ } catch {
332
+ return fallback();
333
+ }
334
+ });
335
+ }
336
+ /**
337
+ * 批量读取最终 chunk 的重写事实;默认关闭,任何批次或单项校验失败都交回 JS。
338
+ */
339
+ function analyzeNpmChunksWithNative(inputs) {
340
+ if (!shouldUseNativeNpmChunkAnalysis() || inputs.length === 0) return;
341
+ let rawResults;
342
+ try {
343
+ const analyzeNative = loadNativeAstBindingSync()?.analyzeNpmChunksNative;
344
+ if (!analyzeNative) return inputs.map(() => null);
345
+ rawResults = analyzeNative(inputs);
346
+ } catch {
347
+ return inputs.map(() => null);
348
+ }
349
+ if (!isNativeScriptAnalysisBatchShape(rawResults, inputs.length)) return inputs.map(() => null);
350
+ return inputs.map((input, index) => {
351
+ try {
352
+ return Object.hasOwn(rawResults, index) ? readNativeNpmChunkAnalysis(rawResults[index], input.code) ?? null : null;
353
+ } catch {
354
+ return null;
355
+ }
356
+ });
357
+ }
358
+ export { loadNativeAstBindingSync as a, analyzeScriptsWithNative as i, analyzeNpmChunksWithNative as n, shouldUseNativeAst as o, analyzeScriptWithNative as r, analyzeCompilerScriptsWithNative as t };
@@ -1,6 +1,5 @@
1
- import { t as AstEngineName } from "./types-4qG2Ubmk.mjs";
1
+ import { t as AstEngineName } from "./types-urOiI-JL.mjs";
2
2
  import * as t from "@babel/types";
3
- //#region src/operations/onPageScroll/types.d.ts
4
3
  interface PageScrollInspection {
5
4
  empty: boolean;
6
5
  hasSetDataCall: boolean;
@@ -10,16 +9,10 @@ interface OxcLoc {
10
9
  line: number;
11
10
  column: number;
12
11
  }
13
- //#endregion
14
- //#region src/operations/onPageScroll/babel.d.ts
15
12
  declare function collectPageScrollInspection(functionPath: any, node: t.ArrowFunctionExpression | t.FunctionExpression | t.ObjectMethod): PageScrollInspection;
16
13
  declare function collectOnPageScrollWarningsWithBabel(code: string, filename: string): string[];
17
- //#endregion
18
- //#region src/operations/onPageScroll/oxc.d.ts
19
14
  declare function collectPageScrollInspectionWithOxc(node: any): PageScrollInspection;
20
15
  declare function collectOnPageScrollWarningsWithOxc(code: string, filename: string): string[];
21
- //#endregion
22
- //#region src/operations/onPageScroll/shared.d.ts
23
16
  declare function isStaticPropertyName(key: t.Expression | t.Identifier | t.PrivateName): string | undefined;
24
17
  declare function getMemberExpressionPropertyName(node: t.MemberExpression | t.OptionalMemberExpression): string | undefined;
25
18
  declare function isOnPageScrollCallee(callee: t.Expression | t.V8IntrinsicIdentifier, hookNames: Set<string>, namespaceImports: Set<string>): boolean;
@@ -35,8 +28,6 @@ declare function isOxcOnPageScrollCallee(callee: any, hookNames: Set<string>, na
35
28
  declare function getOxcCallExpressionCalleeName(callee: any): string | undefined;
36
29
  declare function createLineStartOffsets(code: string): number[];
37
30
  declare function getLocationFromOffset(offset: number | undefined, lineStarts: number[]): OxcLoc | undefined;
38
- //#endregion
39
- //#region src/operations/onPageScroll/index.d.ts
40
31
  declare function collectOnPageScrollWarningsWithNative(code: string, filename: string): string[] | undefined;
41
32
  /**
42
33
  * 静态检测 onPageScroll 中的常见性能风险并返回告警文案。
@@ -44,5 +35,4 @@ declare function collectOnPageScrollWarningsWithNative(code: string, filename: s
44
35
  declare function collectOnPageScrollPerformanceWarnings(code: string, filename: string, options?: {
45
36
  engine?: AstEngineName;
46
37
  }): string[];
47
- //#endregion
48
38
  export { collectPageScrollInspectionWithOxc as _, getCallExpressionCalleeName as a, getOnPageScrollCallbackArgument as c, getOxcStaticPropertyName as d, isOnPageScrollCallee as f, collectOnPageScrollWarningsWithOxc as g, isStaticPropertyName as h, createWarningPrefix as i, getOxcCallExpressionCalleeName as l, isOxcOnPageScrollCallee as m, collectOnPageScrollWarningsWithNative as n, getLocationFromOffset as o, isOxcFunctionLike as p, createLineStartOffsets as r, getMemberExpressionPropertyName as s, collectOnPageScrollPerformanceWarnings as t, getOxcMemberExpressionPropertyName as u, collectOnPageScrollWarningsWithBabel as v, collectPageScrollInspection as y };
@@ -1,8 +1,8 @@
1
1
  import { parseJsLike, traverse } from "./babel.mjs";
2
- import { t as parseJsLikeWithEngine } from "./engine-CBE2OpFp.mjs";
3
- import { i as shouldUseNativeAst, r as loadNativeAstBindingSync } from "./native-C-xcrMBn.mjs";
2
+ import { t as parseJsLikeWithEngine } from "./engine-DNS4Kzzw.mjs";
3
+ import { a as loadNativeAstBindingSync, o as shouldUseNativeAst } from "./native-D8RHiEuF.mjs";
4
4
  import { walk } from "oxc-walker";
5
- //#region src/operations/onPageScroll/shared.ts
5
+ // src/operations/onPageScroll/shared.ts
6
6
  function isStaticPropertyName(key) {
7
7
  if (key.type === "Identifier") return key.name;
8
8
  if (key.type === "StringLiteral") return key.value;
@@ -79,8 +79,7 @@ function getLocationFromOffset(offset, lineStarts) {
79
79
  column: offset - lineStarts[lineIndex] + 1
80
80
  };
81
81
  }
82
- //#endregion
83
- //#region src/operations/onPageScroll/babel.ts
82
+ // src/operations/onPageScroll/babel.ts
84
83
  function collectPageScrollInspection(functionPath, node) {
85
84
  const inspection = {
86
85
  empty: node.body.type === "BlockStatement" && node.body.body.length === 0,
@@ -169,8 +168,7 @@ function collectOnPageScrollWarningsWithBabel(code, filename) {
169
168
  });
170
169
  return warnings;
171
170
  }
172
- //#endregion
173
- //#region src/operations/onPageScroll/oxc.ts
171
+ // src/operations/onPageScroll/oxc.ts
174
172
  function isOxcNestedFunctionBoundary(node) {
175
173
  return isOxcFunctionLike(node) || node?.type === "FunctionDeclaration";
176
174
  }
@@ -241,8 +239,7 @@ function collectOnPageScrollWarningsWithOxc(code, filename) {
241
239
  } });
242
240
  return warnings;
243
241
  }
244
- //#endregion
245
- //#region src/operations/onPageScroll/index.ts
242
+ // src/operations/onPageScroll/index.ts
246
243
  function formatNativeOnPageScrollWarning(diagnostic, filename) {
247
244
  const prefix = createWarningPrefix(filename, diagnostic.line, diagnostic.column);
248
245
  if (diagnostic.kind === "empty") return `${prefix} 检测到空的 ${diagnostic.sourceLabel} 回调,建议移除无效监听以降低滚动时调度开销。`;
@@ -282,5 +279,4 @@ function collectOnPageScrollPerformanceWarnings(code, filename, options) {
282
279
  return [];
283
280
  }
284
281
  }
285
- //#endregion
286
282
  export { isOxcFunctionLike as _, collectOnPageScrollWarningsWithBabel as a, createWarningPrefix as c, getMemberExpressionPropertyName as d, getOnPageScrollCallbackArgument as f, isOnPageScrollCallee as g, getOxcStaticPropertyName as h, collectPageScrollInspectionWithOxc as i, getCallExpressionCalleeName as l, getOxcMemberExpressionPropertyName as m, collectOnPageScrollWarningsWithNative as n, collectPageScrollInspection as o, getOxcCallExpressionCalleeName as p, collectOnPageScrollWarningsWithOxc as r, createLineStartOffsets as s, collectOnPageScrollPerformanceWarnings as t, getLocationFromOffset as u, isOxcOnPageScrollCallee as v, isStaticPropertyName as y };
@@ -1,7 +1,6 @@
1
- import { t as AstEngineName } from "../types-4qG2Ubmk.mjs";
1
+ import { t as AstEngineName } from "../types-urOiI-JL.mjs";
2
2
  import * as t from "@babel/types";
3
3
  import { NodePath } from "@babel/traverse";
4
- //#region src/operations/componentProps.d.ts
5
4
  export type ComponentPropMap = Map<string, string>;
6
5
  export declare function mayContainComponentPropsShape(code: string): boolean;
7
6
  export declare function mapConstructorName(name: string): string;
@@ -19,5 +18,4 @@ export declare function collectComponentPropsWithOxc(code: string): ComponentPro
19
18
  */
20
19
  export declare function collectComponentPropsFromCode(code: string, options?: {
21
20
  astEngine?: AstEngineName;
22
- }): ComponentPropMap;
23
- //#endregion
21
+ }): ComponentPropMap;
@@ -1,7 +1,7 @@
1
1
  import { BABEL_TS_MODULE_PARSER_OPTIONS, parse, traverse } from "../babel.mjs";
2
- import { t as parseJsLikeWithEngine } from "../engine-CBE2OpFp.mjs";
2
+ import { t as parseJsLikeWithEngine } from "../engine-DNS4Kzzw.mjs";
3
3
  import { walk } from "oxc-walker";
4
- //#region src/operations/componentProps.ts
4
+ // src/operations/componentProps.ts
5
5
  const COMPONENT_PROPS_TEXT_HINTS = ["properties", "props"];
6
6
  const COMPONENT_OPTIONS_CALL_HINT_RE = /\b[a-z_$][\w$]*(?:\s*<[^(){};]+>)?\s*(?:\?\.\s*)?\(/i;
7
7
  function mayContainComponentPropsShape(code) {
@@ -183,5 +183,4 @@ function collectComponentPropsFromCode(code, options) {
183
183
  return /* @__PURE__ */ new Map();
184
184
  }
185
185
  }
186
- //#endregion
187
186
  export { collectComponentPropsFromCode, collectComponentPropsWithBabel, collectComponentPropsWithOxc, extractComponentProperties, extractPropertiesObject, getStaticPropertyName, mapConstructorName, mayContainComponentPropsShape, mergeComponentPropTypes, resolveOptionsObjectExpression, resolveOptionsObjectExpressionWithBabel, resolveTypeFromNode };
@@ -1,5 +1,4 @@
1
- import { t as AstEngineName } from "../types-4qG2Ubmk.mjs";
2
- //#region src/operations/featureFlags.d.ts
1
+ import { t as AstEngineName } from "../types-urOiI-JL.mjs";
3
2
  export interface FeatureFlagOptions<TFeature extends string> {
4
3
  astEngine?: AstEngineName;
5
4
  moduleId: string;
@@ -17,5 +16,4 @@ export declare function collectFeatureFlagsWithNativeBatch<TFeature extends stri
17
16
  /**
18
17
  * 根据模块 ID 与 hook 映射表,从源码中收集启用的特性标识。
19
18
  */
20
- export declare function collectFeatureFlagsFromCode<TFeature extends string>(code: string, options: FeatureFlagOptions<TFeature>): Set<TFeature>;
21
- //#endregion
19
+ export declare function collectFeatureFlagsFromCode<TFeature extends string>(code: string, options: FeatureFlagOptions<TFeature>): Set<TFeature>;
@@ -1,9 +1,9 @@
1
1
  import { parseJsLike, traverse } from "../babel.mjs";
2
- import { t as parseJsLikeWithEngine } from "../engine-CBE2OpFp.mjs";
3
- import { i as shouldUseNativeAst, r as loadNativeAstBindingSync, t as analyzeScriptWithNative } from "../native-C-xcrMBn.mjs";
2
+ import { t as parseJsLikeWithEngine } from "../engine-DNS4Kzzw.mjs";
3
+ import { a as loadNativeAstBindingSync, o as shouldUseNativeAst, r as analyzeScriptWithNative } from "../native-D8RHiEuF.mjs";
4
4
  import * as t from "@babel/types";
5
5
  import { walk } from "oxc-walker";
6
- //#region src/operations/featureFlags.ts
6
+ // src/operations/featureFlags.ts
7
7
  const CALL_EXPRESSION_TEXT_RE = /\b[a-z_$][\w$]*(?:\s*<[^(){};]+>)?\s*(?:\?\.\s*)?\(/i;
8
8
  function mayContainFeatureFlagHints(code, moduleId, hookToFeature) {
9
9
  if (!code.includes(moduleId)) return false;
@@ -123,5 +123,4 @@ function collectFeatureFlagsFromCode(code, options) {
123
123
  return /* @__PURE__ */ new Set();
124
124
  }
125
125
  }
126
- //#endregion
127
126
  export { collectFeatureFlagsFromCode, collectFeatureFlagsWithBabel, collectFeatureFlagsWithNative, collectFeatureFlagsWithNativeBatch, collectFeatureFlagsWithOxc, consumeNamedFeatureFlag, consumeNamespaceFeatureFlag, mayContainFeatureFlagHints, registerNamedFeatureFlagLocal, registerNamespaceFeatureFlagLocal };
@@ -1,7 +1,6 @@
1
- import { t as AstEngineName } from "../types-4qG2Ubmk.mjs";
1
+ import { t as AstEngineName } from "../types-urOiI-JL.mjs";
2
2
  import * as t from "@babel/types";
3
3
  import { Expression, ObjectExpression } from "@babel/types";
4
- //#region src/operations/jsxAutoComponents/types.d.ts
5
4
  export interface JsxImportedComponent {
6
5
  localName: string;
7
6
  importSource: string;
@@ -23,8 +22,6 @@ export interface JsxBabelModuleAnalysisOptions {
23
22
  isDefineComponentSource?: (source: string) => boolean;
24
23
  resolveBabelComponentExpression?: (declaration: t.Declaration | t.Expression | null, defineComponentDecls: Map<string, ObjectExpression>, defineComponentAliases: Set<string>) => Expression | null;
25
24
  }
26
- //#endregion
27
- //#region src/operations/jsxAutoComponents/babel.d.ts
28
25
  export declare function defaultResolveBabelComponentExpression(declaration: t.Declaration | t.Expression | null, defineComponentDecls: Map<string, ObjectExpression>, defineComponentAliases: Set<string>): Expression | null;
29
26
  export declare function defaultResolveBabelRenderExpression(componentExpr: Expression): Expression | null;
30
27
  export declare function collectJsxImportedComponentsAndDefaultExportFromBabelAst(ast: t.File, options?: JsxBabelModuleAnalysisOptions): {
@@ -33,26 +30,19 @@ export declare function collectJsxImportedComponentsAndDefaultExportFromBabelAst
33
30
  };
34
31
  export declare function collectJsxTemplateTagsFromBabelExpression(renderExpression: Expression, isCollectableTag: (tag: string) => boolean): Set<string>;
35
32
  export declare function collectJsxAutoComponentsWithBabel(source: string, options: Required<JsxAutoComponentAnalysisOptions>): JsxAutoComponentContext;
36
- //#endregion
37
- //#region src/operations/jsxAutoComponents/oxc.d.ts
38
33
  export declare function unwrapOxcExpression(node: any): any;
39
34
  export declare function getJsxOxcStaticPropertyName(node: any): any;
40
35
  export declare function resolveOxcComponentExpression(declaration: any, defineComponentDecls: Map<string, any>, defineComponentAliases: Set<string>): any;
41
36
  export declare function resolveOxcRenderExpression(componentExpr: any): any;
42
37
  export declare function collectJsxTemplateTagsFromOxc(renderExpression: any, isCollectableTag: (tag: string) => boolean): Set<string>;
43
38
  export declare function collectJsxAutoComponentsWithOxc(source: string, options: Required<Pick<JsxAutoComponentAnalysisOptions, 'isCollectableTag' | 'isDefineComponentSource'>>): JsxAutoComponentContext;
44
- //#endregion
45
- //#region src/operations/jsxAutoComponents/shared.d.ts
46
39
  export declare function mayContainJsxAutoComponentEntry(source: string): boolean;
47
40
  export declare function defaultIsDefineComponentSource(source: string): source is "vue";
48
41
  export declare function getJsxImportedName(imported: any): any;
49
42
  export declare function createJsxImportedComponent(localName: string, importSource: string, kind: JsxImportedComponent['kind'], imported?: any): JsxImportedComponent;
50
43
  export declare function getJsxImportLocalName(specifier: any): any;
51
44
  export declare function isJsxDefineComponentImportSpecifier(specifier: any): boolean;
52
- //#endregion
53
- //#region src/operations/jsxAutoComponents/index.d.ts
54
45
  /**
55
46
  * 从 JSX 源码中收集自动 usingComponents 所需的导入组件与模板标签。
56
47
  */
57
- export declare function collectJsxAutoComponentsFromCode(source: string, options: JsxAutoComponentAnalysisOptions): JsxAutoComponentContext;
58
- //#endregion
48
+ export declare function collectJsxAutoComponentsFromCode(source: string, options: JsxAutoComponentAnalysisOptions): JsxAutoComponentContext;
@@ -3,7 +3,7 @@ import { getObjectPropertyByKey, resolveRenderableExpression } from "../babelNod
3
3
  import * as t from "@babel/types";
4
4
  import { parseSync } from "oxc-parser";
5
5
  import { walk } from "oxc-walker";
6
- //#region src/operations/jsxAutoComponents/shared.ts
6
+ // src/operations/jsxAutoComponents/shared.ts
7
7
  function mayContainJsxAutoComponentEntry(source) {
8
8
  return source.includes("import") || source.includes("export default");
9
9
  }
@@ -28,8 +28,7 @@ function getJsxImportLocalName(specifier) {
28
28
  function isJsxDefineComponentImportSpecifier(specifier) {
29
29
  return t.isImportSpecifier(specifier) ? t.isIdentifier(specifier.imported, { name: "defineComponent" }) : specifier?.type === "ImportSpecifier" && specifier.imported?.type === "Identifier" && specifier.imported.name === "defineComponent";
30
30
  }
31
- //#endregion
32
- //#region src/operations/jsxAutoComponents/babel.ts
31
+ // src/operations/jsxAutoComponents/babel.ts
33
32
  function defaultResolveBabelComponentExpression(declaration, defineComponentDecls, defineComponentAliases) {
34
33
  if (!declaration) return null;
35
34
  if (t.isObjectExpression(declaration)) return declaration;
@@ -171,8 +170,7 @@ function collectJsxAutoComponentsWithBabel(source, options) {
171
170
  importedComponents
172
171
  };
173
172
  }
174
- //#endregion
175
- //#region src/operations/jsxAutoComponents/oxc.ts
173
+ // src/operations/jsxAutoComponents/oxc.ts
176
174
  function unwrapOxcExpression(node) {
177
175
  let current = node;
178
176
  while (current && (current.type === "TSAsExpression" || current.type === "TSSatisfiesExpression" || current.type === "TSNonNullExpression" || current.type === "ParenthesizedExpression")) current = current.expression;
@@ -289,8 +287,7 @@ function collectJsxAutoComponentsWithOxc(source, options) {
289
287
  importedComponents
290
288
  };
291
289
  }
292
- //#endregion
293
- //#region src/operations/jsxAutoComponents/index.ts
290
+ // src/operations/jsxAutoComponents/index.ts
294
291
  /**
295
292
  * 从 JSX 源码中收集自动 usingComponents 所需的导入组件与模板标签。
296
293
  */
@@ -315,5 +312,4 @@ function collectJsxAutoComponentsFromCode(source, options) {
315
312
  };
316
313
  }
317
314
  }
318
- //#endregion
319
315
  export { collectJsxAutoComponentsFromCode, collectJsxAutoComponentsWithBabel, collectJsxAutoComponentsWithOxc, collectJsxImportedComponentsAndDefaultExportFromBabelAst, collectJsxTemplateTagsFromBabelExpression, collectJsxTemplateTagsFromOxc, createJsxImportedComponent, defaultIsDefineComponentSource, defaultResolveBabelComponentExpression, defaultResolveBabelRenderExpression, getJsxImportLocalName, getJsxImportedName, getJsxOxcStaticPropertyName, isJsxDefineComponentImportSpecifier, mayContainJsxAutoComponentEntry, resolveOxcComponentExpression, resolveOxcRenderExpression, unwrapOxcExpression };
@@ -1,2 +1,2 @@
1
- import { _ as collectPageScrollInspectionWithOxc, a as getCallExpressionCalleeName, c as getOnPageScrollCallbackArgument, d as getOxcStaticPropertyName, f as isOnPageScrollCallee, g as collectOnPageScrollWarningsWithOxc, h as isStaticPropertyName, i as createWarningPrefix, l as getOxcCallExpressionCalleeName, m as isOxcOnPageScrollCallee, n as collectOnPageScrollWarningsWithNative, o as getLocationFromOffset, p as isOxcFunctionLike, r as createLineStartOffsets, s as getMemberExpressionPropertyName, t as collectOnPageScrollPerformanceWarnings, u as getOxcMemberExpressionPropertyName, v as collectOnPageScrollWarningsWithBabel, y as collectPageScrollInspection } from "../onPageScroll-n3Vptu1_.mjs";
1
+ import { _ as collectPageScrollInspectionWithOxc, a as getCallExpressionCalleeName, c as getOnPageScrollCallbackArgument, d as getOxcStaticPropertyName, f as isOnPageScrollCallee, g as collectOnPageScrollWarningsWithOxc, h as isStaticPropertyName, i as createWarningPrefix, l as getOxcCallExpressionCalleeName, m as isOxcOnPageScrollCallee, n as collectOnPageScrollWarningsWithNative, o as getLocationFromOffset, p as isOxcFunctionLike, r as createLineStartOffsets, s as getMemberExpressionPropertyName, t as collectOnPageScrollPerformanceWarnings, u as getOxcMemberExpressionPropertyName, v as collectOnPageScrollWarningsWithBabel, y as collectPageScrollInspection } from "../onPageScroll-9kwtAWzG.mjs";
2
2
  export { collectOnPageScrollPerformanceWarnings, collectOnPageScrollWarningsWithBabel, collectOnPageScrollWarningsWithNative, collectOnPageScrollWarningsWithOxc, collectPageScrollInspection, collectPageScrollInspectionWithOxc, createLineStartOffsets, createWarningPrefix, getCallExpressionCalleeName, getLocationFromOffset, getMemberExpressionPropertyName, getOnPageScrollCallbackArgument, getOxcCallExpressionCalleeName, getOxcMemberExpressionPropertyName, getOxcStaticPropertyName, isOnPageScrollCallee, isOxcFunctionLike, isOxcOnPageScrollCallee, isStaticPropertyName };
@@ -1 +1 @@
1
- export { t as collectOnPageScrollPerformanceWarnings, a as collectOnPageScrollWarningsWithBabel, n as collectOnPageScrollWarningsWithNative, r as collectOnPageScrollWarningsWithOxc, o as collectPageScrollInspection, i as collectPageScrollInspectionWithOxc, s as createLineStartOffsets, c as createWarningPrefix, l as getCallExpressionCalleeName, u as getLocationFromOffset, d as getMemberExpressionPropertyName, f as getOnPageScrollCallbackArgument, p as getOxcCallExpressionCalleeName, m as getOxcMemberExpressionPropertyName, h as getOxcStaticPropertyName, g as isOnPageScrollCallee, _ as isOxcFunctionLike, v as isOxcOnPageScrollCallee, y as isStaticPropertyName } from "../onPageScroll-tuvgNooK.mjs";
1
+ export { t as collectOnPageScrollPerformanceWarnings, a as collectOnPageScrollWarningsWithBabel, n as collectOnPageScrollWarningsWithNative, r as collectOnPageScrollWarningsWithOxc, o as collectPageScrollInspection, i as collectPageScrollInspectionWithOxc, s as createLineStartOffsets, c as createWarningPrefix, l as getCallExpressionCalleeName, u as getLocationFromOffset, d as getMemberExpressionPropertyName, f as getOnPageScrollCallbackArgument, p as getOxcCallExpressionCalleeName, m as getOxcMemberExpressionPropertyName, h as getOxcStaticPropertyName, g as isOnPageScrollCallee, _ as isOxcFunctionLike, v as isOxcOnPageScrollCallee, y as isStaticPropertyName } from "../onPageScroll-CN_ocv9l.mjs";
@@ -1,6 +1,5 @@
1
- import { n as AstParserLike, t as AstEngineName } from "../types-4qG2Ubmk.mjs";
1
+ import { n as AstParserLike, t as AstEngineName } from "../types-urOiI-JL.mjs";
2
2
  import { Program } from "@oxc-project/types";
3
- //#region src/operations/platformApi.d.ts
4
3
  export declare const platformApiIdentifierList: readonly ["wx", "my", "tt", "swan", "jd", "xhs"];
5
4
  export declare const platformApiIdentifiers: Set<"wx" | "my" | "tt" | "swan" | "jd" | "xhs">;
6
5
  export declare function isPlatformApiIdentifier(name: string): boolean;
@@ -13,5 +12,4 @@ export declare function hasPlatformApiMemberExpression(ast: Program): boolean;
13
12
  export declare function mayContainPlatformApiAccess(code: string, options?: {
14
13
  engine?: AstEngineName;
15
14
  parserLike?: AstParserLike;
16
- }): boolean;
17
- //#endregion
15
+ }): boolean;
@@ -1,7 +1,7 @@
1
- import { t as parseJsLikeWithEngine } from "../engine-CBE2OpFp.mjs";
2
- import { i as shouldUseNativeAst, r as loadNativeAstBindingSync, t as analyzeScriptWithNative } from "../native-C-xcrMBn.mjs";
1
+ import { t as parseJsLikeWithEngine } from "../engine-DNS4Kzzw.mjs";
2
+ import { a as loadNativeAstBindingSync, o as shouldUseNativeAst, r as analyzeScriptWithNative } from "../native-D8RHiEuF.mjs";
3
3
  import { walk } from "oxc-walker";
4
- //#region src/operations/platformApi.ts
4
+ // src/operations/platformApi.ts
5
5
  const platformApiIdentifierList = [
6
6
  "wx",
7
7
  "my",
@@ -52,5 +52,4 @@ function mayContainPlatformApiAccess(code, options) {
52
52
  return true;
53
53
  }
54
54
  }
55
- //#endregion
56
55
  export { hasPlatformApiMemberExpression, isPlatformApiIdentifier, isPlatformApiMemberExpression, mayContainPlatformApiAccess, mayContainPlatformApiIdentifierByText, platformApiIdentifierList, platformApiIdentifiers };