weapp-tailwindcss 5.0.0-next.15 → 5.0.0-next.17
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-ClSg28Qk.js → bundle-state-DDgxuERW.js} +1 -1
- package/dist/{bundle-state-CrhkNTsw.mjs → bundle-state-YW-zLcsc.mjs} +1 -1
- package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/markers.d.ts +4 -0
- package/dist/bundlers/shared/generator-css.d.ts +1 -1
- package/dist/bundlers/vite/css-finalizer.d.ts +1 -0
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{generator-CImaTibB.js → generator-BIEhxFdv.js} +1 -1
- package/dist/{generator-DSMdL4vg.mjs → generator-Ber8UVgv.mjs} +1 -1
- 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-CH1L--wj.js → incremental-runtime-class-set-CfznDtJ0.js} +134 -21
- package/dist/{incremental-runtime-class-set-P-3ZoWW5.mjs → incremental-runtime-class-set-DC0RsBbK.mjs} +134 -21
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{postcss-k0BshZZQ.js → postcss-DCOUtuwI.js} +2 -2
- package/dist/{postcss-CgFCqilE.mjs → postcss-DW08tZXt.mjs} +2 -2
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-DMXLnfTN.mjs → precheck-CX-5VqM1.mjs} +2 -2
- package/dist/{precheck-GcUdX1BX.js → precheck-CZfnh4T6.js} +2 -2
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/{source-candidates-ES3ttZPe.js → source-candidates-BDyoPviV.js} +1 -1
- package/dist/{source-candidates-om5-wQJ0.mjs → source-candidates-DGlDzkvf.mjs} +1 -1
- package/dist/{tailwindcss-CkTBauKa.js → tailwindcss-BVoa7vx-.js} +5 -3
- package/dist/{tailwindcss-fe0rGj7T.mjs → tailwindcss-D74Wk4ys.mjs} +5 -3
- package/dist/{v3-engine-v__n8_Sd.js → v3-engine-BRInt2DS.js} +92 -4
- package/dist/{v3-engine-qoWtwjIj.mjs → v3-engine-CCxDqZ8e.mjs} +93 -5
- package/dist/{vite-Bob_Mrva.js → vite-DnHdmHHD.js} +32 -15
- package/dist/{vite-cBjGYHFH.mjs → vite-bmU2kkO6.mjs} +32 -15
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +2 -1
- package/dist/{webpack-Cq45BZzs.mjs → webpack-BkBoEn4k.mjs} +5 -5
- package/dist/{webpack-BedfyGbF.js → webpack-SxEdWHlL.js} +5 -5
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_precheck = require("./precheck-
|
|
2
|
+
const require_precheck = require("./precheck-CZfnh4T6.js");
|
|
3
3
|
let node_module = require("node:module");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_chunk.__toESM(node_path);
|
|
@@ -2,3 +2,4 @@ import type postcss from 'postcss';
|
|
|
2
2
|
export declare function removeSpecificityPlaceholders(root: postcss.Root): void;
|
|
3
3
|
export declare function removeUnsupportedBrowserSelectors(root: postcss.Root): void;
|
|
4
4
|
export declare function removeDisplayP3Declarations(root: postcss.Root): void;
|
|
5
|
+
export declare function removeUnsupportedModernColorDeclarations(root: postcss.Root): void;
|
|
@@ -12,6 +12,10 @@ export declare function splitTailwindV4GeneratedCssBySourceOrder(rawSource: stri
|
|
|
12
12
|
before: string;
|
|
13
13
|
after: string;
|
|
14
14
|
} | undefined;
|
|
15
|
+
export declare function splitGeneratorPlaceholderCssBySourceOrder(rawSource: string, rawTailwindCss?: string): {
|
|
16
|
+
before: string;
|
|
17
|
+
after: string;
|
|
18
|
+
} | undefined;
|
|
15
19
|
export declare function removeTailwindGeneratedCssByBanner(rawSource: string): string | undefined;
|
|
16
20
|
export declare function splitTailwindGeneratedCssByBanner(rawSource: string, start?: number): {
|
|
17
21
|
before: string;
|
|
@@ -4,7 +4,7 @@ import type { InternalUserDefinedOptions } from '../../types';
|
|
|
4
4
|
export { hasTailwindSourceDirectives, normalizeTailwindSourceForGenerator, removeTailwindSourceDirectives, resolveCssEntrySource, } from './generator-css/directives';
|
|
5
5
|
export { removeTailwindApplyRules, } from './generator-css/legacy-compat';
|
|
6
6
|
export { inheritLegacyUnitConvertedDeclarations, } from './generator-css/legacy-units';
|
|
7
|
-
export { createCssAppend, hasTailwindGeneratedCss, hasTailwindGeneratedCssMarkers, removeTailwindGeneratedCssByBanner, splitTailwindGeneratedCssByBanner, splitTailwindV4GeneratedCss, splitTailwindV4GeneratedCssBySourceOrder, stripGeneratorPlaceholderMarkers, stripTailwindBanner, stripTailwindBanners, } from './generator-css/markers';
|
|
7
|
+
export { createCssAppend, hasTailwindGeneratedCss, hasTailwindGeneratedCssMarkers, removeTailwindGeneratedCssByBanner, splitGeneratorPlaceholderCssBySourceOrder, splitTailwindGeneratedCssByBanner, splitTailwindV4GeneratedCss, splitTailwindV4GeneratedCssBySourceOrder, stripGeneratorPlaceholderMarkers, stripTailwindBanner, stripTailwindBanners, } from './generator-css/markers';
|
|
8
8
|
export { resolveGeneratorSource, } from './generator-css/source-resolver';
|
|
9
9
|
export interface GenerateCssByGeneratorOptions {
|
|
10
10
|
opts: InternalUserDefinedOptions;
|
|
@@ -19,6 +19,7 @@ interface CssFinalizerContext {
|
|
|
19
19
|
getSourceCandidatesForEntries?: ((entries: TailwindSourceEntry[] | undefined) => Set<string>) | undefined;
|
|
20
20
|
waitForSourceCandidateSyncs?: () => Promise<void>;
|
|
21
21
|
rememberMainCssSource?: (file: string, rawSource: string) => void;
|
|
22
|
+
getRememberedMainCssSource?: (file: string) => string | undefined;
|
|
22
23
|
}
|
|
23
24
|
export declare function createViteCssFinalizerOutputPlugin(context: CssFinalizerContext): Plugin;
|
|
24
25
|
export {};
|
package/dist/core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("./chunk-8l464Juk.js");
|
|
3
|
-
const require_precheck = require("./precheck-
|
|
3
|
+
const require_precheck = require("./precheck-CZfnh4T6.js");
|
|
4
4
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
5
5
|
//#region src/core.ts
|
|
6
6
|
const DEFAULT_MAIN_CHUNK_STYLE_OPTIONS = Object.freeze({ isMainChunk: true });
|
package/dist/core.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as ensureRuntimeClassSet, g as createTailwindRuntimeReadyPromise, n as getCompilerContext, t as shouldSkipJsTransform } from "./precheck-
|
|
1
|
+
import { _ as ensureRuntimeClassSet, g as createTailwindRuntimeReadyPromise, n as getCompilerContext, t as shouldSkipJsTransform } from "./precheck-CX-5VqM1.mjs";
|
|
2
2
|
import { defuOverrideArray } from "@weapp-tailwindcss/shared";
|
|
3
3
|
//#region src/core.ts
|
|
4
4
|
const DEFAULT_MAIN_CHUNK_STYLE_OPTIONS = Object.freeze({ isMainChunk: true });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as createTailwindV4Engine, i as createTailwindV3Engine, n as resolveTailwindV3SourceFromPatcher, x as resolveTailwindV4SourceFromPatcher } from "./v3-engine-
|
|
1
|
+
import { C as createTailwindV4Engine, i as createTailwindV3Engine, n as resolveTailwindV3SourceFromPatcher, x as resolveTailwindV4SourceFromPatcher } from "./v3-engine-CCxDqZ8e.mjs";
|
|
2
2
|
//#region src/generator/options.ts
|
|
3
3
|
function normalizeWeappTailwindcssGeneratorOptions(options) {
|
|
4
4
|
if (options == null) return {
|
package/dist/generator.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("./chunk-8l464Juk.js");
|
|
3
|
-
const require_v3_engine = require("./v3-engine-
|
|
4
|
-
const require_generator = require("./generator-
|
|
3
|
+
const require_v3_engine = require("./v3-engine-BRInt2DS.js");
|
|
4
|
+
const require_generator = require("./generator-BIEhxFdv.js");
|
|
5
5
|
let tailwindcss_patch = require("tailwindcss-patch");
|
|
6
6
|
exports.createWeappTailwindcssGenerator = require_generator.createWeappTailwindcssGenerator;
|
|
7
7
|
exports.createWeappTailwindcssGeneratorFromPatcher = require_generator.createWeappTailwindcssGeneratorFromPatcher;
|
package/dist/generator.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { S as resolveTailwindV4SourceOptionsFromPatcher, T as transformTailwindV4CssToWeapp, a as transformTailwindV3CssByTarget, b as resolveTailwindV4SourceFromPatchOptions, n as resolveTailwindV3SourceFromPatcher, o as transformTailwindV3CssToWeapp, r as resolveTailwindV3SourceOptionsFromPatcher, t as resolveTailwindV3Source, w as transformTailwindV4CssByTarget, x as resolveTailwindV4SourceFromPatcher, y as resolveTailwindV4Source } from "./v3-engine-
|
|
2
|
-
import { i as normalizeWeappTailwindcssGeneratorOptions, n as createWeappTailwindcssGeneratorFromPatcher, r as resolveTailwindSourceFromPatcher, t as createWeappTailwindcssGenerator } from "./generator-
|
|
1
|
+
import { S as resolveTailwindV4SourceOptionsFromPatcher, T as transformTailwindV4CssToWeapp, a as transformTailwindV3CssByTarget, b as resolveTailwindV4SourceFromPatchOptions, n as resolveTailwindV3SourceFromPatcher, o as transformTailwindV3CssToWeapp, r as resolveTailwindV3SourceOptionsFromPatcher, t as resolveTailwindV3Source, w as transformTailwindV4CssByTarget, x as resolveTailwindV4SourceFromPatcher, y as resolveTailwindV4Source } from "./v3-engine-CCxDqZ8e.mjs";
|
|
2
|
+
import { i as normalizeWeappTailwindcssGeneratorOptions, n as createWeappTailwindcssGeneratorFromPatcher, r as resolveTailwindSourceFromPatcher, t as createWeappTailwindcssGenerator } from "./generator-Ber8UVgv.mjs";
|
|
3
3
|
export { createWeappTailwindcssGenerator, createWeappTailwindcssGeneratorFromPatcher, normalizeWeappTailwindcssGeneratorOptions, resolveTailwindSourceFromPatcher, resolveTailwindV3Source, resolveTailwindV3SourceFromPatcher, resolveTailwindV3SourceOptionsFromPatcher, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions, resolveTailwindV4SourceFromPatcher, resolveTailwindV4SourceOptionsFromPatcher, transformTailwindV3CssByTarget, transformTailwindV3CssToWeapp, transformTailwindV4CssByTarget, transformTailwindV4CssToWeapp };
|
package/dist/gulp.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
3
|
-
const require_v3_engine = require("./v3-engine-
|
|
4
|
-
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-
|
|
5
|
-
const require_precheck = require("./precheck-
|
|
6
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
7
|
-
const require_source_candidates = require("./source-candidates-
|
|
3
|
+
const require_v3_engine = require("./v3-engine-BRInt2DS.js");
|
|
4
|
+
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-CfznDtJ0.js");
|
|
5
|
+
const require_precheck = require("./precheck-CZfnh4T6.js");
|
|
6
|
+
const require_tailwindcss = require("./tailwindcss-BVoa7vx-.js");
|
|
7
|
+
const require_source_candidates = require("./source-candidates-BDyoPviV.js");
|
|
8
8
|
let node_fs = require("node:fs");
|
|
9
9
|
node_fs = require_chunk.__toESM(node_fs);
|
|
10
10
|
let node_path = require("node:path");
|
package/dist/gulp.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { F as createDebug, _ as resolveViteSourceScanEntries, l as getRuntimeClassSetSignature } from "./v3-engine-
|
|
2
|
-
import { i as generateCssByGenerator, l as normalizeTailwindSourceForGenerator, o as processCachedTask, r as emitHmrTiming, s as hasTailwindRootDirectives, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-
|
|
3
|
-
import { _ as ensureRuntimeClassSet, g as createTailwindRuntimeReadyPromise, n as getCompilerContext, t as shouldSkipJsTransform } from "./precheck-
|
|
4
|
-
import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-
|
|
5
|
-
import { t as createSourceCandidateCollector } from "./source-candidates-
|
|
1
|
+
import { F as createDebug, _ as resolveViteSourceScanEntries, l as getRuntimeClassSetSignature } from "./v3-engine-CCxDqZ8e.mjs";
|
|
2
|
+
import { i as generateCssByGenerator, l as normalizeTailwindSourceForGenerator, o as processCachedTask, r as emitHmrTiming, s as hasTailwindRootDirectives, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-DC0RsBbK.mjs";
|
|
3
|
+
import { _ as ensureRuntimeClassSet, g as createTailwindRuntimeReadyPromise, n as getCompilerContext, t as shouldSkipJsTransform } from "./precheck-CX-5VqM1.mjs";
|
|
4
|
+
import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-D74Wk4ys.mjs";
|
|
5
|
+
import { t as createSourceCandidateCollector } from "./source-candidates-DGlDzkvf.mjs";
|
|
6
6
|
import fs from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import process from "node:process";
|
package/dist/{incremental-runtime-class-set-CH1L--wj.js → incremental-runtime-class-set-CfznDtJ0.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-BRInt2DS.js");
|
|
3
|
+
const require_generator = require("./generator-BIEhxFdv.js");
|
|
4
|
+
const require_precheck = require("./precheck-CZfnh4T6.js");
|
|
5
|
+
const require_tailwindcss = require("./tailwindcss-BVoa7vx-.js");
|
|
6
6
|
let node_fs = require("node:fs");
|
|
7
7
|
let postcss = require("postcss");
|
|
8
8
|
postcss = require_chunk.__toESM(postcss);
|
|
@@ -11,6 +11,7 @@ node_path = require_chunk.__toESM(node_path);
|
|
|
11
11
|
let node_process = require("node:process");
|
|
12
12
|
node_process = require_chunk.__toESM(node_process);
|
|
13
13
|
let tailwindcss_patch = require("tailwindcss-patch");
|
|
14
|
+
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
14
15
|
//#region src/bundlers/shared/generator-css/markers.ts
|
|
15
16
|
const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
|
|
16
17
|
const TAILWIND_GENERATED_CSS_MARKER_RE = /\/\*!\s*tailwindcss v|@property\s+--tw-|--tw-|:not\(#\\#\)|\.[^,{]*(?:\\:|\\\[|\\#)|(?::host|page|\.tw-root|wx-root-portal-content)[^{]*\{[^}]*--(?:color|spacing|text|font-weight|radius)-/;
|
|
@@ -43,6 +44,20 @@ function splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss) {
|
|
|
43
44
|
after: rawSource.slice(start + rawTailwindCss.length)
|
|
44
45
|
};
|
|
45
46
|
}
|
|
47
|
+
function splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss) {
|
|
48
|
+
const match = GENERATOR_PLACEHOLDER_MARKER_RE.exec(rawSource);
|
|
49
|
+
if (!match || match.index === void 0) return;
|
|
50
|
+
let afterStart = match.index + match[0].length;
|
|
51
|
+
while (/\s/.test(rawSource[afterStart] ?? "")) afterStart++;
|
|
52
|
+
if (rawTailwindCss && rawSource.slice(afterStart).startsWith(rawTailwindCss)) {
|
|
53
|
+
afterStart += rawTailwindCss.length;
|
|
54
|
+
while (/\s/.test(rawSource[afterStart] ?? "")) afterStart++;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
before: rawSource.slice(0, match.index),
|
|
58
|
+
after: rawSource.slice(afterStart)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
46
61
|
function splitTailwindGeneratedCssByBanner(rawSource, start) {
|
|
47
62
|
const match = start === void 0 ? TAILWIND_BANNER_RE.exec(rawSource) : { index: start };
|
|
48
63
|
if (!match || match.index === void 0) return;
|
|
@@ -93,6 +108,7 @@ const TAILWIND_ROOT_DIRECTIVE_NAMES = new Set([
|
|
|
93
108
|
const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|tailwind|config|custom-variant|plugin|source|theme|utility|variant)\b/;
|
|
94
109
|
const TAILWIND_EXTRACTABLE_DIRECTIVE_RE = /^\s*@(?:import|tailwind|config|source|reference|plugin)\b[\s\S]*?(?:;|$)/;
|
|
95
110
|
const TAILWIND_EXTRACTABLE_BLOCK_DIRECTIVE_RE = /^\s*@(?:theme|utility|variant|custom-variant)\b[\s\S]*$/;
|
|
111
|
+
const TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE = /^\s*@layer\s[^;{]+;\s*$/;
|
|
96
112
|
function parseImportRequest(params) {
|
|
97
113
|
return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
|
|
98
114
|
}
|
|
@@ -149,7 +165,7 @@ function extractTailwindDirectiveLines(rawSource, options = {}) {
|
|
|
149
165
|
for (const line of stripGeneratorPlaceholderMarkers(rawSource).split(/\r?\n/)) {
|
|
150
166
|
const trimmed = line.trim();
|
|
151
167
|
if (!trimmed || trimmed.startsWith("//")) continue;
|
|
152
|
-
const directive = TAILWIND_EXTRACTABLE_DIRECTIVE_RE.exec(line)?.[0] ?? TAILWIND_EXTRACTABLE_BLOCK_DIRECTIVE_RE.exec(line)?.[0];
|
|
168
|
+
const directive = TAILWIND_EXTRACTABLE_DIRECTIVE_RE.exec(line)?.[0] ?? TAILWIND_EXTRACTABLE_BLOCK_DIRECTIVE_RE.exec(line)?.[0] ?? TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE.exec(line)?.[0];
|
|
153
169
|
if (!directive) continue;
|
|
154
170
|
const normalized = normalizeTailwindDirectiveLine(directive.trimEnd(), options);
|
|
155
171
|
const normalizedTrimmed = normalized.trim();
|
|
@@ -572,8 +588,19 @@ function removeDisplayP3Declarations(root) {
|
|
|
572
588
|
removeEmptyAtRuleAncestors(parent);
|
|
573
589
|
}
|
|
574
590
|
});
|
|
591
|
+
}
|
|
592
|
+
function removeUnsupportedModernColorDeclarations(root) {
|
|
593
|
+
const customPropertyValues = /* @__PURE__ */ new Map();
|
|
575
594
|
root.walkDecls((decl) => {
|
|
576
|
-
if (
|
|
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);
|
|
577
604
|
});
|
|
578
605
|
}
|
|
579
606
|
//#endregion
|
|
@@ -588,6 +615,7 @@ const PREFLIGHT_RESET_PROPS = new Set([
|
|
|
588
615
|
"padding"
|
|
589
616
|
]);
|
|
590
617
|
const CONTENT_VAR_RE = /var\(\s*--tw-content\b/;
|
|
618
|
+
const HOIST_ANCHOR_COMMENT = "__weapp_tailwindcss_base_anchor__";
|
|
591
619
|
function isMiniProgramThemeScopeSelector$1(selectors) {
|
|
592
620
|
return selectors.length > 0 && selectors.every((selector) => MINI_PROGRAM_THEME_SCOPE_SELECTORS$1.has(selector));
|
|
593
621
|
}
|
|
@@ -705,11 +733,27 @@ function getTopDirectiveTail(root) {
|
|
|
705
733
|
}
|
|
706
734
|
return tail;
|
|
707
735
|
}
|
|
708
|
-
function
|
|
709
|
-
|
|
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
|
+
}
|
|
710
749
|
const topDirectiveTail = getTopDirectiveTail(root);
|
|
711
750
|
const firstRule = rules[0];
|
|
712
751
|
if (!firstRule) return;
|
|
752
|
+
if (anchor) {
|
|
753
|
+
firstRule.raws.before = anchor.raws.before;
|
|
754
|
+
anchor.replaceWith(rules);
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
713
757
|
firstRule.raws.before = topDirectiveTail ? "\n" : "";
|
|
714
758
|
if (topDirectiveTail) topDirectiveTail.after(rules);
|
|
715
759
|
else root.prepend(rules);
|
|
@@ -723,13 +767,15 @@ function finalizeMiniProgramCssRoot(root, options = {}) {
|
|
|
723
767
|
removeSpecificityPlaceholders(root);
|
|
724
768
|
removeUnsupportedBrowserSelectors(root);
|
|
725
769
|
removeDisplayP3Declarations(root);
|
|
770
|
+
removeUnsupportedModernColorDeclarations(root);
|
|
771
|
+
const hoistAnchor = createHoistInsertionAnchor(root);
|
|
726
772
|
const preflightRules = collectPreflightRules(root, options);
|
|
727
773
|
if (preflightRules.length === 0) {
|
|
728
774
|
const resetRule = createPreflightResetRule(options.cssPreflight);
|
|
729
775
|
if (resetRule) preflightRules.push(resetRule);
|
|
730
776
|
}
|
|
731
777
|
const themeRule = collectThemeVariableRule(root, options);
|
|
732
|
-
insertHoistedRules(root, themeRule ? [...preflightRules, themeRule] : preflightRules);
|
|
778
|
+
insertHoistedRules(root, themeRule ? [...preflightRules, themeRule] : preflightRules, hoistAnchor);
|
|
733
779
|
}
|
|
734
780
|
function unwrapTailwindSourceMedia(root) {
|
|
735
781
|
root.walkAtRules("media", (atRule) => {
|
|
@@ -1474,6 +1520,57 @@ function createStableJson(value) {
|
|
|
1474
1520
|
function createLegacyCompatTransformCacheKey(source, options) {
|
|
1475
1521
|
return `${createStableJson(options)}\0${source}`;
|
|
1476
1522
|
}
|
|
1523
|
+
function countUnclosedBlocks(source) {
|
|
1524
|
+
let depth = 0;
|
|
1525
|
+
let quote;
|
|
1526
|
+
let inComment = false;
|
|
1527
|
+
let escaped = false;
|
|
1528
|
+
for (let index = 0; index < source.length; index += 1) {
|
|
1529
|
+
const char = source[index];
|
|
1530
|
+
const next = source[index + 1];
|
|
1531
|
+
if (inComment) {
|
|
1532
|
+
if (char === "*" && next === "/") {
|
|
1533
|
+
inComment = false;
|
|
1534
|
+
index += 1;
|
|
1535
|
+
}
|
|
1536
|
+
continue;
|
|
1537
|
+
}
|
|
1538
|
+
if (quote) {
|
|
1539
|
+
if (escaped) {
|
|
1540
|
+
escaped = false;
|
|
1541
|
+
continue;
|
|
1542
|
+
}
|
|
1543
|
+
if (char === "\\") {
|
|
1544
|
+
escaped = true;
|
|
1545
|
+
continue;
|
|
1546
|
+
}
|
|
1547
|
+
if (char === quote) quote = void 0;
|
|
1548
|
+
continue;
|
|
1549
|
+
}
|
|
1550
|
+
if (char === "/" && next === "*") {
|
|
1551
|
+
inComment = true;
|
|
1552
|
+
index += 1;
|
|
1553
|
+
continue;
|
|
1554
|
+
}
|
|
1555
|
+
if (char === "\"" || char === "'") {
|
|
1556
|
+
quote = char;
|
|
1557
|
+
continue;
|
|
1558
|
+
}
|
|
1559
|
+
if (char === "{") depth += 1;
|
|
1560
|
+
else if (char === "}" && depth > 0) depth -= 1;
|
|
1561
|
+
}
|
|
1562
|
+
return depth;
|
|
1563
|
+
}
|
|
1564
|
+
function closeTrailingUnclosedBlocks(source) {
|
|
1565
|
+
try {
|
|
1566
|
+
postcss.default.parse(source);
|
|
1567
|
+
return source;
|
|
1568
|
+
} catch (error) {
|
|
1569
|
+
if (error.reason !== "Unclosed block") return source;
|
|
1570
|
+
const unclosedBlocks = countUnclosedBlocks(source);
|
|
1571
|
+
return unclosedBlocks > 0 ? `${source}${"}".repeat(unclosedBlocks)}` : source;
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1477
1574
|
function removeTailwindApplyRules(rawSource) {
|
|
1478
1575
|
try {
|
|
1479
1576
|
const root = postcss.default.parse(rawSource);
|
|
@@ -1495,7 +1592,7 @@ function removeTailwindApplyRules(rawSource) {
|
|
|
1495
1592
|
function resolveLegacyCompatCssSource(rawSource) {
|
|
1496
1593
|
const cached = legacyCompatSourceCache.get(rawSource);
|
|
1497
1594
|
if (cached !== void 0) return cached;
|
|
1498
|
-
const resolved = removeUnsupportedMiniProgramAtRules(removeTailwindApplyRules(removeTailwindSourceDirectives(stripTailwindBanners(rawSource))));
|
|
1595
|
+
const resolved = closeTrailingUnclosedBlocks(removeUnsupportedMiniProgramAtRules(removeTailwindApplyRules(removeTailwindSourceDirectives(closeTrailingUnclosedBlocks(stripTailwindBanners(rawSource))))));
|
|
1499
1596
|
setLimitedCacheValue(legacyCompatSourceCache, rawSource, resolved);
|
|
1500
1597
|
return resolved;
|
|
1501
1598
|
}
|
|
@@ -1610,10 +1707,10 @@ function inheritLegacyUnitConvertedDeclarations(css, legacyCss) {
|
|
|
1610
1707
|
//#region src/bundlers/shared/generator-css.ts
|
|
1611
1708
|
const SUPPORTED_GENERATOR_MAJOR_VERSIONS = new Set([3, 4]);
|
|
1612
1709
|
const REMOTE_IMPORT_RE = /^(?:https?:)?\/\//i;
|
|
1613
|
-
function finalizeMiniProgramGeneratorCss(css, target, majorVersion, cssPreflight) {
|
|
1710
|
+
function finalizeMiniProgramGeneratorCss(css, target, majorVersion, cssPreflight, options = {}) {
|
|
1614
1711
|
if (target !== "weapp") return css;
|
|
1615
1712
|
return finalizeMiniProgramCss(css, {
|
|
1616
|
-
cssPreflight: majorVersion === 4 ? cssPreflight : void 0,
|
|
1713
|
+
cssPreflight: majorVersion === 4 && options.injectPreflight !== false ? cssPreflight : void 0,
|
|
1617
1714
|
preservePseudoContentInit: majorVersion === 3
|
|
1618
1715
|
});
|
|
1619
1716
|
}
|
|
@@ -1661,6 +1758,20 @@ function isCommentOnlyCss(source) {
|
|
|
1661
1758
|
return false;
|
|
1662
1759
|
}
|
|
1663
1760
|
}
|
|
1761
|
+
function stripTailwindSourceMediaFragments(source) {
|
|
1762
|
+
return source.replace(/^\s*@media\s+source\([^)]*\)\s*\{\s*$/gm, "").replace(/^\s*\}\s*(?=@(?:source|theme|config|plugin|utility|variant|custom-variant)\b)/gm, "").replace(/^\s*\}\s*\/\*\s*source\([^)]*\)\s*\*\/\s*$/gm, "");
|
|
1763
|
+
}
|
|
1764
|
+
function stripLeadingTailwindSourceMediaCloseFragment(source) {
|
|
1765
|
+
return source.replace(/^\s*\}\s*(?:\n|$)/, "");
|
|
1766
|
+
}
|
|
1767
|
+
function stripUnmatchedTailwindSourceMediaCloseFragments(source) {
|
|
1768
|
+
try {
|
|
1769
|
+
postcss.default.parse(source);
|
|
1770
|
+
return source;
|
|
1771
|
+
} catch {
|
|
1772
|
+
return stripLeadingTailwindSourceMediaCloseFragment(source).replace(/\s*\}\s*$/, "");
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1664
1775
|
function createCssSourceOrderAppend(base, extra) {
|
|
1665
1776
|
if (!base) return extra;
|
|
1666
1777
|
if (!extra) return base;
|
|
@@ -1668,19 +1779,21 @@ function createCssSourceOrderAppend(base, extra) {
|
|
|
1668
1779
|
return `${base}\n${extra}`;
|
|
1669
1780
|
}
|
|
1670
1781
|
function splitRawSourceByGeneratedCssOrder(rawSource, rawTailwindCss) {
|
|
1782
|
+
const placeholderParts = splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss);
|
|
1783
|
+
if (placeholderParts) return placeholderParts;
|
|
1671
1784
|
const exactParts = splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss);
|
|
1672
1785
|
if (exactParts) return exactParts;
|
|
1673
1786
|
return splitTailwindGeneratedCssByBanner(rawSource);
|
|
1674
1787
|
}
|
|
1675
1788
|
async function transformGeneratorUserCss(source, options) {
|
|
1676
1789
|
if (source.trim().length === 0) return "";
|
|
1677
|
-
const cleanedSource = removeTailwindSourceDirectives(source, { importFallback: options.importFallback });
|
|
1790
|
+
const cleanedSource = removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source)), { importFallback: options.importFallback });
|
|
1678
1791
|
if (cleanedSource.trim().length === 0) return "";
|
|
1679
|
-
const
|
|
1680
|
-
if (
|
|
1681
|
-
if (isCommentOnlyCss(
|
|
1682
|
-
if (options.generatorTarget !== "weapp") return
|
|
1683
|
-
const { css } = await options.styleHandler(
|
|
1792
|
+
const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? removeUnsupportedMiniProgramAtRules(cleanedSource) : cleanedSource)), { importFallback: options.importFallback }));
|
|
1793
|
+
if (userSource.trim().length === 0) return "";
|
|
1794
|
+
if (isCommentOnlyCss(userSource)) return userSource;
|
|
1795
|
+
if (options.generatorTarget !== "weapp") return userSource;
|
|
1796
|
+
const { css } = await options.styleHandler(userSource, {
|
|
1684
1797
|
...options.generatorStyleOptions,
|
|
1685
1798
|
...options.cssUserHandlerOptions
|
|
1686
1799
|
});
|
|
@@ -1742,7 +1855,7 @@ async function generateCssByGenerator(options) {
|
|
|
1742
1855
|
const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, debug } = options;
|
|
1743
1856
|
const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator);
|
|
1744
1857
|
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
1745
|
-
const effectiveRawSource = normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback });
|
|
1858
|
+
const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })));
|
|
1746
1859
|
const cleanedLocalImportWrapper = cleanLocalCssImportWrapperTailwindDirectives(effectiveRawSource);
|
|
1747
1860
|
if (cleanedLocalImportWrapper !== void 0) return {
|
|
1748
1861
|
css: generatorOptions.target === "weapp" ? removeUnsupportedMiniProgramAtRules(cleanedLocalImportWrapper) : cleanedLocalImportWrapper,
|
|
@@ -1800,7 +1913,7 @@ async function generateCssByGenerator(options) {
|
|
|
1800
1913
|
if (typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
|
|
1801
1914
|
const incrementalCss = stripTailwindBanner(generated.incrementalCss);
|
|
1802
1915
|
return {
|
|
1803
|
-
css: incrementalCss.trim().length > 0 ? createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight)) : options.previousCss,
|
|
1916
|
+
css: incrementalCss.trim().length > 0 ? createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, { injectPreflight: false })) : options.previousCss,
|
|
1804
1917
|
target: generated.target,
|
|
1805
1918
|
source: "generator",
|
|
1806
1919
|
dependencies: generated.dependencies,
|
|
@@ -1836,7 +1949,7 @@ async function generateCssByGenerator(options) {
|
|
|
1836
1949
|
debug("tailwind direct css generation prefix mismatch, append transformed bundle css %s", file);
|
|
1837
1950
|
let css = stripTailwindBanner(generated.css);
|
|
1838
1951
|
if (generated.target === "weapp") css = inheritLegacyUnitConvertedDeclarations(css, effectiveRawSource);
|
|
1839
|
-
if (hasMatchedCssSourceFile) return {
|
|
1952
|
+
if (hasMatchedCssSourceFile || generated.target === "web") return {
|
|
1840
1953
|
css: finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight),
|
|
1841
1954
|
target: generated.target,
|
|
1842
1955
|
source: "generator",
|