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.
- package/dist/{bundle-state-BrtFgX-A.mjs → bundle-state-BOBbxYzQ.mjs} +3 -2
- package/dist/{bundle-state-BRkhpjio.js → bundle-state-CxtGmT4t.js} +3 -2
- package/dist/bundlers/shared/css-cleanup.d.ts +6 -1
- package/dist/bundlers/shared/generator-css/source-files.d.ts +9 -6
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +16 -2
- package/dist/bundlers/shared/generator-css.d.ts +4 -0
- package/dist/bundlers/shared/hmr-timing.d.ts +18 -1
- package/dist/bundlers/vite/bundle-state.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -1
- package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +8 -1
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +1 -0
- package/dist/bundlers/vite/runtime-class-set.d.ts +4 -1
- package/dist/bundlers/vite/source-candidates.d.ts +11 -0
- package/dist/bundlers/vite/source-scan.d.ts +18 -1
- package/dist/bundlers/vite/static-config-content.d.ts +5 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +5 -0
- package/dist/cli.js +486 -18
- package/dist/cli.mjs +484 -17
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/defaults-B1igPF_e.mjs +150 -0
- package/dist/defaults-IHhYxNeU.js +193 -0
- package/dist/defaults.js +6 -150
- package/dist/defaults.mjs +1 -143
- package/dist/generator-C9H44wEF.mjs +32 -0
- package/dist/generator-CRORPkpW.js +55 -0
- package/dist/generator.js +12 -11
- package/dist/generator.mjs +2 -1
- package/dist/gulp.js +49 -13
- package/dist/gulp.mjs +46 -10
- package/dist/{incremental-runtime-class-set-CBMefNHQ.js → incremental-runtime-class-set-B4EXHHii.js} +512 -103
- package/dist/{incremental-runtime-class-set-DaS2yw5c.mjs → incremental-runtime-class-set-DoKrMrEh.mjs} +491 -88
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/js/babel/cache-options.d.ts +3 -0
- package/dist/js/babel/parse.d.ts +7 -4
- package/dist/{postcss-xZDiTRII.mjs → postcss-BFxu5_cs.mjs} +19 -8
- package/dist/{postcss-Bs-RbNzK.js → postcss-CZE8k8oP.js} +59 -53
- package/dist/{postcss-BdcRlSpp.js → postcss-Vqn4IlO3.js} +30 -19
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-D5eEdqeH.js → precheck-CZHcFX8k.js} +65 -25
- package/dist/{precheck-DtBGFS-n.mjs → precheck-DCresEiu.mjs} +57 -17
- package/dist/presets.js +4 -4
- package/dist/presets.mjs +2 -2
- package/dist/source-candidates-BvbvkIPP.js +274 -0
- package/dist/source-candidates-CK70jGo7.mjs +259 -0
- package/dist/tailwindcss/runtime/cache.d.ts +1 -0
- package/dist/tailwindcss/v3-engine/types.d.ts +3 -0
- package/dist/tailwindcss/v4-engine/types.d.ts +8 -0
- package/dist/{tailwindcss-DGM8lHUj.mjs → tailwindcss-7k0LFa12.mjs} +8 -3
- package/dist/{tailwindcss-B78nj6n7.js → tailwindcss-CN0K7G-l.js} +20 -15
- package/dist/types/index.d.ts +7 -1
- package/dist/types/user-defined-options/general.d.ts +2 -0
- package/dist/v3-engine-D61eilBl.mjs +3208 -0
- package/dist/v3-engine-DwV1E6rX.js +3461 -0
- package/dist/{vite-C8S1wfyQ.mjs → vite-DCmKrTo0.mjs} +378 -540
- package/dist/{vite-BEj9JOOA.js → vite-DJ0P9Hrp.js} +383 -548
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +29 -9
- package/dist/weapp-tw-runtime-classset-loader.js +1 -1
- package/dist/{webpack-Dm1IXTIh.js → webpack-8y4NOMnT.js} +39 -22
- package/dist/{webpack-ZGIKKpFf.mjs → webpack-CbO4jjkH.mjs} +35 -18
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +3 -3
- package/dist/cache-B_9E7FxF.js +0 -517
- package/dist/cache-DEDxBMIw.mjs +0 -443
- package/dist/generator-CahkD2vq.mjs +0 -1469
- package/dist/generator-Ck1Dd1V0.js +0 -1568
- package/dist/runtime-patch-CqB-A4zA.js +0 -85
- package/dist/runtime-patch-DGKsVkiG.mjs +0 -71
- package/dist/source-scan-CIVTa3Cj.js +0 -297
- package/dist/source-scan-CJ0y0XBj.mjs +0 -258
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { j as expandTailwindSourceEntries } from "./v3-engine-D61eilBl.mjs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { extractSourceCandidates } from "tailwindcss-patch";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
import fg from "fast-glob";
|
|
6
|
+
import micromatch from "micromatch";
|
|
7
|
+
//#region src/bundlers/vite/source-candidates.ts
|
|
8
|
+
const CLEAN_URL_RE = /[?#].*$/;
|
|
9
|
+
const SOURCE_CANDIDATE_EXTENSIONS = [
|
|
10
|
+
"js",
|
|
11
|
+
"jsx",
|
|
12
|
+
"mjs",
|
|
13
|
+
"cjs",
|
|
14
|
+
"ts",
|
|
15
|
+
"tsx",
|
|
16
|
+
"mts",
|
|
17
|
+
"cts",
|
|
18
|
+
"vue",
|
|
19
|
+
"uvue",
|
|
20
|
+
"nvue",
|
|
21
|
+
"svelte",
|
|
22
|
+
"mpx",
|
|
23
|
+
"html",
|
|
24
|
+
"wxml",
|
|
25
|
+
"axml",
|
|
26
|
+
"jxml",
|
|
27
|
+
"ksml",
|
|
28
|
+
"ttml",
|
|
29
|
+
"qml",
|
|
30
|
+
"tyml",
|
|
31
|
+
"xhsml",
|
|
32
|
+
"swan",
|
|
33
|
+
"css",
|
|
34
|
+
"wxss",
|
|
35
|
+
"acss",
|
|
36
|
+
"jxss",
|
|
37
|
+
"ttss",
|
|
38
|
+
"qss",
|
|
39
|
+
"tyss",
|
|
40
|
+
"scss",
|
|
41
|
+
"sass",
|
|
42
|
+
"less",
|
|
43
|
+
"styl",
|
|
44
|
+
"stylus"
|
|
45
|
+
];
|
|
46
|
+
const SOURCE_CANDIDATE_EXTENSION_RE = /\.(?:[cm]?[jt]sx?|vue|uvue|nvue|svelte|mpx|html|wxml|axml|jxml|ksml|ttml|qml|tyml|xhsml|swan|css|wxss|acss|jxss|ttss|qss|tyss|scss|sass|less|stylus?)$/;
|
|
47
|
+
const SOURCE_CANDIDATE_GLOB = `**/*.{${SOURCE_CANDIDATE_EXTENSIONS.join(",")}}`;
|
|
48
|
+
const DEFAULT_SCAN_IGNORE = ["**/node_modules/**", "**/.git/**"];
|
|
49
|
+
const sourceCandidateContentCache = /* @__PURE__ */ new Map();
|
|
50
|
+
function cleanUrl(id) {
|
|
51
|
+
return path.resolve(id.replace(CLEAN_URL_RE, ""));
|
|
52
|
+
}
|
|
53
|
+
function toPosixPath(value) {
|
|
54
|
+
return value.split(path.sep).join("/");
|
|
55
|
+
}
|
|
56
|
+
function resolveOutDirIgnorePattern(root, outDir) {
|
|
57
|
+
if (!outDir) return;
|
|
58
|
+
const relative = path.relative(root, path.resolve(root, outDir));
|
|
59
|
+
if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) return;
|
|
60
|
+
return `${toPosixPath(relative)}/**`;
|
|
61
|
+
}
|
|
62
|
+
function resolveSourceCandidateExtension(id) {
|
|
63
|
+
const normalized = cleanUrl(id);
|
|
64
|
+
return /\.([^.\\/]+)$/.exec(normalized)?.[1] ?? "html";
|
|
65
|
+
}
|
|
66
|
+
function createSourceCandidateContentCacheKey(extension, source) {
|
|
67
|
+
return `${extension}\0${source}`;
|
|
68
|
+
}
|
|
69
|
+
function isSourceCandidateRequest(id) {
|
|
70
|
+
return SOURCE_CANDIDATE_EXTENSION_RE.test(cleanUrl(id));
|
|
71
|
+
}
|
|
72
|
+
function removeCandidateSet(candidateCount, candidates) {
|
|
73
|
+
for (const candidate of candidates) {
|
|
74
|
+
const count = candidateCount.get(candidate);
|
|
75
|
+
if (count == null) continue;
|
|
76
|
+
if (count <= 1) {
|
|
77
|
+
candidateCount.delete(candidate);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
candidateCount.set(candidate, count - 1);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function addCandidateSet(candidateCount, candidates) {
|
|
84
|
+
for (const candidate of candidates) candidateCount.set(candidate, (candidateCount.get(candidate) ?? 0) + 1);
|
|
85
|
+
}
|
|
86
|
+
function isFileMatchedByEntries(file, entries) {
|
|
87
|
+
if (!entries?.length) return true;
|
|
88
|
+
const positiveEntries = entries.filter((entry) => !entry.negated);
|
|
89
|
+
const negativeEntries = entries.filter((entry) => entry.negated);
|
|
90
|
+
if (positiveEntries.length === 0) return false;
|
|
91
|
+
const resolvedFile = path.resolve(file);
|
|
92
|
+
if (!positiveEntries.some((entry) => {
|
|
93
|
+
const relative = toPosixPath(path.relative(path.resolve(entry.base), resolvedFile));
|
|
94
|
+
const pattern = path.isAbsolute(entry.pattern) ? toPosixPath(path.relative(path.resolve(entry.base), entry.pattern)) : entry.pattern;
|
|
95
|
+
return relative && !relative.startsWith("../") && !path.isAbsolute(relative) && micromatch.isMatch(relative, pattern);
|
|
96
|
+
})) return false;
|
|
97
|
+
return !negativeEntries.some((entry) => {
|
|
98
|
+
const relative = toPosixPath(path.relative(path.resolve(entry.base), resolvedFile));
|
|
99
|
+
const pattern = path.isAbsolute(entry.pattern) ? toPosixPath(path.relative(path.resolve(entry.base), entry.pattern)) : entry.pattern;
|
|
100
|
+
return relative && !relative.startsWith("../") && !path.isAbsolute(relative) && micromatch.isMatch(relative, pattern);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function createSourceCandidateCollector() {
|
|
104
|
+
const candidatesById = /* @__PURE__ */ new Map();
|
|
105
|
+
const scanCandidatesById = /* @__PURE__ */ new Map();
|
|
106
|
+
const transformCandidatesById = /* @__PURE__ */ new Map();
|
|
107
|
+
const candidateCount = /* @__PURE__ */ new Map();
|
|
108
|
+
let inlineIncludedCandidates = /* @__PURE__ */ new Set();
|
|
109
|
+
let inlineExcludedCandidates = /* @__PURE__ */ new Set();
|
|
110
|
+
async function sync(id, source) {
|
|
111
|
+
const normalizedId = cleanUrl(id);
|
|
112
|
+
const extension = resolveSourceCandidateExtension(normalizedId);
|
|
113
|
+
const contentCacheKey = createSourceCandidateContentCacheKey(extension, source);
|
|
114
|
+
const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
|
|
115
|
+
if (cachedCandidates) {
|
|
116
|
+
replaceScanLayer(normalizedId, new Set(cachedCandidates));
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const nextCandidates = new Set(await extractSourceCandidates(source, extension));
|
|
120
|
+
sourceCandidateContentCache.set(contentCacheKey, [...nextCandidates]);
|
|
121
|
+
replaceScanLayer(normalizedId, nextCandidates);
|
|
122
|
+
}
|
|
123
|
+
async function merge(id, source) {
|
|
124
|
+
const normalizedId = cleanUrl(id);
|
|
125
|
+
const extension = resolveSourceCandidateExtension(normalizedId);
|
|
126
|
+
const contentCacheKey = createSourceCandidateContentCacheKey(extension, source);
|
|
127
|
+
const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
|
|
128
|
+
const extractedCandidates = cachedCandidates ? new Set(cachedCandidates) : new Set(await extractSourceCandidates(source, extension));
|
|
129
|
+
if (!cachedCandidates) sourceCandidateContentCache.set(contentCacheKey, [...extractedCandidates]);
|
|
130
|
+
replaceTransformLayer(normalizedId, extractedCandidates);
|
|
131
|
+
}
|
|
132
|
+
async function syncFile(id) {
|
|
133
|
+
const normalizedId = cleanUrl(id);
|
|
134
|
+
await sync(normalizedId, await readFile(normalizedId, "utf8"));
|
|
135
|
+
}
|
|
136
|
+
async function scanRoot({ entries, root, outDir }) {
|
|
137
|
+
const resolvedRoot = path.resolve(root);
|
|
138
|
+
const outDirIgnore = resolveOutDirIgnorePattern(resolvedRoot, outDir);
|
|
139
|
+
const ignore = outDirIgnore ? [...DEFAULT_SCAN_IGNORE, outDirIgnore] : DEFAULT_SCAN_IGNORE;
|
|
140
|
+
const files = entries ? await expandTailwindSourceEntries(entries, { ignore }) : await fg(SOURCE_CANDIDATE_GLOB, {
|
|
141
|
+
absolute: true,
|
|
142
|
+
cwd: resolvedRoot,
|
|
143
|
+
ignore,
|
|
144
|
+
onlyFiles: true,
|
|
145
|
+
unique: true
|
|
146
|
+
});
|
|
147
|
+
await Promise.all(files.map((file) => syncFile(file)));
|
|
148
|
+
}
|
|
149
|
+
function replaceFinal(id, nextCandidates) {
|
|
150
|
+
const normalizedId = cleanUrl(id);
|
|
151
|
+
const previousCandidates = candidatesById.get(normalizedId);
|
|
152
|
+
if (previousCandidates) {
|
|
153
|
+
removeCandidateSet(candidateCount, previousCandidates);
|
|
154
|
+
candidatesById.delete(normalizedId);
|
|
155
|
+
}
|
|
156
|
+
if (nextCandidates.size === 0) return;
|
|
157
|
+
candidatesById.set(normalizedId, nextCandidates);
|
|
158
|
+
addCandidateSet(candidateCount, nextCandidates);
|
|
159
|
+
}
|
|
160
|
+
function replaceScanLayer(id, nextCandidates) {
|
|
161
|
+
const normalizedId = cleanUrl(id);
|
|
162
|
+
if (nextCandidates.size === 0) scanCandidatesById.delete(normalizedId);
|
|
163
|
+
else scanCandidatesById.set(normalizedId, nextCandidates);
|
|
164
|
+
recompute(normalizedId);
|
|
165
|
+
}
|
|
166
|
+
function replaceTransformLayer(id, nextCandidates) {
|
|
167
|
+
const normalizedId = cleanUrl(id);
|
|
168
|
+
if (nextCandidates.size === 0) transformCandidatesById.delete(normalizedId);
|
|
169
|
+
else transformCandidatesById.set(normalizedId, nextCandidates);
|
|
170
|
+
recompute(normalizedId);
|
|
171
|
+
}
|
|
172
|
+
function recompute(id) {
|
|
173
|
+
const normalizedId = cleanUrl(id);
|
|
174
|
+
replaceFinal(normalizedId, new Set([...scanCandidatesById.get(normalizedId) ?? [], ...transformCandidatesById.get(normalizedId) ?? []]));
|
|
175
|
+
}
|
|
176
|
+
function syncInline(inlineCandidates) {
|
|
177
|
+
inlineIncludedCandidates = new Set(inlineCandidates?.included ?? []);
|
|
178
|
+
inlineExcludedCandidates = new Set(inlineCandidates?.excluded ?? []);
|
|
179
|
+
}
|
|
180
|
+
function remove(id) {
|
|
181
|
+
const normalizedId = cleanUrl(id);
|
|
182
|
+
scanCandidatesById.delete(normalizedId);
|
|
183
|
+
transformCandidatesById.delete(normalizedId);
|
|
184
|
+
const previousCandidates = candidatesById.get(normalizedId);
|
|
185
|
+
if (!previousCandidates) return;
|
|
186
|
+
removeCandidateSet(candidateCount, previousCandidates);
|
|
187
|
+
candidatesById.delete(normalizedId);
|
|
188
|
+
}
|
|
189
|
+
function values() {
|
|
190
|
+
const values = new Set([...candidateCount.keys(), ...inlineIncludedCandidates]);
|
|
191
|
+
for (const candidate of inlineExcludedCandidates) values.delete(candidate);
|
|
192
|
+
return values;
|
|
193
|
+
}
|
|
194
|
+
function valuesForEntries(entries) {
|
|
195
|
+
if (entries === void 0) return values();
|
|
196
|
+
const filtered = /* @__PURE__ */ new Set();
|
|
197
|
+
for (const [id, candidates] of candidatesById) {
|
|
198
|
+
if (!isFileMatchedByEntries(id, entries)) continue;
|
|
199
|
+
for (const candidate of candidates) filtered.add(candidate);
|
|
200
|
+
}
|
|
201
|
+
for (const candidate of inlineIncludedCandidates) filtered.add(candidate);
|
|
202
|
+
for (const candidate of inlineExcludedCandidates) filtered.delete(candidate);
|
|
203
|
+
return filtered;
|
|
204
|
+
}
|
|
205
|
+
function clear() {
|
|
206
|
+
candidatesById.clear();
|
|
207
|
+
scanCandidatesById.clear();
|
|
208
|
+
transformCandidatesById.clear();
|
|
209
|
+
candidateCount.clear();
|
|
210
|
+
inlineIncludedCandidates.clear();
|
|
211
|
+
inlineExcludedCandidates.clear();
|
|
212
|
+
}
|
|
213
|
+
function snapshot() {
|
|
214
|
+
return {
|
|
215
|
+
candidatesById: [...candidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
|
|
216
|
+
scanCandidatesById: [...scanCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
|
|
217
|
+
transformCandidatesById: [...transformCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
|
|
218
|
+
inlineExcludedCandidates: [...inlineExcludedCandidates],
|
|
219
|
+
inlineIncludedCandidates: [...inlineIncludedCandidates]
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
function restore(snapshot) {
|
|
223
|
+
clear();
|
|
224
|
+
inlineExcludedCandidates = new Set(snapshot.inlineExcludedCandidates);
|
|
225
|
+
inlineIncludedCandidates = new Set(snapshot.inlineIncludedCandidates);
|
|
226
|
+
const scanEntries = snapshot.scanCandidatesById ?? snapshot.candidatesById;
|
|
227
|
+
for (const [id, candidates] of scanEntries) {
|
|
228
|
+
const candidateSet = new Set(candidates);
|
|
229
|
+
if (candidateSet.size === 0) continue;
|
|
230
|
+
scanCandidatesById.set(id, candidateSet);
|
|
231
|
+
}
|
|
232
|
+
for (const [id, candidates] of snapshot.transformCandidatesById ?? []) {
|
|
233
|
+
const candidateSet = new Set(candidates);
|
|
234
|
+
if (candidateSet.size === 0) continue;
|
|
235
|
+
transformCandidatesById.set(id, candidateSet);
|
|
236
|
+
}
|
|
237
|
+
for (const [id, candidates] of snapshot.candidatesById) {
|
|
238
|
+
const candidateSet = new Set(candidates);
|
|
239
|
+
if (candidateSet.size === 0) continue;
|
|
240
|
+
candidatesById.set(id, candidateSet);
|
|
241
|
+
addCandidateSet(candidateCount, candidateSet);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
sync,
|
|
246
|
+
merge,
|
|
247
|
+
syncFile,
|
|
248
|
+
scanRoot,
|
|
249
|
+
syncInline,
|
|
250
|
+
remove,
|
|
251
|
+
values,
|
|
252
|
+
valuesForEntries,
|
|
253
|
+
snapshot,
|
|
254
|
+
restore,
|
|
255
|
+
clear
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
//#endregion
|
|
259
|
+
export { isSourceCandidateRequest as n, createSourceCandidateCollector as t };
|
|
@@ -8,4 +8,5 @@ export declare const runtimeSignaturePatchersSymbol: unique symbol;
|
|
|
8
8
|
export declare function invalidateRuntimeClassSet(twPatcher?: TailwindcssPatcherLike): void;
|
|
9
9
|
export declare function getRuntimeClassSetCacheEntry(twPatcher: TailwindcssPatcherLike): RuntimeClassSetCacheEntry;
|
|
10
10
|
export declare function getRuntimeClassSetSignature(twPatcher: TailwindcssPatcherLike): string;
|
|
11
|
+
export declare function getRuntimeClassSetSignatureWithSources(twPatcher: TailwindcssPatcherLike): Promise<string>;
|
|
11
12
|
export {};
|
|
@@ -34,12 +34,15 @@ export interface TailwindV3ResolvedSource {
|
|
|
34
34
|
export interface TailwindV3GenerateOptions {
|
|
35
35
|
candidates?: Iterable<string> | undefined;
|
|
36
36
|
sources?: TailwindV3CandidateSource[] | undefined;
|
|
37
|
+
incrementalCache?: boolean | undefined;
|
|
37
38
|
target?: TailwindV3GenerateTarget | undefined;
|
|
38
39
|
styleOptions?: Partial<IStyleHandlerOptions> | undefined;
|
|
39
40
|
}
|
|
40
41
|
export interface TailwindV3GenerateResult {
|
|
41
42
|
css: string;
|
|
42
43
|
rawCss: string;
|
|
44
|
+
incrementalCss?: string | undefined;
|
|
45
|
+
incrementalRawCss?: string | undefined;
|
|
43
46
|
classSet: Set<string>;
|
|
44
47
|
rawCandidates: Set<string>;
|
|
45
48
|
dependencies: string[];
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import type { IStyleHandlerOptions } from '@weapp-tailwindcss/postcss/types';
|
|
2
2
|
import type { TailwindV4Engine as PatchTailwindV4Engine, TailwindV4GenerateOptions as PatchTailwindV4GenerateOptions, TailwindV4GenerateResult as PatchTailwindV4GenerateResult, TailwindV4CandidateSource, TailwindV4DesignSystem, TailwindV4ResolvedSource, TailwindV4SourceOptions } from 'tailwindcss-patch';
|
|
3
3
|
export type TailwindV4GenerateTarget = 'weapp' | 'web' | 'tailwind';
|
|
4
|
+
export interface TailwindV4SourcePattern {
|
|
5
|
+
base: string;
|
|
6
|
+
pattern: string;
|
|
7
|
+
negated: boolean;
|
|
8
|
+
}
|
|
4
9
|
type TailwindV4PatchGenerateOptions = Omit<PatchTailwindV4GenerateOptions, 'target' | 'styleOptions' | 'tailwindcssV3Compatibility' | 'scanSources'>;
|
|
5
10
|
export interface TailwindV4GenerateOptions extends TailwindV4PatchGenerateOptions {
|
|
11
|
+
incrementalCache?: boolean | undefined;
|
|
6
12
|
target?: TailwindV4GenerateTarget | undefined;
|
|
7
13
|
styleOptions?: Partial<IStyleHandlerOptions> | undefined;
|
|
8
14
|
tailwindcssV3Compatibility?: boolean | undefined;
|
|
@@ -11,6 +17,8 @@ export interface TailwindV4GenerateOptions extends TailwindV4PatchGenerateOption
|
|
|
11
17
|
export interface TailwindV4GenerateResult extends Omit<PatchTailwindV4GenerateResult, 'css'> {
|
|
12
18
|
css: string;
|
|
13
19
|
rawCss: string;
|
|
20
|
+
incrementalCss?: string | undefined;
|
|
21
|
+
incrementalRawCss?: string | undefined;
|
|
14
22
|
target: TailwindV4GenerateTarget;
|
|
15
23
|
}
|
|
16
24
|
export interface TailwindV4Engine extends Omit<PatchTailwindV4Engine, 'generate'> {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as omitUndefined, H as findWorkspacePackageDir, I as createTailwindcssPatcher, L as readInstalledPackageMajorVersion, U as findWorkspaceRoot, V as findNearestPackageRoot, f as runtimeSignaturePatchersSymbol } from "./v3-engine-D61eilBl.mjs";
|
|
2
2
|
import { n as defuOverrideArray } from "./utils-CGBVVNm6.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
5
|
import path from "node:path";
|
|
5
6
|
import process from "node:process";
|
|
6
7
|
import { logger } from "@weapp-tailwindcss/logger";
|
|
7
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
9
|
//#region src/tailwindcss/v4/css-sources.ts
|
|
10
10
|
function hasCssEntriesValue(value) {
|
|
@@ -23,15 +23,20 @@ function normalizeCssSourceFile(file) {
|
|
|
23
23
|
if (!file) return;
|
|
24
24
|
return path.isAbsolute(file) ? path.normalize(file) : file;
|
|
25
25
|
}
|
|
26
|
+
function normalizeCssSourceBase(base) {
|
|
27
|
+
if (!base) return;
|
|
28
|
+
return path.resolve(base);
|
|
29
|
+
}
|
|
26
30
|
function normalizeDependencies(dependencies) {
|
|
27
31
|
return dependencies?.map(normalizeCssSourceFile).filter((dependency) => typeof dependency === "string" && dependency.length > 0);
|
|
28
32
|
}
|
|
29
33
|
function isSameCssSource(a, b) {
|
|
30
|
-
return a.css === b.css && a.base === b.base && normalizeCssSourceFile(a.file) === normalizeCssSourceFile(b.file) && JSON.stringify(normalizeDependencies(a.dependencies)) === JSON.stringify(normalizeDependencies(b.dependencies));
|
|
34
|
+
return a.css === b.css && normalizeCssSourceBase(a.base) === normalizeCssSourceBase(b.base) && normalizeCssSourceFile(a.file) === normalizeCssSourceFile(b.file) && JSON.stringify(normalizeDependencies(a.dependencies)) === JSON.stringify(normalizeDependencies(b.dependencies));
|
|
31
35
|
}
|
|
32
36
|
function upsertTailwindV4CssSource(opts, source) {
|
|
33
37
|
const normalizedSource = omitUndefined({
|
|
34
38
|
...source,
|
|
39
|
+
...source.base === void 0 ? {} : { base: normalizeCssSourceBase(source.base) },
|
|
35
40
|
...source.file === void 0 ? {} : { file: normalizeCssSourceFile(source.file) },
|
|
36
41
|
...source.dependencies === void 0 ? {} : { dependencies: normalizeDependencies(source.dependencies) }
|
|
37
42
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const
|
|
2
|
+
const require_v3_engine = require("./v3-engine-DwV1E6rX.js");
|
|
3
3
|
require("./utils-4ODFyoqD.js");
|
|
4
|
+
let node_fs = require("node:fs");
|
|
4
5
|
let node_module = require("node:module");
|
|
5
6
|
let node_path = require("node:path");
|
|
6
7
|
node_path = require_chunk.__toESM(node_path);
|
|
7
8
|
let node_process = require("node:process");
|
|
8
9
|
node_process = require_chunk.__toESM(node_process);
|
|
9
10
|
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
10
|
-
let node_fs = require("node:fs");
|
|
11
11
|
let node_url = require("node:url");
|
|
12
12
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
13
13
|
//#region src/tailwindcss/v4/css-sources.ts
|
|
@@ -27,15 +27,20 @@ function normalizeCssSourceFile(file) {
|
|
|
27
27
|
if (!file) return;
|
|
28
28
|
return node_path.default.isAbsolute(file) ? node_path.default.normalize(file) : file;
|
|
29
29
|
}
|
|
30
|
+
function normalizeCssSourceBase(base) {
|
|
31
|
+
if (!base) return;
|
|
32
|
+
return node_path.default.resolve(base);
|
|
33
|
+
}
|
|
30
34
|
function normalizeDependencies(dependencies) {
|
|
31
35
|
return dependencies?.map(normalizeCssSourceFile).filter((dependency) => typeof dependency === "string" && dependency.length > 0);
|
|
32
36
|
}
|
|
33
37
|
function isSameCssSource(a, b) {
|
|
34
|
-
return a.css === b.css && a.base === b.base && normalizeCssSourceFile(a.file) === normalizeCssSourceFile(b.file) && JSON.stringify(normalizeDependencies(a.dependencies)) === JSON.stringify(normalizeDependencies(b.dependencies));
|
|
38
|
+
return a.css === b.css && normalizeCssSourceBase(a.base) === normalizeCssSourceBase(b.base) && normalizeCssSourceFile(a.file) === normalizeCssSourceFile(b.file) && JSON.stringify(normalizeDependencies(a.dependencies)) === JSON.stringify(normalizeDependencies(b.dependencies));
|
|
35
39
|
}
|
|
36
40
|
function upsertTailwindV4CssSource(opts, source) {
|
|
37
|
-
const normalizedSource =
|
|
41
|
+
const normalizedSource = require_v3_engine.omitUndefined({
|
|
38
42
|
...source,
|
|
43
|
+
...source.base === void 0 ? {} : { base: normalizeCssSourceBase(source.base) },
|
|
39
44
|
...source.file === void 0 ? {} : { file: normalizeCssSourceFile(source.file) },
|
|
40
45
|
...source.dependencies === void 0 ? {} : { dependencies: normalizeDependencies(source.dependencies) }
|
|
41
46
|
});
|
|
@@ -175,7 +180,7 @@ function createMultiTailwindcssPatcher(patchers) {
|
|
|
175
180
|
}
|
|
176
181
|
if (result.classSet) for (const className of result.classSet) aggregatedSet.add(className);
|
|
177
182
|
}
|
|
178
|
-
return
|
|
183
|
+
return require_v3_engine.omitUndefined({
|
|
179
184
|
classList: aggregatedList,
|
|
180
185
|
classSet: aggregatedSet,
|
|
181
186
|
filename
|
|
@@ -191,7 +196,7 @@ function createMultiTailwindcssPatcher(patchers) {
|
|
|
191
196
|
}
|
|
192
197
|
return aggregated;
|
|
193
198
|
};
|
|
194
|
-
Object.defineProperty(multiPatcher,
|
|
199
|
+
Object.defineProperty(multiPatcher, require_v3_engine.runtimeSignaturePatchersSymbol, {
|
|
195
200
|
value: [...patchers],
|
|
196
201
|
configurable: true
|
|
197
202
|
});
|
|
@@ -225,7 +230,7 @@ function guessBasedirFromEntries(entries) {
|
|
|
225
230
|
const trimmed = entry.trim();
|
|
226
231
|
if (!trimmed || !node_path.default.isAbsolute(trimmed)) continue;
|
|
227
232
|
const entryDir = node_path.default.dirname(trimmed);
|
|
228
|
-
const resolved =
|
|
233
|
+
const resolved = require_v3_engine.findNearestPackageRoot(entryDir) ?? entryDir;
|
|
229
234
|
if (resolved) return resolved;
|
|
230
235
|
}
|
|
231
236
|
}
|
|
@@ -251,7 +256,7 @@ function resolveCssEntryBase(entryDir, options) {
|
|
|
251
256
|
const { preferredBaseDir, workspaceRoot } = options;
|
|
252
257
|
if (preferredBaseDir && isSubPath(preferredBaseDir, normalizedDir)) return preferredBaseDir;
|
|
253
258
|
if (workspaceRoot && isSubPath(workspaceRoot, normalizedDir)) return workspaceRoot;
|
|
254
|
-
const packageRoot =
|
|
259
|
+
const packageRoot = require_v3_engine.findNearestPackageRoot(normalizedDir);
|
|
255
260
|
if (packageRoot) return node_path.default.normalize(packageRoot);
|
|
256
261
|
return normalizedDir;
|
|
257
262
|
}
|
|
@@ -294,7 +299,7 @@ function createPatcherForBase(baseDir, cssEntries, options) {
|
|
|
294
299
|
cwd: baseDir,
|
|
295
300
|
v2: { cwd: baseDir },
|
|
296
301
|
v3: { cwd: baseDir },
|
|
297
|
-
v4: hasCssEntries ?
|
|
302
|
+
v4: hasCssEntries ? require_v3_engine.omitUndefined({ cssEntries }) : require_v3_engine.omitUndefined({
|
|
298
303
|
base: baseDir,
|
|
299
304
|
cssEntries
|
|
300
305
|
})
|
|
@@ -317,7 +322,7 @@ function createPatcherForBase(baseDir, cssEntries, options) {
|
|
|
317
322
|
const explicitTailwindVersion = resolveExplicitTailwindVersion(tailwindcss?.version || tailwindcssPatcherOptions?.tailwindcss?.version || mergedTailwindOptions.version, configuredPackageName);
|
|
318
323
|
const hasExplicitV4Signals = hasCssEntries || hasOwnV4Signal(tailwindcss) || hasOwnV4Signal(tailwindcssPatcherOptions?.tailwindcss);
|
|
319
324
|
const packageNameForVersionDetection = configuredPackageName ?? mergedTailwindOptions.packageName ?? "tailwindcss";
|
|
320
|
-
const installedTailwindVersion =
|
|
325
|
+
const installedTailwindVersion = require_v3_engine.readInstalledPackageMajorVersion(packageNameForVersionDetection, baseDir);
|
|
321
326
|
const resolvedTailwindVersion = installedTailwindVersion ?? explicitTailwindVersion;
|
|
322
327
|
const supportedResolvedTailwindVersion = resolvedTailwindVersion === 2 || resolvedTailwindVersion === 3 || resolvedTailwindVersion === 4 ? resolvedTailwindVersion : void 0;
|
|
323
328
|
const shouldPatchV4PostcssPackage = (resolvedTailwindVersion === 4 && (installedTailwindVersion === 4 || explicitTailwindVersion === 4 || hasExplicitV4Signals && isTailwindcss4Package(packageNameForVersionDetection)) || resolvedTailwindVersion === void 0 && (hasCssEntries || hasOwnV4Signal(tailwindcss) || hasOwnV4Signal(tailwindcssPatcherOptions?.tailwindcss))) && !Boolean(configuredPackageName);
|
|
@@ -334,7 +339,7 @@ function createPatcherForBase(baseDir, cssEntries, options) {
|
|
|
334
339
|
};
|
|
335
340
|
if (supportedResolvedTailwindVersion) tailwindOptionsForPackage.version = supportedResolvedTailwindVersion;
|
|
336
341
|
try {
|
|
337
|
-
patchers.push(
|
|
342
|
+
patchers.push(require_v3_engine.createTailwindcssPatcher(require_v3_engine.omitUndefined({
|
|
338
343
|
basedir: baseDir,
|
|
339
344
|
supportCustomLengthUnitsPatch: supportCustomLengthUnitsPatch ?? true,
|
|
340
345
|
tailwindcss: tailwindOptionsForPackage,
|
|
@@ -501,9 +506,9 @@ function resolveTailwindcssBasedir(basedir, fallback) {
|
|
|
501
506
|
return node_path.default.normalize(node_path.default.dirname(packageJsonPath));
|
|
502
507
|
} catch {
|
|
503
508
|
if (node_process.default.env["WEAPP_TW_DEBUG_STACK"] === "1") _weapp_tailwindcss_logger.logger.debug("failed to resolve package json for %s", packageName);
|
|
504
|
-
const workspaceRoot =
|
|
509
|
+
const workspaceRoot = require_v3_engine.findWorkspaceRoot(anchor);
|
|
505
510
|
if (workspaceRoot) {
|
|
506
|
-
const packageDir =
|
|
511
|
+
const packageDir = require_v3_engine.findWorkspacePackageDir(workspaceRoot, packageName);
|
|
507
512
|
if (packageDir) return packageDir;
|
|
508
513
|
}
|
|
509
514
|
}
|
|
@@ -577,8 +582,8 @@ function createTailwindcssPatcherFromContext(ctx) {
|
|
|
577
582
|
appType,
|
|
578
583
|
bareArbitraryValues: arbitraryValues?.bareArbitraryValues
|
|
579
584
|
};
|
|
580
|
-
const workspaceRoot =
|
|
581
|
-
const groupedCssEntries = normalizedCssEntries ? groupCssEntriesByBase(normalizedCssEntries,
|
|
585
|
+
const workspaceRoot = require_v3_engine.findWorkspaceRoot(resolvedTailwindcssBasedir) ?? (absoluteCssEntryBasedir ? require_v3_engine.findWorkspaceRoot(absoluteCssEntryBasedir) : void 0);
|
|
586
|
+
const groupedCssEntries = normalizedCssEntries ? groupCssEntriesByBase(normalizedCssEntries, require_v3_engine.omitUndefined({
|
|
582
587
|
preferredBaseDir: resolvedTailwindcssBasedir,
|
|
583
588
|
workspaceRoot
|
|
584
589
|
})) : void 0;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -34,6 +34,12 @@ export interface TailwindcssPatcherLike {
|
|
|
34
34
|
collectContentTokens?: TailwindcssPatcher['collectContentTokens'] | undefined;
|
|
35
35
|
options?: TailwindcssPatcher['options'] | undefined;
|
|
36
36
|
}
|
|
37
|
+
export type BabelParserOptions = ParserOptions & {
|
|
38
|
+
cache?: boolean | undefined;
|
|
39
|
+
cacheKey?: string | undefined;
|
|
40
|
+
cacheMaxEntries?: number | undefined;
|
|
41
|
+
cacheMaxSourceLength?: number | undefined;
|
|
42
|
+
};
|
|
37
43
|
export interface RefreshTailwindcssPatcherOptions {
|
|
38
44
|
clearCache?: boolean | undefined;
|
|
39
45
|
}
|
|
@@ -48,7 +54,7 @@ export interface IJsHandlerOptions {
|
|
|
48
54
|
generateMap?: boolean | undefined;
|
|
49
55
|
alwaysEscape?: boolean | undefined;
|
|
50
56
|
unescapeUnicode?: boolean | undefined;
|
|
51
|
-
babelParserOptions?:
|
|
57
|
+
babelParserOptions?: BabelParserOptions | undefined;
|
|
52
58
|
ignoreTaggedTemplateExpressionIdentifiers?: (string | RegExp)[] | undefined;
|
|
53
59
|
ignoreCallExpressionIdentifiers?: (string | RegExp)[] | undefined;
|
|
54
60
|
uniAppX?: boolean | undefined;
|
|
@@ -19,6 +19,8 @@ export interface UserDefinedOptionsGeneralPart {
|
|
|
19
19
|
babelParserOptions?: (ParserOptions & {
|
|
20
20
|
cache?: boolean | undefined;
|
|
21
21
|
cacheKey?: string | undefined;
|
|
22
|
+
cacheMaxEntries?: number | undefined;
|
|
23
|
+
cacheMaxSourceLength?: number | undefined;
|
|
22
24
|
}) | undefined;
|
|
23
25
|
cssChildCombinatorReplaceValue?: string | string[] | undefined;
|
|
24
26
|
postcssOptions?: LoadedPostcssOptions | undefined;
|