weapp-tailwindcss 5.0.0-next.10 → 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 (110) hide show
  1. package/dist/{bundle-state-EUbcdKqo.js → bundle-state-Bz8vLnCf.js} +42 -3
  2. package/dist/{bundle-state-BWqi5ZyX.mjs → bundle-state-CP2XS3Uj.mjs} +31 -4
  3. package/dist/bundlers/shared/cache.d.ts +6 -6
  4. package/dist/bundlers/shared/css-cleanup.d.ts +6 -1
  5. package/dist/bundlers/shared/css-imports.d.ts +3 -3
  6. package/dist/bundlers/shared/generator-css/directives.d.ts +10 -3
  7. package/dist/bundlers/shared/generator-css/source-files.d.ts +9 -6
  8. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +16 -2
  9. package/dist/bundlers/shared/generator-css.d.ts +5 -1
  10. package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
  11. package/dist/bundlers/shared/style-requests.d.ts +2 -0
  12. package/dist/bundlers/vite/bundle-state.d.ts +1 -0
  13. package/dist/bundlers/vite/css-finalizer.d.ts +2 -0
  14. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -1
  15. package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +1 -0
  16. package/dist/bundlers/vite/generate-bundle.d.ts +8 -1
  17. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +5 -1
  18. package/dist/bundlers/vite/rewrite-css-imports.d.ts +5 -5
  19. package/dist/bundlers/vite/runtime-class-set.d.ts +4 -1
  20. package/dist/bundlers/vite/source-candidates.d.ts +13 -2
  21. package/dist/bundlers/vite/source-scan.d.ts +21 -3
  22. package/dist/bundlers/vite/static-config-content.d.ts +5 -0
  23. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +5 -0
  24. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +3 -3
  25. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +3 -3
  26. package/dist/cache/index.d.ts +6 -6
  27. package/dist/cli/context.d.ts +1 -11
  28. package/dist/cli/doctor/types.d.ts +11 -11
  29. package/dist/cli/vscode-entry.d.ts +3 -3
  30. package/dist/cli.js +468 -10
  31. package/dist/cli.mjs +466 -9
  32. package/dist/context/tailwindcss.d.ts +1 -1
  33. package/dist/core.js +1 -1
  34. package/dist/core.mjs +1 -1
  35. package/dist/css-macro/postcss.js +3 -2
  36. package/dist/css-macro/postcss.mjs +3 -2
  37. package/dist/css-macro.js +2 -2
  38. package/dist/css-macro.mjs +2 -2
  39. package/dist/defaults.js +1 -1
  40. package/dist/defaults.mjs +1 -1
  41. package/dist/escape.js +10 -2
  42. package/dist/escape.mjs +10 -2
  43. package/dist/generator/options.d.ts +8 -6
  44. package/dist/generator/types.d.ts +3 -3
  45. package/dist/generator-C9H44wEF.mjs +32 -0
  46. package/dist/generator-CRORPkpW.js +55 -0
  47. package/dist/generator.js +12 -11
  48. package/dist/generator.mjs +2 -1
  49. package/dist/gulp.js +57 -18
  50. package/dist/gulp.mjs +54 -15
  51. package/dist/{incremental-runtime-class-set-BYmzQ-_f.js → incremental-runtime-class-set-DN9KKjSi.js} +753 -155
  52. package/dist/{incremental-runtime-class-set-BgMW6wf2.mjs → incremental-runtime-class-set-Dbn4yPfZ.mjs} +724 -144
  53. package/dist/index.js +4 -4
  54. package/dist/index.mjs +4 -4
  55. package/dist/js/precheck.d.ts +2 -2
  56. package/dist/lightningcss/style-handler/selector-transform.d.ts +1 -1
  57. package/dist/lightningcss/style-handler.d.ts +3 -3
  58. package/dist/{postcss-Dg-_lyHS.js → postcss-Ab7YzAbs.js} +37 -23
  59. package/dist/postcss-CZE8k8oP.js +5483 -0
  60. package/dist/{postcss-C7efq3hr.mjs → postcss-CtlrNknb.mjs} +26 -12
  61. package/dist/postcss.js +1 -1
  62. package/dist/postcss.mjs +1 -1
  63. package/dist/{precheck-B32p-gLI.js → precheck-CRX-pMKJ.js} +63 -37
  64. package/dist/{precheck-B4RH6ZNN.mjs → precheck-SG48aLG2.mjs} +56 -30
  65. package/dist/presets.js +11 -11
  66. package/dist/presets.mjs +11 -11
  67. package/dist/shared/mpx.d.ts +1 -0
  68. package/dist/source-candidates-C4YgmZ8A.js +274 -0
  69. package/dist/source-candidates-CyupdLKi.mjs +259 -0
  70. package/dist/tailwindcss/runtime/cache.d.ts +4 -3
  71. package/dist/tailwindcss/runtime.d.ts +9 -9
  72. package/dist/tailwindcss/v3-engine/types.d.ts +17 -14
  73. package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
  74. package/dist/tailwindcss/v4/patcher.d.ts +1 -1
  75. package/dist/tailwindcss/v4-engine/types.d.ts +14 -5
  76. package/dist/{tailwindcss-C5IgPlQ0.mjs → tailwindcss-BbTVeQkG.mjs} +52 -33
  77. package/dist/{tailwindcss-Bu-RWIHx.js → tailwindcss-DZ6jVYb4.js} +59 -40
  78. package/dist/types/index.d.ts +44 -40
  79. package/dist/types/user-defined-options/general.d.ts +21 -21
  80. package/dist/types/user-defined-options/important.d.ts +30 -27
  81. package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
  82. package/dist/types/user-defined-options/matcher.d.ts +6 -6
  83. package/dist/utils/object.d.ts +9 -0
  84. package/dist/{utils-Btw1iOVV.mjs → utils-CycMvPn_.mjs} +1 -1
  85. package/dist/{utils-BiShvil9.js → utils-D0MZP_tr.js} +1 -1
  86. package/dist/v3-engine-D61eilBl.mjs +3208 -0
  87. package/dist/v3-engine-DwV1E6rX.js +3461 -0
  88. package/dist/{vite-BU74SkOi.mjs → vite-Ti_qSctn.mjs} +434 -536
  89. package/dist/{vite-CKjx_5c3.js → vite-xKS6RvLR.js} +437 -542
  90. package/dist/vite.js +1 -1
  91. package/dist/vite.mjs +1 -1
  92. package/dist/weapp-tw-css-import-rewrite-loader.js +143 -18
  93. package/dist/weapp-tw-runtime-classset-loader.js +44 -6
  94. package/dist/{webpack-CAk_ITq7.mjs → webpack-DvptFz7B.mjs} +111 -39
  95. package/dist/{webpack-damWiYqY.js → webpack-wfNutjMm.js} +115 -43
  96. package/dist/webpack.js +1 -1
  97. package/dist/webpack.mjs +1 -1
  98. package/package.json +5 -5
  99. package/dist/cache-BVAiJV3J.js +0 -502
  100. package/dist/cache-CHs4DXui.mjs +0 -434
  101. package/dist/generator-DKkhJbOg.js +0 -1531
  102. package/dist/generator-UBmfduYg.mjs +0 -1432
  103. package/dist/runtime-patch-CwN5ya72.mjs +0 -71
  104. package/dist/runtime-patch-D6mBo_KB.js +0 -85
  105. package/dist/source-scan-BaYvNx-k.js +0 -293
  106. package/dist/source-scan-cGZxoJqP.mjs +0 -254
  107. /package/dist/{constants-BeeyfJ9k.js → constants-BoB_6lFw.js} +0 -0
  108. /package/dist/{constants-BG12WAKw.mjs → constants-E_loJC49.mjs} +0 -0
  109. /package/dist/{logger-EVNB9z7i.js → logger-BRy6XPQ2.js} +0 -0
  110. /package/dist/{logger-CZUxvJJD.mjs → logger-Bub1jggA.mjs} +0 -0
@@ -1,71 +0,0 @@
1
- import { i as runtimeSignaturePatchersSymbol } from "./cache-CHs4DXui.mjs";
2
- import { createRequire } from "node:module";
3
- import path from "node:path";
4
- import _createDebug from "debug";
5
- //#region src/debug/index.ts
6
- const _debug = _createDebug("weapp-tw");
7
- function createDebug(prefix) {
8
- const debug = ((formatter, ...args) => {
9
- return _debug((prefix ?? "") + formatter, ...args);
10
- });
11
- Object.defineProperty(debug, "enabled", {
12
- enumerable: false,
13
- configurable: false,
14
- get() {
15
- return _debug.enabled;
16
- }
17
- });
18
- return debug;
19
- }
20
- //#endregion
21
- //#region src/tailwindcss/runtime-patch.ts
22
- const debug = createDebug("[tailwindcss:runtime-patch] ");
23
- const require = createRequire(import.meta.url);
24
- const runtimePatchPromiseCache = /* @__PURE__ */ new WeakMap();
25
- function getNestedPatchers(twPatcher) {
26
- const nested = twPatcher[runtimeSignaturePatchersSymbol];
27
- return Array.isArray(nested) && nested.length > 0 ? nested : void 0;
28
- }
29
- function shouldApplyRuntimePatch(twPatcher) {
30
- return twPatcher.majorVersion === 3 && typeof twPatcher.patch === "function";
31
- }
32
- function clearTailwindcssRequireCache(twPatcher) {
33
- const rootPath = twPatcher.packageInfo?.rootPath;
34
- if (!rootPath) return;
35
- const normalizedRoot = path.resolve(rootPath);
36
- let count = 0;
37
- for (const id of Object.keys(require.cache)) {
38
- const normalizedId = path.resolve(id);
39
- if (normalizedId === normalizedRoot || normalizedId.startsWith(`${normalizedRoot}${path.sep}`)) {
40
- delete require.cache[id];
41
- count += 1;
42
- }
43
- }
44
- if (count > 0) debug("clear tailwindcss require cache after runtime patch, count=%d root=%s", count, normalizedRoot);
45
- }
46
- async function ensureTailwindcssRuntimePatch(twPatcher, options = {}) {
47
- const nestedPatchers = getNestedPatchers(twPatcher);
48
- if (nestedPatchers) {
49
- await Promise.all(nestedPatchers.map((patcher) => ensureTailwindcssRuntimePatch(patcher)));
50
- return;
51
- }
52
- if (!shouldApplyRuntimePatch(twPatcher)) return;
53
- const cached = runtimePatchPromiseCache.get(twPatcher);
54
- if (cached) {
55
- await cached;
56
- if (options.clearRequireCache) clearTailwindcssRequireCache(twPatcher);
57
- return;
58
- }
59
- const task = Promise.resolve().then(async () => {
60
- debug("apply tailwindcss runtime patch, package=%s version=%s root=%s", twPatcher.packageInfo?.name ?? "tailwindcss", twPatcher.packageInfo?.version ?? "unknown", twPatcher.packageInfo?.rootPath ?? "unknown");
61
- await twPatcher.patch?.();
62
- if (options.clearRequireCache) clearTailwindcssRequireCache(twPatcher);
63
- }).catch((error) => {
64
- runtimePatchPromiseCache.delete(twPatcher);
65
- throw error;
66
- });
67
- runtimePatchPromiseCache.set(twPatcher, task);
68
- return task;
69
- }
70
- //#endregion
71
- export { createDebug as n, ensureTailwindcssRuntimePatch as t };
@@ -1,85 +0,0 @@
1
- const require_chunk = require("./chunk-8l464Juk.js");
2
- const require_cache = require("./cache-BVAiJV3J.js");
3
- let node_module = require("node:module");
4
- let node_path = require("node:path");
5
- node_path = require_chunk.__toESM(node_path);
6
- let debug = require("debug");
7
- debug = require_chunk.__toESM(debug);
8
- //#region src/debug/index.ts
9
- const _debug = (0, debug.default)("weapp-tw");
10
- function createDebug(prefix) {
11
- const debug$2 = ((formatter, ...args) => {
12
- return _debug((prefix ?? "") + formatter, ...args);
13
- });
14
- Object.defineProperty(debug$2, "enabled", {
15
- enumerable: false,
16
- configurable: false,
17
- get() {
18
- return _debug.enabled;
19
- }
20
- });
21
- return debug$2;
22
- }
23
- //#endregion
24
- //#region src/tailwindcss/runtime-patch.ts
25
- const debug$1 = createDebug("[tailwindcss:runtime-patch] ");
26
- const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
27
- const runtimePatchPromiseCache = /* @__PURE__ */ new WeakMap();
28
- function getNestedPatchers(twPatcher) {
29
- const nested = twPatcher[require_cache.runtimeSignaturePatchersSymbol];
30
- return Array.isArray(nested) && nested.length > 0 ? nested : void 0;
31
- }
32
- function shouldApplyRuntimePatch(twPatcher) {
33
- return twPatcher.majorVersion === 3 && typeof twPatcher.patch === "function";
34
- }
35
- function clearTailwindcssRequireCache(twPatcher) {
36
- const rootPath = twPatcher.packageInfo?.rootPath;
37
- if (!rootPath) return;
38
- const normalizedRoot = node_path.default.resolve(rootPath);
39
- let count = 0;
40
- for (const id of Object.keys(require$1.cache)) {
41
- const normalizedId = node_path.default.resolve(id);
42
- if (normalizedId === normalizedRoot || normalizedId.startsWith(`${normalizedRoot}${node_path.default.sep}`)) {
43
- delete require$1.cache[id];
44
- count += 1;
45
- }
46
- }
47
- if (count > 0) debug$1("clear tailwindcss require cache after runtime patch, count=%d root=%s", count, normalizedRoot);
48
- }
49
- async function ensureTailwindcssRuntimePatch(twPatcher, options = {}) {
50
- const nestedPatchers = getNestedPatchers(twPatcher);
51
- if (nestedPatchers) {
52
- await Promise.all(nestedPatchers.map((patcher) => ensureTailwindcssRuntimePatch(patcher)));
53
- return;
54
- }
55
- if (!shouldApplyRuntimePatch(twPatcher)) return;
56
- const cached = runtimePatchPromiseCache.get(twPatcher);
57
- if (cached) {
58
- await cached;
59
- if (options.clearRequireCache) clearTailwindcssRequireCache(twPatcher);
60
- return;
61
- }
62
- const task = Promise.resolve().then(async () => {
63
- debug$1("apply tailwindcss runtime patch, package=%s version=%s root=%s", twPatcher.packageInfo?.name ?? "tailwindcss", twPatcher.packageInfo?.version ?? "unknown", twPatcher.packageInfo?.rootPath ?? "unknown");
64
- await twPatcher.patch?.();
65
- if (options.clearRequireCache) clearTailwindcssRequireCache(twPatcher);
66
- }).catch((error) => {
67
- runtimePatchPromiseCache.delete(twPatcher);
68
- throw error;
69
- });
70
- runtimePatchPromiseCache.set(twPatcher, task);
71
- return task;
72
- }
73
- //#endregion
74
- Object.defineProperty(exports, "createDebug", {
75
- enumerable: true,
76
- get: function() {
77
- return createDebug;
78
- }
79
- });
80
- Object.defineProperty(exports, "ensureTailwindcssRuntimePatch", {
81
- enumerable: true,
82
- get: function() {
83
- return ensureTailwindcssRuntimePatch;
84
- }
85
- });
@@ -1,293 +0,0 @@
1
- const require_chunk = require("./chunk-8l464Juk.js");
2
- let node_path = require("node:path");
3
- node_path = require_chunk.__toESM(node_path);
4
- let node_fs_promises = require("node:fs/promises");
5
- let fast_glob = require("fast-glob");
6
- fast_glob = require_chunk.__toESM(fast_glob);
7
- let micromatch = require("micromatch");
8
- micromatch = require_chunk.__toESM(micromatch);
9
- //#region src/tailwindcss/source-scan.ts
10
- const DEFAULT_SOURCE_SCAN_EXTENSIONS = [
11
- "html",
12
- "wxml",
13
- "axml",
14
- "jxml",
15
- "ksml",
16
- "ttml",
17
- "qml",
18
- "tyml",
19
- "xhsml",
20
- "swan",
21
- "vue",
22
- "mpx",
23
- "js",
24
- "jsx",
25
- "ts",
26
- "tsx"
27
- ];
28
- function createSourceScanPattern(extensions = DEFAULT_SOURCE_SCAN_EXTENSIONS) {
29
- return `**/*.{${extensions.join(",")}}`;
30
- }
31
- const NUMERICAL_RANGE_RE = /^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/;
32
- function parseConfigParam(params) {
33
- const value = params.trim();
34
- return /^(['"])(.+)\1$/.exec(value)?.[2];
35
- }
36
- function isLegacyContentObject(value) {
37
- return typeof value === "object" && value !== null && "files" in value;
38
- }
39
- function normalizeGlobPattern(pattern) {
40
- return pattern.startsWith("./") ? pattern.slice(2) : pattern;
41
- }
42
- function segmentTopLevel(input, separator) {
43
- const parts = [];
44
- const stack = [];
45
- let lastPos = 0;
46
- let quote;
47
- for (let index = 0; index < input.length; index++) {
48
- const char = input[index];
49
- if (char === "\\") {
50
- index += 1;
51
- continue;
52
- }
53
- if (quote) {
54
- if (char === quote) quote = void 0;
55
- continue;
56
- }
57
- if (char === "\"" || char === "'") {
58
- quote = char;
59
- continue;
60
- }
61
- if (char === "(") {
62
- stack.push(")");
63
- continue;
64
- }
65
- if (char === "[") {
66
- stack.push("]");
67
- continue;
68
- }
69
- if (char === "{") {
70
- stack.push("}");
71
- continue;
72
- }
73
- if (stack.length > 0 && char === stack[stack.length - 1]) {
74
- stack.pop();
75
- continue;
76
- }
77
- if (stack.length === 0 && char === separator) {
78
- parts.push(input.slice(lastPos, index));
79
- lastPos = index + 1;
80
- }
81
- }
82
- parts.push(input.slice(lastPos));
83
- return parts;
84
- }
85
- function isSequence(value) {
86
- return NUMERICAL_RANGE_RE.test(value);
87
- }
88
- function expandSequence(value) {
89
- const match = value.match(NUMERICAL_RANGE_RE);
90
- if (!match) return [value];
91
- const [, start, end, stepValue] = match;
92
- let step = stepValue ? Number.parseInt(stepValue, 10) : void 0;
93
- const startNumber = Number.parseInt(start, 10);
94
- const endNumber = Number.parseInt(end, 10);
95
- const increasing = startNumber < endNumber;
96
- if (step === void 0) step = increasing ? 1 : -1;
97
- if (step === 0) return [];
98
- if (increasing && step < 0) step = -step;
99
- if (!increasing && step > 0) step = -step;
100
- const result = [];
101
- for (let value = startNumber; increasing ? value <= endNumber : value >= endNumber; value += step) result.push(String(value));
102
- return result;
103
- }
104
- function expandInlineSourceCandidatePattern(pattern) {
105
- const index = pattern.indexOf("{");
106
- if (index === -1) return [pattern];
107
- const prefix = pattern.slice(0, index);
108
- const rest = pattern.slice(index);
109
- let depth = 0;
110
- let endIndex = -1;
111
- for (let index = 0; index < rest.length; index++) {
112
- const char = rest[index];
113
- if (char === "{") depth += 1;
114
- else if (char === "}") {
115
- depth -= 1;
116
- if (depth === 0) {
117
- endIndex = index;
118
- break;
119
- }
120
- }
121
- }
122
- if (endIndex === -1) return [pattern];
123
- const inner = rest.slice(1, endIndex);
124
- const suffix = rest.slice(endIndex + 1);
125
- const parts = (isSequence(inner) ? expandSequence(inner) : segmentTopLevel(inner, ",")).flatMap((part) => expandInlineSourceCandidatePattern(part));
126
- return expandInlineSourceCandidatePattern(suffix).flatMap((suffix) => parts.map((part) => `${prefix}${part}${suffix}`));
127
- }
128
- function parseSourceInlineParam(params) {
129
- let value = params.trim();
130
- const negated = value.startsWith("not ");
131
- if (negated) value = value.slice(4).trim();
132
- if (!value.startsWith("inline(") || !value.endsWith(")")) return;
133
- const inlineValue = value.slice(7, -1).trim();
134
- const match = /^(['"])([\s\S]*)\1$/.exec(inlineValue);
135
- if (!match) return;
136
- return {
137
- negated,
138
- source: match[2]
139
- };
140
- }
141
- function collectCssInlineSourceCandidates(root) {
142
- const included = /* @__PURE__ */ new Set();
143
- const excluded = /* @__PURE__ */ new Set();
144
- root.walkAtRules("source", (rule) => {
145
- const parsed = parseSourceInlineParam(rule.params);
146
- if (!parsed) return;
147
- const target = parsed.negated ? excluded : included;
148
- for (const source of segmentTopLevel(parsed.source, " ")) {
149
- const trimmed = source.trim();
150
- if (!trimmed) continue;
151
- for (const candidate of expandInlineSourceCandidatePattern(trimmed)) {
152
- const normalized = candidate.trim();
153
- if (normalized) target.add(normalized);
154
- }
155
- }
156
- });
157
- for (const candidate of excluded) included.delete(candidate);
158
- return {
159
- included,
160
- excluded
161
- };
162
- }
163
- function normalizeLegacyContentEntries(content, base) {
164
- if (typeof content === "string") {
165
- const negated = content.startsWith("!");
166
- return [{
167
- base,
168
- negated,
169
- pattern: normalizeGlobPattern(negated ? content.slice(1) : content)
170
- }];
171
- }
172
- if (Array.isArray(content)) return content.flatMap((item) => normalizeLegacyContentEntries(item, base));
173
- if (isLegacyContentObject(content)) return normalizeLegacyContentEntries(content.files, base);
174
- return [];
175
- }
176
- async function pathExistsAsDirectory(file) {
177
- try {
178
- return (await (0, node_fs_promises.stat)(file)).isDirectory();
179
- } catch {
180
- return false;
181
- }
182
- }
183
- async function resolveTailwindSourceEntry(sourcePath, base, negated, defaultPattern = createSourceScanPattern()) {
184
- const absoluteSource = node_path.default.isAbsolute(sourcePath) ? node_path.default.resolve(sourcePath) : node_path.default.resolve(base, sourcePath);
185
- if (await pathExistsAsDirectory(absoluteSource)) return {
186
- base: absoluteSource,
187
- negated,
188
- pattern: normalizeGlobPattern(defaultPattern)
189
- };
190
- if (node_path.default.isAbsolute(sourcePath)) return {
191
- base: node_path.default.dirname(absoluteSource),
192
- negated,
193
- pattern: normalizeGlobPattern(node_path.default.basename(absoluteSource))
194
- };
195
- return {
196
- base,
197
- negated,
198
- pattern: normalizeGlobPattern(sourcePath)
199
- };
200
- }
201
- function parseSourceFileParam(params) {
202
- const value = params.trim();
203
- if (!value || value === "none" || value.startsWith("inline(")) return;
204
- const negated = value.startsWith("not ");
205
- const sourceValue = negated ? value.slice(4).trim() : value;
206
- if (sourceValue.startsWith("inline(")) return;
207
- const match = /^(['"])(.+)\1$/.exec(sourceValue);
208
- return match?.[2] ? {
209
- negated,
210
- sourcePath: match[2]
211
- } : void 0;
212
- }
213
- async function resolveCssSourceEntries(root, base, defaultPattern = createSourceScanPattern()) {
214
- const entries = [];
215
- const tasks = [];
216
- root.walkAtRules("source", (rule) => {
217
- const parsed = parseSourceFileParam(rule.params);
218
- if (!parsed) return;
219
- tasks.push(resolveTailwindSourceEntry(parsed.sourcePath, base, parsed.negated, defaultPattern));
220
- });
221
- entries.push(...await Promise.all(tasks));
222
- return entries;
223
- }
224
- async function expandTailwindSourceEntries(entries, options = {}) {
225
- const files = /* @__PURE__ */ new Set();
226
- const negativeEntries = entries.filter((entry) => entry.negated);
227
- const entriesByBase = /* @__PURE__ */ new Map();
228
- for (const entry of entries) {
229
- const base = node_path.default.resolve(entry.base);
230
- const group = entriesByBase.get(base) ?? [];
231
- group.push({
232
- ...entry,
233
- base
234
- });
235
- entriesByBase.set(base, group);
236
- }
237
- await Promise.all([...entriesByBase.entries()].map(async ([base, group]) => {
238
- const patterns = group.map((entry) => {
239
- const pattern = normalizeGlobPattern(entry.pattern);
240
- return entry.negated ? `!${pattern}` : pattern;
241
- });
242
- if (!patterns.some((pattern) => !pattern.startsWith("!"))) return;
243
- const matched = await (0, fast_glob.default)(patterns, {
244
- absolute: true,
245
- cwd: base,
246
- ignore: options.ignore,
247
- onlyFiles: true,
248
- unique: true
249
- });
250
- for (const file of matched) files.add(node_path.default.resolve(file));
251
- }));
252
- return [...files].filter((file) => !negativeEntries.some((entry) => {
253
- const relative = node_path.default.relative(node_path.default.resolve(entry.base), file).split(node_path.default.sep).join("/");
254
- return relative && !relative.startsWith("../") && !node_path.default.isAbsolute(relative) && micromatch.default.isMatch(relative, normalizeGlobPattern(entry.pattern));
255
- }));
256
- }
257
- //#endregion
258
- Object.defineProperty(exports, "collectCssInlineSourceCandidates", {
259
- enumerable: true,
260
- get: function() {
261
- return collectCssInlineSourceCandidates;
262
- }
263
- });
264
- Object.defineProperty(exports, "createSourceScanPattern", {
265
- enumerable: true,
266
- get: function() {
267
- return createSourceScanPattern;
268
- }
269
- });
270
- Object.defineProperty(exports, "expandTailwindSourceEntries", {
271
- enumerable: true,
272
- get: function() {
273
- return expandTailwindSourceEntries;
274
- }
275
- });
276
- Object.defineProperty(exports, "normalizeLegacyContentEntries", {
277
- enumerable: true,
278
- get: function() {
279
- return normalizeLegacyContentEntries;
280
- }
281
- });
282
- Object.defineProperty(exports, "parseConfigParam", {
283
- enumerable: true,
284
- get: function() {
285
- return parseConfigParam;
286
- }
287
- });
288
- Object.defineProperty(exports, "resolveCssSourceEntries", {
289
- enumerable: true,
290
- get: function() {
291
- return resolveCssSourceEntries;
292
- }
293
- });
@@ -1,254 +0,0 @@
1
- import path from "node:path";
2
- import { stat } from "node:fs/promises";
3
- import fg from "fast-glob";
4
- import micromatch from "micromatch";
5
- //#region src/tailwindcss/source-scan.ts
6
- const DEFAULT_SOURCE_SCAN_EXTENSIONS = [
7
- "html",
8
- "wxml",
9
- "axml",
10
- "jxml",
11
- "ksml",
12
- "ttml",
13
- "qml",
14
- "tyml",
15
- "xhsml",
16
- "swan",
17
- "vue",
18
- "mpx",
19
- "js",
20
- "jsx",
21
- "ts",
22
- "tsx"
23
- ];
24
- function createSourceScanPattern(extensions = DEFAULT_SOURCE_SCAN_EXTENSIONS) {
25
- return `**/*.{${extensions.join(",")}}`;
26
- }
27
- const NUMERICAL_RANGE_RE = /^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/;
28
- function parseConfigParam(params) {
29
- const value = params.trim();
30
- return /^(['"])(.+)\1$/.exec(value)?.[2];
31
- }
32
- function isLegacyContentObject(value) {
33
- return typeof value === "object" && value !== null && "files" in value;
34
- }
35
- function normalizeGlobPattern(pattern) {
36
- return pattern.startsWith("./") ? pattern.slice(2) : pattern;
37
- }
38
- function segmentTopLevel(input, separator) {
39
- const parts = [];
40
- const stack = [];
41
- let lastPos = 0;
42
- let quote;
43
- for (let index = 0; index < input.length; index++) {
44
- const char = input[index];
45
- if (char === "\\") {
46
- index += 1;
47
- continue;
48
- }
49
- if (quote) {
50
- if (char === quote) quote = void 0;
51
- continue;
52
- }
53
- if (char === "\"" || char === "'") {
54
- quote = char;
55
- continue;
56
- }
57
- if (char === "(") {
58
- stack.push(")");
59
- continue;
60
- }
61
- if (char === "[") {
62
- stack.push("]");
63
- continue;
64
- }
65
- if (char === "{") {
66
- stack.push("}");
67
- continue;
68
- }
69
- if (stack.length > 0 && char === stack[stack.length - 1]) {
70
- stack.pop();
71
- continue;
72
- }
73
- if (stack.length === 0 && char === separator) {
74
- parts.push(input.slice(lastPos, index));
75
- lastPos = index + 1;
76
- }
77
- }
78
- parts.push(input.slice(lastPos));
79
- return parts;
80
- }
81
- function isSequence(value) {
82
- return NUMERICAL_RANGE_RE.test(value);
83
- }
84
- function expandSequence(value) {
85
- const match = value.match(NUMERICAL_RANGE_RE);
86
- if (!match) return [value];
87
- const [, start, end, stepValue] = match;
88
- let step = stepValue ? Number.parseInt(stepValue, 10) : void 0;
89
- const startNumber = Number.parseInt(start, 10);
90
- const endNumber = Number.parseInt(end, 10);
91
- const increasing = startNumber < endNumber;
92
- if (step === void 0) step = increasing ? 1 : -1;
93
- if (step === 0) return [];
94
- if (increasing && step < 0) step = -step;
95
- if (!increasing && step > 0) step = -step;
96
- const result = [];
97
- for (let value = startNumber; increasing ? value <= endNumber : value >= endNumber; value += step) result.push(String(value));
98
- return result;
99
- }
100
- function expandInlineSourceCandidatePattern(pattern) {
101
- const index = pattern.indexOf("{");
102
- if (index === -1) return [pattern];
103
- const prefix = pattern.slice(0, index);
104
- const rest = pattern.slice(index);
105
- let depth = 0;
106
- let endIndex = -1;
107
- for (let index = 0; index < rest.length; index++) {
108
- const char = rest[index];
109
- if (char === "{") depth += 1;
110
- else if (char === "}") {
111
- depth -= 1;
112
- if (depth === 0) {
113
- endIndex = index;
114
- break;
115
- }
116
- }
117
- }
118
- if (endIndex === -1) return [pattern];
119
- const inner = rest.slice(1, endIndex);
120
- const suffix = rest.slice(endIndex + 1);
121
- const parts = (isSequence(inner) ? expandSequence(inner) : segmentTopLevel(inner, ",")).flatMap((part) => expandInlineSourceCandidatePattern(part));
122
- return expandInlineSourceCandidatePattern(suffix).flatMap((suffix) => parts.map((part) => `${prefix}${part}${suffix}`));
123
- }
124
- function parseSourceInlineParam(params) {
125
- let value = params.trim();
126
- const negated = value.startsWith("not ");
127
- if (negated) value = value.slice(4).trim();
128
- if (!value.startsWith("inline(") || !value.endsWith(")")) return;
129
- const inlineValue = value.slice(7, -1).trim();
130
- const match = /^(['"])([\s\S]*)\1$/.exec(inlineValue);
131
- if (!match) return;
132
- return {
133
- negated,
134
- source: match[2]
135
- };
136
- }
137
- function collectCssInlineSourceCandidates(root) {
138
- const included = /* @__PURE__ */ new Set();
139
- const excluded = /* @__PURE__ */ new Set();
140
- root.walkAtRules("source", (rule) => {
141
- const parsed = parseSourceInlineParam(rule.params);
142
- if (!parsed) return;
143
- const target = parsed.negated ? excluded : included;
144
- for (const source of segmentTopLevel(parsed.source, " ")) {
145
- const trimmed = source.trim();
146
- if (!trimmed) continue;
147
- for (const candidate of expandInlineSourceCandidatePattern(trimmed)) {
148
- const normalized = candidate.trim();
149
- if (normalized) target.add(normalized);
150
- }
151
- }
152
- });
153
- for (const candidate of excluded) included.delete(candidate);
154
- return {
155
- included,
156
- excluded
157
- };
158
- }
159
- function normalizeLegacyContentEntries(content, base) {
160
- if (typeof content === "string") {
161
- const negated = content.startsWith("!");
162
- return [{
163
- base,
164
- negated,
165
- pattern: normalizeGlobPattern(negated ? content.slice(1) : content)
166
- }];
167
- }
168
- if (Array.isArray(content)) return content.flatMap((item) => normalizeLegacyContentEntries(item, base));
169
- if (isLegacyContentObject(content)) return normalizeLegacyContentEntries(content.files, base);
170
- return [];
171
- }
172
- async function pathExistsAsDirectory(file) {
173
- try {
174
- return (await stat(file)).isDirectory();
175
- } catch {
176
- return false;
177
- }
178
- }
179
- async function resolveTailwindSourceEntry(sourcePath, base, negated, defaultPattern = createSourceScanPattern()) {
180
- const absoluteSource = path.isAbsolute(sourcePath) ? path.resolve(sourcePath) : path.resolve(base, sourcePath);
181
- if (await pathExistsAsDirectory(absoluteSource)) return {
182
- base: absoluteSource,
183
- negated,
184
- pattern: normalizeGlobPattern(defaultPattern)
185
- };
186
- if (path.isAbsolute(sourcePath)) return {
187
- base: path.dirname(absoluteSource),
188
- negated,
189
- pattern: normalizeGlobPattern(path.basename(absoluteSource))
190
- };
191
- return {
192
- base,
193
- negated,
194
- pattern: normalizeGlobPattern(sourcePath)
195
- };
196
- }
197
- function parseSourceFileParam(params) {
198
- const value = params.trim();
199
- if (!value || value === "none" || value.startsWith("inline(")) return;
200
- const negated = value.startsWith("not ");
201
- const sourceValue = negated ? value.slice(4).trim() : value;
202
- if (sourceValue.startsWith("inline(")) return;
203
- const match = /^(['"])(.+)\1$/.exec(sourceValue);
204
- return match?.[2] ? {
205
- negated,
206
- sourcePath: match[2]
207
- } : void 0;
208
- }
209
- async function resolveCssSourceEntries(root, base, defaultPattern = createSourceScanPattern()) {
210
- const entries = [];
211
- const tasks = [];
212
- root.walkAtRules("source", (rule) => {
213
- const parsed = parseSourceFileParam(rule.params);
214
- if (!parsed) return;
215
- tasks.push(resolveTailwindSourceEntry(parsed.sourcePath, base, parsed.negated, defaultPattern));
216
- });
217
- entries.push(...await Promise.all(tasks));
218
- return entries;
219
- }
220
- async function expandTailwindSourceEntries(entries, options = {}) {
221
- const files = /* @__PURE__ */ new Set();
222
- const negativeEntries = entries.filter((entry) => entry.negated);
223
- const entriesByBase = /* @__PURE__ */ new Map();
224
- for (const entry of entries) {
225
- const base = path.resolve(entry.base);
226
- const group = entriesByBase.get(base) ?? [];
227
- group.push({
228
- ...entry,
229
- base
230
- });
231
- entriesByBase.set(base, group);
232
- }
233
- await Promise.all([...entriesByBase.entries()].map(async ([base, group]) => {
234
- const patterns = group.map((entry) => {
235
- const pattern = normalizeGlobPattern(entry.pattern);
236
- return entry.negated ? `!${pattern}` : pattern;
237
- });
238
- if (!patterns.some((pattern) => !pattern.startsWith("!"))) return;
239
- const matched = await fg(patterns, {
240
- absolute: true,
241
- cwd: base,
242
- ignore: options.ignore,
243
- onlyFiles: true,
244
- unique: true
245
- });
246
- for (const file of matched) files.add(path.resolve(file));
247
- }));
248
- return [...files].filter((file) => !negativeEntries.some((entry) => {
249
- const relative = path.relative(path.resolve(entry.base), file).split(path.sep).join("/");
250
- return relative && !relative.startsWith("../") && !path.isAbsolute(relative) && micromatch.isMatch(relative, normalizeGlobPattern(entry.pattern));
251
- }));
252
- }
253
- //#endregion
254
- export { parseConfigParam as a, normalizeLegacyContentEntries as i, createSourceScanPattern as n, resolveCssSourceEntries as o, expandTailwindSourceEntries as r, collectCssInlineSourceCandidates as t };