weapp-tailwindcss 5.0.0-next.9 → 5.0.1

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 (167) hide show
  1. package/README.md +2 -2
  2. package/dist/auto-DEHRmEAx.mjs +200 -0
  3. package/dist/auto-dPpsm6FB.js +238 -0
  4. package/dist/bundle-state-CBF5YX1m.js +529 -0
  5. package/dist/bundle-state-CQmxxx0R.mjs +413 -0
  6. package/dist/bundlers/shared/cache.d.ts +9 -7
  7. package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +1 -2
  8. package/dist/bundlers/shared/css-cleanup.d.ts +1 -3
  9. package/dist/bundlers/shared/css-imports.d.ts +3 -3
  10. package/dist/bundlers/shared/generated-css-marker.d.ts +3 -0
  11. package/dist/bundlers/shared/generator-css/directives.d.ts +11 -3
  12. package/dist/bundlers/shared/generator-css/markers.d.ts +12 -0
  13. package/dist/bundlers/shared/generator-css/source-files.d.ts +9 -6
  14. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +16 -2
  15. package/dist/bundlers/shared/generator-css/user-layer-order.d.ts +10 -0
  16. package/dist/bundlers/shared/generator-css.d.ts +6 -2
  17. package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
  18. package/dist/bundlers/shared/style-requests.d.ts +2 -0
  19. package/dist/bundlers/vite/bundle-state.d.ts +1 -0
  20. package/dist/bundlers/vite/css-finalizer.d.ts +6 -0
  21. package/dist/bundlers/vite/generate-bundle/candidates.d.ts +1 -1
  22. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -1
  23. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +1 -0
  24. package/dist/bundlers/vite/generate-bundle.d.ts +13 -1
  25. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +10 -2
  26. package/dist/bundlers/vite/index.d.ts +5 -2
  27. package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
  28. package/dist/bundlers/vite/rewrite-css-imports.d.ts +8 -5
  29. package/dist/bundlers/vite/runtime-class-set.d.ts +5 -1
  30. package/dist/bundlers/vite/serve-css-generation.d.ts +11 -0
  31. package/dist/bundlers/vite/source-candidates.d.ts +24 -2
  32. package/dist/bundlers/vite/source-scan.d.ts +26 -0
  33. package/dist/bundlers/vite/static-config-content.d.ts +5 -0
  34. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +5 -0
  35. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +5 -1
  36. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +8 -3
  37. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -1
  38. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +31 -0
  39. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -8
  40. package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
  41. package/dist/cache/index.d.ts +6 -6
  42. package/dist/{chunk-8l464Juk.js → chunk-C5U5_Hdc.js} +14 -0
  43. package/dist/cli/context.d.ts +1 -11
  44. package/dist/cli/doctor/types.d.ts +11 -11
  45. package/dist/cli/vscode-entry.d.ts +3 -3
  46. package/dist/cli.js +684 -41
  47. package/dist/cli.mjs +682 -40
  48. package/dist/context/runtime-package-replacements.d.ts +2 -0
  49. package/dist/context/style-options.d.ts +3 -0
  50. package/dist/context/tailwindcss.d.ts +1 -1
  51. package/dist/core.js +1 -2
  52. package/dist/core.mjs +1 -1
  53. package/dist/css-macro/auto.d.ts +11 -0
  54. package/dist/css-macro/constants.d.ts +5 -2
  55. package/dist/css-macro/postcss.d.ts +1 -0
  56. package/dist/css-macro/postcss.js +7 -46
  57. package/dist/css-macro/postcss.mjs +2 -46
  58. package/dist/css-macro.js +16 -7
  59. package/dist/css-macro.mjs +15 -6
  60. package/dist/defaults-8xrgzxFY.mjs +151 -0
  61. package/dist/defaults-zKUH2mDe.js +193 -0
  62. package/dist/defaults.js +6 -150
  63. package/dist/defaults.mjs +1 -143
  64. package/dist/escape.js +10 -2
  65. package/dist/escape.mjs +10 -2
  66. package/dist/generator/options.d.ts +11 -6
  67. package/dist/generator/types.d.ts +3 -3
  68. package/dist/generator-CvmsIQFI.js +92 -0
  69. package/dist/generator-DDtsUvkH.mjs +67 -0
  70. package/dist/generator.js +12 -12
  71. package/dist/generator.mjs +2 -1
  72. package/dist/gulp.js +163 -40
  73. package/dist/gulp.mjs +155 -32
  74. package/dist/incremental-runtime-class-set-BffodqHh.js +2366 -0
  75. package/dist/incremental-runtime-class-set-DArodvWs.mjs +2291 -0
  76. package/dist/index.d.ts +2 -1
  77. package/dist/index.js +17 -5
  78. package/dist/index.mjs +6 -5
  79. package/dist/js/babel/cache-options.d.ts +3 -0
  80. package/dist/js/babel/parse.d.ts +7 -4
  81. package/dist/js/precheck.d.ts +2 -2
  82. package/dist/js/replacement-cache.d.ts +5 -0
  83. package/dist/{postcss-w48mGIhe.mjs → postcss-BzNYQUOH.mjs} +54 -114
  84. package/dist/postcss-C7BMYpEF.mjs +169 -0
  85. package/dist/postcss-CiYLsqZn.js +192 -0
  86. package/dist/{postcss-QIXwT40c.js → postcss-DE0TOtV9.js} +60 -121
  87. package/dist/postcss-html-transform.js +1 -1
  88. package/dist/postcss.js +1 -1
  89. package/dist/postcss.mjs +1 -1
  90. package/dist/precheck-BzYPm-EG.js +4842 -0
  91. package/dist/precheck-jZvTVXXG.mjs +4716 -0
  92. package/dist/presets/index.d.ts +1 -0
  93. package/dist/presets/uni-app-x.d.ts +1 -0
  94. package/dist/presets.js +27 -13
  95. package/dist/presets.mjs +25 -13
  96. package/dist/reset.js +1 -1
  97. package/dist/runtime-registry-DpcR3IHI.js +5496 -0
  98. package/dist/shared/mpx.d.ts +1 -0
  99. package/dist/source-candidates-BuTlMabx.mjs +322 -0
  100. package/dist/source-candidates-CxoIaS88.js +335 -0
  101. package/dist/tailwindcss/miniprogram.d.ts +1 -5
  102. package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -2
  103. package/dist/tailwindcss/runtime/cache.d.ts +4 -3
  104. package/dist/tailwindcss/runtime.d.ts +9 -9
  105. package/dist/tailwindcss/source-scan.d.ts +35 -0
  106. package/dist/tailwindcss/v3-engine/types.d.ts +19 -14
  107. package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
  108. package/dist/tailwindcss/v4/patcher.d.ts +1 -1
  109. package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
  110. package/dist/tailwindcss/v4-engine/types.d.ts +18 -5
  111. package/dist/{tailwindcss-C5IgPlQ0.mjs → tailwindcss-CCZcu0lr.mjs} +75 -98
  112. package/dist/{tailwindcss-Bu-RWIHx.js → tailwindcss-DZckITp1.js} +83 -106
  113. package/dist/typedoc.export.d.ts +1 -1
  114. package/dist/types/index.d.ts +51 -41
  115. package/dist/types/shared.d.ts +3 -0
  116. package/dist/types/typedoc-tailwindcss-patch.d.ts +67 -0
  117. package/dist/types/user-defined-options/general.d.ts +25 -22
  118. package/dist/types/user-defined-options/important.d.ts +32 -27
  119. package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
  120. package/dist/types/user-defined-options/matcher.d.ts +6 -6
  121. package/dist/unocss/index.d.ts +2 -0
  122. package/dist/utils/object.d.ts +9 -0
  123. package/dist/utils/options.d.ts +2 -0
  124. package/dist/utils/regex.d.ts +1 -0
  125. package/dist/{utils-BiShvil9.js → utils-D7Ygohep.js} +2 -2
  126. package/dist/{utils-Btw1iOVV.mjs → utils-DsaS975I.mjs} +1 -1
  127. package/dist/v3-engine-DGBhUnjn.mjs +3419 -0
  128. package/dist/v3-engine-M6Aqru5T.js +3714 -0
  129. package/dist/vite-BBcQIJpD.mjs +24493 -0
  130. package/dist/vite-DgRkWVPG.js +24507 -0
  131. package/dist/vite.js +1 -1
  132. package/dist/vite.mjs +1 -1
  133. package/dist/weapp-tw-css-import-rewrite-loader.js +5456 -22
  134. package/dist/weapp-tw-runtime-classset-loader.js +32 -9
  135. package/dist/{webpack-BzN2ly34.js → webpack-D-gb4ZvO.js} +341 -96
  136. package/dist/{webpack-DJazm5sT.mjs → webpack-D43aMQzO.mjs} +323 -79
  137. package/dist/webpack.d.ts +1 -3
  138. package/dist/webpack.js +3 -4
  139. package/dist/webpack.mjs +2 -2
  140. package/dist/wxml/utils/codegen/legacy-visitor.d.ts +2 -4
  141. package/package.json +22 -20
  142. package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +0 -3
  143. package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +0 -4
  144. package/dist/bundlers/shared/css-cleanup/selectors.d.ts +0 -8
  145. package/dist/cache-BVAiJV3J.js +0 -502
  146. package/dist/cache-CHs4DXui.mjs +0 -434
  147. package/dist/constants-BoB_6lFw.js +0 -73
  148. package/dist/constants-E_loJC49.mjs +0 -44
  149. package/dist/generator-DKkhJbOg.js +0 -1531
  150. package/dist/generator-UBmfduYg.mjs +0 -1432
  151. package/dist/generator-css-Bwp3nbrl.js +0 -1381
  152. package/dist/generator-css-DeLLmp2N.mjs +0 -1342
  153. package/dist/lightningcss/index.d.ts +0 -8
  154. package/dist/lightningcss/style-handler/options.d.ts +0 -3
  155. package/dist/lightningcss/style-handler/selector-transform.d.ts +0 -10
  156. package/dist/lightningcss/style-handler/selector-utils.d.ts +0 -10
  157. package/dist/lightningcss/style-handler.d.ts +0 -17
  158. package/dist/precheck-B32p-gLI.js +0 -2736
  159. package/dist/precheck-B4RH6ZNN.mjs +0 -2622
  160. package/dist/run-tasks-B50A3pxt.js +0 -128
  161. package/dist/run-tasks-DdNi-hkk.mjs +0 -91
  162. package/dist/runtime-patch-CwN5ya72.mjs +0 -71
  163. package/dist/runtime-patch-D6mBo_KB.js +0 -85
  164. package/dist/vite-By5KQi9s.js +0 -2419
  165. package/dist/vite-Cyp42bBf.mjs +0 -2406
  166. /package/dist/{logger-Bub1jggA.mjs → logger-BNzxZbZj.mjs} +0 -0
  167. /package/dist/{logger-BRy6XPQ2.js → logger-TlKT3xmR.js} +0 -0
@@ -0,0 +1,413 @@
1
+ import { g as traverse, h as babelParse, o as Parser } from "./precheck-jZvTVXXG.mjs";
2
+ import { createRequire } from "node:module";
3
+ import process from "node:process";
4
+ import path from "node:path";
5
+ import { cleanUrl, ensurePosix } from "@weapp-tailwindcss/shared";
6
+ import { Buffer } from "node:buffer";
7
+ //#region src/bundlers/shared/module-graph.ts
8
+ const QUERY_HASH_RE = /[?#].*$/u;
9
+ const PROTOCOL_RE = /^[a-z][a-z+.-]*:/iu;
10
+ const WINDOWS_ABSOLUTE_RE = /^[a-z]:[\\/]/iu;
11
+ const VIRTUAL_PREFIX = "\0";
12
+ const JS_EXTENSIONS = [
13
+ ".js",
14
+ ".mjs",
15
+ ".cjs"
16
+ ];
17
+ function normalizeOutputPathKey(value) {
18
+ return path.normalize(value).replace(/\\/g, "/");
19
+ }
20
+ function stripQueryAndHash(specifier) {
21
+ return specifier.replace(QUERY_HASH_RE, "");
22
+ }
23
+ function isResolvableSpecifier(specifier) {
24
+ if (!specifier) return false;
25
+ const normalized = stripQueryAndHash(specifier);
26
+ if (normalized.startsWith(VIRTUAL_PREFIX)) return false;
27
+ if (path.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) return true;
28
+ return !PROTOCOL_RE.test(normalized);
29
+ }
30
+ function toAbsoluteOutputPath(fileName, outDir) {
31
+ if (path.isAbsolute(fileName) || WINDOWS_ABSOLUTE_RE.test(fileName)) return path.normalize(fileName);
32
+ return path.resolve(outDir, fileName);
33
+ }
34
+ function matchWithExtensions(candidate, hasOutput) {
35
+ if (hasOutput(candidate)) return candidate;
36
+ if (!path.extname(candidate)) for (const ext of JS_EXTENSIONS) {
37
+ const extended = `${candidate}${ext}`;
38
+ if (hasOutput(extended)) return extended;
39
+ }
40
+ }
41
+ function resolveOutputSpecifier(specifier, importer, outDir, hasOutput) {
42
+ if (!isResolvableSpecifier(specifier)) return;
43
+ const normalized = stripQueryAndHash(specifier);
44
+ let candidate;
45
+ if (path.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) candidate = path.normalize(normalized);
46
+ else if (normalized.startsWith("/")) candidate = path.resolve(outDir, normalized.slice(1));
47
+ else candidate = path.resolve(path.dirname(importer), normalized);
48
+ return matchWithExtensions(candidate, hasOutput);
49
+ }
50
+ //#endregion
51
+ //#region src/bundlers/shared/style-requests.ts
52
+ const SOURCE_STYLE_EXT_RE = /\.(?:css|scss|sass|less|styl|stylus|pcss|postcss)$/i;
53
+ const STYLE_QUERY_RE = /(?:^|&)type=styles?(?:&|$)/;
54
+ const STYLE_LANG_QUERY_RE = /(?:^|&)lang(?:[.=](?:css|scss|sass|less|styl|stylus|pcss|postcss))?(?:&|$)/;
55
+ function stripHash(request) {
56
+ const hashIndex = request.indexOf("#");
57
+ return hashIndex === -1 ? request : request.slice(0, hashIndex);
58
+ }
59
+ function stripRequestQuery(request) {
60
+ const normalized = stripHash(request);
61
+ const queryIndex = normalized.indexOf("?");
62
+ return queryIndex === -1 ? normalized : normalized.slice(0, queryIndex);
63
+ }
64
+ function isSourceStyleRequest(request) {
65
+ if (typeof request !== "string" || request.length === 0) return false;
66
+ const normalized = stripHash(request);
67
+ const queryIndex = normalized.indexOf("?");
68
+ const pathname = queryIndex === -1 ? normalized : normalized.slice(0, queryIndex);
69
+ if (SOURCE_STYLE_EXT_RE.test(pathname)) return true;
70
+ if (queryIndex === -1) return false;
71
+ const query = normalized.slice(queryIndex + 1);
72
+ return STYLE_QUERY_RE.test(query) || STYLE_LANG_QUERY_RE.test(query);
73
+ }
74
+ //#endregion
75
+ //#region src/bundlers/vite/utils.ts
76
+ function slash(p) {
77
+ return ensurePosix(p);
78
+ }
79
+ const isWindows = process.platform === "win32";
80
+ const cssLangRE = new RegExp(`\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`);
81
+ function isCSSRequest(request) {
82
+ return cssLangRE.test(request) || isSourceStyleRequest(request);
83
+ }
84
+ function normalizePath(id) {
85
+ return path.posix.normalize(isWindows ? ensurePosix(id) : id);
86
+ }
87
+ async function formatPostcssSourceMap(rawMap, file) {
88
+ const inputFileDir = path.dirname(file);
89
+ const sources = rawMap.sources.map((source) => {
90
+ const cleanSource = cleanUrl(decodeURIComponent(source));
91
+ if (cleanSource[0] === "<" && cleanSource.endsWith(">")) return `\0${cleanSource}`;
92
+ return normalizePath(path.resolve(inputFileDir, cleanSource));
93
+ });
94
+ return {
95
+ file,
96
+ mappings: rawMap.mappings,
97
+ names: rawMap.names,
98
+ sources,
99
+ sourcesContent: rawMap.sourcesContent,
100
+ version: rawMap.version
101
+ };
102
+ }
103
+ //#endregion
104
+ //#region src/utils/disabled.ts
105
+ function resolvePluginDisabledState(disabled) {
106
+ if (disabled === true) return { plugin: true };
107
+ if (disabled === false || disabled == null) return { plugin: false };
108
+ return { plugin: disabled.plugin ?? false };
109
+ }
110
+ //#endregion
111
+ //#region src/utils/resolve-package.ts
112
+ const require = createRequire(import.meta.url);
113
+ function resolvePackageDir(name) {
114
+ const pkgPath = require.resolve(`${name}/package.json`);
115
+ return path.dirname(pkgPath);
116
+ }
117
+ //#endregion
118
+ //#region src/bundlers/shared/generated-css-marker.ts
119
+ const BUNDLER_GENERATED_CSS_MARKER_RE = /\/\*!\s*weapp-tailwindcss (?:vite|webpack)-generated-css(?::[^\s*]+)?\s*\*\/\s*/i;
120
+ const BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss (?:vite|webpack)-generated-css(?::[^\s*]+)?\s*\*\/\s*/gi;
121
+ function createBundlerGeneratedCssMarker(bundler, file) {
122
+ return `/*! weapp-tailwindcss ${bundler}-generated-css:${encodeURIComponent(file)} */`;
123
+ }
124
+ function hasBundlerGeneratedCssMarker(source) {
125
+ return typeof source === "string" && BUNDLER_GENERATED_CSS_MARKER_RE.test(source);
126
+ }
127
+ function stripBundlerGeneratedCssMarkers(source) {
128
+ return source.replace(BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE, "");
129
+ }
130
+ //#endregion
131
+ //#region src/bundlers/shared/run-tasks.ts
132
+ async function runWithConcurrency(factories, limit = Math.min(4, Math.max(1, factories.length))) {
133
+ if (factories.length === 0) return [];
134
+ const results = Array.from({ length: factories.length });
135
+ const executing = /* @__PURE__ */ new Set();
136
+ let cursor = 0;
137
+ const effectiveLimit = Math.max(1, limit);
138
+ const scheduleNext = () => {
139
+ if (cursor >= factories.length) return;
140
+ const currentIndex = cursor++;
141
+ const factory = factories[currentIndex];
142
+ if (!factory) return;
143
+ const wrapped = Promise.resolve(factory()).then((value) => {
144
+ results[currentIndex] = value;
145
+ }).finally(() => {
146
+ executing.delete(wrapped);
147
+ });
148
+ executing.add(wrapped);
149
+ };
150
+ while (cursor < factories.length && executing.size < effectiveLimit) scheduleNext();
151
+ while (cursor < factories.length) {
152
+ await Promise.race(executing);
153
+ scheduleNext();
154
+ }
155
+ await Promise.all(executing);
156
+ return results;
157
+ }
158
+ function pushConcurrentTaskFactories(queue, factories, limit) {
159
+ if (factories.length === 0) return;
160
+ queue.push(runWithConcurrency(factories, limit).then(() => void 0));
161
+ }
162
+ //#endregion
163
+ //#region src/bundlers/vite/bundle-entries.ts
164
+ function readOutputEntry(entry) {
165
+ if (entry.output.type === "chunk") return entry.output.code;
166
+ const source = entry.output.source;
167
+ if (typeof source === "string") return source;
168
+ if (source instanceof Uint8Array) return Buffer.from(source).toString();
169
+ const fallbackSource = source;
170
+ if (fallbackSource == null) return;
171
+ if (typeof fallbackSource.toString === "function") return fallbackSource.toString();
172
+ }
173
+ function isJavaScriptEntry(entry) {
174
+ if (entry.output.type === "chunk") return true;
175
+ return entry.fileName.endsWith(".js");
176
+ }
177
+ function createBundleModuleGraphOptions(outputDir, entries) {
178
+ const normalizedEntries = /* @__PURE__ */ new Map();
179
+ for (const [id, entry] of entries) normalizedEntries.set(normalizeOutputPathKey(id), entry);
180
+ const getEntry = (id) => entries.get(id) ?? normalizedEntries.get(normalizeOutputPathKey(id));
181
+ return {
182
+ resolve(specifier, importer) {
183
+ return resolveOutputSpecifier(specifier, importer, outputDir, (candidate) => Boolean(getEntry(candidate)));
184
+ },
185
+ load(id) {
186
+ const entry = getEntry(id);
187
+ if (!entry) return;
188
+ return readOutputEntry(entry);
189
+ },
190
+ filter(id) {
191
+ return Boolean(getEntry(id));
192
+ }
193
+ };
194
+ }
195
+ function applyLinkedResults(linked, entries, onLinkedUpdate, onApplied) {
196
+ if (!linked) return;
197
+ const normalizedEntries = /* @__PURE__ */ new Map();
198
+ for (const [entryId, entry] of entries) normalizedEntries.set(normalizeOutputPathKey(entryId), entry);
199
+ for (const [id, { code }] of Object.entries(linked)) {
200
+ const entry = entries.get(id) ?? normalizedEntries.get(normalizeOutputPathKey(id));
201
+ if (!entry) continue;
202
+ const previous = readOutputEntry(entry);
203
+ if (previous == null || previous === code) continue;
204
+ if (entry.output.type === "chunk") entry.output.code = code;
205
+ else entry.output.source = code;
206
+ onApplied?.(entry, code);
207
+ onLinkedUpdate(entry.fileName, previous, code);
208
+ }
209
+ }
210
+ //#endregion
211
+ //#region src/bundlers/vite/runtime-affecting-signature.ts
212
+ const CSS_BLOCK_COMMENT_RE = /\/\*[\s\S]*?\*\//g;
213
+ const CSS_AROUND_PUNCTUATION_RE = /\s*([{}:;,>+~()])\s*/g;
214
+ const CSS_TRAILING_DECLARATION_SEMICOLON_RE = /;\}/g;
215
+ const CSS_WHITESPACE_RE = /\s+/g;
216
+ function createHtmlRuntimeAffectingSignature(source) {
217
+ try {
218
+ const parts = [];
219
+ const parser = new Parser({
220
+ onattribute(name, value) {
221
+ parts.push(`a:${name}=${value}`);
222
+ },
223
+ oncomment(data) {
224
+ parts.push(`c:${data}`);
225
+ },
226
+ ontext(data) {
227
+ const value = data.trim();
228
+ if (value.length > 0) parts.push(`t:${value}`);
229
+ }
230
+ }, { xmlMode: true });
231
+ parser.write(source);
232
+ parser.end();
233
+ return parts.join("\n");
234
+ } catch {
235
+ return source;
236
+ }
237
+ }
238
+ function createJsRuntimeAffectingSignature(source) {
239
+ try {
240
+ const ast = babelParse(source, {
241
+ cache: true,
242
+ cacheKey: "vite-runtime-affecting:unambiguous",
243
+ plugins: ["jsx", "typescript"],
244
+ sourceType: "unambiguous"
245
+ });
246
+ const parts = [];
247
+ traverse(ast, {
248
+ noScope: true,
249
+ StringLiteral(path) {
250
+ parts.push(`s:${path.node.value}`);
251
+ },
252
+ TemplateElement(path) {
253
+ parts.push(`t:${path.node.value.raw}`);
254
+ },
255
+ JSXText(path) {
256
+ const value = path.node.value.trim();
257
+ if (value.length > 0) parts.push(`x:${value}`);
258
+ }
259
+ });
260
+ const comments = ast.comments;
261
+ if (Array.isArray(comments)) {
262
+ for (const comment of comments) if (typeof comment?.value === "string" && comment.value.length > 0) parts.push(`c:${comment.value}`);
263
+ }
264
+ return parts.join("\n");
265
+ } catch {
266
+ return source;
267
+ }
268
+ }
269
+ function createCssRuntimeAffectingSignature(source) {
270
+ return source.replace(CSS_BLOCK_COMMENT_RE, "").replace(CSS_AROUND_PUNCTUATION_RE, "$1").replace(CSS_TRAILING_DECLARATION_SEMICOLON_RE, "}").replace(CSS_WHITESPACE_RE, " ").trim();
271
+ }
272
+ function createRuntimeAffectingSourceSignature(source, type) {
273
+ if (type === "html") return createHtmlRuntimeAffectingSignature(source);
274
+ if (type === "js") return createJsRuntimeAffectingSignature(source);
275
+ if (type === "css") return createCssRuntimeAffectingSignature(source);
276
+ return source;
277
+ }
278
+ //#endregion
279
+ //#region src/bundlers/vite/bundle-state.ts
280
+ function createBundleBuildState() {
281
+ return {
282
+ iteration: 0,
283
+ sourceHashByFile: /* @__PURE__ */ new Map(),
284
+ runtimeAffectingSignatureByFile: /* @__PURE__ */ new Map(),
285
+ runtimeAffectingHashByFile: /* @__PURE__ */ new Map(),
286
+ linkedByEntry: /* @__PURE__ */ new Map(),
287
+ dependentsByLinkedFile: /* @__PURE__ */ new Map(),
288
+ generatorCandidateSignature: void 0
289
+ };
290
+ }
291
+ function createChangedByType() {
292
+ return {
293
+ html: /* @__PURE__ */ new Set(),
294
+ js: /* @__PURE__ */ new Set(),
295
+ css: /* @__PURE__ */ new Set(),
296
+ other: /* @__PURE__ */ new Set()
297
+ };
298
+ }
299
+ function createProcessFiles() {
300
+ return {
301
+ html: /* @__PURE__ */ new Set(),
302
+ js: /* @__PURE__ */ new Set(),
303
+ css: /* @__PURE__ */ new Set()
304
+ };
305
+ }
306
+ function readEntrySource(output) {
307
+ if (output.type === "chunk") return output.code;
308
+ return output.source.toString();
309
+ }
310
+ function classifyBundleEntry(file, opts) {
311
+ if (opts.cssMatcher(file) || isCSSRequest(file)) return "css";
312
+ if (opts.htmlMatcher(file)) return "html";
313
+ if (opts.jsMatcher(file) || opts.wxsMatcher(file)) return "js";
314
+ return "other";
315
+ }
316
+ function collectJsEntries(fileName, output, outDir, store) {
317
+ const entry = {
318
+ fileName,
319
+ output
320
+ };
321
+ if (!isJavaScriptEntry(entry)) return;
322
+ const absolute = toAbsoluteOutputPath(fileName, outDir);
323
+ store.set(absolute, entry);
324
+ }
325
+ function markProcessFile(type, file, processFiles) {
326
+ if (type === "html" || type === "js" || type === "css") processFiles[type].add(file);
327
+ }
328
+ function buildBundleSnapshot(bundle, opts, outDir, state, forceAll = false) {
329
+ const sourceHashByFile = /* @__PURE__ */ new Map();
330
+ const runtimeAffectingSignatureByFile = /* @__PURE__ */ new Map();
331
+ const runtimeAffectingHashByFile = /* @__PURE__ */ new Map();
332
+ const changedByType = createChangedByType();
333
+ const runtimeAffectingChangedByType = createChangedByType();
334
+ const processFiles = createProcessFiles();
335
+ const linkedImpactsByEntry = /* @__PURE__ */ new Map();
336
+ const jsEntries = /* @__PURE__ */ new Map();
337
+ const entries = [];
338
+ const firstRun = state.linkedByEntry.size === 0;
339
+ for (const [file, output] of Object.entries(bundle)) {
340
+ const type = classifyBundleEntry(file, opts);
341
+ const source = readEntrySource(output);
342
+ const hash = opts.cache.computeHash(source);
343
+ sourceHashByFile.set(file, hash);
344
+ const previousHash = state.sourceHashByFile.get(file);
345
+ const changed = previousHash == null || previousHash !== hash;
346
+ const previousRuntimeAffectingSignature = state.runtimeAffectingSignatureByFile.get(file);
347
+ const previousRuntimeAffectingHash = state.runtimeAffectingHashByFile.get(file);
348
+ const canReuseRuntimeAffectingSignature = !changed && previousRuntimeAffectingSignature != null && previousRuntimeAffectingHash != null;
349
+ const runtimeAffectingSignature = canReuseRuntimeAffectingSignature ? previousRuntimeAffectingSignature : createRuntimeAffectingSourceSignature(source, type);
350
+ const runtimeAffectingHash = canReuseRuntimeAffectingSignature ? previousRuntimeAffectingHash : opts.cache.computeHash(runtimeAffectingSignature);
351
+ runtimeAffectingSignatureByFile.set(file, runtimeAffectingSignature);
352
+ runtimeAffectingHashByFile.set(file, runtimeAffectingHash);
353
+ if (changed) changedByType[type].add(file);
354
+ if (previousRuntimeAffectingHash == null || previousRuntimeAffectingHash !== runtimeAffectingHash) runtimeAffectingChangedByType[type].add(file);
355
+ if (forceAll || firstRun) markProcessFile(type, file, processFiles);
356
+ else if (type === "html") processFiles.html.add(file);
357
+ else if (changed && (type === "js" || type === "css")) processFiles[type].add(file);
358
+ collectJsEntries(file, output, outDir, jsEntries);
359
+ entries.push({
360
+ file,
361
+ output,
362
+ source,
363
+ type
364
+ });
365
+ }
366
+ if (!forceAll && !firstRun) for (const changedFile of changedByType.js) {
367
+ const dependents = state.dependentsByLinkedFile.get(changedFile);
368
+ if (!dependents) continue;
369
+ for (const entryFile of dependents) {
370
+ processFiles.js.add(entryFile);
371
+ let impacts = linkedImpactsByEntry.get(entryFile);
372
+ if (!impacts) {
373
+ impacts = /* @__PURE__ */ new Set();
374
+ linkedImpactsByEntry.set(entryFile, impacts);
375
+ }
376
+ impacts.add(changedFile);
377
+ }
378
+ }
379
+ return {
380
+ entries,
381
+ jsEntries,
382
+ sourceHashByFile,
383
+ runtimeAffectingSignatureByFile,
384
+ runtimeAffectingHashByFile,
385
+ changedByType,
386
+ runtimeAffectingChangedByType,
387
+ processFiles,
388
+ linkedImpactsByEntry
389
+ };
390
+ }
391
+ function invertLinkedByEntry(linkedByEntry) {
392
+ const dependentsByLinkedFile = /* @__PURE__ */ new Map();
393
+ for (const [entryFile, linkedFiles] of linkedByEntry.entries()) for (const linkedFile of linkedFiles) {
394
+ let dependents = dependentsByLinkedFile.get(linkedFile);
395
+ if (!dependents) {
396
+ dependents = /* @__PURE__ */ new Set();
397
+ dependentsByLinkedFile.set(linkedFile, dependents);
398
+ }
399
+ dependents.add(entryFile);
400
+ }
401
+ return dependentsByLinkedFile;
402
+ }
403
+ function updateBundleBuildState(state, snapshot, linkedByEntry, options = {}) {
404
+ const incremental = options.incremental === true;
405
+ state.iteration += 1;
406
+ state.sourceHashByFile = incremental ? new Map([...state.sourceHashByFile, ...snapshot.sourceHashByFile]) : snapshot.sourceHashByFile;
407
+ state.runtimeAffectingSignatureByFile = incremental ? new Map([...state.runtimeAffectingSignatureByFile, ...snapshot.runtimeAffectingSignatureByFile]) : snapshot.runtimeAffectingSignatureByFile;
408
+ state.runtimeAffectingHashByFile = incremental ? new Map([...state.runtimeAffectingHashByFile, ...snapshot.runtimeAffectingHashByFile]) : snapshot.runtimeAffectingHashByFile;
409
+ state.linkedByEntry = incremental ? new Map([...state.linkedByEntry, ...linkedByEntry]) : linkedByEntry;
410
+ state.dependentsByLinkedFile = invertLinkedByEntry(state.linkedByEntry);
411
+ }
412
+ //#endregion
413
+ export { stripRequestQuery as _, createBundleModuleGraphOptions as a, toAbsoluteOutputPath as b, hasBundlerGeneratedCssMarker as c, resolvePluginDisabledState as d, cleanUrl as f, isSourceStyleRequest as g, slash as h, applyLinkedResults as i, stripBundlerGeneratedCssMarkers as l, isCSSRequest as m, createBundleBuildState as n, pushConcurrentTaskFactories as o, formatPostcssSourceMap as p, updateBundleBuildState as r, createBundlerGeneratedCssMarker as s, buildBundleSnapshot as t, resolvePackageDir as u, normalizeOutputPathKey as v, resolveOutputSpecifier as y };
@@ -2,15 +2,17 @@ import type { CacheValue, HashMapKey, ICreateCacheReturnType } from '../../cache
2
2
  export interface ProcessCachedTaskOptions<TValue extends CacheValue> {
3
3
  cache: ICreateCacheReturnType;
4
4
  cacheKey: string;
5
- hashKey?: HashMapKey;
6
- rawSource?: string;
7
- hash?: string;
8
- readCache?: () => TValue | undefined;
9
- applyResult: (value: TValue) => void | Promise<void>;
5
+ hashKey?: HashMapKey | undefined;
6
+ rawSource?: string | undefined;
7
+ hash?: string | undefined;
8
+ readCache?: (() => TValue | undefined) | undefined;
9
+ applyResult: (value: TValue, meta: {
10
+ cacheHit: boolean;
11
+ }) => void | Promise<void>;
10
12
  transform: () => Promise<{
11
13
  result: TValue;
12
- cacheValue?: CacheValue;
14
+ cacheValue?: CacheValue | undefined;
13
15
  }>;
14
- onCacheHit?: () => void;
16
+ onCacheHit?: (() => void) | undefined;
15
17
  }
16
18
  export declare function processCachedTask<TValue extends CacheValue>({ cache, cacheKey, hashKey, rawSource, hash, readCache, applyResult, transform, onCacheHit, }: ProcessCachedTaskOptions<TValue>): Promise<void>;
@@ -1,2 +1 @@
1
- export declare function removeUnsupportedMiniProgramAtRules(css: string): string;
2
- export declare function removeUnsupportedAtSupports(css: string): string;
1
+ export { removeUnsupportedAtSupports, removeUnsupportedMiniProgramAtRules, } from '@weapp-tailwindcss/postcss';
@@ -1,3 +1 @@
1
- export { removeUnsupportedAtSupports, removeUnsupportedMiniProgramAtRules } from './css-cleanup/at-rules';
2
- export declare function hoistTailwindPreflightBase(css: string): string;
3
- export declare function finalizeMiniProgramCss(css: string): string;
1
+ export { finalizeMiniProgramCss, hoistTailwindPreflightBase, removeUnsupportedAtSupports, removeUnsupportedMiniProgramAtRules, } from '@weapp-tailwindcss/postcss';
@@ -1,8 +1,8 @@
1
1
  import type { AppType } from '../../types';
2
2
  export interface ResolveTailwindcssImportOptions {
3
- join?: (base: string, subpath: string) => string;
4
- appType?: AppType;
5
- rootImport?: string;
3
+ join?: ((base: string, subpath: string) => string) | undefined;
4
+ appType?: AppType | undefined;
5
+ rootImport?: string | undefined;
6
6
  }
7
7
  export declare function resolveTailwindcssImport(specifier: string, pkgDir: string, options?: ResolveTailwindcssImportOptions): string | null;
8
8
  export declare function rewriteTailwindcssImportsInCode(code: string, pkgDir: string, options?: ResolveTailwindcssImportOptions): string | undefined;
@@ -0,0 +1,3 @@
1
+ export declare function createBundlerGeneratedCssMarker(bundler: 'vite' | 'webpack', file: string): string;
2
+ export declare function hasBundlerGeneratedCssMarker(source: unknown): boolean;
3
+ export declare function stripBundlerGeneratedCssMarkers(source: string): string;
@@ -1,13 +1,21 @@
1
+ interface TailwindDirectiveOptions {
2
+ importFallback?: boolean | undefined;
3
+ }
1
4
  export declare function parseImportRequest(params: string): string | undefined;
2
- export declare function removeTailwindSourceDirectives(rawSource: string): string;
3
- export declare function hasTailwindSourceDirectives(rawSource: string): boolean;
4
- export declare function hasTailwindRootDirectives(rawSource: string): boolean;
5
+ export declare function normalizeTailwindSourceForGenerator(rawSource: string, options?: TailwindDirectiveOptions): string;
6
+ export declare function normalizeTailwindV3CssEntrySource(rawSource: string): string;
7
+ export declare function normalizeTailwindSourceDirectives(rawSource: string, options?: TailwindDirectiveOptions): string;
8
+ export declare function removeTailwindSourceDirectives(rawSource: string, options?: TailwindDirectiveOptions): string;
9
+ export declare function hasTailwindSourceDirectives(rawSource: string, options?: TailwindDirectiveOptions): boolean;
10
+ export declare function hasTailwindRootDirectives(rawSource: string, options?: TailwindDirectiveOptions): boolean;
5
11
  export declare function hasTailwindApplyDirective(rawSource: string): boolean;
6
12
  export declare function resolveCssEntrySource(rawSource: string, base: string, options?: {
7
13
  removeConfig?: boolean;
14
+ importFallback?: boolean;
8
15
  }): {
9
16
  css: string;
10
17
  config: string | undefined;
11
18
  configRequest: string | undefined;
12
19
  base: string;
13
20
  } | undefined;
21
+ export {};
@@ -8,7 +8,19 @@ export declare const TAILWIND_BANNER_GLOBAL_RE: RegExp;
8
8
  export declare const VITE_MARKER_RE: RegExp;
9
9
  export declare function createCssAppend(base: string, extra: string): string;
10
10
  export declare function splitTailwindV4GeneratedCss(rawSource: string, rawTailwindCss: string): string | undefined;
11
+ export declare function splitTailwindV4GeneratedCssBySourceOrder(rawSource: string, rawTailwindCss: string): {
12
+ before: string;
13
+ after: string;
14
+ } | undefined;
15
+ export declare function splitGeneratorPlaceholderCssBySourceOrder(rawSource: string, rawTailwindCss?: string): {
16
+ before: string;
17
+ after: string;
18
+ } | undefined;
11
19
  export declare function removeTailwindGeneratedCssByBanner(rawSource: string): string | undefined;
20
+ export declare function splitTailwindGeneratedCssByBanner(rawSource: string, start?: number): {
21
+ before: string;
22
+ after: string;
23
+ } | undefined;
12
24
  export declare function stripTailwindBanner(css: string): string;
13
25
  export declare function stripTailwindBanners(css: string): string;
14
26
  export declare function stripGeneratorPlaceholderMarkers(css: string): string;
@@ -1,11 +1,14 @@
1
+ export interface SourceSideCssEntrySource {
2
+ css: string;
3
+ config?: string | undefined;
4
+ configRequest?: string | undefined;
5
+ base: string;
6
+ file: string;
7
+ }
1
8
  export declare function resolveSourceSideCssEntrySource(file: string, sourceOptions: {
2
9
  projectRoot?: string;
3
10
  cwd?: string;
11
+ outputRoot?: string;
4
12
  }, resolveOptions?: {
5
13
  removeConfig?: boolean;
6
- }): {
7
- css: string;
8
- config: string | undefined;
9
- configRequest: string | undefined;
10
- base: string;
11
- } | undefined;
14
+ }): SourceSideCssEntrySource | undefined;
@@ -1,10 +1,24 @@
1
1
  import type { IStyleHandlerOptions } from '@weapp-tailwindcss/postcss/types';
2
2
  import type { NormalizedWeappTailwindcssGeneratorOptions, TailwindResolvedSource } from '../../../generator';
3
+ import type { TailwindSourceEntry } from '../../../tailwindcss/source-scan';
3
4
  import type { InternalUserDefinedOptions } from '../../../types';
4
5
  interface GeneratorSourceRuntimeState {
5
6
  twPatcher: InternalUserDefinedOptions['twPatcher'];
6
7
  }
8
+ interface GeneratorSourceSelectionOptions {
9
+ runtime?: Set<string> | undefined;
10
+ getSourceCandidatesForEntries?: ((entries: TailwindSourceEntry[] | undefined) => Set<string>) | undefined;
11
+ }
12
+ export interface GeneratorSourceMetadata {
13
+ matchedCssSourceFile?: string | undefined;
14
+ sourceBase?: string | undefined;
15
+ sourceCss?: string | undefined;
16
+ }
17
+ export type GeneratorResolvedSource = TailwindResolvedSource & {
18
+ __weappTailwindcssMeta?: GeneratorSourceMetadata | undefined;
19
+ };
7
20
  export declare function resolveCssSourceBase(file: string, cssHandlerOptions: IStyleHandlerOptions): string;
8
- export declare function resolveGeneratorSource(majorVersion: number | undefined, runtimeState: GeneratorSourceRuntimeState, rawSource: string, file: string, cssHandlerOptions: IStyleHandlerOptions, generatorOptions?: NormalizedWeappTailwindcssGeneratorOptions): Promise<import("@/generator").TailwindV3ResolvedSource | import("tailwindcss-patch").TailwindV4ResolvedSource>;
9
- export declare function resolveGeneratorSources(majorVersion: number | undefined, runtimeState: GeneratorSourceRuntimeState, rawSource: string, file: string, cssHandlerOptions: IStyleHandlerOptions, generatorOptions?: NormalizedWeappTailwindcssGeneratorOptions): Promise<TailwindResolvedSource[]>;
21
+ export declare function resolveGeneratorSource(majorVersion: number | undefined, runtimeState: GeneratorSourceRuntimeState, rawSource: string, file: string, cssHandlerOptions: IStyleHandlerOptions, generatorOptions?: NormalizedWeappTailwindcssGeneratorOptions, selectionOptions?: GeneratorSourceSelectionOptions): Promise<import("tailwindcss-patch").TailwindV4ResolvedSource | import("@/generator").TailwindV3ResolvedSource | undefined>;
22
+ export declare function resolveGeneratorSources(majorVersion: number | undefined, runtimeState: GeneratorSourceRuntimeState, rawSource: string, file: string, cssHandlerOptions: IStyleHandlerOptions, generatorOptions?: NormalizedWeappTailwindcssGeneratorOptions, selectionOptions?: GeneratorSourceSelectionOptions): Promise<TailwindResolvedSource[]>;
23
+ export declare function resolveGeneratorSourceEntries(source: TailwindResolvedSource, runtimeState?: GeneratorSourceRuntimeState): Promise<TailwindSourceEntry[] | undefined>;
10
24
  export {};
@@ -0,0 +1,10 @@
1
+ export declare function wrapUserLayerComponentsCss(css: string): string;
2
+ export declare function extractMarkedUserLayerComponentsCss(css: string): {
3
+ layers: string[];
4
+ rest: string;
5
+ };
6
+ export declare function reorderMarkedUserLayerComponentsCss(css: string): string;
7
+ export declare function mergeMarkedUserLayerComponentsCss(baseCss: string, markedCss: string): {
8
+ css: string;
9
+ merged: boolean;
10
+ };
@@ -1,9 +1,10 @@
1
1
  import type { IStyleHandlerOptions } from '@weapp-tailwindcss/postcss/types';
2
+ import type { TailwindSourceEntry } from '../../tailwindcss/source-scan';
2
3
  import type { InternalUserDefinedOptions } from '../../types';
3
- export { hasTailwindSourceDirectives, removeTailwindSourceDirectives, resolveCssEntrySource, } from './generator-css/directives';
4
+ export { hasTailwindSourceDirectives, normalizeTailwindSourceForGenerator, removeTailwindSourceDirectives, resolveCssEntrySource, } from './generator-css/directives';
4
5
  export { removeTailwindApplyRules, } from './generator-css/legacy-compat';
5
6
  export { inheritLegacyUnitConvertedDeclarations, } from './generator-css/legacy-units';
6
- export { createCssAppend, hasTailwindGeneratedCss, hasTailwindGeneratedCssMarkers, removeTailwindGeneratedCssByBanner, splitTailwindV4GeneratedCss, stripGeneratorPlaceholderMarkers, stripTailwindBanner, stripTailwindBanners, } from './generator-css/markers';
7
+ export { createCssAppend, hasTailwindGeneratedCss, hasTailwindGeneratedCssMarkers, removeTailwindGeneratedCssByBanner, splitGeneratorPlaceholderCssBySourceOrder, splitTailwindGeneratedCssByBanner, splitTailwindV4GeneratedCss, splitTailwindV4GeneratedCssBySourceOrder, stripGeneratorPlaceholderMarkers, stripTailwindBanner, stripTailwindBanners, } from './generator-css/markers';
7
8
  export { resolveGeneratorSource, } from './generator-css/source-resolver';
8
9
  export interface GenerateCssByGeneratorOptions {
9
10
  opts: InternalUserDefinedOptions;
@@ -16,14 +17,17 @@ export interface GenerateCssByGeneratorOptions {
16
17
  file: string;
17
18
  cssHandlerOptions: IStyleHandlerOptions;
18
19
  cssUserHandlerOptions: IStyleHandlerOptions;
20
+ getSourceCandidatesForEntries?: ((entries: TailwindSourceEntry[] | undefined) => Set<string>) | undefined;
19
21
  styleHandler: InternalUserDefinedOptions['styleHandler'];
20
22
  debug: (format: string, ...args: unknown[]) => void;
23
+ previousCss?: string | undefined;
21
24
  }
22
25
  export interface GenerateCssByGeneratorResult {
23
26
  css: string;
24
27
  target: string;
25
28
  source: 'generator';
26
29
  dependencies: string[];
30
+ incremental?: boolean | undefined;
27
31
  }
28
32
  export declare function isPureLocalCssImportWrapper(css: string): boolean;
29
33
  export declare function generateCssByGenerator(options: GenerateCssByGeneratorOptions): Promise<GenerateCssByGeneratorResult | undefined>;
@@ -0,0 +1,22 @@
1
+ export interface HmrTimingDetails {
2
+ emit?: boolean;
3
+ file?: string;
4
+ hooks?: Record<string, HmrTimingHookSummary>;
5
+ metric?: 'hook' | 'total';
6
+ wallMs?: number;
7
+ }
8
+ export interface HmrTimingHookSummary {
9
+ count: number;
10
+ durationMs: number;
11
+ maxMs: number;
12
+ }
13
+ type HmrTimingBundler = 'vite' | 'webpack' | 'gulp';
14
+ export interface HmrTimingRecorder {
15
+ emitTotal: (phase?: string) => void;
16
+ measure: <T>(phase: string, task: () => T | Promise<T>, details?: HmrTimingDetails) => Promise<T>;
17
+ record: (phase: string, durationMs: number, details?: HmrTimingDetails) => void;
18
+ }
19
+ export declare function shouldEmitHmrTiming(): boolean;
20
+ export declare function emitHmrTiming(bundler: HmrTimingBundler, phase: string, durationMs: number, details?: HmrTimingDetails): void;
21
+ export declare function createHmrTimingRecorder(bundler: HmrTimingBundler): HmrTimingRecorder;
22
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare function stripRequestQuery(request: string): string;
2
+ export declare function isSourceStyleRequest(request: string | undefined): boolean;
@@ -31,6 +31,7 @@ export interface BundleBuildState {
31
31
  runtimeAffectingHashByFile: Map<string, string>;
32
32
  linkedByEntry: Map<string, Set<string>>;
33
33
  dependentsByLinkedFile: Map<string, Set<string>>;
34
+ generatorCandidateSignature?: string | undefined;
34
35
  }
35
36
  interface UpdateBundleBuildStateOptions {
36
37
  incremental?: boolean;