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

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