weapp-tailwindcss 5.0.0-next.3 → 5.0.0-next.31

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