weapp-tailwindcss 5.1.3 → 5.1.4
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/auto-CrJJc5rK.mjs +13 -0
- package/dist/bundlers/shared/generator-css/local-imports.d.ts +1 -10
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/temporary-css-assets.d.ts +1 -1
- package/dist/bundlers/vite/processed-css-assets.d.ts +1 -0
- package/dist/{context-B07Vf584.mjs → context-Bkpmt3ja.mjs} +31 -5
- package/dist/{context-D75pwtBW.js → context-DCVMkTRj.js} +36 -4
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro/auto.d.ts +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/framework/platform.d.ts +2 -0
- package/dist/{generator-DNs6ekoC.mjs → generator-24-HgU9F.mjs} +5 -3
- package/dist/{generator-CV_0irKO.js → generator-CilgHtxb.js} +5 -3
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-aQMZ0M7c.mjs → gulp-0RsqkF_d.mjs} +4 -4
- package/dist/{gulp-B_u8NjQL.js → gulp-Bogfnoki.js} +7 -6
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-DLYQTCDb.mjs → hmr-timing-BRNaz8Od.mjs} +41 -148
- package/dist/{hmr-timing-DOoHun3i.js → hmr-timing-BV6nFPoT.js} +41 -166
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/postcss.js +2 -2
- package/dist/postcss.mjs +2 -2
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/rspack.js +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/{source-candidate-scan-signature-pS87mdHZ.mjs → source-candidate-scan-signature-BB1hvW68.mjs} +12 -6
- package/dist/{source-candidate-scan-signature-DzwebZrf.js → source-candidate-scan-signature-CaDT0gkj.js} +13 -6
- package/dist/tailwindcss/v4-engine/css-macro-source.d.ts +2 -0
- package/dist/{tailwindcss-BwV3_Ryc.mjs → tailwindcss-D0JF0fuZ.mjs} +4 -4
- package/dist/{tailwindcss-BSCvrs1p.js → tailwindcss-D2xs4OEu.js} +4 -4
- package/dist/{transform-Clj7R818.mjs → transform-BP86eSZp.mjs} +1 -1
- package/dist/{transform-fin-OTVD.js → transform-CXCQ28Tc.js} +1 -1
- package/dist/{v4-engine-BklH3CpJ.mjs → v4-engine-BuuYDXt1.mjs} +54 -114
- package/dist/{v4-engine-CKbS27-o.js → v4-engine-CKtsdKxK.js} +57 -111
- package/dist/{vite-5Wn0PIzJ.mjs → vite-B1SlBmqO.mjs} +212 -44
- package/dist/{vite-CkVMSDDp.js → vite-BYgT1ir9.js} +214 -46
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +89 -191
- package/dist/{webpack-DEag6ueE.mjs → webpack-Bg6pefpb.mjs} +49 -6
- package/dist/{webpack-hvSFaicc.js → webpack-khSwkXP5.js} +50 -7
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +3 -3
- package/dist/auto-Ba6hDrse.mjs +0 -13
|
@@ -151,14 +151,14 @@ function parseConfigRequest$1(params) {
|
|
|
151
151
|
function isPackageJsonImportRequest$2(request) {
|
|
152
152
|
return typeof request === "string" && request.startsWith("#");
|
|
153
153
|
}
|
|
154
|
-
function isWeappTailwindcssImportRequest
|
|
154
|
+
function isWeappTailwindcssImportRequest(request) {
|
|
155
155
|
return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
|
|
156
156
|
}
|
|
157
157
|
function isTailwindImportRequest$1(request) {
|
|
158
158
|
return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
|
|
159
159
|
}
|
|
160
160
|
function normalizeTailwindImportRequest$1(request, options = {}) {
|
|
161
|
-
if (options.importFallback && isWeappTailwindcssImportRequest
|
|
161
|
+
if (options.importFallback && isWeappTailwindcssImportRequest(request)) return request.replace(/^weapp-tailwindcss/, "tailwindcss");
|
|
162
162
|
return request;
|
|
163
163
|
}
|
|
164
164
|
function replaceImportRequest$1(params, request, replacement) {
|
|
@@ -170,7 +170,7 @@ function normalizeTailwindDirectiveLine(line, options = {}) {
|
|
|
170
170
|
const trimmed = line.trimStart();
|
|
171
171
|
if (/^@(?:use|forward)\b/.test(trimmed)) {
|
|
172
172
|
const request = parseImportRequest$1(trimmed.replace(/^@(?:use|forward)\b/, ""));
|
|
173
|
-
if (isTailwindImportRequest$1(request) || options.importFallback && isWeappTailwindcssImportRequest
|
|
173
|
+
if (isTailwindImportRequest$1(request) || options.importFallback && isWeappTailwindcssImportRequest(request)) {
|
|
174
174
|
const normalizedRequest = normalizeTailwindImportRequest$1(request, options);
|
|
175
175
|
return replaceImportRequest$1(line.replace(/^(\s*)@(?:use|forward)\b/, "$1@import"), request, normalizedRequest);
|
|
176
176
|
}
|
|
@@ -178,7 +178,7 @@ function normalizeTailwindDirectiveLine(line, options = {}) {
|
|
|
178
178
|
}
|
|
179
179
|
if (!options.importFallback || !trimmed.startsWith("@import")) return line;
|
|
180
180
|
const request = parseImportRequest$1(trimmed.replace(/^@import\b/, ""));
|
|
181
|
-
if (!request || !isWeappTailwindcssImportRequest
|
|
181
|
+
if (!request || !isWeappTailwindcssImportRequest(request)) return line;
|
|
182
182
|
return replaceImportRequest$1(line, request, request.replace(/^weapp-tailwindcss/, "tailwindcss"));
|
|
183
183
|
}
|
|
184
184
|
function extractTailwindDirectiveLines(rawSource, options = {}) {
|
|
@@ -310,32 +310,18 @@ const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = /* @__PURE__ */ new Set([
|
|
|
310
310
|
"utility",
|
|
311
311
|
"variant"
|
|
312
312
|
]);
|
|
313
|
-
const TAILWIND_ROOT_DIRECTIVE_NAMES = /* @__PURE__ */ new Set([
|
|
314
|
-
"config",
|
|
315
|
-
"custom-variant",
|
|
316
|
-
"plugin",
|
|
317
|
-
"source",
|
|
318
|
-
"tailwind",
|
|
319
|
-
"theme",
|
|
320
|
-
"utility",
|
|
321
|
-
"variant"
|
|
322
|
-
]);
|
|
323
313
|
const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|(?:use|forward)\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|tailwind|config|custom-variant|plugin|source|theme|utility|variant)\b/;
|
|
324
314
|
function parseImportRequest(params) {
|
|
325
|
-
return
|
|
315
|
+
return (0, _weapp_tailwindcss_postcss.parseTailwindCssDirectiveRequest)(params);
|
|
326
316
|
}
|
|
327
317
|
function parseConfigRequest(params) {
|
|
328
|
-
return
|
|
318
|
+
return (0, _weapp_tailwindcss_postcss.parseTailwindCssConfigRequest)(params);
|
|
329
319
|
}
|
|
330
320
|
function isPackageJsonImportRequest$1(request) {
|
|
331
|
-
return
|
|
332
|
-
}
|
|
333
|
-
function isWeappTailwindcssImportRequest(request) {
|
|
334
|
-
return request === "weapp-tailwindcss" || request?.startsWith("weapp-tailwindcss/");
|
|
321
|
+
return (0, _weapp_tailwindcss_postcss.isTailwindCssPackageJsonImportRequest)(request);
|
|
335
322
|
}
|
|
336
323
|
function normalizeTailwindImportRequest(request, options = {}) {
|
|
337
|
-
|
|
338
|
-
return request;
|
|
324
|
+
return (0, _weapp_tailwindcss_postcss.normalizeTailwindCssImportRequest)(request, options);
|
|
339
325
|
}
|
|
340
326
|
function replaceImportRequest(params, request, replacement) {
|
|
341
327
|
const index = params.indexOf(request);
|
|
@@ -391,12 +377,11 @@ function normalizeTailwindSourceDirectives(rawSource, options = {}) {
|
|
|
391
377
|
}
|
|
392
378
|
}
|
|
393
379
|
function isTailwindImportRequest(request) {
|
|
394
|
-
|
|
380
|
+
const normalized = normalizeTailwindImportRequest(request);
|
|
381
|
+
return normalized === "tailwindcss" || normalized === "tailwindcss4" || normalized?.startsWith("tailwindcss/") === true || normalized?.startsWith("tailwindcss4/") === true;
|
|
395
382
|
}
|
|
396
383
|
function isTailwindImportAtRule(node, options = {}) {
|
|
397
|
-
|
|
398
|
-
if (node.name !== "import" && node.name !== "use" && node.name !== "forward") return false;
|
|
399
|
-
return isTailwindImportRequest(normalizeTailwindImportRequest(parseImportRequest(node.params), options));
|
|
384
|
+
return (0, _weapp_tailwindcss_postcss.isTailwindCssImportAtRule)(node, options);
|
|
400
385
|
}
|
|
401
386
|
function isTailwindSourceDirective(node, options = {}) {
|
|
402
387
|
if (node.type !== "atrule") return false;
|
|
@@ -410,10 +395,18 @@ function hasGeneratedCssArtifacts(rawSource) {
|
|
|
410
395
|
return hasTailwindGeneratedCssMarkers(rawSource) && !GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
|
|
411
396
|
}
|
|
412
397
|
function isTailwindGenerationDirective(node, options = {}) {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
398
|
+
return (0, _weapp_tailwindcss_postcss.isTailwindCssGenerationDirective)(node, options);
|
|
399
|
+
}
|
|
400
|
+
function analyzeParseableTailwindDirectives(rawSource, options = {}) {
|
|
401
|
+
try {
|
|
402
|
+
const ignoreLayer = options.ignoreLayer ?? hasGeneratedCssArtifacts(rawSource);
|
|
403
|
+
return (0, _weapp_tailwindcss_postcss.analyzeTailwindCssDirectives)(_weapp_tailwindcss_postcss.postcss.parse(rawSource), {
|
|
404
|
+
...options,
|
|
405
|
+
ignoreLayer
|
|
406
|
+
});
|
|
407
|
+
} catch {
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
417
410
|
}
|
|
418
411
|
function removeTailwindSourceDirectives(rawSource, options = {}) {
|
|
419
412
|
try {
|
|
@@ -433,56 +426,19 @@ function removeTailwindSourceDirectives(rawSource, options = {}) {
|
|
|
433
426
|
}
|
|
434
427
|
}
|
|
435
428
|
function hasTailwindSourceDirectives(rawSource, options = {}) {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
439
|
-
let found = false;
|
|
440
|
-
const ignoreLayer = hasGeneratedCssArtifacts(rawSource);
|
|
441
|
-
root.walk((node) => {
|
|
442
|
-
if (isTailwindGenerationDirective(node, {
|
|
443
|
-
...options,
|
|
444
|
-
ignoreLayer
|
|
445
|
-
})) {
|
|
446
|
-
found = true;
|
|
447
|
-
return false;
|
|
448
|
-
}
|
|
449
|
-
});
|
|
450
|
-
return found;
|
|
451
|
-
} catch {
|
|
452
|
-
return extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
453
|
-
}
|
|
429
|
+
if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
|
|
430
|
+
return analyzeParseableTailwindDirectives(rawSource, options)?.hasTailwindSourceDirectives ?? extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
454
431
|
}
|
|
455
432
|
function hasTailwindRootDirectives(rawSource, options = {}) {
|
|
456
433
|
if (!TAILWIND_ROOT_DIRECTIVE_RE.test(rawSource) && !(options.importFallback && rawSource.includes("weapp-tailwindcss"))) return false;
|
|
457
|
-
|
|
458
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
459
|
-
let found = false;
|
|
460
|
-
root.walkAtRules((node) => {
|
|
461
|
-
const request = node.name === "import" ? parseImportRequest(node.params) : node.name === "config" || node.name === "plugin" ? parseConfigRequest(node.params) : void 0;
|
|
462
|
-
if (isTailwindImportAtRule(node, options) || isPackageJsonImportRequest$1(request) || TAILWIND_ROOT_DIRECTIVE_NAMES.has(node.name)) {
|
|
463
|
-
found = true;
|
|
464
|
-
return false;
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
return found;
|
|
468
|
-
} catch {
|
|
469
|
-
return extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
470
|
-
}
|
|
434
|
+
return analyzeParseableTailwindDirectives(rawSource, options)?.hasTailwindRootDirectives ?? extractTailwindDirectiveLines(rawSource, options).length > 0;
|
|
471
435
|
}
|
|
472
436
|
function hasTailwindApplyDirective(rawSource) {
|
|
473
437
|
if (!rawSource.includes("@apply")) return false;
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
found = true;
|
|
479
|
-
return false;
|
|
480
|
-
});
|
|
481
|
-
return found;
|
|
482
|
-
} catch {
|
|
483
|
-
const fallback = extractTailwindSourceForPostcssFallback(rawSource);
|
|
484
|
-
return typeof fallback === "string" && /@apply\s[^;{}]+;/.test(fallback);
|
|
485
|
-
}
|
|
438
|
+
const analysis = analyzeParseableTailwindDirectives(rawSource);
|
|
439
|
+
if (analysis) return analysis.hasTailwindApplyDirective;
|
|
440
|
+
const fallback = extractTailwindSourceForPostcssFallback(rawSource);
|
|
441
|
+
return typeof fallback === "string" && /@apply\s[^;{}]+;/.test(fallback);
|
|
486
442
|
}
|
|
487
443
|
function resolveCssEntrySource(rawSource, base, options = {}) {
|
|
488
444
|
try {
|
|
@@ -598,6 +554,15 @@ function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
|
|
|
598
554
|
return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
|
|
599
555
|
}
|
|
600
556
|
//#endregion
|
|
557
|
+
//#region src/tailwindcss/v4-engine/css-macro-source.ts
|
|
558
|
+
function resolveCssMacroTailwindV4Source(source) {
|
|
559
|
+
const css = (0, _weapp_tailwindcss_postcss.transformCssMacroTailwindV4Source)(source.css);
|
|
560
|
+
return css === source.css ? source : {
|
|
561
|
+
...source,
|
|
562
|
+
css
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
//#endregion
|
|
601
566
|
//#region src/tailwindcss/v4-engine/tailwind-v4-default-colors.ts
|
|
602
567
|
const TAILWIND_V4_COLOR_STEPS = [
|
|
603
568
|
"50",
|
|
@@ -1662,7 +1627,7 @@ function createIncrementalStyleOptions(styleOptions) {
|
|
|
1662
1627
|
};
|
|
1663
1628
|
}
|
|
1664
1629
|
function resolveStyleOptions(source, options) {
|
|
1665
|
-
return (0, _weapp_tailwindcss_postcss.
|
|
1630
|
+
return (0, _weapp_tailwindcss_postcss.hasCssMacroTailwindV4Source)(source.css) ? (0, _weapp_tailwindcss_postcss.withCssMacroStyleOptions)(options) : options;
|
|
1666
1631
|
}
|
|
1667
1632
|
function collectCustomPropertyValues(css) {
|
|
1668
1633
|
const values = /* @__PURE__ */ new Map();
|
|
@@ -1715,7 +1680,7 @@ function createTailwindV4Engine(source) {
|
|
|
1715
1680
|
async function generateOnce(generateSource, options = {}) {
|
|
1716
1681
|
const { scanSources = true, styleOptions, target = "weapp", ...patchOptions } = options;
|
|
1717
1682
|
const resolvedStyleOptions = resolveStyleOptions(generateSource, styleOptions);
|
|
1718
|
-
const engine = (0, _tailwindcss_mangle_engine.createTailwindV4Engine)(createCompatibleSource(generateSource, target));
|
|
1683
|
+
const engine = (0, _tailwindcss_mangle_engine.createTailwindV4Engine)(createCompatibleSource(resolveCssMacroTailwindV4Source(generateSource), target));
|
|
1719
1684
|
const resolvedScanSources = await resolveScanSources(generateSource, scanSources);
|
|
1720
1685
|
const delegateSourceScan = shouldDelegateWebSourceScanToTailwind(target, resolvedScanSources);
|
|
1721
1686
|
const filesystemCandidates = !delegateSourceScan && Array.isArray(resolvedScanSources) ? new Set(await (0, _tailwindcss_mangle_engine.extractRawCandidates)(resolvedScanSources, { ...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues } })) : void 0;
|
|
@@ -1738,13 +1703,14 @@ function createTailwindV4Engine(source) {
|
|
|
1738
1703
|
}
|
|
1739
1704
|
async function generateWithIncrementalCache(options = {}) {
|
|
1740
1705
|
const target = options.target ?? "weapp";
|
|
1741
|
-
const
|
|
1706
|
+
const cssMacroSource = resolveCssMacroTailwindV4Source(source);
|
|
1707
|
+
const compatibleSource = createCompatibleSource(cssMacroSource, target);
|
|
1742
1708
|
const requestedCandidates = resolveTargetCandidates(options.candidates, target);
|
|
1743
1709
|
const styleOptions = resolveStyleOptions(source, options.styleOptions);
|
|
1744
|
-
if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(
|
|
1710
|
+
if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(cssMacroSource, options);
|
|
1745
1711
|
const cacheKey = createIncrementalGenerateCacheKey(compatibleSource, target, styleOptions);
|
|
1746
1712
|
if (options.scanSources === true) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1747
|
-
const generated = await generateOnce(
|
|
1713
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
1748
1714
|
if (!seedIncrementalGenerateCache({
|
|
1749
1715
|
compatibleSource,
|
|
1750
1716
|
generated,
|
|
@@ -1757,7 +1723,7 @@ function createTailwindV4Engine(source) {
|
|
|
1757
1723
|
const cached = incrementalGenerateCache.get(cacheKey);
|
|
1758
1724
|
if (cached) {
|
|
1759
1725
|
if (hasRemovedCandidates(cached.seenCandidates, requestedCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1760
|
-
const generated = await generateOnce(
|
|
1726
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
1761
1727
|
if (!seedIncrementalGenerateCache({
|
|
1762
1728
|
compatibleSource,
|
|
1763
1729
|
generated,
|
|
@@ -1781,7 +1747,7 @@ function createTailwindV4Engine(source) {
|
|
|
1781
1747
|
target: cached.target
|
|
1782
1748
|
};
|
|
1783
1749
|
if (shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1784
|
-
const generated = await generateOnce(
|
|
1750
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
1785
1751
|
if (!seedIncrementalGenerateCache({
|
|
1786
1752
|
compatibleSource,
|
|
1787
1753
|
generated,
|
|
@@ -1831,7 +1797,7 @@ function createTailwindV4Engine(source) {
|
|
|
1831
1797
|
});
|
|
1832
1798
|
}
|
|
1833
1799
|
return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
1834
|
-
const generated = await generateOnce(
|
|
1800
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
1835
1801
|
seedIncrementalGenerateCache({
|
|
1836
1802
|
compatibleSource,
|
|
1837
1803
|
generated,
|
|
@@ -2262,10 +2228,12 @@ function normalizeWeappTailwindcssGeneratorOptions(options, context = {}) {
|
|
|
2262
2228
|
...context,
|
|
2263
2229
|
generatorTarget: target
|
|
2264
2230
|
});
|
|
2231
|
+
const hasExplicitTarget = options !== void 0 && Object.hasOwn(options, "target");
|
|
2232
|
+
const webCompat = options?.webCompat ?? (!hasExplicitTarget && branch.isWeb ? true : void 0);
|
|
2265
2233
|
if (options == null) return {
|
|
2266
2234
|
target,
|
|
2267
2235
|
branch,
|
|
2268
|
-
webCompat
|
|
2236
|
+
webCompat,
|
|
2269
2237
|
importFallback: false,
|
|
2270
2238
|
bareArbitraryValues: void 0
|
|
2271
2239
|
};
|
|
@@ -2274,7 +2242,7 @@ function normalizeWeappTailwindcssGeneratorOptions(options, context = {}) {
|
|
|
2274
2242
|
branch,
|
|
2275
2243
|
config: options.config,
|
|
2276
2244
|
styleOptions: options.styleOptions,
|
|
2277
|
-
webCompat
|
|
2245
|
+
webCompat,
|
|
2278
2246
|
importFallback: options.importFallback ?? false,
|
|
2279
2247
|
bareArbitraryValues: options.bareArbitraryValues
|
|
2280
2248
|
};
|
|
@@ -2429,8 +2397,10 @@ function hasMiniProgramTailwindV4PreflightReset(css) {
|
|
|
2429
2397
|
}
|
|
2430
2398
|
function finalizeMiniProgramGeneratorCss(css, target, _majorVersion, cssPreflight, options = {}) {
|
|
2431
2399
|
if (target !== "weapp") return css;
|
|
2400
|
+
const injectPreflight = options.injectPreflight !== false && !hasMiniProgramTailwindV4PreflightReset(css);
|
|
2432
2401
|
return (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(css, {
|
|
2433
|
-
cssPreflight:
|
|
2402
|
+
cssPreflight: cssPreflight === false ? false : injectPreflight ? cssPreflight : void 0,
|
|
2403
|
+
cssSelectorReplacement: options.styleOptions?.cssOptions?.cssSelectorReplacement ?? options.styleOptions?.cssSelectorReplacement,
|
|
2434
2404
|
isTailwindcssV4: true,
|
|
2435
2405
|
tailwindcssV4GradientFallback: options.styleOptions?.cssOptions?.tailwindcssV4GradientFallback ?? options.styleOptions?.tailwindcssV4GradientFallback
|
|
2436
2406
|
});
|
|
@@ -5158,96 +5128,6 @@ function inheritLegacyUnitConvertedDeclarations(css, legacyCss) {
|
|
|
5158
5128
|
}
|
|
5159
5129
|
}
|
|
5160
5130
|
//#endregion
|
|
5161
|
-
//#region src/bundlers/shared/generator-css/local-imports.ts
|
|
5162
|
-
const REMOTE_IMPORT_RE = /^(?:https?:)?\/\//i;
|
|
5163
|
-
function createCssSourceOrderAppend(base, extra) {
|
|
5164
|
-
if (!base) return extra;
|
|
5165
|
-
if (!extra) return base;
|
|
5166
|
-
if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
|
|
5167
|
-
return `${base}\n${extra}`;
|
|
5168
|
-
}
|
|
5169
|
-
function isLocalImportRequest(request) {
|
|
5170
|
-
return request.length > 0 && !request.startsWith("#") && !request.startsWith("tailwindcss") && !request.startsWith("weapp-tailwindcss") && !request.startsWith("data:") && !REMOTE_IMPORT_RE.test(request);
|
|
5171
|
-
}
|
|
5172
|
-
function isPureLocalCssImportWrapper(css) {
|
|
5173
|
-
let hasImport = false;
|
|
5174
|
-
try {
|
|
5175
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
5176
|
-
for (const node of root.nodes) {
|
|
5177
|
-
if (node.type === "comment") continue;
|
|
5178
|
-
if (node.type !== "atrule" || node.name !== "import") return false;
|
|
5179
|
-
const request = parseImportRequest(node.params);
|
|
5180
|
-
if (!request || !isLocalImportRequest(request)) return false;
|
|
5181
|
-
hasImport = true;
|
|
5182
|
-
}
|
|
5183
|
-
} catch {
|
|
5184
|
-
return false;
|
|
5185
|
-
}
|
|
5186
|
-
return hasImport;
|
|
5187
|
-
}
|
|
5188
|
-
function cleanLocalCssImportWrapperTailwindDirectives(css) {
|
|
5189
|
-
let hasLocalImport = false;
|
|
5190
|
-
let hasTailwindDirective = false;
|
|
5191
|
-
try {
|
|
5192
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
5193
|
-
for (const node of root.nodes) {
|
|
5194
|
-
if (node.type === "comment") continue;
|
|
5195
|
-
if (node.type === "atrule" && node.name === "import") {
|
|
5196
|
-
const request = parseImportRequest(node.params);
|
|
5197
|
-
if (!request || !isLocalImportRequest(request)) return;
|
|
5198
|
-
hasLocalImport = true;
|
|
5199
|
-
continue;
|
|
5200
|
-
}
|
|
5201
|
-
if (node.type === "atrule" && node.name === "source") {
|
|
5202
|
-
hasTailwindDirective = true;
|
|
5203
|
-
continue;
|
|
5204
|
-
}
|
|
5205
|
-
return;
|
|
5206
|
-
}
|
|
5207
|
-
} catch {
|
|
5208
|
-
return;
|
|
5209
|
-
}
|
|
5210
|
-
return hasLocalImport && hasTailwindDirective ? prefixLocalCssImportsWithWebpackIgnore(removeTailwindSourceDirectives(css)) : void 0;
|
|
5211
|
-
}
|
|
5212
|
-
function prefixLocalCssImportsWithWebpackIgnore(css) {
|
|
5213
|
-
try {
|
|
5214
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
5215
|
-
root.walkAtRules("import", (atRule) => {
|
|
5216
|
-
const request = parseImportRequest(atRule.params);
|
|
5217
|
-
if (request && isLocalImportRequest(request)) atRule.raws.before = `${atRule.raws.before ?? ""}/* webpackIgnore: true */\n`;
|
|
5218
|
-
});
|
|
5219
|
-
return root.toString();
|
|
5220
|
-
} catch {
|
|
5221
|
-
return css;
|
|
5222
|
-
}
|
|
5223
|
-
}
|
|
5224
|
-
function splitLocalCssImports(source) {
|
|
5225
|
-
try {
|
|
5226
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
5227
|
-
const importRoot = _weapp_tailwindcss_postcss.postcss.root();
|
|
5228
|
-
let changed = false;
|
|
5229
|
-
for (const node of [...root.nodes]) {
|
|
5230
|
-
if (node.type !== "atrule" || node.name !== "import") continue;
|
|
5231
|
-
const request = parseImportRequest(node.params);
|
|
5232
|
-
if (!request || !isLocalImportRequest(request)) continue;
|
|
5233
|
-
importRoot.append(node.clone());
|
|
5234
|
-
node.remove();
|
|
5235
|
-
changed = true;
|
|
5236
|
-
}
|
|
5237
|
-
const imports = importRoot.nodes.filter((node) => node.type === "atrule" && node.name === "import").map((node) => `@import ${node.params};`).join("\n");
|
|
5238
|
-
return changed ? {
|
|
5239
|
-
imports,
|
|
5240
|
-
source: root.toString()
|
|
5241
|
-
} : void 0;
|
|
5242
|
-
} catch {
|
|
5243
|
-
return;
|
|
5244
|
-
}
|
|
5245
|
-
}
|
|
5246
|
-
function restoreLocalCssImports(css, imports) {
|
|
5247
|
-
if (!imports?.trim()) return css;
|
|
5248
|
-
return createCssSourceOrderAppend(imports, css);
|
|
5249
|
-
}
|
|
5250
|
-
//#endregion
|
|
5251
5131
|
//#region src/bundlers/shared/generator-css/user-layer-order.ts
|
|
5252
5132
|
const USER_LAYER_COMPONENTS_START = "/*! weapp-tailwindcss layer components start */";
|
|
5253
5133
|
const USER_LAYER_COMPONENTS_END = "/*! weapp-tailwindcss layer components end */";
|
|
@@ -5354,6 +5234,23 @@ function intersectCandidateSets(left, right) {
|
|
|
5354
5234
|
for (const candidate of small) if (large.has(candidate)) matched.add(candidate);
|
|
5355
5235
|
return matched;
|
|
5356
5236
|
}
|
|
5237
|
+
function parseCssSourceRoot(rawSource) {
|
|
5238
|
+
try {
|
|
5239
|
+
return _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
5240
|
+
} catch {
|
|
5241
|
+
return;
|
|
5242
|
+
}
|
|
5243
|
+
}
|
|
5244
|
+
function cleanLocalCssImportWrapperFromParsedRoot(rawSource, root) {
|
|
5245
|
+
if (!root) return (0, _weapp_tailwindcss_postcss.cleanLocalCssImportWrapperTailwindDirectives)(rawSource);
|
|
5246
|
+
return (0, _weapp_tailwindcss_postcss.cleanLocalCssImportWrapperTailwindDirectivesRoot)(root) ? root.toString() : void 0;
|
|
5247
|
+
}
|
|
5248
|
+
function isPureLocalCssImportWrapperFromParsedRoot(rawSource, root) {
|
|
5249
|
+
return root ? (0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapperRoot)(root) : (0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapper)(rawSource);
|
|
5250
|
+
}
|
|
5251
|
+
function splitLocalCssImportsFromParsedRoot(rawSource, root) {
|
|
5252
|
+
return root ? (0, _weapp_tailwindcss_postcss.splitLocalCssImportsRoot)(root) : (0, _weapp_tailwindcss_postcss.splitLocalCssImports)(rawSource);
|
|
5253
|
+
}
|
|
5357
5254
|
function collectCssRuleIdentityMarkers(source) {
|
|
5358
5255
|
const markers = /* @__PURE__ */ new Set();
|
|
5359
5256
|
try {
|
|
@@ -5402,20 +5299,8 @@ async function generateCssByGenerator(options) {
|
|
|
5402
5299
|
const majorVersion = runtimeState.tailwindRuntime.majorVersion;
|
|
5403
5300
|
if (majorVersion !== 4) throw new Error("weapp-tailwindcss 生成管线仅支持 Tailwind CSS v4。");
|
|
5404
5301
|
const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })));
|
|
5405
|
-
const
|
|
5406
|
-
const
|
|
5407
|
-
const finalizeGeneratorCss = (css, target, finalizeOptions = {}) => {
|
|
5408
|
-
return finalizeWebGeneratorCss(restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, target, majorVersion, opts.cssPreflight, finalizeOptions), localImports), target, generatorOptions.webCompat);
|
|
5409
|
-
};
|
|
5410
|
-
const generatorRawSource = localImportParts?.source ?? effectiveRawSource;
|
|
5411
|
-
const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback })));
|
|
5412
|
-
const userSource = splitLocalCssImports(rawUserSource)?.source ?? rawUserSource;
|
|
5413
|
-
const userCssRawSource = removeTailwindV4GeneratorAtRules(userSource);
|
|
5414
|
-
const generatedUserCssOrderSource = hasTailwindGeneratedCss(userSource) ? splitTailwindV4GeneratedCssBySourceOrder(userSource, generatorRawSource) : void 0;
|
|
5415
|
-
const generatedUserCssRawSource = generatedUserCssOrderSource ? createCssAppend(generatedUserCssOrderSource.before, generatedUserCssOrderSource.after) : hasTailwindGeneratedCss(userSource) ? "" : userCssRawSource;
|
|
5416
|
-
const userCssOrderSource = GENERATOR_PLACEHOLDER_MARKER_RE.test(userSource) ? userSource : hasTailwindGeneratedCss(userSource) ? userSource : generatedUserCssRawSource;
|
|
5417
|
-
const hasDistinctUserRawSource = typeof userRawSource === "string" && normalizeCssSourceForCompare(generatedUserCssRawSource) !== normalizeCssSourceForCompare(generatorRawSource);
|
|
5418
|
-
const cleanedLocalImportWrapper = cleanLocalCssImportWrapperTailwindDirectives(effectiveRawSource);
|
|
5302
|
+
const effectiveRawSourceRoot = parseCssSourceRoot(effectiveRawSource);
|
|
5303
|
+
const cleanedLocalImportWrapper = cleanLocalCssImportWrapperFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot);
|
|
5419
5304
|
if (cleanedLocalImportWrapper !== void 0) return {
|
|
5420
5305
|
css: shouldUseMiniProgramCssBranch(generatorBranch) ? (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(cleanedLocalImportWrapper) : cleanedLocalImportWrapper,
|
|
5421
5306
|
classSet: /* @__PURE__ */ new Set(),
|
|
@@ -5427,7 +5312,20 @@ async function generateCssByGenerator(options) {
|
|
|
5427
5312
|
majorVersion
|
|
5428
5313
|
}
|
|
5429
5314
|
};
|
|
5430
|
-
if (
|
|
5315
|
+
if (isPureLocalCssImportWrapperFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot)) return;
|
|
5316
|
+
const localImportParts = splitLocalCssImportsFromParsedRoot(effectiveRawSource, effectiveRawSourceRoot);
|
|
5317
|
+
const localImports = options.restoreLocalCssImports === false ? void 0 : localImportParts?.imports;
|
|
5318
|
+
const finalizeGeneratorCss = (css, target, finalizeOptions = {}) => {
|
|
5319
|
+
return finalizeWebGeneratorCss((0, _weapp_tailwindcss_postcss.restoreLocalCssImports)(finalizeMiniProgramGeneratorCss(css, target, majorVersion, opts.cssPreflight, finalizeOptions), localImports), target, generatorOptions.webCompat);
|
|
5320
|
+
};
|
|
5321
|
+
const generatorRawSource = localImportParts?.source ?? effectiveRawSource;
|
|
5322
|
+
const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback })));
|
|
5323
|
+
const userSource = (rawUserSource === generatorRawSource ? void 0 : (0, _weapp_tailwindcss_postcss.splitLocalCssImports)(rawUserSource))?.source ?? rawUserSource;
|
|
5324
|
+
const userCssRawSource = removeTailwindV4GeneratorAtRules(userSource);
|
|
5325
|
+
const generatedUserCssOrderSource = hasTailwindGeneratedCss(userSource) ? splitTailwindV4GeneratedCssBySourceOrder(userSource, generatorRawSource) : void 0;
|
|
5326
|
+
const generatedUserCssRawSource = generatedUserCssOrderSource ? createCssAppend(generatedUserCssOrderSource.before, generatedUserCssOrderSource.after) : hasTailwindGeneratedCss(userSource) ? "" : userCssRawSource;
|
|
5327
|
+
const userCssOrderSource = GENERATOR_PLACEHOLDER_MARKER_RE.test(userSource) ? userSource : hasTailwindGeneratedCss(userSource) ? userSource : generatedUserCssRawSource;
|
|
5328
|
+
const hasDistinctUserRawSource = typeof userRawSource === "string" && normalizeCssSourceForCompare(generatedUserCssRawSource) !== normalizeCssSourceForCompare(generatorRawSource);
|
|
5431
5329
|
const hasGeneratedCss = hasTailwindGeneratedCss(generatorRawSource);
|
|
5432
5330
|
const hasSourceDirectives = hasTailwindSourceDirectives(generatorRawSource, { importFallback: generatorOptions.importFallback });
|
|
5433
5331
|
const hasGeneratedMarkers = hasTailwindGeneratedCssMarkers(generatorRawSource);
|
|
@@ -5495,7 +5393,7 @@ async function generateCssByGenerator(options) {
|
|
|
5495
5393
|
debug("tailwind generator result: %s rawBytes=%d cssBytes=%d candidates=%d", file, generated.rawCss.length, generated.css.length, generated.classSet.size);
|
|
5496
5394
|
if ((generated.target !== "weapp" || !hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
|
|
5497
5395
|
const incrementalCss = stripTailwindBanner(generated.incrementalCss);
|
|
5498
|
-
const finalCss = finalizeWebGeneratorCss(restoreLocalCssImports(incrementalCss.trim().length > 0 ? createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, {
|
|
5396
|
+
const finalCss = finalizeWebGeneratorCss((0, _weapp_tailwindcss_postcss.restoreLocalCssImports)(incrementalCss.trim().length > 0 ? createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, {
|
|
5499
5397
|
injectPreflight: false,
|
|
5500
5398
|
styleOptions: generatorStyleOptions
|
|
5501
5399
|
})) : options.previousCss, localImports), generated.target, generatorOptions.webCompat);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { C as hasTailwindRootDirectives, F as hasTailwindGeneratedCssMarkers, G as getTailwindV4IncrementalGenerateCacheStats, O as parseImportRequest, P as hasTailwindGeneratedCss, T as normalizeTailwindConfigDirectives, _ as resolveTailwindcssOptions,
|
|
2
|
-
import { o as resolveRuntimeBranch } from "./generator-
|
|
1
|
+
import { C as hasTailwindRootDirectives, F as hasTailwindGeneratedCssMarkers, G as getTailwindV4IncrementalGenerateCacheStats, O as parseImportRequest, P as hasTailwindGeneratedCss, T as normalizeTailwindConfigDirectives, _ as resolveTailwindcssOptions, k as removeTailwindSourceDirectives, lt as inferGeneratorTargetFromEnv, nt as resolveSourceScanPath, o as hasConfiguredTailwindV4CssRoots, s as upsertTailwindV4CssSource, w as hasTailwindSourceDirectives, x as hasTailwindApplyDirective } from "./v4-engine-BuuYDXt1.mjs";
|
|
2
|
+
import { o as resolveRuntimeBranch } from "./generator-24-HgU9F.mjs";
|
|
3
3
|
import { r as getGroupedEntries } from "./utils-DodxWHGz.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { l as getRuntimeClassSetSignature, p as resolveViteSourceScanEntries } from "./tailwindcss-
|
|
6
|
-
import { C as stripTailwindSourceMediaFragments, D as createCssSourceOrderAppend, E as removeGeneratedSelectorCompatCss, F as createCssTokenSourceMap, I as isCssSourceTraceEnabled, L as processCachedTask, M as stripMiniProgramCssSpecificityPlaceholders, N as annotateCssSourceTrace, O as hasMiniProgramTailwindV4PreflightReset, P as createCssSourceTraceCacheSignature, S as removeTailwindV4GeneratorAtRules, T as scoreTailwindV4CssSourceFileMatch, _ as isPureLocalCssImportWrapper, a as isSourceCandidateRequest, b as removeMiniProgramHoverSelectors, c as collectStrictEscapedRuntimeCandidates, f as pushConcurrentTaskFactories, i as createSourceCandidateStore, j as pruneMiniProgramGeneratedCss, k as finalizeMiniProgramCss, l as createEscapeFragments, n as emitHmrTiming, o as resolveSourceCandidateScanFiles, p as resolveTaskConcurrency, s as createBundleRuntimeClassSetManager, w as stripUnmatchedTailwindSourceMediaCloseFragments, x as removeTailwindV4GeneratedUserCssArtifacts } from "./hmr-timing-
|
|
7
|
-
import { A as isSourceStyleRequest, C as resolvePluginDisabledState, N as resolveOutputSpecifier, P as toAbsoluteOutputPath, S as resolvePackageDir, _ as generateTailwindV4Css, d as classifyBundleEntry, f as createBundleBuildState, i as createCandidateSignature, j as stripRequestQuery, m as createRuntimeAffectingSourceSignature, p as updateBundleBuildState, r as createScopedGeneratorRuntime, t as createSourceCandidateScanSignature, x as stripBundlerGeneratedCssMarkers, y as hasBundlerGeneratedCssMarker } from "./source-candidate-scan-signature-
|
|
4
|
+
import { S as createDebug, b as ensureRuntimeClassSet, f as _defineProperty, i as pluginName, l as shouldSkipJsTransform, n as normalizeStyleHandlerMajorVersion, r as resolveStyleOptionsFromContext, t as getCompilerContext, w as md5Hash, x as refreshTailwindRuntimeState, y as createTailwindRuntimeReadyPromise } from "./context-Bkpmt3ja.mjs";
|
|
5
|
+
import { l as getRuntimeClassSetSignature, p as resolveViteSourceScanEntries } from "./tailwindcss-D0JF0fuZ.mjs";
|
|
6
|
+
import { C as stripTailwindSourceMediaFragments, D as createCssSourceOrderAppend, E as removeGeneratedSelectorCompatCss, F as createCssTokenSourceMap, I as isCssSourceTraceEnabled, L as processCachedTask, M as stripMiniProgramCssSpecificityPlaceholders, N as annotateCssSourceTrace, O as hasMiniProgramTailwindV4PreflightReset, P as createCssSourceTraceCacheSignature, S as removeTailwindV4GeneratorAtRules, T as scoreTailwindV4CssSourceFileMatch, _ as isPureLocalCssImportWrapper, a as isSourceCandidateRequest, b as removeMiniProgramHoverSelectors, c as collectStrictEscapedRuntimeCandidates, f as pushConcurrentTaskFactories, i as createSourceCandidateStore, j as pruneMiniProgramGeneratedCss, k as finalizeMiniProgramCss, l as createEscapeFragments, n as emitHmrTiming, o as resolveSourceCandidateScanFiles, p as resolveTaskConcurrency, s as createBundleRuntimeClassSetManager, w as stripUnmatchedTailwindSourceMediaCloseFragments, x as removeTailwindV4GeneratedUserCssArtifacts } from "./hmr-timing-BRNaz8Od.mjs";
|
|
7
|
+
import { A as isSourceStyleRequest, C as resolvePluginDisabledState, N as resolveOutputSpecifier, P as toAbsoluteOutputPath, S as resolvePackageDir, _ as generateTailwindV4Css, d as classifyBundleEntry, f as createBundleBuildState, i as createCandidateSignature, j as stripRequestQuery, m as createRuntimeAffectingSourceSignature, p as updateBundleBuildState, r as createScopedGeneratorRuntime, t as createSourceCandidateScanSignature, x as stripBundlerGeneratedCssMarkers, y as hasBundlerGeneratedCssMarker } from "./source-candidate-scan-signature-BB1hvW68.mjs";
|
|
8
8
|
import Module, { createRequire } from "node:module";
|
|
9
9
|
import fs from "node:fs";
|
|
10
10
|
import path from "node:path";
|
|
@@ -470,6 +470,7 @@ const WEBPACK_TAILWIND_GENERATED_LAYER_NAMES = /* @__PURE__ */ new Set([
|
|
|
470
470
|
]);
|
|
471
471
|
const WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE = /(?:^|[^\w-])\.[^,{]{0,512}(?:\\:|\\\[|\\#)/;
|
|
472
472
|
const WEBPACK_TAILWIND_UTILITY_PREFIX_RE = /^\.(?:-?(?:bg|text|border|ring|shadow|drop-shadow|[pmwhz]|px|py|pt|pr|pb|pl|mx|my|mt|mr|mb|ml|min-w|min-h|max-w|max-h|flex|grid|inline|block|hidden|rounded|opacity|translate|scale|rotate|skew|top|right|bottom|left|inset|gap|font|leading|tracking|underline|container)(?:[\-\\{]|$)|\\\[)/;
|
|
473
|
+
const WEBPACK_TAILWIND_BANNER_RE = /tailwindcss v4\./;
|
|
473
474
|
function parseWebpackCssLayerNames(params) {
|
|
474
475
|
return params.split(",").map((name) => name.trim()).filter(Boolean);
|
|
475
476
|
}
|
|
@@ -478,6 +479,22 @@ function removeWebpackTailwindGeneratedAssetCss(source) {
|
|
|
478
479
|
try {
|
|
479
480
|
const root = postcss.parse(cleaned);
|
|
480
481
|
let changed = false;
|
|
482
|
+
let removingBannerPrefix = false;
|
|
483
|
+
for (const node of [...root.nodes]) {
|
|
484
|
+
if (node.type === "comment" && WEBPACK_TAILWIND_BANNER_RE.test(node.text)) {
|
|
485
|
+
node.remove();
|
|
486
|
+
changed = true;
|
|
487
|
+
removingBannerPrefix = true;
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
if (!removingBannerPrefix) continue;
|
|
491
|
+
if (isWebpackTailwindGeneratedPrefixNode(node)) {
|
|
492
|
+
node.remove();
|
|
493
|
+
changed = true;
|
|
494
|
+
continue;
|
|
495
|
+
}
|
|
496
|
+
removingBannerPrefix = false;
|
|
497
|
+
}
|
|
481
498
|
root.walkAtRules("layer", (rule) => {
|
|
482
499
|
const names = parseWebpackCssLayerNames(rule.params);
|
|
483
500
|
const hasGeneratedLayerName = names.some((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name));
|
|
@@ -507,6 +524,20 @@ function removeWebpackTailwindGeneratedAssetCss(source) {
|
|
|
507
524
|
}
|
|
508
525
|
}
|
|
509
526
|
});
|
|
527
|
+
root.walkRules((rule) => {
|
|
528
|
+
if (rule.parent?.type === "atrule" && rule.parent.name === "layer") return;
|
|
529
|
+
const selector = rule.selector.trim();
|
|
530
|
+
if (WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE.test(selector)) {
|
|
531
|
+
rule.remove();
|
|
532
|
+
changed = true;
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
root.walkComments((comment) => {
|
|
536
|
+
if (WEBPACK_TAILWIND_BANNER_RE.test(comment.text)) {
|
|
537
|
+
comment.remove();
|
|
538
|
+
changed = true;
|
|
539
|
+
}
|
|
540
|
+
});
|
|
510
541
|
root.walkAtRules((rule) => {
|
|
511
542
|
if (rule.nodes !== void 0 && rule.nodes.length === 0) {
|
|
512
543
|
rule.remove();
|
|
@@ -518,6 +549,18 @@ function removeWebpackTailwindGeneratedAssetCss(source) {
|
|
|
518
549
|
return cleaned;
|
|
519
550
|
}
|
|
520
551
|
}
|
|
552
|
+
function isWebpackTailwindGeneratedPrefixNode(node) {
|
|
553
|
+
if (node.type === "rule") return node.selectors.every((selector) => isWebpackTailwindGeneratedUtilitySelector(selector.trim(), true));
|
|
554
|
+
if (node.type !== "atrule") return false;
|
|
555
|
+
const names = node.name === "layer" ? parseWebpackCssLayerNames(node.params) : [];
|
|
556
|
+
if (node.name === "property" && node.params.trim().startsWith("--tw-")) return true;
|
|
557
|
+
if (names.length > 0 && names.every((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name))) return true;
|
|
558
|
+
if (node.nodes === void 0 || node.nodes.length === 0) return false;
|
|
559
|
+
return node.nodes.every((child) => isWebpackTailwindGeneratedPrefixNode(child));
|
|
560
|
+
}
|
|
561
|
+
function isWebpackTailwindGeneratedUtilitySelector(selector, includePrefix) {
|
|
562
|
+
return WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE.test(selector) || includePrefix && WEBPACK_TAILWIND_UTILITY_PREFIX_RE.test(selector);
|
|
563
|
+
}
|
|
521
564
|
function collectWebpackCssRuleIdentityMarkers(source) {
|
|
522
565
|
const markers = /* @__PURE__ */ new Set();
|
|
523
566
|
try {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.js");
|
|
2
|
-
const require_v4_engine = require("./v4-engine-
|
|
3
|
-
const require_generator = require("./generator-
|
|
2
|
+
const require_v4_engine = require("./v4-engine-CKtsdKxK.js");
|
|
3
|
+
const require_generator = require("./generator-CilgHtxb.js");
|
|
4
4
|
const require_utils = require("./utils-D3h8j7Mk.js");
|
|
5
|
-
const require_context = require("./context-
|
|
6
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
7
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
8
|
-
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-
|
|
5
|
+
const require_context = require("./context-DCVMkTRj.js");
|
|
6
|
+
const require_tailwindcss = require("./tailwindcss-D2xs4OEu.js");
|
|
7
|
+
const require_hmr_timing = require("./hmr-timing-BV6nFPoT.js");
|
|
8
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-CaDT0gkj.js");
|
|
9
9
|
let node_fs = require("node:fs");
|
|
10
10
|
node_fs = require_rolldown_runtime.__toESM(node_fs);
|
|
11
11
|
let node_path = require("node:path");
|
|
@@ -476,6 +476,7 @@ const WEBPACK_TAILWIND_GENERATED_LAYER_NAMES = /* @__PURE__ */ new Set([
|
|
|
476
476
|
]);
|
|
477
477
|
const WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE = /(?:^|[^\w-])\.[^,{]{0,512}(?:\\:|\\\[|\\#)/;
|
|
478
478
|
const WEBPACK_TAILWIND_UTILITY_PREFIX_RE = /^\.(?:-?(?:bg|text|border|ring|shadow|drop-shadow|[pmwhz]|px|py|pt|pr|pb|pl|mx|my|mt|mr|mb|ml|min-w|min-h|max-w|max-h|flex|grid|inline|block|hidden|rounded|opacity|translate|scale|rotate|skew|top|right|bottom|left|inset|gap|font|leading|tracking|underline|container)(?:[\-\\{]|$)|\\\[)/;
|
|
479
|
+
const WEBPACK_TAILWIND_BANNER_RE = /tailwindcss v4\./;
|
|
479
480
|
function parseWebpackCssLayerNames(params) {
|
|
480
481
|
return params.split(",").map((name) => name.trim()).filter(Boolean);
|
|
481
482
|
}
|
|
@@ -484,6 +485,22 @@ function removeWebpackTailwindGeneratedAssetCss(source) {
|
|
|
484
485
|
try {
|
|
485
486
|
const root = _weapp_tailwindcss_postcss.postcss.parse(cleaned);
|
|
486
487
|
let changed = false;
|
|
488
|
+
let removingBannerPrefix = false;
|
|
489
|
+
for (const node of [...root.nodes]) {
|
|
490
|
+
if (node.type === "comment" && WEBPACK_TAILWIND_BANNER_RE.test(node.text)) {
|
|
491
|
+
node.remove();
|
|
492
|
+
changed = true;
|
|
493
|
+
removingBannerPrefix = true;
|
|
494
|
+
continue;
|
|
495
|
+
}
|
|
496
|
+
if (!removingBannerPrefix) continue;
|
|
497
|
+
if (isWebpackTailwindGeneratedPrefixNode(node)) {
|
|
498
|
+
node.remove();
|
|
499
|
+
changed = true;
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
removingBannerPrefix = false;
|
|
503
|
+
}
|
|
487
504
|
root.walkAtRules("layer", (rule) => {
|
|
488
505
|
const names = parseWebpackCssLayerNames(rule.params);
|
|
489
506
|
const hasGeneratedLayerName = names.some((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name));
|
|
@@ -513,6 +530,20 @@ function removeWebpackTailwindGeneratedAssetCss(source) {
|
|
|
513
530
|
}
|
|
514
531
|
}
|
|
515
532
|
});
|
|
533
|
+
root.walkRules((rule) => {
|
|
534
|
+
if (rule.parent?.type === "atrule" && rule.parent.name === "layer") return;
|
|
535
|
+
const selector = rule.selector.trim();
|
|
536
|
+
if (WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE.test(selector)) {
|
|
537
|
+
rule.remove();
|
|
538
|
+
changed = true;
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
root.walkComments((comment) => {
|
|
542
|
+
if (WEBPACK_TAILWIND_BANNER_RE.test(comment.text)) {
|
|
543
|
+
comment.remove();
|
|
544
|
+
changed = true;
|
|
545
|
+
}
|
|
546
|
+
});
|
|
516
547
|
root.walkAtRules((rule) => {
|
|
517
548
|
if (rule.nodes !== void 0 && rule.nodes.length === 0) {
|
|
518
549
|
rule.remove();
|
|
@@ -524,6 +555,18 @@ function removeWebpackTailwindGeneratedAssetCss(source) {
|
|
|
524
555
|
return cleaned;
|
|
525
556
|
}
|
|
526
557
|
}
|
|
558
|
+
function isWebpackTailwindGeneratedPrefixNode(node) {
|
|
559
|
+
if (node.type === "rule") return node.selectors.every((selector) => isWebpackTailwindGeneratedUtilitySelector(selector.trim(), true));
|
|
560
|
+
if (node.type !== "atrule") return false;
|
|
561
|
+
const names = node.name === "layer" ? parseWebpackCssLayerNames(node.params) : [];
|
|
562
|
+
if (node.name === "property" && node.params.trim().startsWith("--tw-")) return true;
|
|
563
|
+
if (names.length > 0 && names.every((name) => WEBPACK_TAILWIND_GENERATED_LAYER_NAMES.has(name))) return true;
|
|
564
|
+
if (node.nodes === void 0 || node.nodes.length === 0) return false;
|
|
565
|
+
return node.nodes.every((child) => isWebpackTailwindGeneratedPrefixNode(child));
|
|
566
|
+
}
|
|
567
|
+
function isWebpackTailwindGeneratedUtilitySelector(selector, includePrefix) {
|
|
568
|
+
return WEBPACK_TAILWIND_UTILITY_RULE_MARKER_RE.test(selector) || includePrefix && WEBPACK_TAILWIND_UTILITY_PREFIX_RE.test(selector);
|
|
569
|
+
}
|
|
527
570
|
function collectWebpackCssRuleIdentityMarkers(source) {
|
|
528
571
|
const markers = /* @__PURE__ */ new Set();
|
|
529
572
|
try {
|
|
@@ -1807,7 +1850,7 @@ function setupWebpackV5ProcessAssetsHook(options) {
|
|
|
1807
1850
|
}),
|
|
1808
1851
|
sourceCssProcessed
|
|
1809
1852
|
}), registeredUserRawSource);
|
|
1810
|
-
if (
|
|
1853
|
+
if ((0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapper)(currentRawSource)) return { result: new ConcatSource(require_v4_engine.removeTailwindSourceDirectives(require_source_candidate_scan_signature.stripBundlerGeneratedCssMarkers(currentRawSource), { importFallback: true })) };
|
|
1811
1854
|
const fallbackGeneratorRuntimeSet = getGeneratorRuntimeSet();
|
|
1812
1855
|
const hasExplicitTailwindV4SourceCss = sourceCss !== void 0 && (require_v4_engine.hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || sourceCss.includes("@config"));
|
|
1813
1856
|
const currentAssetHasTailwindDirectives = require_v4_engine.hasTailwindRootDirectives(generatorRawSource, { importFallback: true }) || require_v4_engine.hasTailwindSourceDirectives(generatorRawSource, { importFallback: true }) || require_v4_engine.hasTailwindApplyDirective(generatorRawSource);
|