weapp-tailwindcss 5.0.0-next.24 → 5.0.0-next.26

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 (76) hide show
  1. package/dist/auto-CqyEtds4.js +115 -0
  2. package/dist/auto-CsWz6lsU.mjs +78 -0
  3. package/dist/{bundle-state-CP_BWXfx.mjs → bundle-state-CWcrb3mH.mjs} +1 -2
  4. package/dist/{bundle-state-DXFq2nEo.js → bundle-state-uCtqRm0p.js} +2 -3
  5. package/dist/bundlers/vite/serve-css-generation.d.ts +11 -0
  6. package/dist/cli.js +167 -6
  7. package/dist/cli.mjs +166 -5
  8. package/dist/context/runtime-package-replacements.d.ts +2 -0
  9. package/dist/context/style-options.d.ts +3 -0
  10. package/dist/core.js +1 -1
  11. package/dist/core.mjs +1 -1
  12. package/dist/css-macro/auto.d.ts +10 -0
  13. package/dist/css-macro/constants.d.ts +5 -2
  14. package/dist/css-macro/postcss.d.ts +1 -0
  15. package/dist/css-macro/postcss.js +7 -47
  16. package/dist/css-macro/postcss.mjs +2 -47
  17. package/dist/css-macro.js +15 -6
  18. package/dist/css-macro.mjs +15 -6
  19. package/dist/{defaults-C6sIKXgC.mjs → defaults-B-1EEhdL.mjs} +2 -1
  20. package/dist/{defaults-D3cFX6Cq.js → defaults-C10hYUch.js} +2 -1
  21. package/dist/defaults.js +1 -1
  22. package/dist/defaults.mjs +1 -1
  23. package/dist/{generator-BcH28HU-.js → generator-BH6a0xuB.js} +1 -1
  24. package/dist/{generator-DdEgn8nG.mjs → generator-iI_265gt.mjs} +1 -1
  25. package/dist/generator.js +2 -2
  26. package/dist/generator.mjs +2 -2
  27. package/dist/gulp.js +5 -5
  28. package/dist/gulp.mjs +5 -5
  29. package/dist/{incremental-runtime-class-set-Bux7viee.mjs → incremental-runtime-class-set-ECHyKwUL.mjs} +4 -16
  30. package/dist/{incremental-runtime-class-set-CWdfLHON.js → incremental-runtime-class-set-mY0v1k-Y.js} +4 -16
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.js +18 -4
  33. package/dist/index.mjs +6 -5
  34. package/dist/postcss-BwW8zO24.js +192 -0
  35. package/dist/postcss-BzaRjBL0.mjs +169 -0
  36. package/dist/{postcss-cD5PXmMU.js → postcss-DEEAZ8J5.js} +2 -2
  37. package/dist/{postcss-nk5bhdoV.mjs → postcss-DJoU--Z-.mjs} +2 -2
  38. package/dist/postcss.js +1 -1
  39. package/dist/postcss.mjs +1 -1
  40. package/dist/precheck-BI8oBeUg.mjs +4692 -0
  41. package/dist/{precheck-DtYqujIx.js → precheck-DLJg0_pu.js} +2070 -34
  42. package/dist/presets/index.d.ts +1 -0
  43. package/dist/presets/uni-app-x.d.ts +1 -0
  44. package/dist/presets.js +19 -5
  45. package/dist/presets.mjs +18 -6
  46. package/dist/{source-candidates-B7wmEa-G.mjs → source-candidates-DkScNh9A.mjs} +1 -1
  47. package/dist/{source-candidates-lHtAHLQq.js → source-candidates-mfvC9gMc.js} +1 -1
  48. package/dist/{tailwindcss-BtUBeOes.js → tailwindcss-Cm93idme.js} +17 -26
  49. package/dist/{tailwindcss-DO-VVR5k.mjs → tailwindcss-DFa5Yes8.mjs} +17 -26
  50. package/dist/types/index.d.ts +1 -1
  51. package/dist/types/shared.d.ts +3 -0
  52. package/dist/types/user-defined-options/general.d.ts +2 -1
  53. package/dist/types/user-defined-options/important.d.ts +3 -1
  54. package/dist/unocss/index.d.ts +2 -0
  55. package/dist/utils/options.d.ts +2 -0
  56. package/dist/utils/regex.d.ts +1 -0
  57. package/dist/{v3-engine-vHlppqaZ.js → v3-engine-CGsbY81C.js} +67 -19
  58. package/dist/{v3-engine-CXqgQZUc.mjs → v3-engine-CPJ9uGyr.mjs} +56 -20
  59. package/dist/{vite-BkNDGBZ2.js → vite-BM_ksf1q.js} +140 -21
  60. package/dist/{vite-BthAm8kt.mjs → vite-CqEF-Wx5.mjs} +140 -21
  61. package/dist/vite.js +1 -1
  62. package/dist/vite.mjs +1 -1
  63. package/dist/weapp-tw-css-import-rewrite-loader.js +327 -73
  64. package/dist/weapp-tw-runtime-classset-loader.js +1 -4
  65. package/dist/{webpack-prCus5xn.js → webpack-CfcuDhQ8.js} +10 -7
  66. package/dist/{webpack-hPc8wUAi.mjs → webpack-D--XZMBB.mjs} +11 -8
  67. package/dist/webpack.js +1 -1
  68. package/dist/webpack.mjs +1 -1
  69. package/package.json +14 -14
  70. package/dist/constants-BG12WAKw.mjs +0 -44
  71. package/dist/constants-BeeyfJ9k.js +0 -73
  72. package/dist/precheck-DreRGvYH.mjs +0 -2668
  73. /package/dist/{logger-EVNB9z7i.js → logger-Cdzl3p8j.js} +0 -0
  74. /package/dist/{logger-CZUxvJJD.mjs → logger-Dr7IvyH2.mjs} +0 -0
  75. /package/dist/{utils-CGBVVNm6.mjs → utils-B2SJgA1L.mjs} +0 -0
  76. /package/dist/{utils-4ODFyoqD.js → utils-CSA174-I.js} +0 -0
@@ -0,0 +1,4692 @@
1
+ import { B as createDebug, C as createTailwindV4Engine, K as resolveBooleanObjectOption, c as getRuntimeClassSetCacheEntry, d as invalidateRuntimeClassSet, q as omitUndefined, s as ensureTailwindcssRuntimePatch, u as getRuntimeClassSetSignatureWithSources, x as resolveTailwindV4SourceFromPatcher } from "./v3-engine-CPJ9uGyr.mjs";
2
+ import { a as resolveDefaultCssPreflight, i as getDefaultOptions, o as DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH, s as HARD_PARSE_CACHE_MAX_ENTRIES } from "./defaults-B-1EEhdL.mjs";
3
+ import { i as isMap, n as defuOverrideArray } from "./utils-B2SJgA1L.mjs";
4
+ import { a as applyV4CssCalcDefaults, i as resolveUniAppXOptions, o as warnMissingCssEntries, t as createTailwindcssPatcherFromContext } from "./tailwindcss-DFa5Yes8.mjs";
5
+ import path from "node:path";
6
+ import process from "node:process";
7
+ import { logger, pc } from "@weapp-tailwindcss/logger";
8
+ import { rm } from "node:fs/promises";
9
+ import { createStyleHandler } from "@weapp-tailwindcss/postcss";
10
+ import { Buffer } from "node:buffer";
11
+ import { LRUCache } from "lru-cache";
12
+ import { md5 as md5Hash } from "@weapp-tailwindcss/shared/node";
13
+ import { MappingChars2String, escape } from "@weapp-core/escape";
14
+ import _babelTraverse from "@babel/traverse";
15
+ import { parse, parseExpression } from "@babel/parser";
16
+ import MagicString from "magic-string";
17
+ import { jsStringEscape } from "@ast-core/escape";
18
+ import { splitCode } from "@weapp-tailwindcss/shared/extractors";
19
+ import * as t from "@babel/types";
20
+ //#region src/cache/index.ts
21
+ function isProcessResult(value) {
22
+ return typeof value === "object" && value !== null && "result" in value;
23
+ }
24
+ function createCache(options) {
25
+ const disabled = options === false;
26
+ const hashMap = /* @__PURE__ */ new Map();
27
+ const instance = new LRUCache({
28
+ max: 1024,
29
+ ttl: 0,
30
+ ttlAutopurge: false
31
+ });
32
+ const cache = {
33
+ hashMap,
34
+ instance,
35
+ hasHashKey(key) {
36
+ return hashMap.has(key);
37
+ },
38
+ getHashValue(key) {
39
+ return hashMap.get(key);
40
+ },
41
+ setHashValue(key, value) {
42
+ return hashMap.set(key, value);
43
+ },
44
+ get(key) {
45
+ return instance.get(key);
46
+ },
47
+ set(key, value) {
48
+ return instance.set(key, value);
49
+ },
50
+ computeHash(message) {
51
+ return md5Hash(message);
52
+ },
53
+ calcHashValueChanged(key, hash) {
54
+ const hit = hashMap.get(key);
55
+ if (hit) hashMap.set(key, {
56
+ changed: hash !== hit.hash,
57
+ hash
58
+ });
59
+ else hashMap.set(key, {
60
+ changed: true,
61
+ hash
62
+ });
63
+ return cache;
64
+ },
65
+ has(key) {
66
+ return instance.has(key);
67
+ },
68
+ async process({ key, hashKey, rawSource, hash, resolveCache, transform, onCacheHit }) {
69
+ if (disabled) {
70
+ const value = await transform();
71
+ return isProcessResult(value) ? value.result : value;
72
+ }
73
+ const cacheHashKey = hashKey ?? key;
74
+ let hasChanged = true;
75
+ if (hash != null || rawSource != null) {
76
+ const nextHash = hash ?? cache.computeHash(rawSource);
77
+ cache.calcHashValueChanged(cacheHashKey, nextHash);
78
+ hasChanged = cache.getHashValue(cacheHashKey)?.changed ?? true;
79
+ }
80
+ const readCache = resolveCache ?? (() => cache.get(key));
81
+ if (!hasChanged) {
82
+ const cached = readCache();
83
+ if (cached !== void 0) {
84
+ await onCacheHit?.(cached);
85
+ return cached;
86
+ }
87
+ }
88
+ const value = await transform();
89
+ const normalized = isProcessResult(value) ? value : { result: value };
90
+ const stored = normalized.cacheValue ?? normalized.result;
91
+ cache.set(key, stored);
92
+ return normalized.result;
93
+ }
94
+ };
95
+ return cache;
96
+ }
97
+ function initializeCache(cacheConfig) {
98
+ if (typeof cacheConfig === "boolean" || cacheConfig === void 0) return createCache(cacheConfig);
99
+ return cacheConfig;
100
+ }
101
+ //#endregion
102
+ //#region src/tailwindcss/runtime.ts
103
+ const debug$1 = createDebug("[tailwindcss:runtime] ");
104
+ const refreshTailwindcssPatcherSymbol = Symbol.for("weapp-tailwindcss.refreshTailwindcssPatcher");
105
+ function createTailwindRuntimeReadyPromise(twPatcher) {
106
+ return Promise.resolve().then(async () => {
107
+ await ensureTailwindcssRuntimePatch(twPatcher);
108
+ invalidateRuntimeClassSet(twPatcher);
109
+ });
110
+ }
111
+ const runtimeClassSetStateCache = /* @__PURE__ */ new WeakMap();
112
+ function getRuntimeClassSetStateEntry(state) {
113
+ let entry = runtimeClassSetStateCache.get(state);
114
+ if (!entry) {
115
+ entry = {};
116
+ runtimeClassSetStateCache.set(state, entry);
117
+ }
118
+ return entry;
119
+ }
120
+ async function refreshTailwindRuntimeState(state, forceOrOptions) {
121
+ const normalizedOptions = typeof forceOrOptions === "boolean" ? { force: forceOrOptions } : forceOrOptions;
122
+ const force = normalizedOptions.force;
123
+ const clearCache = normalizedOptions.clearCache === true;
124
+ if (!force) return false;
125
+ debug$1("refresh runtime state start, clearCache=%s major=%s", clearCache, state.twPatcher.majorVersion ?? "unknown");
126
+ await state.readyPromise;
127
+ let refreshed = false;
128
+ if (typeof state.refreshTailwindcssPatcher === "function") {
129
+ const next = await state.refreshTailwindcssPatcher({ clearCache });
130
+ if (next !== state.twPatcher) state.twPatcher = next;
131
+ refreshed = true;
132
+ }
133
+ if (refreshed) state.readyPromise = createTailwindRuntimeReadyPromise(state.twPatcher);
134
+ debug$1("refresh runtime state end, refreshed=%s major=%s", refreshed, state.twPatcher.majorVersion ?? "unknown");
135
+ return refreshed;
136
+ }
137
+ async function ensureRuntimeClassSet(state, options = {}) {
138
+ const forceRefresh = options.forceRefresh === true;
139
+ const forceCollect = options.forceCollect === true;
140
+ const clearCache = options.clearCache === true;
141
+ const allowEmpty = options.allowEmpty === true;
142
+ if (forceRefresh) await refreshTailwindRuntimeState(state, {
143
+ force: true,
144
+ clearCache
145
+ });
146
+ await state.readyPromise;
147
+ const entry = getRuntimeClassSetStateEntry(state);
148
+ const signature = await getRuntimeClassSetSignatureWithSources(state.twPatcher);
149
+ const signatureChanged = entry.signature !== signature;
150
+ const shouldForceCollect = forceCollect || forceRefresh || signatureChanged;
151
+ if (!shouldForceCollect) {
152
+ if (entry.value && (allowEmpty || entry.value.size > 0)) return entry.value;
153
+ if (entry.promise) return entry.promise;
154
+ }
155
+ const task = (async () => {
156
+ const collected = await collectRuntimeClassSet(state.twPatcher, {
157
+ force: shouldForceCollect,
158
+ skipRefresh: true,
159
+ clearCache
160
+ });
161
+ if (allowEmpty || collected.size > 0) return collected;
162
+ await refreshTailwindRuntimeState(state, {
163
+ force: true,
164
+ clearCache: true
165
+ });
166
+ await state.readyPromise;
167
+ return collectRuntimeClassSet(state.twPatcher, {
168
+ force: true,
169
+ skipRefresh: true,
170
+ clearCache: true
171
+ });
172
+ })();
173
+ entry.promise = task;
174
+ try {
175
+ const runtimeSet = await task;
176
+ entry.value = runtimeSet;
177
+ entry.signature = await getRuntimeClassSetSignatureWithSources(state.twPatcher);
178
+ return runtimeSet;
179
+ } finally {
180
+ if (entry.promise === task) entry.promise = void 0;
181
+ }
182
+ }
183
+ function shouldPreferSync(majorVersion) {
184
+ if (majorVersion == null) return true;
185
+ if (majorVersion === 3) return true;
186
+ if (majorVersion === 4) return true;
187
+ return false;
188
+ }
189
+ function tryGetRuntimeClassSetSync(twPatcher) {
190
+ if (typeof twPatcher.getClassSetSync !== "function") return;
191
+ if (!shouldPreferSync(twPatcher.majorVersion)) return;
192
+ try {
193
+ const set = twPatcher.getClassSetSync();
194
+ if (set && set.size === 0) return;
195
+ return set;
196
+ } catch (error) {
197
+ if (twPatcher.majorVersion === 4) debug$1("getClassSetSync() unavailable for tailwindcss v4, fallback to async getClassSet(): %O", error);
198
+ else debug$1("getClassSetSync() failed, fallback to async getClassSet(): %O", error);
199
+ return;
200
+ }
201
+ }
202
+ async function collectTailwindV4GeneratorClassSet(twPatcher) {
203
+ try {
204
+ const generated = await createTailwindV4Engine(await resolveTailwindV4SourceFromPatcher(twPatcher)).generate({
205
+ scanSources: true,
206
+ target: "tailwind"
207
+ });
208
+ debug$1("runtime class set resolved via tailwindcss v4 generator source scan, size=%d", generated.classSet.size);
209
+ return generated.classSet;
210
+ } catch (error) {
211
+ debug$1("tailwindcss v4 generator source scan failed, continuing fallback chain: %O", error);
212
+ return;
213
+ }
214
+ }
215
+ async function collectRuntimeClassSet(twPatcher, options = {}) {
216
+ let activePatcher = twPatcher;
217
+ if (options.force && !options.skipRefresh) {
218
+ const refresh = activePatcher[refreshTailwindcssPatcherSymbol];
219
+ if (typeof refresh === "function") try {
220
+ const refreshed = await refresh({ clearCache: options.clearCache === true });
221
+ if (refreshed) activePatcher = refreshed;
222
+ } catch (error) {
223
+ debug$1("refreshTailwindcssPatcher failed, continuing with existing patcher: %O", error);
224
+ }
225
+ }
226
+ const entry = getRuntimeClassSetCacheEntry(activePatcher);
227
+ const signature = await getRuntimeClassSetSignatureWithSources(activePatcher);
228
+ if (!options.force) {
229
+ if (entry.value && entry.signature === signature) return entry.value;
230
+ if (entry.promise) return entry.promise;
231
+ } else entry.value = void 0;
232
+ const task = (async () => {
233
+ await ensureTailwindcssRuntimePatch(activePatcher);
234
+ const preExtractSyncSet = options.force ? tryGetRuntimeClassSetSync(activePatcher) : void 0;
235
+ if (preExtractSyncSet) debug$1("runtime class set snapshot via getClassSetSync() before extract(), size=%d", preExtractSyncSet.size);
236
+ const preferExtract = options.force === true;
237
+ try {
238
+ const result = await activePatcher.extract({ write: false });
239
+ if (result?.classSet) {
240
+ if (result.classSet.size > 0) {
241
+ debug$1("runtime class set resolved via extract(), size=%d", result.classSet.size);
242
+ return result.classSet;
243
+ }
244
+ if (preferExtract && activePatcher.majorVersion !== 4) {
245
+ debug$1("runtime class set resolved via empty extract() on force collect, size=0");
246
+ return result.classSet;
247
+ }
248
+ if (preferExtract) debug$1("runtime class set from extract() is empty on force collect, fallback to generator/sync/async class set");
249
+ else debug$1("runtime class set from extract() is empty, fallback to sync/async class set");
250
+ }
251
+ } catch (error) {
252
+ debug$1("extract() failed, fallback to getClassSet(): %O", error);
253
+ }
254
+ if (activePatcher.majorVersion === 4) {
255
+ const generatorClassSet = await collectTailwindV4GeneratorClassSet(activePatcher);
256
+ if (generatorClassSet && generatorClassSet.size > 0) return generatorClassSet;
257
+ }
258
+ if (preExtractSyncSet) {
259
+ debug$1("runtime class set fallback to pre-extract sync snapshot, size=%d", preExtractSyncSet.size);
260
+ return preExtractSyncSet;
261
+ }
262
+ const syncSet = tryGetRuntimeClassSetSync(activePatcher);
263
+ if (syncSet) {
264
+ debug$1("runtime class set resolved via getClassSetSync(), size=%d", syncSet.size);
265
+ return syncSet;
266
+ }
267
+ try {
268
+ const fallbackSet = await Promise.resolve(activePatcher.getClassSet());
269
+ if (fallbackSet) {
270
+ debug$1("runtime class set resolved via getClassSet(), size=%d", fallbackSet.size);
271
+ return fallbackSet;
272
+ }
273
+ } catch (error) {
274
+ debug$1("getClassSet() failed, returning empty set: %O", error);
275
+ }
276
+ return /* @__PURE__ */ new Set();
277
+ })();
278
+ entry.promise = task;
279
+ entry.signature = signature;
280
+ try {
281
+ const resolved = await task;
282
+ entry.value = resolved;
283
+ entry.promise = void 0;
284
+ entry.signature = signature;
285
+ return resolved;
286
+ } catch (error) {
287
+ entry.promise = void 0;
288
+ throw error;
289
+ }
290
+ }
291
+ //#endregion
292
+ //#region src/tailwindcss/runtime-logs.ts
293
+ const runtimeLogDedupeHolder = globalThis;
294
+ const runtimeLogDedupe = runtimeLogDedupeHolder.__WEAPP_TW_RUNTIME_LOG_DEDUPE__ ?? (runtimeLogDedupeHolder.__WEAPP_TW_RUNTIME_LOG_DEDUPE__ = /* @__PURE__ */ new Set());
295
+ function createRuntimeLogKey(category, baseDir, rootPath, version) {
296
+ return JSON.stringify([
297
+ category,
298
+ baseDir ?? process.cwd(),
299
+ rootPath ?? "",
300
+ version ?? ""
301
+ ]);
302
+ }
303
+ function markRuntimeLog(category, baseDir, rootPath, version) {
304
+ const key = createRuntimeLogKey(category, baseDir, rootPath, version);
305
+ if (runtimeLogDedupe.has(key)) return false;
306
+ runtimeLogDedupe.add(key);
307
+ return true;
308
+ }
309
+ function logRuntimeTailwindcssTarget(baseDir, rootPath, version) {
310
+ if (!markRuntimeLog("target", baseDir, rootPath, version)) return;
311
+ const versionText = version ? ` (v${version})` : "";
312
+ logger.info("%s 使用 Tailwind CSS%s", "Weapp-tailwindcss", versionText);
313
+ }
314
+ function logRuntimeTailwindcssVersion(baseDir, rootPath, version) {
315
+ if (version) {
316
+ if (!markRuntimeLog("version", baseDir, rootPath, version)) return;
317
+ logger.success(`当前使用 ${pc.cyanBright("Tailwind CSS")} 版本为: ${pc.underline(pc.bold(pc.green(version)))}`);
318
+ return;
319
+ }
320
+ if (!markRuntimeLog("missing", baseDir, rootPath, version)) return;
321
+ logger.warn(`${pc.cyanBright("Tailwind CSS")} 未安装,已跳过版本检测与运行时初始化。`);
322
+ }
323
+ //#endregion
324
+ //#region src/tailwindcss/targets.ts
325
+ function formatRelativeToBase(targetPath, baseDir) {
326
+ const normalized = path.normalize(targetPath);
327
+ if (!baseDir) return normalized.replace(/\\/g, "/");
328
+ const relative = path.relative(baseDir, normalized);
329
+ if (!relative || relative === ".") return ".";
330
+ if (relative.startsWith("..")) return normalized.replace(/\\/g, "/");
331
+ return path.join(".", relative).replace(/\\/g, "/");
332
+ }
333
+ function logTailwindcssTarget(patcher, baseDir) {
334
+ const packageInfo = patcher?.packageInfo;
335
+ const label = "Weapp-tailwindcss";
336
+ if (!packageInfo?.rootPath) {
337
+ logger.warn("%s 未找到 Tailwind CSS 依赖,请检查在 %s 是否已安装 tailwindcss", label, baseDir ?? process.cwd());
338
+ return;
339
+ }
340
+ const displayPath = formatRelativeToBase(packageInfo.rootPath, baseDir);
341
+ const version = packageInfo.version ? ` (v${packageInfo.version})` : "";
342
+ logRuntimeTailwindcssTarget(baseDir, packageInfo.rootPath, packageInfo.version);
343
+ logger.debug("%s 解析 Tailwind CSS -> %s%s", label, displayPath, version);
344
+ }
345
+ //#endregion
346
+ //#region src/unocss/index.ts
347
+ function normalizeUnocssOptions(unocss) {
348
+ return resolveBooleanObjectOption(unocss, {});
349
+ }
350
+ function resolveUnocssBareArbitraryValues(arbitraryValues, unocss) {
351
+ const baseArbitraryValues = arbitraryValues ?? {};
352
+ const options = normalizeUnocssOptions(unocss);
353
+ if (!options) return baseArbitraryValues;
354
+ if (baseArbitraryValues.bareArbitraryValues !== void 0 && baseArbitraryValues.bareArbitraryValues !== false) return baseArbitraryValues;
355
+ const bareArbitraryValues = options.bareArbitraryValues ?? true;
356
+ if (bareArbitraryValues === false) return baseArbitraryValues;
357
+ return {
358
+ ...baseArbitraryValues,
359
+ bareArbitraryValues
360
+ };
361
+ }
362
+ //#endregion
363
+ //#region src/context/compiler-context-cache.ts
364
+ const PAREN_CONTENT_RE = /\(([^)]+)\)/u;
365
+ const AT_LOCATION_RE = /at\s+(\S.*)$/u;
366
+ const TRAILING_LINE_COL_RE = /:\d+(?::\d+)?$/u;
367
+ const globalCacheHolder = globalThis;
368
+ const compilerContextCache = globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__ ?? (globalCacheHolder.__WEAPP_TW_COMPILER_CONTEXT_CACHE__ = /* @__PURE__ */ new Map());
369
+ const compilerContextKeyCacheByOptions = /* @__PURE__ */ new WeakMap();
370
+ const compilerContextKeyCacheWithoutOptions = /* @__PURE__ */ new Map();
371
+ function withCircularGuard(value, stack, factory) {
372
+ if (stack.has(value)) throw new TypeError("Cannot serialize circular structure in compiler context options");
373
+ stack.add(value);
374
+ try {
375
+ return factory();
376
+ } finally {
377
+ stack.delete(value);
378
+ }
379
+ }
380
+ function encodeTaggedValue(type, value) {
381
+ const record = { __type: type };
382
+ if (value !== void 0) record["value"] = value;
383
+ return record;
384
+ }
385
+ function hasExplicitOptionBasedir(opts) {
386
+ return typeof opts?.tailwindcssBasedir === "string" && opts.tailwindcssBasedir.length > 0;
387
+ }
388
+ function shouldProbeCallerLocation(opts) {
389
+ if (hasExplicitOptionBasedir(opts)) return false;
390
+ return !(process.env["WEAPP_TAILWINDCSS_BASEDIR"] || process.env["WEAPP_TAILWINDCSS_BASE_DIR"] || process.env["TAILWINDCSS_BASEDIR"] || process.env["TAILWINDCSS_BASE_DIR"]);
391
+ }
392
+ function detectCallerLocation() {
393
+ const stack = (/* @__PURE__ */ new Error("compiler-context-cache stack probe")).stack;
394
+ if (!stack) return;
395
+ const lines = stack.split("\n");
396
+ for (const line of lines) {
397
+ const location = (line.match(PAREN_CONTENT_RE) ?? line.match(AT_LOCATION_RE))?.[1];
398
+ if (!location) continue;
399
+ const candidatePath = location.replace(TRAILING_LINE_COL_RE, "");
400
+ if (!candidatePath || !path.isAbsolute(candidatePath)) continue;
401
+ if (candidatePath.includes(`${path.sep}weapp-tailwindcss${path.sep}src${path.sep}`) || candidatePath.includes(`${path.sep}weapp-tailwindcss${path.sep}dist${path.sep}`) || candidatePath.includes(`${path.sep}node_modules${path.sep}weapp-tailwindcss${path.sep}`)) continue;
402
+ return candidatePath;
403
+ }
404
+ }
405
+ function getRuntimeCacheScope(opts) {
406
+ if (hasExplicitOptionBasedir(opts)) return { caller: void 0 };
407
+ const runtimeScope = {
408
+ caller: void 0,
409
+ cwd: process.cwd(),
410
+ init_cwd: process.env["INIT_CWD"],
411
+ npm_config_local_prefix: process.env["npm_config_local_prefix"],
412
+ npm_package_json: process.env["npm_package_json"],
413
+ pnpm_package_name: process.env["PNPM_PACKAGE_NAME"],
414
+ pwd: process.env["PWD"],
415
+ tailwindcss_base_dir: process.env["TAILWINDCSS_BASE_DIR"],
416
+ tailwindcss_basedir: process.env["TAILWINDCSS_BASEDIR"],
417
+ uni_app_input_dir: process.env["UNI_APP_INPUT_DIR"],
418
+ uni_cli_root: process.env["UNI_CLI_ROOT"],
419
+ uni_input_dir: process.env["UNI_INPUT_DIR"],
420
+ uni_input_root: process.env["UNI_INPUT_ROOT"],
421
+ weapp_tailwindcss_base_dir: process.env["WEAPP_TAILWINDCSS_BASE_DIR"],
422
+ weapp_tailwindcss_basedir: process.env["WEAPP_TAILWINDCSS_BASEDIR"]
423
+ };
424
+ if (shouldProbeCallerLocation(opts)) runtimeScope.caller = detectCallerLocation();
425
+ return runtimeScope;
426
+ }
427
+ function serializeNormalizedValue(value) {
428
+ return JSON.stringify(value);
429
+ }
430
+ function createRuntimeCacheScopeKey(opts) {
431
+ return serializeNormalizedValue(normalizeOptionsValue(getRuntimeCacheScope(opts)));
432
+ }
433
+ function getCompilerContextKeyCacheStore(opts) {
434
+ if (!opts) return compilerContextKeyCacheWithoutOptions;
435
+ let store = compilerContextKeyCacheByOptions.get(opts);
436
+ if (!store) {
437
+ store = /* @__PURE__ */ new Map();
438
+ compilerContextKeyCacheByOptions.set(opts, store);
439
+ }
440
+ return store;
441
+ }
442
+ function createComparableNormalizedValue(rawValue, stack) {
443
+ const normalized = normalizeOptionsValue(rawValue, stack);
444
+ return {
445
+ normalized,
446
+ sortKey: serializeNormalizedValue(normalized)
447
+ };
448
+ }
449
+ function getRuntimeCacheScopeValue(opts) {
450
+ return {
451
+ options: opts ?? {},
452
+ runtime: getRuntimeCacheScope(opts)
453
+ };
454
+ }
455
+ function normalizeOptionsValue(rawValue, stack = /* @__PURE__ */ new WeakSet()) {
456
+ if (rawValue === null) return null;
457
+ if (rawValue === void 0) return encodeTaggedValue("Undefined");
458
+ const type = typeof rawValue;
459
+ if (type === "string") return rawValue;
460
+ if (type === "boolean") return rawValue;
461
+ if (type === "number") {
462
+ const numericValue = rawValue;
463
+ if (Number.isNaN(numericValue)) return encodeTaggedValue("Number", "NaN");
464
+ if (!Number.isFinite(numericValue)) return encodeTaggedValue("Number", numericValue > 0 ? "Infinity" : "-Infinity");
465
+ if (Object.is(numericValue, -0)) return encodeTaggedValue("Number", "-0");
466
+ return numericValue;
467
+ }
468
+ if (type === "bigint") return encodeTaggedValue("BigInt", rawValue.toString());
469
+ if (type === "symbol") {
470
+ const symbolValue = rawValue;
471
+ return encodeTaggedValue("Symbol", symbolValue.description ?? String(symbolValue));
472
+ }
473
+ if (type === "function") return encodeTaggedValue("Function", rawValue.toString());
474
+ if (Array.isArray(rawValue)) return withCircularGuard(rawValue, stack, () => rawValue.map((item) => normalizeOptionsValue(item, stack)));
475
+ if (rawValue instanceof Date) return encodeTaggedValue("Date", rawValue.toISOString());
476
+ if (rawValue instanceof RegExp) return {
477
+ __type: "RegExp",
478
+ source: rawValue.source,
479
+ flags: rawValue.flags
480
+ };
481
+ if (typeof Buffer !== "undefined" && Buffer.isBuffer(rawValue)) return encodeTaggedValue("Buffer", rawValue.toString("base64"));
482
+ if (ArrayBuffer.isView(rawValue)) {
483
+ const view = rawValue;
484
+ const buffer = Buffer.from(view.buffer, view.byteOffset, view.byteLength);
485
+ return encodeTaggedValue(view.constructor?.name ?? "ArrayBufferView", buffer.toString("base64"));
486
+ }
487
+ if (rawValue instanceof ArrayBuffer) return encodeTaggedValue("ArrayBuffer", Buffer.from(rawValue).toString("base64"));
488
+ if (rawValue instanceof Set) return withCircularGuard(rawValue, stack, () => {
489
+ const normalizedEntries = Array.from(rawValue, (element) => createComparableNormalizedValue(element, stack));
490
+ normalizedEntries.sort((a, b) => a.sortKey.localeCompare(b.sortKey));
491
+ return {
492
+ __type: "Set",
493
+ value: normalizedEntries.map((entry) => entry.normalized)
494
+ };
495
+ });
496
+ if (rawValue instanceof Map) return withCircularGuard(rawValue, stack, () => {
497
+ const normalizedEntries = Array.from(rawValue.entries(), ([key, entryValue]) => {
498
+ const normalizedKey = createComparableNormalizedValue(key, stack);
499
+ return {
500
+ key: normalizedKey.normalized,
501
+ sortKey: normalizedKey.sortKey,
502
+ value: normalizeOptionsValue(entryValue, stack)
503
+ };
504
+ });
505
+ normalizedEntries.sort((a, b) => a.sortKey.localeCompare(b.sortKey));
506
+ return {
507
+ __type: "Map",
508
+ value: normalizedEntries.map((entry) => [entry.key, entry.value])
509
+ };
510
+ });
511
+ if (typeof URL !== "undefined" && rawValue instanceof URL) return encodeTaggedValue("URL", rawValue.toString());
512
+ if (rawValue instanceof Error) {
513
+ const errorValue = rawValue;
514
+ return {
515
+ __type: "Error",
516
+ name: errorValue.name,
517
+ message: errorValue.message,
518
+ stack: errorValue.stack ?? ""
519
+ };
520
+ }
521
+ if (rawValue instanceof Promise) return encodeTaggedValue("Promise");
522
+ if (rawValue instanceof WeakMap) return encodeTaggedValue("WeakMap");
523
+ if (rawValue instanceof WeakSet) return encodeTaggedValue("WeakSet");
524
+ if (rawValue && typeof rawValue === "object") return withCircularGuard(rawValue, stack, () => {
525
+ const result = {};
526
+ const entries = Object.entries(rawValue);
527
+ entries.sort(([a], [b]) => a.localeCompare(b));
528
+ for (const [key, entryValue] of entries) result[key] = normalizeOptionsValue(entryValue, stack);
529
+ return result;
530
+ });
531
+ return encodeTaggedValue(typeof rawValue, String(rawValue));
532
+ }
533
+ function createCompilerContextCacheKey(opts) {
534
+ try {
535
+ const runtimeCacheScopeKey = createRuntimeCacheScopeKey(opts);
536
+ const keyStore = getCompilerContextKeyCacheStore(opts);
537
+ const cached = keyStore.get(runtimeCacheScopeKey);
538
+ if (cached !== void 0) return cached;
539
+ const cacheKey = md5Hash(serializeNormalizedValue(normalizeOptionsValue(getRuntimeCacheScopeValue(opts))));
540
+ keyStore.set(runtimeCacheScopeKey, cacheKey);
541
+ return cacheKey;
542
+ } catch (error) {
543
+ logger.debug("skip compiler context cache: %O", error);
544
+ return;
545
+ }
546
+ }
547
+ function withCompilerContextCache(opts, factory) {
548
+ const cacheKey = createCompilerContextCacheKey(opts);
549
+ if (cacheKey) {
550
+ const cached = compilerContextCache.get(cacheKey);
551
+ if (cached) return cached;
552
+ }
553
+ const ctx = factory();
554
+ if (cacheKey) compilerContextCache.set(cacheKey, ctx);
555
+ return ctx;
556
+ }
557
+ //#endregion
558
+ //#region src/context/custom-attributes.ts
559
+ function toCustomAttributesEntities(customAttributes) {
560
+ if (!customAttributes) return [];
561
+ if (isMap(customAttributes)) return [...customAttributes.entries()];
562
+ return Object.entries(customAttributes);
563
+ }
564
+ //#endregion
565
+ //#region src/babel/index.ts
566
+ function _interopDefaultCompat(e) {
567
+ return e && typeof e === "object" && "default" in e ? e.default : e;
568
+ }
569
+ const traverse = _interopDefaultCompat(_babelTraverse);
570
+ //#endregion
571
+ //#region src/utils/regex.ts
572
+ function escapeStringRegexp(str) {
573
+ if (typeof str !== "string") throw new TypeError("Expected a string");
574
+ return str.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&").replaceAll("-", "\\x2d");
575
+ }
576
+ //#endregion
577
+ //#region src/utils/nameMatcher.ts
578
+ const NEVER_MATCH_NAME$1 = () => false;
579
+ const GLOBAL_FLAG_REGEXP = /g/g;
580
+ function buildFuzzyMatcher(fuzzyStrings) {
581
+ if (fuzzyStrings.length === 0) return;
582
+ if (fuzzyStrings.length === 1) {
583
+ const [needle] = fuzzyStrings;
584
+ if (needle === void 0) return;
585
+ return (value) => value.includes(needle);
586
+ }
587
+ const unique = [...new Set(fuzzyStrings)];
588
+ const pattern = new RegExp(unique.map(escapeStringRegexp).join("|"));
589
+ return (value) => pattern.test(value);
590
+ }
591
+ function normaliseRegex(regex) {
592
+ const { source, flags } = regex;
593
+ if (!flags.includes("g")) return regex;
594
+ return new RegExp(source, flags.replace(GLOBAL_FLAG_REGEXP, ""));
595
+ }
596
+ function createNameMatcher(list, { exact = false } = {}) {
597
+ if (!list || list.length === 0) return NEVER_MATCH_NAME$1;
598
+ const exactStrings = exact ? /* @__PURE__ */ new Set() : void 0;
599
+ const fuzzyStrings = [];
600
+ const regexList = [];
601
+ for (const item of list) if (typeof item === "string") if (exact) exactStrings.add(item);
602
+ else fuzzyStrings.push(item);
603
+ else regexList.push(normaliseRegex(item));
604
+ if (exact) {
605
+ const exactStringCount = exactStrings?.size ?? 0;
606
+ if (exactStringCount === 1 && regexList.length === 0) {
607
+ const [needle] = exactStrings;
608
+ if (needle === void 0) return NEVER_MATCH_NAME$1;
609
+ return (value) => value === needle;
610
+ }
611
+ if (regexList.length === 0) return (value) => exactStrings.has(value);
612
+ if (exactStringCount === 0 && regexList.length === 1) {
613
+ const [regex] = regexList;
614
+ if (!regex) return NEVER_MATCH_NAME$1;
615
+ return (value) => regex.test(value);
616
+ }
617
+ return (value) => {
618
+ if (exactStrings?.has(value)) return true;
619
+ return regexList.some((regex) => regex.test(value));
620
+ };
621
+ }
622
+ const fuzzyMatcher = exact ? void 0 : buildFuzzyMatcher(fuzzyStrings);
623
+ const hasRegex = regexList.length > 0;
624
+ if (fuzzyMatcher && !hasRegex) return fuzzyMatcher;
625
+ if (!fuzzyMatcher && regexList.length === 1) {
626
+ const [regex] = regexList;
627
+ if (!regex) return NEVER_MATCH_NAME$1;
628
+ return (value) => regex.test(value);
629
+ }
630
+ return (value) => {
631
+ if (fuzzyMatcher?.(value)) return true;
632
+ if (!hasRegex) return false;
633
+ return regexList.some((regex) => regex.test(value));
634
+ };
635
+ }
636
+ //#endregion
637
+ //#region src/js/babel/parse.ts
638
+ const parseCache = new LRUCache({ max: HARD_PARSE_CACHE_MAX_ENTRIES });
639
+ function genCacheKey(source, options) {
640
+ if (typeof options === "string") return `${md5Hash(source)}:${options}`;
641
+ return `${md5Hash(source)}:${JSON.stringify(options, (_, val) => typeof val === "function" ? val.toString() : val)}`;
642
+ }
643
+ function normalizeCacheMaxEntries(value) {
644
+ if (typeof value !== "number" || !Number.isFinite(value)) return 128;
645
+ return Math.min(Math.max(Math.floor(value), 0), HARD_PARSE_CACHE_MAX_ENTRIES);
646
+ }
647
+ function normalizeCacheMaxSourceLength(value) {
648
+ if (typeof value !== "number" || !Number.isFinite(value)) return DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH;
649
+ return Math.max(Math.floor(value), 0);
650
+ }
651
+ function trimParseCache(maxEntries) {
652
+ while (parseCache.size > maxEntries) parseCache.pop();
653
+ }
654
+ function babelParse(code, opts = {}) {
655
+ const { cache, cacheKey, cacheMaxEntries, cacheMaxSourceLength, ...rest } = opts;
656
+ const maxEntries = normalizeCacheMaxEntries(cacheMaxEntries);
657
+ const maxSourceLength = normalizeCacheMaxSourceLength(cacheMaxSourceLength);
658
+ const shouldCache = cache === true && maxEntries > 0 && code.length <= maxSourceLength;
659
+ const cacheKeyString = shouldCache ? genCacheKey(code, cacheKey ?? rest) : void 0;
660
+ let result;
661
+ if (shouldCache) {
662
+ trimParseCache(maxEntries);
663
+ result = parseCache.get(cacheKeyString);
664
+ }
665
+ if (!result) {
666
+ const { cache: _cache, cacheKey: _cacheKey, cacheMaxEntries: _cacheMaxEntries, cacheMaxSourceLength: _cacheMaxSourceLength, ...parseOptions } = opts;
667
+ result = parse(code, parseOptions);
668
+ if (shouldCache) {
669
+ parseCache.set(cacheKeyString, result);
670
+ trimParseCache(maxEntries);
671
+ }
672
+ }
673
+ return result;
674
+ }
675
+ //#endregion
676
+ //#region src/wxml/shared.ts
677
+ const NEWLINE_RE = /[\n\r]+/g;
678
+ function replaceWxml(original, options = {
679
+ keepEOL: false,
680
+ escapeMap: MappingChars2String
681
+ }) {
682
+ const { keepEOL, escapeMap, ignoreHead } = options;
683
+ let res = original;
684
+ if (!keepEOL) res = res.replaceAll(NEWLINE_RE, "");
685
+ res = escape(res, omitUndefined({
686
+ map: escapeMap,
687
+ ignoreHead
688
+ }));
689
+ return res;
690
+ }
691
+ //#endregion
692
+ //#region src/shared/classname-transform.ts
693
+ const escapedCandidateCacheByEscapeMap = /* @__PURE__ */ new WeakMap();
694
+ const defaultEscapedCandidateCache = /* @__PURE__ */ new Map();
695
+ let lastEscapedCandidateEscapeMap;
696
+ let lastEscapedCandidateCacheStore;
697
+ function isUrlLikeCandidate(candidate) {
698
+ return candidate.startsWith("//") || candidate.startsWith("http://") || candidate.startsWith("https://");
699
+ }
700
+ function isArbitraryValueCandidate(candidate) {
701
+ let hasOpenBracket = false;
702
+ let hasCloseBracket = false;
703
+ for (let i = 0; i < candidate.length; i++) {
704
+ const char = candidate[i];
705
+ if (char === "[") hasOpenBracket = true;
706
+ else if (char === "]") hasCloseBracket = true;
707
+ if (hasOpenBracket && hasCloseBracket) break;
708
+ }
709
+ if (!hasOpenBracket || !hasCloseBracket) return false;
710
+ if (isUrlLikeCandidate(candidate.trim())) return false;
711
+ return true;
712
+ }
713
+ function shouldEnableArbitraryValueFallbackByInputs(classNameSet, jsArbitraryValueFallback, tailwindcssMajorVersion) {
714
+ if (jsArbitraryValueFallback === true) return true;
715
+ if (jsArbitraryValueFallback === false) return false;
716
+ return tailwindcssMajorVersion === 4 && (!classNameSet || classNameSet.size === 0);
717
+ }
718
+ function shouldEnableArbitraryValueFallback({ classNameSet, jsArbitraryValueFallback, tailwindcssMajorVersion }) {
719
+ return shouldEnableArbitraryValueFallbackByInputs(classNameSet, jsArbitraryValueFallback, tailwindcssMajorVersion);
720
+ }
721
+ const SKIP_RESULT = { decision: "skip" };
722
+ const DIRECT_RESULT = { decision: "direct" };
723
+ const FALLBACK_RESULT = { decision: "fallback" };
724
+ function getEscapedCandidateCacheStore(escapeMap) {
725
+ if (!escapeMap) return defaultEscapedCandidateCache;
726
+ if (escapeMap === lastEscapedCandidateEscapeMap && lastEscapedCandidateCacheStore) return lastEscapedCandidateCacheStore;
727
+ let store = escapedCandidateCacheByEscapeMap.get(escapeMap);
728
+ if (!store) {
729
+ store = /* @__PURE__ */ new Map();
730
+ escapedCandidateCacheByEscapeMap.set(escapeMap, store);
731
+ }
732
+ lastEscapedCandidateEscapeMap = escapeMap;
733
+ lastEscapedCandidateCacheStore = store;
734
+ return store;
735
+ }
736
+ function getEscapedCandidate(candidate, escapeMap, store = getEscapedCandidateCacheStore(escapeMap)) {
737
+ let cached = store.get(candidate);
738
+ if (cached === void 0) {
739
+ cached = replaceWxml(candidate, { escapeMap });
740
+ store.set(candidate, cached);
741
+ }
742
+ return cached;
743
+ }
744
+ /**
745
+ * JS 转译严格遵循 runtime class set:
746
+ * 1. 直接命中 classNameSet 原始值;
747
+ * 2. 兼容命中 classNameSet 中已转义值;
748
+ * 3. 仅在受控条件下允许 class 语义兜底。
749
+ *
750
+ * 返回结构化结果,附带已计算的 escapedValue 以避免下游重复 escape。
751
+ */
752
+ function resolveClassNameTransformWithResult(candidate, { alwaysEscape, classNameSet, escapeMap, jsArbitraryValueFallback, jsPreserveClass, tailwindcssMajorVersion, classContext }) {
753
+ if (alwaysEscape) return DIRECT_RESULT;
754
+ if (jsPreserveClass?.(candidate)) return SKIP_RESULT;
755
+ if (classNameSet?.has(candidate)) return DIRECT_RESULT;
756
+ if (classNameSet && classNameSet.size > 0) {
757
+ const escapedCandidate = getEscapedCandidate(candidate, escapeMap);
758
+ if (escapedCandidate !== candidate && classNameSet.has(escapedCandidate)) return {
759
+ decision: "escaped",
760
+ escapedValue: escapedCandidate
761
+ };
762
+ }
763
+ if (classContext && shouldEnableArbitraryValueFallbackByInputs(classNameSet, jsArbitraryValueFallback, tailwindcssMajorVersion) && isArbitraryValueCandidate(candidate)) return FALLBACK_RESULT;
764
+ return SKIP_RESULT;
765
+ }
766
+ //#endregion
767
+ //#region src/utils/decode.ts
768
+ const unicodeEscapeRE = /\\u([\dA-Fa-f]{4})/g;
769
+ const unicodeEscapeTestRE = /\\u[\dA-Fa-f]{4}/;
770
+ function decodeUnicode(value) {
771
+ if (!unicodeEscapeTestRE.test(value)) return value;
772
+ return value.replace(unicodeEscapeRE, (_match, hex) => {
773
+ const codePoint = Number.parseInt(hex, 16);
774
+ return Number.isNaN(codePoint) ? _match : String.fromCharCode(codePoint);
775
+ });
776
+ }
777
+ function decodeUnicode2(input) {
778
+ if (!unicodeEscapeTestRE.test(input)) return input;
779
+ try {
780
+ return JSON.parse(`"${input}"`);
781
+ } catch (_error) {
782
+ return decodeUnicode(input);
783
+ }
784
+ }
785
+ //#endregion
786
+ //#region src/js/class-context.ts
787
+ const CLASS_LIKE_KEYWORDS = new Set([
788
+ "class",
789
+ "classname",
790
+ "hoverclass",
791
+ "virtualhostclass",
792
+ "rootclass"
793
+ ]);
794
+ const CLASS_HELPER_IDENTIFIERS = new Set([
795
+ "cn",
796
+ "clsx",
797
+ "classnames",
798
+ "twmerge",
799
+ "cva",
800
+ "tv",
801
+ "cx",
802
+ "r"
803
+ ]);
804
+ const DASH_CODE = 45;
805
+ const COLON_CODE = 58;
806
+ const UPPERCASE_A_CODE = 65;
807
+ const UPPERCASE_Z_CODE = 90;
808
+ const UNDERSCORE_CODE = 95;
809
+ const ASCII_MAX_CODE = 127;
810
+ const NORMALIZE_KEYWORD_REGEXP = /[-_:]/g;
811
+ function normalizeKeyword(name) {
812
+ const length = name.length;
813
+ let firstNormalizedIndex = -1;
814
+ for (let i = 0; i < length; i++) {
815
+ const code = name.charCodeAt(i);
816
+ if (code === DASH_CODE || code === UNDERSCORE_CODE || code === COLON_CODE || code >= UPPERCASE_A_CODE && code <= UPPERCASE_Z_CODE) {
817
+ firstNormalizedIndex = i;
818
+ break;
819
+ }
820
+ if (code > ASCII_MAX_CODE) return name.replace(NORMALIZE_KEYWORD_REGEXP, "").toLowerCase();
821
+ }
822
+ if (firstNormalizedIndex === -1) return name;
823
+ let normalized = name.slice(0, firstNormalizedIndex);
824
+ for (let i = firstNormalizedIndex; i < length; i++) {
825
+ const code = name.charCodeAt(i);
826
+ if (code === DASH_CODE || code === UNDERSCORE_CODE || code === COLON_CODE) continue;
827
+ if (code >= UPPERCASE_A_CODE && code <= UPPERCASE_Z_CODE) {
828
+ normalized += String.fromCharCode(code + 32);
829
+ continue;
830
+ }
831
+ if (code > ASCII_MAX_CODE) return name.replace(NORMALIZE_KEYWORD_REGEXP, "").toLowerCase();
832
+ normalized += name[i];
833
+ }
834
+ return normalized;
835
+ }
836
+ function readObjectKeyName(path) {
837
+ if (path.isIdentifier()) return path.node.name;
838
+ if (path.isStringLiteral()) return path.node.value;
839
+ if (path.isTemplateLiteral() && path.node.expressions.length === 0) return path.node.quasis[0]?.value.cooked ?? path.node.quasis[0]?.value.raw;
840
+ }
841
+ function isClassLikeObjectProperty(path, valuePath) {
842
+ if (!path.isObjectProperty()) return false;
843
+ if (path.get("value") !== valuePath) return false;
844
+ const keyName = readObjectKeyName(path.get("key"));
845
+ if (!keyName) return false;
846
+ return CLASS_LIKE_KEYWORDS.has(normalizeKeyword(keyName));
847
+ }
848
+ function isClassLikeJsxAttribute(path) {
849
+ if (!path.isJSXAttribute()) return false;
850
+ const namePath = path.get("name");
851
+ if (!namePath.isJSXIdentifier()) return false;
852
+ return CLASS_LIKE_KEYWORDS.has(normalizeKeyword(namePath.node.name));
853
+ }
854
+ function readCallHelperName(calleePath) {
855
+ if (calleePath.isIdentifier()) return calleePath.node.name;
856
+ if (calleePath.isMemberExpression()) {
857
+ const propertyPath = calleePath.get("property");
858
+ if (propertyPath.isIdentifier()) return propertyPath.node.name;
859
+ if (propertyPath.isStringLiteral()) return propertyPath.node.value;
860
+ }
861
+ }
862
+ function isClassLikeCallExpression(path, valuePath) {
863
+ if (!path.isCallExpression()) return false;
864
+ const helperName = readCallHelperName(path.get("callee"));
865
+ if (!helperName || !CLASS_HELPER_IDENTIFIERS.has(normalizeKeyword(helperName))) return false;
866
+ return path.get("arguments").some((argumentPath) => argumentPath.node === valuePath.node);
867
+ }
868
+ /**
869
+ * 判断字符串字面量是否处于 class 语义上下文。
870
+ * 仅用于受控兜底场景,避免将普通业务文本误判为 class。
871
+ */
872
+ function isClassContextLiteralPath(path) {
873
+ let current = path;
874
+ while (current.parentPath) {
875
+ const parent = current.parentPath;
876
+ if (isClassLikeObjectProperty(parent, current)) return true;
877
+ if (isClassLikeJsxAttribute(parent)) return true;
878
+ if (isClassLikeCallExpression(parent, current)) return true;
879
+ current = parent;
880
+ }
881
+ return false;
882
+ }
883
+ //#endregion
884
+ //#region src/js/handlers.ts
885
+ const debug = createDebug("[js:handlers] ");
886
+ const replacementCacheByEscapeMap = /* @__PURE__ */ new WeakMap();
887
+ const defaultReplacementCache = /* @__PURE__ */ new Map();
888
+ const WEAPP_TW_IGNORE_MARKER = "weapp-tw";
889
+ const IGNORE_MARKER = "ignore";
890
+ function getReplacementCacheStore(escapeMap) {
891
+ if (!escapeMap) return defaultReplacementCache;
892
+ let store = replacementCacheByEscapeMap.get(escapeMap);
893
+ if (!store) {
894
+ store = /* @__PURE__ */ new Map();
895
+ replacementCacheByEscapeMap.set(escapeMap, store);
896
+ }
897
+ return store;
898
+ }
899
+ function getReplacement(candidate, escapeMap, store = getReplacementCacheStore(escapeMap)) {
900
+ let cached = store.get(candidate);
901
+ if (cached === void 0) {
902
+ cached = replaceWxml(candidate, { escapeMap });
903
+ store.set(candidate, cached);
904
+ }
905
+ return cached;
906
+ }
907
+ function hasIgnoreComment(node) {
908
+ const { leadingComments } = node;
909
+ if (!Array.isArray(leadingComments) || leadingComments.length === 0) return false;
910
+ for (const comment of leadingComments) {
911
+ const { value } = comment;
912
+ if (value.includes(WEAPP_TW_IGNORE_MARKER) && value.includes(IGNORE_MARKER)) return true;
913
+ }
914
+ return false;
915
+ }
916
+ function extractLiteralValue(path, { unescapeUnicode, arbitraryValues }) {
917
+ const allowDoubleQuotes = arbitraryValues?.allowDoubleQuotes;
918
+ const { node } = path;
919
+ let offset = 0;
920
+ let original;
921
+ if (node.type === "StringLiteral") {
922
+ offset = 1;
923
+ original = node.value;
924
+ } else if (node.type === "TemplateElement") original = node.value.raw;
925
+ else original = "";
926
+ let literal = original;
927
+ if (unescapeUnicode && original.includes("\\u")) literal = decodeUnicode2(original);
928
+ return {
929
+ allowDoubleQuotes,
930
+ literal,
931
+ offset,
932
+ original
933
+ };
934
+ }
935
+ function createCandidatePlanResolver(options, classContext) {
936
+ const { escapeMap } = options;
937
+ const replacementCache = getReplacementCacheStore(escapeMap);
938
+ const transformOptions = classContext ? {
939
+ ...options,
940
+ classContext
941
+ } : options;
942
+ let firstCandidate = "";
943
+ let firstPlan;
944
+ let cache;
945
+ const buildCandidatePlan = (candidate) => {
946
+ const result = resolveClassNameTransformWithResult(candidate, transformOptions);
947
+ if (result.decision === "skip") return { result };
948
+ let replacement;
949
+ if (result.decision === "escaped" && result.escapedValue) {
950
+ replacement = result.escapedValue;
951
+ replacementCache.set(candidate, replacement);
952
+ } else replacement = getReplacement(candidate, escapeMap, replacementCache);
953
+ return {
954
+ result,
955
+ replacement
956
+ };
957
+ };
958
+ return (candidate) => {
959
+ if (cache) {
960
+ const cached = cache.get(candidate);
961
+ if (cached) return cached;
962
+ } else if (firstPlan && candidate === firstCandidate) return firstPlan;
963
+ const plan = buildCandidatePlan(candidate);
964
+ if (!firstPlan) {
965
+ firstCandidate = candidate;
966
+ firstPlan = plan;
967
+ return plan;
968
+ }
969
+ if (!cache) {
970
+ cache = /* @__PURE__ */ new Map();
971
+ cache.set(firstCandidate, firstPlan);
972
+ }
973
+ cache.set(candidate, plan);
974
+ return plan;
975
+ };
976
+ }
977
+ function replaceHandleValue(path, options) {
978
+ const { needEscaped = false } = options;
979
+ const { classNameSet, alwaysEscape } = options;
980
+ const fallbackEnabled = shouldEnableArbitraryValueFallback(options);
981
+ if (!alwaysEscape && !fallbackEnabled && (!classNameSet || classNameSet.size === 0)) return;
982
+ if (hasIgnoreComment(path.node)) return;
983
+ const { literal, original, allowDoubleQuotes, offset } = extractLiteralValue(path, options);
984
+ const candidates = splitCode(literal, allowDoubleQuotes);
985
+ if (candidates.length === 0) return;
986
+ const debugEnabled = debug.enabled;
987
+ const classContext = options.wrapExpression || isClassContextLiteralPath(path);
988
+ let transformed = literal;
989
+ let mutated = false;
990
+ let matchedCandidateCount = 0;
991
+ let escapedDecisionCount = 0;
992
+ let fallbackDecisionCount = 0;
993
+ let escapedSamples;
994
+ let skippedSamples;
995
+ const resolveCandidatePlan = createCandidatePlanResolver(options, classContext);
996
+ for (const candidate of candidates) {
997
+ const plan = resolveCandidatePlan(candidate);
998
+ if (plan.result.decision === "skip") {
999
+ if (debugEnabled) {
1000
+ if (!skippedSamples) skippedSamples = [];
1001
+ if (skippedSamples.length < 6) skippedSamples.push(candidate);
1002
+ }
1003
+ continue;
1004
+ }
1005
+ if (debugEnabled) {
1006
+ matchedCandidateCount += 1;
1007
+ if (plan.result.decision === "escaped") {
1008
+ escapedDecisionCount += 1;
1009
+ if (!escapedSamples) escapedSamples = [];
1010
+ if (escapedSamples.length < 6) escapedSamples.push(candidate);
1011
+ }
1012
+ if (plan.result.decision === "fallback") fallbackDecisionCount += 1;
1013
+ }
1014
+ const replaced = transformed.replace(candidate, plan.replacement);
1015
+ if (replaced !== transformed) {
1016
+ transformed = replaced;
1017
+ mutated = true;
1018
+ }
1019
+ }
1020
+ const node = path.node;
1021
+ if (!mutated || typeof node.start !== "number" || typeof node.end !== "number") return;
1022
+ if (debugEnabled) debug("runtimeSet size=%d fallbackTriggered=%s candidates=%d matched=%d escapedHits=%d skipped=%d file=%s escapedSamples=%s skippedSamples=%s", classNameSet?.size ?? 0, fallbackDecisionCount > 0, candidates.length, matchedCandidateCount, escapedDecisionCount, skippedSamples?.length ?? 0, options.filename ?? "unknown", escapedSamples?.join(",") || "-", skippedSamples?.join(",") || "-");
1023
+ const start = node.start + offset;
1024
+ const end = node.end - offset;
1025
+ if (start >= end || transformed === original) return;
1026
+ return {
1027
+ start,
1028
+ end,
1029
+ value: needEscaped ? jsStringEscape(transformed) : transformed,
1030
+ path
1031
+ };
1032
+ }
1033
+ //#endregion
1034
+ //#region src/js/sourceAnalysis.ts
1035
+ function hasReplacementEntries(replacements) {
1036
+ for (const key in replacements) if (Object.hasOwn(replacements, key)) return true;
1037
+ return false;
1038
+ }
1039
+ function createModuleSpecifierReplacementToken(path, replacement) {
1040
+ const node = path.node;
1041
+ if (node.value === replacement) return;
1042
+ if (typeof node.start !== "number" || typeof node.end !== "number") return;
1043
+ const start = node.start + 1;
1044
+ const end = node.end - 1;
1045
+ if (start >= end) return;
1046
+ return {
1047
+ start,
1048
+ end,
1049
+ value: replacement,
1050
+ path
1051
+ };
1052
+ }
1053
+ function collectModuleSpecifierReplacementTokens(analysis, replacements) {
1054
+ if (!hasReplacementEntries(replacements)) return [];
1055
+ if (analysis.importDeclarations.size === 0 && analysis.exportDeclarations.size === 0 && analysis.requireCallPaths.length === 0 && analysis.walker.imports.size === 0) return [];
1056
+ const tokens = [];
1057
+ const applyReplacement = (path) => {
1058
+ const replacement = replacements[path.node.value];
1059
+ if (!replacement) return;
1060
+ const token = createModuleSpecifierReplacementToken(path, replacement);
1061
+ if (token) tokens.push(token);
1062
+ };
1063
+ for (const importPath of analysis.importDeclarations) {
1064
+ const source = importPath.get("source");
1065
+ if (source.isStringLiteral()) applyReplacement(source);
1066
+ }
1067
+ for (const exportPath of analysis.exportDeclarations) if (exportPath.isExportNamedDeclaration() || exportPath.isExportAllDeclaration()) {
1068
+ const source = exportPath.get("source");
1069
+ if (source && !Array.isArray(source) && source.isStringLiteral()) applyReplacement(source);
1070
+ }
1071
+ for (const literalPath of analysis.requireCallPaths) applyReplacement(literalPath);
1072
+ for (const token of analysis.walker.imports) {
1073
+ const replacement = replacements[token.source];
1074
+ if (replacement) token.source = replacement;
1075
+ }
1076
+ return tokens;
1077
+ }
1078
+ //#endregion
1079
+ //#region src/js/babel/process.ts
1080
+ const optionVariantsCache = /* @__PURE__ */ new WeakMap();
1081
+ function getNeedEscapedOptions(options, needEscaped) {
1082
+ if (options.needEscaped === needEscaped) return options;
1083
+ let cached = optionVariantsCache.get(options);
1084
+ if (!cached) {
1085
+ cached = {};
1086
+ optionVariantsCache.set(options, cached);
1087
+ }
1088
+ if (needEscaped) {
1089
+ if (!cached.stringLiteralOptions) cached.stringLiteralOptions = {
1090
+ ...options,
1091
+ needEscaped: true
1092
+ };
1093
+ return cached.stringLiteralOptions;
1094
+ }
1095
+ if (!cached.templateLiteralOptions) cached.templateLiteralOptions = {
1096
+ ...options,
1097
+ needEscaped: false
1098
+ };
1099
+ return cached.templateLiteralOptions;
1100
+ }
1101
+ function processUpdatedSource(rawSource, options, analysis) {
1102
+ const { targetPaths, jsTokenUpdater, ignoredPaths } = analysis;
1103
+ if (targetPaths.length === 0 && !options.moduleSpecifierReplacements && jsTokenUpdater.length === 0) return new MagicString(rawSource);
1104
+ const replacementTokens = [];
1105
+ for (const path of targetPaths) {
1106
+ if (ignoredPaths.has(path)) continue;
1107
+ const token = replaceHandleValue(path, path.isStringLiteral() ? getNeedEscapedOptions(options, true) : getNeedEscapedOptions(options, false));
1108
+ if (token) replacementTokens.push(token);
1109
+ }
1110
+ if (options.moduleSpecifierReplacements) replacementTokens.push(...collectModuleSpecifierReplacementTokens(analysis, options.moduleSpecifierReplacements));
1111
+ if (jsTokenUpdater.length + replacementTokens.length === 0) return new MagicString(rawSource);
1112
+ const ms = new MagicString(rawSource);
1113
+ jsTokenUpdater.push(...replacementTokens).filter((token) => !ignoredPaths.has(token.path)).updateMagicString(ms);
1114
+ return ms;
1115
+ }
1116
+ //#endregion
1117
+ //#region src/js/evalTransforms.ts
1118
+ const evalHandlerOptionsCache = /* @__PURE__ */ new WeakMap();
1119
+ const EVAL_SCOPE_ERROR_REGEXP = /pass a scope and parentPath|traversing a Program\/File/i;
1120
+ function isEvalPath(path) {
1121
+ if (path.isCallExpression()) return path.get("callee").isIdentifier({ name: "eval" });
1122
+ return false;
1123
+ }
1124
+ function createEvalReplacementToken(path, updated) {
1125
+ const node = path.node;
1126
+ let offset = 0;
1127
+ let original;
1128
+ if (path.isStringLiteral()) {
1129
+ offset = 1;
1130
+ original = path.node.value;
1131
+ } else if (path.isTemplateElement()) original = path.node.value.raw;
1132
+ else original = "";
1133
+ if (typeof node.start !== "number" || typeof node.end !== "number") return;
1134
+ const start = node.start + offset;
1135
+ const end = node.end - offset;
1136
+ if (start >= end) return;
1137
+ if (original === updated) return;
1138
+ return {
1139
+ start,
1140
+ end,
1141
+ value: path.isStringLiteral() ? jsStringEscape(updated) : updated,
1142
+ path
1143
+ };
1144
+ }
1145
+ function handleEvalStringLiteral(path, handlerOptions, updater, handler) {
1146
+ const { code } = handler(path.node.value, handlerOptions);
1147
+ if (!code) return;
1148
+ const token = createEvalReplacementToken(path, code);
1149
+ if (token) updater.addToken(token);
1150
+ }
1151
+ function handleEvalTemplateElement(path, handlerOptions, updater, handler) {
1152
+ const { code } = handler(path.node.value.raw, handlerOptions);
1153
+ if (!code) return;
1154
+ const token = createEvalReplacementToken(path, code);
1155
+ if (token) updater.addToken(token);
1156
+ }
1157
+ function getEvalStringHandlerOptions(options) {
1158
+ if (options.needEscaped === false && options.generateMap === false) return options;
1159
+ let cached = evalHandlerOptionsCache.get(options);
1160
+ if (!cached) {
1161
+ cached = {};
1162
+ evalHandlerOptionsCache.set(options, cached);
1163
+ }
1164
+ if (!cached.stringLiteralOptions) cached.stringLiteralOptions = {
1165
+ ...options,
1166
+ needEscaped: false,
1167
+ generateMap: false
1168
+ };
1169
+ return cached.stringLiteralOptions;
1170
+ }
1171
+ function getEvalTemplateHandlerOptions(options) {
1172
+ if (options.generateMap === false) return options;
1173
+ let cached = evalHandlerOptionsCache.get(options);
1174
+ if (!cached) {
1175
+ cached = {};
1176
+ evalHandlerOptionsCache.set(options, cached);
1177
+ }
1178
+ if (!cached.templateLiteralOptions) cached.templateLiteralOptions = {
1179
+ ...options,
1180
+ generateMap: false
1181
+ };
1182
+ return cached.templateLiteralOptions;
1183
+ }
1184
+ function walkEvalExpression(path, options, updater, handler) {
1185
+ const stringHandlerOptions = getEvalStringHandlerOptions(options);
1186
+ const templateHandlerOptions = getEvalTemplateHandlerOptions(options);
1187
+ const maybeTraverse = path?.traverse;
1188
+ if (typeof maybeTraverse === "function") try {
1189
+ return maybeTraverse.call(path, {
1190
+ StringLiteral(innerPath) {
1191
+ handleEvalStringLiteral(innerPath, stringHandlerOptions, updater, handler);
1192
+ },
1193
+ TemplateElement(innerPath) {
1194
+ handleEvalTemplateElement(innerPath, templateHandlerOptions, updater, handler);
1195
+ }
1196
+ });
1197
+ } catch (error) {
1198
+ const msg = error?.message ?? "";
1199
+ if (!EVAL_SCOPE_ERROR_REGEXP.test(msg)) throw error;
1200
+ }
1201
+ const getArgs = path?.get?.("arguments");
1202
+ if (Array.isArray(getArgs)) {
1203
+ for (const arg of getArgs) {
1204
+ if (arg?.isStringLiteral?.()) {
1205
+ handleEvalStringLiteral(arg, stringHandlerOptions, updater, handler);
1206
+ continue;
1207
+ }
1208
+ if (arg?.isTemplateLiteral?.()) for (const quasi of arg.get("quasis")) handleEvalTemplateElement(quasi, templateHandlerOptions, updater, handler);
1209
+ }
1210
+ return;
1211
+ }
1212
+ const nodeArgs = path?.node?.arguments;
1213
+ if (Array.isArray(nodeArgs)) {
1214
+ for (const n of nodeArgs) if (n?.type === "StringLiteral") handleEvalStringLiteral({
1215
+ node: n,
1216
+ isStringLiteral: () => true
1217
+ }, stringHandlerOptions, updater, handler);
1218
+ else if (n?.type === "TemplateLiteral" && Array.isArray(n.quasis)) for (const q of n.quasis) handleEvalTemplateElement({
1219
+ node: q,
1220
+ isStringLiteral: () => false,
1221
+ isTemplateElement: () => true
1222
+ }, templateHandlerOptions, updater, handler);
1223
+ }
1224
+ }
1225
+ //#endregion
1226
+ //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
1227
+ function _typeof(o) {
1228
+ "@babel/helpers - typeof";
1229
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
1230
+ return typeof o;
1231
+ } : function(o) {
1232
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
1233
+ }, _typeof(o);
1234
+ }
1235
+ //#endregion
1236
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
1237
+ function toPrimitive(t, r) {
1238
+ if ("object" != _typeof(t) || !t) return t;
1239
+ var e = t[Symbol.toPrimitive];
1240
+ if (void 0 !== e) {
1241
+ var i = e.call(t, r || "default");
1242
+ if ("object" != _typeof(i)) return i;
1243
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1244
+ }
1245
+ return ("string" === r ? String : Number)(t);
1246
+ }
1247
+ //#endregion
1248
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
1249
+ function toPropertyKey(t) {
1250
+ var i = toPrimitive(t, "string");
1251
+ return "symbol" == _typeof(i) ? i : i + "";
1252
+ }
1253
+ //#endregion
1254
+ //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
1255
+ function _defineProperty(e, r, t) {
1256
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
1257
+ value: t,
1258
+ enumerable: !0,
1259
+ configurable: !0,
1260
+ writable: !0
1261
+ }) : e[r] = t, e;
1262
+ }
1263
+ //#endregion
1264
+ //#region src/js/JsTokenUpdater.ts
1265
+ /**
1266
+ * Lightweight helper that batches updates to {@link MagicString}.
1267
+ * It keeps the transformation logic out of the traversal code and makes
1268
+ * it easier to reason about the order in which tokens are written back.
1269
+ */
1270
+ var JsTokenUpdater = class {
1271
+ constructor({ value } = {}) {
1272
+ _defineProperty(this, "tokens", void 0);
1273
+ this.tokens = value ? [...value] : [];
1274
+ }
1275
+ addToken(token) {
1276
+ if (token) this.tokens.push(token);
1277
+ }
1278
+ push(...args) {
1279
+ this.tokens.push(...args);
1280
+ return this;
1281
+ }
1282
+ /**
1283
+ * 待写入的 token 数量。
1284
+ */
1285
+ get length() {
1286
+ return this.tokens.length;
1287
+ }
1288
+ map(callbackfn) {
1289
+ this.tokens = this.tokens.map(callbackfn);
1290
+ return this;
1291
+ }
1292
+ filter(callbackfn) {
1293
+ this.tokens = this.tokens.filter(callbackfn);
1294
+ return this;
1295
+ }
1296
+ updateMagicString(ms) {
1297
+ for (const { start, end, value } of this.tokens) ms.update(start, end, value);
1298
+ return ms;
1299
+ }
1300
+ };
1301
+ //#endregion
1302
+ //#region src/js/module-graph/ignored-exports.ts
1303
+ var IgnoredExportsTracker = class {
1304
+ constructor(options) {
1305
+ this.options = options;
1306
+ _defineProperty(this, "ignoredExportNames", /* @__PURE__ */ new Map());
1307
+ }
1308
+ addIgnoredExport(filename, exportName) {
1309
+ if (!exportName) return;
1310
+ let pending = this.ignoredExportNames.get(filename);
1311
+ if (!pending) {
1312
+ pending = /* @__PURE__ */ new Set();
1313
+ this.ignoredExportNames.set(filename, pending);
1314
+ }
1315
+ if (pending.has(exportName)) return;
1316
+ pending.add(exportName);
1317
+ const existing = this.options.modules.get(filename);
1318
+ if (existing) this.applyIgnoredExportsToAnalysis(filename, existing.analysis);
1319
+ }
1320
+ registerIgnoredExportsFromTokens(resolved, tokens) {
1321
+ for (const token of tokens) if (token.type === "ImportSpecifier") this.addIgnoredExport(resolved, token.imported);
1322
+ else if (token.type === "ImportDefaultSpecifier") this.addIgnoredExport(resolved, "default");
1323
+ }
1324
+ applyIgnoredExportsToAnalysis(filename, analysis) {
1325
+ const pending = this.ignoredExportNames.get(filename);
1326
+ if (!pending || pending.size === 0) return;
1327
+ const names = new Set(pending);
1328
+ pending.clear();
1329
+ const propagate = [];
1330
+ for (const exportPath of analysis.exportDeclarations) {
1331
+ if (names.size === 0) break;
1332
+ if (exportPath.isExportDefaultDeclaration()) {
1333
+ if (names.has("default")) {
1334
+ analysis.walker.walkExportDefaultDeclaration(exportPath);
1335
+ names.delete("default");
1336
+ }
1337
+ continue;
1338
+ }
1339
+ if (exportPath.isExportNamedDeclaration()) {
1340
+ const source = exportPath.node.source?.value;
1341
+ if (typeof source === "string") {
1342
+ for (const spec of exportPath.get("specifiers")) {
1343
+ if (!spec.isExportSpecifier()) continue;
1344
+ const exported = spec.get("exported");
1345
+ let exportedName;
1346
+ if (exported.isIdentifier()) exportedName = exported.node.name;
1347
+ else if (exported.isStringLiteral()) exportedName = exported.node.value;
1348
+ if (!exportedName || !names.has(exportedName)) continue;
1349
+ const local = spec.get("local");
1350
+ if (local.isIdentifier()) {
1351
+ propagate.push({
1352
+ specifier: source,
1353
+ exportName: local.node.name
1354
+ });
1355
+ names.delete(exportedName);
1356
+ } else if (local.isStringLiteral()) {
1357
+ propagate.push({
1358
+ specifier: source,
1359
+ exportName: local.node.value
1360
+ });
1361
+ names.delete(exportedName);
1362
+ }
1363
+ }
1364
+ continue;
1365
+ }
1366
+ const declaration = exportPath.get("declaration");
1367
+ if (declaration.isVariableDeclaration()) for (const decl of declaration.get("declarations")) {
1368
+ const id = decl.get("id");
1369
+ if (id.isIdentifier()) {
1370
+ const exportName = id.node.name;
1371
+ if (names.has(exportName)) {
1372
+ analysis.walker.walkVariableDeclarator(decl);
1373
+ names.delete(exportName);
1374
+ }
1375
+ }
1376
+ }
1377
+ for (const spec of exportPath.get("specifiers")) {
1378
+ if (!spec.isExportSpecifier()) continue;
1379
+ const exported = spec.get("exported");
1380
+ let exportedName;
1381
+ if (exported.isIdentifier()) exportedName = exported.node.name;
1382
+ else if (exported.isStringLiteral()) exportedName = exported.node.value;
1383
+ if (!exportedName || !names.has(exportedName)) continue;
1384
+ const local = spec.get("local");
1385
+ analysis.walker.walkNode(local);
1386
+ names.delete(exportedName);
1387
+ }
1388
+ continue;
1389
+ }
1390
+ if (exportPath.isExportAllDeclaration()) {
1391
+ const source = exportPath.node.source?.value;
1392
+ if (typeof source === "string") {
1393
+ for (const exportName of names) propagate.push({
1394
+ specifier: source,
1395
+ exportName
1396
+ });
1397
+ names.clear();
1398
+ }
1399
+ }
1400
+ }
1401
+ for (const { specifier, exportName } of propagate) {
1402
+ let resolved;
1403
+ try {
1404
+ resolved = this.options.resolve(specifier, filename);
1405
+ } catch {
1406
+ resolved = void 0;
1407
+ }
1408
+ if (!resolved) {
1409
+ pending.add(exportName);
1410
+ continue;
1411
+ }
1412
+ if (this.options.filter && !this.options.filter(resolved, specifier, filename)) {
1413
+ pending.add(exportName);
1414
+ continue;
1415
+ }
1416
+ this.addIgnoredExport(resolved, exportName);
1417
+ }
1418
+ for (const name of names) pending.add(name);
1419
+ }
1420
+ };
1421
+ //#endregion
1422
+ //#region src/js/ModuleGraph.ts
1423
+ var JsModuleGraph = class {
1424
+ constructor(entry, graphOptions) {
1425
+ _defineProperty(this, "modules", /* @__PURE__ */ new Map());
1426
+ _defineProperty(this, "queue", []);
1427
+ _defineProperty(this, "resolve", void 0);
1428
+ _defineProperty(this, "load", void 0);
1429
+ _defineProperty(this, "filter", void 0);
1430
+ _defineProperty(this, "maxDepth", void 0);
1431
+ _defineProperty(this, "baseOptions", void 0);
1432
+ _defineProperty(this, "parserOptions", void 0);
1433
+ _defineProperty(this, "rootFilename", void 0);
1434
+ _defineProperty(this, "ignoredExports", void 0);
1435
+ this.resolve = graphOptions.resolve;
1436
+ this.load = graphOptions.load;
1437
+ this.filter = graphOptions.filter;
1438
+ this.maxDepth = graphOptions.maxDepth ?? Number.POSITIVE_INFINITY;
1439
+ const { moduleGraph: _moduleGraph, filename: _ignoredFilename, ...rest } = entry.handlerOptions;
1440
+ this.baseOptions = {
1441
+ ...rest,
1442
+ filename: entry.filename
1443
+ };
1444
+ this.parserOptions = entry.handlerOptions.babelParserOptions;
1445
+ this.rootFilename = entry.filename;
1446
+ this.ignoredExports = new IgnoredExportsTracker({
1447
+ resolve: this.resolve,
1448
+ filter: this.filter,
1449
+ modules: this.modules
1450
+ });
1451
+ this.modules.set(entry.filename, {
1452
+ filename: entry.filename,
1453
+ source: entry.source,
1454
+ analysis: entry.analysis
1455
+ });
1456
+ this.queue.push({
1457
+ filename: entry.filename,
1458
+ depth: 0
1459
+ });
1460
+ }
1461
+ build() {
1462
+ this.collectDependencies();
1463
+ let linked;
1464
+ for (const [filename, state] of this.modules) {
1465
+ if (filename === this.rootFilename) continue;
1466
+ const childOptions = {
1467
+ ...this.baseOptions,
1468
+ filename
1469
+ };
1470
+ const code = processUpdatedSource(state.source, childOptions, state.analysis).toString();
1471
+ if (code !== state.source) {
1472
+ if (!linked) linked = {};
1473
+ linked[filename] = { code };
1474
+ }
1475
+ }
1476
+ return linked;
1477
+ }
1478
+ collectDependencies() {
1479
+ while (this.queue.length > 0) {
1480
+ const { filename, depth } = this.queue.shift();
1481
+ if (depth >= this.maxDepth) continue;
1482
+ const state = this.modules.get(filename);
1483
+ if (!state) continue;
1484
+ const dependencySpecifiers = /* @__PURE__ */ new Map();
1485
+ for (const token of state.analysis.walker.imports) {
1486
+ if (!dependencySpecifiers.has(token.source)) dependencySpecifiers.set(token.source, []);
1487
+ dependencySpecifiers.get(token.source).push(token);
1488
+ }
1489
+ for (const exportPath of state.analysis.exportDeclarations) if (exportPath.isExportAllDeclaration() || exportPath.isExportNamedDeclaration()) {
1490
+ const source = exportPath.node.source?.value;
1491
+ if (typeof source === "string" && !dependencySpecifiers.has(source)) dependencySpecifiers.set(source, []);
1492
+ }
1493
+ for (const [specifier, tokens] of dependencySpecifiers) {
1494
+ let resolved;
1495
+ try {
1496
+ resolved = this.resolve(specifier, filename);
1497
+ } catch {
1498
+ continue;
1499
+ }
1500
+ if (!resolved) continue;
1501
+ if (this.filter && !this.filter(resolved, specifier, filename)) continue;
1502
+ if (tokens.length > 0) this.ignoredExports.registerIgnoredExportsFromTokens(resolved, tokens);
1503
+ if (this.modules.has(resolved)) continue;
1504
+ let source;
1505
+ try {
1506
+ source = this.load(resolved);
1507
+ } catch {
1508
+ continue;
1509
+ }
1510
+ if (typeof source !== "string") continue;
1511
+ let analysis;
1512
+ try {
1513
+ analysis = analyzeSource(babelParse(source, {
1514
+ ...this.parserOptions,
1515
+ sourceFilename: resolved
1516
+ }), {
1517
+ ...this.baseOptions,
1518
+ filename: resolved
1519
+ });
1520
+ this.ignoredExports.applyIgnoredExportsToAnalysis(resolved, analysis);
1521
+ } catch {
1522
+ continue;
1523
+ }
1524
+ this.modules.set(resolved, {
1525
+ filename: resolved,
1526
+ source,
1527
+ analysis
1528
+ });
1529
+ this.queue.push({
1530
+ filename: resolved,
1531
+ depth: depth + 1
1532
+ });
1533
+ }
1534
+ }
1535
+ }
1536
+ };
1537
+ //#endregion
1538
+ //#region src/js/node-path-walker/export-handlers.ts
1539
+ function walkExportDeclaration(ctx, path) {
1540
+ if (path.isExportDeclaration()) {
1541
+ if (path.isExportNamedDeclaration()) walkExportNamedDeclaration(ctx, path);
1542
+ else if (path.isExportDefaultDeclaration()) walkExportDefaultDeclaration(ctx, path);
1543
+ else if (path.isExportAllDeclaration()) walkExportAllDeclaration(ctx, path);
1544
+ }
1545
+ }
1546
+ function walkExportNamedDeclaration(ctx, path) {
1547
+ const declaration = path.get("declaration");
1548
+ if (declaration.isVariableDeclaration()) for (const decl of declaration.get("declarations")) ctx.walkNode(decl);
1549
+ const specifiers = path.get("specifiers");
1550
+ for (const spec of specifiers) if (spec.isExportSpecifier()) {
1551
+ const local = spec.get("local");
1552
+ if (local.isIdentifier()) ctx.walkNode(local);
1553
+ }
1554
+ }
1555
+ function walkExportDefaultDeclaration(ctx, path) {
1556
+ const decl = path.get("declaration");
1557
+ if (decl.isIdentifier()) ctx.walkNode(decl);
1558
+ else ctx.walkNode(decl);
1559
+ }
1560
+ function walkExportAllDeclaration(ctx, path) {
1561
+ const source = path.get("source");
1562
+ if (source.isStringLiteral()) ctx.addImportToken({
1563
+ declaration: path,
1564
+ source: source.node.value,
1565
+ type: "ExportAllDeclaration"
1566
+ });
1567
+ }
1568
+ //#endregion
1569
+ //#region src/js/node-path-walker/import-tokens.ts
1570
+ function maybeAddImportToken(imports, arg) {
1571
+ if (!(arg.isImportSpecifier() && arg.node.importKind !== "type" || arg.isImportDefaultSpecifier())) return false;
1572
+ const importDeclaration = arg.parentPath;
1573
+ if (!importDeclaration.isImportDeclaration() || importDeclaration.node.importKind === "type") return false;
1574
+ if (arg.isImportSpecifier()) {
1575
+ const imported = arg.get("imported");
1576
+ if (imported.isIdentifier()) imports.add({
1577
+ declaration: importDeclaration,
1578
+ specifier: arg,
1579
+ imported: imported.node.name,
1580
+ local: arg.node.local.name,
1581
+ source: importDeclaration.node.source.value,
1582
+ type: "ImportSpecifier"
1583
+ });
1584
+ return true;
1585
+ }
1586
+ imports.add({
1587
+ declaration: importDeclaration,
1588
+ specifier: arg,
1589
+ local: arg.node.local.name,
1590
+ source: importDeclaration.node.source.value,
1591
+ type: "ImportDefaultSpecifier"
1592
+ });
1593
+ return true;
1594
+ }
1595
+ //#endregion
1596
+ //#region src/js/NodePathWalker.ts
1597
+ const EMPTY_IGNORE_CALL_EXPRESSION_IDENTIFIERS = [];
1598
+ const EMPTY_IMPORT_TOKENS = /* @__PURE__ */ new Set();
1599
+ function NOOP_STRING_PATH_CALLBACK() {}
1600
+ const NEVER_MATCH_NAME = () => false;
1601
+ /**
1602
+ * 遍历我们关注的调用表达式所关联的绑定,收集后续需要转换的字符串节点。
1603
+ */
1604
+ var NodePathWalker = class {
1605
+ constructor({ ignoreCallExpressionIdentifiers, callback } = {}) {
1606
+ _defineProperty(this, "ignoreCallExpressionIdentifiers", void 0);
1607
+ _defineProperty(this, "callback", void 0);
1608
+ _defineProperty(this, "isIgnoredCallIdentifier", void 0);
1609
+ _defineProperty(this, "hasIgnoredCallIdentifiers", void 0);
1610
+ _defineProperty(this, "importsStore", void 0);
1611
+ _defineProperty(this, "visitedStore", void 0);
1612
+ this.hasIgnoredCallIdentifiers = Boolean(ignoreCallExpressionIdentifiers && ignoreCallExpressionIdentifiers.length > 0);
1613
+ this.ignoreCallExpressionIdentifiers = ignoreCallExpressionIdentifiers ?? EMPTY_IGNORE_CALL_EXPRESSION_IDENTIFIERS;
1614
+ this.callback = callback ?? NOOP_STRING_PATH_CALLBACK;
1615
+ this.isIgnoredCallIdentifier = this.hasIgnoredCallIdentifiers ? createNameMatcher(this.ignoreCallExpressionIdentifiers, { exact: true }) : NEVER_MATCH_NAME;
1616
+ }
1617
+ get imports() {
1618
+ return this.importsStore ?? EMPTY_IMPORT_TOKENS;
1619
+ }
1620
+ getWritableImports() {
1621
+ if (!this.importsStore) this.importsStore = /* @__PURE__ */ new Set();
1622
+ return this.importsStore;
1623
+ }
1624
+ addImportToken(token) {
1625
+ this.getWritableImports().add(token);
1626
+ }
1627
+ getVisited() {
1628
+ if (!this.visitedStore) this.visitedStore = /* @__PURE__ */ new WeakSet();
1629
+ return this.visitedStore;
1630
+ }
1631
+ walkVariableDeclarator(path) {
1632
+ const init = path.get("init");
1633
+ this.walkNode(init);
1634
+ }
1635
+ walkTemplateLiteral(path) {
1636
+ for (const exp of path.get("expressions")) this.walkNode(exp);
1637
+ for (const quasis of path.get("quasis")) this.callback(quasis);
1638
+ }
1639
+ walkStringLiteral(path) {
1640
+ this.callback(path);
1641
+ }
1642
+ walkBinaryExpression(path) {
1643
+ const left = path.get("left");
1644
+ this.walkNode(left);
1645
+ const right = path.get("right");
1646
+ this.walkNode(right);
1647
+ }
1648
+ walkLogicalExpression(path) {
1649
+ const left = path.get("left");
1650
+ this.walkNode(left);
1651
+ const right = path.get("right");
1652
+ this.walkNode(right);
1653
+ }
1654
+ walkObjectExpression(path) {
1655
+ const props = path.get("properties");
1656
+ for (const prop of props) if (prop.isObjectProperty()) {
1657
+ const key = prop.get("key");
1658
+ this.walkNode(key);
1659
+ const value = prop.get("value");
1660
+ this.walkNode(value);
1661
+ }
1662
+ }
1663
+ walkArrayExpression(path) {
1664
+ const elements = path.get("elements");
1665
+ for (const element of elements) this.walkNode(element);
1666
+ }
1667
+ walkNode(arg) {
1668
+ const visited = this.getVisited();
1669
+ if (visited.has(arg)) return;
1670
+ visited.add(arg);
1671
+ if (arg.isIdentifier()) {
1672
+ const binding = arg?.scope?.getBinding?.(arg.node.name);
1673
+ if (binding) this.walkNode(binding.path);
1674
+ } else if (arg.isMemberExpression()) {
1675
+ const objectPath = arg.get("object");
1676
+ if (objectPath.isIdentifier()) {
1677
+ const binding = arg?.scope?.getBinding?.(objectPath.node.name);
1678
+ if (binding) {
1679
+ if (binding.path.isVariableDeclarator()) this.walkVariableDeclarator(binding.path);
1680
+ }
1681
+ }
1682
+ } else if (arg.isTemplateLiteral()) this.walkTemplateLiteral(arg);
1683
+ else if (arg.isStringLiteral()) this.walkStringLiteral(arg);
1684
+ else if (arg.isBinaryExpression()) this.walkBinaryExpression(arg);
1685
+ else if (arg.isLogicalExpression()) this.walkLogicalExpression(arg);
1686
+ else if (arg.isObjectExpression()) this.walkObjectExpression(arg);
1687
+ else if (arg.isArrayExpression()) this.walkArrayExpression(arg);
1688
+ else if (arg.isVariableDeclarator()) this.walkVariableDeclarator(arg);
1689
+ else if (maybeAddImportToken(this.getWritableImports(), arg)) {}
1690
+ }
1691
+ /**
1692
+ * Walk the arguments of a desired call expression so their bindings can be analysed.
1693
+ */
1694
+ walkCallExpression(path) {
1695
+ if (!this.hasIgnoredCallIdentifiers) return;
1696
+ const calleePath = path.get("callee");
1697
+ if (calleePath.isIdentifier() && this.isIgnoredCallIdentifier(calleePath.node.name)) for (const arg of path.get("arguments")) this.walkNode(arg);
1698
+ }
1699
+ walkExportDeclaration(path) {
1700
+ walkExportDeclaration(this, path);
1701
+ }
1702
+ walkExportNamedDeclaration(path) {
1703
+ walkExportNamedDeclaration(this, path);
1704
+ }
1705
+ walkExportDefaultDeclaration(path) {
1706
+ walkExportDefaultDeclaration(this, path);
1707
+ }
1708
+ walkExportAllDeclaration(path) {
1709
+ walkExportAllDeclaration(this, path);
1710
+ }
1711
+ };
1712
+ //#endregion
1713
+ //#region src/js/taggedTemplateIgnore.ts
1714
+ function createTaggedTemplateIgnore({ matcher, names }) {
1715
+ const bindingIgnoreCache = /* @__PURE__ */ new Map();
1716
+ const taggedTemplateIgnoreCache = /* @__PURE__ */ new WeakMap();
1717
+ const seenBindings = /* @__PURE__ */ new Set();
1718
+ let singleCanonicalIgnoreName;
1719
+ let canonicalIgnoreNames;
1720
+ for (const item of names ?? []) {
1721
+ if (typeof item !== "string") continue;
1722
+ if (singleCanonicalIgnoreName === void 0) {
1723
+ singleCanonicalIgnoreName = item;
1724
+ continue;
1725
+ }
1726
+ if (item === singleCanonicalIgnoreName) continue;
1727
+ if (!canonicalIgnoreNames) {
1728
+ canonicalIgnoreNames = new Set([singleCanonicalIgnoreName, item]);
1729
+ continue;
1730
+ }
1731
+ canonicalIgnoreNames.add(item);
1732
+ }
1733
+ const hasCanonicalIgnoreNames = singleCanonicalIgnoreName !== void 0;
1734
+ const matchesIgnoreName = (value) => {
1735
+ if (hasCanonicalIgnoreNames) {
1736
+ if (canonicalIgnoreNames) {
1737
+ if (canonicalIgnoreNames.has(value)) return true;
1738
+ } else if (value === singleCanonicalIgnoreName) return true;
1739
+ }
1740
+ return matcher(value);
1741
+ };
1742
+ const propertyMatches = (propertyPath) => {
1743
+ if (!propertyPath) return false;
1744
+ if (propertyPath.isIdentifier()) return matchesIgnoreName(propertyPath.node.name);
1745
+ if (propertyPath.isStringLiteral()) return matchesIgnoreName(propertyPath.node.value);
1746
+ return false;
1747
+ };
1748
+ const resolvesMemberExpressionToIgnore = (path, seen) => {
1749
+ if (propertyMatches(path.get("property"))) return true;
1750
+ const objectPath = path.get("object");
1751
+ if (objectPath.isIdentifier()) {
1752
+ const binding = (objectPath?.scope)?.getBinding?.(objectPath.node.name);
1753
+ if (binding) return resolvesToWeappTwIgnore(binding, seen);
1754
+ }
1755
+ return false;
1756
+ };
1757
+ const resolvesToWeappTwIgnore = (binding, seen) => {
1758
+ const cached = bindingIgnoreCache.get(binding);
1759
+ if (cached !== void 0) return cached;
1760
+ if (seen.has(binding)) return false;
1761
+ seen.add(binding);
1762
+ let result = false;
1763
+ const bindingPath = binding.path;
1764
+ if (bindingPath.isImportSpecifier()) {
1765
+ const imported = bindingPath.node.imported;
1766
+ if (imported.type === "Identifier" && matchesIgnoreName(imported.name)) result = true;
1767
+ else if (imported.type === "StringLiteral" && matchesIgnoreName(imported.value)) result = true;
1768
+ } else if (bindingPath.isVariableDeclarator()) {
1769
+ const init = bindingPath.get("init");
1770
+ if (init && init.node) {
1771
+ if (init.isIdentifier()) {
1772
+ const target = binding?.scope?.getBinding?.(init.node.name);
1773
+ if (target) result = resolvesToWeappTwIgnore(target, seen);
1774
+ } else if (init.isMemberExpression()) result = resolvesMemberExpressionToIgnore(init, seen);
1775
+ }
1776
+ }
1777
+ bindingIgnoreCache.set(binding, result);
1778
+ seen.delete(binding);
1779
+ return result;
1780
+ };
1781
+ const getEffectiveTagPath = (tagPath) => {
1782
+ let current = tagPath;
1783
+ while (true) {
1784
+ if (current.isParenthesizedExpression?.() || current.node.type === "ParenthesizedExpression") {
1785
+ current = current.get("expression");
1786
+ continue;
1787
+ }
1788
+ if (current.isTSAsExpression() || current.isTSTypeAssertion()) {
1789
+ current = current.get("expression");
1790
+ continue;
1791
+ }
1792
+ if (current.isTSNonNullExpression()) {
1793
+ current = current.get("expression");
1794
+ continue;
1795
+ }
1796
+ if (current.isTypeCastExpression?.()) {
1797
+ current = current.get("expression");
1798
+ continue;
1799
+ }
1800
+ if (current.isSequenceExpression()) {
1801
+ const last = current.get("expressions").at(-1);
1802
+ if (last) {
1803
+ current = last;
1804
+ continue;
1805
+ }
1806
+ }
1807
+ if (current.isCallExpression?.() || current.node.type === "CallExpression") {
1808
+ current = current.get("callee");
1809
+ continue;
1810
+ }
1811
+ break;
1812
+ }
1813
+ return current;
1814
+ };
1815
+ const evaluateTagPath = (tagPath, seen) => {
1816
+ if (tagPath.isCallExpression?.() || tagPath.node.type === "CallExpression") return evaluateTagPath(tagPath.get("callee"), seen);
1817
+ if (tagPath.isIdentifier()) {
1818
+ if (matchesIgnoreName(tagPath.node.name)) return true;
1819
+ const binding = tagPath?.scope?.getBinding?.(tagPath.node.name);
1820
+ if (binding) return resolvesToWeappTwIgnore(binding, seen);
1821
+ return false;
1822
+ }
1823
+ if (tagPath.isMemberExpression()) return resolvesMemberExpressionToIgnore(tagPath, seen);
1824
+ return false;
1825
+ };
1826
+ const computeIgnore = (tagPath) => {
1827
+ const cached = taggedTemplateIgnoreCache.get(tagPath.node);
1828
+ if (cached !== void 0) return cached;
1829
+ const effectiveTagPath = getEffectiveTagPath(tagPath);
1830
+ const effectiveCached = taggedTemplateIgnoreCache.get(effectiveTagPath.node);
1831
+ if (effectiveCached !== void 0) {
1832
+ taggedTemplateIgnoreCache.set(tagPath.node, effectiveCached);
1833
+ return effectiveCached;
1834
+ }
1835
+ seenBindings.clear();
1836
+ const result = evaluateTagPath(effectiveTagPath, seenBindings);
1837
+ taggedTemplateIgnoreCache.set(effectiveTagPath.node, result);
1838
+ taggedTemplateIgnoreCache.set(tagPath.node, result);
1839
+ return result;
1840
+ };
1841
+ return {
1842
+ shouldIgnore(tagPath) {
1843
+ return computeIgnore(tagPath);
1844
+ },
1845
+ getEffectiveTagPath
1846
+ };
1847
+ }
1848
+ //#endregion
1849
+ //#region src/js/babel.ts
1850
+ const EXPRESSION_WRAPPER_PREFIX = "(\n";
1851
+ const EXPRESSION_WRAPPER_SUFFIX = "\n)";
1852
+ const EMPTY_IGNORED_PATHS = /* @__PURE__ */ new WeakSet();
1853
+ const EMPTY_IMPORT_DECLARATIONS = /* @__PURE__ */ new Set();
1854
+ const EMPTY_EXPORT_DECLARATIONS = /* @__PURE__ */ new Set();
1855
+ const EMPTY_REQUIRE_CALL_PATHS = [];
1856
+ const ignoredTaggedTemplateMatcherCache = /* @__PURE__ */ new WeakMap();
1857
+ let defaultEvalHandler;
1858
+ function getIgnoredTaggedTemplateMatcher(options) {
1859
+ const cached = ignoredTaggedTemplateMatcherCache.get(options);
1860
+ if (cached) return cached;
1861
+ const created = createNameMatcher(options.ignoreTaggedTemplateExpressionIdentifiers, { exact: true });
1862
+ ignoredTaggedTemplateMatcherCache.set(options, created);
1863
+ return created;
1864
+ }
1865
+ function getDefaultEvalHandler() {
1866
+ if (!defaultEvalHandler) throw new Error("Default JS eval handler is not initialized.");
1867
+ return defaultEvalHandler;
1868
+ }
1869
+ function analyzeSource(ast, options, handler, collectModuleMetadata = true) {
1870
+ const jsTokenUpdater = new JsTokenUpdater();
1871
+ const needScope = Boolean(options.ignoreCallExpressionIdentifiers && options.ignoreCallExpressionIdentifiers.length > 0);
1872
+ const ignoredPaths = needScope ? /* @__PURE__ */ new WeakSet() : EMPTY_IGNORED_PATHS;
1873
+ const walker = needScope ? new NodePathWalker({
1874
+ ...options.ignoreCallExpressionIdentifiers === void 0 ? {} : { ignoreCallExpressionIdentifiers: options.ignoreCallExpressionIdentifiers },
1875
+ callback(path) {
1876
+ ignoredPaths.add(path);
1877
+ }
1878
+ }) : new NodePathWalker();
1879
+ let taggedTemplateIgnore;
1880
+ const hasTaggedTemplateIgnoreIdentifiers = Boolean(options.ignoreTaggedTemplateExpressionIdentifiers && options.ignoreTaggedTemplateExpressionIdentifiers.length > 0);
1881
+ function getTaggedTemplateIgnore() {
1882
+ if (!taggedTemplateIgnore) taggedTemplateIgnore = createTaggedTemplateIgnore({
1883
+ matcher: getIgnoredTaggedTemplateMatcher(options),
1884
+ ...options.ignoreTaggedTemplateExpressionIdentifiers === void 0 ? {} : { names: options.ignoreTaggedTemplateExpressionIdentifiers }
1885
+ });
1886
+ return taggedTemplateIgnore;
1887
+ }
1888
+ const targetPaths = [];
1889
+ const importDeclarations = collectModuleMetadata ? /* @__PURE__ */ new Set() : EMPTY_IMPORT_DECLARATIONS;
1890
+ const exportDeclarations = collectModuleMetadata ? /* @__PURE__ */ new Set() : EMPTY_EXPORT_DECLARATIONS;
1891
+ const requireCallPaths = collectModuleMetadata ? [] : EMPTY_REQUIRE_CALL_PATHS;
1892
+ const evalHandler = handler ?? getDefaultEvalHandler();
1893
+ traverse(ast, {
1894
+ StringLiteral: { enter(p) {
1895
+ if (isEvalPath(p.parentPath)) return;
1896
+ targetPaths.push(p);
1897
+ } },
1898
+ TemplateElement: { enter: hasTaggedTemplateIgnoreIdentifiers ? (p) => {
1899
+ const pp = p.parentPath;
1900
+ if (pp.isTemplateLiteral()) {
1901
+ const ppp = pp.parentPath;
1902
+ if (isEvalPath(ppp)) return;
1903
+ if (ppp.isTaggedTemplateExpression()) {
1904
+ const tagPath = ppp.get("tag");
1905
+ if (getTaggedTemplateIgnore().shouldIgnore(tagPath)) return;
1906
+ }
1907
+ }
1908
+ targetPaths.push(p);
1909
+ } : (p) => {
1910
+ const pp = p.parentPath;
1911
+ if (pp.isTemplateLiteral()) {
1912
+ const ppp = pp.parentPath;
1913
+ if (isEvalPath(ppp)) return;
1914
+ }
1915
+ targetPaths.push(p);
1916
+ } },
1917
+ CallExpression: { enter: !collectModuleMetadata && !needScope ? (p) => {
1918
+ if (isEvalPath(p)) walkEvalExpression(p, options, jsTokenUpdater, evalHandler);
1919
+ } : (p) => {
1920
+ if (isEvalPath(p)) {
1921
+ walkEvalExpression(p, options, jsTokenUpdater, evalHandler);
1922
+ return;
1923
+ }
1924
+ const calleePath = p.get("callee");
1925
+ if (collectModuleMetadata && calleePath.isIdentifier({ name: "require" }) && !p?.scope?.hasBinding?.("require")) {
1926
+ const args = p.get("arguments");
1927
+ if (Array.isArray(args) && args.length > 0) {
1928
+ const first = args[0];
1929
+ if (first?.isStringLiteral()) requireCallPaths.push(first);
1930
+ }
1931
+ }
1932
+ if (needScope) walker.walkCallExpression(p);
1933
+ } },
1934
+ ...collectModuleMetadata ? {
1935
+ ImportDeclaration: { enter(p) {
1936
+ importDeclarations.add(p);
1937
+ } },
1938
+ ExportDeclaration: { enter(p) {
1939
+ exportDeclarations.add(p);
1940
+ } }
1941
+ } : {},
1942
+ noScope: !needScope
1943
+ });
1944
+ return {
1945
+ walker,
1946
+ jsTokenUpdater,
1947
+ ast,
1948
+ targetPaths,
1949
+ importDeclarations,
1950
+ exportDeclarations,
1951
+ requireCallPaths,
1952
+ ignoredPaths
1953
+ };
1954
+ }
1955
+ function jsHandler(rawSource, options) {
1956
+ const shouldWrapExpression = Boolean(options.wrapExpression);
1957
+ const source = shouldWrapExpression ? `${EXPRESSION_WRAPPER_PREFIX}${rawSource}${EXPRESSION_WRAPPER_SUFFIX}` : rawSource;
1958
+ let ast;
1959
+ try {
1960
+ ast = babelParse(source, options.babelParserOptions);
1961
+ } catch (error) {
1962
+ return {
1963
+ code: rawSource,
1964
+ error
1965
+ };
1966
+ }
1967
+ const needsModuleMetadata = Boolean(options.moduleSpecifierReplacements || options.moduleGraph && options.filename);
1968
+ const analysis = analyzeSource(ast, options, jsHandler, needsModuleMetadata);
1969
+ const ms = processUpdatedSource(source, options, analysis);
1970
+ if (shouldWrapExpression) {
1971
+ const start = 0;
1972
+ const end = source.length;
1973
+ const prefixLength = 2;
1974
+ const suffixLength = 2;
1975
+ ms.remove(start, start + prefixLength);
1976
+ ms.remove(end - suffixLength, end);
1977
+ }
1978
+ const result = { code: ms.toString() };
1979
+ if (options.generateMap) Object.defineProperty(result, "map", {
1980
+ configurable: true,
1981
+ enumerable: true,
1982
+ get() {
1983
+ return ms.generateMap();
1984
+ }
1985
+ });
1986
+ if (options.moduleGraph && options.filename) {
1987
+ const linked = new JsModuleGraph({
1988
+ filename: options.filename,
1989
+ source: rawSource,
1990
+ analysis,
1991
+ handlerOptions: options
1992
+ }, options.moduleGraph).build();
1993
+ if (linked) result.linked = linked;
1994
+ }
1995
+ return result;
1996
+ }
1997
+ defaultEvalHandler = jsHandler;
1998
+ //#endregion
1999
+ //#region src/js/index.ts
2000
+ /** 默认 LRU 缓存最大条目数 */
2001
+ const RESULT_CACHE_MAX = 512;
2002
+ /** 仅对短片段做内层结果缓存,避免 bundler 热路径重复 hash 大块 JS。 */
2003
+ const CACHEABLE_SOURCE_MAX_LENGTH = 512;
2004
+ /** 为每个 ClassNameSet 实例分配递增 ID */
2005
+ const classNameSetIds = /* @__PURE__ */ new WeakMap();
2006
+ let nextClassNameSetId = 0;
2007
+ /**
2008
+ * 获取 ClassNameSet 的唯一身份 ID。
2009
+ * 每个 Set 引用分配一个递增整数,用于指纹计算。
2010
+ */
2011
+ function getClassNameSetId(set) {
2012
+ if (!set) return "none";
2013
+ const existing = classNameSetIds.get(set);
2014
+ if (existing !== void 0) return String(existing);
2015
+ const id = nextClassNameSetId++;
2016
+ classNameSetIds.set(set, id);
2017
+ return String(id);
2018
+ }
2019
+ /** 缓存 IJsHandlerOptions -> fingerprint 的映射 */
2020
+ const fingerprintCache = /* @__PURE__ */ new WeakMap();
2021
+ /**
2022
+ * 计算选项指纹,包含所有影响转译结果的字段。
2023
+ * 不包含 filename、moduleGraph、jsPreserveClass。
2024
+ */
2025
+ function getOptionsFingerprint(options) {
2026
+ const cached = fingerprintCache.get(options);
2027
+ if (cached) return cached;
2028
+ const fingerprint = [
2029
+ getClassNameSetId(options.classNameSet),
2030
+ JSON.stringify(options.escapeMap ?? null),
2031
+ options.needEscaped ? "1" : "0",
2032
+ options.alwaysEscape ? "1" : "0",
2033
+ options.unescapeUnicode ? "1" : "0",
2034
+ options.generateMap ? "1" : "0",
2035
+ options.uniAppX ? "1" : "0",
2036
+ options.wrapExpression ? "1" : "0",
2037
+ String(options.tailwindcssMajorVersion ?? ""),
2038
+ String(options.jsArbitraryValueFallback ?? ""),
2039
+ JSON.stringify(options.arbitraryValues ?? null),
2040
+ JSON.stringify(options.ignoreCallExpressionIdentifiers ?? null),
2041
+ JSON.stringify(options.ignoreTaggedTemplateExpressionIdentifiers?.map((v) => v instanceof RegExp ? v.source : v) ?? null),
2042
+ JSON.stringify(options.moduleSpecifierReplacements ?? null),
2043
+ JSON.stringify(options.babelParserOptions ?? null)
2044
+ ].join("|");
2045
+ fingerprintCache.set(options, fingerprint);
2046
+ return fingerprint;
2047
+ }
2048
+ function hasDefinedOverrides(options) {
2049
+ if (!options) return false;
2050
+ for (const key in options) if (options[key] !== void 0) return true;
2051
+ return false;
2052
+ }
2053
+ function shouldCacheJsResult(rawSource, options) {
2054
+ if (rawSource.length === 0 || rawSource.length > CACHEABLE_SOURCE_MAX_LENGTH) return false;
2055
+ if (options.moduleGraph || options.filename) return false;
2056
+ return true;
2057
+ }
2058
+ function createJsHandler(options) {
2059
+ const defaults = {
2060
+ escapeMap: options.escapeMap,
2061
+ jsArbitraryValueFallback: options.jsArbitraryValueFallback,
2062
+ tailwindcssMajorVersion: options.tailwindcssMajorVersion,
2063
+ arbitraryValues: options.arbitraryValues,
2064
+ jsPreserveClass: options.jsPreserveClass,
2065
+ generateMap: options.generateMap,
2066
+ needEscaped: options.needEscaped,
2067
+ alwaysEscape: options.alwaysEscape,
2068
+ unescapeUnicode: options.unescapeUnicode,
2069
+ babelParserOptions: options.babelParserOptions,
2070
+ ignoreCallExpressionIdentifiers: options.ignoreCallExpressionIdentifiers,
2071
+ ignoreTaggedTemplateExpressionIdentifiers: options.ignoreTaggedTemplateExpressionIdentifiers,
2072
+ uniAppX: options.uniAppX,
2073
+ moduleSpecifierReplacements: options.moduleSpecifierReplacements
2074
+ };
2075
+ /** 层1: 无 override 时,classNameSet -> resolvedOptions */
2076
+ const defaultOptionsCache = /* @__PURE__ */ new WeakMap();
2077
+ let resolvedOptionsWithoutClassNameSet;
2078
+ /** 层2: 有 override 时,overrideOptions -> { bySet, noSet } */
2079
+ const overrideOptionsCache = /* @__PURE__ */ new WeakMap();
2080
+ const resultCache = new LRUCache({ max: RESULT_CACHE_MAX });
2081
+ function resolveDefaultOptions(classNameSet) {
2082
+ if (!classNameSet) {
2083
+ if (!resolvedOptionsWithoutClassNameSet) resolvedOptionsWithoutClassNameSet = {
2084
+ ...defaults,
2085
+ classNameSet
2086
+ };
2087
+ return resolvedOptionsWithoutClassNameSet;
2088
+ }
2089
+ const cached = defaultOptionsCache.get(classNameSet);
2090
+ if (cached) return cached;
2091
+ const created = {
2092
+ ...defaults,
2093
+ classNameSet
2094
+ };
2095
+ defaultOptionsCache.set(classNameSet, created);
2096
+ return created;
2097
+ }
2098
+ function getCachedJsResult(rawSource, resolvedOptions) {
2099
+ if (!shouldCacheJsResult(rawSource, resolvedOptions)) return;
2100
+ const key = `${getOptionsFingerprint(resolvedOptions)}:${md5Hash(rawSource)}`;
2101
+ return resultCache.get(key);
2102
+ }
2103
+ function setCachedJsResult(rawSource, resolvedOptions, result) {
2104
+ if (!shouldCacheJsResult(rawSource, resolvedOptions) || result.error || result.linked) return result;
2105
+ const key = `${getOptionsFingerprint(resolvedOptions)}:${md5Hash(rawSource)}`;
2106
+ resultCache.set(key, result);
2107
+ return result;
2108
+ }
2109
+ function resolveOptions(classNameSet, overrideOptions) {
2110
+ if (!hasDefinedOverrides(overrideOptions)) return resolveDefaultOptions(classNameSet);
2111
+ let entry = overrideOptionsCache.get(overrideOptions);
2112
+ if (!entry) {
2113
+ entry = { bySet: /* @__PURE__ */ new WeakMap() };
2114
+ overrideOptionsCache.set(overrideOptions, entry);
2115
+ }
2116
+ if (!classNameSet) {
2117
+ if (entry.noSet) return entry.noSet;
2118
+ const created = defuOverrideArray({
2119
+ ...overrideOptions,
2120
+ classNameSet
2121
+ }, defaults);
2122
+ entry.noSet = created;
2123
+ return created;
2124
+ }
2125
+ const cached = entry.bySet.get(classNameSet);
2126
+ if (cached) return cached;
2127
+ const created = defuOverrideArray({
2128
+ ...overrideOptions,
2129
+ classNameSet
2130
+ }, defaults);
2131
+ entry.bySet.set(classNameSet, created);
2132
+ return created;
2133
+ }
2134
+ function handler(rawSource, classNameSet, options) {
2135
+ const resolvedOptions = resolveOptions(classNameSet, options);
2136
+ const cached = getCachedJsResult(rawSource, resolvedOptions);
2137
+ if (cached) return cached;
2138
+ return setCachedJsResult(rawSource, resolvedOptions, jsHandler(rawSource, resolvedOptions));
2139
+ }
2140
+ return handler;
2141
+ }
2142
+ //#endregion
2143
+ //#region src/wxml/custom-attributes.ts
2144
+ function regTest(reg, str) {
2145
+ reg.lastIndex = 0;
2146
+ return reg.test(str);
2147
+ }
2148
+ function isPropsMatch(props, attr) {
2149
+ if (Array.isArray(props)) {
2150
+ let lowerAttr;
2151
+ for (const prop of props) if (typeof prop === "string") {
2152
+ lowerAttr ?? (lowerAttr = attr.toLowerCase());
2153
+ if (prop.toLowerCase() === lowerAttr) return true;
2154
+ } else if (regTest(prop, attr)) return true;
2155
+ return false;
2156
+ } else if (typeof props === "string") return props === attr;
2157
+ else return regTest(props, attr);
2158
+ }
2159
+ function createAttributeMatcher(entities) {
2160
+ if (!entities || entities.length === 0) return;
2161
+ const wildcardAttributeRules = [];
2162
+ const tagAttributeRuleMap = /* @__PURE__ */ new Map();
2163
+ const regexpAttributeRules = [];
2164
+ for (const [selector, props] of entities) if (selector === "*") wildcardAttributeRules.push(props);
2165
+ else if (typeof selector === "string") {
2166
+ const list = tagAttributeRuleMap.get(selector);
2167
+ if (list) list.push(props);
2168
+ else tagAttributeRuleMap.set(selector, [props]);
2169
+ } else regexpAttributeRules.push([selector, props]);
2170
+ return (tag, attr) => {
2171
+ for (const props of wildcardAttributeRules) if (isPropsMatch(props, attr)) return true;
2172
+ const tagRules = tagAttributeRuleMap.get(tag);
2173
+ if (tagRules) {
2174
+ for (const props of tagRules) if (isPropsMatch(props, attr)) return true;
2175
+ }
2176
+ for (const [selector, props] of regexpAttributeRules) if (regTest(selector, tag) && isPropsMatch(props, attr)) return true;
2177
+ return false;
2178
+ };
2179
+ }
2180
+ //#endregion
2181
+ //#region src/wxml/utils/codegen/legacy-visitor.ts
2182
+ function shouldSkipLegacyStringLiteral(path) {
2183
+ if (t.isMemberExpression(path.parent)) return true;
2184
+ return Boolean(t.isBinaryExpression(path.parent) && (t.isConditionalExpression(path.parentPath?.parent) || t.isLogicalExpression(path.parentPath?.parent)));
2185
+ }
2186
+ function createLegacyTraverseOptions(options, jsTokenUpdater) {
2187
+ const legacyReplaceOptions = {
2188
+ escapeMap: options.escapeMap,
2189
+ classNameSet: options.runtimeSet,
2190
+ needEscaped: true,
2191
+ alwaysEscape: true
2192
+ };
2193
+ return {
2194
+ StringLiteral(path) {
2195
+ if (shouldSkipLegacyStringLiteral(path)) return;
2196
+ jsTokenUpdater.addToken(replaceHandleValue(path, legacyReplaceOptions));
2197
+ },
2198
+ noScope: true
2199
+ };
2200
+ }
2201
+ //#endregion
2202
+ //#region src/wxml/utils/codegen/legacy-rewriter.ts
2203
+ function rewriteLegacyExpression(match, options) {
2204
+ const ast = parseExpression(match);
2205
+ const jsTokenUpdater = new JsTokenUpdater();
2206
+ traverse(ast, createLegacyTraverseOptions(options, jsTokenUpdater));
2207
+ if (jsTokenUpdater.length === 0) return match;
2208
+ const ms = new MagicString(match);
2209
+ jsTokenUpdater.updateMagicString(ms);
2210
+ return ms.toString();
2211
+ }
2212
+ //#endregion
2213
+ //#region src/wxml/utils/codegen.ts
2214
+ const WRAP_EXPRESSION_HANDLER_OPTIONS = Object.freeze({ wrapExpression: true });
2215
+ function generateCode(match, options = {}) {
2216
+ try {
2217
+ const { jsHandler, runtimeSet, wrapExpression } = options;
2218
+ if (jsHandler && runtimeSet) {
2219
+ const initial = jsHandler(match, runtimeSet, wrapExpression ? WRAP_EXPRESSION_HANDLER_OPTIONS : void 0);
2220
+ if (!initial.error || wrapExpression) return initial.code;
2221
+ return jsHandler(match, runtimeSet, WRAP_EXPRESSION_HANDLER_OPTIONS).code;
2222
+ } else return rewriteLegacyExpression(match, options);
2223
+ } catch {
2224
+ return match;
2225
+ }
2226
+ }
2227
+ //#endregion
2228
+ //#region ../../node_modules/.pnpm/entities@8.0.0/node_modules/entities/dist/decode-codepoint.js
2229
+ const decodeMap = new Map([
2230
+ [0, 65533],
2231
+ [128, 8364],
2232
+ [130, 8218],
2233
+ [131, 402],
2234
+ [132, 8222],
2235
+ [133, 8230],
2236
+ [134, 8224],
2237
+ [135, 8225],
2238
+ [136, 710],
2239
+ [137, 8240],
2240
+ [138, 352],
2241
+ [139, 8249],
2242
+ [140, 338],
2243
+ [142, 381],
2244
+ [145, 8216],
2245
+ [146, 8217],
2246
+ [147, 8220],
2247
+ [148, 8221],
2248
+ [149, 8226],
2249
+ [150, 8211],
2250
+ [151, 8212],
2251
+ [152, 732],
2252
+ [153, 8482],
2253
+ [154, 353],
2254
+ [155, 8250],
2255
+ [156, 339],
2256
+ [158, 382],
2257
+ [159, 376]
2258
+ ]);
2259
+ /**
2260
+ * Replace the given code point with a replacement character if it is a
2261
+ * surrogate or is outside the valid range. Otherwise return the code
2262
+ * point unchanged.
2263
+ * @param codePoint Unicode code point to convert.
2264
+ */
2265
+ function replaceCodePoint(codePoint) {
2266
+ if (codePoint >= 55296 && codePoint <= 57343 || codePoint > 1114111) return 65533;
2267
+ return decodeMap.get(codePoint) ?? codePoint;
2268
+ }
2269
+ //#endregion
2270
+ //#region ../../node_modules/.pnpm/entities@8.0.0/node_modules/entities/dist/internal/decode-shared.js
2271
+ /**
2272
+ * Shared base64 decode helper for generated decode data.
2273
+ * Assumes global atob is available.
2274
+ * @param input Input string to encode or decode.
2275
+ */
2276
+ function decodeBase64(input) {
2277
+ const binary = atob(input);
2278
+ const evenLength = binary.length & -2;
2279
+ const out = new Uint16Array(evenLength / 2);
2280
+ for (let index = 0, outIndex = 0; index < evenLength; index += 2) {
2281
+ const lo = binary.charCodeAt(index);
2282
+ const hi = binary.charCodeAt(index + 1);
2283
+ out[outIndex++] = lo | hi << 8;
2284
+ }
2285
+ return out;
2286
+ }
2287
+ //#endregion
2288
+ //#region ../../node_modules/.pnpm/entities@8.0.0/node_modules/entities/dist/generated/decode-data-html.js
2289
+ /** Packed HTML decode trie data. */
2290
+ const htmlDecodeTree = /* @__PURE__ */ decodeBase64("QR08ALkAAgH6AYsDNQR2BO0EPgXZBQEGLAbdBxMISQrvCmQLfQurDKQNLw4fD4YPpA+6D/IPAAAAAAAAAAAAAAAAKhBMEY8TmxUWF2EYLBkxGuAa3RsJHDscWR8YIC8jSCSIJcMl6ie3Ku8rEC0CLjoupS7kLgAIRU1hYmNmZ2xtbm9wcnN0dVQAWgBeAGUAaQBzAHcAfgCBAIQAhwCSAJoAoACsALMAbABpAGcAO4DGAMZAUAA7gCYAJkBjAHUAdABlADuAwQDBQHIiZXZlAAJhAAFpeW0AcgByAGMAO4DCAMJAEGRyAADgNdgE3XIAYQB2AGUAO4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x9LoAuAOA12GnddQDzAP8RaQBtAOUABBIAAUFhiy6OLnIA8gDuAnIA8gCaBwABY3GVLgoScgAA4DXYzdwAAXB0nS6hLmwAdQDzACUScgDpACASAARhY2VmaW9zdbEuvC7ELsguzC7PLtQu2S5jAAABdXm2LrsudABlADuA/QD9QE9kAAFpecAuwy5yAGMAd2FLZG4AO4ClAKVAcgAA4DXYNt1jAHkAV2RwAGYAAOA12GrdYwByAADgNdjO3AABY23dLt8ueQBOZGwAO4D/AP9AAAVhY2RlZmhpb3N38y73Lv8uAi8MLxAvEy8YLx0vIi9jInV0ZQB6YQABYXn7Lv4u8iFvbn5hN2RvAHQAfGEAAWV0Bi8KL3QAcgDmAB8QYQC2Y3IAAOA12DfdYwB5ADZk5yJyYXJyAKDdIXAAZgAA4DXYa91jAHIAAOA12M/cAAFqbiYvKC8AoA0gagAAoAwg");
2291
+ //#endregion
2292
+ //#region ../../node_modules/.pnpm/entities@8.0.0/node_modules/entities/dist/generated/decode-data-xml.js
2293
+ /** Packed XML decode trie data. */
2294
+ const xmlDecodeTree = /* @__PURE__ */ decodeBase64("AAJhZ2xxBwARABMAFQBtAg0AAAAAAA8AcAAmYG8AcwAnYHQAPmB0ADxg9SFvdCJg");
2295
+ //#endregion
2296
+ //#region ../../node_modules/.pnpm/entities@8.0.0/node_modules/entities/dist/internal/bin-trie-flags.js
2297
+ /**
2298
+ * Bit flags & masks for the binary trie encoding used for entity decoding.
2299
+ *
2300
+ * Bit layout (16 bits total):
2301
+ * 15..14 VALUE_LENGTH (+1 encoding; 0 => no value)
2302
+ * 13 FLAG13. If valueLength>0: semicolon required flag (implicit ';').
2303
+ * If valueLength==0: compact run flag.
2304
+ * 12..7 BRANCH_LENGTH Branch length (0 => single branch in 6..0 if jumpOffset==char) OR run length (when compact run)
2305
+ * 6..0 JUMP_TABLE Jump offset (jump table) OR single-branch char code OR first run char
2306
+ */
2307
+ var BinTrieFlags;
2308
+ (function(BinTrieFlags) {
2309
+ BinTrieFlags[BinTrieFlags["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
2310
+ BinTrieFlags[BinTrieFlags["FLAG13"] = 8192] = "FLAG13";
2311
+ BinTrieFlags[BinTrieFlags["BRANCH_LENGTH"] = 8064] = "BRANCH_LENGTH";
2312
+ BinTrieFlags[BinTrieFlags["JUMP_TABLE"] = 127] = "JUMP_TABLE";
2313
+ })(BinTrieFlags || (BinTrieFlags = {}));
2314
+ //#endregion
2315
+ //#region ../../node_modules/.pnpm/entities@8.0.0/node_modules/entities/dist/decode.js
2316
+ var CharCodes$1;
2317
+ (function(CharCodes) {
2318
+ CharCodes[CharCodes["NUM"] = 35] = "NUM";
2319
+ CharCodes[CharCodes["SEMI"] = 59] = "SEMI";
2320
+ CharCodes[CharCodes["EQUALS"] = 61] = "EQUALS";
2321
+ CharCodes[CharCodes["ZERO"] = 48] = "ZERO";
2322
+ CharCodes[CharCodes["NINE"] = 57] = "NINE";
2323
+ CharCodes[CharCodes["LOWER_A"] = 97] = "LOWER_A";
2324
+ CharCodes[CharCodes["LOWER_F"] = 102] = "LOWER_F";
2325
+ CharCodes[CharCodes["LOWER_X"] = 120] = "LOWER_X";
2326
+ CharCodes[CharCodes["LOWER_Z"] = 122] = "LOWER_Z";
2327
+ CharCodes[CharCodes["UPPER_A"] = 65] = "UPPER_A";
2328
+ CharCodes[CharCodes["UPPER_F"] = 70] = "UPPER_F";
2329
+ CharCodes[CharCodes["UPPER_Z"] = 90] = "UPPER_Z";
2330
+ })(CharCodes$1 || (CharCodes$1 = {}));
2331
+ /** Bit that needs to be set to convert an upper case ASCII character to lower case */
2332
+ const TO_LOWER_BIT = 32;
2333
+ function isNumber(code) {
2334
+ return code >= CharCodes$1.ZERO && code <= CharCodes$1.NINE;
2335
+ }
2336
+ function isHexadecimalCharacter(code) {
2337
+ return code >= CharCodes$1.UPPER_A && code <= CharCodes$1.UPPER_F || code >= CharCodes$1.LOWER_A && code <= CharCodes$1.LOWER_F;
2338
+ }
2339
+ function isAsciiAlphaNumeric(code) {
2340
+ return code >= CharCodes$1.UPPER_A && code <= CharCodes$1.UPPER_Z || code >= CharCodes$1.LOWER_A && code <= CharCodes$1.LOWER_Z || isNumber(code);
2341
+ }
2342
+ /**
2343
+ * Checks if the given character is a valid end character for an entity in an attribute.
2344
+ *
2345
+ * Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.
2346
+ * See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
2347
+ * @param code Code point to decode.
2348
+ */
2349
+ function isEntityInAttributeInvalidEnd(code) {
2350
+ return code === CharCodes$1.EQUALS || isAsciiAlphaNumeric(code);
2351
+ }
2352
+ var EntityDecoderState;
2353
+ (function(EntityDecoderState) {
2354
+ EntityDecoderState[EntityDecoderState["EntityStart"] = 0] = "EntityStart";
2355
+ EntityDecoderState[EntityDecoderState["NumericStart"] = 1] = "NumericStart";
2356
+ EntityDecoderState[EntityDecoderState["NumericDecimal"] = 2] = "NumericDecimal";
2357
+ EntityDecoderState[EntityDecoderState["NumericHex"] = 3] = "NumericHex";
2358
+ EntityDecoderState[EntityDecoderState["NamedEntity"] = 4] = "NamedEntity";
2359
+ })(EntityDecoderState || (EntityDecoderState = {}));
2360
+ /**
2361
+ * Decoding mode for named entities.
2362
+ */
2363
+ var DecodingMode;
2364
+ (function(DecodingMode) {
2365
+ /** Entities in text nodes that can end with any character. */
2366
+ DecodingMode[DecodingMode["Legacy"] = 0] = "Legacy";
2367
+ /** Only allow entities terminated with a semicolon. */
2368
+ DecodingMode[DecodingMode["Strict"] = 1] = "Strict";
2369
+ /** Entities in attributes have limitations on ending characters. */
2370
+ DecodingMode[DecodingMode["Attribute"] = 2] = "Attribute";
2371
+ })(DecodingMode || (DecodingMode = {}));
2372
+ /**
2373
+ * Token decoder with support of writing partial entities.
2374
+ */
2375
+ var EntityDecoder = class {
2376
+ constructor(decodeTree, emitCodePoint, errors) {
2377
+ _defineProperty(this, "decodeTree", void 0);
2378
+ _defineProperty(this, "emitCodePoint", void 0);
2379
+ _defineProperty(this, "errors", void 0);
2380
+ _defineProperty(
2381
+ this,
2382
+ /** The current state of the decoder. */
2383
+ "state",
2384
+ EntityDecoderState.EntityStart
2385
+ );
2386
+ _defineProperty(
2387
+ this,
2388
+ /** Characters that were consumed while parsing an entity. */
2389
+ "consumed",
2390
+ 1
2391
+ );
2392
+ _defineProperty(
2393
+ this,
2394
+ /**
2395
+ * The result of the entity.
2396
+ *
2397
+ * Either the result index of a numeric entity, or the codepoint of a
2398
+ * numeric entity.
2399
+ */
2400
+ "result",
2401
+ 0
2402
+ );
2403
+ _defineProperty(
2404
+ this,
2405
+ /** The current index in the decode tree. */
2406
+ "treeIndex",
2407
+ 0
2408
+ );
2409
+ _defineProperty(
2410
+ this,
2411
+ /** The number of characters that were consumed in excess. */
2412
+ "excess",
2413
+ 1
2414
+ );
2415
+ _defineProperty(
2416
+ this,
2417
+ /** The mode in which the decoder is operating. */
2418
+ "decodeMode",
2419
+ DecodingMode.Strict
2420
+ );
2421
+ _defineProperty(
2422
+ this,
2423
+ /** The number of characters that have been consumed in the current run. */
2424
+ "runConsumed",
2425
+ 0
2426
+ );
2427
+ this.decodeTree = decodeTree;
2428
+ this.emitCodePoint = emitCodePoint;
2429
+ this.errors = errors;
2430
+ }
2431
+ /**
2432
+ * Resets the instance to make it reusable.
2433
+ * @param decodeMode Entity decoding mode to use.
2434
+ */
2435
+ startEntity(decodeMode) {
2436
+ this.decodeMode = decodeMode;
2437
+ this.state = EntityDecoderState.EntityStart;
2438
+ this.result = 0;
2439
+ this.treeIndex = 0;
2440
+ this.excess = 1;
2441
+ this.consumed = 1;
2442
+ this.runConsumed = 0;
2443
+ }
2444
+ /**
2445
+ * Write an entity to the decoder. This can be called multiple times with partial entities.
2446
+ * If the entity is incomplete, the decoder will return -1.
2447
+ *
2448
+ * Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
2449
+ * entity is incomplete, and resume when the next string is written.
2450
+ * @param input The string containing the entity (or a continuation of the entity).
2451
+ * @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
2452
+ * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
2453
+ */
2454
+ write(input, offset) {
2455
+ switch (this.state) {
2456
+ case EntityDecoderState.EntityStart:
2457
+ if (input.charCodeAt(offset) === CharCodes$1.NUM) {
2458
+ this.state = EntityDecoderState.NumericStart;
2459
+ this.consumed += 1;
2460
+ return this.stateNumericStart(input, offset + 1);
2461
+ }
2462
+ this.state = EntityDecoderState.NamedEntity;
2463
+ return this.stateNamedEntity(input, offset);
2464
+ case EntityDecoderState.NumericStart: return this.stateNumericStart(input, offset);
2465
+ case EntityDecoderState.NumericDecimal: return this.stateNumericDecimal(input, offset);
2466
+ case EntityDecoderState.NumericHex: return this.stateNumericHex(input, offset);
2467
+ case EntityDecoderState.NamedEntity: return this.stateNamedEntity(input, offset);
2468
+ }
2469
+ }
2470
+ /**
2471
+ * Switches between the numeric decimal and hexadecimal states.
2472
+ *
2473
+ * Equivalent to the `Numeric character reference state` in the HTML spec.
2474
+ * @param input The string containing the entity (or a continuation of the entity).
2475
+ * @param offset The current offset.
2476
+ * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
2477
+ */
2478
+ stateNumericStart(input, offset) {
2479
+ if (offset >= input.length) return -1;
2480
+ if ((input.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes$1.LOWER_X) {
2481
+ this.state = EntityDecoderState.NumericHex;
2482
+ this.consumed += 1;
2483
+ return this.stateNumericHex(input, offset + 1);
2484
+ }
2485
+ this.state = EntityDecoderState.NumericDecimal;
2486
+ return this.stateNumericDecimal(input, offset);
2487
+ }
2488
+ /**
2489
+ * Parses a hexadecimal numeric entity.
2490
+ *
2491
+ * Equivalent to the `Hexademical character reference state` in the HTML spec.
2492
+ * @param input The string containing the entity (or a continuation of the entity).
2493
+ * @param offset The current offset.
2494
+ * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
2495
+ */
2496
+ stateNumericHex(input, offset) {
2497
+ while (offset < input.length) {
2498
+ const char = input.charCodeAt(offset);
2499
+ if (isNumber(char) || isHexadecimalCharacter(char)) {
2500
+ const digit = char <= CharCodes$1.NINE ? char - CharCodes$1.ZERO : (char | TO_LOWER_BIT) - CharCodes$1.LOWER_A + 10;
2501
+ this.result = this.result * 16 + digit;
2502
+ this.consumed++;
2503
+ offset++;
2504
+ } else return this.emitNumericEntity(char, 3);
2505
+ }
2506
+ return -1;
2507
+ }
2508
+ /**
2509
+ * Parses a decimal numeric entity.
2510
+ *
2511
+ * Equivalent to the `Decimal character reference state` in the HTML spec.
2512
+ * @param input The string containing the entity (or a continuation of the entity).
2513
+ * @param offset The current offset.
2514
+ * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
2515
+ */
2516
+ stateNumericDecimal(input, offset) {
2517
+ while (offset < input.length) {
2518
+ const char = input.charCodeAt(offset);
2519
+ if (isNumber(char)) {
2520
+ this.result = this.result * 10 + (char - CharCodes$1.ZERO);
2521
+ this.consumed++;
2522
+ offset++;
2523
+ } else return this.emitNumericEntity(char, 2);
2524
+ }
2525
+ return -1;
2526
+ }
2527
+ /**
2528
+ * Validate and emit a numeric entity.
2529
+ *
2530
+ * Implements the logic from the `Hexademical character reference start
2531
+ * state` and `Numeric character reference end state` in the HTML spec.
2532
+ * @param lastCp The last code point of the entity. Used to see if the
2533
+ * entity was terminated with a semicolon.
2534
+ * @param expectedLength The minimum number of characters that should be
2535
+ * consumed. Used to validate that at least one digit
2536
+ * was consumed.
2537
+ * @returns The number of characters that were consumed.
2538
+ */
2539
+ emitNumericEntity(lastCp, expectedLength) {
2540
+ if (this.consumed <= expectedLength) {
2541
+ this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);
2542
+ return 0;
2543
+ }
2544
+ if (lastCp === CharCodes$1.SEMI) this.consumed += 1;
2545
+ else if (this.decodeMode === DecodingMode.Strict) return 0;
2546
+ this.emitCodePoint(replaceCodePoint(this.result), this.consumed);
2547
+ if (this.errors) {
2548
+ if (lastCp !== CharCodes$1.SEMI) this.errors.missingSemicolonAfterCharacterReference();
2549
+ this.errors.validateNumericCharacterReference(this.result);
2550
+ }
2551
+ return this.consumed;
2552
+ }
2553
+ /**
2554
+ * Parses a named entity.
2555
+ *
2556
+ * Equivalent to the `Named character reference state` in the HTML spec.
2557
+ * @param input The string containing the entity (or a continuation of the entity).
2558
+ * @param offset The current offset.
2559
+ * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
2560
+ */
2561
+ stateNamedEntity(input, offset) {
2562
+ const { decodeTree } = this;
2563
+ let current = decodeTree[this.treeIndex];
2564
+ let valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
2565
+ while (offset < input.length) {
2566
+ if (valueLength === 0 && (current & BinTrieFlags.FLAG13) !== 0) {
2567
+ const runLength = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
2568
+ if (this.runConsumed === 0) {
2569
+ const firstChar = current & BinTrieFlags.JUMP_TABLE;
2570
+ if (input.charCodeAt(offset) !== firstChar) return this.result === 0 ? 0 : this.emitNotTerminatedNamedEntity();
2571
+ offset++;
2572
+ this.excess++;
2573
+ this.runConsumed++;
2574
+ }
2575
+ while (this.runConsumed < runLength) {
2576
+ if (offset >= input.length) return -1;
2577
+ const charIndexInPacked = this.runConsumed - 1;
2578
+ const packedWord = decodeTree[this.treeIndex + 1 + (charIndexInPacked >> 1)];
2579
+ const expectedChar = charIndexInPacked % 2 === 0 ? packedWord & 255 : packedWord >> 8 & 255;
2580
+ if (input.charCodeAt(offset) !== expectedChar) {
2581
+ this.runConsumed = 0;
2582
+ return this.result === 0 ? 0 : this.emitNotTerminatedNamedEntity();
2583
+ }
2584
+ offset++;
2585
+ this.excess++;
2586
+ this.runConsumed++;
2587
+ }
2588
+ this.runConsumed = 0;
2589
+ this.treeIndex += 1 + (runLength >> 1);
2590
+ current = decodeTree[this.treeIndex];
2591
+ valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
2592
+ }
2593
+ if (offset >= input.length) break;
2594
+ const char = input.charCodeAt(offset);
2595
+ if (char === CharCodes$1.SEMI && valueLength !== 0 && (current & BinTrieFlags.FLAG13) !== 0) return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess);
2596
+ this.treeIndex = determineBranch(decodeTree, current, this.treeIndex + Math.max(1, valueLength), char);
2597
+ if (this.treeIndex < 0) return this.result === 0 || this.decodeMode === DecodingMode.Attribute && (valueLength === 0 || isEntityInAttributeInvalidEnd(char)) ? 0 : this.emitNotTerminatedNamedEntity();
2598
+ current = decodeTree[this.treeIndex];
2599
+ valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
2600
+ if (valueLength !== 0) {
2601
+ if (char === CharCodes$1.SEMI) return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess);
2602
+ if (this.decodeMode !== DecodingMode.Strict && (current & BinTrieFlags.FLAG13) === 0) {
2603
+ this.result = this.treeIndex;
2604
+ this.consumed += this.excess;
2605
+ this.excess = 0;
2606
+ }
2607
+ }
2608
+ offset++;
2609
+ this.excess++;
2610
+ }
2611
+ return -1;
2612
+ }
2613
+ /**
2614
+ * Emit a named entity that was not terminated with a semicolon.
2615
+ * @returns The number of characters consumed.
2616
+ */
2617
+ emitNotTerminatedNamedEntity() {
2618
+ const { result, decodeTree } = this;
2619
+ const valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14;
2620
+ this.emitNamedEntityData(result, valueLength, this.consumed);
2621
+ this.errors?.missingSemicolonAfterCharacterReference();
2622
+ return this.consumed;
2623
+ }
2624
+ /**
2625
+ * Emit a named entity.
2626
+ * @param result The index of the entity in the decode tree.
2627
+ * @param valueLength The number of bytes in the entity.
2628
+ * @param consumed The number of characters consumed.
2629
+ * @returns The number of characters consumed.
2630
+ */
2631
+ emitNamedEntityData(result, valueLength, consumed) {
2632
+ const { decodeTree } = this;
2633
+ this.emitCodePoint(valueLength === 1 ? decodeTree[result] & ~(BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13) : decodeTree[result + 1], consumed);
2634
+ if (valueLength === 3) this.emitCodePoint(decodeTree[result + 2], consumed);
2635
+ return consumed;
2636
+ }
2637
+ /**
2638
+ * Signal to the parser that the end of the input was reached.
2639
+ *
2640
+ * Remaining data will be emitted and relevant errors will be produced.
2641
+ * @returns The number of characters consumed.
2642
+ */
2643
+ end() {
2644
+ switch (this.state) {
2645
+ case EntityDecoderState.NamedEntity: return this.result !== 0 && (this.decodeMode !== DecodingMode.Attribute || this.result === this.treeIndex) ? this.emitNotTerminatedNamedEntity() : 0;
2646
+ case EntityDecoderState.NumericDecimal: return this.emitNumericEntity(0, 2);
2647
+ case EntityDecoderState.NumericHex: return this.emitNumericEntity(0, 3);
2648
+ case EntityDecoderState.NumericStart:
2649
+ this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);
2650
+ return 0;
2651
+ case EntityDecoderState.EntityStart: return 0;
2652
+ }
2653
+ }
2654
+ };
2655
+ /**
2656
+ * Determines the branch of the current node that is taken given the current
2657
+ * character. This function is used to traverse the trie.
2658
+ * @param decodeTree The trie.
2659
+ * @param current The current node.
2660
+ * @param nodeIndex Index immediately after the current node header.
2661
+ * @param char The current character.
2662
+ * @returns The index of the next node, or -1 if no branch is taken.
2663
+ */
2664
+ function determineBranch(decodeTree, current, nodeIndex, char) {
2665
+ const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
2666
+ const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
2667
+ if (branchCount === 0) return jumpOffset !== 0 && char === jumpOffset ? nodeIndex : -1;
2668
+ if (jumpOffset) {
2669
+ const value = char - jumpOffset;
2670
+ return value < 0 || value >= branchCount ? -1 : decodeTree[nodeIndex + value] - 1;
2671
+ }
2672
+ const packedKeySlots = branchCount + 1 >> 1;
2673
+ let lo = 0;
2674
+ let hi = branchCount - 1;
2675
+ while (lo <= hi) {
2676
+ const mid = lo + hi >>> 1;
2677
+ const midKey = decodeTree[nodeIndex + (mid >> 1)] >> (mid & 1) * 8 & 255;
2678
+ if (midKey < char) lo = mid + 1;
2679
+ else if (midKey > char) hi = mid - 1;
2680
+ else return decodeTree[nodeIndex + packedKeySlots + mid];
2681
+ }
2682
+ return -1;
2683
+ }
2684
+ //#endregion
2685
+ //#region ../../node_modules/.pnpm/htmlparser2@12.0.0/node_modules/htmlparser2/dist/Tokenizer.js
2686
+ var CharCodes;
2687
+ (function(CharCodes) {
2688
+ CharCodes[CharCodes["Tab"] = 9] = "Tab";
2689
+ CharCodes[CharCodes["NewLine"] = 10] = "NewLine";
2690
+ CharCodes[CharCodes["FormFeed"] = 12] = "FormFeed";
2691
+ CharCodes[CharCodes["CarriageReturn"] = 13] = "CarriageReturn";
2692
+ CharCodes[CharCodes["Space"] = 32] = "Space";
2693
+ CharCodes[CharCodes["ExclamationMark"] = 33] = "ExclamationMark";
2694
+ CharCodes[CharCodes["Number"] = 35] = "Number";
2695
+ CharCodes[CharCodes["Amp"] = 38] = "Amp";
2696
+ CharCodes[CharCodes["SingleQuote"] = 39] = "SingleQuote";
2697
+ CharCodes[CharCodes["DoubleQuote"] = 34] = "DoubleQuote";
2698
+ CharCodes[CharCodes["Dash"] = 45] = "Dash";
2699
+ CharCodes[CharCodes["Slash"] = 47] = "Slash";
2700
+ CharCodes[CharCodes["Zero"] = 48] = "Zero";
2701
+ CharCodes[CharCodes["Nine"] = 57] = "Nine";
2702
+ CharCodes[CharCodes["Semi"] = 59] = "Semi";
2703
+ CharCodes[CharCodes["Lt"] = 60] = "Lt";
2704
+ CharCodes[CharCodes["Eq"] = 61] = "Eq";
2705
+ CharCodes[CharCodes["Gt"] = 62] = "Gt";
2706
+ CharCodes[CharCodes["Questionmark"] = 63] = "Questionmark";
2707
+ CharCodes[CharCodes["UpperA"] = 65] = "UpperA";
2708
+ CharCodes[CharCodes["LowerA"] = 97] = "LowerA";
2709
+ CharCodes[CharCodes["UpperF"] = 70] = "UpperF";
2710
+ CharCodes[CharCodes["LowerF"] = 102] = "LowerF";
2711
+ CharCodes[CharCodes["UpperZ"] = 90] = "UpperZ";
2712
+ CharCodes[CharCodes["LowerZ"] = 122] = "LowerZ";
2713
+ CharCodes[CharCodes["LowerX"] = 120] = "LowerX";
2714
+ CharCodes[CharCodes["OpeningSquareBracket"] = 91] = "OpeningSquareBracket";
2715
+ })(CharCodes || (CharCodes = {}));
2716
+ /** All the states the tokenizer can be in. */
2717
+ var State;
2718
+ (function(State) {
2719
+ State[State["Text"] = 1] = "Text";
2720
+ State[State["BeforeTagName"] = 2] = "BeforeTagName";
2721
+ State[State["InTagName"] = 3] = "InTagName";
2722
+ State[State["InSelfClosingTag"] = 4] = "InSelfClosingTag";
2723
+ State[State["BeforeClosingTagName"] = 5] = "BeforeClosingTagName";
2724
+ State[State["InClosingTagName"] = 6] = "InClosingTagName";
2725
+ State[State["AfterClosingTagName"] = 7] = "AfterClosingTagName";
2726
+ State[State["BeforeAttributeName"] = 8] = "BeforeAttributeName";
2727
+ State[State["InAttributeName"] = 9] = "InAttributeName";
2728
+ State[State["AfterAttributeName"] = 10] = "AfterAttributeName";
2729
+ State[State["BeforeAttributeValue"] = 11] = "BeforeAttributeValue";
2730
+ State[State["InAttributeValueDq"] = 12] = "InAttributeValueDq";
2731
+ State[State["InAttributeValueSq"] = 13] = "InAttributeValueSq";
2732
+ State[State["InAttributeValueNq"] = 14] = "InAttributeValueNq";
2733
+ State[State["BeforeDeclaration"] = 15] = "BeforeDeclaration";
2734
+ State[State["InDeclaration"] = 16] = "InDeclaration";
2735
+ State[State["InProcessingInstruction"] = 17] = "InProcessingInstruction";
2736
+ State[State["BeforeComment"] = 18] = "BeforeComment";
2737
+ State[State["CDATASequence"] = 19] = "CDATASequence";
2738
+ State[State["DeclarationSequence"] = 20] = "DeclarationSequence";
2739
+ State[State["InSpecialComment"] = 21] = "InSpecialComment";
2740
+ State[State["InCommentLike"] = 22] = "InCommentLike";
2741
+ State[State["SpecialStartSequence"] = 23] = "SpecialStartSequence";
2742
+ State[State["InSpecialTag"] = 24] = "InSpecialTag";
2743
+ State[State["InPlainText"] = 25] = "InPlainText";
2744
+ State[State["InEntity"] = 26] = "InEntity";
2745
+ })(State || (State = {}));
2746
+ function isWhitespace$1(c) {
2747
+ return c === CharCodes.Space || c === CharCodes.NewLine || c === CharCodes.Tab || c === CharCodes.FormFeed || c === CharCodes.CarriageReturn;
2748
+ }
2749
+ function isEndOfTagSection(c) {
2750
+ return c === CharCodes.Slash || c === CharCodes.Gt || isWhitespace$1(c);
2751
+ }
2752
+ function isASCIIAlpha(c) {
2753
+ return c >= CharCodes.LowerA && c <= CharCodes.LowerZ || c >= CharCodes.UpperA && c <= CharCodes.UpperZ;
2754
+ }
2755
+ /**
2756
+ * Quote style used for parsed attributes.
2757
+ */
2758
+ var QuoteType;
2759
+ (function(QuoteType) {
2760
+ QuoteType[QuoteType["NoValue"] = 0] = "NoValue";
2761
+ QuoteType[QuoteType["Unquoted"] = 1] = "Unquoted";
2762
+ QuoteType[QuoteType["Single"] = 2] = "Single";
2763
+ QuoteType[QuoteType["Double"] = 3] = "Double";
2764
+ })(QuoteType || (QuoteType = {}));
2765
+ /**
2766
+ * Sequences used to match longer strings.
2767
+ *
2768
+ * We don't have `Script`, `Style`, or `Title` here. Instead, we re-use the *End
2769
+ * sequences with an increased offset.
2770
+ */
2771
+ const Sequences = {
2772
+ Empty: new Uint8Array(0),
2773
+ Cdata: new Uint8Array([
2774
+ 67,
2775
+ 68,
2776
+ 65,
2777
+ 84,
2778
+ 65,
2779
+ 91
2780
+ ]),
2781
+ CdataEnd: new Uint8Array([
2782
+ 93,
2783
+ 93,
2784
+ 62
2785
+ ]),
2786
+ CommentEnd: new Uint8Array([
2787
+ 45,
2788
+ 45,
2789
+ 33,
2790
+ 62
2791
+ ]),
2792
+ Doctype: new Uint8Array([
2793
+ 100,
2794
+ 111,
2795
+ 99,
2796
+ 116,
2797
+ 121,
2798
+ 112,
2799
+ 101
2800
+ ]),
2801
+ IframeEnd: new Uint8Array([
2802
+ 60,
2803
+ 47,
2804
+ 105,
2805
+ 102,
2806
+ 114,
2807
+ 97,
2808
+ 109,
2809
+ 101
2810
+ ]),
2811
+ NoembedEnd: new Uint8Array([
2812
+ 60,
2813
+ 47,
2814
+ 110,
2815
+ 111,
2816
+ 101,
2817
+ 109,
2818
+ 98,
2819
+ 101,
2820
+ 100
2821
+ ]),
2822
+ NoframesEnd: new Uint8Array([
2823
+ 60,
2824
+ 47,
2825
+ 110,
2826
+ 111,
2827
+ 102,
2828
+ 114,
2829
+ 97,
2830
+ 109,
2831
+ 101,
2832
+ 115
2833
+ ]),
2834
+ Plaintext: new Uint8Array([
2835
+ 60,
2836
+ 47,
2837
+ 112,
2838
+ 108,
2839
+ 97,
2840
+ 105,
2841
+ 110,
2842
+ 116,
2843
+ 101,
2844
+ 120,
2845
+ 116
2846
+ ]),
2847
+ ScriptEnd: new Uint8Array([
2848
+ 60,
2849
+ 47,
2850
+ 115,
2851
+ 99,
2852
+ 114,
2853
+ 105,
2854
+ 112,
2855
+ 116
2856
+ ]),
2857
+ StyleEnd: new Uint8Array([
2858
+ 60,
2859
+ 47,
2860
+ 115,
2861
+ 116,
2862
+ 121,
2863
+ 108,
2864
+ 101
2865
+ ]),
2866
+ TitleEnd: new Uint8Array([
2867
+ 60,
2868
+ 47,
2869
+ 116,
2870
+ 105,
2871
+ 116,
2872
+ 108,
2873
+ 101
2874
+ ]),
2875
+ TextareaEnd: new Uint8Array([
2876
+ 60,
2877
+ 47,
2878
+ 116,
2879
+ 101,
2880
+ 120,
2881
+ 116,
2882
+ 97,
2883
+ 114,
2884
+ 101,
2885
+ 97
2886
+ ]),
2887
+ XmpEnd: new Uint8Array([
2888
+ 60,
2889
+ 47,
2890
+ 120,
2891
+ 109,
2892
+ 112
2893
+ ])
2894
+ };
2895
+ /**
2896
+ * Maps the first lowercase character of an HTML tag name to the sequence
2897
+ * used for special-tag detection. All sequences share a common layout
2898
+ * where index 2 is the first tag-name character, so matching always
2899
+ * continues from offset 3.
2900
+ */
2901
+ const specialStartSequences = new Map([
2902
+ [Sequences.IframeEnd[2], Sequences.IframeEnd],
2903
+ [Sequences.NoembedEnd[2], Sequences.NoembedEnd],
2904
+ [Sequences.Plaintext[2], Sequences.Plaintext],
2905
+ [Sequences.ScriptEnd[2], Sequences.ScriptEnd],
2906
+ [Sequences.TitleEnd[2], Sequences.TitleEnd],
2907
+ [Sequences.XmpEnd[2], Sequences.XmpEnd]
2908
+ ]);
2909
+ /**
2910
+ * Tokenizer implementation used by `Parser`.
2911
+ */
2912
+ var Tokenizer$1 = class {
2913
+ constructor({ xmlMode = false, decodeEntities = true, recognizeSelfClosing = xmlMode }, cbs) {
2914
+ _defineProperty(this, "cbs", void 0);
2915
+ _defineProperty(
2916
+ this,
2917
+ /** The current state the tokenizer is in. */
2918
+ "state",
2919
+ State.Text
2920
+ );
2921
+ _defineProperty(
2922
+ this,
2923
+ /** The read buffer. */
2924
+ "buffer",
2925
+ ""
2926
+ );
2927
+ _defineProperty(
2928
+ this,
2929
+ /** The beginning of the section that is currently being read. */
2930
+ "sectionStart",
2931
+ 0
2932
+ );
2933
+ _defineProperty(
2934
+ this,
2935
+ /** The index within the buffer that we are currently looking at. */
2936
+ "index",
2937
+ 0
2938
+ );
2939
+ _defineProperty(
2940
+ this,
2941
+ /** The start of the last entity. */
2942
+ "entityStart",
2943
+ 0
2944
+ );
2945
+ _defineProperty(
2946
+ this,
2947
+ /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
2948
+ "baseState",
2949
+ State.Text
2950
+ );
2951
+ _defineProperty(
2952
+ this,
2953
+ /** For special parsing behavior inside of script and style tags. */
2954
+ "isSpecial",
2955
+ false
2956
+ );
2957
+ _defineProperty(
2958
+ this,
2959
+ /** Indicates whether the tokenizer has been paused. */
2960
+ "running",
2961
+ true
2962
+ );
2963
+ _defineProperty(
2964
+ this,
2965
+ /** The offset of the current buffer. */
2966
+ "offset",
2967
+ 0
2968
+ );
2969
+ _defineProperty(this, "xmlMode", void 0);
2970
+ _defineProperty(this, "decodeEntities", void 0);
2971
+ _defineProperty(this, "recognizeSelfClosing", void 0);
2972
+ _defineProperty(this, "entityDecoder", void 0);
2973
+ _defineProperty(this, "currentSequence", Sequences.Empty);
2974
+ _defineProperty(this, "sequenceIndex", 0);
2975
+ this.cbs = cbs;
2976
+ this.xmlMode = xmlMode;
2977
+ this.decodeEntities = decodeEntities;
2978
+ this.recognizeSelfClosing = recognizeSelfClosing;
2979
+ this.entityDecoder = new EntityDecoder(xmlMode ? xmlDecodeTree : htmlDecodeTree, (cp, consumed) => this.emitCodePoint(cp, consumed));
2980
+ }
2981
+ reset() {
2982
+ this.state = State.Text;
2983
+ this.buffer = "";
2984
+ this.sectionStart = 0;
2985
+ this.index = 0;
2986
+ this.baseState = State.Text;
2987
+ this.isSpecial = false;
2988
+ this.currentSequence = Sequences.Empty;
2989
+ this.sequenceIndex = 0;
2990
+ this.running = true;
2991
+ this.offset = 0;
2992
+ }
2993
+ write(chunk) {
2994
+ this.offset += this.buffer.length;
2995
+ this.buffer = chunk;
2996
+ this.parse();
2997
+ }
2998
+ end() {
2999
+ if (this.running) this.finish();
3000
+ }
3001
+ pause() {
3002
+ this.running = false;
3003
+ }
3004
+ resume() {
3005
+ this.running = true;
3006
+ if (this.index < this.buffer.length + this.offset) this.parse();
3007
+ }
3008
+ stateText(c) {
3009
+ if (c === CharCodes.Lt || !this.decodeEntities && this.fastForwardTo(CharCodes.Lt)) {
3010
+ if (this.index > this.sectionStart) this.cbs.ontext(this.sectionStart, this.index);
3011
+ this.state = State.BeforeTagName;
3012
+ this.sectionStart = this.index;
3013
+ } else if (this.decodeEntities && c === CharCodes.Amp) this.startEntity();
3014
+ }
3015
+ enterTagBody() {
3016
+ if (this.currentSequence === Sequences.Plaintext) {
3017
+ this.currentSequence = Sequences.Empty;
3018
+ this.state = State.InPlainText;
3019
+ } else if (this.isSpecial) {
3020
+ this.state = State.InSpecialTag;
3021
+ this.sequenceIndex = 0;
3022
+ } else this.state = State.Text;
3023
+ }
3024
+ /**
3025
+ * Match the opening tag name against an HTML text-only tag sequence.
3026
+ *
3027
+ * Some tags share an initial prefix (`script`/`style`, `title`/`textarea`,
3028
+ * `noembed`/`noframes`), so we may switch to an alternate sequence at the
3029
+ * first distinguishing byte. On a successful full match we fall back to
3030
+ * the normal tag-name state; a later `>` will enter raw-text, RCDATA, or
3031
+ * plaintext mode based on `currentSequence` / `isSpecial`.
3032
+ * @param c Current character code point.
3033
+ */
3034
+ stateSpecialStartSequence(c) {
3035
+ const lower = c | 32;
3036
+ if (this.sequenceIndex < this.currentSequence.length) {
3037
+ if (lower === this.currentSequence[this.sequenceIndex]) {
3038
+ this.sequenceIndex++;
3039
+ return;
3040
+ }
3041
+ if (this.sequenceIndex === 3) {
3042
+ if (this.currentSequence === Sequences.ScriptEnd && lower === Sequences.StyleEnd[3]) {
3043
+ this.currentSequence = Sequences.StyleEnd;
3044
+ this.sequenceIndex = 4;
3045
+ return;
3046
+ }
3047
+ if (this.currentSequence === Sequences.TitleEnd && lower === Sequences.TextareaEnd[3]) {
3048
+ this.currentSequence = Sequences.TextareaEnd;
3049
+ this.sequenceIndex = 4;
3050
+ return;
3051
+ }
3052
+ } else if (this.sequenceIndex === 4 && this.currentSequence === Sequences.NoembedEnd && lower === Sequences.NoframesEnd[4]) {
3053
+ this.currentSequence = Sequences.NoframesEnd;
3054
+ this.sequenceIndex = 5;
3055
+ return;
3056
+ }
3057
+ } else if (isEndOfTagSection(c)) {
3058
+ this.sequenceIndex = 0;
3059
+ this.state = State.InTagName;
3060
+ this.stateInTagName(c);
3061
+ return;
3062
+ }
3063
+ this.isSpecial = false;
3064
+ this.currentSequence = Sequences.Empty;
3065
+ this.sequenceIndex = 0;
3066
+ this.state = State.InTagName;
3067
+ this.stateInTagName(c);
3068
+ }
3069
+ stateCDATASequence(c) {
3070
+ if (c === Sequences.Cdata[this.sequenceIndex]) {
3071
+ if (++this.sequenceIndex === Sequences.Cdata.length) {
3072
+ this.state = State.InCommentLike;
3073
+ this.currentSequence = Sequences.CdataEnd;
3074
+ this.sequenceIndex = 0;
3075
+ this.sectionStart = this.index + 1;
3076
+ }
3077
+ } else {
3078
+ this.sequenceIndex = 0;
3079
+ if (this.xmlMode) {
3080
+ this.state = State.InDeclaration;
3081
+ this.stateInDeclaration(c);
3082
+ } else {
3083
+ this.state = State.InSpecialComment;
3084
+ this.stateInSpecialComment(c);
3085
+ }
3086
+ }
3087
+ }
3088
+ /**
3089
+ * When we wait for one specific character, we can speed things up
3090
+ * by skipping through the buffer until we find it.
3091
+ * @param c Current character code point.
3092
+ * @returns Whether the character was found.
3093
+ */
3094
+ fastForwardTo(c) {
3095
+ while (++this.index < this.buffer.length + this.offset) if (this.buffer.charCodeAt(this.index - this.offset) === c) return true;
3096
+ this.index = this.buffer.length + this.offset - 1;
3097
+ return false;
3098
+ }
3099
+ /**
3100
+ * Emit a comment token and return to the text state.
3101
+ * @param offset Number of characters in the end sequence that have already been matched.
3102
+ */
3103
+ emitComment(offset) {
3104
+ this.cbs.oncomment(this.sectionStart, this.index, offset);
3105
+ this.sequenceIndex = 0;
3106
+ this.sectionStart = this.index + 1;
3107
+ this.state = State.Text;
3108
+ }
3109
+ /**
3110
+ * Comments and CDATA end with `-->` and `]]>`.
3111
+ *
3112
+ * Their common qualities are:
3113
+ * - Their end sequences have a distinct character they start with.
3114
+ * - That character is then repeated, so we have to check multiple repeats.
3115
+ * - All characters but the start character of the sequence can be skipped.
3116
+ * @param c Current character code point.
3117
+ */
3118
+ stateInCommentLike(c) {
3119
+ if (!this.xmlMode && this.currentSequence === Sequences.CommentEnd && this.sequenceIndex <= 1 && this.index === this.sectionStart + this.sequenceIndex && c === CharCodes.Gt) this.emitComment(this.sequenceIndex);
3120
+ else if (this.currentSequence === Sequences.CommentEnd && this.sequenceIndex === 2 && c === CharCodes.Gt) this.emitComment(2);
3121
+ else if (this.currentSequence === Sequences.CommentEnd && this.sequenceIndex === this.currentSequence.length - 1 && c !== CharCodes.Gt) this.sequenceIndex = Number(c === CharCodes.Dash);
3122
+ else if (c === this.currentSequence[this.sequenceIndex]) {
3123
+ if (++this.sequenceIndex === this.currentSequence.length) {
3124
+ if (this.currentSequence === Sequences.CdataEnd) this.cbs.oncdata(this.sectionStart, this.index, 2);
3125
+ else this.cbs.oncomment(this.sectionStart, this.index, 3);
3126
+ this.sequenceIndex = 0;
3127
+ this.sectionStart = this.index + 1;
3128
+ this.state = State.Text;
3129
+ }
3130
+ } else if (this.sequenceIndex === 0) {
3131
+ if (this.fastForwardTo(this.currentSequence[0])) this.sequenceIndex = 1;
3132
+ } else if (c !== this.currentSequence[this.sequenceIndex - 1]) this.sequenceIndex = 0;
3133
+ }
3134
+ /**
3135
+ * HTML only allows ASCII alpha characters (a-z and A-Z) at the beginning of a tag name.
3136
+ *
3137
+ * XML allows a lot more characters here (@see https://www.w3.org/TR/REC-xml/#NT-NameStartChar).
3138
+ * We allow anything that wouldn't end the tag.
3139
+ * @param c Current character code point.
3140
+ */
3141
+ isTagStartChar(c) {
3142
+ return this.xmlMode ? !isEndOfTagSection(c) : isASCIIAlpha(c);
3143
+ }
3144
+ /**
3145
+ * Scan raw-text / RCDATA content for the matching end tag.
3146
+ *
3147
+ * For RCDATA tags (`<title>`, `<textarea>`) entities are decoded inline.
3148
+ * For raw-text tags (`<script>`, `<style>`, etc.) we fast-forward to `<`.
3149
+ * @param c Current character code point.
3150
+ */
3151
+ stateInSpecialTag(c) {
3152
+ if (this.sequenceIndex === this.currentSequence.length) {
3153
+ if (isEndOfTagSection(c)) {
3154
+ const endOfText = this.index - this.currentSequence.length;
3155
+ if (this.sectionStart < endOfText) {
3156
+ const actualIndex = this.index;
3157
+ this.index = endOfText;
3158
+ this.cbs.ontext(this.sectionStart, endOfText);
3159
+ this.index = actualIndex;
3160
+ }
3161
+ this.isSpecial = false;
3162
+ this.sectionStart = endOfText + 2;
3163
+ this.stateInClosingTagName(c);
3164
+ return;
3165
+ }
3166
+ this.sequenceIndex = 0;
3167
+ }
3168
+ if ((c | 32) === this.currentSequence[this.sequenceIndex]) this.sequenceIndex += 1;
3169
+ else if (this.sequenceIndex === 0) {
3170
+ if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd) {
3171
+ if (this.decodeEntities && c === CharCodes.Amp) this.startEntity();
3172
+ } else if (this.fastForwardTo(CharCodes.Lt)) this.sequenceIndex = 1;
3173
+ } else this.sequenceIndex = Number(c === CharCodes.Lt);
3174
+ }
3175
+ stateBeforeTagName(c) {
3176
+ if (c === CharCodes.ExclamationMark) {
3177
+ this.state = State.BeforeDeclaration;
3178
+ this.sectionStart = this.index + 1;
3179
+ } else if (c === CharCodes.Questionmark) if (this.xmlMode) {
3180
+ this.state = State.InProcessingInstruction;
3181
+ this.sequenceIndex = 0;
3182
+ this.sectionStart = this.index + 1;
3183
+ } else {
3184
+ this.state = State.InSpecialComment;
3185
+ this.sectionStart = this.index;
3186
+ }
3187
+ else if (this.isTagStartChar(c)) {
3188
+ this.sectionStart = this.index;
3189
+ const special = this.xmlMode || this.cbs.isInForeignContext?.() ? void 0 : specialStartSequences.get(c | 32);
3190
+ if (special === void 0) this.state = State.InTagName;
3191
+ else {
3192
+ this.isSpecial = true;
3193
+ this.currentSequence = special;
3194
+ this.sequenceIndex = 3;
3195
+ this.state = State.SpecialStartSequence;
3196
+ }
3197
+ } else if (c === CharCodes.Slash) this.state = State.BeforeClosingTagName;
3198
+ else {
3199
+ this.state = State.Text;
3200
+ this.stateText(c);
3201
+ }
3202
+ }
3203
+ stateInTagName(c) {
3204
+ if (isEndOfTagSection(c)) {
3205
+ this.cbs.onopentagname(this.sectionStart, this.index);
3206
+ this.sectionStart = -1;
3207
+ this.state = State.BeforeAttributeName;
3208
+ this.stateBeforeAttributeName(c);
3209
+ }
3210
+ }
3211
+ stateBeforeClosingTagName(c) {
3212
+ if (isWhitespace$1(c)) if (this.xmlMode) {} else {
3213
+ this.state = State.InSpecialComment;
3214
+ this.sectionStart = this.index;
3215
+ }
3216
+ else if (c === CharCodes.Gt) {
3217
+ this.state = State.Text;
3218
+ if (!this.xmlMode) this.sectionStart = this.index + 1;
3219
+ } else {
3220
+ this.state = this.isTagStartChar(c) ? State.InClosingTagName : State.InSpecialComment;
3221
+ this.sectionStart = this.index;
3222
+ }
3223
+ }
3224
+ stateInClosingTagName(c) {
3225
+ if (isEndOfTagSection(c)) {
3226
+ this.cbs.onclosetag(this.sectionStart, this.index);
3227
+ this.sectionStart = -1;
3228
+ this.state = State.AfterClosingTagName;
3229
+ this.stateAfterClosingTagName(c);
3230
+ }
3231
+ }
3232
+ stateAfterClosingTagName(c) {
3233
+ if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {
3234
+ this.state = State.Text;
3235
+ this.sectionStart = this.index + 1;
3236
+ }
3237
+ }
3238
+ stateBeforeAttributeName(c) {
3239
+ if (c === CharCodes.Gt) {
3240
+ this.cbs.onopentagend(this.index);
3241
+ this.enterTagBody();
3242
+ this.sectionStart = this.index + 1;
3243
+ } else if (c === CharCodes.Slash) this.state = State.InSelfClosingTag;
3244
+ else if (!isWhitespace$1(c)) {
3245
+ this.state = State.InAttributeName;
3246
+ this.sectionStart = this.index;
3247
+ }
3248
+ }
3249
+ /**
3250
+ * Handle `/` before `>` in an opening tag.
3251
+ *
3252
+ * In HTML mode, text-only tags ignore the self-closing flag and still enter
3253
+ * their raw-text/RCDATA/plaintext state unless self-closing tags are being
3254
+ * recognized. In XML mode, or for ordinary tags, the tokenizer returns to
3255
+ * regular text parsing after emitting the self-closing callback.
3256
+ * @param c Current character code point.
3257
+ */
3258
+ stateInSelfClosingTag(c) {
3259
+ if (c === CharCodes.Gt) {
3260
+ this.cbs.onselfclosingtag(this.index);
3261
+ this.sectionStart = this.index + 1;
3262
+ if (!this.recognizeSelfClosing) {
3263
+ this.enterTagBody();
3264
+ return;
3265
+ }
3266
+ this.state = State.Text;
3267
+ this.isSpecial = false;
3268
+ this.currentSequence = Sequences.Empty;
3269
+ } else if (!isWhitespace$1(c)) {
3270
+ this.state = State.BeforeAttributeName;
3271
+ this.stateBeforeAttributeName(c);
3272
+ }
3273
+ }
3274
+ stateInAttributeName(c) {
3275
+ if (c === CharCodes.Eq || isEndOfTagSection(c)) {
3276
+ this.cbs.onattribname(this.sectionStart, this.index);
3277
+ this.sectionStart = this.index;
3278
+ this.state = State.AfterAttributeName;
3279
+ this.stateAfterAttributeName(c);
3280
+ }
3281
+ }
3282
+ stateAfterAttributeName(c) {
3283
+ if (c === CharCodes.Eq) this.state = State.BeforeAttributeValue;
3284
+ else if (c === CharCodes.Slash || c === CharCodes.Gt) {
3285
+ this.cbs.onattribend(QuoteType.NoValue, this.sectionStart);
3286
+ this.sectionStart = -1;
3287
+ this.state = State.BeforeAttributeName;
3288
+ this.stateBeforeAttributeName(c);
3289
+ } else if (!isWhitespace$1(c)) {
3290
+ this.cbs.onattribend(QuoteType.NoValue, this.sectionStart);
3291
+ this.state = State.InAttributeName;
3292
+ this.sectionStart = this.index;
3293
+ }
3294
+ }
3295
+ stateBeforeAttributeValue(c) {
3296
+ if (c === CharCodes.DoubleQuote) {
3297
+ this.state = State.InAttributeValueDq;
3298
+ this.sectionStart = this.index + 1;
3299
+ } else if (c === CharCodes.SingleQuote) {
3300
+ this.state = State.InAttributeValueSq;
3301
+ this.sectionStart = this.index + 1;
3302
+ } else if (!isWhitespace$1(c)) {
3303
+ this.sectionStart = this.index;
3304
+ this.state = State.InAttributeValueNq;
3305
+ this.stateInAttributeValueNoQuotes(c);
3306
+ }
3307
+ }
3308
+ handleInAttributeValue(c, quote) {
3309
+ if (c === quote || !this.decodeEntities && this.fastForwardTo(quote)) {
3310
+ this.cbs.onattribdata(this.sectionStart, this.index);
3311
+ this.sectionStart = -1;
3312
+ this.cbs.onattribend(quote === CharCodes.DoubleQuote ? QuoteType.Double : QuoteType.Single, this.index + 1);
3313
+ this.state = State.BeforeAttributeName;
3314
+ } else if (this.decodeEntities && c === CharCodes.Amp) this.startEntity();
3315
+ }
3316
+ stateInAttributeValueDoubleQuotes(c) {
3317
+ this.handleInAttributeValue(c, CharCodes.DoubleQuote);
3318
+ }
3319
+ stateInAttributeValueSingleQuotes(c) {
3320
+ this.handleInAttributeValue(c, CharCodes.SingleQuote);
3321
+ }
3322
+ stateInAttributeValueNoQuotes(c) {
3323
+ if (isWhitespace$1(c) || c === CharCodes.Gt) {
3324
+ this.cbs.onattribdata(this.sectionStart, this.index);
3325
+ this.sectionStart = -1;
3326
+ this.cbs.onattribend(QuoteType.Unquoted, this.index);
3327
+ this.state = State.BeforeAttributeName;
3328
+ this.stateBeforeAttributeName(c);
3329
+ } else if (this.decodeEntities && c === CharCodes.Amp) this.startEntity();
3330
+ }
3331
+ /**
3332
+ * Distinguish between CDATA, declarations, HTML comments, and HTML bogus
3333
+ * comments after `<!`.
3334
+ *
3335
+ * In HTML mode, only real comments and doctypes stay on declaration paths;
3336
+ * everything else becomes a bogus comment terminated by the next `>`.
3337
+ * @param c Current character code point.
3338
+ */
3339
+ stateBeforeDeclaration(c) {
3340
+ if (c === CharCodes.OpeningSquareBracket) {
3341
+ this.state = State.CDATASequence;
3342
+ this.sequenceIndex = 0;
3343
+ } else if (this.xmlMode) this.state = c === CharCodes.Dash ? State.BeforeComment : State.InDeclaration;
3344
+ else if ((c | 32) === Sequences.Doctype[0]) {
3345
+ this.state = State.DeclarationSequence;
3346
+ this.currentSequence = Sequences.Doctype;
3347
+ this.sequenceIndex = 1;
3348
+ } else if (c === CharCodes.Gt) {
3349
+ this.cbs.oncomment(this.sectionStart, this.index, 0);
3350
+ this.state = State.Text;
3351
+ this.sectionStart = this.index + 1;
3352
+ } else if (c === CharCodes.Dash) this.state = State.BeforeComment;
3353
+ else this.state = State.InSpecialComment;
3354
+ }
3355
+ /**
3356
+ * Continue matching `doctype` after `<!d`.
3357
+ *
3358
+ * A full `doctype` match stays on the declaration path; any other name falls
3359
+ * back to an HTML bogus comment, which matches browser behavior for
3360
+ * non-doctype `<!...>` constructs.
3361
+ * @param c Current character code point.
3362
+ */
3363
+ stateDeclarationSequence(c) {
3364
+ if (this.sequenceIndex === this.currentSequence.length) {
3365
+ this.state = State.InDeclaration;
3366
+ this.stateInDeclaration(c);
3367
+ } else if ((c | 32) === this.currentSequence[this.sequenceIndex]) this.sequenceIndex += 1;
3368
+ else if (c === CharCodes.Gt) {
3369
+ this.cbs.oncomment(this.sectionStart, this.index, 0);
3370
+ this.state = State.Text;
3371
+ this.sectionStart = this.index + 1;
3372
+ } else this.state = State.InSpecialComment;
3373
+ }
3374
+ stateInDeclaration(c) {
3375
+ if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {
3376
+ this.cbs.ondeclaration(this.sectionStart, this.index);
3377
+ this.state = State.Text;
3378
+ this.sectionStart = this.index + 1;
3379
+ }
3380
+ }
3381
+ /**
3382
+ * XML processing instructions (`<?...?>`).
3383
+ *
3384
+ * In HTML mode `<?` is routed to `InSpecialComment` instead, so this
3385
+ * state is only reachable in XML mode.
3386
+ * @param c Current character code point.
3387
+ */
3388
+ stateInProcessingInstruction(c) {
3389
+ if (c === CharCodes.Questionmark) this.sequenceIndex = 1;
3390
+ else if (c === CharCodes.Gt && this.sequenceIndex === 1) {
3391
+ this.cbs.onprocessinginstruction(this.sectionStart, this.index - 1);
3392
+ this.sequenceIndex = 0;
3393
+ this.state = State.Text;
3394
+ this.sectionStart = this.index + 1;
3395
+ } else this.sequenceIndex = Number(this.fastForwardTo(CharCodes.Questionmark));
3396
+ }
3397
+ stateBeforeComment(c) {
3398
+ if (c === CharCodes.Dash) {
3399
+ this.state = State.InCommentLike;
3400
+ this.currentSequence = Sequences.CommentEnd;
3401
+ this.sequenceIndex = 0;
3402
+ this.sectionStart = this.index + 1;
3403
+ } else if (this.xmlMode) this.state = State.InDeclaration;
3404
+ else if (c === CharCodes.Gt) {
3405
+ this.cbs.oncomment(this.sectionStart, this.index, 0);
3406
+ this.state = State.Text;
3407
+ this.sectionStart = this.index + 1;
3408
+ } else this.state = State.InSpecialComment;
3409
+ }
3410
+ stateInSpecialComment(c) {
3411
+ if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {
3412
+ this.cbs.oncomment(this.sectionStart, this.index, 0);
3413
+ this.state = State.Text;
3414
+ this.sectionStart = this.index + 1;
3415
+ }
3416
+ }
3417
+ startEntity() {
3418
+ this.baseState = this.state;
3419
+ this.state = State.InEntity;
3420
+ this.entityStart = this.index;
3421
+ this.entityDecoder.startEntity(this.xmlMode ? DecodingMode.Strict : this.baseState === State.Text || this.baseState === State.InSpecialTag ? DecodingMode.Legacy : DecodingMode.Attribute);
3422
+ }
3423
+ stateInEntity() {
3424
+ const indexInBuffer = this.index - this.offset;
3425
+ const length = this.entityDecoder.write(this.buffer, indexInBuffer);
3426
+ if (length >= 0) {
3427
+ this.state = this.baseState;
3428
+ if (length === 0) this.index -= 1;
3429
+ } else {
3430
+ if (indexInBuffer < this.buffer.length && this.buffer.charCodeAt(indexInBuffer) === CharCodes.Amp) {
3431
+ this.state = this.baseState;
3432
+ this.index -= 1;
3433
+ return;
3434
+ }
3435
+ this.index = this.offset + this.buffer.length - 1;
3436
+ }
3437
+ }
3438
+ /**
3439
+ * Remove data that has already been consumed from the buffer.
3440
+ */
3441
+ cleanup() {
3442
+ if (this.running && this.sectionStart !== this.index) {
3443
+ if (this.state === State.Text || this.state === State.InPlainText || this.state === State.InSpecialTag && this.sequenceIndex === 0) {
3444
+ this.cbs.ontext(this.sectionStart, this.index);
3445
+ this.sectionStart = this.index;
3446
+ } else if (this.state === State.InAttributeValueDq || this.state === State.InAttributeValueSq || this.state === State.InAttributeValueNq) {
3447
+ this.cbs.onattribdata(this.sectionStart, this.index);
3448
+ this.sectionStart = this.index;
3449
+ }
3450
+ }
3451
+ }
3452
+ shouldContinue() {
3453
+ return this.index < this.buffer.length + this.offset && this.running;
3454
+ }
3455
+ /**
3456
+ * Iterates through the buffer, calling the function corresponding to the current state.
3457
+ *
3458
+ * States that are more likely to be hit are higher up, as a performance improvement.
3459
+ */
3460
+ parse() {
3461
+ while (this.shouldContinue()) {
3462
+ const c = this.buffer.charCodeAt(this.index - this.offset);
3463
+ switch (this.state) {
3464
+ case State.Text:
3465
+ this.stateText(c);
3466
+ break;
3467
+ case State.InPlainText:
3468
+ this.index = this.buffer.length + this.offset - 1;
3469
+ break;
3470
+ case State.SpecialStartSequence:
3471
+ this.stateSpecialStartSequence(c);
3472
+ break;
3473
+ case State.InSpecialTag:
3474
+ this.stateInSpecialTag(c);
3475
+ break;
3476
+ case State.CDATASequence:
3477
+ this.stateCDATASequence(c);
3478
+ break;
3479
+ case State.DeclarationSequence:
3480
+ this.stateDeclarationSequence(c);
3481
+ break;
3482
+ case State.InAttributeValueDq:
3483
+ this.stateInAttributeValueDoubleQuotes(c);
3484
+ break;
3485
+ case State.InAttributeName:
3486
+ this.stateInAttributeName(c);
3487
+ break;
3488
+ case State.InCommentLike:
3489
+ this.stateInCommentLike(c);
3490
+ break;
3491
+ case State.InSpecialComment:
3492
+ this.stateInSpecialComment(c);
3493
+ break;
3494
+ case State.BeforeAttributeName:
3495
+ this.stateBeforeAttributeName(c);
3496
+ break;
3497
+ case State.InTagName:
3498
+ this.stateInTagName(c);
3499
+ break;
3500
+ case State.InClosingTagName:
3501
+ this.stateInClosingTagName(c);
3502
+ break;
3503
+ case State.BeforeTagName:
3504
+ this.stateBeforeTagName(c);
3505
+ break;
3506
+ case State.AfterAttributeName:
3507
+ this.stateAfterAttributeName(c);
3508
+ break;
3509
+ case State.InAttributeValueSq:
3510
+ this.stateInAttributeValueSingleQuotes(c);
3511
+ break;
3512
+ case State.BeforeAttributeValue:
3513
+ this.stateBeforeAttributeValue(c);
3514
+ break;
3515
+ case State.BeforeClosingTagName:
3516
+ this.stateBeforeClosingTagName(c);
3517
+ break;
3518
+ case State.AfterClosingTagName:
3519
+ this.stateAfterClosingTagName(c);
3520
+ break;
3521
+ case State.InAttributeValueNq:
3522
+ this.stateInAttributeValueNoQuotes(c);
3523
+ break;
3524
+ case State.InSelfClosingTag:
3525
+ this.stateInSelfClosingTag(c);
3526
+ break;
3527
+ case State.InDeclaration:
3528
+ this.stateInDeclaration(c);
3529
+ break;
3530
+ case State.BeforeDeclaration:
3531
+ this.stateBeforeDeclaration(c);
3532
+ break;
3533
+ case State.BeforeComment:
3534
+ this.stateBeforeComment(c);
3535
+ break;
3536
+ case State.InProcessingInstruction:
3537
+ this.stateInProcessingInstruction(c);
3538
+ break;
3539
+ case State.InEntity:
3540
+ this.stateInEntity();
3541
+ break;
3542
+ }
3543
+ this.index++;
3544
+ }
3545
+ this.cleanup();
3546
+ }
3547
+ finish() {
3548
+ if (this.state === State.InEntity) {
3549
+ this.entityDecoder.end();
3550
+ this.state = this.baseState;
3551
+ }
3552
+ this.handleTrailingData();
3553
+ this.cbs.onend();
3554
+ }
3555
+ handleTrailingCommentLikeData(endIndex) {
3556
+ if (this.state !== State.InCommentLike) return false;
3557
+ if (this.currentSequence === Sequences.CdataEnd) if (this.xmlMode) {
3558
+ if (this.sectionStart < endIndex) this.cbs.oncdata(this.sectionStart, endIndex, 0);
3559
+ } else {
3560
+ const cdataStart = this.sectionStart - Sequences.Cdata.length - 1;
3561
+ this.cbs.oncomment(cdataStart, endIndex, 0);
3562
+ }
3563
+ else {
3564
+ const offset = this.xmlMode ? 0 : Math.min(this.sequenceIndex, Sequences.CommentEnd.length - 1);
3565
+ this.cbs.oncomment(this.sectionStart, endIndex, offset);
3566
+ }
3567
+ return true;
3568
+ }
3569
+ handleTrailingMarkupDeclaration(endIndex) {
3570
+ if (this.xmlMode) switch (this.state) {
3571
+ case State.InSpecialComment:
3572
+ case State.BeforeComment:
3573
+ case State.CDATASequence:
3574
+ case State.DeclarationSequence:
3575
+ case State.InDeclaration:
3576
+ this.cbs.ontext(this.sectionStart, endIndex);
3577
+ return true;
3578
+ default: return false;
3579
+ }
3580
+ switch (this.state) {
3581
+ case State.BeforeDeclaration:
3582
+ case State.InSpecialComment:
3583
+ case State.BeforeComment:
3584
+ case State.CDATASequence:
3585
+ this.cbs.oncomment(this.sectionStart, endIndex, 0);
3586
+ return true;
3587
+ case State.DeclarationSequence:
3588
+ if (this.sequenceIndex !== Sequences.Doctype.length) this.cbs.oncomment(this.sectionStart, endIndex, 0);
3589
+ return true;
3590
+ case State.InDeclaration: return true;
3591
+ default: return false;
3592
+ }
3593
+ }
3594
+ /** Handle any trailing data. */
3595
+ handleTrailingData() {
3596
+ const endIndex = this.buffer.length + this.offset;
3597
+ if (this.handleTrailingCommentLikeData(endIndex) || this.handleTrailingMarkupDeclaration(endIndex)) return;
3598
+ if (this.sectionStart >= endIndex) return;
3599
+ switch (this.state) {
3600
+ case State.InTagName:
3601
+ case State.BeforeAttributeName:
3602
+ case State.BeforeAttributeValue:
3603
+ case State.AfterAttributeName:
3604
+ case State.InAttributeName:
3605
+ case State.InAttributeValueSq:
3606
+ case State.InAttributeValueDq:
3607
+ case State.InAttributeValueNq:
3608
+ case State.InClosingTagName: break;
3609
+ default: this.cbs.ontext(this.sectionStart, endIndex);
3610
+ }
3611
+ }
3612
+ emitCodePoint(cp, consumed) {
3613
+ if (this.baseState !== State.Text && this.baseState !== State.InSpecialTag) {
3614
+ if (this.sectionStart < this.entityStart) this.cbs.onattribdata(this.sectionStart, this.entityStart);
3615
+ this.sectionStart = this.entityStart + consumed;
3616
+ this.index = this.sectionStart - 1;
3617
+ this.cbs.onattribentity(cp);
3618
+ } else {
3619
+ if (this.sectionStart < this.entityStart) this.cbs.ontext(this.sectionStart, this.entityStart);
3620
+ this.sectionStart = this.entityStart + consumed;
3621
+ this.index = this.sectionStart - 1;
3622
+ this.cbs.ontextentity(cp, this.sectionStart);
3623
+ }
3624
+ }
3625
+ };
3626
+ //#endregion
3627
+ //#region ../../node_modules/.pnpm/htmlparser2@12.0.0/node_modules/htmlparser2/dist/Parser.js
3628
+ const { fromCodePoint } = String;
3629
+ const formTags = new Set([
3630
+ "input",
3631
+ "option",
3632
+ "optgroup",
3633
+ "select",
3634
+ "button",
3635
+ "datalist",
3636
+ "textarea"
3637
+ ]);
3638
+ const pTag = new Set(["p"]);
3639
+ const headingTags = new Set([
3640
+ "h1",
3641
+ "h2",
3642
+ "h3",
3643
+ "h4",
3644
+ "h5",
3645
+ "h6",
3646
+ "p"
3647
+ ]);
3648
+ const tableSectionTags = new Set(["thead", "tbody"]);
3649
+ const ddtTags = new Set(["dd", "dt"]);
3650
+ const rtpTags = new Set(["rt", "rp"]);
3651
+ const openImpliesClose = new Map([
3652
+ ["tr", new Set([
3653
+ "tr",
3654
+ "th",
3655
+ "td"
3656
+ ])],
3657
+ ["th", new Set(["th"])],
3658
+ ["td", new Set([
3659
+ "thead",
3660
+ "th",
3661
+ "td"
3662
+ ])],
3663
+ ["body", new Set([
3664
+ "head",
3665
+ "link",
3666
+ "script"
3667
+ ])],
3668
+ ["a", new Set(["a"])],
3669
+ ["li", new Set(["li"])],
3670
+ ["p", pTag],
3671
+ ["h1", headingTags],
3672
+ ["h2", headingTags],
3673
+ ["h3", headingTags],
3674
+ ["h4", headingTags],
3675
+ ["h5", headingTags],
3676
+ ["h6", headingTags],
3677
+ ["select", formTags],
3678
+ ["input", formTags],
3679
+ ["output", formTags],
3680
+ ["button", formTags],
3681
+ ["datalist", formTags],
3682
+ ["textarea", formTags],
3683
+ ["option", new Set(["option"])],
3684
+ ["optgroup", new Set(["optgroup", "option"])],
3685
+ ["dd", ddtTags],
3686
+ ["dt", ddtTags],
3687
+ ["address", pTag],
3688
+ ["article", pTag],
3689
+ ["aside", pTag],
3690
+ ["blockquote", pTag],
3691
+ ["details", pTag],
3692
+ ["div", pTag],
3693
+ ["dl", pTag],
3694
+ ["fieldset", pTag],
3695
+ ["figcaption", pTag],
3696
+ ["figure", pTag],
3697
+ ["footer", pTag],
3698
+ ["form", pTag],
3699
+ ["header", pTag],
3700
+ ["hr", pTag],
3701
+ ["main", pTag],
3702
+ ["nav", pTag],
3703
+ ["ol", pTag],
3704
+ ["pre", pTag],
3705
+ ["section", pTag],
3706
+ ["table", pTag],
3707
+ ["ul", pTag],
3708
+ ["rt", rtpTags],
3709
+ ["rp", rtpTags],
3710
+ ["tbody", tableSectionTags],
3711
+ ["tfoot", tableSectionTags]
3712
+ ]);
3713
+ const DOCUMENT_TYPE = "doctype";
3714
+ const voidElements = new Set([
3715
+ "area",
3716
+ "base",
3717
+ "basefont",
3718
+ "br",
3719
+ "col",
3720
+ "command",
3721
+ "embed",
3722
+ "frame",
3723
+ "hr",
3724
+ "img",
3725
+ "input",
3726
+ "isindex",
3727
+ "keygen",
3728
+ "link",
3729
+ "meta",
3730
+ "param",
3731
+ "source",
3732
+ "track",
3733
+ "wbr"
3734
+ ]);
3735
+ const foreignContextElements = new Set(["math", "svg"]);
3736
+ /**
3737
+ * Elements that can be used to integrate HTML content within foreign namespaces (e.g., SVG or MathML).
3738
+ *
3739
+ * Entries must use the SVG-adjusted casing (e.g. "foreignObject" not
3740
+ * "foreignobject") since they are compared against adjusted tag names.
3741
+ */
3742
+ const htmlIntegrationElements = new Set([
3743
+ "mi",
3744
+ "mo",
3745
+ "mn",
3746
+ "ms",
3747
+ "mtext",
3748
+ "annotation-xml",
3749
+ "foreignObject",
3750
+ "desc",
3751
+ "title"
3752
+ ]);
3753
+ const svgTagNameAdjustments = new Map([
3754
+ ["altglyph", "altGlyph"],
3755
+ ["altglyphdef", "altGlyphDef"],
3756
+ ["altglyphitem", "altGlyphItem"],
3757
+ ["animatecolor", "animateColor"],
3758
+ ["animatemotion", "animateMotion"],
3759
+ ["animatetransform", "animateTransform"],
3760
+ ["clippath", "clipPath"],
3761
+ ["feblend", "feBlend"],
3762
+ ["fecolormatrix", "feColorMatrix"],
3763
+ ["fecomponenttransfer", "feComponentTransfer"],
3764
+ ["fecomposite", "feComposite"],
3765
+ ["feconvolvematrix", "feConvolveMatrix"],
3766
+ ["fediffuselighting", "feDiffuseLighting"],
3767
+ ["fedisplacementmap", "feDisplacementMap"],
3768
+ ["fedistantlight", "feDistantLight"],
3769
+ ["fedropshadow", "feDropShadow"],
3770
+ ["feflood", "feFlood"],
3771
+ ["fefunca", "feFuncA"],
3772
+ ["fefuncb", "feFuncB"],
3773
+ ["fefuncg", "feFuncG"],
3774
+ ["fefuncr", "feFuncR"],
3775
+ ["fegaussianblur", "feGaussianBlur"],
3776
+ ["feimage", "feImage"],
3777
+ ["femerge", "feMerge"],
3778
+ ["femergenode", "feMergeNode"],
3779
+ ["femorphology", "feMorphology"],
3780
+ ["feoffset", "feOffset"],
3781
+ ["fepointlight", "fePointLight"],
3782
+ ["fespecularlighting", "feSpecularLighting"],
3783
+ ["fespotlight", "feSpotLight"],
3784
+ ["fetile", "feTile"],
3785
+ ["feturbulence", "feTurbulence"],
3786
+ ["foreignobject", "foreignObject"],
3787
+ ["glyphref", "glyphRef"],
3788
+ ["lineargradient", "linearGradient"],
3789
+ ["radialgradient", "radialGradient"],
3790
+ ["textpath", "textPath"]
3791
+ ]);
3792
+ var ForeignContext;
3793
+ (function(ForeignContext) {
3794
+ ForeignContext[ForeignContext["None"] = 0] = "None";
3795
+ ForeignContext[ForeignContext["Svg"] = 1] = "Svg";
3796
+ ForeignContext[ForeignContext["MathML"] = 2] = "MathML";
3797
+ })(ForeignContext || (ForeignContext = {}));
3798
+ const reNameEnd = /\s|\//;
3799
+ /**
3800
+ * Incremental parser implementation.
3801
+ */
3802
+ var Parser = class {
3803
+ constructor(cbs, options = {}) {
3804
+ _defineProperty(this, "options", void 0);
3805
+ _defineProperty(
3806
+ this,
3807
+ /** The start index of the last event. */
3808
+ "startIndex",
3809
+ 0
3810
+ );
3811
+ _defineProperty(
3812
+ this,
3813
+ /** The end index of the last event. */
3814
+ "endIndex",
3815
+ 0
3816
+ );
3817
+ _defineProperty(
3818
+ this,
3819
+ /**
3820
+ * Store the start index of the current open tag,
3821
+ * so we can update the start index for attributes.
3822
+ */
3823
+ "openTagStart",
3824
+ 0
3825
+ );
3826
+ _defineProperty(this, "tagname", "");
3827
+ _defineProperty(this, "attribname", "");
3828
+ _defineProperty(this, "attribvalue", "");
3829
+ _defineProperty(this, "attribs", null);
3830
+ _defineProperty(this, "stack", []);
3831
+ _defineProperty(this, "foreignContext", void 0);
3832
+ _defineProperty(this, "cbs", void 0);
3833
+ _defineProperty(this, "lowerCaseTagNames", void 0);
3834
+ _defineProperty(this, "lowerCaseAttributeNames", void 0);
3835
+ _defineProperty(this, "recognizeSelfClosing", void 0);
3836
+ _defineProperty(
3837
+ this,
3838
+ /** We are parsing HTML. Inverse of the `xmlMode` option. */
3839
+ "htmlMode",
3840
+ void 0
3841
+ );
3842
+ _defineProperty(this, "tokenizer", void 0);
3843
+ _defineProperty(this, "buffers", []);
3844
+ _defineProperty(this, "bufferOffset", 0);
3845
+ _defineProperty(
3846
+ this,
3847
+ /** The index of the last written buffer. Used when resuming after a `pause()`. */
3848
+ "writeIndex",
3849
+ 0
3850
+ );
3851
+ _defineProperty(
3852
+ this,
3853
+ /** Indicates whether the parser has finished running / `.end` has been called. */
3854
+ "ended",
3855
+ false
3856
+ );
3857
+ this.options = options;
3858
+ this.cbs = cbs ?? {};
3859
+ this.htmlMode = !this.options.xmlMode;
3860
+ this.lowerCaseTagNames = options.lowerCaseTags ?? this.htmlMode;
3861
+ this.lowerCaseAttributeNames = options.lowerCaseAttributeNames ?? this.htmlMode;
3862
+ this.recognizeSelfClosing = options.recognizeSelfClosing ?? !this.htmlMode;
3863
+ this.tokenizer = new (options.Tokenizer ?? Tokenizer$1)(this.options, this);
3864
+ this.foreignContext = [ForeignContext.None];
3865
+ this.cbs.onparserinit?.(this);
3866
+ }
3867
+ /**
3868
+ * @param start Start index for the current parser event.
3869
+ * @param endIndex End index for the current parser event.
3870
+ * @internal
3871
+ */
3872
+ ontext(start, endIndex) {
3873
+ const data = this.getSlice(start, endIndex);
3874
+ this.endIndex = endIndex - 1;
3875
+ this.cbs.ontext?.(data);
3876
+ this.startIndex = endIndex;
3877
+ }
3878
+ /**
3879
+ * @param cp Current Unicode code point.
3880
+ * @param endIndex End index for the current parser event.
3881
+ * @internal
3882
+ */
3883
+ ontextentity(cp, endIndex) {
3884
+ this.endIndex = endIndex - 1;
3885
+ this.cbs.ontext?.(fromCodePoint(cp));
3886
+ this.startIndex = endIndex;
3887
+ }
3888
+ /** @internal */
3889
+ isInForeignContext() {
3890
+ return this.foreignContext[0] !== ForeignContext.None;
3891
+ }
3892
+ /**
3893
+ * Checks if the current tag is a void element. Override this if you want
3894
+ * to specify your own additional void elements.
3895
+ * @param name Name of the pseudo selector.
3896
+ */
3897
+ isVoidElement(name) {
3898
+ return this.htmlMode && voidElements.has(name);
3899
+ }
3900
+ /**
3901
+ * Read a tag name from the buffer.
3902
+ *
3903
+ * When `lowerCaseTagNames` is enabled (the default in HTML mode), the name
3904
+ * is lowercased and may be adjusted for SVG casing or the `image` → `img`
3905
+ * alias.
3906
+ * @param start Start index of the tag name in the buffer.
3907
+ * @param endIndex End index of the tag name in the buffer.
3908
+ */
3909
+ readTagName(start, endIndex) {
3910
+ const name = this.lowerCaseTagNames ? this.getSlice(start, endIndex).toLowerCase() : this.getSlice(start, endIndex);
3911
+ if (!(this.lowerCaseTagNames && this.htmlMode)) return name;
3912
+ if (this.foreignContext[0] === ForeignContext.Svg) return svgTagNameAdjustments.get(name) ?? name;
3913
+ if (this.foreignContext.length > 1) {
3914
+ const adjusted = svgTagNameAdjustments.get(name);
3915
+ if (adjusted !== void 0 && this.stack.includes(adjusted)) return adjusted;
3916
+ }
3917
+ if (!this.isInForeignContext()) return name === "image" ? "img" : name;
3918
+ return name;
3919
+ }
3920
+ /**
3921
+ * @param start Start index for the current parser event.
3922
+ * @param endIndex End index for the current parser event.
3923
+ * @internal
3924
+ */
3925
+ onopentagname(start, endIndex) {
3926
+ this.endIndex = endIndex;
3927
+ this.emitOpenTag(this.readTagName(start, endIndex));
3928
+ }
3929
+ emitOpenTag(name) {
3930
+ this.openTagStart = this.startIndex;
3931
+ this.tagname = name;
3932
+ if (this.htmlMode && name === "form" && this.stack.includes("form")) {
3933
+ this.tagname = "";
3934
+ return;
3935
+ }
3936
+ const impliesClose = this.htmlMode && openImpliesClose.get(name);
3937
+ if (impliesClose) while (this.stack.length > 0 && impliesClose.has(this.stack[0])) this.popElement(true);
3938
+ if (!this.isVoidElement(name)) {
3939
+ this.stack.unshift(name);
3940
+ if (this.htmlMode) {
3941
+ if (name === "svg") this.foreignContext.unshift(ForeignContext.Svg);
3942
+ else if (name === "math") this.foreignContext.unshift(ForeignContext.MathML);
3943
+ else if (htmlIntegrationElements.has(name)) this.foreignContext.unshift(ForeignContext.None);
3944
+ }
3945
+ }
3946
+ this.cbs.onopentagname?.(name);
3947
+ if (this.cbs.onopentag) this.attribs = {};
3948
+ }
3949
+ endOpenTag(isImplied) {
3950
+ this.startIndex = this.openTagStart;
3951
+ if (this.attribs) {
3952
+ this.cbs.onopentag?.(this.tagname, this.attribs, isImplied);
3953
+ this.attribs = null;
3954
+ }
3955
+ if (this.cbs.onclosetag && this.isVoidElement(this.tagname)) this.cbs.onclosetag(this.tagname, true);
3956
+ this.tagname = "";
3957
+ }
3958
+ /**
3959
+ * @param endIndex End index for the current parser event.
3960
+ * @internal
3961
+ */
3962
+ onopentagend(endIndex) {
3963
+ this.endIndex = endIndex;
3964
+ this.endOpenTag(false);
3965
+ this.startIndex = endIndex + 1;
3966
+ }
3967
+ /**
3968
+ * @param start Start index for the current parser event.
3969
+ * @param endIndex End index for the current parser event.
3970
+ * @internal
3971
+ */
3972
+ onclosetag(start, endIndex) {
3973
+ this.endIndex = endIndex;
3974
+ const name = this.readTagName(start, endIndex);
3975
+ if (!this.isVoidElement(name)) {
3976
+ const pos = this.stack.indexOf(name);
3977
+ if (pos !== -1) {
3978
+ for (let index = 0; index < pos; index++) this.popElement(true);
3979
+ this.popElement(false);
3980
+ } else if (this.htmlMode && name === "p") {
3981
+ this.emitOpenTag("p");
3982
+ this.closeCurrentTag(true);
3983
+ }
3984
+ } else if (this.htmlMode && name === "br") {
3985
+ this.cbs.onopentagname?.("br");
3986
+ this.cbs.onopentag?.("br", {}, true);
3987
+ this.cbs.onclosetag?.("br", false);
3988
+ }
3989
+ this.startIndex = endIndex + 1;
3990
+ }
3991
+ /**
3992
+ * @param endIndex End index for the current parser event.
3993
+ * @internal
3994
+ */
3995
+ onselfclosingtag(endIndex) {
3996
+ this.endIndex = endIndex;
3997
+ if (this.recognizeSelfClosing || this.isInForeignContext()) {
3998
+ this.closeCurrentTag(false);
3999
+ this.startIndex = endIndex + 1;
4000
+ } else this.onopentagend(endIndex);
4001
+ }
4002
+ /**
4003
+ * Pop the top element off the stack, emit a close event, and maintain
4004
+ * the foreign context stack.
4005
+ * @param implied Whether this close is implied (not from an explicit end tag).
4006
+ */
4007
+ popElement(implied) {
4008
+ const element = this.stack.shift();
4009
+ if (this.htmlMode && (foreignContextElements.has(element) || htmlIntegrationElements.has(element))) this.foreignContext.shift();
4010
+ this.cbs.onclosetag?.(element, implied);
4011
+ }
4012
+ closeCurrentTag(isOpenImplied) {
4013
+ const name = this.tagname;
4014
+ this.endOpenTag(isOpenImplied);
4015
+ if (this.stack[0] === name) this.popElement(!isOpenImplied);
4016
+ }
4017
+ /**
4018
+ * @param start Start index for the current parser event.
4019
+ * @param endIndex End index for the current parser event.
4020
+ * @internal
4021
+ */
4022
+ onattribname(start, endIndex) {
4023
+ this.startIndex = start;
4024
+ const name = this.getSlice(start, endIndex);
4025
+ this.attribname = this.lowerCaseAttributeNames ? name.toLowerCase() : name;
4026
+ }
4027
+ /**
4028
+ * @param start Start index for the current parser event.
4029
+ * @param endIndex End index for the current parser event.
4030
+ * @internal
4031
+ */
4032
+ onattribdata(start, endIndex) {
4033
+ this.attribvalue += this.getSlice(start, endIndex);
4034
+ }
4035
+ /**
4036
+ * @param cp Current Unicode code point.
4037
+ * @internal
4038
+ */
4039
+ onattribentity(cp) {
4040
+ this.attribvalue += fromCodePoint(cp);
4041
+ }
4042
+ /**
4043
+ * @param quote Quote type used for the current attribute.
4044
+ * @param endIndex End index for the current parser event.
4045
+ * @internal
4046
+ */
4047
+ onattribend(quote, endIndex) {
4048
+ this.endIndex = endIndex;
4049
+ this.cbs.onattribute?.(this.attribname, this.attribvalue, quote === QuoteType.Double ? "\"" : quote === QuoteType.Single ? "'" : quote === QuoteType.NoValue ? void 0 : null);
4050
+ if (this.attribs && !Object.hasOwn(this.attribs, this.attribname)) this.attribs[this.attribname] = this.attribvalue;
4051
+ this.attribvalue = "";
4052
+ }
4053
+ getInstructionName(value) {
4054
+ const index = value.search(reNameEnd);
4055
+ let name = index < 0 ? value : value.substr(0, index);
4056
+ if (this.lowerCaseTagNames) name = name.toLowerCase();
4057
+ return name;
4058
+ }
4059
+ /**
4060
+ * @param start Start index for the current parser event.
4061
+ * @param endIndex End index for the current parser event.
4062
+ * @internal
4063
+ */
4064
+ ondeclaration(start, endIndex) {
4065
+ this.endIndex = endIndex;
4066
+ const value = this.getSlice(start, endIndex);
4067
+ if (this.cbs.onprocessinginstruction) {
4068
+ const name = this.htmlMode ? this.lowerCaseTagNames ? DOCUMENT_TYPE : value.slice(0, 7) : this.getInstructionName(value);
4069
+ this.cbs.onprocessinginstruction(`!${name}`, `!${value}`);
4070
+ }
4071
+ this.startIndex = endIndex + 1;
4072
+ }
4073
+ /**
4074
+ * @param start Start index for the current parser event.
4075
+ * @param endIndex End index for the current parser event.
4076
+ * @internal
4077
+ */
4078
+ onprocessinginstruction(start, endIndex) {
4079
+ this.endIndex = endIndex;
4080
+ const value = this.getSlice(start, endIndex);
4081
+ if (this.cbs.onprocessinginstruction) {
4082
+ const name = this.getInstructionName(value);
4083
+ this.cbs.onprocessinginstruction(`?${name}`, `?${value}`);
4084
+ }
4085
+ this.startIndex = endIndex + 1;
4086
+ }
4087
+ /**
4088
+ * @param start Start index for the current parser event.
4089
+ * @param endIndex End index for the current parser event.
4090
+ * @param offset Offset applied when computing parser indices.
4091
+ * @internal
4092
+ */
4093
+ oncomment(start, endIndex, offset) {
4094
+ this.endIndex = endIndex;
4095
+ this.cbs.oncomment?.(this.getSlice(start, endIndex - offset));
4096
+ this.cbs.oncommentend?.();
4097
+ this.startIndex = endIndex + 1;
4098
+ }
4099
+ /**
4100
+ * @param start Start index for the current parser event.
4101
+ * @param endIndex End index for the current parser event.
4102
+ * @param offset Offset applied when computing parser indices.
4103
+ * @internal
4104
+ */
4105
+ oncdata(start, endIndex, offset) {
4106
+ this.endIndex = endIndex;
4107
+ const value = this.getSlice(start, endIndex - offset);
4108
+ if (!this.htmlMode || this.options.recognizeCDATA) {
4109
+ this.cbs.oncdatastart?.();
4110
+ this.cbs.ontext?.(value);
4111
+ this.cbs.oncdataend?.();
4112
+ } else if (this.isInForeignContext()) this.cbs.ontext?.(value);
4113
+ else {
4114
+ this.cbs.oncomment?.(`[CDATA[${value}]]`);
4115
+ this.cbs.oncommentend?.();
4116
+ }
4117
+ this.startIndex = endIndex + 1;
4118
+ }
4119
+ /** @internal */
4120
+ onend() {
4121
+ if (this.cbs.onclosetag) {
4122
+ this.endIndex = this.startIndex;
4123
+ for (let index = 0; index < this.stack.length; index++) this.cbs.onclosetag(this.stack[index], true);
4124
+ }
4125
+ this.cbs.onend?.();
4126
+ }
4127
+ /**
4128
+ * Resets the parser to a blank state, ready to parse a new HTML document
4129
+ */
4130
+ reset() {
4131
+ this.cbs.onreset?.();
4132
+ this.tokenizer.reset();
4133
+ this.tagname = "";
4134
+ this.attribname = "";
4135
+ this.attribvalue = "";
4136
+ this.attribs = null;
4137
+ this.stack.length = 0;
4138
+ this.startIndex = 0;
4139
+ this.endIndex = 0;
4140
+ this.cbs.onparserinit?.(this);
4141
+ this.buffers.length = 0;
4142
+ this.foreignContext.length = 0;
4143
+ this.foreignContext.unshift(ForeignContext.None);
4144
+ this.bufferOffset = 0;
4145
+ this.writeIndex = 0;
4146
+ this.ended = false;
4147
+ }
4148
+ /**
4149
+ * Resets the parser, then parses a complete document and
4150
+ * pushes it to the handler.
4151
+ * @param data Document to parse.
4152
+ */
4153
+ parseComplete(data) {
4154
+ this.reset();
4155
+ this.end(data);
4156
+ }
4157
+ getSlice(start, end) {
4158
+ if (start === end) return "";
4159
+ while (start - this.bufferOffset >= this.buffers[0].length) this.shiftBuffer();
4160
+ let slice = this.buffers[0].slice(start - this.bufferOffset, end - this.bufferOffset);
4161
+ while (end - this.bufferOffset > this.buffers[0].length) {
4162
+ this.shiftBuffer();
4163
+ slice += this.buffers[0].slice(0, end - this.bufferOffset);
4164
+ }
4165
+ return slice;
4166
+ }
4167
+ shiftBuffer() {
4168
+ this.bufferOffset += this.buffers[0].length;
4169
+ this.writeIndex--;
4170
+ this.buffers.shift();
4171
+ }
4172
+ /**
4173
+ * Parses a chunk of data and calls the corresponding callbacks.
4174
+ * @param chunk Chunk to parse.
4175
+ */
4176
+ write(chunk) {
4177
+ if (this.ended) {
4178
+ this.cbs.onerror?.(/* @__PURE__ */ new Error(".write() after done!"));
4179
+ return;
4180
+ }
4181
+ this.buffers.push(chunk);
4182
+ if (this.tokenizer.running) {
4183
+ this.tokenizer.write(chunk);
4184
+ this.writeIndex++;
4185
+ }
4186
+ }
4187
+ /**
4188
+ * Parses the end of the buffer and clears the stack, calls onend.
4189
+ * @param chunk Optional final chunk to parse.
4190
+ */
4191
+ end(chunk) {
4192
+ if (this.ended) {
4193
+ this.cbs.onerror?.(/* @__PURE__ */ new Error(".end() after done!"));
4194
+ return;
4195
+ }
4196
+ if (chunk) this.write(chunk);
4197
+ this.ended = true;
4198
+ this.tokenizer.end();
4199
+ }
4200
+ /**
4201
+ * Pauses parsing. The parser won't emit events until `resume` is called.
4202
+ */
4203
+ pause() {
4204
+ this.tokenizer.pause();
4205
+ }
4206
+ /**
4207
+ * Resumes parsing after `pause` was called.
4208
+ */
4209
+ resume() {
4210
+ this.tokenizer.resume();
4211
+ while (this.tokenizer.running && this.writeIndex < this.buffers.length) this.tokenizer.write(this.buffers[this.writeIndex++]);
4212
+ if (this.ended) this.tokenizer.end();
4213
+ }
4214
+ };
4215
+ //#endregion
4216
+ //#region src/wxml/whitespace.ts
4217
+ const WHITESPACE_CODES = new Set([
4218
+ 9,
4219
+ 10,
4220
+ 11,
4221
+ 12,
4222
+ 13,
4223
+ 32,
4224
+ 160,
4225
+ 65279
4226
+ ]);
4227
+ function isWhitespace(char) {
4228
+ if (char.length === 0) return false;
4229
+ return WHITESPACE_CODES.has(char.charCodeAt(0));
4230
+ }
4231
+ function isAllWhitespace(value) {
4232
+ for (let i = 0; i < value.length; i++) if (!WHITESPACE_CODES.has(value.charCodeAt(i))) return false;
4233
+ return true;
4234
+ }
4235
+ //#endregion
4236
+ //#region src/wxml/Tokenizer.ts
4237
+ var Tokenizer = class {
4238
+ constructor() {
4239
+ _defineProperty(this, "state", void 0);
4240
+ _defineProperty(this, "buffer", void 0);
4241
+ _defineProperty(this, "tokens", void 0);
4242
+ _defineProperty(this, "bufferStartIndex", void 0);
4243
+ _defineProperty(this, "expressionStartIndex", void 0);
4244
+ _defineProperty(this, "expressionBuffer", void 0);
4245
+ _defineProperty(this, "expressions", void 0);
4246
+ this.reset();
4247
+ }
4248
+ processChar(char, index) {
4249
+ switch (this.state) {
4250
+ case 0:
4251
+ if (isWhitespace(char)) {} else if (char === "{") {
4252
+ this.state = 2;
4253
+ this.bufferStartIndex = index;
4254
+ this.buffer += char;
4255
+ this.expressionBuffer = char;
4256
+ this.expressionStartIndex = index;
4257
+ } else {
4258
+ this.state = 1;
4259
+ this.bufferStartIndex = index;
4260
+ this.buffer += char;
4261
+ }
4262
+ break;
4263
+ case 1:
4264
+ if (isWhitespace(char)) {
4265
+ this.tokens.push({
4266
+ start: this.bufferStartIndex,
4267
+ end: index,
4268
+ value: this.buffer,
4269
+ expressions: this.expressions
4270
+ });
4271
+ this.buffer = "";
4272
+ this.expressions = [];
4273
+ this.state = 0;
4274
+ } else if (char === "{") {
4275
+ this.buffer += char;
4276
+ this.expressionBuffer = char;
4277
+ this.expressionStartIndex = index;
4278
+ this.state = 2;
4279
+ } else this.buffer += char;
4280
+ break;
4281
+ case 2:
4282
+ if (char === "}") {
4283
+ this.buffer += char;
4284
+ this.expressionBuffer += char;
4285
+ this.state = 3;
4286
+ } else {
4287
+ this.buffer += char;
4288
+ this.expressionBuffer += char;
4289
+ }
4290
+ break;
4291
+ case 3:
4292
+ if (char === "}") {
4293
+ this.buffer += char;
4294
+ this.expressionBuffer += char;
4295
+ this.expressions.push({
4296
+ start: this.expressionStartIndex,
4297
+ end: index + 1,
4298
+ value: this.expressionBuffer
4299
+ });
4300
+ this.expressionBuffer = "";
4301
+ this.state = 4;
4302
+ } else {
4303
+ this.buffer += char;
4304
+ this.expressionBuffer += char;
4305
+ this.state = 2;
4306
+ }
4307
+ break;
4308
+ case 4:
4309
+ if (isWhitespace(char)) {
4310
+ this.tokens.push({
4311
+ start: this.bufferStartIndex,
4312
+ end: index,
4313
+ value: this.buffer,
4314
+ expressions: this.expressions
4315
+ });
4316
+ this.buffer = "";
4317
+ this.expressions = [];
4318
+ this.state = 0;
4319
+ } else if (char === "{") {
4320
+ this.expressionStartIndex = index;
4321
+ this.expressionBuffer = char;
4322
+ this.buffer += char;
4323
+ this.state = 2;
4324
+ } else {
4325
+ this.buffer += char;
4326
+ this.state = 1;
4327
+ }
4328
+ break;
4329
+ default: throw new Error("Unexpected state");
4330
+ }
4331
+ }
4332
+ run(input) {
4333
+ this.reset();
4334
+ for (let i = 0; i < input.length; i++) {
4335
+ const char = input[i];
4336
+ if (char === void 0) continue;
4337
+ this.processChar(char, i);
4338
+ }
4339
+ if (this.buffer.length > 0) this.tokens.push({
4340
+ start: this.bufferStartIndex,
4341
+ end: input.length,
4342
+ value: this.buffer,
4343
+ expressions: this.expressions
4344
+ });
4345
+ const tokens = this.tokens;
4346
+ this.reset();
4347
+ return tokens;
4348
+ }
4349
+ reset() {
4350
+ this.state = 0;
4351
+ this.buffer = "";
4352
+ this.tokens = [];
4353
+ this.bufferStartIndex = 0;
4354
+ this.expressionBuffer = "";
4355
+ this.expressionStartIndex = 0;
4356
+ this.expressions = [];
4357
+ }
4358
+ };
4359
+ //#endregion
4360
+ //#region src/wxml/utils/fragment-helpers.ts
4361
+ function updateWhitespaceGap(ms, start, end, options) {
4362
+ const gap = ms.slice(start, end);
4363
+ if (isAllWhitespace(gap)) ms.update(start, end, replaceWxml(gap, {
4364
+ keepEOL: false,
4365
+ escapeMap: options.escapeMap,
4366
+ ignoreHead: true
4367
+ }));
4368
+ }
4369
+ function updateWxmlSegment(ms, start, end, options, keepEOL, ignoreHead) {
4370
+ ms.update(start, end, replaceWxml(ms.slice(start, end), {
4371
+ keepEOL,
4372
+ escapeMap: options.escapeMap,
4373
+ ignoreHead
4374
+ }));
4375
+ }
4376
+ function updateExpressionSegment(ms, exp, options) {
4377
+ const code = `{{${generateCode(exp.value.slice(2, -2), options)}}}`;
4378
+ ms.update(exp.start, exp.end, code);
4379
+ }
4380
+ //#endregion
4381
+ //#region src/wxml/utils/fragment-updater.ts
4382
+ function handleEachClassFragment(ms, tokens, options = {}) {
4383
+ let previousEnd = 0;
4384
+ for (const token of tokens) {
4385
+ if (token.start > previousEnd) updateWhitespaceGap(ms, previousEnd, token.start, options);
4386
+ let p = token.start;
4387
+ if (token.expressions.length > 0) {
4388
+ for (const exp of token.expressions) {
4389
+ if (exp.start > token.start && p < exp.start) updateWxmlSegment(ms, p, exp.start, options, true, p > 0);
4390
+ updateExpressionSegment(ms, exp, options);
4391
+ p = exp.end;
4392
+ }
4393
+ if (token.end > p) updateWxmlSegment(ms, p, token.end, options, false, true);
4394
+ } else updateWxmlSegment(ms, token.start, token.end, options, false, false);
4395
+ previousEnd = token.end;
4396
+ }
4397
+ if (tokens.length > 0) {
4398
+ const lastToken = tokens[tokens.length - 1];
4399
+ if (!lastToken) return;
4400
+ if (lastToken.end < ms.original.length) updateWhitespaceGap(ms, lastToken.end, ms.original.length, options);
4401
+ }
4402
+ }
4403
+ //#endregion
4404
+ //#region src/wxml/utils/template-fragments.ts
4405
+ /**
4406
+ * 模块级共享 Tokenizer 实例,避免每次调用都重新创建。
4407
+ * Tokenizer.run() 末尾已调用 reset(),天然支持复用。
4408
+ */
4409
+ const sharedTokenizer = new Tokenizer();
4410
+ function templateReplacer(original, options = {}, tokenizer) {
4411
+ const ms = new MagicString(original);
4412
+ handleEachClassFragment(ms, (tokenizer ?? sharedTokenizer).run(ms.original), options);
4413
+ return ms.toString();
4414
+ }
4415
+ //#endregion
4416
+ //#region src/wxml/utils/custom-template.ts
4417
+ async function customTemplateHandler(rawSource, options, cachedMatcher) {
4418
+ const { customAttributesEntities = [], disabledDefaultTemplateHandler, inlineWxs, runtimeSet, jsHandler } = options ?? {};
4419
+ const matchCustomAttribute = cachedMatcher ?? createAttributeMatcher(customAttributesEntities);
4420
+ const defaultTemplateHandlerEnabled = !disabledDefaultTemplateHandler;
4421
+ let replaceOptions;
4422
+ let cachedQuote;
4423
+ let s;
4424
+ let tag = "";
4425
+ let wxsArray;
4426
+ function getMagicString() {
4427
+ if (!s) s = new MagicString(rawSource);
4428
+ return s;
4429
+ }
4430
+ function getReplaceOptions(quote) {
4431
+ if (!replaceOptions) {
4432
+ replaceOptions = {
4433
+ ...options,
4434
+ quote
4435
+ };
4436
+ cachedQuote = quote;
4437
+ return replaceOptions;
4438
+ }
4439
+ if (cachedQuote !== quote) {
4440
+ replaceOptions.quote = quote;
4441
+ cachedQuote = quote;
4442
+ }
4443
+ return replaceOptions;
4444
+ }
4445
+ function isDefaultTemplateAttribute(name) {
4446
+ if (name === "class" || name === "hover-class" || name === "virtualhostclass") return true;
4447
+ const lowerName = name.toLowerCase();
4448
+ return lowerName === "class" || lowerName === "hover-class" || lowerName === "virtualhostclass";
4449
+ }
4450
+ const parser = new Parser({
4451
+ onopentagname(name) {
4452
+ tag = name;
4453
+ },
4454
+ onattribute(name, value, quote) {
4455
+ if (!value) return;
4456
+ const shouldHandleDefault = defaultTemplateHandlerEnabled && isDefaultTemplateAttribute(name);
4457
+ const shouldHandleCustom = matchCustomAttribute?.(tag, name) ?? false;
4458
+ if (!shouldHandleDefault && !shouldHandleCustom) return;
4459
+ getMagicString().update(parser.startIndex + name.length + 2, parser.endIndex - 1, templateReplacer(value, getReplaceOptions(quote)));
4460
+ },
4461
+ ontext(data) {
4462
+ if (inlineWxs && tag === "wxs") (wxsArray ?? (wxsArray = [])).push({
4463
+ data,
4464
+ endIndex: parser.endIndex + 1,
4465
+ startIndex: parser.startIndex
4466
+ });
4467
+ },
4468
+ onclosetag() {
4469
+ tag = "";
4470
+ }
4471
+ }, { xmlMode: true });
4472
+ parser.write(rawSource);
4473
+ parser.end();
4474
+ if (jsHandler) for (const { data, endIndex, startIndex } of wxsArray ?? []) {
4475
+ const { code } = await jsHandler(data, runtimeSet);
4476
+ if (code !== data) getMagicString().update(startIndex, endIndex, code);
4477
+ }
4478
+ return s?.toString() ?? rawSource;
4479
+ }
4480
+ //#endregion
4481
+ //#region src/wxml/utils.ts
4482
+ function createTemplateHandler(options = {}) {
4483
+ const cachedMatcher = createAttributeMatcher(options.customAttributesEntities);
4484
+ const defaultOptions = options;
4485
+ let cachedRuntimeSet;
4486
+ let cachedOptionsWithRuntimeSet;
4487
+ return (rawSource, opt) => {
4488
+ const runtimeSet = opt?.runtimeSet;
4489
+ if (runtimeSet === void 0) return customTemplateHandler(rawSource, defaultOptions, cachedMatcher);
4490
+ if (cachedRuntimeSet !== runtimeSet || !cachedOptionsWithRuntimeSet) {
4491
+ cachedRuntimeSet = runtimeSet;
4492
+ cachedOptionsWithRuntimeSet = {
4493
+ ...defaultOptions,
4494
+ runtimeSet
4495
+ };
4496
+ }
4497
+ return customTemplateHandler(rawSource, cachedOptionsWithRuntimeSet, cachedMatcher);
4498
+ };
4499
+ }
4500
+ //#endregion
4501
+ //#region src/constants.ts
4502
+ const pluginName = "weapp-tailwindcss";
4503
+ const vitePluginName = "weapp-tailwindcss:adaptor";
4504
+ const DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS = {
4505
+ "tailwind-merge": "@weapp-tailwindcss/merge",
4506
+ "class-variance-authority": "@weapp-tailwindcss/cva",
4507
+ "tailwind-variants": "@weapp-tailwindcss/variants"
4508
+ };
4509
+ //#endregion
4510
+ //#region src/context/runtime-package-replacements.ts
4511
+ function resolveRuntimePackageReplacements(option) {
4512
+ const mapping = resolveBooleanObjectOption(option, DEFAULT_RUNTIME_PACKAGE_REPLACEMENTS);
4513
+ if (!mapping) return;
4514
+ const normalized = {};
4515
+ for (const [from, to] of Object.entries(mapping)) {
4516
+ if (!from || typeof to !== "string" || to.length === 0) continue;
4517
+ normalized[from] = to;
4518
+ }
4519
+ return Object.keys(normalized).length > 0 ? normalized : void 0;
4520
+ }
4521
+ //#endregion
4522
+ //#region src/context/style-options.ts
4523
+ function resolveStyleOptionsFromContext(ctx) {
4524
+ const resolvedUniAppXOptions = resolveUniAppXOptions(ctx.uniAppX);
4525
+ return {
4526
+ cssPreflight: ctx.cssPreflight,
4527
+ cssPreflightRange: ctx.cssPreflightRange,
4528
+ cssChildCombinatorReplaceValue: ctx.cssChildCombinatorReplaceValue,
4529
+ cssSelectorReplacement: ctx.cssSelectorReplacement,
4530
+ rem2rpx: ctx.rem2rpx,
4531
+ cssRemoveProperty: ctx.cssRemoveProperty,
4532
+ cssRemoveHoverPseudoClass: ctx.cssRemoveHoverPseudoClass,
4533
+ cssPresetEnv: ctx.cssPresetEnv,
4534
+ autoprefixer: ctx.autoprefixer,
4535
+ cssCalc: ctx.cssCalc,
4536
+ uniAppX: resolvedUniAppXOptions.enabled,
4537
+ platform: ctx.platform,
4538
+ px2rpx: ctx.px2rpx,
4539
+ unitsToPx: ctx.unitsToPx,
4540
+ unitConversion: ctx.unitConversion
4541
+ };
4542
+ }
4543
+ //#endregion
4544
+ //#region src/context/handlers.ts
4545
+ function createHandlersFromContext(ctx, customAttributesEntities, cssCalcOptions, tailwindcssMajorVersion) {
4546
+ const { escapeMap, injectAdditionalCssVarScope, postcssOptions, uniAppX, arbitraryValues, jsPreserveClass, jsArbitraryValueFallback, babelParserOptions, ignoreCallExpressionIdentifiers, ignoreTaggedTemplateExpressionIdentifiers, inlineWxs, disabledDefaultTemplateHandler, replaceRuntimePackages } = ctx;
4547
+ const resolvedUniAppXOptions = resolveUniAppXOptions(uniAppX);
4548
+ const styleOptions = resolveStyleOptionsFromContext(ctx);
4549
+ const uniAppXEnabled = styleOptions.uniAppX === true;
4550
+ const moduleSpecifierReplacements = resolveRuntimePackageReplacements(replaceRuntimePackages);
4551
+ const styleHandler = createStyleHandler({
4552
+ ...styleOptions,
4553
+ escapeMap,
4554
+ injectAdditionalCssVarScope,
4555
+ postcssOptions,
4556
+ uniAppXUnsupported: resolvedUniAppXOptions.uvueUnsupported,
4557
+ cssCalc: cssCalcOptions,
4558
+ majorVersion: tailwindcssMajorVersion
4559
+ });
4560
+ const jsHandler = createJsHandler({
4561
+ escapeMap,
4562
+ arbitraryValues,
4563
+ jsPreserveClass,
4564
+ jsArbitraryValueFallback: jsArbitraryValueFallback ?? "auto",
4565
+ tailwindcssMajorVersion,
4566
+ generateMap: true,
4567
+ babelParserOptions,
4568
+ ignoreCallExpressionIdentifiers,
4569
+ ignoreTaggedTemplateExpressionIdentifiers,
4570
+ uniAppX: uniAppXEnabled,
4571
+ moduleSpecifierReplacements
4572
+ });
4573
+ return {
4574
+ styleHandler,
4575
+ jsHandler,
4576
+ templateHandler: createTemplateHandler({
4577
+ customAttributesEntities,
4578
+ escapeMap,
4579
+ inlineWxs,
4580
+ jsHandler,
4581
+ disabledDefaultTemplateHandler
4582
+ })
4583
+ };
4584
+ }
4585
+ //#endregion
4586
+ //#region src/context/logger.ts
4587
+ const loggerLevelMap = {
4588
+ error: 0,
4589
+ warn: 1,
4590
+ info: 3,
4591
+ silent: -999
4592
+ };
4593
+ function applyLoggerLevel(logLevel) {
4594
+ logger.level = loggerLevelMap[logLevel ?? "info"] ?? loggerLevelMap.info;
4595
+ }
4596
+ //#endregion
4597
+ //#region src/context/index.ts
4598
+ async function clearTailwindcssPatcherCache(patcher, options) {
4599
+ if (!patcher) return;
4600
+ const cacheOptions = patcher.options?.cache;
4601
+ if (cacheOptions == null || typeof cacheOptions === "object" && cacheOptions.enabled === false) return;
4602
+ if (typeof patcher.clearCache === "function") try {
4603
+ await patcher.clearCache({ scope: "all" });
4604
+ } catch (error) {
4605
+ logger.debug("failed to clear tailwindcss patcher cache via clearCache(): %O", error);
4606
+ }
4607
+ if (!options?.removeDirectory) return;
4608
+ const cachePaths = /* @__PURE__ */ new Map();
4609
+ const normalizedCacheOptions = typeof cacheOptions === "object" ? cacheOptions : void 0;
4610
+ if (normalizedCacheOptions?.path) cachePaths.set(normalizedCacheOptions.path, false);
4611
+ const privateCachePath = patcher?.cacheStore?.options?.path;
4612
+ if (privateCachePath) cachePaths.set(privateCachePath, false);
4613
+ if (options?.removeDirectory && normalizedCacheOptions?.dir) cachePaths.set(normalizedCacheOptions.dir, true);
4614
+ if (!cachePaths.size) return;
4615
+ for (const [cachePath, recursive] of cachePaths.entries()) try {
4616
+ await rm(cachePath, {
4617
+ force: true,
4618
+ recursive
4619
+ });
4620
+ } catch (error) {
4621
+ const err = error;
4622
+ if (err?.code === "ENOENT") continue;
4623
+ logger.debug("failed to clear tailwindcss patcher cache: %s %O", cachePath, err);
4624
+ }
4625
+ }
4626
+ function createInternalCompilerContext(opts) {
4627
+ const ctx = defuOverrideArray(opts, getDefaultOptions(), {});
4628
+ ctx.arbitraryValues = resolveUnocssBareArbitraryValues(ctx.arbitraryValues, ctx.unocss);
4629
+ ctx.escapeMap = ctx.customReplaceDictionary;
4630
+ applyLoggerLevel(ctx.logLevel);
4631
+ const twPatcher = createTailwindcssPatcherFromContext(ctx);
4632
+ logTailwindcssTarget(twPatcher, ctx.tailwindcssBasedir);
4633
+ logRuntimeTailwindcssVersion(ctx.tailwindcssBasedir, twPatcher.packageInfo?.rootPath, twPatcher.packageInfo?.version);
4634
+ if (opts?.__internalDeferMissingCssEntriesWarning !== true) warnMissingCssEntries(ctx, twPatcher);
4635
+ ctx.cssPreflight = resolveDefaultCssPreflight(opts?.cssPreflight, twPatcher.majorVersion);
4636
+ const cssCalcOptions = applyV4CssCalcDefaults(ctx.cssCalc, twPatcher);
4637
+ ctx.cssCalc = cssCalcOptions;
4638
+ const { styleHandler, jsHandler, templateHandler } = createHandlersFromContext(ctx, toCustomAttributesEntities(ctx.customAttributes), cssCalcOptions, twPatcher.majorVersion);
4639
+ ctx.styleHandler = styleHandler;
4640
+ ctx.jsHandler = jsHandler;
4641
+ ctx.templateHandler = templateHandler;
4642
+ ctx.cache = initializeCache(ctx.cache);
4643
+ ctx.twPatcher = twPatcher;
4644
+ const refreshTailwindcssPatcher = async (options) => {
4645
+ const previousPatcher = ctx.twPatcher;
4646
+ if (options?.clearCache !== false) await clearTailwindcssPatcherCache(previousPatcher);
4647
+ invalidateRuntimeClassSet(previousPatcher);
4648
+ const nextPatcher = createTailwindcssPatcherFromContext(ctx);
4649
+ Object.assign(previousPatcher, nextPatcher);
4650
+ ctx.twPatcher = previousPatcher;
4651
+ return previousPatcher;
4652
+ };
4653
+ ctx.refreshTailwindcssPatcher = refreshTailwindcssPatcher;
4654
+ Object.defineProperty(ctx.twPatcher, refreshTailwindcssPatcherSymbol, {
4655
+ value: refreshTailwindcssPatcher,
4656
+ configurable: true
4657
+ });
4658
+ return ctx;
4659
+ }
4660
+ /**
4661
+ * 获取用户定义选项的内部表示,并初始化相关的处理程序和 Tailwind 运行时。
4662
+ * @param opts - 用户定义的选项,可选。
4663
+ * @returns 返回一个包含内部用户定义选项的对象,包括样式、JS 和模板处理程序,以及 Tailwind CSS 运行时。
4664
+ */
4665
+ function getCompilerContext(opts) {
4666
+ return withCompilerContextCache(opts, () => createInternalCompilerContext(opts));
4667
+ }
4668
+ //#endregion
4669
+ //#region src/js/precheck.ts
4670
+ /** 用于检测源码中是否包含类名相关模式的正则表达式 */
4671
+ const FAST_JS_TRANSFORM_HINT_RE = /className\b|class\s*=|classList\.|\b(?:twMerge|clsx|classnames|cn|cva)\b|\[["'`]class["'`]\]|text-\[|bg-\[|\b(?:[whpm]|px|py|mx|my|rounded|flex|grid|gap)-/;
4672
+ /** 用于检测源码中是否包含 import/export/require 语句的正则表达式 */
4673
+ const DEPENDENCY_HINT_RE = /\bimport\s*[("'`{*]|\brequire\s*\(|\bexport\s+\*\s+from\s+["'`]|\bexport\s*\{[^}]*\}\s*from\s+["'`]/;
4674
+ /**
4675
+ * 判断是否可以跳过 JS 转换。
4676
+ * 通过正则快速检测源码内容,避免不必要的 Babel AST 解析。
4677
+ *
4678
+ * @param rawSource - 原始 JS 源码字符串
4679
+ * @param options - 可选的 JS 处理器配置选项
4680
+ * @returns 如果可以跳过转换返回 `true`,否则返回 `false`
4681
+ */
4682
+ function shouldSkipJsTransform(rawSource, options) {
4683
+ if (process.env["WEAPP_TW_DISABLE_JS_PRECHECK"] === "1") return false;
4684
+ if (!rawSource) return true;
4685
+ if (options?.alwaysEscape) return false;
4686
+ if (options?.moduleSpecifierReplacements && Object.keys(options.moduleSpecifierReplacements).length > 0) return false;
4687
+ if (options?.wrapExpression) return false;
4688
+ if (DEPENDENCY_HINT_RE.test(rawSource)) return false;
4689
+ return !FAST_JS_TRANSFORM_HINT_RE.test(rawSource);
4690
+ }
4691
+ //#endregion
4692
+ export { collectRuntimeClassSet as _, vitePluginName as a, refreshTailwindRuntimeState as b, createAttributeMatcher as c, _defineProperty as d, isClassContextLiteralPath as f, toCustomAttributesEntities as g, traverse as h, pluginName as i, analyzeSource as l, babelParse as m, getCompilerContext as n, Parser as o, replaceWxml as p, resolveStyleOptionsFromContext as r, generateCode as s, shouldSkipJsTransform as t, JsTokenUpdater as u, createTailwindRuntimeReadyPromise as v, ensureRuntimeClassSet as y };