weapp-tailwindcss 5.5.5 → 5.5.6
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/bundlers/gulp/shared/create-native-framework-plugins/file-transforms.d.ts +5 -4
- package/dist/bundlers/shared/final-css-cleanup.d.ts +1 -2
- package/dist/bundlers/shared/framework-css-composition.d.ts +1 -0
- package/dist/bundlers/shared/framework-postcss.d.ts +2 -1
- package/dist/bundlers/shared/framework-user-css.d.ts +1 -0
- package/dist/bundlers/shared/generated-css-marker.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/generation-helpers/results.d.ts +5 -7
- package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +4 -1
- package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +1 -4
- package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/pipeline/context.d.ts +4 -2
- package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/types.d.ts +6 -3
- package/dist/bundlers/shared/generator-css/user-css/apply-only.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/user-css/compile-functions.d.ts +4 -0
- package/dist/bundlers/shared/generator-css/user-css/generated-cleanup.d.ts +3 -1
- package/dist/bundlers/shared/generator-css/user-css/source-fragments.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/user-css/transform.d.ts +3 -0
- package/dist/bundlers/shared/style-handler-options.d.ts +7 -0
- package/dist/bundlers/shared/v4-generation-core.d.ts +0 -1
- package/dist/bundlers/vite/css-finalizer/css-calc.d.ts +3 -0
- package/dist/bundlers/vite/css-finalizer/final-assets.d.ts +3 -0
- package/dist/bundlers/vite/css-handler-options.d.ts +1 -1
- package/dist/bundlers/vite/frameworks/generic/web.d.ts +2 -1
- package/dist/bundlers/vite/generate-bundle/css-transform-decision-plan.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/finalize/sync-processed-css.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/framework-style-memory.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +7 -0
- package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/runtime.d.ts +3 -1
- package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/temporary-css-assets.d.ts +2 -2
- package/dist/bundlers/vite/generate-bundle/types.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/web-css-module.d.ts +1 -0
- package/dist/bundlers/vite/plugin-hook.d.ts +3 -0
- package/dist/bundlers/vite/processed-css-assets/coverage.d.ts +3 -1
- package/dist/bundlers/vite/processed-css-assets/markers-imports.d.ts +1 -1
- package/dist/bundlers/vite/processed-css-assets/scoped-tailwind-noise.d.ts +1 -1
- package/dist/bundlers/vite/shared/create-framework-plugins-runtime.d.ts +3 -1
- package/dist/bundlers/vite/shared/framework-module-candidates.d.ts +2 -1
- package/dist/bundlers/vite/shared/framework-runtime-configuration.d.ts +3 -0
- package/dist/bundlers/vite/shared/framework-runtime-options.d.ts +9 -0
- package/dist/bundlers/vite/shared/framework-runtime-utils.d.ts +6 -5
- package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +3 -3
- package/dist/bundlers/vite/shared/framework-strategy.d.ts +3 -1
- package/dist/bundlers/vite/shared/hmr-source.d.ts +2 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/processed-css-task.d.ts +2 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -1
- package/dist/bundlers/webpack/shared/create-framework-plugin/plugin.d.ts +1 -1
- package/dist/compiler/index.d.ts +2 -0
- package/dist/compiler/semantic-css.d.ts +1 -1
- package/dist/compiler/types.d.ts +1 -1
- package/dist/{compiler-Cc0JXfbw.cjs → compiler-C8FqI-P3.cjs} +17378 -40552
- package/dist/{compiler-D_vxtEdw.js → compiler-D3GBwxoa.js} +32 -23
- package/dist/core/compiler/transforms.d.ts +1 -1
- package/dist/core.cjs +4 -4
- package/dist/core.js +4 -4
- package/dist/{css-imports-FRZwX4P6.cjs → css-imports-XvtI1zCY.cjs} +2 -3
- package/dist/css-macro.cjs +1 -1
- package/dist/css-macro.js +1 -1
- package/dist/{defaults-CKx-4LcW.js → defaults-AQuvJS-h.js} +4 -2
- package/dist/{defaults-CiGsr8Xq.cjs → defaults-CyX5iO9y.cjs} +4 -2
- package/dist/defaults.cjs +1 -1
- package/dist/defaults.js +1 -1
- package/dist/final-css-cleanup-CDTmVAye.cjs +1 -0
- package/dist/{final-css-cleanup-B0HUBtiE.js → final-css-cleanup-u_sI2p56.js} +1 -126
- package/dist/framework/index.d.ts +1 -1
- package/dist/framework/platform.d.ts +2 -2
- package/dist/{generator-BdSIvFEO.cjs → generator-Bvr4WmuF.cjs} +135 -149
- package/dist/{generator-CAOx1Sqm.js → generator-C0BJjyLM.js} +116 -130
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-Dnt8VL8D.cjs → gulp-BExe5RBF.cjs} +8 -8
- package/dist/{gulp-B1mPTMqw.js → gulp-BhkIIk7J.js} +5 -5
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-wAt0LavM.js → hmr-timing-B9Yt86-U.js} +299 -404
- package/dist/{hmr-timing-qpX410qU.cjs → hmr-timing-CoiJIqDu.cjs} +4 -4
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/js/NodePathWalker.d.ts +1 -1
- package/dist/js/node-path-walker/export-handlers.d.ts +1 -1
- package/dist/js/node-path-walker/import-tokens.d.ts +1 -1
- package/dist/{pipeline-helpers-BHagysZY.cjs → pipeline-helpers-BOjTEmMi.cjs} +6 -6
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +2 -2
- package/dist/presets.js +2 -2
- package/dist/rspack.cjs +2 -2
- package/dist/rspack.js +2 -2
- package/dist/{scoped-generator-BqxVxNp9.js → scoped-generator-B6Y1bxzM.js} +46 -31
- package/dist/{scoped-generator-CtetE5rm.cjs → scoped-generator-BUBls_oM.cjs} +46 -31
- package/dist/{source-candidate-scan-signature-BDGB9nKZ.cjs → source-candidate-scan-signature-BtJZp28T.cjs} +32 -3
- package/dist/{source-candidate-scan-signature-Lm32zKVA.js → source-candidate-scan-signature-DNuGKTqf.js} +21 -4
- package/dist/style-injector/internal.d.ts +118 -8
- package/dist/style-injector/options.d.ts +5 -1
- package/dist/tailwindcss/runtime-options.d.ts +5 -0
- package/dist/tailwindcss/v4/preflight.d.ts +0 -1
- package/dist/tailwindcss/v4-engine/generator/style-context.d.ts +1 -3
- package/dist/{tailwindcss-DTV9MoJT.js → tailwindcss-B_4E52WF.js} +7 -13
- package/dist/{tailwindcss-9e6ZuYgS.cjs → tailwindcss-CBYjzRmV.cjs} +4 -10
- package/dist/{transform-BbbZvFQq.js → transform-CkEnJYIP.js} +18 -12
- package/dist/{transform-D21f8Dm8.cjs → transform-FkqbTBJR.cjs} +17 -11
- package/dist/types/index.d.ts +3 -2
- package/dist/uni-app-x/border-preflight.d.ts +1 -2
- package/dist/uni-app-x/component-local-style.d.ts +2 -1
- package/dist/uni-app-x/transform.d.ts +4 -2
- package/dist/uni-app-x/vite/author-apply.d.ts +3 -1
- package/dist/uni-app-x/vite/native-hmr.d.ts +1 -1
- package/dist/uni-app-x/vite/style-result.d.ts +5 -0
- package/dist/{v4-generation-core-DJBWZ_D0.cjs → v4-generation-core-Cz1D7wm1.cjs} +313 -418
- package/dist/vite/web.cjs +1 -1
- package/dist/vite/web.js +1 -1
- package/dist/{vite-CaH7WjX6.cjs → vite-DxuKPZlp.cjs} +565 -592
- package/dist/{vite-CuYntLZP.js → vite-lP35OguX.js} +558 -578
- package/dist/vite-web.d.ts +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-generation-loader.cjs +2 -2
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +7 -7
- package/dist/{web-CdXkY_VO.js → web-Dfz_jpNj.js} +144 -107
- package/dist/{web-CYs2Kcaa.cjs → web-DhDxhlkq.cjs} +156 -107
- package/dist/{webpack-BnCSOUuu.js → webpack-D6jp1o3m.js} +18 -17
- package/dist/{webpack-BQNnpQPC.cjs → webpack-R2Sbggiy.cjs} +20 -20
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/dist/wxml/utils/codegen/legacy-visitor.d.ts +2 -2
- package/dist/wxml/utils/custom-template.d.ts +1 -1
- package/package.json +8 -10
- package/dist/final-css-cleanup-DSjczga3.cjs +0 -138
- package/dist/tailwindcss/v4-engine/css-import.d.ts +0 -14
- package/dist/uni-app-x/style-asset/source-parser.d.ts +0 -2
|
@@ -12,7 +12,6 @@ let _tailwindcss_mangle_engine = require("@tailwindcss-mangle/engine");
|
|
|
12
12
|
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
13
13
|
let lru_cache = require("lru-cache");
|
|
14
14
|
let node_module = require("node:module");
|
|
15
|
-
let _csstools_css_tokenizer = require("@csstools/css-tokenizer");
|
|
16
15
|
let node_fs_promises = require("node:fs/promises");
|
|
17
16
|
let micromatch = require("micromatch");
|
|
18
17
|
micromatch = require_rolldown_runtime.__toESM(micromatch, 1);
|
|
@@ -321,7 +320,7 @@ async function transformTailwindV4CssToWeapp(css, options) {
|
|
|
321
320
|
...options
|
|
322
321
|
});
|
|
323
322
|
const pruneOptions = {
|
|
324
|
-
|
|
323
|
+
...options?.uniAppX === true && options.uniAppXCssTarget === "uvue" ? { preserveContentInit: false } : {},
|
|
325
324
|
preservePreflight: true,
|
|
326
325
|
preserveConditionalComments: (0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options)
|
|
327
326
|
};
|
|
@@ -339,48 +338,8 @@ function transformTailwindV4WebRpxCss(css) {
|
|
|
339
338
|
async function transformTailwindV4CssByTarget(css, target, options) {
|
|
340
339
|
if (target === "weapp") return transformTailwindV4CssToWeapp(css, options);
|
|
341
340
|
const resolvedWebCss = await ((0, _weapp_tailwindcss_postcss.hasCssMacroStyleOptions)(options) ? (0, _weapp_tailwindcss_postcss.transformCssMacroCss)(css, options) : css);
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
//#endregion
|
|
345
|
-
//#region src/tailwindcss/v4-engine/css-import.ts
|
|
346
|
-
function parseCssImportSpecifier(params) {
|
|
347
|
-
const tokens = (0, _csstools_css_tokenizer.tokenize)({ css: params }).filter((token) => token[0] !== _csstools_css_tokenizer.TokenType.Whitespace && token[0] !== _csstools_css_tokenizer.TokenType.Comment);
|
|
348
|
-
const first = tokens[0];
|
|
349
|
-
if (!first) return;
|
|
350
|
-
if (first[0] === _csstools_css_tokenizer.TokenType.String || first[0] === _csstools_css_tokenizer.TokenType.URL) return {
|
|
351
|
-
specifier: first[4].value,
|
|
352
|
-
raw: first[1],
|
|
353
|
-
quote: first[0] === _csstools_css_tokenizer.TokenType.String ? first[1][0] : void 0
|
|
354
|
-
};
|
|
355
|
-
if (first[0] === _csstools_css_tokenizer.TokenType.Function && first[4].value.toLowerCase() === "url" && tokens[1]?.[0] === _csstools_css_tokenizer.TokenType.String && tokens[2]?.[0] === _csstools_css_tokenizer.TokenType.CloseParen) return {
|
|
356
|
-
specifier: tokens[1][4].value,
|
|
357
|
-
raw: params.slice(first[2], tokens[2][3] + 1),
|
|
358
|
-
quote: tokens[1][1][0]
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
function quoteCssImportSpecifier(file, quote = "\"") {
|
|
362
|
-
return `${quote}${(node_path.default.sep === "\\" || /^[a-z]:[\\/]|^\\\\/i.test(file) ? file.replaceAll("\\", "/") : file).replaceAll("\\", "\\\\").replaceAll(quote, `\\${quote}`).replaceAll("\n", "\\a ").replaceAll("\r", "\\d ")}${quote}`;
|
|
363
|
-
}
|
|
364
|
-
function isTailwindCssImport(params) {
|
|
365
|
-
const specifier = parseCssImportSpecifier(params)?.specifier;
|
|
366
|
-
if (!specifier) return false;
|
|
367
|
-
if (specifier === "tailwindcss" || specifier.startsWith("tailwindcss/")) return true;
|
|
368
|
-
const paths = specifier.includes("\\") ? node_path.default.win32 : node_path.default.posix;
|
|
369
|
-
return paths.basename(specifier) === "index.css" && paths.basename(paths.dirname(specifier)) === "tailwindcss";
|
|
370
|
-
}
|
|
371
|
-
function parseImportSourceParam(params) {
|
|
372
|
-
const tokens = (0, _csstools_css_tokenizer.tokenize)({ css: params }).filter((token) => token[0] !== _csstools_css_tokenizer.TokenType.Whitespace && token[0] !== _csstools_css_tokenizer.TokenType.Comment);
|
|
373
|
-
const index = tokens.findIndex((token) => token[0] === _csstools_css_tokenizer.TokenType.Function && token[4].value === "source");
|
|
374
|
-
const value = tokens[index + 1];
|
|
375
|
-
if (index < 0 || tokens[index + 2]?.[0] !== _csstools_css_tokenizer.TokenType.CloseParen) return;
|
|
376
|
-
if (value?.[0] === _csstools_css_tokenizer.TokenType.Ident && value[4].value === "none") return {
|
|
377
|
-
none: true,
|
|
378
|
-
sourcePath: void 0
|
|
379
|
-
};
|
|
380
|
-
return value?.[0] === _csstools_css_tokenizer.TokenType.String ? {
|
|
381
|
-
none: false,
|
|
382
|
-
sourcePath: value[4].value
|
|
383
|
-
} : void 0;
|
|
341
|
+
const calculatedWebCss = await (0, _weapp_tailwindcss_postcss.applyConfiguredCssCalc)(resolvedWebCss, options ?? {});
|
|
342
|
+
return shouldUseUniAppWebRpxCompatibility(options?.appType) ? transformTailwindV4WebRpxCss(calculatedWebCss) : calculatedWebCss;
|
|
384
343
|
}
|
|
385
344
|
//#endregion
|
|
386
345
|
//#region src/tailwindcss/v4-engine/tailwind-v4-default-colors.ts
|
|
@@ -772,7 +731,7 @@ function resolveTailwindV4ThemeCssFromImport(css) {
|
|
|
772
731
|
let resolved;
|
|
773
732
|
root.walkAtRules("import", (rule) => {
|
|
774
733
|
if (resolved) return;
|
|
775
|
-
const specifier = parseCssImportSpecifier(rule.params)?.specifier;
|
|
734
|
+
const specifier = (0, _weapp_tailwindcss_postcss.parseCssImportSpecifier)(rule.params)?.specifier;
|
|
776
735
|
if (!specifier || !node_path.default.isAbsolute(specifier) || node_path.default.basename(specifier) !== "index.css") return;
|
|
777
736
|
const themeCss = node_path.default.join(node_path.default.dirname(specifier), "theme.css");
|
|
778
737
|
if ((0, node_fs.existsSync)(themeCss)) resolved = themeCss;
|
|
@@ -804,58 +763,10 @@ function applyMiniProgramTailwindV4DefaultColorCss(css, source) {
|
|
|
804
763
|
if (insertionIndex === 0) return `${themeCss}\n${css}`;
|
|
805
764
|
return `${css.slice(0, insertionIndex)}\n${themeCss}\n${css.slice(insertionIndex)}`;
|
|
806
765
|
}
|
|
807
|
-
function isTailwindCssPreflightImport(params) {
|
|
808
|
-
const specifier = parseCssImportSpecifier(params)?.specifier;
|
|
809
|
-
return specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss/preflight";
|
|
810
|
-
}
|
|
811
|
-
function removeTailwindV4PreflightImports(css) {
|
|
812
|
-
if (!css.includes("preflight")) return css;
|
|
813
|
-
let root;
|
|
814
|
-
try {
|
|
815
|
-
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
816
|
-
} catch {
|
|
817
|
-
return css;
|
|
818
|
-
}
|
|
819
|
-
let changed = false;
|
|
820
|
-
root.walkAtRules("import", (rule) => {
|
|
821
|
-
if (isTailwindCssPreflightImport(rule.params)) {
|
|
822
|
-
rule.remove();
|
|
823
|
-
changed = true;
|
|
824
|
-
}
|
|
825
|
-
});
|
|
826
|
-
return changed ? root.toString() : css;
|
|
827
|
-
}
|
|
828
|
-
function hasThemeParent(rule) {
|
|
829
|
-
let parent = rule.parent;
|
|
830
|
-
while (parent) {
|
|
831
|
-
if (parent.type === "atrule" && parent.name === "theme") return true;
|
|
832
|
-
parent = parent.parent;
|
|
833
|
-
}
|
|
834
|
-
return false;
|
|
835
|
-
}
|
|
836
|
-
function isVendorPrefixedKeyframes(rule) {
|
|
837
|
-
return rule.name.startsWith("-") && rule.name.endsWith("keyframes");
|
|
838
|
-
}
|
|
839
|
-
function removeUnsupportedThemeVendorKeyframes(css) {
|
|
840
|
-
if (!css.includes("@theme") || !css.includes("@-")) return css;
|
|
841
|
-
let root;
|
|
842
|
-
try {
|
|
843
|
-
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
844
|
-
} catch {
|
|
845
|
-
return css;
|
|
846
|
-
}
|
|
847
|
-
let changed = false;
|
|
848
|
-
root.walkAtRules((rule) => {
|
|
849
|
-
if (isVendorPrefixedKeyframes(rule) && hasThemeParent(rule)) {
|
|
850
|
-
rule.remove();
|
|
851
|
-
changed = true;
|
|
852
|
-
}
|
|
853
|
-
});
|
|
854
|
-
return changed ? root.toString() : css;
|
|
855
|
-
}
|
|
856
766
|
function createCompatibleSource(source, target) {
|
|
857
|
-
const filteredSourceCss = target === "weapp" ? removeTailwindV4PreflightImports(source.css) : source.css;
|
|
858
|
-
const
|
|
767
|
+
const filteredSourceCss = target === "weapp" ? (0, _weapp_tailwindcss_postcss.removeTailwindV4PreflightImports)(source.css) : source.css;
|
|
768
|
+
const sourceCss = target === "weapp" ? applyMiniProgramTailwindV4DefaultColorCss(filteredSourceCss, source) : filteredSourceCss;
|
|
769
|
+
const compatibleSourceCss = (0, _weapp_tailwindcss_postcss.removeUnsupportedThemeVendorKeyframes)(sourceCss);
|
|
859
770
|
return compatibleSourceCss === source.css ? source : {
|
|
860
771
|
...source,
|
|
861
772
|
css: compatibleSourceCss
|
|
@@ -1273,7 +1184,7 @@ async function resolveCssDefinedScanSources(source) {
|
|
|
1273
1184
|
const definitions = [{
|
|
1274
1185
|
css: source.css,
|
|
1275
1186
|
base: source.base,
|
|
1276
|
-
from: source.dependencies[0]
|
|
1187
|
+
...source.dependencies[0] === void 0 ? {} : { from: source.dependencies[0] }
|
|
1277
1188
|
}];
|
|
1278
1189
|
for (const dependency of source.dependencies.slice(1)) {
|
|
1279
1190
|
if (!(0, node_fs.existsSync)(dependency)) continue;
|
|
@@ -1293,28 +1204,22 @@ async function resolveCssDefinedScanSources(source) {
|
|
|
1293
1204
|
continue;
|
|
1294
1205
|
}
|
|
1295
1206
|
root.walkAtRules((rule) => {
|
|
1296
|
-
if (rule.name !== "import" || !isTailwindCssImport(rule.params)) return;
|
|
1207
|
+
if (rule.name !== "import" || !(0, _weapp_tailwindcss_postcss.isTailwindCssImport)(rule.params)) return;
|
|
1297
1208
|
hasTailwindImport = true;
|
|
1298
|
-
const sourceParam = parseImportSourceParam(rule.params);
|
|
1209
|
+
const sourceParam = (0, _weapp_tailwindcss_postcss.parseImportSourceParam)(rule.params);
|
|
1299
1210
|
if (sourceParam?.none) hasSourceNone = true;
|
|
1300
1211
|
if (sourceParam?.sourcePath) importSourceBase = resolveSourceBase(definition.base, sourceParam.sourcePath);
|
|
1301
1212
|
});
|
|
1302
1213
|
sourcePatterns.push(...await resolveCssSourceEntries(root, definition.base, "**/*"));
|
|
1303
1214
|
}
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
}
|
|
1313
|
-
return [
|
|
1314
|
-
await resolveTailwindSourceEntry(".", importSourceBase, false, "**/*"),
|
|
1315
|
-
...sourcePatterns,
|
|
1316
|
-
...createDefaultIgnoredScanSources(importSourceBase)
|
|
1317
|
-
];
|
|
1215
|
+
let entries;
|
|
1216
|
+
if (importSourceBase) entries = [await resolveTailwindSourceEntry(".", importSourceBase, false, "**/*"), ...sourcePatterns];
|
|
1217
|
+
else if (sourcePatterns.length > 0) entries = normalizeCssDefinedScanSources(source.base, sourcePatterns);
|
|
1218
|
+
else if (hasSourceNone) return false;
|
|
1219
|
+
else if (hasTailwindImport) entries = [await resolveTailwindSourceEntry(".", resolveDefaultSourceBase(source), false, "**/*")];
|
|
1220
|
+
else return;
|
|
1221
|
+
const scanBases = /* @__PURE__ */ new Set([importSourceBase ?? (sourcePatterns.length > 0 ? source.base : resolveDefaultSourceBase(source)), ...entries.filter((entry) => !entry.negated).map((entry) => entry.base)]);
|
|
1222
|
+
return [...entries, ...[...scanBases].flatMap((base) => createDefaultIgnoredScanSources(base))];
|
|
1318
1223
|
}
|
|
1319
1224
|
async function resolveScanSources(source, scanSources) {
|
|
1320
1225
|
if (scanSources !== true) return scanSources;
|
|
@@ -1324,8 +1229,8 @@ function resolveCompiledSourceRoot(source) {
|
|
|
1324
1229
|
let root = null;
|
|
1325
1230
|
try {
|
|
1326
1231
|
_weapp_tailwindcss_postcss.postcss.parse(source.css).walkAtRules("import", (rule) => {
|
|
1327
|
-
if (!isTailwindCssImport(rule.params)) return;
|
|
1328
|
-
const sourceParam = parseImportSourceParam(rule.params);
|
|
1232
|
+
if (!(0, _weapp_tailwindcss_postcss.isTailwindCssImport)(rule.params)) return;
|
|
1233
|
+
const sourceParam = (0, _weapp_tailwindcss_postcss.parseImportSourceParam)(rule.params);
|
|
1329
1234
|
if (sourceParam?.none) {
|
|
1330
1235
|
root = "none";
|
|
1331
1236
|
return false;
|
|
@@ -2072,8 +1977,7 @@ function createCssNodeSignature(node) {
|
|
|
2072
1977
|
node.selector,
|
|
2073
1978
|
node.nodes?.map(createCssNodeSignature) ?? null
|
|
2074
1979
|
]);
|
|
2075
|
-
|
|
2076
|
-
return node.toString();
|
|
1980
|
+
return JSON.stringify(["comment", node.text]);
|
|
2077
1981
|
}
|
|
2078
1982
|
function createRuleBodySignature(rule) {
|
|
2079
1983
|
return JSON.stringify(rule.nodes?.map(createCssNodeSignature) ?? []);
|
|
@@ -2081,7 +1985,7 @@ function createRuleBodySignature(rule) {
|
|
|
2081
1985
|
function createRuleAtRuleContextSignature(rule) {
|
|
2082
1986
|
const context = [];
|
|
2083
1987
|
let parent = rule.parent;
|
|
2084
|
-
while (parent && parent.type !== "root"
|
|
1988
|
+
while (parent && parent.type !== "root") {
|
|
2085
1989
|
if (parent.type === "atrule") context.unshift(JSON.stringify([parent.name, parent.params]));
|
|
2086
1990
|
parent = parent.parent;
|
|
2087
1991
|
}
|
|
@@ -2275,6 +2179,7 @@ function filterApplyOnlyGeneratedCss(css, source, options = {}) {
|
|
|
2275
2179
|
});
|
|
2276
2180
|
});
|
|
2277
2181
|
const isVariableRule = rule.nodes?.some((node) => node.type === "decl" && node.prop.startsWith("--"));
|
|
2182
|
+
if (options.preserveRuntimeProperties && (0, _weapp_tailwindcss_postcss.isTailwindRuntimePropertyRule)(rule)) return;
|
|
2278
2183
|
if (!isApplySelector && (!preserveVariables || !isVariableRule)) rule.remove();
|
|
2279
2184
|
});
|
|
2280
2185
|
root.walkAtRules((rule) => {
|
|
@@ -2357,9 +2262,38 @@ function isTailwindGeneratedThemeScopeSelector(selector) {
|
|
|
2357
2262
|
if (!selectors.every((item) => TAILWIND_GENERATED_THEME_SCOPE_SELECTORS.has(item))) return false;
|
|
2358
2263
|
return selectorSet.size === 2 && selectorSet.has(":root") && selectorSet.has(":host") || selectorSet.size === 4 && selectorSet.has(":host") && selectorSet.has("page") && selectorSet.has(".tw-root") && selectorSet.has("wx-root-portal-content");
|
|
2359
2264
|
}
|
|
2360
|
-
function
|
|
2361
|
-
|
|
2362
|
-
|
|
2265
|
+
function themeDeclarationContext(declaration) {
|
|
2266
|
+
const context = [];
|
|
2267
|
+
let parent = declaration.parent?.parent;
|
|
2268
|
+
while (parent && parent.type !== "root") {
|
|
2269
|
+
if (parent.type === "atrule" && parent.name !== "layer") context.unshift(`@${parent.name} ${parent.params}`);
|
|
2270
|
+
parent = parent.parent;
|
|
2271
|
+
}
|
|
2272
|
+
return context;
|
|
2273
|
+
}
|
|
2274
|
+
function themeDeclarationKey(declaration) {
|
|
2275
|
+
const value = declaration.value.trim().replace(/^(-?)0\.(\d+(?:[a-z]+|%)?)$/i, "$1.$2");
|
|
2276
|
+
return JSON.stringify([
|
|
2277
|
+
themeDeclarationContext(declaration),
|
|
2278
|
+
declaration.prop,
|
|
2279
|
+
value,
|
|
2280
|
+
Boolean(declaration.important)
|
|
2281
|
+
]);
|
|
2282
|
+
}
|
|
2283
|
+
function collectGeneratedThemeDeclarations(source) {
|
|
2284
|
+
const declarations = /* @__PURE__ */ new Set();
|
|
2285
|
+
try {
|
|
2286
|
+
_weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
|
|
2287
|
+
if (!isTailwindGeneratedThemeScopeSelector(rule.selector.replace(/\s+/g, " ").replace(/\s*,\s*/g, ",").trim())) return;
|
|
2288
|
+
for (const child of rule.nodes ?? []) if (child.type === "decl") declarations.add(themeDeclarationKey(child));
|
|
2289
|
+
});
|
|
2290
|
+
} catch {}
|
|
2291
|
+
return declarations;
|
|
2292
|
+
}
|
|
2293
|
+
/** 同一轮框架恢复共享声明索引;只有遇到根变量时才解析生成产物。 */
|
|
2294
|
+
function createGeneratedThemeDeclarationResolver(source) {
|
|
2295
|
+
let declarations;
|
|
2296
|
+
return () => declarations ?? (declarations = collectGeneratedThemeDeclarations(source));
|
|
2363
2297
|
}
|
|
2364
2298
|
function isTailwindGeneratedPreflightRule(selector, node) {
|
|
2365
2299
|
if (selector === "view,text,::after,::before" || selector === "view, text, ::after, ::before" || selector === "*" || selector === "::after" || selector === "::before" || selector === "::backdrop" || selector === ":host" || selector === "[hidden]:not([hidden=\"until-found\"])" || selector === "[hidden]:not([hidden='until-found'])" || selector === "button,input[type=\"button\"],input[type=\"reset\"],input[type=\"submit\"]" || selector === "button, input[type=\"button\"], input[type=\"reset\"], input[type=\"submit\"]" || selector === "button,input[type='button'],input[type='reset'],input[type='submit']" || selector === "button, input[type='button'], input[type='reset'], input[type='submit']") return true;
|
|
@@ -2367,7 +2301,7 @@ function isTailwindGeneratedPreflightRule(selector, node) {
|
|
|
2367
2301
|
if (selector === ":host") return node.nodes?.some((child) => child.type === "decl" && child.value?.includes("--theme(")) ?? false;
|
|
2368
2302
|
return false;
|
|
2369
2303
|
}
|
|
2370
|
-
function removeTailwindV4GeneratedUserCssArtifacts(source) {
|
|
2304
|
+
function removeTailwindV4GeneratedUserCssArtifacts(source, generatedSource) {
|
|
2371
2305
|
try {
|
|
2372
2306
|
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
2373
2307
|
let changed = false;
|
|
@@ -2376,9 +2310,27 @@ function removeTailwindV4GeneratedUserCssArtifacts(source) {
|
|
|
2376
2310
|
comment.remove();
|
|
2377
2311
|
changed = true;
|
|
2378
2312
|
});
|
|
2313
|
+
let generatedDeclarations;
|
|
2314
|
+
const overriddenProperties = /* @__PURE__ */ new Set();
|
|
2379
2315
|
root.walkRules((rule) => {
|
|
2380
|
-
const selector = rule.selector.replace(/\s+/g, " ").trim();
|
|
2381
|
-
if (
|
|
2316
|
+
const selector = rule.selector.replace(/\s+/g, " ").replace(/\s*,\s*/g, ",").trim();
|
|
2317
|
+
if (isTailwindGeneratedThemeScopeSelector(selector) || TAILWIND_GENERATED_THEME_SCOPE_SELECTORS.has(selector) && rule.nodes.some((child) => child.type === "decl" && child.prop.startsWith("--"))) {
|
|
2318
|
+
generatedDeclarations ?? (generatedDeclarations = typeof generatedSource === "function" ? generatedSource() : generatedSource ? collectGeneratedThemeDeclarations(generatedSource) : /* @__PURE__ */ new Set());
|
|
2319
|
+
for (const child of [...rule.nodes]) {
|
|
2320
|
+
if (child.type !== "decl") continue;
|
|
2321
|
+
const propertyKey = JSON.stringify([themeDeclarationContext(child), child.prop]);
|
|
2322
|
+
if (generatedDeclarations?.has(themeDeclarationKey(child)) && !overriddenProperties.has(propertyKey)) {
|
|
2323
|
+
child.remove();
|
|
2324
|
+
changed = true;
|
|
2325
|
+
} else overriddenProperties.add(propertyKey);
|
|
2326
|
+
}
|
|
2327
|
+
if (rule.nodes.length === 0) {
|
|
2328
|
+
rule.remove();
|
|
2329
|
+
changed = true;
|
|
2330
|
+
}
|
|
2331
|
+
return;
|
|
2332
|
+
}
|
|
2333
|
+
if (isTailwindGeneratedPreflightRule(selector, rule)) {
|
|
2382
2334
|
rule.remove();
|
|
2383
2335
|
changed = true;
|
|
2384
2336
|
}
|
|
@@ -2642,16 +2594,37 @@ function unwrapMiniProgramCascadeLayers(source) {
|
|
|
2642
2594
|
function hasClassSelector(selector) {
|
|
2643
2595
|
return /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i.test(selector);
|
|
2644
2596
|
}
|
|
2645
|
-
function collectBareSelectorUserCss(source) {
|
|
2597
|
+
function collectBareSelectorUserCss(source, transformedCss) {
|
|
2646
2598
|
try {
|
|
2647
2599
|
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
2600
|
+
const representedSelectors = /* @__PURE__ */ new Set();
|
|
2601
|
+
const rootSelectors = /* @__PURE__ */ new Set([
|
|
2602
|
+
":root",
|
|
2603
|
+
":host",
|
|
2604
|
+
"page",
|
|
2605
|
+
".tw-root",
|
|
2606
|
+
"wx-root-portal-content"
|
|
2607
|
+
]);
|
|
2608
|
+
const selectorKey = (rule, selector) => {
|
|
2609
|
+
const context = [];
|
|
2610
|
+
let parent = rule.parent;
|
|
2611
|
+
while (parent && parent.type !== "root") {
|
|
2612
|
+
if (parent.type === "atrule") context.unshift(`@${parent.name} ${parent.params}`);
|
|
2613
|
+
parent = parent.parent;
|
|
2614
|
+
}
|
|
2615
|
+
return JSON.stringify([...context, rootSelectors.has(selector.trim()) ? ":root" : selector.trim()]);
|
|
2616
|
+
};
|
|
2617
|
+
if (transformedCss !== void 0) _weapp_tailwindcss_postcss.postcss.parse(transformedCss).walkRules((rule) => {
|
|
2618
|
+
for (const selector of rule.selectors) representedSelectors.add(selectorKey(rule, selector));
|
|
2619
|
+
});
|
|
2648
2620
|
let changed = false;
|
|
2649
2621
|
root.walkAtRules("import", (rule) => {
|
|
2650
2622
|
rule.remove();
|
|
2651
2623
|
changed = true;
|
|
2652
2624
|
});
|
|
2653
2625
|
root.walkRules((rule) => {
|
|
2654
|
-
|
|
2626
|
+
const selectors = rule.selectors?.length ? rule.selectors : [rule.selector];
|
|
2627
|
+
if (selectors.some((selector) => hasClassSelector(selector)) || selectors.every((selector) => representedSelectors.has(selectorKey(rule, selector)))) {
|
|
2655
2628
|
rule.remove();
|
|
2656
2629
|
changed = true;
|
|
2657
2630
|
}
|
|
@@ -2697,22 +2670,30 @@ function stripUnmatchedTailwindSourceMediaCloseFragments(source) {
|
|
|
2697
2670
|
//#region src/bundlers/shared/generator-css/user-css/transform.ts
|
|
2698
2671
|
async function transformGeneratorUserCss(source, options) {
|
|
2699
2672
|
if (source.trim().length === 0) return "";
|
|
2700
|
-
if (options.processed)
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2673
|
+
if (options.processed) {
|
|
2674
|
+
const compiledSource = await options.compileAuthorCssFunctions?.(source) ?? source;
|
|
2675
|
+
return stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(removeTailwindV4GeneratorAtRules(options.generatorTarget === "weapp" ? removeTailwindV4GeneratedUserCssArtifacts(unwrapMiniProgramCascadeLayers(removeProcessedMiniProgramUnsupportedCss(compiledSource, {
|
|
2676
|
+
...options.generatorStyleOptions,
|
|
2677
|
+
...options.cssUserHandlerOptions
|
|
2678
|
+
})), options.generatedSource) : compiledSource)));
|
|
2679
|
+
}
|
|
2704
2680
|
const cleanedSource = removeTailwindSourceDirectives(removeTailwindV4GeneratorAtRules(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source))), { importFallback: options.importFallback });
|
|
2705
2681
|
if (cleanedSource.trim().length === 0) return "";
|
|
2706
|
-
const
|
|
2682
|
+
const authorSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindApplyAtRules(removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(unwrapMiniProgramCascadeLayers(stripTailwindBanners(cleanedSource))), options.generatedSource) : cleanedSource)), { importFallback: options.importFallback })));
|
|
2683
|
+
const userSource = await options.compileAuthorCssFunctions?.(authorSource) ?? authorSource;
|
|
2707
2684
|
if (userSource.trim().length === 0) return "";
|
|
2708
2685
|
if (isCommentOnlyCss(userSource)) return userSource;
|
|
2709
|
-
if (options.generatorTarget !== "weapp") return userSource
|
|
2686
|
+
if (options.generatorTarget !== "weapp") return (0, _weapp_tailwindcss_postcss.applyConfiguredCssCalc)(userSource, {
|
|
2687
|
+
cssCalc: options.generatorStyleOptions.cssOptions?.cssCalc ?? options.generatorStyleOptions.cssCalc ?? options.cssUserHandlerOptions.cssOptions?.cssCalc ?? options.cssUserHandlerOptions.cssCalc,
|
|
2688
|
+
customPropertyValues: options.generatorStyleOptions.customPropertyValues ?? options.cssUserHandlerOptions.customPropertyValues,
|
|
2689
|
+
contextCss: typeof options.generatedSource === "string" ? options.generatedSource : void 0
|
|
2690
|
+
});
|
|
2710
2691
|
const { css } = await options.styleHandler(userSource, {
|
|
2711
2692
|
...options.generatorStyleOptions,
|
|
2712
2693
|
...options.cssUserHandlerOptions
|
|
2713
2694
|
});
|
|
2714
|
-
const transformedCss = removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(css));
|
|
2715
|
-
const bareSelectorUserCss = collectBareSelectorUserCss(userSource);
|
|
2695
|
+
const transformedCss = removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(stripTailwindBanners(css)), options.generatedSource);
|
|
2696
|
+
const bareSelectorUserCss = collectBareSelectorUserCss(userSource, transformedCss);
|
|
2716
2697
|
const missingBareSelectorUserCss = bareSelectorUserCss.trim().length > 0 ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(transformedCss, bareSelectorUserCss) : "";
|
|
2717
2698
|
return missingBareSelectorUserCss.trim().length > 0 ? `${transformedCss}\n${missingBareSelectorUserCss}` : transformedCss;
|
|
2718
2699
|
}
|
|
@@ -2746,6 +2727,11 @@ function normalizeExtendLengthUnits(value) {
|
|
|
2746
2727
|
function normalizeTailwindcssRuntimeOptions(options) {
|
|
2747
2728
|
return options;
|
|
2748
2729
|
}
|
|
2730
|
+
/** 清除可选字段中的 undefined,再交给引擎候选校验与生成契约。 */
|
|
2731
|
+
function resolveRuntimeBareArbitraryValues(options) {
|
|
2732
|
+
const value = resolveTailwindcssOptions(options)?.v4?.bareArbitraryValues;
|
|
2733
|
+
return value && typeof value === "object" ? value.units === void 0 ? {} : { units: value.units } : value;
|
|
2734
|
+
}
|
|
2749
2735
|
//#endregion
|
|
2750
2736
|
//#region src/utils/object.ts
|
|
2751
2737
|
function definedEntries(value) {
|
|
@@ -3036,11 +3022,11 @@ function normalizeTailwindV4CssPackageImports(css, packageName) {
|
|
|
3036
3022
|
let changed = false;
|
|
3037
3023
|
root.walkAtRules((rule) => {
|
|
3038
3024
|
if (rule.name !== "import" && rule.name !== "reference") return;
|
|
3039
|
-
const parsed = parseCssImportSpecifier(rule.params);
|
|
3025
|
+
const parsed = (0, _weapp_tailwindcss_postcss.parseCssImportSpecifier)(rule.params);
|
|
3040
3026
|
if (!parsed || !importSpecifiers.has(parsed.specifier)) return;
|
|
3041
3027
|
const cssEntryPoint = resolvePackageCssEntryPoint(`${parsed.specifier}/index.css`);
|
|
3042
3028
|
if (!cssEntryPoint) return;
|
|
3043
|
-
rule.params = rule.params.replace(parsed.raw, quoteCssImportSpecifier(cssEntryPoint, parsed.quote));
|
|
3029
|
+
rule.params = rule.params.replace(parsed.raw, (0, _weapp_tailwindcss_postcss.quoteCssImportSpecifier)(cssEntryPoint, parsed.quote));
|
|
3044
3030
|
changed = true;
|
|
3045
3031
|
});
|
|
3046
3032
|
return changed ? root.toString() : css;
|
|
@@ -3094,7 +3080,7 @@ function normalizeTailwindV4CssEntrySources(cssEntries, packageName) {
|
|
|
3094
3080
|
}
|
|
3095
3081
|
const base = node_path.default.dirname(normalizedFile);
|
|
3096
3082
|
root.walkAtRules("import", (rule) => {
|
|
3097
|
-
const parsed = parseCssImportSpecifier(rule.params);
|
|
3083
|
+
const parsed = (0, _weapp_tailwindcss_postcss.parseCssImportSpecifier)(rule.params);
|
|
3098
3084
|
if (!parsed || !parsed.specifier.startsWith(".")) return;
|
|
3099
3085
|
const importedFile = resolveCssImportFile(base, parsed.specifier);
|
|
3100
3086
|
const resolved = (node_path.default.extname(importedFile) ? [importedFile] : [
|
|
@@ -3399,6 +3385,12 @@ Object.defineProperty(exports, "createCssAppend", {
|
|
|
3399
3385
|
return createCssAppend;
|
|
3400
3386
|
}
|
|
3401
3387
|
});
|
|
3388
|
+
Object.defineProperty(exports, "createGeneratedThemeDeclarationResolver", {
|
|
3389
|
+
enumerable: true,
|
|
3390
|
+
get: function() {
|
|
3391
|
+
return createGeneratedThemeDeclarationResolver;
|
|
3392
|
+
}
|
|
3393
|
+
});
|
|
3402
3394
|
Object.defineProperty(exports, "createTailwindV4Engine", {
|
|
3403
3395
|
enumerable: true,
|
|
3404
3396
|
get: function() {
|
|
@@ -3645,12 +3637,6 @@ Object.defineProperty(exports, "parseConfigParam", {
|
|
|
3645
3637
|
return parseConfigParam;
|
|
3646
3638
|
}
|
|
3647
3639
|
});
|
|
3648
|
-
Object.defineProperty(exports, "parseCssImportSpecifier", {
|
|
3649
|
-
enumerable: true,
|
|
3650
|
-
get: function() {
|
|
3651
|
-
return parseCssImportSpecifier;
|
|
3652
|
-
}
|
|
3653
|
-
});
|
|
3654
3640
|
Object.defineProperty(exports, "parseImportRequest", {
|
|
3655
3641
|
enumerable: true,
|
|
3656
3642
|
get: function() {
|
|
@@ -3669,12 +3655,6 @@ Object.defineProperty(exports, "prependConfigDirective", {
|
|
|
3669
3655
|
return prependConfigDirective;
|
|
3670
3656
|
}
|
|
3671
3657
|
});
|
|
3672
|
-
Object.defineProperty(exports, "quoteCssImportSpecifier", {
|
|
3673
|
-
enumerable: true,
|
|
3674
|
-
get: function() {
|
|
3675
|
-
return quoteCssImportSpecifier;
|
|
3676
|
-
}
|
|
3677
|
-
});
|
|
3678
3658
|
Object.defineProperty(exports, "removeMiniProgramInteractiveSelectors", {
|
|
3679
3659
|
enumerable: true,
|
|
3680
3660
|
get: function() {
|
|
@@ -3735,6 +3715,12 @@ Object.defineProperty(exports, "resolveGeneratorRuntimeBranch", {
|
|
|
3735
3715
|
return resolveGeneratorRuntimeBranch;
|
|
3736
3716
|
}
|
|
3737
3717
|
});
|
|
3718
|
+
Object.defineProperty(exports, "resolveRuntimeBareArbitraryValues", {
|
|
3719
|
+
enumerable: true,
|
|
3720
|
+
get: function() {
|
|
3721
|
+
return resolveRuntimeBareArbitraryValues;
|
|
3722
|
+
}
|
|
3723
|
+
});
|
|
3738
3724
|
Object.defineProperty(exports, "resolveRuntimeBranch", {
|
|
3739
3725
|
enumerable: true,
|
|
3740
3726
|
get: function() {
|