weapp-tailwindcss 5.0.0-next.20 → 5.0.0-next.22
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-BlXvU4jl.js → bundle-state-BnV8o2Yn.js} +1 -1
- package/dist/{bundle-state-PO6MysTJ.mjs → bundle-state-CLnuf2CW.mjs} +1 -1
- package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +1 -2
- package/dist/bundlers/shared/css-cleanup.d.ts +1 -8
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{generator-N4jy1HCk.js → generator-CV_APjnB.js} +33 -5
- package/dist/generator-DPX8vA2P.mjs +58 -0
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/gulp.js +5 -5
- package/dist/gulp.mjs +5 -5
- package/dist/{incremental-runtime-class-set-CJ0Pnsw2.js → incremental-runtime-class-set-C6akmwlk.js} +11 -433
- package/dist/{incremental-runtime-class-set-hF-uiw6W.mjs → incremental-runtime-class-set-Cwpw6aZK.mjs} +5 -427
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{postcss-DlY-YRvA.js → postcss-Csaggbm7.js} +2 -2
- package/dist/{postcss-D4UdbBQ6.mjs → postcss-ioX7S9x5.mjs} +2 -2
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-BjEbVEpX.js → precheck-8pQbjqpq.js} +2 -2
- package/dist/{precheck-tbk626YL.mjs → precheck-D1O5AWzy.mjs} +2 -2
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/{runtime-registry-D5qnaSpo.js → runtime-registry-CdCV3Opt.js} +0 -20
- package/dist/{source-candidates-gxijpPI3.js → source-candidates-CUTNdsiz.js} +1 -1
- package/dist/{source-candidates-BrvneDDd.mjs → source-candidates-CnD4vyic.mjs} +1 -1
- package/dist/tailwindcss/miniprogram.d.ts +1 -5
- package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -2
- package/dist/{tailwindcss-c6ROlNNW.mjs → tailwindcss-B_JAdOQf.mjs} +1 -1
- package/dist/{tailwindcss-BhG7BtB-.js → tailwindcss-whZE3HpL.js} +1 -1
- package/dist/{v3-engine-5LoZUH-4.js → v3-engine-CCwvhRrQ.js} +2 -224
- package/dist/{v3-engine-DIXDEDmL.mjs → v3-engine-DyIcbpZm.mjs} +2 -218
- package/dist/{vite-B5faZcbE.mjs → vite-BcXuBYy3.mjs} +7 -7
- package/dist/{vite-MyXBNux0.js → vite-k4Nlk42j.js} +7 -7
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +42 -641
- package/dist/weapp-tw-runtime-classset-loader.js +3 -2
- package/dist/{webpack-BnVyDmsD.mjs → webpack-C4pViZ7V.mjs} +5 -5
- package/dist/{webpack-Mz1V0A9p.js → webpack-DC7v6ylA.js} +5 -5
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +7 -7
- package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +0 -3
- package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +0 -5
- package/dist/bundlers/shared/css-cleanup/selectors.d.ts +0 -8
- package/dist/generator-DIuglJub.mjs +0 -32
- package/dist/lightningcss/index.d.ts +0 -8
- package/dist/lightningcss/style-handler/options.d.ts +0 -3
- package/dist/lightningcss/style-handler/selector-transform.d.ts +0 -10
- package/dist/lightningcss/style-handler/selector-utils.d.ts +0 -10
- package/dist/lightningcss/style-handler.d.ts +0 -17
package/dist/{incremental-runtime-class-set-CJ0Pnsw2.js → incremental-runtime-class-set-C6akmwlk.js}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_v3_engine = require("./v3-engine-
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const require_precheck = require("./precheck-
|
|
5
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
2
|
+
const require_v3_engine = require("./v3-engine-CCwvhRrQ.js");
|
|
3
|
+
const require_generator = require("./generator-CV_APjnB.js");
|
|
4
|
+
const require_precheck = require("./precheck-8pQbjqpq.js");
|
|
5
|
+
const require_tailwindcss = require("./tailwindcss-whZE3HpL.js");
|
|
6
6
|
let node_fs = require("node:fs");
|
|
7
7
|
let postcss = require("postcss");
|
|
8
8
|
postcss = require_chunk.__toESM(postcss);
|
|
@@ -378,428 +378,6 @@ async function processCachedTask({ cache, cacheKey, hashKey = cacheKey, rawSourc
|
|
|
378
378
|
if (!cacheHit) await applyResult(result);
|
|
379
379
|
}
|
|
380
380
|
//#endregion
|
|
381
|
-
//#region src/bundlers/shared/css-cleanup/at-rules.ts
|
|
382
|
-
const MINI_PROGRAM_UNSUPPORTED_AT_RULES = new Set(["property", "supports"]);
|
|
383
|
-
function removeAtRulesByScan(css, names) {
|
|
384
|
-
let index = 0;
|
|
385
|
-
let result = "";
|
|
386
|
-
const atRulePattern = new RegExp(`@(?:${[...names].join("|")})\\b`, "i");
|
|
387
|
-
while (index < css.length) {
|
|
388
|
-
const match = atRulePattern.exec(css.slice(index));
|
|
389
|
-
if (!match || match.index === void 0) {
|
|
390
|
-
result += css.slice(index);
|
|
391
|
-
break;
|
|
392
|
-
}
|
|
393
|
-
const start = index + match.index;
|
|
394
|
-
result += css.slice(index, start);
|
|
395
|
-
const blockStart = css.indexOf("{", start);
|
|
396
|
-
if (blockStart === -1) {
|
|
397
|
-
result += css.slice(start);
|
|
398
|
-
break;
|
|
399
|
-
}
|
|
400
|
-
let depth = 0;
|
|
401
|
-
let cursor = blockStart;
|
|
402
|
-
for (; cursor < css.length; cursor++) {
|
|
403
|
-
const char = css[cursor];
|
|
404
|
-
if (char === "{") depth++;
|
|
405
|
-
else if (char === "}") {
|
|
406
|
-
depth--;
|
|
407
|
-
if (depth === 0) {
|
|
408
|
-
cursor++;
|
|
409
|
-
break;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
index = cursor;
|
|
414
|
-
}
|
|
415
|
-
return result;
|
|
416
|
-
}
|
|
417
|
-
function removeUnsupportedMiniProgramAtRules(css) {
|
|
418
|
-
try {
|
|
419
|
-
const root = postcss.default.parse(css);
|
|
420
|
-
root.walkAtRules((atRule) => {
|
|
421
|
-
if (MINI_PROGRAM_UNSUPPORTED_AT_RULES.has(atRule.name)) atRule.remove();
|
|
422
|
-
});
|
|
423
|
-
root.walkAtRules((atRule) => {
|
|
424
|
-
if (atRule.nodes && atRule.nodes.length === 0) atRule.remove();
|
|
425
|
-
});
|
|
426
|
-
return root.toString();
|
|
427
|
-
} catch {
|
|
428
|
-
return removeAtRulesByScan(css, MINI_PROGRAM_UNSUPPORTED_AT_RULES);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
//#endregion
|
|
432
|
-
//#region src/bundlers/shared/css-cleanup/color-gamut.ts
|
|
433
|
-
const DISPLAY_P3_VALUE_RE = /color\(\s*display-p3\b/i;
|
|
434
|
-
const COLOR_GAMUT_P3_RE = /\(\s*color-gamut\s*:\s*p3\s*\)/i;
|
|
435
|
-
function isDisplayP3MediaRule(atRule) {
|
|
436
|
-
return atRule.name === "media" && COLOR_GAMUT_P3_RE.test(atRule.params);
|
|
437
|
-
}
|
|
438
|
-
function isDisplayP3Declaration(decl) {
|
|
439
|
-
return DISPLAY_P3_VALUE_RE.test(decl.value);
|
|
440
|
-
}
|
|
441
|
-
//#endregion
|
|
442
|
-
//#region src/bundlers/shared/css-cleanup/selectors.ts
|
|
443
|
-
const MINI_PROGRAM_THEME_SCOPE_SELECTOR = ":host,page,.tw-root,wx-root-portal-content";
|
|
444
|
-
const MINI_PROGRAM_PREFLIGHT_SELECTORS = new Set([
|
|
445
|
-
"*",
|
|
446
|
-
"view",
|
|
447
|
-
"text",
|
|
448
|
-
":before",
|
|
449
|
-
":after",
|
|
450
|
-
"::before",
|
|
451
|
-
"::after"
|
|
452
|
-
]);
|
|
453
|
-
const MINI_PROGRAM_THEME_SCOPE_SELECTORS$1 = new Set([
|
|
454
|
-
":host",
|
|
455
|
-
":root",
|
|
456
|
-
"page",
|
|
457
|
-
".tw-root",
|
|
458
|
-
"wx-root-portal-content"
|
|
459
|
-
]);
|
|
460
|
-
const SPECIFICITY_PLACEHOLDER_SUFFIXES = [":not(#n)", ":not(#\\#)"];
|
|
461
|
-
const MINI_PROGRAM_UNSUPPORTED_BROWSER_SELECTORS = new Set([
|
|
462
|
-
":-moz-focusring",
|
|
463
|
-
":-moz-ui-invalid",
|
|
464
|
-
"::-webkit-calendar-picker-indicator",
|
|
465
|
-
"::-webkit-date-and-time-value",
|
|
466
|
-
"::-webkit-datetime-edit",
|
|
467
|
-
"::-webkit-datetime-edit-day-field",
|
|
468
|
-
"::-webkit-datetime-edit-fields-wrapper",
|
|
469
|
-
"::-webkit-datetime-edit-hour-field",
|
|
470
|
-
"::-webkit-datetime-edit-meridiem-field",
|
|
471
|
-
"::-webkit-datetime-edit-millisecond-field",
|
|
472
|
-
"::-webkit-datetime-edit-minute-field",
|
|
473
|
-
"::-webkit-datetime-edit-month-field",
|
|
474
|
-
"::-webkit-datetime-edit-second-field",
|
|
475
|
-
"::-webkit-datetime-edit-year-field",
|
|
476
|
-
"::-webkit-inner-spin-button",
|
|
477
|
-
"::-webkit-input-placeholder",
|
|
478
|
-
"::-webkit-outer-spin-button",
|
|
479
|
-
"::-webkit-search-decoration",
|
|
480
|
-
"::placeholder",
|
|
481
|
-
"[hidden]:where(:not([hidden='until-found']))"
|
|
482
|
-
]);
|
|
483
|
-
const MINI_PROGRAM_UNSUPPORTED_BROWSER_TAG_SELECTORS = new Set([
|
|
484
|
-
"a",
|
|
485
|
-
"abbr:where([title])",
|
|
486
|
-
"audio",
|
|
487
|
-
"b",
|
|
488
|
-
"button",
|
|
489
|
-
"canvas",
|
|
490
|
-
"code",
|
|
491
|
-
"embed",
|
|
492
|
-
"h1",
|
|
493
|
-
"h2",
|
|
494
|
-
"h3",
|
|
495
|
-
"h4",
|
|
496
|
-
"h5",
|
|
497
|
-
"h6",
|
|
498
|
-
"hr",
|
|
499
|
-
"html",
|
|
500
|
-
"iframe",
|
|
501
|
-
"img",
|
|
502
|
-
"input",
|
|
503
|
-
"input:where([type='button'],[type='reset'],[type='submit'])",
|
|
504
|
-
"kbd",
|
|
505
|
-
"menu",
|
|
506
|
-
"object",
|
|
507
|
-
"ol",
|
|
508
|
-
"optgroup",
|
|
509
|
-
"pre",
|
|
510
|
-
"progress",
|
|
511
|
-
"samp",
|
|
512
|
-
"select",
|
|
513
|
-
"select[multiple]optgroup",
|
|
514
|
-
"select[multiple]optgroupoption",
|
|
515
|
-
"select[size]optgroup",
|
|
516
|
-
"select[size]optgroupoption",
|
|
517
|
-
"small",
|
|
518
|
-
"strong",
|
|
519
|
-
"sub",
|
|
520
|
-
"summary",
|
|
521
|
-
"sup",
|
|
522
|
-
"svg",
|
|
523
|
-
"table",
|
|
524
|
-
"textarea",
|
|
525
|
-
"ul",
|
|
526
|
-
"video"
|
|
527
|
-
]);
|
|
528
|
-
function normalizeSelector(selector) {
|
|
529
|
-
return selector.trim().replace(/\s+/g, "");
|
|
530
|
-
}
|
|
531
|
-
function getRuleSelectors(rule) {
|
|
532
|
-
return rule.selector.split(",").map(normalizeSelector).filter(Boolean);
|
|
533
|
-
}
|
|
534
|
-
function isUnsupportedBrowserSelector(selector) {
|
|
535
|
-
const normalized = normalizeSelector(selector);
|
|
536
|
-
return MINI_PROGRAM_UNSUPPORTED_BROWSER_SELECTORS.has(normalized) || MINI_PROGRAM_UNSUPPORTED_BROWSER_TAG_SELECTORS.has(normalized);
|
|
537
|
-
}
|
|
538
|
-
//#endregion
|
|
539
|
-
//#region src/bundlers/shared/css-cleanup/root-cleanups.ts
|
|
540
|
-
function removeSpecificityPlaceholders(root) {
|
|
541
|
-
root.walkRules((rule) => {
|
|
542
|
-
if (!rule.selectors || rule.selectors.length === 0) return;
|
|
543
|
-
let changed = false;
|
|
544
|
-
const selectors = rule.selectors.map((selector) => {
|
|
545
|
-
let next = selector;
|
|
546
|
-
for (const suffix of SPECIFICITY_PLACEHOLDER_SUFFIXES) if (next.includes(suffix)) next = next.split(suffix).join("");
|
|
547
|
-
if (next !== selector) changed = true;
|
|
548
|
-
return next;
|
|
549
|
-
});
|
|
550
|
-
if (changed) rule.selectors = selectors;
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
function removeEmptyAtRuleAncestors(parent) {
|
|
554
|
-
while (parent?.type === "atrule" && (!parent.nodes || parent.nodes.length === 0)) {
|
|
555
|
-
const nextParent = parent.parent;
|
|
556
|
-
parent.remove();
|
|
557
|
-
parent = nextParent?.type === "atrule" ? nextParent : void 0;
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
function removeUnsupportedBrowserSelectors(root) {
|
|
561
|
-
root.walkRules((rule) => {
|
|
562
|
-
if (!rule.selectors || rule.selectors.length === 0) return;
|
|
563
|
-
const selectors = rule.selectors.filter((selector) => !isUnsupportedBrowserSelector(selector));
|
|
564
|
-
if (selectors.length === rule.selectors.length) return;
|
|
565
|
-
if (selectors.length === 0) {
|
|
566
|
-
const parent = rule.parent;
|
|
567
|
-
rule.remove();
|
|
568
|
-
removeEmptyAtRuleAncestors(parent);
|
|
569
|
-
return;
|
|
570
|
-
}
|
|
571
|
-
rule.selectors = selectors;
|
|
572
|
-
});
|
|
573
|
-
}
|
|
574
|
-
function removeDeclarationAndEmptyRule(decl) {
|
|
575
|
-
const parent = decl.parent;
|
|
576
|
-
decl.remove();
|
|
577
|
-
if (parent?.type === "rule" && parent.nodes.length === 0) {
|
|
578
|
-
const ruleParent = parent.parent;
|
|
579
|
-
parent.remove();
|
|
580
|
-
removeEmptyAtRuleAncestors(ruleParent);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
function removeDisplayP3Declarations(root) {
|
|
584
|
-
root.walkAtRules((atRule) => {
|
|
585
|
-
if (isDisplayP3MediaRule(atRule)) {
|
|
586
|
-
const parent = atRule.parent;
|
|
587
|
-
atRule.remove();
|
|
588
|
-
removeEmptyAtRuleAncestors(parent);
|
|
589
|
-
}
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
function removeUnsupportedModernColorDeclarations(root) {
|
|
593
|
-
const customPropertyValues = /* @__PURE__ */ new Map();
|
|
594
|
-
root.walkDecls((decl) => {
|
|
595
|
-
if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
|
|
596
|
-
});
|
|
597
|
-
root.walkDecls((decl) => {
|
|
598
|
-
const normalized = (0, _weapp_tailwindcss_postcss.normalizeModernColorValue)(decl.value, customPropertyValues);
|
|
599
|
-
if (normalized.changed) {
|
|
600
|
-
decl.value = normalized.value;
|
|
601
|
-
if (decl.prop.startsWith("--")) customPropertyValues.set(decl.prop, decl.value.trim());
|
|
602
|
-
}
|
|
603
|
-
if (normalized.hasUnsupported) removeDeclarationAndEmptyRule(decl);
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
//#endregion
|
|
607
|
-
//#region src/bundlers/shared/css-cleanup.ts
|
|
608
|
-
const PREFLIGHT_RESET_PROPS = new Set([
|
|
609
|
-
"box-sizing",
|
|
610
|
-
"border",
|
|
611
|
-
"border-width",
|
|
612
|
-
"border-style",
|
|
613
|
-
"border-color",
|
|
614
|
-
"margin",
|
|
615
|
-
"padding"
|
|
616
|
-
]);
|
|
617
|
-
const CONTENT_VAR_RE = /var\(\s*--tw-content\b/;
|
|
618
|
-
const HOIST_ANCHOR_COMMENT = "__weapp_tailwindcss_base_anchor__";
|
|
619
|
-
function isMiniProgramThemeScopeSelector$1(selectors) {
|
|
620
|
-
return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_THEME_SCOPE_SELECTORS$1.has(selector));
|
|
621
|
-
}
|
|
622
|
-
function isMiniProgramPreflightSelector(selectors) {
|
|
623
|
-
return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_PREFLIGHT_SELECTORS.has(selector)) && selectors.some((selector) => selector === "*" || selector === ":before" || selector === ":after" || selector === "::before" || selector === "::after");
|
|
624
|
-
}
|
|
625
|
-
function hasTailwindPreflightDeclaration(rule) {
|
|
626
|
-
let hasTailwindVar = false;
|
|
627
|
-
let hasResetProp = false;
|
|
628
|
-
rule.walkDecls((decl) => {
|
|
629
|
-
if (decl.prop.startsWith("--tw-")) hasTailwindVar = true;
|
|
630
|
-
if (PREFLIGHT_RESET_PROPS.has(decl.prop)) hasResetProp = true;
|
|
631
|
-
});
|
|
632
|
-
return hasTailwindVar || hasResetProp;
|
|
633
|
-
}
|
|
634
|
-
function isCustomPropertyOnlyRule$1(rule) {
|
|
635
|
-
let hasDeclaration = false;
|
|
636
|
-
let allCustomProperties = true;
|
|
637
|
-
rule.each((node) => {
|
|
638
|
-
if (node.type !== "decl") return;
|
|
639
|
-
hasDeclaration = true;
|
|
640
|
-
if (!node.prop.startsWith("--")) allCustomProperties = false;
|
|
641
|
-
});
|
|
642
|
-
return hasDeclaration && allCustomProperties;
|
|
643
|
-
}
|
|
644
|
-
function hasContentInitDeclaration(rule) {
|
|
645
|
-
let hasContentInit = false;
|
|
646
|
-
rule.walkDecls("--tw-content", () => {
|
|
647
|
-
hasContentInit = true;
|
|
648
|
-
});
|
|
649
|
-
return hasContentInit;
|
|
650
|
-
}
|
|
651
|
-
function isEmptyContentInitDeclaration(decl) {
|
|
652
|
-
return decl.prop === "--tw-content" && (decl.value === "\"\"" || decl.value === "''");
|
|
653
|
-
}
|
|
654
|
-
function usesTwContentVariable(root) {
|
|
655
|
-
let used = false;
|
|
656
|
-
root.walkDecls((decl) => {
|
|
657
|
-
if (CONTENT_VAR_RE.test(decl.value)) used = true;
|
|
658
|
-
});
|
|
659
|
-
return used;
|
|
660
|
-
}
|
|
661
|
-
function isTailwindPreflightRule(node) {
|
|
662
|
-
if (node.type !== "rule" || node.parent?.type !== "root") return false;
|
|
663
|
-
const rule = node;
|
|
664
|
-
return isMiniProgramPreflightSelector(getRuleSelectors(rule)) && hasTailwindPreflightDeclaration(rule);
|
|
665
|
-
}
|
|
666
|
-
function isMiniProgramThemeVariableRule(node) {
|
|
667
|
-
if (node.type !== "rule" || node.parent?.type !== "root") return false;
|
|
668
|
-
const rule = node;
|
|
669
|
-
return isMiniProgramThemeScopeSelector$1(getRuleSelectors(rule)) && isCustomPropertyOnlyRule$1(rule);
|
|
670
|
-
}
|
|
671
|
-
function createPseudoContentInitRule() {
|
|
672
|
-
const rule = postcss.default.rule({ selector: "::before,\n::after" });
|
|
673
|
-
rule.append({
|
|
674
|
-
prop: "--tw-content",
|
|
675
|
-
value: "''"
|
|
676
|
-
});
|
|
677
|
-
return rule;
|
|
678
|
-
}
|
|
679
|
-
function collectPreflightRules(root, options = {}) {
|
|
680
|
-
const preflightNodes = [];
|
|
681
|
-
let hasContentInit = false;
|
|
682
|
-
for (const node of root.nodes ?? []) if (isTailwindPreflightRule(node)) {
|
|
683
|
-
preflightNodes.push(node);
|
|
684
|
-
if (hasContentInitDeclaration(node)) hasContentInit = true;
|
|
685
|
-
}
|
|
686
|
-
if (preflightNodes.length === 0) return [];
|
|
687
|
-
const clonedPreflightRules = preflightNodes.map((node) => node.clone());
|
|
688
|
-
const contentInitRules = options.preservePseudoContentInit ? clonedPreflightRules.filter((rule) => hasContentInitDeclaration(rule)) : [];
|
|
689
|
-
const otherPreflightRules = clonedPreflightRules.filter((rule) => !hasContentInitDeclaration(rule));
|
|
690
|
-
const preflightRules = hasContentInit ? [...contentInitRules, ...otherPreflightRules] : [...options.preservePseudoContentInit ? [createPseudoContentInitRule()] : [], ...otherPreflightRules];
|
|
691
|
-
for (const node of preflightNodes) node.remove();
|
|
692
|
-
return preflightRules;
|
|
693
|
-
}
|
|
694
|
-
function createPreflightResetRule(cssPreflight) {
|
|
695
|
-
if (!cssPreflight || typeof cssPreflight !== "object") return;
|
|
696
|
-
const rule = postcss.default.rule({ selector: "view,text,:after,:before" });
|
|
697
|
-
for (const [prop, value] of Object.entries(cssPreflight)) {
|
|
698
|
-
if (value === false) continue;
|
|
699
|
-
rule.append({
|
|
700
|
-
prop,
|
|
701
|
-
value: value.toString()
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
return rule.nodes?.length ? rule : void 0;
|
|
705
|
-
}
|
|
706
|
-
function collectThemeVariableRule(root, options = {}) {
|
|
707
|
-
const themeRules = [];
|
|
708
|
-
const declarations = /* @__PURE__ */ new Map();
|
|
709
|
-
const shouldPreserveContentInit = options.preservePseudoContentInit || usesTwContentVariable(root);
|
|
710
|
-
for (const node of root.nodes ?? []) {
|
|
711
|
-
if (!isMiniProgramThemeVariableRule(node)) continue;
|
|
712
|
-
themeRules.push(node);
|
|
713
|
-
node.walkDecls((decl) => {
|
|
714
|
-
if (isDisplayP3Declaration(decl)) return;
|
|
715
|
-
if (!shouldPreserveContentInit && isEmptyContentInitDeclaration(decl)) return;
|
|
716
|
-
declarations.set(decl.prop, decl.clone());
|
|
717
|
-
});
|
|
718
|
-
}
|
|
719
|
-
for (const rule of themeRules) rule.remove();
|
|
720
|
-
if (declarations.size === 0) return;
|
|
721
|
-
const rule = postcss.default.rule({ selector: MINI_PROGRAM_THEME_SCOPE_SELECTOR });
|
|
722
|
-
for (const decl of declarations.values()) rule.append(decl);
|
|
723
|
-
return rule;
|
|
724
|
-
}
|
|
725
|
-
function getTopDirectiveTail(root) {
|
|
726
|
-
let tail;
|
|
727
|
-
for (const node of root.nodes ?? []) {
|
|
728
|
-
if (node.type === "atrule" && (node.name === "charset" || node.name === "import")) {
|
|
729
|
-
tail = node;
|
|
730
|
-
continue;
|
|
731
|
-
}
|
|
732
|
-
break;
|
|
733
|
-
}
|
|
734
|
-
return tail;
|
|
735
|
-
}
|
|
736
|
-
function createHoistInsertionAnchor(root) {
|
|
737
|
-
for (const node of root.nodes ?? []) if (isTailwindPreflightRule(node) || isMiniProgramThemeVariableRule(node)) {
|
|
738
|
-
const anchor = postcss.default.comment({ text: HOIST_ANCHOR_COMMENT });
|
|
739
|
-
node.before(anchor);
|
|
740
|
-
return anchor;
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
function insertHoistedRules(root, rules, anchor) {
|
|
744
|
-
if (anchor && !anchor.parent) anchor = void 0;
|
|
745
|
-
if (rules.length === 0) {
|
|
746
|
-
anchor?.remove();
|
|
747
|
-
return;
|
|
748
|
-
}
|
|
749
|
-
const topDirectiveTail = getTopDirectiveTail(root);
|
|
750
|
-
const firstRule = rules[0];
|
|
751
|
-
if (!firstRule) return;
|
|
752
|
-
if (anchor) {
|
|
753
|
-
if (anchor.raws.before === void 0) delete firstRule.raws.before;
|
|
754
|
-
else firstRule.raws.before = anchor.raws.before;
|
|
755
|
-
anchor.replaceWith(rules);
|
|
756
|
-
return;
|
|
757
|
-
}
|
|
758
|
-
firstRule.raws.before = topDirectiveTail ? "\n" : "";
|
|
759
|
-
if (topDirectiveTail) topDirectiveTail.after(rules);
|
|
760
|
-
else root.prepend(rules);
|
|
761
|
-
}
|
|
762
|
-
function finalizeMiniProgramCssRoot(root, options = {}) {
|
|
763
|
-
require_v3_engine.removeUnsupportedCascadeLayers(root);
|
|
764
|
-
unwrapTailwindSourceMedia(root);
|
|
765
|
-
root.walkAtRules("property", (atRule) => {
|
|
766
|
-
atRule.remove();
|
|
767
|
-
});
|
|
768
|
-
removeSpecificityPlaceholders(root);
|
|
769
|
-
removeUnsupportedBrowserSelectors(root);
|
|
770
|
-
removeDisplayP3Declarations(root);
|
|
771
|
-
removeUnsupportedModernColorDeclarations(root);
|
|
772
|
-
root.walkDecls((decl) => {
|
|
773
|
-
(0, _weapp_tailwindcss_postcss.normalizeMiniProgramPrefixedDeclaration)(decl);
|
|
774
|
-
});
|
|
775
|
-
root.walkAtRules((atRule) => {
|
|
776
|
-
(0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramPrefixedAtRule)(atRule);
|
|
777
|
-
});
|
|
778
|
-
const hoistAnchor = createHoistInsertionAnchor(root);
|
|
779
|
-
const preflightRules = collectPreflightRules(root, options);
|
|
780
|
-
if (preflightRules.length === 0) {
|
|
781
|
-
const resetRule = createPreflightResetRule(options.cssPreflight);
|
|
782
|
-
if (resetRule) preflightRules.push(resetRule);
|
|
783
|
-
}
|
|
784
|
-
const themeRule = collectThemeVariableRule(root, options);
|
|
785
|
-
insertHoistedRules(root, themeRule ? [...preflightRules, themeRule] : preflightRules, hoistAnchor);
|
|
786
|
-
}
|
|
787
|
-
function unwrapTailwindSourceMedia(root) {
|
|
788
|
-
root.walkAtRules("media", (atRule) => {
|
|
789
|
-
if (atRule.params.startsWith("source(") && atRule.nodes && atRule.nodes.length > 0) atRule.replaceWith(...atRule.nodes);
|
|
790
|
-
});
|
|
791
|
-
}
|
|
792
|
-
function finalizeMiniProgramCss(css, options = {}) {
|
|
793
|
-
const cleanedCss = removeUnsupportedMiniProgramAtRules(css);
|
|
794
|
-
try {
|
|
795
|
-
const root = postcss.default.parse(cleanedCss);
|
|
796
|
-
finalizeMiniProgramCssRoot(root, options);
|
|
797
|
-
return root.toString();
|
|
798
|
-
} catch {
|
|
799
|
-
return cleanedCss;
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
//#endregion
|
|
803
381
|
//#region src/bundlers/shared/generator-css/legacy-selectors.ts
|
|
804
382
|
const CLASS_SELECTOR_RE = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
|
|
805
383
|
const MINI_PROGRAM_THEME_SCOPE_SELECTORS = new Set([
|
|
@@ -1597,7 +1175,7 @@ function removeTailwindApplyRules(rawSource) {
|
|
|
1597
1175
|
function resolveLegacyCompatCssSource(rawSource) {
|
|
1598
1176
|
const cached = legacyCompatSourceCache.get(rawSource);
|
|
1599
1177
|
if (cached !== void 0) return cached;
|
|
1600
|
-
const resolved = closeTrailingUnclosedBlocks(removeUnsupportedMiniProgramAtRules(removeTailwindApplyRules(removeTailwindSourceDirectives(closeTrailingUnclosedBlocks(stripTailwindBanners(rawSource))))));
|
|
1178
|
+
const resolved = closeTrailingUnclosedBlocks((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(removeTailwindApplyRules(removeTailwindSourceDirectives(closeTrailingUnclosedBlocks(stripTailwindBanners(rawSource))))));
|
|
1601
1179
|
setLimitedCacheValue(legacyCompatSourceCache, rawSource, resolved);
|
|
1602
1180
|
return resolved;
|
|
1603
1181
|
}
|
|
@@ -1642,7 +1220,7 @@ async function appendLegacyCompatCss(css, rawSource, generatorTarget, styleHandl
|
|
|
1642
1220
|
compatCss = (await styleHandler(compatSource, styleOptions)).css;
|
|
1643
1221
|
setLimitedCacheValue(legacyCompatTransformCache, compatCssCacheKey, compatCss);
|
|
1644
1222
|
}
|
|
1645
|
-
const cleanedCompatCss = collectDedupedPostTransformCompatCss(removeDuplicatedViteMarkers(removeUnsupportedMiniProgramAtRules(compatCss), css), css);
|
|
1223
|
+
const cleanedCompatCss = collectDedupedPostTransformCompatCss(removeDuplicatedViteMarkers((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(compatCss), css), css);
|
|
1646
1224
|
if (cleanedCompatCss.trim().length === 0) return css;
|
|
1647
1225
|
return createCssAppend(css, cleanedCompatCss);
|
|
1648
1226
|
}
|
|
@@ -1660,7 +1238,7 @@ async function appendLegacyContainerCompatCss(css, rawSource, file, runtime, con
|
|
|
1660
1238
|
compatCss = (await styleHandler(LEGACY_CONTAINER_COMPAT_CSS, styleOptions)).css;
|
|
1661
1239
|
setLimitedCacheValue(legacyCompatTransformCache, compatCssCacheKey, compatCss);
|
|
1662
1240
|
}
|
|
1663
|
-
const cleanedCompatCss = collectDedupedPostTransformCompatCss(removeUnsupportedMiniProgramAtRules(compatCss), css);
|
|
1241
|
+
const cleanedCompatCss = collectDedupedPostTransformCompatCss((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(compatCss), css);
|
|
1664
1242
|
if (cleanedCompatCss.trim().length === 0) return css;
|
|
1665
1243
|
return createCssAppend(css, cleanedCompatCss);
|
|
1666
1244
|
}
|
|
@@ -1714,7 +1292,7 @@ const SUPPORTED_GENERATOR_MAJOR_VERSIONS = new Set([3, 4]);
|
|
|
1714
1292
|
const REMOTE_IMPORT_RE = /^(?:https?:)?\/\//i;
|
|
1715
1293
|
function finalizeMiniProgramGeneratorCss(css, target, majorVersion, cssPreflight, options = {}) {
|
|
1716
1294
|
if (target !== "weapp") return css;
|
|
1717
|
-
return finalizeMiniProgramCss(css, {
|
|
1295
|
+
return (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(css, {
|
|
1718
1296
|
cssPreflight: majorVersion === 4 && options.injectPreflight !== false ? cssPreflight : void 0,
|
|
1719
1297
|
preservePseudoContentInit: majorVersion === 3
|
|
1720
1298
|
});
|
|
@@ -1794,7 +1372,7 @@ async function transformGeneratorUserCss(source, options) {
|
|
|
1794
1372
|
if (source.trim().length === 0) return "";
|
|
1795
1373
|
const cleanedSource = removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source)), { importFallback: options.importFallback });
|
|
1796
1374
|
if (cleanedSource.trim().length === 0) return "";
|
|
1797
|
-
const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? removeUnsupportedMiniProgramAtRules(cleanedSource) : cleanedSource)), { importFallback: options.importFallback }));
|
|
1375
|
+
const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(cleanedSource) : cleanedSource)), { importFallback: options.importFallback }));
|
|
1798
1376
|
if (userSource.trim().length === 0) return "";
|
|
1799
1377
|
if (isCommentOnlyCss(userSource)) return userSource;
|
|
1800
1378
|
if (options.generatorTarget !== "weapp") return userSource;
|
|
@@ -1802,7 +1380,7 @@ async function transformGeneratorUserCss(source, options) {
|
|
|
1802
1380
|
...options.generatorStyleOptions,
|
|
1803
1381
|
...options.cssUserHandlerOptions
|
|
1804
1382
|
});
|
|
1805
|
-
return removeUnsupportedMiniProgramAtRules(css);
|
|
1383
|
+
return (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(css);
|
|
1806
1384
|
}
|
|
1807
1385
|
function isPureLocalCssImportWrapper(css) {
|
|
1808
1386
|
let hasImport = false;
|
|
@@ -1863,7 +1441,7 @@ async function generateCssByGenerator(options) {
|
|
|
1863
1441
|
const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })));
|
|
1864
1442
|
const cleanedLocalImportWrapper = cleanLocalCssImportWrapperTailwindDirectives(effectiveRawSource);
|
|
1865
1443
|
if (cleanedLocalImportWrapper !== void 0) return {
|
|
1866
|
-
css: generatorOptions.target === "weapp" ? removeUnsupportedMiniProgramAtRules(cleanedLocalImportWrapper) : cleanedLocalImportWrapper,
|
|
1444
|
+
css: generatorOptions.target === "weapp" ? (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(cleanedLocalImportWrapper) : cleanedLocalImportWrapper,
|
|
1867
1445
|
target: generatorOptions.target,
|
|
1868
1446
|
source: "generator",
|
|
1869
1447
|
dependencies: []
|