weapp-tailwindcss 5.1.6 → 5.1.7
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/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +10 -0
- package/dist/{context-3GGqW9vw.mjs → context-BqeDu1Ha.mjs} +5 -4
- package/dist/{context-BCSk_YnL.js → context-C7KTDlrG.js} +5 -4
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{generator-CoT5vu9w.mjs → generator-BOt2Tvx3.mjs} +1 -1
- package/dist/{generator-CqWzj2Z1.js → generator-DASZwC6t.js} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/{gulp-hXE1U4Cu.js → gulp-D6hsaTLM.js} +4 -4
- package/dist/{gulp-Bss4wJ8t.mjs → gulp-alDZryyB.mjs} +4 -4
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-Df4203aI.js → hmr-timing-BIr_CiPW.js} +12 -6
- package/dist/{hmr-timing-Cfu-4Bnf.mjs → hmr-timing-CYwVMRol.mjs} +12 -6
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/postcss.js +2 -2
- package/dist/postcss.mjs +2 -2
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/rspack.js +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/{source-candidate-scan-signature-BbCmW975.mjs → source-candidate-scan-signature-D97ZEXcj.mjs} +3 -3
- package/dist/{source-candidate-scan-signature-5Uk6U72B.js → source-candidate-scan-signature-Djr2Hw8y.js} +3 -3
- package/dist/{tailwindcss-Bjr3aphG.mjs → tailwindcss-DDGD90w7.mjs} +1 -1
- package/dist/{tailwindcss-DYJ3HZD2.js → tailwindcss-DPxJpRVP.js} +1 -1
- package/dist/{transform-B6_y_yCB.js → transform-CvqqZBuq.js} +1 -1
- package/dist/{transform--155BmeJ.mjs → transform-DPPr79r2.mjs} +1 -1
- package/dist/uni-app-x/web-preflight-reset.d.ts +3 -0
- package/dist/{v4-engine-C9cmNlP8.js → v4-engine-3UmJkAY7.js} +32 -1
- package/dist/{v4-engine-DRQaCFMm.mjs → v4-engine-CYSrDVNp.mjs} +33 -2
- package/dist/{vite-Baw9qNrc.js → vite-BJRlG835.js} +91 -17
- package/dist/{vite-PdxjaqhO.mjs → vite-XxJh7Xtu.mjs} +91 -17
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +141 -6
- package/dist/{webpack-C9u7mfGE.js → webpack-BxBOMUtY.js} +274 -34
- package/dist/{webpack-BffTDmod.mjs → webpack-eN8WzIT-.mjs} +274 -34
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.js");
|
|
2
2
|
const require_framework = require("./framework.js");
|
|
3
|
-
const require_v4_engine = require("./v4-engine-
|
|
4
|
-
const require_generator = require("./generator-
|
|
3
|
+
const require_v4_engine = require("./v4-engine-3UmJkAY7.js");
|
|
4
|
+
const require_generator = require("./generator-DASZwC6t.js");
|
|
5
5
|
const require_utils = require("./utils-D3h8j7Mk.js");
|
|
6
|
-
const require_context = require("./context-
|
|
7
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
8
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
9
|
-
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-
|
|
6
|
+
const require_context = require("./context-C7KTDlrG.js");
|
|
7
|
+
const require_tailwindcss = require("./tailwindcss-DPxJpRVP.js");
|
|
8
|
+
const require_hmr_timing = require("./hmr-timing-BIr_CiPW.js");
|
|
9
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-Djr2Hw8y.js");
|
|
10
10
|
require("./logger-TlKT3xmR.js");
|
|
11
11
|
let node_fs = require("node:fs");
|
|
12
12
|
node_fs = require_rolldown_runtime.__toESM(node_fs);
|
|
@@ -515,7 +515,7 @@ function resolveUniAppXStyleIsolationEnabled(root) {
|
|
|
515
515
|
//#region src/uni-app-x/vite.ts
|
|
516
516
|
let transformUVuePromise;
|
|
517
517
|
function loadTransformUVue() {
|
|
518
|
-
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-
|
|
518
|
+
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-CvqqZBuq.js")).then((mod) => mod.transformUVue));
|
|
519
519
|
return transformUVuePromise;
|
|
520
520
|
}
|
|
521
521
|
const preprocessorLangs = /* @__PURE__ */ new Set([
|
|
@@ -749,6 +749,68 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
|
|
|
749
749
|
});
|
|
750
750
|
};
|
|
751
751
|
}
|
|
752
|
+
const UNI_APP_X_WEB_PREFLIGHT_RESET_CSS = [`/* weapp-tailwindcss uni-app-x web preflight reset */`, `${[
|
|
753
|
+
"uni-ad-draw",
|
|
754
|
+
"uni-ad-fullscreen-video",
|
|
755
|
+
"uni-ad-interactive",
|
|
756
|
+
"uni-ad-interstitial",
|
|
757
|
+
"uni-ad-rewarded-video",
|
|
758
|
+
"uni-ad",
|
|
759
|
+
"uni-animation-view",
|
|
760
|
+
"uni-audio",
|
|
761
|
+
"uni-block",
|
|
762
|
+
"uni-button",
|
|
763
|
+
"uni-camera",
|
|
764
|
+
"uni-canvas",
|
|
765
|
+
"uni-checkbox-group",
|
|
766
|
+
"uni-checkbox",
|
|
767
|
+
"uni-cover-image",
|
|
768
|
+
"uni-cover-view",
|
|
769
|
+
"uni-custom-tab-bar",
|
|
770
|
+
"uni-editor",
|
|
771
|
+
"uni-form",
|
|
772
|
+
"uni-icon",
|
|
773
|
+
"uni-image",
|
|
774
|
+
"uni-input",
|
|
775
|
+
"uni-label",
|
|
776
|
+
"uni-list-item",
|
|
777
|
+
"uni-list-view",
|
|
778
|
+
"uni-live-player",
|
|
779
|
+
"uni-live-pusher",
|
|
780
|
+
"uni-map",
|
|
781
|
+
"uni-match-media",
|
|
782
|
+
"uni-movable-area",
|
|
783
|
+
"uni-movable-view",
|
|
784
|
+
"uni-navigation-bar",
|
|
785
|
+
"uni-navigator",
|
|
786
|
+
"uni-open-data",
|
|
787
|
+
"uni-page-meta",
|
|
788
|
+
"uni-picker-view",
|
|
789
|
+
"uni-picker",
|
|
790
|
+
"uni-progress",
|
|
791
|
+
"uni-radio-group",
|
|
792
|
+
"uni-radio",
|
|
793
|
+
"uni-rich-text",
|
|
794
|
+
"uni-scroll-view",
|
|
795
|
+
"uni-slider",
|
|
796
|
+
"uni-sticky-header",
|
|
797
|
+
"uni-sticky-section",
|
|
798
|
+
"uni-swiper-item",
|
|
799
|
+
"uni-swiper",
|
|
800
|
+
"uni-switch",
|
|
801
|
+
"uni-template",
|
|
802
|
+
"uni-text",
|
|
803
|
+
"uni-textarea",
|
|
804
|
+
"uni-unicloud-db",
|
|
805
|
+
"uni-video",
|
|
806
|
+
"uni-view",
|
|
807
|
+
"uni-web-view"
|
|
808
|
+
].map((tag) => `uni-app ${tag}`).join(", ")}{border-width:0;}`].join("\n");
|
|
809
|
+
const TAILWIND_PREFLIGHT_BORDER_RE = /\bborder\s*:\s*0(?:px)?\s+solid\b/;
|
|
810
|
+
function withUniAppXWebPreflightReset(css, enabled) {
|
|
811
|
+
if (!enabled || css.includes("weapp-tailwindcss uni-app-x web preflight reset") || !TAILWIND_PREFLIGHT_BORDER_RE.test(css)) return css;
|
|
812
|
+
return css.length > 0 ? `${UNI_APP_X_WEB_PREFLIGHT_RESET_CSS}\n${css}` : UNI_APP_X_WEB_PREFLIGHT_RESET_CSS;
|
|
813
|
+
}
|
|
752
814
|
//#endregion
|
|
753
815
|
//#region src/bundlers/vite/generate-bundle/configured-css-sources.ts
|
|
754
816
|
function collectConfiguredTailwindV4CssSources(opts) {
|
|
@@ -4281,7 +4343,7 @@ function createGenerateBundleHook(context) {
|
|
|
4281
4343
|
const shouldApplyWebviewCssCompat = isWebGeneratorTarget || shouldApplyWebviewSafeSelectors;
|
|
4282
4344
|
const transformWebTargetCss = (css) => {
|
|
4283
4345
|
const compatCss = isWebGeneratorTarget ? (0, _weapp_tailwindcss_postcss.transformWebCssCompat)(css, generatorOptions.webCompat) : shouldApplyWebviewCssCompat ? (0, _weapp_tailwindcss_postcss.transformWebCssCompat)(css, generatorOptions.webCompat ?? true) : css;
|
|
4284
|
-
return shouldApplyWebviewSafeSelectors ? (0, _weapp_tailwindcss_postcss.transformWebCssSafeSelectors)(compatCss, { escapeMap: opts.escapeMap }) : compatCss;
|
|
4346
|
+
return withUniAppXWebPreflightReset(shouldApplyWebviewSafeSelectors ? (0, _weapp_tailwindcss_postcss.transformWebCssSafeSelectors)(compatCss, { escapeMap: opts.escapeMap }) : compatCss, opts.appType === "uni-app-x" && isWebGeneratorTarget);
|
|
4285
4347
|
};
|
|
4286
4348
|
const isUniAppXStyleTarget = opts.appType === "uni-app-x";
|
|
4287
4349
|
const isNativeAppStyleTarget = isUniAppXStyleTarget && uniUtsPlatform.isApp;
|
|
@@ -5173,7 +5235,7 @@ function isUniAppViteWebviewOutDir(outDir) {
|
|
|
5173
5235
|
}
|
|
5174
5236
|
function finalizeWebCss(css, enabled, webCompat, options = {}) {
|
|
5175
5237
|
const compatCss = enabled ? (0, _weapp_tailwindcss_postcss.transformWebCssCompat)(css, webCompat) : css;
|
|
5176
|
-
return options.safeSelectors ? (0, _weapp_tailwindcss_postcss.transformWebCssSafeSelectors)(compatCss, { escapeMap: options.escapeMap }) : compatCss;
|
|
5238
|
+
return withUniAppXWebPreflightReset(options.safeSelectors ? (0, _weapp_tailwindcss_postcss.transformWebCssSafeSelectors)(compatCss, { escapeMap: options.escapeMap }) : compatCss, options.uniAppXWebPreflightReset === true);
|
|
5177
5239
|
}
|
|
5178
5240
|
function createViteCssFinalizerOutputPlugin(context) {
|
|
5179
5241
|
return {
|
|
@@ -5224,7 +5286,8 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
5224
5286
|
resolveViteProcessedCssOutputFile: (file) => resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, isNativeAppStyleTarget, sourceRoot, resolveMiniProgramStyleOutputExtension({ files: Object.keys(bundle) }), Object.keys(bundle)),
|
|
5225
5287
|
transformCss: (css) => finalizeWebCss(css, generatorBranch.isWeb, generatorOptions.webCompat, {
|
|
5226
5288
|
escapeMap: opts.escapeMap,
|
|
5227
|
-
safeSelectors: shouldApplyWebviewSafeSelectors
|
|
5289
|
+
safeSelectors: shouldApplyWebviewSafeSelectors,
|
|
5290
|
+
uniAppXWebPreflightReset: opts.appType === "uni-app-x" && generatorBranch.isWeb
|
|
5228
5291
|
}),
|
|
5229
5292
|
debug
|
|
5230
5293
|
});
|
|
@@ -5237,7 +5300,8 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
5237
5300
|
recordCssAssetResult,
|
|
5238
5301
|
transformCss: (css) => finalizeWebCss(css, generatorBranch.isWeb, generatorOptions.webCompat, {
|
|
5239
5302
|
escapeMap: opts.escapeMap,
|
|
5240
|
-
safeSelectors: shouldApplyWebviewSafeSelectors
|
|
5303
|
+
safeSelectors: shouldApplyWebviewSafeSelectors,
|
|
5304
|
+
uniAppXWebPreflightReset: opts.appType === "uni-app-x" && generatorBranch.isWeb
|
|
5241
5305
|
}),
|
|
5242
5306
|
debug,
|
|
5243
5307
|
onUpdate: opts.onUpdate
|
|
@@ -5305,7 +5369,8 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
5305
5369
|
if (isViteProcessedCssAsset?.(output, file)) {
|
|
5306
5370
|
const nextCss = annotateCss(finalizeWebCss(require_source_candidate_scan_signature.stripBundlerGeneratedCssMarkers(rawSource), generatorBranch.isWeb, generatorOptions.webCompat, {
|
|
5307
5371
|
escapeMap: opts.escapeMap,
|
|
5308
|
-
safeSelectors: shouldApplyWebviewSafeSelectors
|
|
5372
|
+
safeSelectors: shouldApplyWebviewSafeSelectors,
|
|
5373
|
+
uniAppXWebPreflightReset: opts.appType === "uni-app-x" && generatorBranch.isWeb
|
|
5309
5374
|
}));
|
|
5310
5375
|
output.source = nextCss;
|
|
5311
5376
|
markCssAssetProcessed(output, file);
|
|
@@ -5343,7 +5408,8 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
5343
5408
|
}) : void 0;
|
|
5344
5409
|
const nextCss = annotateCss(generated?.css ?? (generatorBranch.isWeb ? finalizeWebCss(rawSource, true, generatorOptions.webCompat, {
|
|
5345
5410
|
escapeMap: opts.escapeMap,
|
|
5346
|
-
safeSelectors: shouldApplyWebviewSafeSelectors
|
|
5411
|
+
safeSelectors: shouldApplyWebviewSafeSelectors,
|
|
5412
|
+
uniAppXWebPreflightReset: opts.appType === "uni-app-x" && generatorBranch.isWeb
|
|
5347
5413
|
}) : (await opts.styleHandler(rawSource, cssHandlerOptions)).css));
|
|
5348
5414
|
if (generated) {
|
|
5349
5415
|
registerGeneratorDependencies(this, generated.dependencies);
|
|
@@ -6043,6 +6109,12 @@ function isViteServeCssRootRequest(id, command) {
|
|
|
6043
6109
|
function isViteCssHmrModule(code, id, command) {
|
|
6044
6110
|
return isViteServeStyleRequest(id, command) && VITE_CSS_HMR_MODULE_RE.test(code) && /[?&](?:direct|vue)(?:&|$)/.test(id);
|
|
6045
6111
|
}
|
|
6112
|
+
function hasViteServeCssGenerationDirective(code) {
|
|
6113
|
+
return require_v4_engine.hasTailwindRootDirectives(code) || require_v4_engine.hasTailwindSourceDirectives(code, { importFallback: true }) || require_v4_engine.hasTailwindApplyDirective(code);
|
|
6114
|
+
}
|
|
6115
|
+
function hasViteServeCssRootDirective(code) {
|
|
6116
|
+
return require_v4_engine.hasTailwindRootDirectives(code);
|
|
6117
|
+
}
|
|
6046
6118
|
function createViteServeCssGenerationPlugins(options) {
|
|
6047
6119
|
return [{
|
|
6048
6120
|
name: `${require_context.vitePluginName}:generate:serve`,
|
|
@@ -6067,7 +6139,8 @@ function createViteServeCssGenerationPlugins(options) {
|
|
|
6067
6139
|
if (!options.shouldGenerate() || !isViteCssHmrModule(code, id, options.getCommand())) return;
|
|
6068
6140
|
const extracted = extractViteCssHmrModuleCss(code);
|
|
6069
6141
|
if (!extracted) return;
|
|
6070
|
-
|
|
6142
|
+
if (!hasViteServeCssGenerationDirective(extracted.css)) return;
|
|
6143
|
+
if (hasViteServeCssRootDirective(extracted.css)) await options.onTailwindRootCss?.(id, extracted.css);
|
|
6071
6144
|
const generatedCss = await options.generateCss(id, extracted.css, this);
|
|
6072
6145
|
if (generatedCss === void 0 || generatedCss === extracted.css) return;
|
|
6073
6146
|
const nextCode = replaceViteCssHmrModuleCss(code, generatedCss);
|
|
@@ -6203,6 +6276,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
6203
6276
|
const initialTailwindRuntime = tailwindRuntime;
|
|
6204
6277
|
const refreshTailwindRuntime = refreshTailwindcssRuntime;
|
|
6205
6278
|
const uniAppXEnabled = require_tailwindcss.isUniAppXEnabled(uniAppX);
|
|
6279
|
+
const shouldEnableUniAppXPlugins = opts.appType === "uni-app-x" || uniAppXEnabled;
|
|
6206
6280
|
const disabledOptions = require_source_candidate_scan_signature.resolvePluginDisabledState(disabled);
|
|
6207
6281
|
const tailwindcssMajorVersion = initialTailwindRuntime.majorVersion ?? 0;
|
|
6208
6282
|
if (!disabledOptions.plugin && tailwindcssMajorVersion !== 4) throw new Error("weapp-tailwindcss/vite 新生成管线仅支持 Tailwind CSS v4,请升级 tailwindcss 或停留在旧版 weapp-tailwindcss。");
|
|
@@ -6643,11 +6717,11 @@ function WeappTailwindcss(options = {}) {
|
|
|
6643
6717
|
if (!generated) return;
|
|
6644
6718
|
const finalizedCss = finalizeViteMiniProgramCss(generated.css);
|
|
6645
6719
|
const isUniAppViteWebviewPlatform = opts.appType === "uni-app-vite" && isUniAppViteWebviewStylePlatform(resolveViteStylePlatform());
|
|
6646
|
-
const tracedCss = require_hmr_timing.annotateCssSourceTrace(removeScopedTailwindPreflightCss(currentGeneratorBranch.isWeb || isUniAppViteWebviewPlatform ? applyUniAppViteWebviewCssCompat(finalizedCss, {
|
|
6720
|
+
const tracedCss = require_hmr_timing.annotateCssSourceTrace(withUniAppXWebPreflightReset(removeScopedTailwindPreflightCss(currentGeneratorBranch.isWeb || isUniAppViteWebviewPlatform ? applyUniAppViteWebviewCssCompat(finalizedCss, {
|
|
6647
6721
|
compat: currentGeneratorOptions.webCompat ?? true,
|
|
6648
6722
|
escapeMap: opts.escapeMap,
|
|
6649
6723
|
safeSelectors: isUniAppViteWebviewPlatform
|
|
6650
|
-
}) : finalizedCss), {
|
|
6724
|
+
}) : finalizedCss), opts.appType === "uni-app-x" && currentGeneratorBranch.isWeb), {
|
|
6651
6725
|
opts,
|
|
6652
6726
|
tokenSources: require_hmr_timing.createCssTokenSourceMap(getSourceCandidateSourcesForEntries(void 0), opts)
|
|
6653
6727
|
});
|
|
@@ -6752,7 +6826,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
6752
6826
|
if (shouldDiscoverAutoCssSources()) await discoverAndRegisterAutoCssSources();
|
|
6753
6827
|
await syncSourceCandidateScan();
|
|
6754
6828
|
};
|
|
6755
|
-
const uniAppXPlugins =
|
|
6829
|
+
const uniAppXPlugins = shouldEnableUniAppXPlugins ? createUniAppXPlugins({
|
|
6756
6830
|
appType: opts.appType ?? "uni-app-x",
|
|
6757
6831
|
customAttributesEntities,
|
|
6758
6832
|
disabledDefaultTemplateHandler,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { resolveImplicitAppTypeFromViteRoot } from "./framework.mjs";
|
|
2
|
-
import { $ as hasTailwindGeneratedCssMarkers, B as hasTailwindNonRootGenerationDirectives, Et as omitUndefined, G as normalizeTailwindSourceForGenerator, H as hasTailwindSourceDirectives, K as parseImportRequest, L as stripMiniProgramCssSpecificityPlaceholders, P as hasMiniProgramCssSpecificityPlaceholders, R as hasLocalCssImport, Tt as filterUnsupportedMiniProgramTailwindV4Candidates, U as normalizeTailwindConfigDirectives, V as hasTailwindRootDirectives, _ as resolveTailwindcssOptions, a as filterTailwindV4CssSourceRoots, d as normalizeCssEntries, f as findNearestPackageRoot, lt as getTailwindV4IncrementalGenerateCacheStats, o as hasConfiguredTailwindV4CssRoots, q as removeTailwindSourceDirectives, s as upsertTailwindV4CssSource, u as isTailwindV4CssEntry, w as normalizeEmptyTailwindCustomVariants, xt as resolveTailwindV4CssSourceBase, z as hasTailwindApplyDirective } from "./v4-engine-
|
|
3
|
-
import { a as resolveGeneratorRuntimeBranch, c as shouldUseNativeAppCssBranch, i as normalizeWeappTailwindcssGeneratorOptions, s as shouldUseMiniProgramCssBranch } from "./generator-
|
|
2
|
+
import { $ as hasTailwindGeneratedCssMarkers, B as hasTailwindNonRootGenerationDirectives, Et as omitUndefined, G as normalizeTailwindSourceForGenerator, H as hasTailwindSourceDirectives, K as parseImportRequest, L as stripMiniProgramCssSpecificityPlaceholders, P as hasMiniProgramCssSpecificityPlaceholders, R as hasLocalCssImport, Tt as filterUnsupportedMiniProgramTailwindV4Candidates, U as normalizeTailwindConfigDirectives, V as hasTailwindRootDirectives, _ as resolveTailwindcssOptions, a as filterTailwindV4CssSourceRoots, d as normalizeCssEntries, f as findNearestPackageRoot, lt as getTailwindV4IncrementalGenerateCacheStats, o as hasConfiguredTailwindV4CssRoots, q as removeTailwindSourceDirectives, s as upsertTailwindV4CssSource, u as isTailwindV4CssEntry, w as normalizeEmptyTailwindCustomVariants, xt as resolveTailwindV4CssSourceBase, z as hasTailwindApplyDirective } from "./v4-engine-CYSrDVNp.mjs";
|
|
3
|
+
import { a as resolveGeneratorRuntimeBranch, c as shouldUseNativeAppCssBranch, i as normalizeWeappTailwindcssGeneratorOptions, s as shouldUseMiniProgramCssBranch } from "./generator-BOt2Tvx3.mjs";
|
|
4
4
|
import { o as resolveUniUtsPlatform } from "./utils-DodxWHGz.mjs";
|
|
5
|
-
import { C as normalizeFrameworkStylePlatform, S as createDebug, _ as toCustomAttributesEntities, a as vitePluginName, l as shouldSkipJsTransform, m as replaceWxml, n as normalizeStyleHandlerMajorVersion, t as getCompilerContext, v as collectRuntimeClassSet, x as refreshTailwindRuntimeState, y as createTailwindRuntimeReadyPromise } from "./context-
|
|
6
|
-
import { _ as resolveViteTailwindV4CssDependencies, a as findTailwindConfig, f as createViteSourceScanMatcher, g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as resolveViteSourceScanEntries, r as isUniAppXEnabled } from "./tailwindcss-
|
|
7
|
-
import { E as createCssTokenSourceMap, O as processCachedTask, T as createCssSourceTraceCacheSignature, _ as isPureLocalCssImportWrapper, a as isSourceCandidateRequest, b as scoreTailwindV4CssSourceFileMatch, d as validateCandidatesByGenerator, g as mergeMarkedUserLayerComponentsCss, h as extractMarkedUserLayerComponentsCss, m as runWithConcurrency, r as createSourceCandidateCollector, s as createBundleRuntimeClassSetManager, t as createHmrTimingRecorder, w as annotateCssSourceTrace } from "./hmr-timing-
|
|
8
|
-
import { A as isSourceStyleRequest, C as resolvePluginDisabledState, D as isHTMLRequest, E as isCSSRequest, F as createBuiltinViteStyleInjectorPlugins, M as normalizeOutputPathKey, O as normalizePath, P as toAbsoluteOutputPath, S as resolvePackageDir, T as formatPostcssSourceMap, _ as generateTailwindV4Css, a as createJsHashSalt, b as parseBundlerGeneratedCssMarkerBlocks, c as hasRuntimeAffectingSourceChanges, f as createBundleBuildState, g as createBundleModuleGraphOptions, h as applyLinkedResults, i as createCandidateSignature, j as stripRequestQuery, k as slash, l as summarizeStringDiff, m as createRuntimeAffectingSourceSignature, n as createScopedGeneratorCandidateSignature, o as createLinkedImpactSignature, p as updateBundleBuildState, r as createScopedGeneratorRuntime, s as getSnapshotHash, t as createSourceCandidateScanSignature, u as buildBundleSnapshot, v as createBundlerGeneratedCssMarker, w as cleanUrl, x as stripBundlerGeneratedCssMarkers, y as hasBundlerGeneratedCssMarker } from "./source-candidate-scan-signature-
|
|
5
|
+
import { C as normalizeFrameworkStylePlatform, S as createDebug, _ as toCustomAttributesEntities, a as vitePluginName, l as shouldSkipJsTransform, m as replaceWxml, n as normalizeStyleHandlerMajorVersion, t as getCompilerContext, v as collectRuntimeClassSet, x as refreshTailwindRuntimeState, y as createTailwindRuntimeReadyPromise } from "./context-BqeDu1Ha.mjs";
|
|
6
|
+
import { _ as resolveViteTailwindV4CssDependencies, a as findTailwindConfig, f as createViteSourceScanMatcher, g as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions, l as getRuntimeClassSetSignature, m as discoverTailwindV4CssEntries, p as resolveViteSourceScanEntries, r as isUniAppXEnabled } from "./tailwindcss-DDGD90w7.mjs";
|
|
7
|
+
import { E as createCssTokenSourceMap, O as processCachedTask, T as createCssSourceTraceCacheSignature, _ as isPureLocalCssImportWrapper, a as isSourceCandidateRequest, b as scoreTailwindV4CssSourceFileMatch, d as validateCandidatesByGenerator, g as mergeMarkedUserLayerComponentsCss, h as extractMarkedUserLayerComponentsCss, m as runWithConcurrency, r as createSourceCandidateCollector, s as createBundleRuntimeClassSetManager, t as createHmrTimingRecorder, w as annotateCssSourceTrace } from "./hmr-timing-CYwVMRol.mjs";
|
|
8
|
+
import { A as isSourceStyleRequest, C as resolvePluginDisabledState, D as isHTMLRequest, E as isCSSRequest, F as createBuiltinViteStyleInjectorPlugins, M as normalizeOutputPathKey, O as normalizePath, P as toAbsoluteOutputPath, S as resolvePackageDir, T as formatPostcssSourceMap, _ as generateTailwindV4Css, a as createJsHashSalt, b as parseBundlerGeneratedCssMarkerBlocks, c as hasRuntimeAffectingSourceChanges, f as createBundleBuildState, g as createBundleModuleGraphOptions, h as applyLinkedResults, i as createCandidateSignature, j as stripRequestQuery, k as slash, l as summarizeStringDiff, m as createRuntimeAffectingSourceSignature, n as createScopedGeneratorCandidateSignature, o as createLinkedImpactSignature, p as updateBundleBuildState, r as createScopedGeneratorRuntime, s as getSnapshotHash, t as createSourceCandidateScanSignature, u as buildBundleSnapshot, v as createBundlerGeneratedCssMarker, w as cleanUrl, x as stripBundlerGeneratedCssMarkers, y as hasBundlerGeneratedCssMarker } from "./source-candidate-scan-signature-D97ZEXcj.mjs";
|
|
9
9
|
import { t as logger$1 } from "./logger-BNzxZbZj.mjs";
|
|
10
10
|
import fs, { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
11
11
|
import path from "node:path";
|
|
@@ -509,7 +509,7 @@ function resolveUniAppXStyleIsolationEnabled(root) {
|
|
|
509
509
|
//#region src/uni-app-x/vite.ts
|
|
510
510
|
let transformUVuePromise;
|
|
511
511
|
function loadTransformUVue() {
|
|
512
|
-
transformUVuePromise ?? (transformUVuePromise = import("./transform
|
|
512
|
+
transformUVuePromise ?? (transformUVuePromise = import("./transform-DPPr79r2.mjs").then((mod) => mod.transformUVue));
|
|
513
513
|
return transformUVuePromise;
|
|
514
514
|
}
|
|
515
515
|
const preprocessorLangs = /* @__PURE__ */ new Set([
|
|
@@ -743,6 +743,68 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
|
|
|
743
743
|
});
|
|
744
744
|
};
|
|
745
745
|
}
|
|
746
|
+
const UNI_APP_X_WEB_PREFLIGHT_RESET_CSS = [`/* weapp-tailwindcss uni-app-x web preflight reset */`, `${[
|
|
747
|
+
"uni-ad-draw",
|
|
748
|
+
"uni-ad-fullscreen-video",
|
|
749
|
+
"uni-ad-interactive",
|
|
750
|
+
"uni-ad-interstitial",
|
|
751
|
+
"uni-ad-rewarded-video",
|
|
752
|
+
"uni-ad",
|
|
753
|
+
"uni-animation-view",
|
|
754
|
+
"uni-audio",
|
|
755
|
+
"uni-block",
|
|
756
|
+
"uni-button",
|
|
757
|
+
"uni-camera",
|
|
758
|
+
"uni-canvas",
|
|
759
|
+
"uni-checkbox-group",
|
|
760
|
+
"uni-checkbox",
|
|
761
|
+
"uni-cover-image",
|
|
762
|
+
"uni-cover-view",
|
|
763
|
+
"uni-custom-tab-bar",
|
|
764
|
+
"uni-editor",
|
|
765
|
+
"uni-form",
|
|
766
|
+
"uni-icon",
|
|
767
|
+
"uni-image",
|
|
768
|
+
"uni-input",
|
|
769
|
+
"uni-label",
|
|
770
|
+
"uni-list-item",
|
|
771
|
+
"uni-list-view",
|
|
772
|
+
"uni-live-player",
|
|
773
|
+
"uni-live-pusher",
|
|
774
|
+
"uni-map",
|
|
775
|
+
"uni-match-media",
|
|
776
|
+
"uni-movable-area",
|
|
777
|
+
"uni-movable-view",
|
|
778
|
+
"uni-navigation-bar",
|
|
779
|
+
"uni-navigator",
|
|
780
|
+
"uni-open-data",
|
|
781
|
+
"uni-page-meta",
|
|
782
|
+
"uni-picker-view",
|
|
783
|
+
"uni-picker",
|
|
784
|
+
"uni-progress",
|
|
785
|
+
"uni-radio-group",
|
|
786
|
+
"uni-radio",
|
|
787
|
+
"uni-rich-text",
|
|
788
|
+
"uni-scroll-view",
|
|
789
|
+
"uni-slider",
|
|
790
|
+
"uni-sticky-header",
|
|
791
|
+
"uni-sticky-section",
|
|
792
|
+
"uni-swiper-item",
|
|
793
|
+
"uni-swiper",
|
|
794
|
+
"uni-switch",
|
|
795
|
+
"uni-template",
|
|
796
|
+
"uni-text",
|
|
797
|
+
"uni-textarea",
|
|
798
|
+
"uni-unicloud-db",
|
|
799
|
+
"uni-video",
|
|
800
|
+
"uni-view",
|
|
801
|
+
"uni-web-view"
|
|
802
|
+
].map((tag) => `uni-app ${tag}`).join(", ")}{border-width:0;}`].join("\n");
|
|
803
|
+
const TAILWIND_PREFLIGHT_BORDER_RE = /\bborder\s*:\s*0(?:px)?\s+solid\b/;
|
|
804
|
+
function withUniAppXWebPreflightReset(css, enabled) {
|
|
805
|
+
if (!enabled || css.includes("weapp-tailwindcss uni-app-x web preflight reset") || !TAILWIND_PREFLIGHT_BORDER_RE.test(css)) return css;
|
|
806
|
+
return css.length > 0 ? `${UNI_APP_X_WEB_PREFLIGHT_RESET_CSS}\n${css}` : UNI_APP_X_WEB_PREFLIGHT_RESET_CSS;
|
|
807
|
+
}
|
|
746
808
|
//#endregion
|
|
747
809
|
//#region src/bundlers/vite/generate-bundle/configured-css-sources.ts
|
|
748
810
|
function collectConfiguredTailwindV4CssSources(opts) {
|
|
@@ -4275,7 +4337,7 @@ function createGenerateBundleHook(context) {
|
|
|
4275
4337
|
const shouldApplyWebviewCssCompat = isWebGeneratorTarget || shouldApplyWebviewSafeSelectors;
|
|
4276
4338
|
const transformWebTargetCss = (css) => {
|
|
4277
4339
|
const compatCss = isWebGeneratorTarget ? transformWebCssCompat(css, generatorOptions.webCompat) : shouldApplyWebviewCssCompat ? transformWebCssCompat(css, generatorOptions.webCompat ?? true) : css;
|
|
4278
|
-
return shouldApplyWebviewSafeSelectors ? transformWebCssSafeSelectors(compatCss, { escapeMap: opts.escapeMap }) : compatCss;
|
|
4340
|
+
return withUniAppXWebPreflightReset(shouldApplyWebviewSafeSelectors ? transformWebCssSafeSelectors(compatCss, { escapeMap: opts.escapeMap }) : compatCss, opts.appType === "uni-app-x" && isWebGeneratorTarget);
|
|
4279
4341
|
};
|
|
4280
4342
|
const isUniAppXStyleTarget = opts.appType === "uni-app-x";
|
|
4281
4343
|
const isNativeAppStyleTarget = isUniAppXStyleTarget && uniUtsPlatform.isApp;
|
|
@@ -5167,7 +5229,7 @@ function isUniAppViteWebviewOutDir(outDir) {
|
|
|
5167
5229
|
}
|
|
5168
5230
|
function finalizeWebCss(css, enabled, webCompat, options = {}) {
|
|
5169
5231
|
const compatCss = enabled ? transformWebCssCompat(css, webCompat) : css;
|
|
5170
|
-
return options.safeSelectors ? transformWebCssSafeSelectors(compatCss, { escapeMap: options.escapeMap }) : compatCss;
|
|
5232
|
+
return withUniAppXWebPreflightReset(options.safeSelectors ? transformWebCssSafeSelectors(compatCss, { escapeMap: options.escapeMap }) : compatCss, options.uniAppXWebPreflightReset === true);
|
|
5171
5233
|
}
|
|
5172
5234
|
function createViteCssFinalizerOutputPlugin(context) {
|
|
5173
5235
|
return {
|
|
@@ -5218,7 +5280,8 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
5218
5280
|
resolveViteProcessedCssOutputFile: (file) => resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, isNativeAppStyleTarget, sourceRoot, resolveMiniProgramStyleOutputExtension({ files: Object.keys(bundle) }), Object.keys(bundle)),
|
|
5219
5281
|
transformCss: (css) => finalizeWebCss(css, generatorBranch.isWeb, generatorOptions.webCompat, {
|
|
5220
5282
|
escapeMap: opts.escapeMap,
|
|
5221
|
-
safeSelectors: shouldApplyWebviewSafeSelectors
|
|
5283
|
+
safeSelectors: shouldApplyWebviewSafeSelectors,
|
|
5284
|
+
uniAppXWebPreflightReset: opts.appType === "uni-app-x" && generatorBranch.isWeb
|
|
5222
5285
|
}),
|
|
5223
5286
|
debug
|
|
5224
5287
|
});
|
|
@@ -5231,7 +5294,8 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
5231
5294
|
recordCssAssetResult,
|
|
5232
5295
|
transformCss: (css) => finalizeWebCss(css, generatorBranch.isWeb, generatorOptions.webCompat, {
|
|
5233
5296
|
escapeMap: opts.escapeMap,
|
|
5234
|
-
safeSelectors: shouldApplyWebviewSafeSelectors
|
|
5297
|
+
safeSelectors: shouldApplyWebviewSafeSelectors,
|
|
5298
|
+
uniAppXWebPreflightReset: opts.appType === "uni-app-x" && generatorBranch.isWeb
|
|
5235
5299
|
}),
|
|
5236
5300
|
debug,
|
|
5237
5301
|
onUpdate: opts.onUpdate
|
|
@@ -5299,7 +5363,8 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
5299
5363
|
if (isViteProcessedCssAsset?.(output, file)) {
|
|
5300
5364
|
const nextCss = annotateCss(finalizeWebCss(stripBundlerGeneratedCssMarkers(rawSource), generatorBranch.isWeb, generatorOptions.webCompat, {
|
|
5301
5365
|
escapeMap: opts.escapeMap,
|
|
5302
|
-
safeSelectors: shouldApplyWebviewSafeSelectors
|
|
5366
|
+
safeSelectors: shouldApplyWebviewSafeSelectors,
|
|
5367
|
+
uniAppXWebPreflightReset: opts.appType === "uni-app-x" && generatorBranch.isWeb
|
|
5303
5368
|
}));
|
|
5304
5369
|
output.source = nextCss;
|
|
5305
5370
|
markCssAssetProcessed(output, file);
|
|
@@ -5337,7 +5402,8 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
5337
5402
|
}) : void 0;
|
|
5338
5403
|
const nextCss = annotateCss(generated?.css ?? (generatorBranch.isWeb ? finalizeWebCss(rawSource, true, generatorOptions.webCompat, {
|
|
5339
5404
|
escapeMap: opts.escapeMap,
|
|
5340
|
-
safeSelectors: shouldApplyWebviewSafeSelectors
|
|
5405
|
+
safeSelectors: shouldApplyWebviewSafeSelectors,
|
|
5406
|
+
uniAppXWebPreflightReset: opts.appType === "uni-app-x" && generatorBranch.isWeb
|
|
5341
5407
|
}) : (await opts.styleHandler(rawSource, cssHandlerOptions)).css));
|
|
5342
5408
|
if (generated) {
|
|
5343
5409
|
registerGeneratorDependencies(this, generated.dependencies);
|
|
@@ -6037,6 +6103,12 @@ function isViteServeCssRootRequest(id, command) {
|
|
|
6037
6103
|
function isViteCssHmrModule(code, id, command) {
|
|
6038
6104
|
return isViteServeStyleRequest(id, command) && VITE_CSS_HMR_MODULE_RE.test(code) && /[?&](?:direct|vue)(?:&|$)/.test(id);
|
|
6039
6105
|
}
|
|
6106
|
+
function hasViteServeCssGenerationDirective(code) {
|
|
6107
|
+
return hasTailwindRootDirectives(code) || hasTailwindSourceDirectives(code, { importFallback: true }) || hasTailwindApplyDirective(code);
|
|
6108
|
+
}
|
|
6109
|
+
function hasViteServeCssRootDirective(code) {
|
|
6110
|
+
return hasTailwindRootDirectives(code);
|
|
6111
|
+
}
|
|
6040
6112
|
function createViteServeCssGenerationPlugins(options) {
|
|
6041
6113
|
return [{
|
|
6042
6114
|
name: `${vitePluginName}:generate:serve`,
|
|
@@ -6061,7 +6133,8 @@ function createViteServeCssGenerationPlugins(options) {
|
|
|
6061
6133
|
if (!options.shouldGenerate() || !isViteCssHmrModule(code, id, options.getCommand())) return;
|
|
6062
6134
|
const extracted = extractViteCssHmrModuleCss(code);
|
|
6063
6135
|
if (!extracted) return;
|
|
6064
|
-
|
|
6136
|
+
if (!hasViteServeCssGenerationDirective(extracted.css)) return;
|
|
6137
|
+
if (hasViteServeCssRootDirective(extracted.css)) await options.onTailwindRootCss?.(id, extracted.css);
|
|
6065
6138
|
const generatedCss = await options.generateCss(id, extracted.css, this);
|
|
6066
6139
|
if (generatedCss === void 0 || generatedCss === extracted.css) return;
|
|
6067
6140
|
const nextCode = replaceViteCssHmrModuleCss(code, generatedCss);
|
|
@@ -6197,6 +6270,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
6197
6270
|
const initialTailwindRuntime = tailwindRuntime;
|
|
6198
6271
|
const refreshTailwindRuntime = refreshTailwindcssRuntime;
|
|
6199
6272
|
const uniAppXEnabled = isUniAppXEnabled(uniAppX);
|
|
6273
|
+
const shouldEnableUniAppXPlugins = opts.appType === "uni-app-x" || uniAppXEnabled;
|
|
6200
6274
|
const disabledOptions = resolvePluginDisabledState(disabled);
|
|
6201
6275
|
const tailwindcssMajorVersion = initialTailwindRuntime.majorVersion ?? 0;
|
|
6202
6276
|
if (!disabledOptions.plugin && tailwindcssMajorVersion !== 4) throw new Error("weapp-tailwindcss/vite 新生成管线仅支持 Tailwind CSS v4,请升级 tailwindcss 或停留在旧版 weapp-tailwindcss。");
|
|
@@ -6637,11 +6711,11 @@ function WeappTailwindcss(options = {}) {
|
|
|
6637
6711
|
if (!generated) return;
|
|
6638
6712
|
const finalizedCss = finalizeViteMiniProgramCss(generated.css);
|
|
6639
6713
|
const isUniAppViteWebviewPlatform = opts.appType === "uni-app-vite" && isUniAppViteWebviewStylePlatform(resolveViteStylePlatform());
|
|
6640
|
-
const tracedCss = annotateCssSourceTrace(removeScopedTailwindPreflightCss(currentGeneratorBranch.isWeb || isUniAppViteWebviewPlatform ? applyUniAppViteWebviewCssCompat(finalizedCss, {
|
|
6714
|
+
const tracedCss = annotateCssSourceTrace(withUniAppXWebPreflightReset(removeScopedTailwindPreflightCss(currentGeneratorBranch.isWeb || isUniAppViteWebviewPlatform ? applyUniAppViteWebviewCssCompat(finalizedCss, {
|
|
6641
6715
|
compat: currentGeneratorOptions.webCompat ?? true,
|
|
6642
6716
|
escapeMap: opts.escapeMap,
|
|
6643
6717
|
safeSelectors: isUniAppViteWebviewPlatform
|
|
6644
|
-
}) : finalizedCss), {
|
|
6718
|
+
}) : finalizedCss), opts.appType === "uni-app-x" && currentGeneratorBranch.isWeb), {
|
|
6645
6719
|
opts,
|
|
6646
6720
|
tokenSources: createCssTokenSourceMap(getSourceCandidateSourcesForEntries(void 0), opts)
|
|
6647
6721
|
});
|
|
@@ -6746,7 +6820,7 @@ function WeappTailwindcss(options = {}) {
|
|
|
6746
6820
|
if (shouldDiscoverAutoCssSources()) await discoverAndRegisterAutoCssSources();
|
|
6747
6821
|
await syncSourceCandidateScan();
|
|
6748
6822
|
};
|
|
6749
|
-
const uniAppXPlugins =
|
|
6823
|
+
const uniAppXPlugins = shouldEnableUniAppXPlugins ? createUniAppXPlugins({
|
|
6750
6824
|
appType: opts.appType ?? "uni-app-x",
|
|
6751
6825
|
customAttributesEntities,
|
|
6752
6826
|
disabledDefaultTemplateHandler,
|
package/dist/vite.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_vite = require("./vite-
|
|
2
|
+
const require_vite = require("./vite-BJRlG835.js");
|
|
3
3
|
exports.WeappTailwindcss = require_vite.WeappTailwindcss;
|
|
4
4
|
exports.weappTailwindcss = require_vite.WeappTailwindcss;
|
package/dist/vite.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as WeappTailwindcss } from "./vite-
|
|
1
|
+
import { t as WeappTailwindcss } from "./vite-XxJh7Xtu.mjs";
|
|
2
2
|
export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss };
|
|
@@ -60,9 +60,13 @@ function rewriteTailwindcssImportsInCode(code, pkgDir, options) {
|
|
|
60
60
|
}
|
|
61
61
|
//#endregion
|
|
62
62
|
//#region src/bundlers/shared/generated-css-marker.ts
|
|
63
|
+
const BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE = /\/\*!?\s*weapp-tailwindcss (?:vite|webpack)-generated-css(?:\s*:\s*[^\s*]+)?\s*\*\/\s*/gi;
|
|
63
64
|
function createBundlerGeneratedCssMarker(bundler, file) {
|
|
64
65
|
return `/*! weapp-tailwindcss ${bundler}-generated-css:${encodeURIComponent(file)} */`;
|
|
65
66
|
}
|
|
67
|
+
function stripBundlerGeneratedCssMarkers(source) {
|
|
68
|
+
return source.replace(BUNDLER_GENERATED_CSS_MARKER_GLOBAL_RE, "");
|
|
69
|
+
}
|
|
66
70
|
//#endregion
|
|
67
71
|
//#region src/bundlers/shared/generator-css/markers.ts
|
|
68
72
|
const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
|
|
@@ -2150,6 +2154,34 @@ function unwrapMiniProgramCascadeLayers(source) {
|
|
|
2150
2154
|
return source;
|
|
2151
2155
|
}
|
|
2152
2156
|
}
|
|
2157
|
+
function hasClassSelector$1(selector) {
|
|
2158
|
+
return /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i.test(selector);
|
|
2159
|
+
}
|
|
2160
|
+
function collectBareSelectorUserCss(source) {
|
|
2161
|
+
try {
|
|
2162
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
2163
|
+
let changed = false;
|
|
2164
|
+
root.walkAtRules("import", (rule) => {
|
|
2165
|
+
rule.remove();
|
|
2166
|
+
changed = true;
|
|
2167
|
+
});
|
|
2168
|
+
root.walkRules((rule) => {
|
|
2169
|
+
if ((rule.selectors?.length ? rule.selectors : [rule.selector]).some((selector) => hasClassSelector$1(selector))) {
|
|
2170
|
+
rule.remove();
|
|
2171
|
+
changed = true;
|
|
2172
|
+
}
|
|
2173
|
+
});
|
|
2174
|
+
root.walkAtRules((rule) => {
|
|
2175
|
+
if (rule.nodes !== void 0 && rule.nodes.length === 0) {
|
|
2176
|
+
rule.remove();
|
|
2177
|
+
changed = true;
|
|
2178
|
+
}
|
|
2179
|
+
});
|
|
2180
|
+
return changed ? root.toString() : source;
|
|
2181
|
+
} catch {
|
|
2182
|
+
return "";
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2153
2185
|
function stripTailwindSourceMediaFragments(source) {
|
|
2154
2186
|
let removedSourceMediaStart = false;
|
|
2155
2187
|
return terminateTailwindSourceAtRulesBeforeNextDirective(removeTailwindSourceMediaBlocks(source)).split(/\r?\n/).filter((line) => {
|
|
@@ -2354,7 +2386,10 @@ async function transformGeneratorUserCss(source, options) {
|
|
|
2354
2386
|
...options.generatorStyleOptions,
|
|
2355
2387
|
...options.cssUserHandlerOptions
|
|
2356
2388
|
});
|
|
2357
|
-
|
|
2389
|
+
const transformedCss = removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(css));
|
|
2390
|
+
const bareSelectorUserCss = collectBareSelectorUserCss(userSource);
|
|
2391
|
+
const missingBareSelectorUserCss = bareSelectorUserCss.trim().length > 0 ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(transformedCss, bareSelectorUserCss) : "";
|
|
2392
|
+
return missingBareSelectorUserCss.trim().length > 0 ? `${transformedCss}\n${missingBareSelectorUserCss}` : transformedCss;
|
|
2358
2393
|
}
|
|
2359
2394
|
//#endregion
|
|
2360
2395
|
//#region src/tailwindcss/runtime-options.ts
|
|
@@ -5450,6 +5485,12 @@ function intersectCandidateSets(left, right) {
|
|
|
5450
5485
|
for (const candidate of small) if (large.has(candidate)) matched.add(candidate);
|
|
5451
5486
|
return matched;
|
|
5452
5487
|
}
|
|
5488
|
+
function resolveScopedRuntimeCandidates(sourceCandidates, sourceScopedRuntime) {
|
|
5489
|
+
if (!sourceCandidates) return sourceScopedRuntime;
|
|
5490
|
+
if (!sourceScopedRuntime) return sourceCandidates;
|
|
5491
|
+
if (sourceCandidates.size === 0) return sourceScopedRuntime;
|
|
5492
|
+
return intersectCandidateSets(sourceCandidates, sourceScopedRuntime);
|
|
5493
|
+
}
|
|
5453
5494
|
function parseCssSourceRoot(rawSource) {
|
|
5454
5495
|
try {
|
|
5455
5496
|
return _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
@@ -5582,7 +5623,7 @@ async function generateCssByGenerator(options) {
|
|
|
5582
5623
|
const generator = createWeappTailwindcssGenerator(source);
|
|
5583
5624
|
const sourceEntries = getSourceCandidatesForEntries ? await resolveGeneratorSourceEntries(source, runtimeState) : void 0;
|
|
5584
5625
|
const sourceScopedRuntime = sourceEntries && sourceEntries.length > 0 ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
|
|
5585
|
-
const scopedRuntime =
|
|
5626
|
+
const scopedRuntime = resolveScopedRuntimeCandidates(options.sourceCandidates, sourceScopedRuntime);
|
|
5586
5627
|
const isolateCssSource = shouldIsolateScopedCssSource(majorVersion, source, sourceEntries, {
|
|
5587
5628
|
cssHandlerOptions,
|
|
5588
5629
|
target: generatorOptions.target
|
|
@@ -5672,7 +5713,7 @@ async function generateCssByGenerator(options) {
|
|
|
5672
5713
|
const beforeUserCss = await transformGeneratorUserCss(orderedExtraCss.before, userCssOptions);
|
|
5673
5714
|
const afterLayerUserCss = await transformGeneratorUserCss(afterLayerParts.layer, userCssOptions);
|
|
5674
5715
|
const afterUserCss = await transformGeneratorUserCss(afterLayerParts.rest, userCssOptions);
|
|
5675
|
-
const fallbackLayerUserCss = generated.target === "weapp" &&
|
|
5716
|
+
const fallbackLayerUserCss = generated.target === "weapp" && hasUserCssLayerBlocks(userCssRawSource) ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(afterLayerUserCss, await transformGeneratorUserCss(splitUserCssLayerBlocks(userCssRawSource).layer, userCssOptions)) : "";
|
|
5676
5717
|
css = createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(createCssSourceOrderAppend$1(beforeUserCss, generated.target === "weapp" ? wrapUserLayerComponentsCss(createCssSourceOrderAppend$1(afterLayerUserCss, fallbackLayerUserCss)) : afterLayerUserCss), css), afterUserCss);
|
|
5677
5718
|
if (isEmptyCssSourceOrderParts(orderedExtraCss) && shouldAppendWebBundleCssFallback(generated.target, {
|
|
5678
5719
|
hasSourceDirectives,
|
|
@@ -7342,6 +7383,92 @@ function createSourceCandidateStore(options = {}) {
|
|
|
7342
7383
|
}
|
|
7343
7384
|
}
|
|
7344
7385
|
//#endregion
|
|
7386
|
+
//#region src/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.ts
|
|
7387
|
+
function removeTailwindV4StandaloneHostPreflightRule(source) {
|
|
7388
|
+
if (!source.includes("--theme(")) return source;
|
|
7389
|
+
try {
|
|
7390
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
7391
|
+
let changed = false;
|
|
7392
|
+
root.walkRules((rule) => {
|
|
7393
|
+
if (rule.selector.trim() !== ":host") return;
|
|
7394
|
+
if (!rule.nodes?.some((node) => node.type === "decl" && node.value?.includes("--theme("))) return;
|
|
7395
|
+
rule.remove();
|
|
7396
|
+
changed = true;
|
|
7397
|
+
});
|
|
7398
|
+
return changed ? root.toString() : source;
|
|
7399
|
+
} catch {
|
|
7400
|
+
return source;
|
|
7401
|
+
}
|
|
7402
|
+
}
|
|
7403
|
+
function stripTrailingLineWhitespace(source) {
|
|
7404
|
+
return source.replace(/[ \t]+$/gm, "");
|
|
7405
|
+
}
|
|
7406
|
+
function hasWebpackClassSelector(selector) {
|
|
7407
|
+
return /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i.test(selector);
|
|
7408
|
+
}
|
|
7409
|
+
function isWebpackKeyframesRule(rule) {
|
|
7410
|
+
let parent = rule.parent;
|
|
7411
|
+
while (parent) {
|
|
7412
|
+
if (parent.type === "atrule" && parent.name.endsWith("keyframes")) return true;
|
|
7413
|
+
parent = parent.parent;
|
|
7414
|
+
}
|
|
7415
|
+
return false;
|
|
7416
|
+
}
|
|
7417
|
+
function collectWebpackBareSelectorUserCss(source) {
|
|
7418
|
+
try {
|
|
7419
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(removeTailwindSourceDirectives(stripTailwindSourceMediaFragments(removeTailwindV4GeneratorAtRules(source)), { importFallback: true }));
|
|
7420
|
+
let changed = false;
|
|
7421
|
+
root.walkAtRules((rule) => {
|
|
7422
|
+
if (rule.name === "import" || rule.name === "font-face" || rule.name.endsWith("keyframes")) {
|
|
7423
|
+
rule.remove();
|
|
7424
|
+
changed = true;
|
|
7425
|
+
}
|
|
7426
|
+
});
|
|
7427
|
+
root.walkRules((rule) => {
|
|
7428
|
+
if (isWebpackKeyframesRule(rule) || rule.selectors.some((selector) => hasWebpackClassSelector(selector))) {
|
|
7429
|
+
rule.remove();
|
|
7430
|
+
changed = true;
|
|
7431
|
+
}
|
|
7432
|
+
});
|
|
7433
|
+
root.walkAtRules((rule) => {
|
|
7434
|
+
if (rule.nodes !== void 0 && rule.nodes.length === 0) {
|
|
7435
|
+
rule.remove();
|
|
7436
|
+
changed = true;
|
|
7437
|
+
}
|
|
7438
|
+
});
|
|
7439
|
+
return changed ? root.toString() : source;
|
|
7440
|
+
} catch {
|
|
7441
|
+
return "";
|
|
7442
|
+
}
|
|
7443
|
+
}
|
|
7444
|
+
function finalizeMiniProgramUserCssAssetSource(source, compilerOptions, isWebGeneratorTarget, options = {}) {
|
|
7445
|
+
const styleOptions = resolveStyleOptionsFromContext(compilerOptions);
|
|
7446
|
+
if (isWebGeneratorTarget) return source;
|
|
7447
|
+
return (0, _weapp_tailwindcss_postcss.stripMiniProgramCssSpecificityPlaceholders)(removeTailwindV4StandaloneHostPreflightRule((0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(removeMiniProgramHoverSelectors(source, styleOptions.cssRemoveHoverPseudoClass), {
|
|
7448
|
+
cssPreflight: options.cssPreflight === false ? false : !hasMiniProgramTailwindV4PreflightReset(source) ? compilerOptions.cssPreflight : void 0,
|
|
7449
|
+
isTailwindcssV4: true,
|
|
7450
|
+
tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
|
|
7451
|
+
})));
|
|
7452
|
+
}
|
|
7453
|
+
function finalizeWebpackCssAssetSource(source, compilerOptions, isWebGeneratorTarget, options = {}) {
|
|
7454
|
+
const styleOptions = resolveStyleOptionsFromContext(compilerOptions);
|
|
7455
|
+
if (isWebGeneratorTarget) {
|
|
7456
|
+
if (options.generatedCss === true) return stripTrailingLineWhitespace(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(stripBundlerGeneratedCssMarkers(source))));
|
|
7457
|
+
return stripTrailingLineWhitespace(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(removeTailwindV4GeneratorAtRules(removeTailwindSourceDirectives(stripBundlerGeneratedCssMarkers(source), { importFallback: true })))));
|
|
7458
|
+
}
|
|
7459
|
+
let finalized = removeTailwindSourceDirectives(stripBundlerGeneratedCssMarkers(source), { importFallback: true });
|
|
7460
|
+
if (options.generatedCss !== true) return (0, _weapp_tailwindcss_postcss.stripMiniProgramCssSpecificityPlaceholders)(removeMiniProgramHoverSelectors(finalized, styleOptions.cssRemoveHoverPseudoClass));
|
|
7461
|
+
try {
|
|
7462
|
+
finalized = (0, _weapp_tailwindcss_postcss.pruneMiniProgramGeneratedCss)(finalized, { preservePreflight: options.cssPreflight !== false });
|
|
7463
|
+
} catch {}
|
|
7464
|
+
finalized = (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(finalized, {
|
|
7465
|
+
cssPreflight: options.cssPreflight === false ? false : !hasMiniProgramTailwindV4PreflightReset(finalized) ? compilerOptions.cssPreflight : void 0,
|
|
7466
|
+
isTailwindcssV4: true,
|
|
7467
|
+
tailwindcssV4GradientFallback: styleOptions.tailwindcssV4GradientFallback
|
|
7468
|
+
});
|
|
7469
|
+
return (0, _weapp_tailwindcss_postcss.stripMiniProgramCssSpecificityPlaceholders)(removeMiniProgramHoverSelectors(finalized, styleOptions.cssRemoveHoverPseudoClass));
|
|
7470
|
+
}
|
|
7471
|
+
//#endregion
|
|
7345
7472
|
//#region src/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.ts
|
|
7346
7473
|
function resolveLoaderOptions(options) {
|
|
7347
7474
|
const runtime = require_watch_dependencies.getWebpackLoaderRuntime(options?.tailwindcssImportRewriteRuntimeKey)?.cssImportRewrite;
|
|
@@ -7447,14 +7574,22 @@ async function generateCssForWebpackPipeline(source, loaderContext, options) {
|
|
|
7447
7574
|
});
|
|
7448
7575
|
if (!generated) return;
|
|
7449
7576
|
rewriteOptions.markGeneratedCssSource?.(file);
|
|
7577
|
+
for (const dependency of generated.dependencies) require_watch_dependencies.registerWebpackWatchFile(loaderContext, dependency);
|
|
7578
|
+
const generatedCss = removeTailwindSourceDirectives(generated.css, { importFallback: true });
|
|
7579
|
+
const finalizedGeneratedCss = finalizeWebpackCssAssetSource(generatedCss, compilerOptions, generatorTarget === "web", {
|
|
7580
|
+
cssPreflight: cssHandlerOptions.isMainChunk,
|
|
7581
|
+
generatedCss: true
|
|
7582
|
+
});
|
|
7583
|
+
const bareUserCss = generatorTarget === "web" ? "" : collectWebpackBareSelectorUserCss(normalizedSource);
|
|
7584
|
+
const finalizedBareUserCss = bareUserCss.trim().length === 0 ? "" : finalizeMiniProgramUserCssAssetSource(bareUserCss, compilerOptions, generatorTarget === "web", { cssPreflight: false });
|
|
7585
|
+
const missingBareUserCss = finalizedBareUserCss.trim().length === 0 ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(finalizedGeneratedCss, finalizedBareUserCss);
|
|
7586
|
+
const css = missingBareUserCss.trim().length === 0 ? generatedCss : `${generatedCss}\n${missingBareUserCss}`;
|
|
7450
7587
|
rewriteOptions.registerGeneratedCss?.({
|
|
7451
7588
|
classSet: generated.classSet,
|
|
7452
|
-
css
|
|
7589
|
+
css,
|
|
7453
7590
|
dependencies: generated.dependencies,
|
|
7454
7591
|
file
|
|
7455
7592
|
});
|
|
7456
|
-
for (const dependency of generated.dependencies) require_watch_dependencies.registerWebpackWatchFile(loaderContext, dependency);
|
|
7457
|
-
const css = removeTailwindSourceDirectives(generated.css, { importFallback: true });
|
|
7458
7593
|
return `${createBundlerGeneratedCssMarker("webpack", file)}\n${css}`;
|
|
7459
7594
|
}
|
|
7460
7595
|
function transformCssImportRewriteSource(source, options) {
|