weapp-tailwindcss 5.0.0-next.11 → 5.0.0-next.13

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 (81) hide show
  1. package/dist/{bundle-state-BRkhpjio.js → bundle-state-Bz8vLnCf.js} +3 -2
  2. package/dist/{bundle-state-BrtFgX-A.mjs → bundle-state-CP2XS3Uj.mjs} +3 -2
  3. package/dist/bundlers/shared/css-cleanup.d.ts +6 -1
  4. package/dist/bundlers/shared/generator-css/source-files.d.ts +9 -6
  5. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +16 -2
  6. package/dist/bundlers/shared/generator-css.d.ts +4 -0
  7. package/dist/bundlers/shared/hmr-timing.d.ts +18 -1
  8. package/dist/bundlers/vite/bundle-state.d.ts +1 -0
  9. package/dist/bundlers/vite/css-finalizer.d.ts +2 -0
  10. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -1
  11. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +1 -0
  12. package/dist/bundlers/vite/generate-bundle.d.ts +8 -1
  13. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +1 -0
  14. package/dist/bundlers/vite/runtime-class-set.d.ts +4 -1
  15. package/dist/bundlers/vite/source-candidates.d.ts +11 -0
  16. package/dist/bundlers/vite/source-scan.d.ts +18 -1
  17. package/dist/bundlers/vite/static-config-content.d.ts +5 -0
  18. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +5 -0
  19. package/dist/cli.js +453 -9
  20. package/dist/cli.mjs +451 -8
  21. package/dist/core.js +1 -1
  22. package/dist/core.mjs +1 -1
  23. package/dist/css-macro/postcss.js +1 -1
  24. package/dist/css-macro/postcss.mjs +1 -1
  25. package/dist/css-macro.js +2 -2
  26. package/dist/css-macro.mjs +2 -2
  27. package/dist/defaults.js +1 -1
  28. package/dist/defaults.mjs +1 -1
  29. package/dist/generator-C9H44wEF.mjs +32 -0
  30. package/dist/generator-CRORPkpW.js +55 -0
  31. package/dist/generator.js +12 -11
  32. package/dist/generator.mjs +2 -1
  33. package/dist/gulp.js +49 -13
  34. package/dist/gulp.mjs +46 -10
  35. package/dist/{incremental-runtime-class-set-CBMefNHQ.js → incremental-runtime-class-set-DN9KKjSi.js} +512 -103
  36. package/dist/{incremental-runtime-class-set-DaS2yw5c.mjs → incremental-runtime-class-set-Dbn4yPfZ.mjs} +491 -88
  37. package/dist/index.js +4 -4
  38. package/dist/index.mjs +4 -4
  39. package/dist/{postcss-BdcRlSpp.js → postcss-Ab7YzAbs.js} +30 -19
  40. package/dist/{postcss-Bs-RbNzK.js → postcss-CZE8k8oP.js} +59 -53
  41. package/dist/{postcss-xZDiTRII.mjs → postcss-CtlrNknb.mjs} +19 -8
  42. package/dist/postcss.js +1 -1
  43. package/dist/postcss.mjs +1 -1
  44. package/dist/{precheck-D5eEdqeH.js → precheck-CRX-pMKJ.js} +37 -17
  45. package/dist/{precheck-DtBGFS-n.mjs → precheck-SG48aLG2.mjs} +29 -9
  46. package/dist/presets.js +6 -6
  47. package/dist/presets.mjs +4 -4
  48. package/dist/source-candidates-C4YgmZ8A.js +274 -0
  49. package/dist/source-candidates-CyupdLKi.mjs +259 -0
  50. package/dist/tailwindcss/runtime/cache.d.ts +1 -0
  51. package/dist/tailwindcss/v3-engine/types.d.ts +3 -0
  52. package/dist/tailwindcss/v4-engine/types.d.ts +8 -0
  53. package/dist/{tailwindcss-DGM8lHUj.mjs → tailwindcss-BbTVeQkG.mjs} +9 -4
  54. package/dist/{tailwindcss-B78nj6n7.js → tailwindcss-DZ6jVYb4.js} +21 -16
  55. package/dist/v3-engine-D61eilBl.mjs +3208 -0
  56. package/dist/v3-engine-DwV1E6rX.js +3461 -0
  57. package/dist/{vite-C8S1wfyQ.mjs → vite-Ti_qSctn.mjs} +380 -542
  58. package/dist/{vite-BEj9JOOA.js → vite-xKS6RvLR.js} +385 -550
  59. package/dist/vite.js +1 -1
  60. package/dist/vite.mjs +1 -1
  61. package/dist/weapp-tw-css-import-rewrite-loader.js +29 -9
  62. package/dist/weapp-tw-runtime-classset-loader.js +1 -1
  63. package/dist/{webpack-ZGIKKpFf.mjs → webpack-DvptFz7B.mjs} +36 -19
  64. package/dist/{webpack-Dm1IXTIh.js → webpack-wfNutjMm.js} +40 -23
  65. package/dist/webpack.js +1 -1
  66. package/dist/webpack.mjs +1 -1
  67. package/package.json +3 -3
  68. package/dist/cache-B_9E7FxF.js +0 -517
  69. package/dist/cache-DEDxBMIw.mjs +0 -443
  70. package/dist/generator-CahkD2vq.mjs +0 -1469
  71. package/dist/generator-Ck1Dd1V0.js +0 -1568
  72. package/dist/runtime-patch-CqB-A4zA.js +0 -85
  73. package/dist/runtime-patch-DGKsVkiG.mjs +0 -71
  74. package/dist/source-scan-CIVTa3Cj.js +0 -297
  75. package/dist/source-scan-CJ0y0XBj.mjs +0 -258
  76. /package/dist/{constants-BeeyfJ9k.js → constants-BoB_6lFw.js} +0 -0
  77. /package/dist/{constants-BG12WAKw.mjs → constants-E_loJC49.mjs} +0 -0
  78. /package/dist/{logger-EVNB9z7i.js → logger-BRy6XPQ2.js} +0 -0
  79. /package/dist/{logger-CZUxvJJD.mjs → logger-Bub1jggA.mjs} +0 -0
  80. /package/dist/{utils-CGBVVNm6.mjs → utils-CycMvPn_.mjs} +0 -0
  81. /package/dist/{utils-4ODFyoqD.js → utils-D0MZP_tr.js} +0 -0
@@ -1,443 +0,0 @@
1
- import { createRequire } from "node:module";
2
- import path from "node:path";
3
- import process from "node:process";
4
- import { logger } from "@weapp-tailwindcss/logger";
5
- import { defuOverrideArray } from "@weapp-tailwindcss/shared";
6
- import { TailwindcssPatcher } from "tailwindcss-patch";
7
- import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
8
- import { fileURLToPath } from "node:url";
9
- //#region src/context/workspace.ts
10
- const IGNORED_WORKSPACE_DIRS = new Set([
11
- "node_modules",
12
- ".git",
13
- ".hg",
14
- ".svn",
15
- ".turbo",
16
- ".output",
17
- ".next",
18
- "dist",
19
- "build"
20
- ]);
21
- function findWorkspaceRoot(startDir) {
22
- if (!startDir) return;
23
- let current = path.resolve(startDir);
24
- while (true) {
25
- if (existsSync(path.join(current, "pnpm-workspace.yaml"))) return current;
26
- const parent = path.dirname(current);
27
- if (parent === current) return;
28
- current = parent;
29
- }
30
- }
31
- function findNearestPackageRoot(startDir) {
32
- if (!startDir) return;
33
- let current = path.resolve(startDir);
34
- while (true) {
35
- if (existsSync(path.join(current, "package.json"))) return current;
36
- const parent = path.dirname(current);
37
- if (parent === current) return;
38
- current = parent;
39
- }
40
- }
41
- function findWorkspacePackageDir(rootDir, packageName) {
42
- const visited = /* @__PURE__ */ new Set();
43
- const queue = [path.resolve(rootDir)];
44
- while (queue.length > 0) {
45
- const current = queue.shift();
46
- const normalized = path.normalize(current);
47
- if (visited.has(normalized)) continue;
48
- visited.add(normalized);
49
- try {
50
- const pkgPath = path.join(normalized, "package.json");
51
- if (existsSync(pkgPath)) {
52
- if (JSON.parse(readFileSync(pkgPath, "utf8"))?.name === packageName) return normalized;
53
- }
54
- } catch {}
55
- let entries;
56
- try {
57
- entries = readdirSync(normalized, { withFileTypes: true });
58
- } catch {
59
- continue;
60
- }
61
- for (const entry of entries) {
62
- if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || entry.isSymbolicLink?.()) continue;
63
- queue.push(path.join(normalized, entry.name));
64
- }
65
- }
66
- }
67
- //#endregion
68
- //#region src/utils/object.ts
69
- function definedEntries(value) {
70
- return Object.entries(value).filter(([, item]) => item !== void 0);
71
- }
72
- function omitUndefined(value) {
73
- return Object.fromEntries(definedEntries(value));
74
- }
75
- //#endregion
76
- //#region src/tailwindcss/patcher-options.ts
77
- function resolveTailwindcssOptions(options) {
78
- return options?.tailwindcss ?? options?.tailwind;
79
- }
80
- function normalizeExtendLengthUnits(value) {
81
- if (value === false) return false;
82
- if (value === true) return { enabled: true };
83
- if (value && typeof value === "object") return {
84
- enabled: true,
85
- ...value
86
- };
87
- }
88
- function normalizeTailwindcssPatcherOptions(options) {
89
- return options;
90
- }
91
- //#endregion
92
- //#region src/tailwindcss/patcher-resolve.ts
93
- const GENERIC_RELATIVE_SPECIFIERS = [".", ".."];
94
- const DEFAULT_TAILWIND_CONFIG_SPECIFIERS = ["stubs/config.full.js", "defaultConfig.js"];
95
- const TAILWIND_CONFIG_FILES = [
96
- "tailwind.config.js",
97
- "tailwind.config.cjs",
98
- "tailwind.config.mjs",
99
- "tailwind.config.ts",
100
- "tailwind.config.cts",
101
- "tailwind.config.mts"
102
- ];
103
- function isPathSpecifier(specifier) {
104
- if (!specifier) return false;
105
- if (specifier.startsWith("file://")) return true;
106
- if (path.isAbsolute(specifier)) return true;
107
- return GENERIC_RELATIVE_SPECIFIERS.some((prefix) => specifier.startsWith(`${prefix}/`) || specifier.startsWith(`${prefix}\\`));
108
- }
109
- function resolveModuleFromPaths(specifier, paths) {
110
- if (!specifier || isPathSpecifier(specifier) || paths.length === 0) return;
111
- try {
112
- return createRequire(import.meta.url).resolve(specifier, { paths });
113
- } catch {
114
- return;
115
- }
116
- }
117
- function resolveTailwindConfigFallback(packageName, paths) {
118
- if (!packageName) return;
119
- for (const suffix of DEFAULT_TAILWIND_CONFIG_SPECIFIERS) {
120
- const resolved = resolveModuleFromPaths(`${packageName}/${suffix}`, paths);
121
- if (resolved) return resolved;
122
- }
123
- }
124
- function appendNodeModules(paths, dir) {
125
- if (!dir) return;
126
- const nodeModulesDir = path.join(dir, "node_modules");
127
- if (existsSync(nodeModulesDir)) paths.add(nodeModulesDir);
128
- }
129
- function findTailwindConfig(searchRoots) {
130
- for (const root of searchRoots) for (const file of TAILWIND_CONFIG_FILES) {
131
- const candidate = path.resolve(root, file);
132
- if (existsSync(candidate)) return candidate;
133
- }
134
- }
135
- function createDefaultResolvePaths(basedir) {
136
- const paths = /* @__PURE__ */ new Set();
137
- let fallbackCandidates = [];
138
- if (basedir) {
139
- const resolvedBase = path.resolve(basedir);
140
- appendNodeModules(paths, resolvedBase);
141
- fallbackCandidates.push(resolvedBase);
142
- const packageRoot = findNearestPackageRoot(resolvedBase);
143
- if (packageRoot) {
144
- appendNodeModules(paths, packageRoot);
145
- fallbackCandidates.push(packageRoot);
146
- }
147
- }
148
- const cwd = process.cwd();
149
- appendNodeModules(paths, cwd);
150
- try {
151
- const modulePath = fileURLToPath(import.meta.url);
152
- const candidate = existsSync(modulePath) && !path.extname(modulePath) ? modulePath : path.dirname(modulePath);
153
- paths.add(candidate);
154
- } catch {
155
- paths.add(import.meta.url);
156
- }
157
- if (paths.size === 0) {
158
- fallbackCandidates = fallbackCandidates.filter(Boolean);
159
- if (fallbackCandidates.length === 0) fallbackCandidates.push(cwd);
160
- for (const candidate of fallbackCandidates) paths.add(candidate);
161
- }
162
- return [...paths];
163
- }
164
- //#endregion
165
- //#region src/tailwindcss/version.ts
166
- function normalizeSupportedTailwindcssMajorVersion(version) {
167
- return version === 3 || version === 4 ? version : void 0;
168
- }
169
- function readPackageJson(packageJsonPath) {
170
- try {
171
- return JSON.parse(readFileSync(packageJsonPath, "utf8"));
172
- } catch {
173
- return;
174
- }
175
- }
176
- function findPackageJsonDeclaringPackage(packageName, base) {
177
- let current = path.resolve(base);
178
- while (true) {
179
- const pkgPath = path.join(current, "package.json");
180
- if (existsSync(pkgPath)) {
181
- const pkg = readPackageJson(pkgPath);
182
- if (readDeclaredPackageVersion(packageName, pkg)) return pkgPath;
183
- if (pkg?.name !== "weapp-tailwindcss") return;
184
- }
185
- const parent = path.dirname(current);
186
- if (parent === current) return;
187
- current = parent;
188
- }
189
- }
190
- function readDeclaredPackageVersion(packageName, pkg) {
191
- return pkg?.dependencies?.[packageName] ?? pkg?.devDependencies?.[packageName] ?? pkg?.peerDependencies?.[packageName] ?? pkg?.optionalDependencies?.[packageName];
192
- }
193
- function readDeclaredPackageMajorVersion(version) {
194
- const match = version?.match(/(?:^|\D)([34])(?:\.|\b)/);
195
- return normalizeSupportedTailwindcssMajorVersion(match ? Number(match[1]) : void 0);
196
- }
197
- function readInstalledPackageMajorVersion(packageName, base) {
198
- const packageJsonPath = findPackageJsonDeclaringPackage(packageName, base);
199
- if (!packageJsonPath) return;
200
- const declaredVersion = readDeclaredPackageVersion(packageName, readPackageJson(packageJsonPath));
201
- if (!declaredVersion) return;
202
- try {
203
- const pkg = createRequire(packageJsonPath)(`${packageName}/package.json`);
204
- return normalizeSupportedTailwindcssMajorVersion(Number(pkg.version?.split(".")[0]));
205
- } catch {
206
- return readDeclaredPackageMajorVersion(declaredVersion);
207
- }
208
- }
209
- //#endregion
210
- //#region src/tailwindcss/patcher.ts
211
- function createFallbackTailwindcssPatcher() {
212
- return {
213
- packageInfo: {
214
- name: "tailwindcss",
215
- version: void 0,
216
- rootPath: "",
217
- packageJsonPath: "",
218
- packageJson: {}
219
- },
220
- majorVersion: 4,
221
- async getClassSet() {
222
- return /* @__PURE__ */ new Set();
223
- },
224
- async extract(_options) {
225
- return {
226
- classList: [],
227
- classSet: /* @__PURE__ */ new Set()
228
- };
229
- },
230
- async collectContentTokens() {
231
- return {
232
- entries: [],
233
- filesScanned: 0,
234
- sources: [],
235
- skippedFiles: []
236
- };
237
- }
238
- };
239
- }
240
- let hasLoggedMissingTailwind = false;
241
- const TAILWINDCSS_NOT_FOUND_RE = /tailwindcss not found/i;
242
- const UNABLE_TO_LOCATE_TAILWINDCSS_RE = /unable to locate tailwind css package/i;
243
- function isTailwindcssV4PackageName(packageName) {
244
- return packageName === "@tailwindcss/postcss" || packageName === "tailwindcss4" || Boolean(packageName && packageName.includes("tailwindcss4"));
245
- }
246
- function createTailwindcssPatcher(options) {
247
- const { basedir, cacheDir, supportCustomLengthUnitsPatch, tailwindcss, tailwindcssPatcherOptions } = options || {};
248
- const cache = { driver: "memory" };
249
- const normalizedBasedir = basedir ? path.resolve(basedir) : void 0;
250
- const cacheRoot = findNearestPackageRoot(normalizedBasedir) ?? normalizedBasedir ?? process.cwd();
251
- if (cacheDir) if (path.isAbsolute(cacheDir)) cache.dir = cacheDir;
252
- else if (normalizedBasedir) cache.dir = path.resolve(normalizedBasedir, cacheDir);
253
- else cache.dir = path.resolve(process.cwd(), cacheDir);
254
- else cache.dir = path.join(cacheRoot, "node_modules", ".cache", "tailwindcss-patch");
255
- if (normalizedBasedir) cache.cwd = normalizedBasedir;
256
- const resolvePaths = createDefaultResolvePaths(cache.cwd ?? normalizedBasedir ?? process.cwd());
257
- const normalizedUserOptions = normalizeTailwindcssPatcherOptions(tailwindcssPatcherOptions);
258
- const extendLengthUnits = normalizeExtendLengthUnits(supportCustomLengthUnitsPatch ?? true);
259
- const baseTailwindOptions = defuOverrideArray(tailwindcss ?? {}, omitUndefined({
260
- cwd: normalizedBasedir,
261
- resolve: { paths: resolvePaths }
262
- }));
263
- if (!baseTailwindOptions.packageName) baseTailwindOptions.packageName = "tailwindcss";
264
- if (!baseTailwindOptions.postcssPlugin) baseTailwindOptions.postcssPlugin = baseTailwindOptions.version === 4 || isTailwindcssV4PackageName(baseTailwindOptions.packageName) ? "@tailwindcss/postcss" : "tailwindcss";
265
- if (typeof baseTailwindOptions.postcssPlugin === "string") {
266
- const resolvedPlugin = resolveModuleFromPaths(baseTailwindOptions.postcssPlugin, resolvePaths);
267
- if (resolvedPlugin) baseTailwindOptions.postcssPlugin = resolvedPlugin;
268
- }
269
- const baseOptions = omitUndefined({
270
- projectRoot: normalizedBasedir,
271
- cache,
272
- tailwindcss: baseTailwindOptions,
273
- apply: omitUndefined({
274
- exposeContext: true,
275
- extendLengthUnits
276
- })
277
- });
278
- const resolvedOptions = defuOverrideArray(normalizedUserOptions ?? {}, baseOptions);
279
- const resolvedTailwindOptions = resolvedOptions.tailwindcss;
280
- if (resolvedTailwindOptions) {
281
- const existingResolve = resolvedTailwindOptions.resolve ?? {};
282
- const sourcePaths = Array.isArray(existingResolve.paths) && existingResolve.paths.length > 0 ? existingResolve.paths : resolvePaths;
283
- resolvedTailwindOptions.resolve = {
284
- ...existingResolve,
285
- paths: [...new Set(sourcePaths)]
286
- };
287
- logger.debug("Tailwind resolve config %O", {
288
- packageName: resolvedTailwindOptions.packageName,
289
- version: resolvedTailwindOptions.version,
290
- resolve: resolvedTailwindOptions.resolve,
291
- cwd: resolvedTailwindOptions.cwd
292
- });
293
- if (typeof resolvedTailwindOptions.postcssPlugin === "string") {
294
- const resolvedPlugin = resolveModuleFromPaths(resolvedTailwindOptions.postcssPlugin, resolvedTailwindOptions.resolve?.paths ?? resolvePaths);
295
- if (resolvedPlugin) resolvedTailwindOptions.postcssPlugin = resolvedPlugin;
296
- }
297
- const searchRoots = /* @__PURE__ */ new Set();
298
- if (resolvedTailwindOptions.cwd) searchRoots.add(resolvedTailwindOptions.cwd);
299
- for (const resolvePath of resolvedTailwindOptions.resolve?.paths ?? []) {
300
- const parentDir = path.dirname(resolvePath);
301
- searchRoots.add(parentDir);
302
- }
303
- const configPath = findTailwindConfig(searchRoots);
304
- if (!resolvedTailwindOptions.config) if (configPath) resolvedTailwindOptions.config = configPath;
305
- else {
306
- const fallbackConfig = resolveTailwindConfigFallback(resolvedTailwindOptions.packageName, resolvedTailwindOptions.resolve.paths ?? resolvePaths);
307
- if (fallbackConfig) resolvedTailwindOptions.config = fallbackConfig;
308
- }
309
- if (!resolvedTailwindOptions.cwd && configPath) resolvedTailwindOptions.cwd = path.dirname(configPath);
310
- resolvedOptions.tailwindcss = resolvedTailwindOptions;
311
- }
312
- try {
313
- return new TailwindcssPatcher(resolvedOptions);
314
- } catch (error) {
315
- const searchPaths = resolvedOptions.tailwindcss?.resolve?.paths;
316
- if (error instanceof Error && TAILWINDCSS_NOT_FOUND_RE.test(error.message)) {
317
- if (!hasLoggedMissingTailwind) {
318
- logger.warn("Tailwind CSS 未安装,已跳过 Tailwind 运行时能力。若需使用 Tailwind 能力,请安装 tailwindcss。");
319
- hasLoggedMissingTailwind = true;
320
- }
321
- return createFallbackTailwindcssPatcher();
322
- }
323
- if (error instanceof Error && UNABLE_TO_LOCATE_TAILWINDCSS_RE.test(error.message)) logger.error("无法定位 Tailwind CSS 包 \"%s\",已尝试路径: %O", resolvedOptions.tailwindcss?.packageName, searchPaths);
324
- throw error;
325
- }
326
- }
327
- //#endregion
328
- //#region src/tailwindcss/runtime/cache.ts
329
- const runtimeClassSetCache = /* @__PURE__ */ new WeakMap();
330
- const runtimeFileSignatureCache = /* @__PURE__ */ new Map();
331
- let runtimeFileSignatureCacheClearTimer;
332
- const runtimeSignaturePatchersSymbol = Symbol.for("weapp-tailwindcss.runtimeSignaturePatchers");
333
- function getCacheEntry(twPatcher) {
334
- let entry = runtimeClassSetCache.get(twPatcher);
335
- if (!entry) {
336
- entry = {};
337
- runtimeClassSetCache.set(twPatcher, entry);
338
- }
339
- return entry;
340
- }
341
- function scheduleRuntimeConfigSignatureCacheClear() {
342
- if (runtimeFileSignatureCacheClearTimer) return;
343
- runtimeFileSignatureCacheClearTimer = setTimeout(() => {
344
- runtimeFileSignatureCache.clear();
345
- runtimeFileSignatureCacheClearTimer = void 0;
346
- }, 0);
347
- runtimeFileSignatureCacheClearTimer.unref?.();
348
- }
349
- function getFileSignature(filePath) {
350
- const cached = runtimeFileSignatureCache.get(filePath);
351
- if (cached !== void 0) return cached;
352
- let signature;
353
- try {
354
- const stats = statSync(filePath);
355
- signature = `${filePath}:${stats.size}:${stats.mtimeMs}`;
356
- } catch {
357
- signature = `${filePath}:missing`;
358
- }
359
- runtimeFileSignatureCache.set(filePath, signature);
360
- scheduleRuntimeConfigSignatureCacheClear();
361
- return signature;
362
- }
363
- function getTailwindTrackedFiles(twPatcher) {
364
- const tailwindOptions = resolveTailwindcssOptions(twPatcher.options);
365
- const tracked = /* @__PURE__ */ new Set();
366
- const configPath = tailwindOptions?.config;
367
- if (typeof configPath === "string" && configPath.length > 0) tracked.add(configPath);
368
- for (const entry of tailwindOptions?.v4?.cssEntries ?? []) if (typeof entry === "string" && entry.length > 0) tracked.add(entry);
369
- for (const source of tailwindOptions?.v4?.cssSources ?? []) {
370
- if (typeof source.file === "string" && source.file.length > 0) tracked.add(source.file);
371
- for (const dependency of source.dependencies ?? []) if (typeof dependency === "string" && dependency.length > 0) tracked.add(dependency);
372
- }
373
- return tracked;
374
- }
375
- function normalizeSignatureValue(value) {
376
- if (value == null) return "null";
377
- if (typeof value === "string") return value;
378
- if (typeof value === "number" || typeof value === "boolean") return String(value);
379
- if (Array.isArray(value)) return `[${value.map((item) => normalizeSignatureValue(item)).join(",")}]`;
380
- if (typeof value === "object") return `{${Object.entries(value).filter(([, item]) => item !== void 0).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => `${key}:${normalizeSignatureValue(item)}`).join(",")}}`;
381
- return String(value);
382
- }
383
- function readOptionalProperty(value, key) {
384
- if (typeof value !== "object" || value === null || !(key in value)) return;
385
- return value[key];
386
- }
387
- function getTailwindOptionsSignature(twPatcher) {
388
- const options = twPatcher.options;
389
- const tailwindOptions = resolveTailwindcssOptions(options);
390
- return normalizeSignatureValue({
391
- projectRoot: options?.projectRoot,
392
- packageName: tailwindOptions?.packageName,
393
- versionHint: readOptionalProperty(tailwindOptions, "versionHint"),
394
- cwd: tailwindOptions?.cwd,
395
- config: tailwindOptions?.config,
396
- v2: tailwindOptions?.v2,
397
- v3: tailwindOptions?.v3,
398
- v4: {
399
- base: tailwindOptions?.v4?.base,
400
- configuredBase: readOptionalProperty(tailwindOptions?.v4, "configuredBase"),
401
- css: tailwindOptions?.v4?.css,
402
- cssEntries: tailwindOptions?.v4?.cssEntries,
403
- cssSources: tailwindOptions?.v4?.cssSources,
404
- hasUserDefinedSources: readOptionalProperty(tailwindOptions?.v4, "hasUserDefinedSources"),
405
- sources: tailwindOptions?.v4?.sources
406
- }
407
- });
408
- }
409
- function getRuntimeTargetSignature(twPatcher) {
410
- const packageInfo = twPatcher.packageInfo;
411
- return [
412
- packageInfo?.name ?? "missing",
413
- packageInfo?.rootPath ?? "missing",
414
- packageInfo?.version ?? "unknown",
415
- twPatcher.majorVersion ?? "unknown",
416
- getTailwindOptionsSignature(twPatcher)
417
- ].join(":");
418
- }
419
- function getNestedPatchers(twPatcher) {
420
- const nested = twPatcher[runtimeSignaturePatchersSymbol];
421
- return Array.isArray(nested) && nested.length > 0 ? nested : void 0;
422
- }
423
- function getOwnRuntimeClassSetSignature(twPatcher) {
424
- const trackedFiles = [...getTailwindTrackedFiles(twPatcher)].sort((a, b) => a.localeCompare(b)).map(getFileSignature);
425
- return `${trackedFiles.length > 0 ? trackedFiles.join("|") : "files:missing"}|runtime:${getRuntimeTargetSignature(twPatcher)}`;
426
- }
427
- function invalidateRuntimeClassSet(twPatcher) {
428
- if (!twPatcher) return;
429
- const nestedPatchers = getNestedPatchers(twPatcher);
430
- if (nestedPatchers) for (const patcher of nestedPatchers) invalidateRuntimeClassSet(patcher);
431
- for (const trackedFile of getTailwindTrackedFiles(twPatcher)) runtimeFileSignatureCache.delete(trackedFile);
432
- runtimeClassSetCache.delete(twPatcher);
433
- }
434
- function getRuntimeClassSetCacheEntry(twPatcher) {
435
- return getCacheEntry(twPatcher);
436
- }
437
- function getRuntimeClassSetSignature(twPatcher) {
438
- const nestedPatchers = getNestedPatchers(twPatcher);
439
- if (nestedPatchers) return nestedPatchers.map(getOwnRuntimeClassSetSignature).sort((a, b) => a.localeCompare(b)).join("||");
440
- return getOwnRuntimeClassSetSignature(twPatcher);
441
- }
442
- //#endregion
443
- export { createTailwindcssPatcher as a, resolveTailwindcssOptions as c, findWorkspacePackageDir as d, findWorkspaceRoot as f, runtimeSignaturePatchersSymbol as i, omitUndefined as l, getRuntimeClassSetSignature as n, readInstalledPackageMajorVersion as o, invalidateRuntimeClassSet as r, findTailwindConfig as s, getRuntimeClassSetCacheEntry as t, findNearestPackageRoot as u };