weapp-tailwindcss 5.5.5 → 5.5.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/{auto-DtU6f3X6.cjs → auto-B1OyRrE8.cjs} +1 -1
- package/dist/{auto-2dg_uhEJ.js → auto-ENr4xzzw.js} +1 -1
- package/dist/bundlers/gulp/shared/create-native-framework-plugins/file-transforms.d.ts +5 -4
- package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +1 -1
- package/dist/bundlers/shared/css-cleanup.d.ts +1 -1
- package/dist/bundlers/shared/css-source-trace.d.ts +2 -5
- 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 +1 -24
- package/dist/bundlers/shared/framework-user-css.d.ts +1 -3
- package/dist/bundlers/shared/generated-css-marker.d.ts +1 -9
- package/dist/bundlers/shared/generator-css/candidates.d.ts +1 -2
- package/dist/bundlers/shared/generator-css/class-selectors.d.ts +1 -3
- package/dist/bundlers/shared/generator-css/config-directive.d.ts +1 -2
- package/dist/bundlers/shared/generator-css/directives/fallback.d.ts +1 -11
- package/dist/bundlers/shared/generator-css/directives.d.ts +1 -25
- package/dist/bundlers/shared/generator-css/generation-helpers/preflight.d.ts +1 -19
- package/dist/bundlers/shared/generator-css/generation-helpers/results.d.ts +1 -25
- package/dist/bundlers/shared/generator-css/generation-helpers/runtime-isolation.d.ts +1 -30
- package/dist/bundlers/shared/generator-css/generation-helpers/source-order.d.ts +1 -2
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +1 -4
- package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +1 -9
- package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +1 -5
- package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/local-imports.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/markers.d.ts +1 -28
- package/dist/bundlers/shared/generator-css/output-import-shell.d.ts +1 -8
- package/dist/bundlers/shared/generator-css/pipeline/context.d.ts +1 -58
- package/dist/bundlers/shared/generator-css/pipeline/deferred-output.d.ts +1 -3
- package/dist/bundlers/shared/generator-css/pipeline/execution.d.ts +1 -3
- package/dist/bundlers/shared/generator-css/pipeline/fallback-output.d.ts +1 -3
- package/dist/bundlers/shared/generator-css/pipeline/ordered-output.d.ts +1 -3
- package/dist/bundlers/shared/generator-css/pipeline.d.ts +1 -2
- package/dist/bundlers/shared/generator-css/result-helpers.d.ts +1 -6
- package/dist/bundlers/shared/generator-css/scoped-rules.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/source-files.d.ts +1 -21
- package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +1 -13
- package/dist/bundlers/shared/generator-css/source-resolver/config.d.ts +1 -7
- package/dist/bundlers/shared/generator-css/source-resolver/configuration.d.ts +1 -33
- package/dist/bundlers/shared/generator-css/source-resolver/matching.d.ts +1 -3
- package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +1 -28
- package/dist/bundlers/shared/generator-css/source-resolver/postcss-source.d.ts +1 -14
- package/dist/bundlers/shared/generator-css/source-resolver/resolve-source.d.ts +1 -4
- package/dist/bundlers/shared/generator-css/source-resolver/resolve-sources.d.ts +1 -5
- package/dist/bundlers/shared/generator-css/source-resolver/single-source.d.ts +1 -16
- package/dist/bundlers/shared/generator-css/source-resolver/source-entries.d.ts +1 -3
- package/dist/bundlers/shared/generator-css/source-resolver/source-matching.d.ts +1 -5
- package/dist/bundlers/shared/generator-css/source-resolver/types.d.ts +1 -22
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +1 -7
- package/dist/bundlers/shared/generator-css/types.d.ts +1 -61
- package/dist/bundlers/shared/generator-css/user-css/apply-only.d.ts +1 -9
- package/dist/bundlers/shared/generator-css/user-css/at-rules.d.ts +1 -3
- package/dist/bundlers/shared/generator-css/user-css/compile-functions.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/user-css/generated-cleanup.d.ts +1 -4
- package/dist/bundlers/shared/generator-css/user-css/source-fragments.d.ts +1 -15
- package/dist/bundlers/shared/generator-css/user-css/transform.d.ts +1 -10
- package/dist/bundlers/shared/generator-css/user-css/user-layers.d.ts +1 -15
- package/dist/bundlers/shared/generator-css/user-css.d.ts +1 -5
- package/dist/bundlers/shared/generator-css/user-layer-order.d.ts +1 -10
- package/dist/bundlers/shared/generator-css/validate.d.ts +1 -7
- package/dist/bundlers/shared/generator-css.d.ts +1 -9
- package/dist/bundlers/shared/run-tasks.d.ts +1 -3
- package/dist/bundlers/shared/runtime-class-set.d.ts +1 -1
- package/dist/bundlers/shared/source-candidates/collector.d.ts +1 -8
- package/dist/bundlers/shared/source-candidates/scan-root.d.ts +1 -12
- package/dist/bundlers/shared/source-candidates/script.d.ts +1 -1
- package/dist/bundlers/shared/source-candidates/snapshot.d.ts +1 -19
- package/dist/bundlers/shared/source-candidates/source-priority.d.ts +1 -1
- package/dist/bundlers/shared/source-candidates/store.d.ts +1 -2
- package/dist/bundlers/shared/source-candidates/types-and-cache.d.ts +1 -75
- package/dist/bundlers/shared/source-candidates/views.d.ts +1 -12
- package/dist/bundlers/shared/source-candidates.d.ts +1 -4
- package/dist/bundlers/shared/source-scan/css-entries.d.ts +1 -18
- package/dist/bundlers/shared/source-scan/dependencies.d.ts +1 -2
- package/dist/bundlers/shared/source-scan.d.ts +1 -16
- package/dist/bundlers/shared/static-config-content.d.ts +1 -5
- package/dist/bundlers/shared/style-handler-options.d.ts +1 -0
- package/dist/bundlers/shared/style-requests.d.ts +1 -5
- package/dist/bundlers/shared/v4-generation-core.d.ts +1 -21
- 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/configured-css-sources.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/css-transform-decision-plan.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/css-transform-task.d.ts +2 -2
- 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/cleanup.d.ts +1 -1
- package/dist/bundlers/vite/processed-css-assets/coverage.d.ts +1 -10
- package/dist/bundlers/vite/processed-css-assets/injection-plan.d.ts +1 -4
- package/dist/bundlers/vite/processed-css-assets/markers-imports.d.ts +4 -7
- package/dist/bundlers/vite/processed-css-assets/scoped-tailwind-noise.d.ts +1 -13
- package/dist/bundlers/vite/shared/create-framework-plugins-runtime.d.ts +3 -1
- package/dist/bundlers/vite/shared/framework-module-candidates.d.ts +3 -2
- 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/vite/source-candidates/scan-root.d.ts +1 -1
- package/dist/bundlers/vite/source-candidates.d.ts +1 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/finalize.d.ts +1 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/generated-css.d.ts +2 -7
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/preflight-runtime.d.ts +4 -8
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/sources.d.ts +3 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css-markers.d.ts +1 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css.d.ts +2 -7
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/processed-css-task.d.ts +2 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.d.ts +1 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +1 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -1
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +1 -1
- package/dist/bundlers/webpack/loaders/watch-dependencies.d.ts +6 -0
- package/dist/bundlers/webpack/shared/create-framework-plugin/plugin.d.ts +1 -1
- package/dist/cache/index.d.ts +4 -4
- package/dist/cache/source.d.ts +29 -0
- package/dist/{cache-CBJFB1HN.cjs → cache-CzvIGfwS.cjs} +1 -0
- package/dist/compiler/composition.d.ts +1 -1
- package/dist/compiler/index.d.ts +2 -0
- package/dist/compiler/runtime-affecting-signature/js.d.ts +1 -0
- package/dist/compiler/semantic-css.d.ts +1 -1
- package/dist/compiler/types.d.ts +1 -1
- package/dist/{compiler-D_vxtEdw.js → compiler-CThodfGH.js} +3105 -3065
- package/dist/{compiler-Cc0JXfbw.cjs → compiler-DkGY5Nmh.cjs} +22414 -45557
- package/dist/core/compiler/generation-cache.d.ts +4 -2
- package/dist/core/compiler/transforms.d.ts +1 -1
- package/dist/core/compiler/types.d.ts +1 -1
- package/dist/core.cjs +10 -10
- package/dist/core.d.ts +2 -2
- package/dist/core.js +5 -5
- package/dist/css-cleanup-B6FUJC3z.cjs +1 -0
- package/dist/{css-imports-FRZwX4P6.cjs → css-imports-R_RDMjPz.cjs} +7 -22
- package/dist/css-macro/auto.d.ts +1 -1
- package/dist/css-macro/postcss.cjs +1 -1
- package/dist/css-macro.cjs +3 -3
- package/dist/css-macro.js +2 -2
- 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-B6FUJC3z.cjs +1 -0
- package/dist/{final-css-cleanup-B0HUBtiE.js → final-css-cleanup-BOzhuhGz.js} +3 -127
- package/dist/framework/index.d.ts +1 -1
- package/dist/framework/platform.d.ts +2 -2
- package/dist/framework.cjs +1 -1
- package/dist/{v4-generation-core-DJBWZ_D0.cjs → generated-css-marker-jMNbQHpy.cjs} +717 -1730
- package/dist/generation/candidates.d.ts +1 -0
- package/dist/generation/class-selectors.d.ts +4 -0
- package/dist/generation/config-directive.d.ts +1 -0
- package/dist/generation/directives/fallback.d.ts +1 -0
- package/dist/generation/directives.d.ts +1 -0
- package/dist/generation/framework-css-composition.d.ts +1 -0
- package/dist/generation/framework-postcss.d.ts +25 -0
- package/dist/generation/framework-user-css.d.ts +5 -0
- package/dist/generation/generation-helpers/preflight.d.ts +19 -0
- package/dist/generation/generation-helpers/results.d.ts +23 -0
- package/dist/generation/generation-helpers/runtime-isolation.d.ts +30 -0
- package/dist/generation/generation-helpers/source-order.d.ts +1 -0
- package/dist/generation/generation-helpers.d.ts +4 -0
- package/dist/generation/index.d.ts +9 -0
- package/dist/generation/legacy-compat.d.ts +12 -0
- package/dist/generation/legacy-selectors.d.ts +1 -0
- package/dist/generation/legacy-units.d.ts +1 -0
- package/dist/generation/local-imports.d.ts +1 -0
- package/dist/generation/markers.d.ts +1 -0
- package/dist/generation/output-import-shell.d.ts +1 -0
- package/dist/generation/pipeline/context.d.ts +60 -0
- package/dist/generation/pipeline/deferred-output.d.ts +3 -0
- package/dist/generation/pipeline/execution.d.ts +3 -0
- package/dist/generation/pipeline/fallback-output.d.ts +3 -0
- package/dist/generation/pipeline/ordered-output.d.ts +3 -0
- package/dist/generation/pipeline/preparation.d.ts +19 -0
- package/dist/generation/pipeline.d.ts +2 -0
- package/dist/generation/result-helpers.d.ts +6 -0
- package/dist/generation/scoped-rules.d.ts +1 -0
- package/dist/generation/service.d.ts +20 -0
- package/dist/generation/source-files.d.ts +21 -0
- package/dist/generation/source-resolver/apply-reference.d.ts +10 -0
- package/dist/generation/source-resolver/config.d.ts +7 -0
- package/dist/generation/source-resolver/configuration.d.ts +33 -0
- package/dist/generation/source-resolver/matching.d.ts +3 -0
- package/dist/generation/source-resolver/metadata.d.ts +28 -0
- package/dist/generation/source-resolver/postcss-source.d.ts +14 -0
- package/dist/generation/source-resolver/resolve-source.d.ts +4 -0
- package/dist/generation/source-resolver/resolve-sources.d.ts +5 -0
- package/dist/generation/source-resolver/single-source.d.ts +16 -0
- package/dist/generation/source-resolver/source-entries.d.ts +3 -0
- package/dist/generation/source-resolver/source-matching.d.ts +5 -0
- package/dist/generation/source-resolver/types.d.ts +22 -0
- package/dist/generation/source-resolver.d.ts +7 -0
- package/dist/generation/style-options.d.ts +8 -0
- package/dist/generation/style-requests.d.ts +5 -0
- package/dist/generation/types.d.ts +65 -0
- package/dist/generation/user-css/apply-only.d.ts +5 -0
- package/dist/generation/user-css/at-rules.d.ts +1 -0
- package/dist/generation/user-css/compile-functions.d.ts +3 -0
- package/dist/generation/user-css/generated-cleanup.d.ts +1 -0
- package/dist/generation/user-css/source-fragments.d.ts +1 -0
- package/dist/generation/user-css/transform.d.ts +1 -0
- package/dist/generation/user-css/user-layers.d.ts +1 -0
- package/dist/generation/user-css.d.ts +5 -0
- package/dist/generation/user-layer-order.d.ts +1 -0
- package/dist/generation/validate.d.ts +7 -0
- package/dist/generator-CxauQbx3.cjs +1868 -0
- package/dist/generator-oKZ5mCJ5.js +1637 -0
- package/dist/generator.cjs +10 -4
- package/dist/generator.js +1 -1
- package/dist/{gulp-Dnt8VL8D.cjs → gulp-CVvBpIlq.cjs} +27 -26
- package/dist/{gulp-B1mPTMqw.js → gulp-DhddVxGA.js} +6 -5
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-qpX410qU.cjs → hmr-timing-DfMbbZ1E.cjs} +13 -13
- package/dist/{hmr-timing-wAt0LavM.js → hmr-timing-xPpat-km.js} +601 -1548
- package/dist/index.cjs +7 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/js/ModuleGraph.d.ts +3 -1
- package/dist/js/NodePathWalker.d.ts +1 -1
- package/dist/js/babel/analyze.d.ts +6 -0
- package/dist/js/babel.d.ts +1 -2
- package/dist/js/fast-path/analysis.d.ts +14 -0
- package/dist/js/fast-path/oxc.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/js/oxc-parser.d.ts +4 -0
- package/dist/pipeline-helpers-zMPmp5F3.cjs +516 -0
- package/dist/postcss-html-transform.cjs +1 -1
- package/dist/postcss.cjs +3 -2
- package/dist/postcss.d.ts +1 -1
- package/dist/postcss.js +3 -2
- package/dist/presets.cjs +3 -3
- package/dist/presets.js +2 -2
- package/dist/project-sources/candidates/collector.d.ts +8 -0
- package/dist/project-sources/candidates/scan-root.d.ts +12 -0
- package/dist/project-sources/candidates/script.d.ts +1 -0
- package/dist/project-sources/candidates/snapshot.d.ts +19 -0
- package/dist/project-sources/candidates/source-priority.d.ts +1 -0
- package/dist/project-sources/candidates/store.d.ts +2 -0
- package/dist/project-sources/candidates/types-and-cache.d.ts +75 -0
- package/dist/project-sources/candidates/views.d.ts +12 -0
- package/dist/project-sources/candidates.d.ts +4 -0
- package/dist/project-sources/css-entries.d.ts +18 -0
- package/dist/project-sources/dependencies.d.ts +2 -0
- package/dist/project-sources/index.d.ts +16 -0
- package/dist/project-sources/static-config-content.d.ts +5 -0
- package/dist/reset.cjs +1 -1
- package/dist/{rolldown-runtime-Ctb5zv51.cjs → rolldown-runtime-fg3euq-1.cjs} +7 -0
- package/dist/rspack.cjs +4 -4
- package/dist/rspack.js +2 -2
- package/dist/{runtime-state-XYSycuGu.cjs → runtime-state-BOzuVoKl.cjs} +1 -1
- package/dist/{scoped-generator-CtetE5rm.cjs → scoped-generator-BIZ7N_J-.cjs} +51 -36
- package/dist/{scoped-generator-BqxVxNp9.js → scoped-generator-DlQrVbuC.js} +49 -33
- package/dist/{source-candidate-scan-signature-Lm32zKVA.js → source-candidate-scan-signature-BjVQYL-C.js} +22 -5
- package/dist/{source-candidate-scan-signature-BDGB9nKZ.cjs → source-candidate-scan-signature-nG-rg809.cjs} +34 -5
- package/dist/style-injector/internal.d.ts +118 -8
- package/dist/style-injector/options.d.ts +6 -2
- package/dist/tailwindcss/miniprogram.d.ts +1 -1
- package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -1
- package/dist/tailwindcss/runtime-options.d.ts +5 -0
- package/dist/tailwindcss/source-scan/inline-source.d.ts +1 -7
- package/dist/tailwindcss/source-scan.d.ts +3 -32
- package/dist/tailwindcss/v4/css-sources.d.ts +1 -1
- package/dist/tailwindcss/v4/preflight.d.ts +1 -4
- package/dist/tailwindcss/v4/rpx-theme-warning.d.ts +4 -0
- package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/generator/incremental-cache.d.ts +2 -3
- package/dist/tailwindcss/v4-engine/generator/native-session.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/generator/rpx-candidates.d.ts +1 -6
- package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +5 -2
- package/dist/tailwindcss/v4-engine/generator/style-context.d.ts +1 -3
- package/dist/tailwindcss/v4-engine/miniprogram.d.ts +3 -7
- package/dist/tailwindcss/v4-engine/source.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/types.d.ts +3 -1
- package/dist/{tailwindcss-9e6ZuYgS.cjs → tailwindcss-U3KIUegn.cjs} +66 -271
- package/dist/{tailwindcss-DTV9MoJT.js → tailwindcss-kSd0ykiX.js} +73 -251
- package/dist/{transform-BbbZvFQq.js → transform-BAon9ykq.js} +35 -20
- package/dist/{transform-D21f8Dm8.cjs → transform-D2KFdA3C.cjs} +41 -26
- package/dist/types/index.d.ts +4 -3
- package/dist/types/user-defined-options/general.d.ts +1 -1
- package/dist/uni-app-x/border-preflight.d.ts +1 -2
- package/dist/uni-app-x/component-local-style.d.ts +4 -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/utils/run-tasks.d.ts +3 -0
- package/dist/vite/web.cjs +1 -1
- package/dist/vite/web.js +1 -1
- package/dist/{vite-CaH7WjX6.cjs → vite-BxW0qd7J.cjs} +677 -1315
- package/dist/{vite-CuYntLZP.js → vite-D-RGkmOE.js} +541 -1173
- package/dist/vite-web.d.ts +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/{watch-dependencies-GbC14Rlt.cjs → watch-dependencies-C1so1whD.cjs} +14 -1
- package/dist/weapp-tw-css-generation-loader.cjs +4 -3
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +34 -29
- package/dist/weapp-tw-runtime-classset-loader.cjs +5 -18
- package/dist/{web-CdXkY_VO.js → web--kA4HUTm.js} +149 -211
- package/dist/{web-CYs2Kcaa.cjs → web-Y-H6I1k6.cjs} +226 -286
- package/dist/{webpack-BnCSOUuu.js → webpack-BB-kw4Qr.js} +38 -450
- package/dist/{webpack-BQNnpQPC.cjs → webpack-DxrWatNB.cjs} +97 -97
- 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 +16 -13
- package/dist/final-css-cleanup-DSjczga3.cjs +0 -138
- package/dist/generator-BdSIvFEO.cjs +0 -3905
- package/dist/generator-CAOx1Sqm.js +0 -3357
- package/dist/pipeline-helpers-BHagysZY.cjs +0 -971
- package/dist/tailwindcss/v4-engine/css-import.d.ts +0 -14
- package/dist/uni-app-x/style-asset/source-parser.d.ts +0 -2
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
const require_rolldown_runtime = require("./rolldown-runtime-
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-fg3euq-1.cjs");
|
|
2
2
|
const require_framework = require("./framework.cjs");
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const require_tailwindcss = require("./tailwindcss-9e6ZuYgS.cjs");
|
|
3
|
+
const require_generator = require("./generator-CxauQbx3.cjs");
|
|
5
4
|
require("./utils-CuKLf1Zv.cjs");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
5
|
+
const require_compiler = require("./compiler-DkGY5Nmh.cjs");
|
|
6
|
+
const require_tailwindcss = require("./tailwindcss-U3KIUegn.cjs");
|
|
7
|
+
const require_generated_css_marker = require("./generated-css-marker-jMNbQHpy.cjs");
|
|
8
|
+
const require_cache = require("./cache-CzvIGfwS.cjs");
|
|
9
|
+
const require_hmr_timing = require("./hmr-timing-DfMbbZ1E.cjs");
|
|
10
|
+
require("./final-css-cleanup-B6FUJC3z.cjs");
|
|
11
|
+
const require_scoped_generator = require("./scoped-generator-BIZ7N_J-.cjs");
|
|
12
|
+
const require_web = require("./web-Y-H6I1k6.cjs");
|
|
13
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-nG-rg809.cjs");
|
|
14
|
+
require("./css-cleanup-B6FUJC3z.cjs");
|
|
14
15
|
require("./logger-TlKT3xmR.cjs");
|
|
15
16
|
let node_fs = require("node:fs");
|
|
16
17
|
node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
|
|
@@ -18,71 +19,26 @@ let node_path = require("node:path");
|
|
|
18
19
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
19
20
|
let node_process = require("node:process");
|
|
20
21
|
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
21
|
-
let
|
|
22
|
-
let
|
|
22
|
+
let _weapp_tailwindcss_engine = require("@weapp-tailwindcss/engine");
|
|
23
|
+
let _weapp_tailwindcss_postcss_transform = require("@weapp-tailwindcss/postcss/transform");
|
|
23
24
|
let lru_cache = require("lru-cache");
|
|
24
|
-
let node_fs_promises = require("node:fs/promises");
|
|
25
|
-
let micromatch = require("micromatch");
|
|
26
|
-
micromatch = require_rolldown_runtime.__toESM(micromatch, 1);
|
|
27
25
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
28
26
|
let node_buffer = require("node:buffer");
|
|
27
|
+
let node_fs_promises = require("node:fs/promises");
|
|
29
28
|
let _weapp_tailwindcss_logger = require("@weapp-tailwindcss/logger");
|
|
30
29
|
let node_async_hooks = require("node:async_hooks");
|
|
31
|
-
let
|
|
32
|
-
|
|
30
|
+
let micromatch = require("micromatch");
|
|
31
|
+
micromatch = require_rolldown_runtime.__toESM(micromatch, 1);
|
|
33
32
|
let _vue_compiler_dom = require("@vue/compiler-dom");
|
|
34
33
|
let comment_json = require("comment-json");
|
|
35
|
-
//#region src/uni-app-x/style-asset/source-parser.ts
|
|
36
|
-
function parseUniAppXStyleSource(source) {
|
|
37
|
-
return postcss_scss.default.parse(source, { from: void 0 });
|
|
38
|
-
}
|
|
39
|
-
function isUniAppXStyleSourceEmpty(source) {
|
|
40
|
-
try {
|
|
41
|
-
return parseUniAppXStyleSource(source).nodes.every((node) => node.type === "comment");
|
|
42
|
-
} catch {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
//#endregion
|
|
47
34
|
//#region src/uni-app-x/style-asset/harmony-apply.ts
|
|
48
35
|
const SFC_STYLE_BLOCK_RE$1 = /(<style\b[^>]*>)([\s\S]*?)(<\/style>)/gi;
|
|
49
|
-
function createGeneratedRuleMap(css) {
|
|
50
|
-
let root;
|
|
51
|
-
try {
|
|
52
|
-
root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
53
|
-
} catch {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
const rules = /* @__PURE__ */ new Map();
|
|
57
|
-
root.walkRules((rule) => {
|
|
58
|
-
if (rule.nodes && rule.nodes.length > 0) rules.set(rule.selector.trim(), rule.nodes.map((node) => node.clone()));
|
|
59
|
-
});
|
|
60
|
-
return rules.size > 0 ? rules : void 0;
|
|
61
|
-
}
|
|
62
36
|
function expandUniAppXHarmonyApplyStyles(source, generatedCss) {
|
|
63
37
|
if (!source.includes("@apply")) return source;
|
|
64
|
-
const
|
|
65
|
-
if (!
|
|
66
|
-
return source.replace(SFC_STYLE_BLOCK_RE$1, (
|
|
67
|
-
|
|
68
|
-
let root;
|
|
69
|
-
try {
|
|
70
|
-
root = parseUniAppXStyleSource(styleSource);
|
|
71
|
-
} catch {
|
|
72
|
-
return block;
|
|
73
|
-
}
|
|
74
|
-
let changed = false;
|
|
75
|
-
root.walkRules((rule) => {
|
|
76
|
-
if (!(rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply") === true)) return;
|
|
77
|
-
const generatedNodes = generatedRules.get(rule.selector.trim());
|
|
78
|
-
if (!generatedNodes) return;
|
|
79
|
-
rule.removeAll();
|
|
80
|
-
rule.append(generatedNodes.map((node) => node.clone()));
|
|
81
|
-
changed = true;
|
|
82
|
-
});
|
|
83
|
-
if (!changed) return block;
|
|
84
|
-
if (!root.toString().includes("@apply")) root.walkAtRules("reference", (rule) => rule.remove());
|
|
85
|
-
return `${open}${root.toString()}${close}`;
|
|
38
|
+
const expand = (0, _weapp_tailwindcss_postcss_transform.createUniAppXHarmonyApplyCssExpander)(generatedCss);
|
|
39
|
+
if (!expand) return source;
|
|
40
|
+
return source.replace(SFC_STYLE_BLOCK_RE$1, (_block, open, styleSource, close) => {
|
|
41
|
+
return `${open}${expand(styleSource)}${close}`;
|
|
86
42
|
});
|
|
87
43
|
}
|
|
88
44
|
//#endregion
|
|
@@ -115,8 +71,6 @@ const STYLE_ENTRY_RE = /\[\s*("((?:\\.|[^"\\])+)")\s*,\s*(_pS\(_uM\(\[[\s\S]*?\]
|
|
|
115
71
|
const STRING_LITERAL_RE = /(['"`])((?:\\.|(?!\1)[\s\S])*?)\1/g;
|
|
116
72
|
const SFC_STYLE_BLOCK_RE = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
|
|
117
73
|
const STYLE_EXPORT_PREFIX_RE = /^\s*export\s+default\s+/;
|
|
118
|
-
const CLASS_SELECTOR_PREFIX_RE = /^\.((?:\\[^\n\r\f]|[\w-])+)(?=$|[.:#[])/;
|
|
119
|
-
const STRING_STYLE_PROPERTIES = /* @__PURE__ */ new Set(["lineHeight"]);
|
|
120
74
|
function cloneStyleEntry(entry) {
|
|
121
75
|
return Object.fromEntries(Object.entries(entry).map(([state, declarations]) => [state, { ...declarations }]));
|
|
122
76
|
}
|
|
@@ -131,21 +85,6 @@ function mergeStyleEntry(local, generated) {
|
|
|
131
85
|
function cloneStyleValue(style) {
|
|
132
86
|
return Object.fromEntries(Object.entries(style).map(([className, entry]) => [className, cloneStyleEntry(entry)]));
|
|
133
87
|
}
|
|
134
|
-
function toCamelCase(prop) {
|
|
135
|
-
return prop.replace(/-([a-z])/g, (_, char) => char.toUpperCase());
|
|
136
|
-
}
|
|
137
|
-
function normalizeValue(prop, value) {
|
|
138
|
-
const trimmed = value.trim();
|
|
139
|
-
if (!STRING_STYLE_PROPERTIES.has(toCamelCase(prop)) && /^-?\d+(?:\.\d+)?px$/.test(trimmed)) return Number(trimmed.slice(0, -2));
|
|
140
|
-
return trimmed.replace(/\s*,\s*/g, ",");
|
|
141
|
-
}
|
|
142
|
-
function normalizeStyleValue(prop, value) {
|
|
143
|
-
if (typeof value === "number") return STRING_STYLE_PROPERTIES.has(toCamelCase(prop)) ? String(value) : value;
|
|
144
|
-
return normalizeValue(prop, value);
|
|
145
|
-
}
|
|
146
|
-
function unescapeCssClassSelector(className) {
|
|
147
|
-
return className.replace(/\\([^\n\r\f0-9a-f])/gi, "$1");
|
|
148
|
-
}
|
|
149
88
|
function parseStyleExport(source) {
|
|
150
89
|
const json = source.replace(STYLE_EXPORT_PREFIX_RE, "").trim();
|
|
151
90
|
if (!json) return;
|
|
@@ -176,7 +115,7 @@ function styleExportToUtsMap(styleExport) {
|
|
|
176
115
|
const declarations = styleStates[""];
|
|
177
116
|
if (!declarations || Object.keys(declarations).length === 0) continue;
|
|
178
117
|
const declarationEntries = Object.entries(declarations).map(([prop, value]) => {
|
|
179
|
-
return `[${JSON.stringify(
|
|
118
|
+
return `[${JSON.stringify((0, _weapp_tailwindcss_postcss_transform.normalizeUniAppXStyleProperty)(prop))}, ${JSON.stringify((0, _weapp_tailwindcss_postcss_transform.normalizeUniAppXStyleValue)(prop, value))}]`;
|
|
180
119
|
});
|
|
181
120
|
if (declarationEntries.length === 0) continue;
|
|
182
121
|
classEntries.push(`[${JSON.stringify(className)}, _pS(_uM([${declarationEntries.join(", ")}]))]`);
|
|
@@ -206,7 +145,7 @@ function collectUsedClassNames(code, entries) {
|
|
|
206
145
|
for (const literalMatch of code.matchAll(STRING_LITERAL_RE)) {
|
|
207
146
|
const literal = literalMatch[2];
|
|
208
147
|
if (!literal) continue;
|
|
209
|
-
for (const candidate of (0,
|
|
148
|
+
for (const candidate of (0, _weapp_tailwindcss_engine.splitCandidateTokens)(literal)) if (entries.has(candidate)) used.add(candidate);
|
|
210
149
|
}
|
|
211
150
|
return used;
|
|
212
151
|
}
|
|
@@ -221,35 +160,8 @@ function createUtsStyleArrayFromAppStyles(code, appSource) {
|
|
|
221
160
|
if (used.size === 0) return;
|
|
222
161
|
return createUtsStyleArray([...used].map((className) => entries.get(className)).filter(Boolean));
|
|
223
162
|
}
|
|
224
|
-
function cssToStyleExport(source) {
|
|
225
|
-
let root;
|
|
226
|
-
try {
|
|
227
|
-
root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
228
|
-
} catch {
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
const result = {};
|
|
232
|
-
root.walkRules((rule) => {
|
|
233
|
-
const selectors = rule.selectors ?? [];
|
|
234
|
-
for (const selector of selectors) {
|
|
235
|
-
const match = selector.trim().match(CLASS_SELECTOR_PREFIX_RE);
|
|
236
|
-
if (!match?.[1]) continue;
|
|
237
|
-
const declarations = {};
|
|
238
|
-
rule.walkDecls((decl) => {
|
|
239
|
-
declarations[toCamelCase(decl.prop)] = normalizeValue(decl.prop, decl.value);
|
|
240
|
-
});
|
|
241
|
-
if (Object.keys(declarations).length > 0) {
|
|
242
|
-
result[match[1]] = { "": declarations };
|
|
243
|
-
const className = unescapeCssClassSelector(match[1]);
|
|
244
|
-
result[className] = { "": declarations };
|
|
245
|
-
result[require_compiler.replaceWxml(className)] = { "": declarations };
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
return Object.keys(result).length > 0 ? result : void 0;
|
|
250
|
-
}
|
|
251
163
|
function cssSourceToStyleValue(source) {
|
|
252
|
-
return STYLE_EXPORT_PREFIX_RE.test(source) ? parseStyleExport(source) :
|
|
164
|
+
return STYLE_EXPORT_PREFIX_RE.test(source) ? parseStyleExport(source) : (0, _weapp_tailwindcss_postcss_transform.cssToClassStyleValue)(source);
|
|
253
165
|
}
|
|
254
166
|
function mergeStyleValues(...items) {
|
|
255
167
|
const result = {};
|
|
@@ -265,72 +177,23 @@ function createStyleValueFromApplySources(sources, utilityStyles) {
|
|
|
265
177
|
for (const source of sources) {
|
|
266
178
|
const styleSources = source.includes("<style") ? [...source.matchAll(SFC_STYLE_BLOCK_RE)].map((styleBlock) => styleBlock[1] ?? "") : [source];
|
|
267
179
|
for (const styleSource of styleSources) {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
} catch {
|
|
272
|
-
continue;
|
|
273
|
-
}
|
|
274
|
-
root.walkRules((rule) => {
|
|
275
|
-
const applyRules = rule.nodes?.filter((node) => node.type === "atrule" && node.name === "apply") ?? [];
|
|
276
|
-
if (applyRules.length === 0) return;
|
|
277
|
-
const selectors = rule.selectors ?? [rule.selector];
|
|
278
|
-
for (const selector of selectors) {
|
|
279
|
-
const className = selector.trim().match(CLASS_SELECTOR_PREFIX_RE)?.[1];
|
|
280
|
-
if (!className) continue;
|
|
281
|
-
const declarations = {};
|
|
282
|
-
for (const applyRule of applyRules) for (const utility of (0, _tailwindcss_mangle_engine.splitCandidateTokens)(applyRule.params)) {
|
|
283
|
-
const utilityDeclarations = utilityStyles[utility]?.[""] ?? utilityStyles[require_compiler.replaceWxml(utility)]?.[""];
|
|
284
|
-
if (utilityDeclarations) Object.assign(declarations, utilityDeclarations);
|
|
285
|
-
}
|
|
286
|
-
if (Object.keys(declarations).length > 0) {
|
|
287
|
-
const unescapedClassName = unescapeCssClassSelector(className);
|
|
288
|
-
result[className] = { "": declarations };
|
|
289
|
-
result[unescapedClassName] = { "": declarations };
|
|
290
|
-
result[require_compiler.replaceWxml(unescapedClassName)] = { "": declarations };
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
});
|
|
180
|
+
const applied = (0, _weapp_tailwindcss_postcss_transform.expandCssApplySourcesToStyleValue)(styleSource, utilityStyles);
|
|
181
|
+
if (!applied) continue;
|
|
182
|
+
Object.assign(result, applied);
|
|
294
183
|
}
|
|
295
184
|
}
|
|
296
185
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
297
186
|
}
|
|
298
187
|
function resolveReferencePaths(styleSource, sourceId) {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
root = parseUniAppXStyleSource(styleSource);
|
|
302
|
-
} catch {
|
|
303
|
-
return styleSource;
|
|
304
|
-
}
|
|
305
|
-
if (!sourceId || !styleSource.includes("@reference")) return root.toString();
|
|
306
|
-
const cleanSourceId = sourceId.replace(/\?.*$/, "");
|
|
307
|
-
root.walkAtRules("reference", (rule) => {
|
|
308
|
-
const quote = rule.params[0];
|
|
309
|
-
if (quote !== "\"" && quote !== "'") return;
|
|
310
|
-
const closingQuoteIndex = rule.params.indexOf(quote, 1);
|
|
311
|
-
if (closingQuoteIndex <= 1) return;
|
|
312
|
-
const referencePath = rule.params.slice(1, closingQuoteIndex);
|
|
313
|
-
if (!referencePath.startsWith(".")) return;
|
|
314
|
-
rule.params = `${quote}${resolveStyleReferencePath(cleanSourceId, referencePath)}${quote}${rule.params.slice(closingQuoteIndex + 1)}`;
|
|
315
|
-
});
|
|
316
|
-
return root.toString();
|
|
188
|
+
const cleanSourceId = sourceId?.replace(/\?.*$/, "");
|
|
189
|
+
return (0, _weapp_tailwindcss_postcss_transform.rewriteUniAppXStyleReferences)(styleSource, sourceId ? (reference) => resolveStyleReferencePath(cleanSourceId, reference) : void 0);
|
|
317
190
|
}
|
|
318
191
|
function collectUniAppXHarmonyApplyStyleSourcesFromSource(source, sourceId) {
|
|
319
192
|
return (source.includes("<style") ? [...source.matchAll(SFC_STYLE_BLOCK_RE)].map((styleBlock) => styleBlock[1] ?? "") : [source]).map((styleSource) => resolveReferencePaths(styleSource.trim(), sourceId)).filter((styleSource) => styleSource.length > 0 && styleSource.includes("@apply"));
|
|
320
193
|
}
|
|
321
194
|
function collectUniAppXHarmonyApplyUtilitiesFromSources(sources) {
|
|
322
195
|
const utilities = /* @__PURE__ */ new Set();
|
|
323
|
-
for (const source of sources) for (const styleSource of collectUniAppXHarmonyApplyStyleSourcesFromSource(source))
|
|
324
|
-
let root;
|
|
325
|
-
try {
|
|
326
|
-
root = parseUniAppXStyleSource(styleSource);
|
|
327
|
-
} catch {
|
|
328
|
-
continue;
|
|
329
|
-
}
|
|
330
|
-
root.walkAtRules("apply", (rule) => {
|
|
331
|
-
for (const utility of (0, _tailwindcss_mangle_engine.splitCandidateTokens)(rule.params)) utilities.add(utility);
|
|
332
|
-
});
|
|
333
|
-
}
|
|
196
|
+
for (const source of sources) for (const styleSource of collectUniAppXHarmonyApplyStyleSourcesFromSource(source)) for (const utility of (0, _weapp_tailwindcss_postcss_transform.collectCssApplyUtilities)(styleSource)) utilities.add(utility);
|
|
334
197
|
return utilities;
|
|
335
198
|
}
|
|
336
199
|
function createMergedStyleValue(code, localStyle, appStyle) {
|
|
@@ -544,18 +407,7 @@ function resolveSourceMapFiles(file) {
|
|
|
544
407
|
}
|
|
545
408
|
const UNI_APP_X_STYLE_PLACEHOLDER_VERSION = "uni-app-x-style-placeholder-v3";
|
|
546
409
|
function createUniAppXHarmonyApplyGeneratorSource(applyStyleSources, _applyUtilities) {
|
|
547
|
-
return
|
|
548
|
-
let root;
|
|
549
|
-
try {
|
|
550
|
-
root = parseUniAppXStyleSource(source);
|
|
551
|
-
} catch {
|
|
552
|
-
return source;
|
|
553
|
-
}
|
|
554
|
-
root.walkAtRules("reference", (rule) => {
|
|
555
|
-
if (rule.params.match(/^(['"])(.+?)\1/)?.[2]?.startsWith(".")) rule.remove();
|
|
556
|
-
});
|
|
557
|
-
return root.toString();
|
|
558
|
-
}).join("\n");
|
|
410
|
+
return (0, _weapp_tailwindcss_postcss_transform.createUniAppXHarmonyApplyGeneratorSource)(applyStyleSources);
|
|
559
411
|
}
|
|
560
412
|
function collectUniAppXHarmonyApplyUtilities(bundle) {
|
|
561
413
|
const utilities = /* @__PURE__ */ new Set();
|
|
@@ -832,57 +684,207 @@ function updateBundleBuildState(state, snapshot, linkedByEntry, options = {}) {
|
|
|
832
684
|
}
|
|
833
685
|
}
|
|
834
686
|
//#endregion
|
|
835
|
-
//#region src/bundlers/vite/
|
|
836
|
-
function
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
const
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
687
|
+
//#region src/bundlers/vite/generate-bundle/asset-emission-plan.ts
|
|
688
|
+
function applyViteAssetEmissionPlan(plan, options) {
|
|
689
|
+
for (const operation of plan.operations()) {
|
|
690
|
+
if (operation.kind === "delete") {
|
|
691
|
+
delete options.bundle[operation.assetId];
|
|
692
|
+
continue;
|
|
693
|
+
}
|
|
694
|
+
const writeTarget = options.writeTargets?.get(operation.assetId);
|
|
695
|
+
const existing = options.bundle[operation.assetId];
|
|
696
|
+
const asset = writeTarget ?? (existing?.type === "asset" ? existing : void 0);
|
|
697
|
+
if (asset) {
|
|
698
|
+
asset.source = operation.source;
|
|
699
|
+
continue;
|
|
700
|
+
}
|
|
701
|
+
const replayAsset = options.emitOrReplayAsset?.(operation.assetId, operation.source);
|
|
702
|
+
if (replayAsset) options.bundle[operation.assetId] = replayAsset;
|
|
849
703
|
}
|
|
850
704
|
}
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
const
|
|
855
|
-
return (
|
|
705
|
+
//#endregion
|
|
706
|
+
//#region src/bundlers/vite/generate-bundle/root-style-output.ts
|
|
707
|
+
function isRootMiniProgramStyleOutputFile$1(file) {
|
|
708
|
+
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
709
|
+
return !normalized.includes("/") && /\.(?:wxss|acss|ttss|qss|jxss|tyss)$/i.test(normalized);
|
|
856
710
|
}
|
|
857
|
-
function
|
|
858
|
-
|
|
859
|
-
const
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
711
|
+
function createRelativeCssImportRequest$1(targetFile, importedFile) {
|
|
712
|
+
const normalizedTargetFile = require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile.replace(/[?#].*$/, ""));
|
|
713
|
+
const normalizedImportedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(importedFile.replace(/[?#].*$/, ""));
|
|
714
|
+
const targetDir = node_path.default.posix.dirname(normalizedTargetFile);
|
|
715
|
+
const baseDir = targetDir === "." ? "" : targetDir;
|
|
716
|
+
const relative = node_path.default.posix.relative(baseDir, normalizedImportedFile);
|
|
717
|
+
return relative.startsWith(".") ? relative : `./${relative}`;
|
|
863
718
|
}
|
|
864
|
-
function
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
return require_web.appendCss(missingImports.join("\n"), filtered);
|
|
870
|
-
}
|
|
871
|
-
function removeCommentOnlyAtRules(css) {
|
|
872
|
-
if (!require_final_css_cleanup.hasEmptyCssBlockCandidate(css)) return css;
|
|
719
|
+
function createCssImportShell$1(targetFile, importedFile) {
|
|
720
|
+
return `@import "${createRelativeCssImportRequest$1(targetFile, importedFile)}";\n`;
|
|
721
|
+
}
|
|
722
|
+
function resolveSingleCssImportOutputFile(targetFile, css) {
|
|
723
|
+
let importedFile;
|
|
873
724
|
try {
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
if (!
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
725
|
+
_weapp_tailwindcss_postcss_transform.postcss.parse(css).walkAtRules("import", (atRule) => {
|
|
726
|
+
if (importedFile !== void 0) return;
|
|
727
|
+
const request = (0, _weapp_tailwindcss_postcss_transform.parseImportRequest)(atRule.params);
|
|
728
|
+
if (!request || /^(?:https?:)?\/\//i.test(request) || request.startsWith("data:")) return;
|
|
729
|
+
const cleanRequest = request.replace(/[?#].*$/, "");
|
|
730
|
+
if (!/\.(?:css|wxss|acss|ttss|qss|jxss|tyss)$/i.test(cleanRequest)) return;
|
|
731
|
+
const targetDir = node_path.default.posix.dirname(require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile));
|
|
732
|
+
importedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.posix.join(targetDir === "." ? "" : targetDir, cleanRequest));
|
|
881
733
|
});
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
734
|
+
} catch {}
|
|
735
|
+
return importedFile;
|
|
736
|
+
}
|
|
737
|
+
function createRootMiniProgramOriginStyleOutputFile(file) {
|
|
738
|
+
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
739
|
+
if (/(?:^|\/)[^/]+-origin\.[^.]+$/i.test(normalized)) return normalized;
|
|
740
|
+
return normalized.replace(/(\.[^.]+)$/, "-origin$1");
|
|
741
|
+
}
|
|
742
|
+
function shouldKeepRootMiniProgramStyleAsImportShell(enabled) {
|
|
743
|
+
return enabled === true;
|
|
744
|
+
}
|
|
745
|
+
function shouldPreserveFrameworkRootMiniProgramImportShell(options) {
|
|
746
|
+
return !options.isWebGeneratorTarget && options.matchesCss && require_web.isRootStyleOutputFile(options.file) && (0, _weapp_tailwindcss_postcss_transform.isPureLocalCssImportWrapper)(options.css) && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep());
|
|
747
|
+
}
|
|
748
|
+
function resolveFrameworkRootImportShellPlan(options) {
|
|
749
|
+
const isCurrentImportShell = shouldPreserveFrameworkRootMiniProgramImportShell({
|
|
750
|
+
css: options.rawSource,
|
|
751
|
+
file: options.rootImportShellOutputFile,
|
|
752
|
+
isWebGeneratorTarget: options.isWebGeneratorTarget,
|
|
753
|
+
matchesCss: options.matchesCss,
|
|
754
|
+
shouldKeep: options.shouldKeep
|
|
755
|
+
});
|
|
756
|
+
if (isCurrentImportShell) {
|
|
757
|
+
const importedFile = resolveSingleCssImportOutputFile(options.rootImportShellOutputFile, options.rawSource);
|
|
758
|
+
return {
|
|
759
|
+
isCurrentImportShell,
|
|
760
|
+
reusableTarget: options.rememberedTarget,
|
|
761
|
+
targetToRemember: importedFile && require_web.isRootStyleOutputFile(importedFile) ? importedFile : void 0
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
if (options.rememberedTarget) return {
|
|
765
|
+
isCurrentImportShell,
|
|
766
|
+
reusableTarget: options.rememberedTarget,
|
|
767
|
+
targetToRemember: void 0
|
|
768
|
+
};
|
|
769
|
+
if (!(!options.isWebGeneratorTarget && isRootMiniProgramStyleOutputFile$1(options.rootImportShellOutputFile) && require_source_candidate_scan_signature.normalizeOutputPathKey(options.assetSourceFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(options.file) && options.isMainChunk && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep()) && !shouldMoveRootMiniProgramStyleToImportShellOrigin(options.shouldMoveToOrigin()))) return {
|
|
770
|
+
isCurrentImportShell,
|
|
771
|
+
reusableTarget: void 0,
|
|
772
|
+
targetToRemember: void 0
|
|
773
|
+
};
|
|
774
|
+
const targets = new Set([...options.configuredTargetFiles, ...options.processedTargetFiles].filter((file) => typeof file === "string" && isRootMiniProgramStyleOutputFile$1(file) && require_source_candidate_scan_signature.normalizeOutputPathKey(file) !== require_source_candidate_scan_signature.normalizeOutputPathKey(options.rootImportShellOutputFile)));
|
|
775
|
+
const target = targets.size === 1 ? [...targets][0] : void 0;
|
|
776
|
+
return {
|
|
777
|
+
isCurrentImportShell,
|
|
778
|
+
reusableTarget: target,
|
|
779
|
+
targetToRemember: target
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
function restoreFrameworkRootMiniProgramImportShellAssets(bundle, options) {
|
|
783
|
+
if (options.isWebGeneratorTarget || options.targetByFile.size === 0) return 0;
|
|
784
|
+
const plan = new require_compiler.AssetEmissionPlan();
|
|
785
|
+
const writeTargets = /* @__PURE__ */ new Map();
|
|
786
|
+
let restored = 0;
|
|
787
|
+
for (const [sourceFile, targetFile] of options.targetByFile) {
|
|
788
|
+
if (!options.matchesCss(sourceFile) || !options.matchesCss(targetFile) || !require_web.isRootStyleOutputFile(sourceFile) || !require_web.isRootStyleOutputFile(targetFile) || require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile)) continue;
|
|
789
|
+
const output = Object.entries(bundle).find(([bundleFile, candidate]) => candidate.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey(candidate.fileName || bundleFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile))?.[1];
|
|
790
|
+
if (output?.type !== "asset") continue;
|
|
791
|
+
const rawSource = output.source.toString();
|
|
792
|
+
if (!shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep(sourceFile, rawSource))) continue;
|
|
793
|
+
const nextSource = createCssImportShell$1(sourceFile, targetFile);
|
|
794
|
+
if (rawSource === nextSource) continue;
|
|
795
|
+
plan.write(sourceFile, nextSource);
|
|
796
|
+
writeTargets.set(sourceFile, output);
|
|
797
|
+
options.recordCssAssetResult?.(sourceFile, nextSource);
|
|
798
|
+
options.onUpdate?.(sourceFile, rawSource, nextSource);
|
|
799
|
+
options.debug?.("restore framework root css import shell: %s -> %s", sourceFile, targetFile);
|
|
800
|
+
restored++;
|
|
885
801
|
}
|
|
802
|
+
applyViteAssetEmissionPlan(plan, {
|
|
803
|
+
bundle,
|
|
804
|
+
writeTargets
|
|
805
|
+
});
|
|
806
|
+
return restored;
|
|
807
|
+
}
|
|
808
|
+
function resolveRuntimeRootStyleOutputFile(bundle, matchesCss) {
|
|
809
|
+
const rootChunks = Object.entries(bundle).flatMap(([bundleFile, output]) => {
|
|
810
|
+
if (output.type !== "chunk") return [];
|
|
811
|
+
const file = require_source_candidate_scan_signature.normalizeOutputPathKey(output.fileName || bundleFile);
|
|
812
|
+
if (file.includes("/")) return [];
|
|
813
|
+
return [{
|
|
814
|
+
file,
|
|
815
|
+
isEntry: output.isEntry === true
|
|
816
|
+
}];
|
|
817
|
+
});
|
|
818
|
+
const entryChunks = rootChunks.filter((chunk) => chunk.isEntry);
|
|
819
|
+
const rootChunkStems = new Set((entryChunks.length > 0 ? entryChunks : rootChunks).map((chunk) => node_path.default.posix.parse(chunk.file).name));
|
|
820
|
+
const candidates = Object.entries(bundle).flatMap(([bundleFile, output]) => {
|
|
821
|
+
if (output.type !== "asset") return [];
|
|
822
|
+
const file = require_source_candidate_scan_signature.normalizeOutputPathKey(output.fileName || bundleFile);
|
|
823
|
+
return isRootMiniProgramStyleOutputFile$1(file) && matchesCss(file) && rootChunkStems.has(node_path.default.posix.parse(file).name) ? [file] : [];
|
|
824
|
+
});
|
|
825
|
+
return candidates.length === 1 ? candidates[0] : void 0;
|
|
826
|
+
}
|
|
827
|
+
function linkFrameworkRootStyleToRuntimeEntry(bundle, options) {
|
|
828
|
+
if (options.targetByFile.size === 0) return 0;
|
|
829
|
+
const runtimeRootFile = resolveRuntimeRootStyleOutputFile(bundle, options.matchesCss);
|
|
830
|
+
if (!runtimeRootFile) return 0;
|
|
831
|
+
const frameworkRootFiles = [...options.targetByFile.keys()].filter((file) => require_source_candidate_scan_signature.normalizeOutputPathKey(file) !== require_source_candidate_scan_signature.normalizeOutputPathKey(runtimeRootFile) && isRootMiniProgramStyleOutputFile$1(file) && options.matchesCss(file));
|
|
832
|
+
if (frameworkRootFiles.length !== 1) return 0;
|
|
833
|
+
const frameworkRootFile = frameworkRootFiles[0];
|
|
834
|
+
const runtimeOutput = Object.entries(bundle).find(([bundleFile, output]) => output.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey(output.fileName || bundleFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(runtimeRootFile))?.[1];
|
|
835
|
+
const frameworkOutput = Object.entries(bundle).find(([bundleFile, output]) => output.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey(output.fileName || bundleFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(frameworkRootFile))?.[1];
|
|
836
|
+
if (runtimeOutput?.type !== "asset" || frameworkOutput?.type !== "asset") return 0;
|
|
837
|
+
const runtimeSource = runtimeOutput.source.toString();
|
|
838
|
+
const importedRuntimeFile = resolveSingleCssImportOutputFile(runtimeRootFile, runtimeSource);
|
|
839
|
+
if (importedRuntimeFile && require_source_candidate_scan_signature.normalizeOutputPathKey(importedRuntimeFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(frameworkRootFile)) return 0;
|
|
840
|
+
const importedFrameworkFile = resolveSingleCssImportOutputFile(frameworkRootFile, frameworkOutput.source.toString());
|
|
841
|
+
if (importedFrameworkFile && require_source_candidate_scan_signature.normalizeOutputPathKey(importedFrameworkFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(runtimeRootFile)) return 0;
|
|
842
|
+
const nextSource = `${createCssImportShell$1(runtimeRootFile, frameworkRootFile)}${runtimeSource}`;
|
|
843
|
+
runtimeOutput.source = nextSource;
|
|
844
|
+
options.recordCssAssetResult?.(runtimeRootFile, nextSource);
|
|
845
|
+
options.onUpdate?.(runtimeRootFile, runtimeSource, nextSource);
|
|
846
|
+
options.debug?.("link framework root css to runtime entry: %s -> %s", runtimeRootFile, frameworkRootFile);
|
|
847
|
+
return 1;
|
|
848
|
+
}
|
|
849
|
+
function shouldMoveRootMiniProgramStyleToImportShellOrigin(enabled) {
|
|
850
|
+
return enabled === true;
|
|
851
|
+
}
|
|
852
|
+
//#endregion
|
|
853
|
+
//#region src/bundlers/vite/generate-bundle/framework-style-memory.ts
|
|
854
|
+
function createFrameworkStyleMemory(targetByFile) {
|
|
855
|
+
const sources = /* @__PURE__ */ new Map();
|
|
856
|
+
return { prepare(bundle, removedFiles) {
|
|
857
|
+
for (const file of removedFiles) {
|
|
858
|
+
const key = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
859
|
+
sources.delete(key);
|
|
860
|
+
for (const [source, target] of targetByFile) if (require_source_candidate_scan_signature.normalizeOutputPathKey(source) === key || require_source_candidate_scan_signature.normalizeOutputPathKey(target) === key) {
|
|
861
|
+
sources.delete(require_source_candidate_scan_signature.normalizeOutputPathKey(source));
|
|
862
|
+
targetByFile.delete(source);
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
const currentFiles = new Set(Object.entries(bundle).map(([file, asset]) => require_source_candidate_scan_signature.normalizeOutputPathKey(asset.fileName || file)));
|
|
866
|
+
for (const [file, asset] of sources) if (!currentFiles.has(file)) bundle[file] = { ...asset };
|
|
867
|
+
const inputs = /* @__PURE__ */ new Map();
|
|
868
|
+
for (const [file, asset] of Object.entries(bundle)) {
|
|
869
|
+
if (asset.type !== "asset" || !isRootMiniProgramStyleOutputFile$1(asset.fileName || file)) continue;
|
|
870
|
+
const source = typeof asset.source === "string" ? asset.source : node_buffer.Buffer.from(asset.source).toString();
|
|
871
|
+
if ((0, _weapp_tailwindcss_postcss_transform.hasBundlerGeneratedCssMarker)(source)) sources.delete(require_source_candidate_scan_signature.normalizeOutputPathKey(asset.fileName || file));
|
|
872
|
+
else inputs.set(require_source_candidate_scan_signature.normalizeOutputPathKey(asset.fileName || file), {
|
|
873
|
+
...asset,
|
|
874
|
+
source
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
return () => {
|
|
878
|
+
const mappedFiles = new Set([...targetByFile.keys()].map(require_source_candidate_scan_signature.normalizeOutputPathKey));
|
|
879
|
+
for (const file of sources.keys()) if (!mappedFiles.has(file)) sources.delete(file);
|
|
880
|
+
for (const [file, asset] of inputs) if (mappedFiles.has(file)) sources.set(file, asset);
|
|
881
|
+
};
|
|
882
|
+
} };
|
|
883
|
+
}
|
|
884
|
+
//#endregion
|
|
885
|
+
//#region src/bundlers/vite/processed-css-assets/cleanup.ts
|
|
886
|
+
function restoreCssImportAtRules(source, filtered, file) {
|
|
887
|
+
return (0, _weapp_tailwindcss_postcss_transform.restoreProcessedCssImports)(source, filtered, file !== void 0 && require_web.isMiniProgramStyleOutputFile(file));
|
|
886
888
|
}
|
|
887
889
|
function collectImportedBundleCssSources(bundle, importedStyleFiles) {
|
|
888
890
|
if (importedStyleFiles.size === 0) return [];
|
|
@@ -959,16 +961,7 @@ function findBundleAssetByOutputFile(bundle, file) {
|
|
|
959
961
|
function isCssImportOnlyBundleAsset(bundle, file, css) {
|
|
960
962
|
const importedStyleFiles = require_web.collectImportedStyleFiles(css, file);
|
|
961
963
|
if (importedStyleFiles.size === 0) return false;
|
|
962
|
-
|
|
963
|
-
try {
|
|
964
|
-
_weapp_tailwindcss_postcss.postcss.parse(css).each((node) => {
|
|
965
|
-
if (node.type === "comment") return;
|
|
966
|
-
if (node.type !== "atrule" || node.name !== "import") hasNonImportNode = true;
|
|
967
|
-
});
|
|
968
|
-
} catch {
|
|
969
|
-
return false;
|
|
970
|
-
}
|
|
971
|
-
if (hasNonImportNode) return false;
|
|
964
|
+
if (!(0, _weapp_tailwindcss_postcss_transform.isCssImportOnly)(css)) return false;
|
|
972
965
|
return collectImportedBundleCssSources(bundle, importedStyleFiles).length > 0;
|
|
973
966
|
}
|
|
974
967
|
function isCoveredViteGeneratedSourceAsset(file, existingAssetFiles, resolveViteProcessedCssOutputFile) {
|
|
@@ -1063,533 +1056,49 @@ function collectMiniProgramSubpackageSourceEntries(snapshot, subpackageRoots, so
|
|
|
1063
1056
|
return sourceEntries;
|
|
1064
1057
|
}
|
|
1065
1058
|
//#endregion
|
|
1066
|
-
//#region src/bundlers/vite/processed-css-assets/scoped-tailwind-noise.ts
|
|
1067
|
-
const VUE_SCOPED_ATTR_RE = /\[data-v-[^\]]+\]/gi;
|
|
1068
|
-
const VUE_SCOPED_CLASS_RE = /\.data-v-[\w-]+/gi;
|
|
1069
|
-
const SCOPED_UNIVERSAL_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
|
|
1070
|
-
"*",
|
|
1071
|
-
":after",
|
|
1072
|
-
":before",
|
|
1073
|
-
"::after",
|
|
1074
|
-
"::before",
|
|
1075
|
-
"::backdrop",
|
|
1076
|
-
"::file-selector-button"
|
|
1077
|
-
]);
|
|
1078
|
-
const MINI_PROGRAM_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
|
|
1079
|
-
"view",
|
|
1080
|
-
"text",
|
|
1081
|
-
"::after",
|
|
1082
|
-
"::before"
|
|
1083
|
-
]);
|
|
1084
|
-
const UNI_APP_WEB_PREFLIGHT_SELECTORS = /* @__PURE__ */ new Set([
|
|
1085
|
-
"uni-view",
|
|
1086
|
-
"uni-text",
|
|
1087
|
-
":after",
|
|
1088
|
-
":before",
|
|
1089
|
-
"::after",
|
|
1090
|
-
"::before"
|
|
1091
|
-
]);
|
|
1092
|
-
const MINI_PROGRAM_PREFLIGHT_DECLARATIONS = /* @__PURE__ */ new Set([
|
|
1093
|
-
"box-sizing",
|
|
1094
|
-
"margin",
|
|
1095
|
-
"padding",
|
|
1096
|
-
"border"
|
|
1097
|
-
]);
|
|
1098
|
-
const TAILWIND_PREFLIGHT_DECLARATIONS = /* @__PURE__ */ new Set([
|
|
1099
|
-
"-moz-tab-size:4",
|
|
1100
|
-
"-webkit-appearance:none",
|
|
1101
|
-
"-webkit-appearance:button",
|
|
1102
|
-
"-webkit-tap-highlight-color:transparent",
|
|
1103
|
-
"-webkit-text-decoration:inherit",
|
|
1104
|
-
"-webkit-text-decoration:underline dotted",
|
|
1105
|
-
"-webkit-text-size-adjust:100%",
|
|
1106
|
-
"-o-tab-size:4",
|
|
1107
|
-
"appearance:button",
|
|
1108
|
-
"background-color:transparent",
|
|
1109
|
-
"border-collapse:collapse",
|
|
1110
|
-
"border-color:inherit",
|
|
1111
|
-
"border-radius:0",
|
|
1112
|
-
"border-top-width:1px",
|
|
1113
|
-
"bottom:-.25em",
|
|
1114
|
-
"color:inherit",
|
|
1115
|
-
"display:block",
|
|
1116
|
-
"display:inline-flex",
|
|
1117
|
-
"display:list-item",
|
|
1118
|
-
"font:inherit",
|
|
1119
|
-
"font-family:inherit",
|
|
1120
|
-
"font-feature-settings:inherit",
|
|
1121
|
-
"font-size:1em",
|
|
1122
|
-
"font-size:75%",
|
|
1123
|
-
"font-size:80%",
|
|
1124
|
-
"font-size:inherit",
|
|
1125
|
-
"font-variation-settings:inherit",
|
|
1126
|
-
"font-weight:bolder",
|
|
1127
|
-
"font-weight:inherit",
|
|
1128
|
-
"height:0",
|
|
1129
|
-
"height:auto",
|
|
1130
|
-
"letter-spacing:inherit",
|
|
1131
|
-
"line-height:1",
|
|
1132
|
-
"line-height:1.5",
|
|
1133
|
-
"line-height:0",
|
|
1134
|
-
"line-height:inherit",
|
|
1135
|
-
"list-style:none",
|
|
1136
|
-
"margin-inline-end:4px",
|
|
1137
|
-
"max-width:100%",
|
|
1138
|
-
"min-height:1lh",
|
|
1139
|
-
"opacity:1",
|
|
1140
|
-
"outline:auto",
|
|
1141
|
-
"padding:0",
|
|
1142
|
-
"padding-block:0",
|
|
1143
|
-
"position:relative",
|
|
1144
|
-
"resize:vertical",
|
|
1145
|
-
"tab-size:4",
|
|
1146
|
-
"text-align:inherit",
|
|
1147
|
-
"text-decoration:inherit",
|
|
1148
|
-
"text-decoration:underline dotted",
|
|
1149
|
-
"text-indent:0",
|
|
1150
|
-
"text-transform:none",
|
|
1151
|
-
"top:-.5em",
|
|
1152
|
-
"vertical-align:baseline",
|
|
1153
|
-
"vertical-align:middle"
|
|
1154
|
-
]);
|
|
1155
|
-
function hasVueScopedAttr(value) {
|
|
1156
|
-
VUE_SCOPED_ATTR_RE.lastIndex = 0;
|
|
1157
|
-
VUE_SCOPED_CLASS_RE.lastIndex = 0;
|
|
1158
|
-
const matched = VUE_SCOPED_ATTR_RE.test(value) || VUE_SCOPED_CLASS_RE.test(value);
|
|
1159
|
-
VUE_SCOPED_ATTR_RE.lastIndex = 0;
|
|
1160
|
-
VUE_SCOPED_CLASS_RE.lastIndex = 0;
|
|
1161
|
-
return matched;
|
|
1162
|
-
}
|
|
1163
|
-
function normalizeCssSignatureValue(value) {
|
|
1164
|
-
return value.replace(VUE_SCOPED_ATTR_RE, "").replace(VUE_SCOPED_CLASS_RE, "").replace(/\s+/g, " ").replace(/\s*([>+~])\s*/g, "$1").replace(/\(\s+/g, "(").replace(/\s+\)/g, ")").trim();
|
|
1165
|
-
}
|
|
1166
|
-
function hasClassSelector(selector) {
|
|
1167
|
-
return /(?:^|[^\\])\.[_a-z\u00A0-\uFFFF-]/i.test(normalizeCssSignatureValue(selector));
|
|
1168
|
-
}
|
|
1169
|
-
function isLikelyTailwindGlobalSelector(selector) {
|
|
1170
|
-
const normalized = normalizeCssSignatureValue(selector);
|
|
1171
|
-
return normalized === "*" || normalized.startsWith("::") || normalized.startsWith(":root") || normalized.startsWith(":host") || /^(?:html|body|hr|abbr|h1|h2|h3|h4|h5|h6|a|b|strong|code|kbd|samp|pre|small|sub|sup|table|button|input|select|optgroup|textarea|summary|blockquote|dl|dd|fieldset|legend|ol|ul|menu|dialog|progress|video|audio|canvas|embed|iframe|img|object|svg|details|template|[uo]ni-progress)(?:$|[:,[\s>+~.#])/.test(normalized);
|
|
1172
|
-
}
|
|
1173
|
-
function isTailwindPreflightDeclaration(decl) {
|
|
1174
|
-
const prop = decl.prop.trim().toLowerCase();
|
|
1175
|
-
const value = normalizeCssSignatureValue(decl.value.trim().toLowerCase());
|
|
1176
|
-
if (prop.startsWith("--tw-")) return true;
|
|
1177
|
-
if (prop === "color" && value.startsWith("color-mix(") && value.includes("currentcolor") && value.includes("transparent")) return true;
|
|
1178
|
-
if (prop === "color" && value === "currentcolor") return true;
|
|
1179
|
-
if (prop === "font-family" && value.startsWith("var(--default-font-family") || prop === "font-feature-settings" && value.startsWith("var(--default-font-feature-settings") || prop === "font-variation-settings" && value.startsWith("var(--default-font-variation-settings")) return true;
|
|
1180
|
-
return TAILWIND_PREFLIGHT_DECLARATIONS.has(`${prop}:${value}`);
|
|
1181
|
-
}
|
|
1182
|
-
function getRuleDeclarations(rule) {
|
|
1183
|
-
return rule.nodes?.filter((node) => node.type === "decl") ?? [];
|
|
1184
|
-
}
|
|
1185
|
-
function isScopedTailwindThemeCarrierRule(rule) {
|
|
1186
|
-
const selectors = rule.selectors ?? [rule.selector];
|
|
1187
|
-
const declarations = getRuleDeclarations(rule);
|
|
1188
|
-
return selectors.length > 0 && selectors.every((selector) => {
|
|
1189
|
-
const normalized = normalizeCssSignatureValue(selector);
|
|
1190
|
-
return hasVueScopedAttr(selector) && (normalized.startsWith(":root") || normalized.startsWith(":host"));
|
|
1191
|
-
}) && declarations.length > 0 && declarations.every((decl) => decl.prop.startsWith("--"));
|
|
1192
|
-
}
|
|
1193
|
-
function isScopedUniversalTailwindPreflightRule(rule) {
|
|
1194
|
-
const selectors = rule.selectors ?? [rule.selector];
|
|
1195
|
-
const declarations = getRuleDeclarations(rule);
|
|
1196
|
-
return selectors.length > 0 && selectors.every((selector) => hasVueScopedAttr(selector) && SCOPED_UNIVERSAL_PREFLIGHT_SELECTORS.has(normalizeCssSignatureValue(selector))) && declarations.length > 0 && declarations.every((decl) => decl.prop.startsWith("--tw-") || MINI_PROGRAM_PREFLIGHT_DECLARATIONS.has(decl.prop));
|
|
1197
|
-
}
|
|
1198
|
-
function isScopedUniAppWebTailwindPreflightRule(rule) {
|
|
1199
|
-
const selectors = rule.selectors ?? [rule.selector];
|
|
1200
|
-
const declarations = getRuleDeclarations(rule);
|
|
1201
|
-
return selectors.length > 0 && selectors.every((selector) => hasVueScopedAttr(selector) && UNI_APP_WEB_PREFLIGHT_SELECTORS.has(normalizeCssSignatureValue(selector))) && declarations.length > 0 && declarations.every((decl) => decl.prop.startsWith("--tw-") || MINI_PROGRAM_PREFLIGHT_DECLARATIONS.has(decl.prop));
|
|
1202
|
-
}
|
|
1203
|
-
function isLikelyTailwindGlobalRule(rule) {
|
|
1204
|
-
const selectors = rule.selectors ?? [rule.selector];
|
|
1205
|
-
const declarations = getRuleDeclarations(rule);
|
|
1206
|
-
return isScopedTailwindThemeCarrierRule(rule) || isScopedUniversalTailwindPreflightRule(rule) || isScopedUniAppWebTailwindPreflightRule(rule) || selectors.every((selector) => !hasClassSelector(selector) && isLikelyTailwindGlobalSelector(selector)) && declarations.length > 0 && declarations.every(isTailwindPreflightDeclaration);
|
|
1207
|
-
}
|
|
1208
|
-
function isLikelyTailwindPropertyAtRule(atRule) {
|
|
1209
|
-
return atRule.name.toLowerCase() === "property" && normalizeCssSignatureValue(atRule.params).startsWith("--tw-");
|
|
1210
|
-
}
|
|
1211
|
-
function isLikelyTailwindLayerOrderAtRule(atRule) {
|
|
1212
|
-
if (atRule.name.toLowerCase() !== "layer" || atRule.nodes !== void 0) return false;
|
|
1213
|
-
const params = normalizeCssSignatureValue(atRule.params).replace(/\s+/g, "");
|
|
1214
|
-
return params === "properties" || params === "theme" || params === "base" || params === "theme,base,components,utilities";
|
|
1215
|
-
}
|
|
1216
|
-
function isUnscopedMiniProgramTailwindPreflightRule(rule) {
|
|
1217
|
-
const selectors = rule.selectors ?? [rule.selector];
|
|
1218
|
-
if (selectors.length === 0 || !selectors.every((selector) => {
|
|
1219
|
-
const normalized = normalizeCssSignatureValue(selector);
|
|
1220
|
-
return !hasVueScopedAttr(selector) && MINI_PROGRAM_PREFLIGHT_SELECTORS.has(normalized);
|
|
1221
|
-
})) return false;
|
|
1222
|
-
const declarations = getRuleDeclarations(rule);
|
|
1223
|
-
return declarations.length > 0 && declarations.every((decl) => decl.prop.startsWith("--tw-") || MINI_PROGRAM_PREFLIGHT_DECLARATIONS.has(decl.prop));
|
|
1224
|
-
}
|
|
1225
|
-
function isScopedMiniProgramTailwindContentInitRule(rule) {
|
|
1226
|
-
const selectors = rule.selectors ?? [rule.selector];
|
|
1227
|
-
if (selectors.length === 0 || !selectors.every((selector) => {
|
|
1228
|
-
const normalized = normalizeCssSignatureValue(selector);
|
|
1229
|
-
return hasVueScopedAttr(selector) && MINI_PROGRAM_PREFLIGHT_SELECTORS.has(normalized);
|
|
1230
|
-
})) return false;
|
|
1231
|
-
const declarations = getRuleDeclarations(rule);
|
|
1232
|
-
return declarations.length > 0 && declarations.every((decl) => decl.prop === "--tw-content");
|
|
1233
|
-
}
|
|
1234
|
-
//#endregion
|
|
1235
1059
|
//#region src/bundlers/vite/processed-css-assets/coverage.ts
|
|
1236
|
-
function createDeclarationSignature(rule) {
|
|
1237
|
-
return createDeclarationKeys(rule).sort().join(";");
|
|
1238
|
-
}
|
|
1239
|
-
function createRuleCoverageKey(selector, declarations) {
|
|
1240
|
-
return `${normalizeCssSignatureValue(selector)}\0${declarations}`;
|
|
1241
|
-
}
|
|
1242
|
-
function createDeclarationKeys(rule) {
|
|
1243
|
-
return (rule.nodes ?? []).filter((node) => node.type === "decl").map((node) => `${node.prop}:${normalizeCssSignatureValue(node.value)}${node.important ? "!important" : ""}`);
|
|
1244
|
-
}
|
|
1245
|
-
function createAtRuleCoverageKey(atRule) {
|
|
1246
|
-
return `${atRule.name}\0${normalizeCssSignatureValue(atRule.params)}\0${normalizeCssSignatureValue(atRule.toString())}`;
|
|
1247
|
-
}
|
|
1248
|
-
function collectRootScopedComparableCssCoverage(cssSources) {
|
|
1249
|
-
const rules = /* @__PURE__ */ new Set();
|
|
1250
|
-
const atRules = /* @__PURE__ */ new Set();
|
|
1251
|
-
const declarationsBySelector = /* @__PURE__ */ new Map();
|
|
1252
|
-
const normalizedRuleCss = /* @__PURE__ */ new Set();
|
|
1253
|
-
for (const source of cssSources) try {
|
|
1254
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1255
|
-
root.walkRules((rule) => {
|
|
1256
|
-
normalizedRuleCss.add(normalizeCssSignatureValue(rule.toString()));
|
|
1257
|
-
const declarations = createDeclarationSignature(rule);
|
|
1258
|
-
if (declarations.length === 0) return;
|
|
1259
|
-
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
1260
|
-
const normalizedSelector = normalizeCssSignatureValue(selector);
|
|
1261
|
-
rules.add(`${normalizedSelector}\0${declarations}`);
|
|
1262
|
-
const selectorDeclarations = declarationsBySelector.get(normalizedSelector) ?? /* @__PURE__ */ new Set();
|
|
1263
|
-
for (const declaration of createDeclarationKeys(rule)) selectorDeclarations.add(declaration);
|
|
1264
|
-
declarationsBySelector.set(normalizedSelector, selectorDeclarations);
|
|
1265
|
-
}
|
|
1266
|
-
});
|
|
1267
|
-
root.walkAtRules((atRule) => {
|
|
1268
|
-
atRules.add(createAtRuleCoverageKey(atRule));
|
|
1269
|
-
});
|
|
1270
|
-
} catch {}
|
|
1271
|
-
return {
|
|
1272
|
-
rules,
|
|
1273
|
-
atRules,
|
|
1274
|
-
declarationsBySelector,
|
|
1275
|
-
normalizedRuleCss
|
|
1276
|
-
};
|
|
1277
|
-
}
|
|
1278
1060
|
function prepareImportedCssCoverage(importedCssSources) {
|
|
1279
|
-
const sources = importedCssSources.map((source) =>
|
|
1061
|
+
const sources = importedCssSources.map((source) => (0, _weapp_tailwindcss_postcss_transform.stripBundlerGeneratedCssMarkers)(source).trim()).filter(Boolean);
|
|
1280
1062
|
if (sources.length === 0) return;
|
|
1281
1063
|
return {
|
|
1282
|
-
coverage: collectRootScopedComparableCssCoverage(sources),
|
|
1064
|
+
coverage: (0, _weapp_tailwindcss_postcss_transform.collectRootScopedComparableCssCoverage)(sources),
|
|
1283
1065
|
sources
|
|
1284
1066
|
};
|
|
1285
1067
|
}
|
|
1286
|
-
function isRuleCoveredByRootCss(rule, coverage) {
|
|
1287
|
-
const declarations = createDeclarationSignature(rule);
|
|
1288
|
-
if (declarations.length === 0) return false;
|
|
1289
|
-
const selectors = rule.selectors ?? [rule.selector];
|
|
1290
|
-
if (selectors.every((selector) => coverage.rules.has(createRuleCoverageKey(selector, declarations)))) return true;
|
|
1291
|
-
const declarationKeys = createDeclarationKeys(rule);
|
|
1292
|
-
return declarationKeys.length > 0 && selectors.every((selector) => {
|
|
1293
|
-
const rootDeclarations = coverage.declarationsBySelector.get(normalizeCssSignatureValue(selector));
|
|
1294
|
-
return rootDeclarations != null && declarationKeys.every((declaration) => rootDeclarations.has(declaration));
|
|
1295
|
-
});
|
|
1296
|
-
}
|
|
1297
|
-
function removeScopedCssCoveredByRootStyleSources(css, rootSources) {
|
|
1298
|
-
if (!hasVueScopedAttr(css)) return css;
|
|
1299
|
-
const hasScopedTailwindGeneratedCss = /tailwindcss v\d/i.test(css);
|
|
1300
|
-
const coverage = collectRootScopedComparableCssCoverage(rootSources);
|
|
1301
|
-
try {
|
|
1302
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1303
|
-
let changed = false;
|
|
1304
|
-
root.walkComments((comment) => {
|
|
1305
|
-
if (/tailwindcss v\d/i.test(comment.text)) {
|
|
1306
|
-
comment.remove();
|
|
1307
|
-
changed = true;
|
|
1308
|
-
}
|
|
1309
|
-
});
|
|
1310
|
-
root.walkRules((rule) => {
|
|
1311
|
-
if (isRuleCoveredByRootCss(rule, coverage) || hasScopedTailwindGeneratedCss && isLikelyTailwindGlobalRule(rule) || isUnscopedMiniProgramTailwindPreflightRule(rule) || isScopedMiniProgramTailwindContentInitRule(rule) || isScopedUniAppWebTailwindPreflightRule(rule) || isScopedUniversalTailwindPreflightRule(rule)) {
|
|
1312
|
-
rule.remove();
|
|
1313
|
-
changed = true;
|
|
1314
|
-
}
|
|
1315
|
-
});
|
|
1316
|
-
root.walkAtRules((atRule) => {
|
|
1317
|
-
if (coverage.atRules.has(createAtRuleCoverageKey(atRule)) || isLikelyTailwindPropertyAtRule(atRule) || isLikelyTailwindLayerOrderAtRule(atRule)) {
|
|
1318
|
-
atRule.remove();
|
|
1319
|
-
changed = true;
|
|
1320
|
-
return;
|
|
1321
|
-
}
|
|
1322
|
-
if (atRule.nodes !== void 0 && atRule.nodes.length === 0) {
|
|
1323
|
-
atRule.remove();
|
|
1324
|
-
changed = true;
|
|
1325
|
-
}
|
|
1326
|
-
});
|
|
1327
|
-
return changed ? removeDanglingCssSourceTraceComments(root.toString()).trim() : css;
|
|
1328
|
-
} catch {
|
|
1329
|
-
return css;
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
1332
|
-
function removeScopedTailwindPreflightCss(css) {
|
|
1333
|
-
return removeScopedCssCoveredByRootStyleSources(css, []);
|
|
1334
|
-
}
|
|
1335
1068
|
function collectSingleViteGeneratedCssMarkerFile(rawSource) {
|
|
1336
|
-
const blocks =
|
|
1069
|
+
const blocks = (0, _weapp_tailwindcss_postcss_transform.parseBundlerGeneratedCssMarkerBlocks)(rawSource).filter((block) => block.bundler === "vite");
|
|
1337
1070
|
if (blocks.length !== 1) return;
|
|
1338
1071
|
const file = blocks[0]?.file;
|
|
1339
1072
|
return typeof file === "string" && file.length > 0 ? file : void 0;
|
|
1340
1073
|
}
|
|
1341
|
-
function shouldFilterRootGeneratedCssMarkerForScopedAsset(targetFile, markerFile, resolveViteProcessedCssOutputFile) {
|
|
1342
|
-
const resolvedTargetFile = require_web.normalizeMarkerOutputFile(targetFile, resolveViteProcessedCssOutputFile);
|
|
1343
|
-
const resolvedMarkerFile = require_web.normalizeMarkerOutputFile(markerFile, resolveViteProcessedCssOutputFile);
|
|
1344
|
-
if (!require_web.isRootStyleOutputFile(resolvedMarkerFile) || require_web.isRootStyleOutputFile(resolvedTargetFile)) return false;
|
|
1345
|
-
return !require_web.isMatchingGeneratedCssMarkerFile(targetFile, markerFile, resolveViteProcessedCssOutputFile);
|
|
1346
|
-
}
|
|
1347
|
-
function removeCssCoveredByRootStyleBundleSources(bundle, file, css) {
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
const
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
}
|
|
1370
|
-
if (atRule.nodes !== void 0 && atRule.nodes.length === 0) {
|
|
1371
|
-
atRule.remove();
|
|
1372
|
-
changed = true;
|
|
1373
|
-
}
|
|
1374
|
-
});
|
|
1375
|
-
root.walkComments((comment) => {
|
|
1376
|
-
if (hasScopedCss && /tailwindcss v\d/i.test(comment.text)) {
|
|
1377
|
-
comment.remove();
|
|
1378
|
-
changed = true;
|
|
1379
|
-
return;
|
|
1380
|
-
}
|
|
1381
|
-
if (!comment.text.trim().startsWith("tokens:")) return;
|
|
1382
|
-
const next = comment.next();
|
|
1383
|
-
if (next?.type === "rule" || next?.type === "atrule") return;
|
|
1384
|
-
comment.remove();
|
|
1385
|
-
changed = true;
|
|
1386
|
-
});
|
|
1387
|
-
if (changed) nextCss = root.toString().trim();
|
|
1388
|
-
} catch {}
|
|
1389
|
-
return require_web.hasNonCommentCss(nextCss) ? nextCss : "";
|
|
1390
|
-
}
|
|
1391
|
-
function removeDanglingCssSourceTraceComments(css) {
|
|
1392
|
-
if (!css.includes("/* tokens:")) return css;
|
|
1393
|
-
try {
|
|
1394
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1395
|
-
let changed = false;
|
|
1396
|
-
root.each((node) => {
|
|
1397
|
-
if (node.type !== "comment" || !node.text.trim().startsWith("tokens:")) return;
|
|
1398
|
-
const next = node.next();
|
|
1399
|
-
if (next?.type === "rule" || next?.type === "atrule") return;
|
|
1400
|
-
node.remove();
|
|
1401
|
-
changed = true;
|
|
1402
|
-
});
|
|
1403
|
-
return changed ? root.toString().trim() : css;
|
|
1404
|
-
} catch {
|
|
1405
|
-
return css;
|
|
1406
|
-
}
|
|
1407
|
-
}
|
|
1408
|
-
function removeCssCoveredByRootStyleAssets(bundle, options) {
|
|
1409
|
-
let updated = 0;
|
|
1410
|
-
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
1411
|
-
if (output.type !== "asset") continue;
|
|
1412
|
-
const file = require_web.getAssetFile(bundleFile, output);
|
|
1413
|
-
const rawSource = require_web.readAssetSource(output);
|
|
1414
|
-
const hasScopedCss = hasVueScopedAttr(rawSource);
|
|
1415
|
-
const hasTailwindGeneratedCss = /tailwindcss v\d/i.test(rawSource);
|
|
1416
|
-
const shouldIncludeTailwindGeneratedCssAsset = options.includeTailwindGeneratedCssAssets === true && hasTailwindGeneratedCss && require_web.isCssOutputFile(file) && !require_web.isMiniProgramStyleOutputFile(file);
|
|
1417
|
-
if (!(options.cssMatcher(file) || hasScopedCss && require_web.isCssOutputFile(file) || shouldIncludeTailwindGeneratedCssAsset) || require_web.isRootStyleOutputFile(file) || options.isViteProcessedCssAsset?.(output, file) === true && !hasScopedCss && !shouldIncludeTailwindGeneratedCssAsset || options.subpackageRoots != null && isSubpackageOutputFile(file, options.subpackageRoots)) continue;
|
|
1418
|
-
const nextCss = removeCssCoveredByRootStyleBundleSources(bundle, file, rawSource);
|
|
1419
|
-
if (nextCss === rawSource) continue;
|
|
1420
|
-
output.source = nextCss;
|
|
1421
|
-
options.recordCssAssetResult?.(file, nextCss);
|
|
1422
|
-
options.onUpdate?.(file, rawSource, nextCss);
|
|
1423
|
-
options.debug?.("remove root-covered css rules from scoped asset: %s bytes=%d", file, nextCss.length);
|
|
1424
|
-
updated++;
|
|
1425
|
-
}
|
|
1426
|
-
return updated;
|
|
1427
|
-
}
|
|
1428
|
-
//#endregion
|
|
1429
|
-
//#region src/bundlers/vite/generate-bundle/asset-emission-plan.ts
|
|
1430
|
-
function applyViteAssetEmissionPlan(plan, options) {
|
|
1431
|
-
for (const operation of plan.operations()) {
|
|
1432
|
-
if (operation.kind === "delete") {
|
|
1433
|
-
delete options.bundle[operation.assetId];
|
|
1434
|
-
continue;
|
|
1435
|
-
}
|
|
1436
|
-
const writeTarget = options.writeTargets?.get(operation.assetId);
|
|
1437
|
-
const existing = options.bundle[operation.assetId];
|
|
1438
|
-
const asset = writeTarget ?? (existing?.type === "asset" ? existing : void 0);
|
|
1439
|
-
if (asset) {
|
|
1440
|
-
asset.source = operation.source;
|
|
1441
|
-
continue;
|
|
1442
|
-
}
|
|
1443
|
-
const replayAsset = options.emitOrReplayAsset?.(operation.assetId, operation.source);
|
|
1444
|
-
if (replayAsset) options.bundle[operation.assetId] = replayAsset;
|
|
1445
|
-
}
|
|
1446
|
-
}
|
|
1447
|
-
//#endregion
|
|
1448
|
-
//#region src/bundlers/vite/generate-bundle/root-style-output.ts
|
|
1449
|
-
function isRootMiniProgramStyleOutputFile$1(file) {
|
|
1450
|
-
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
1451
|
-
return !normalized.includes("/") && /\.(?:wxss|acss|ttss|qss|jxss|tyss)$/i.test(normalized);
|
|
1452
|
-
}
|
|
1453
|
-
function createRelativeCssImportRequest$1(targetFile, importedFile) {
|
|
1454
|
-
const normalizedTargetFile = require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile.replace(/[?#].*$/, ""));
|
|
1455
|
-
const normalizedImportedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(importedFile.replace(/[?#].*$/, ""));
|
|
1456
|
-
const targetDir = node_path.default.posix.dirname(normalizedTargetFile);
|
|
1457
|
-
const baseDir = targetDir === "." ? "" : targetDir;
|
|
1458
|
-
const relative = node_path.default.posix.relative(baseDir, normalizedImportedFile);
|
|
1459
|
-
return relative.startsWith(".") ? relative : `./${relative}`;
|
|
1460
|
-
}
|
|
1461
|
-
function createCssImportShell$1(targetFile, importedFile) {
|
|
1462
|
-
return `@import "${createRelativeCssImportRequest$1(targetFile, importedFile)}";\n`;
|
|
1463
|
-
}
|
|
1464
|
-
function resolveSingleCssImportOutputFile(targetFile, css) {
|
|
1465
|
-
let importedFile;
|
|
1466
|
-
try {
|
|
1467
|
-
_weapp_tailwindcss_postcss.postcss.parse(css).walkAtRules("import", (atRule) => {
|
|
1468
|
-
if (importedFile !== void 0) return;
|
|
1469
|
-
const request = require_generator.parseImportRequest(atRule.params);
|
|
1470
|
-
if (!request || /^(?:https?:)?\/\//i.test(request) || request.startsWith("data:")) return;
|
|
1471
|
-
const cleanRequest = request.replace(/[?#].*$/, "");
|
|
1472
|
-
if (!/\.(?:css|wxss|acss|ttss|qss|jxss|tyss)$/i.test(cleanRequest)) return;
|
|
1473
|
-
const targetDir = node_path.default.posix.dirname(require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile));
|
|
1474
|
-
importedFile = require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.posix.join(targetDir === "." ? "" : targetDir, cleanRequest));
|
|
1475
|
-
});
|
|
1476
|
-
} catch {}
|
|
1477
|
-
return importedFile;
|
|
1478
|
-
}
|
|
1479
|
-
function createRootMiniProgramOriginStyleOutputFile(file) {
|
|
1480
|
-
const normalized = require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
1481
|
-
if (/(?:^|\/)[^/]+-origin\.[^.]+$/i.test(normalized)) return normalized;
|
|
1482
|
-
return normalized.replace(/(\.[^.]+)$/, "-origin$1");
|
|
1483
|
-
}
|
|
1484
|
-
function shouldKeepRootMiniProgramStyleAsImportShell(enabled) {
|
|
1485
|
-
return enabled === true;
|
|
1486
|
-
}
|
|
1487
|
-
function shouldPreserveFrameworkRootMiniProgramImportShell(options) {
|
|
1488
|
-
return !options.isWebGeneratorTarget && options.matchesCss && require_web.isRootStyleOutputFile(options.file) && (0, _weapp_tailwindcss_postcss.isPureLocalCssImportWrapper)(options.css) && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep());
|
|
1489
|
-
}
|
|
1490
|
-
function resolveFrameworkRootImportShellPlan(options) {
|
|
1491
|
-
const isCurrentImportShell = shouldPreserveFrameworkRootMiniProgramImportShell({
|
|
1492
|
-
css: options.rawSource,
|
|
1493
|
-
file: options.rootImportShellOutputFile,
|
|
1494
|
-
isWebGeneratorTarget: options.isWebGeneratorTarget,
|
|
1495
|
-
matchesCss: options.matchesCss,
|
|
1496
|
-
shouldKeep: options.shouldKeep
|
|
1497
|
-
});
|
|
1498
|
-
if (isCurrentImportShell) {
|
|
1499
|
-
const importedFile = resolveSingleCssImportOutputFile(options.rootImportShellOutputFile, options.rawSource);
|
|
1500
|
-
return {
|
|
1501
|
-
isCurrentImportShell,
|
|
1502
|
-
reusableTarget: options.rememberedTarget,
|
|
1503
|
-
targetToRemember: importedFile && require_web.isRootStyleOutputFile(importedFile) ? importedFile : void 0
|
|
1504
|
-
};
|
|
1505
|
-
}
|
|
1506
|
-
if (options.rememberedTarget) return {
|
|
1507
|
-
isCurrentImportShell,
|
|
1508
|
-
reusableTarget: options.rememberedTarget,
|
|
1509
|
-
targetToRemember: void 0
|
|
1510
|
-
};
|
|
1511
|
-
if (!(!options.isWebGeneratorTarget && isRootMiniProgramStyleOutputFile$1(options.rootImportShellOutputFile) && require_source_candidate_scan_signature.normalizeOutputPathKey(options.assetSourceFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(options.file) && options.isMainChunk && shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep()) && !shouldMoveRootMiniProgramStyleToImportShellOrigin(options.shouldMoveToOrigin()))) return {
|
|
1512
|
-
isCurrentImportShell,
|
|
1513
|
-
reusableTarget: void 0,
|
|
1514
|
-
targetToRemember: void 0
|
|
1515
|
-
};
|
|
1516
|
-
const targets = new Set([...options.configuredTargetFiles, ...options.processedTargetFiles].filter((file) => typeof file === "string" && isRootMiniProgramStyleOutputFile$1(file) && require_source_candidate_scan_signature.normalizeOutputPathKey(file) !== require_source_candidate_scan_signature.normalizeOutputPathKey(options.rootImportShellOutputFile)));
|
|
1517
|
-
const target = targets.size === 1 ? [...targets][0] : void 0;
|
|
1518
|
-
return {
|
|
1519
|
-
isCurrentImportShell,
|
|
1520
|
-
reusableTarget: target,
|
|
1521
|
-
targetToRemember: target
|
|
1522
|
-
};
|
|
1523
|
-
}
|
|
1524
|
-
function restoreFrameworkRootMiniProgramImportShellAssets(bundle, options) {
|
|
1525
|
-
if (options.isWebGeneratorTarget || options.targetByFile.size === 0) return 0;
|
|
1526
|
-
const plan = new require_compiler.AssetEmissionPlan();
|
|
1527
|
-
const writeTargets = /* @__PURE__ */ new Map();
|
|
1528
|
-
let restored = 0;
|
|
1529
|
-
for (const [sourceFile, targetFile] of options.targetByFile) {
|
|
1530
|
-
if (!options.matchesCss(sourceFile) || !options.matchesCss(targetFile) || !require_web.isRootStyleOutputFile(sourceFile) || !require_web.isRootStyleOutputFile(targetFile) || require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile)) continue;
|
|
1531
|
-
const output = Object.entries(bundle).find(([bundleFile, candidate]) => candidate.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey(candidate.fileName || bundleFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile))?.[1];
|
|
1532
|
-
if (output?.type !== "asset") continue;
|
|
1533
|
-
const rawSource = output.source.toString();
|
|
1534
|
-
if (!shouldKeepRootMiniProgramStyleAsImportShell(options.shouldKeep(sourceFile, rawSource))) continue;
|
|
1535
|
-
const nextSource = createCssImportShell$1(sourceFile, targetFile);
|
|
1536
|
-
if (rawSource === nextSource) continue;
|
|
1537
|
-
plan.write(sourceFile, nextSource);
|
|
1538
|
-
writeTargets.set(sourceFile, output);
|
|
1539
|
-
options.recordCssAssetResult?.(sourceFile, nextSource);
|
|
1540
|
-
options.onUpdate?.(sourceFile, rawSource, nextSource);
|
|
1541
|
-
options.debug?.("restore framework root css import shell: %s -> %s", sourceFile, targetFile);
|
|
1542
|
-
restored++;
|
|
1543
|
-
}
|
|
1544
|
-
applyViteAssetEmissionPlan(plan, {
|
|
1545
|
-
bundle,
|
|
1546
|
-
writeTargets
|
|
1547
|
-
});
|
|
1548
|
-
return restored;
|
|
1549
|
-
}
|
|
1550
|
-
function resolveRuntimeRootStyleOutputFile(bundle, matchesCss) {
|
|
1551
|
-
const rootChunks = Object.entries(bundle).flatMap(([bundleFile, output]) => {
|
|
1552
|
-
if (output.type !== "chunk") return [];
|
|
1553
|
-
const file = require_source_candidate_scan_signature.normalizeOutputPathKey(output.fileName || bundleFile);
|
|
1554
|
-
if (file.includes("/")) return [];
|
|
1555
|
-
return [{
|
|
1556
|
-
file,
|
|
1557
|
-
isEntry: output.isEntry === true
|
|
1558
|
-
}];
|
|
1559
|
-
});
|
|
1560
|
-
const entryChunks = rootChunks.filter((chunk) => chunk.isEntry);
|
|
1561
|
-
const rootChunkStems = new Set((entryChunks.length > 0 ? entryChunks : rootChunks).map((chunk) => node_path.default.posix.parse(chunk.file).name));
|
|
1562
|
-
const candidates = Object.entries(bundle).flatMap(([bundleFile, output]) => {
|
|
1563
|
-
if (output.type !== "asset") return [];
|
|
1564
|
-
const file = require_source_candidate_scan_signature.normalizeOutputPathKey(output.fileName || bundleFile);
|
|
1565
|
-
return isRootMiniProgramStyleOutputFile$1(file) && matchesCss(file) && rootChunkStems.has(node_path.default.posix.parse(file).name) ? [file] : [];
|
|
1566
|
-
});
|
|
1567
|
-
return candidates.length === 1 ? candidates[0] : void 0;
|
|
1568
|
-
}
|
|
1569
|
-
function linkFrameworkRootStyleToRuntimeEntry(bundle, options) {
|
|
1570
|
-
if (options.targetByFile.size === 0) return 0;
|
|
1571
|
-
const runtimeRootFile = resolveRuntimeRootStyleOutputFile(bundle, options.matchesCss);
|
|
1572
|
-
if (!runtimeRootFile) return 0;
|
|
1573
|
-
const frameworkRootFiles = [...options.targetByFile.keys()].filter((file) => require_source_candidate_scan_signature.normalizeOutputPathKey(file) !== require_source_candidate_scan_signature.normalizeOutputPathKey(runtimeRootFile) && isRootMiniProgramStyleOutputFile$1(file) && options.matchesCss(file));
|
|
1574
|
-
if (frameworkRootFiles.length !== 1) return 0;
|
|
1575
|
-
const frameworkRootFile = frameworkRootFiles[0];
|
|
1576
|
-
const runtimeOutput = Object.entries(bundle).find(([bundleFile, output]) => output.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey(output.fileName || bundleFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(runtimeRootFile))?.[1];
|
|
1577
|
-
const frameworkOutput = Object.entries(bundle).find(([bundleFile, output]) => output.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey(output.fileName || bundleFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(frameworkRootFile))?.[1];
|
|
1578
|
-
if (runtimeOutput?.type !== "asset" || frameworkOutput?.type !== "asset") return 0;
|
|
1579
|
-
const runtimeSource = runtimeOutput.source.toString();
|
|
1580
|
-
const importedRuntimeFile = resolveSingleCssImportOutputFile(runtimeRootFile, runtimeSource);
|
|
1581
|
-
if (importedRuntimeFile && require_source_candidate_scan_signature.normalizeOutputPathKey(importedRuntimeFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(frameworkRootFile)) return 0;
|
|
1582
|
-
const importedFrameworkFile = resolveSingleCssImportOutputFile(frameworkRootFile, frameworkOutput.source.toString());
|
|
1583
|
-
if (importedFrameworkFile && require_source_candidate_scan_signature.normalizeOutputPathKey(importedFrameworkFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(runtimeRootFile)) return 0;
|
|
1584
|
-
const nextSource = `${createCssImportShell$1(runtimeRootFile, frameworkRootFile)}${runtimeSource}`;
|
|
1585
|
-
runtimeOutput.source = nextSource;
|
|
1586
|
-
options.recordCssAssetResult?.(runtimeRootFile, nextSource);
|
|
1587
|
-
options.onUpdate?.(runtimeRootFile, runtimeSource, nextSource);
|
|
1588
|
-
options.debug?.("link framework root css to runtime entry: %s -> %s", runtimeRootFile, frameworkRootFile);
|
|
1589
|
-
return 1;
|
|
1590
|
-
}
|
|
1591
|
-
function shouldMoveRootMiniProgramStyleToImportShellOrigin(enabled) {
|
|
1592
|
-
return enabled === true;
|
|
1074
|
+
function shouldFilterRootGeneratedCssMarkerForScopedAsset(targetFile, markerFile, resolveViteProcessedCssOutputFile) {
|
|
1075
|
+
const resolvedTargetFile = require_web.normalizeMarkerOutputFile(targetFile, resolveViteProcessedCssOutputFile);
|
|
1076
|
+
const resolvedMarkerFile = require_web.normalizeMarkerOutputFile(markerFile, resolveViteProcessedCssOutputFile);
|
|
1077
|
+
if (!require_web.isRootStyleOutputFile(resolvedMarkerFile) || require_web.isRootStyleOutputFile(resolvedTargetFile)) return false;
|
|
1078
|
+
return !require_web.isMatchingGeneratedCssMarkerFile(targetFile, markerFile, resolveViteProcessedCssOutputFile);
|
|
1079
|
+
}
|
|
1080
|
+
function removeCssCoveredByRootStyleBundleSources(bundle, file, css) {
|
|
1081
|
+
return (0, _weapp_tailwindcss_postcss_transform.removeCssCoveredByRootStyleSources)(css, require_web.collectRootStyleBundleCssSources(bundle, file));
|
|
1082
|
+
}
|
|
1083
|
+
function removeCssCoveredByRootStyleAssets(bundle, options) {
|
|
1084
|
+
let updated = 0;
|
|
1085
|
+
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
1086
|
+
if (output.type !== "asset") continue;
|
|
1087
|
+
const file = require_web.getAssetFile(bundleFile, output);
|
|
1088
|
+
const rawSource = require_web.readAssetSource(output);
|
|
1089
|
+
const hasScopedCss = (0, _weapp_tailwindcss_postcss_transform.hasVueScopedAttr)(rawSource);
|
|
1090
|
+
const hasTailwindGeneratedCss = /tailwindcss v\d/i.test(rawSource);
|
|
1091
|
+
const shouldIncludeTailwindGeneratedCssAsset = options.includeTailwindGeneratedCssAssets === true && hasTailwindGeneratedCss && require_web.isCssOutputFile(file) && !require_web.isMiniProgramStyleOutputFile(file);
|
|
1092
|
+
if (!(options.cssMatcher(file) || hasScopedCss && require_web.isCssOutputFile(file) || shouldIncludeTailwindGeneratedCssAsset) || require_web.isRootStyleOutputFile(file) || options.isViteProcessedCssAsset?.(output, file) === true && !hasScopedCss && !shouldIncludeTailwindGeneratedCssAsset || options.subpackageRoots != null && isSubpackageOutputFile(file, options.subpackageRoots)) continue;
|
|
1093
|
+
const nextCss = removeCssCoveredByRootStyleBundleSources(bundle, file, rawSource);
|
|
1094
|
+
if (nextCss === rawSource) continue;
|
|
1095
|
+
output.source = nextCss;
|
|
1096
|
+
options.recordCssAssetResult?.(file, nextCss);
|
|
1097
|
+
options.onUpdate?.(file, rawSource, nextCss);
|
|
1098
|
+
options.debug?.("remove root-covered css rules from scoped asset: %s bytes=%d", file, nextCss.length);
|
|
1099
|
+
updated++;
|
|
1100
|
+
}
|
|
1101
|
+
return updated;
|
|
1593
1102
|
}
|
|
1594
1103
|
//#endregion
|
|
1595
1104
|
//#region src/bundlers/vite/processed-css-assets/injection-plan.ts
|
|
@@ -1697,7 +1206,7 @@ function removeCoveredInjectedSourceAssets(bundle, targetFile, targetCss, record
|
|
|
1697
1206
|
if (removableRecords.length === 0) return 0;
|
|
1698
1207
|
const recordFileKeys = new Set(removableRecords.map((record) => require_source_candidate_scan_signature.normalizeOutputPathKey(record.file)));
|
|
1699
1208
|
const recordCss = new Set(removableRecords.map((record) => record.css.trim()));
|
|
1700
|
-
const targetMatcher = (0,
|
|
1209
|
+
const targetMatcher = (0, _weapp_tailwindcss_postcss_transform.createCssRuleMatcher)(targetCss);
|
|
1701
1210
|
let removed = 0;
|
|
1702
1211
|
for (const [candidateFile, candidateOutput] of Object.entries(bundle)) {
|
|
1703
1212
|
if (candidateOutput.type !== "asset") continue;
|
|
@@ -1706,7 +1215,7 @@ function removeCoveredInjectedSourceAssets(bundle, targetFile, targetCss, record
|
|
|
1706
1215
|
const candidateIsRootWebStyle = require_web.isRootStyleOutputFile(candidateKey) && !require_web.isMiniProgramStyleOutputFile(candidateKey);
|
|
1707
1216
|
if (candidateIsRootWebStyle && !targetIsRootWebStyle) continue;
|
|
1708
1217
|
const candidateSource = require_web.readAssetSource(candidateOutput).trim();
|
|
1709
|
-
if (!(recordFileKeys.has(candidateKey) || candidateSource.length > 0 && (recordCss.has(candidateSource) || targetMatcher.contains(candidateSource) || targetIsRootWebStyle && candidateIsRootWebStyle && !
|
|
1218
|
+
if (!(recordFileKeys.has(candidateKey) || candidateSource.length > 0 && (recordCss.has(candidateSource) || targetMatcher.contains(candidateSource) || targetIsRootWebStyle && candidateIsRootWebStyle && !(0, _weapp_tailwindcss_postcss_transform.hasNonCommentCss)(targetMatcher.filter(candidateSource).trim())))) continue;
|
|
1710
1219
|
if (candidateIsRootWebStyle) delete bundle[candidateFile];
|
|
1711
1220
|
else require_web.clearAssetSource(candidateOutput);
|
|
1712
1221
|
options.debug?.("remove injected vite-processed source css asset: %s -> %s", candidateKey, targetFile);
|
|
@@ -1716,24 +1225,7 @@ function removeCoveredInjectedSourceAssets(bundle, targetFile, targetCss, record
|
|
|
1716
1225
|
}
|
|
1717
1226
|
function removeCssCoveredByImportedViteResults(css, importedCssSources, prepared = prepareImportedCssCoverage(importedCssSources)) {
|
|
1718
1227
|
if (!prepared) return css;
|
|
1719
|
-
return restoreCssImportAtRules(css, removeCssRulesCoveredBySources(css, prepared.sources, { exactOnly: true }, prepared.coverage));
|
|
1720
|
-
}
|
|
1721
|
-
function removeCssRulesCoveredBySources(css, sources, options = {}, preparedCoverage) {
|
|
1722
|
-
if (sources.length === 0 || css.trim().length === 0) return css;
|
|
1723
|
-
const coverage = preparedCoverage ?? collectRootScopedComparableCssCoverage(sources);
|
|
1724
|
-
if (coverage.rules.size === 0 && coverage.declarationsBySelector.size === 0 && coverage.normalizedRuleCss.size === 0) return css;
|
|
1725
|
-
try {
|
|
1726
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1727
|
-
let changed = false;
|
|
1728
|
-
root.walkRules((rule) => {
|
|
1729
|
-
if (!coverage.normalizedRuleCss.has(normalizeCssSignatureValue(rule.toString())) && (options.exactOnly === true || !isRuleCoveredByRootCss(rule, coverage))) return;
|
|
1730
|
-
rule.remove();
|
|
1731
|
-
changed = true;
|
|
1732
|
-
});
|
|
1733
|
-
return changed ? root.toString() : css;
|
|
1734
|
-
} catch {
|
|
1735
|
-
return css;
|
|
1736
|
-
}
|
|
1228
|
+
return restoreCssImportAtRules(css, (0, _weapp_tailwindcss_postcss_transform.removeCssRulesCoveredBySources)(css, prepared.sources, { exactOnly: true }, prepared.coverage));
|
|
1737
1229
|
}
|
|
1738
1230
|
//#endregion
|
|
1739
1231
|
//#region src/bundlers/vite/processed-css-assets/collector.ts
|
|
@@ -1743,10 +1235,15 @@ function collectViteProcessedCssAssetResults(bundle, options) {
|
|
|
1743
1235
|
for (const [bundleFile, output] of Object.entries(bundle)) {
|
|
1744
1236
|
if (output.type !== "asset") continue;
|
|
1745
1237
|
const file = require_web.getAssetFile(bundleFile, output);
|
|
1746
|
-
if (!require_web.isCssOutputFile(file)
|
|
1238
|
+
if (!require_web.isCssOutputFile(file)) continue;
|
|
1747
1239
|
const rawSource = require_web.readAssetSource(output);
|
|
1748
|
-
let nextCss = require_web.resolveViteProcessedCssAssetSource(file, rawSource, options.resolveViteProcessedCssOutputFile);
|
|
1749
1240
|
const singleMarkerFile = collectSingleViteGeneratedCssMarkerFile(rawSource);
|
|
1241
|
+
if (singleMarkerFile) {
|
|
1242
|
+
require_web.getActiveViteSourceOutputRelationOwner()?.recordOwnedOutput(singleMarkerFile, file);
|
|
1243
|
+
options.debug?.("css marker ownership: %s -> %s", singleMarkerFile, file);
|
|
1244
|
+
}
|
|
1245
|
+
if (!options.isViteProcessedCssAsset?.(output, file)) continue;
|
|
1246
|
+
let nextCss = require_web.resolveViteProcessedCssAssetSource(file, rawSource, options.resolveViteProcessedCssOutputFile);
|
|
1750
1247
|
if (singleMarkerFile && (options.subpackageRoots == null || !isSubpackageOutputFile(file, options.subpackageRoots)) && shouldFilterRootGeneratedCssMarkerForScopedAsset(file, singleMarkerFile, options.resolveViteProcessedCssOutputFile)) nextCss = removeCssCoveredByRootStyleBundleSources(bundle, file, nextCss);
|
|
1751
1248
|
nextCss = options.transformCss?.(nextCss, file) ?? nextCss;
|
|
1752
1249
|
if (nextCss !== rawSource) {
|
|
@@ -1762,7 +1259,7 @@ function collectViteProcessedCssAssetResults(bundle, options) {
|
|
|
1762
1259
|
const targetAsset = findBundleAssetByOutputFile(bundle, resolvedOutputFile);
|
|
1763
1260
|
if (targetAsset) {
|
|
1764
1261
|
const targetRawSource = require_web.readAssetSource(targetAsset);
|
|
1765
|
-
const missingCss = (0,
|
|
1262
|
+
const missingCss = (0, _weapp_tailwindcss_postcss_transform.filterExistingCssRules)(targetRawSource, nextCss).trim();
|
|
1766
1263
|
const targetNextCss = require_web.appendCss(targetRawSource, missingCss);
|
|
1767
1264
|
if (targetNextCss !== targetRawSource) {
|
|
1768
1265
|
targetAsset.source = targetNextCss;
|
|
@@ -1858,7 +1355,7 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
1858
1355
|
}
|
|
1859
1356
|
const fileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
1860
1357
|
const mainFileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(file);
|
|
1861
|
-
const normalizedOriginalCss = measure("normalizeTarget", () => require_web.normalizeInjectableCssForTargetWithImports(transformCss(
|
|
1358
|
+
const normalizedOriginalCss = measure("normalizeTarget", () => require_web.normalizeInjectableCssForTargetWithImports(transformCss((0, _weapp_tailwindcss_postcss_transform.removeTailwindEntryDirectivesFromCss)(originalSource, options.createCssPipelineContext?.(file)?.currentGeneratorBranch?.isWeb === true), file), file));
|
|
1862
1359
|
let nextCss = normalizedOriginalCss.css;
|
|
1863
1360
|
const importedStyleFiles = normalizedOriginalCss.importedStyleFiles;
|
|
1864
1361
|
const importedBundleCssSources = collectImportedBundleCssSources(bundle, importedStyleFiles);
|
|
@@ -1879,40 +1376,40 @@ function injectViteProcessedCssIntoMainCssAssets(bundle, options) {
|
|
|
1879
1376
|
if (!shouldInjectViteProcessedCssResult(options.opts, mainFileKey, record.file, record)) continue;
|
|
1880
1377
|
if (isViteProcessedCssResultImported(record, importedStyleFiles)) continue;
|
|
1881
1378
|
targetViteCssResults.push(record);
|
|
1882
|
-
let css = measure("normalizeRecord", () => require_web.normalizeInjectableCssForTarget(
|
|
1379
|
+
let css = measure("normalizeRecord", () => require_web.normalizeInjectableCssForTarget((0, _weapp_tailwindcss_postcss_transform.stripBundlerGeneratedCssMarkers)(record.css).trim(), file).trim());
|
|
1883
1380
|
css = measure("importCoverage", () => removeCssCoveredByImportedViteResults(css, importedCssSources, importedCssCoverage).trim());
|
|
1884
1381
|
if (css.length === 0) continue;
|
|
1885
|
-
const mergedLayerCss = measure("mergeLayers", () =>
|
|
1382
|
+
const mergedLayerCss = measure("mergeLayers", () => (0, _weapp_tailwindcss_postcss_transform.mergeMarkedUserLayerComponentsCss)(nextCss, css));
|
|
1886
1383
|
if (mergedLayerCss.merged) {
|
|
1887
1384
|
nextCss = mergedLayerCss.css;
|
|
1888
|
-
css =
|
|
1385
|
+
css = (0, _weapp_tailwindcss_postcss_transform.extractMarkedUserLayerComponentsCss)(css).rest.trim();
|
|
1889
1386
|
if (css.length === 0) continue;
|
|
1890
1387
|
}
|
|
1891
|
-
const mergedPreflightDeclarations = measure("mergePreflight", () => (0,
|
|
1388
|
+
const mergedPreflightDeclarations = measure("mergePreflight", () => (0, _weapp_tailwindcss_postcss_transform.mergeMiniProgramPreflightRuleDeclarations)(nextCss, css));
|
|
1892
1389
|
if (mergedPreflightDeclarations.changed) {
|
|
1893
1390
|
nextCss = mergedPreflightDeclarations.baseCss;
|
|
1894
1391
|
css = mergedPreflightDeclarations.css.trim();
|
|
1895
1392
|
if (css.length === 0) continue;
|
|
1896
1393
|
}
|
|
1897
|
-
const mergedThemeScopeDeclarations = measure("mergeTheme", () => (0,
|
|
1394
|
+
const mergedThemeScopeDeclarations = measure("mergeTheme", () => (0, _weapp_tailwindcss_postcss_transform.mergeMiniProgramThemeScopeRuleDeclarations)(nextCss, css));
|
|
1898
1395
|
if (mergedThemeScopeDeclarations.changed) {
|
|
1899
1396
|
nextCss = mergedThemeScopeDeclarations.baseCss;
|
|
1900
1397
|
css = mergedThemeScopeDeclarations.css.trim();
|
|
1901
1398
|
if (css.length === 0) continue;
|
|
1902
1399
|
}
|
|
1903
|
-
const mergedRuleDeclarations = measure("mergeDeclarations", () => (0,
|
|
1400
|
+
const mergedRuleDeclarations = measure("mergeDeclarations", () => (0, _weapp_tailwindcss_postcss_transform.mergeCoveredCssRuleDeclarations)(nextCss, css));
|
|
1904
1401
|
if (mergedRuleDeclarations.changed) {
|
|
1905
1402
|
nextCss = mergedRuleDeclarations.baseCss;
|
|
1906
1403
|
css = mergedRuleDeclarations.css.trim();
|
|
1907
1404
|
if (css.length === 0) continue;
|
|
1908
1405
|
}
|
|
1909
|
-
const missingCss = measure("filterRules", () => (0,
|
|
1910
|
-
if (missingCss.length === 0 || !
|
|
1406
|
+
const missingCss = measure("filterRules", () => (0, _weapp_tailwindcss_postcss_transform.filterExistingCssRules)(nextCss, css));
|
|
1407
|
+
if (missingCss.length === 0 || !(0, _weapp_tailwindcss_postcss_transform.hasNonCommentCss)(missingCss) || measure("containsMissing", () => (0, _weapp_tailwindcss_postcss_transform.containsCssAfterMinify)(nextCss, missingCss))) continue;
|
|
1911
1408
|
nextCss = require_web.appendCss(nextCss, missingCss);
|
|
1912
1409
|
}
|
|
1913
1410
|
const finalImportedCssSources = collectImportedBundleCssSources(bundle, require_web.collectImportedStyleFiles(originalSource, file));
|
|
1914
1411
|
const finalImportedCssCoverage = prepareImportedCssCoverage(finalImportedCssSources);
|
|
1915
|
-
nextCss = measure("finalizeTarget", () => transformCss(removeCommentOnlyAtRules(restoreCssImportAtRules(originalSource, removeCssRulesCoveredBySources(nextCss, finalImportedCssSources, { exactOnly: true }, finalImportedCssCoverage?.coverage).trim(), file)), file));
|
|
1412
|
+
nextCss = measure("finalizeTarget", () => transformCss((0, _weapp_tailwindcss_postcss_transform.removeCommentOnlyAtRules)(restoreCssImportAtRules(originalSource, (0, _weapp_tailwindcss_postcss_transform.removeCssRulesCoveredBySources)(nextCss, finalImportedCssSources, { exactOnly: true }, finalImportedCssCoverage?.coverage).trim(), file)), file));
|
|
1916
1413
|
if (nextCss.trim() === originalSource.trim()) nextCss = originalSource;
|
|
1917
1414
|
if (nextCss !== originalSource) {
|
|
1918
1415
|
output.source = nextCss;
|
|
@@ -2108,8 +1605,8 @@ async function collectBundleMarkupCandidates(options) {
|
|
|
2108
1605
|
const valuesForEntries = (entries, filterOptions = {}) => {
|
|
2109
1606
|
const values = /* @__PURE__ */ new Set();
|
|
2110
1607
|
for (const { sourceFile: file, candidates } of candidatesByFile.values()) {
|
|
2111
|
-
if (entries !== void 0 && !
|
|
2112
|
-
if (filterOptions.excludeEntries?.length &&
|
|
1608
|
+
if (entries !== void 0 && !(0, require_tailwindcss.source_scan_exports.isFileMatchedByTailwindSourceEntries)(file, entries)) continue;
|
|
1609
|
+
if (filterOptions.excludeEntries?.length && (0, require_tailwindcss.source_scan_exports.isFileMatchedByTailwindSourceEntries)(file, filterOptions.excludeEntries)) continue;
|
|
2113
1610
|
for (const candidate of candidates) values.add(candidate);
|
|
2114
1611
|
}
|
|
2115
1612
|
return values;
|
|
@@ -2156,7 +1653,7 @@ function createCssAssetEmitter(context, bundle) {
|
|
|
2156
1653
|
return (fileName, source) => {
|
|
2157
1654
|
const fileNameKey = require_source_candidate_scan_signature.normalizeOutputPathKey(fileName);
|
|
2158
1655
|
const existing = bundle?.[fileName] ?? Object.entries(bundle ?? {}).find(([bundleFile, output]) => output != null && typeof output === "object" && "type" in output && output.type === "asset" && require_source_candidate_scan_signature.normalizeOutputPathKey("fileName" in output && typeof output.fileName === "string" ? output.fileName : bundleFile) === fileNameKey)?.[1];
|
|
2159
|
-
if (existing && typeof existing === "object" && "type" in existing && existing.type === "asset") {
|
|
1656
|
+
if (existing && typeof existing === "object" && "type" in existing && existing.type === "asset" && "source" in existing) {
|
|
2160
1657
|
existing.source = source;
|
|
2161
1658
|
return existing;
|
|
2162
1659
|
}
|
|
@@ -2264,6 +1761,10 @@ function processViteCssCacheTask(options) {
|
|
|
2264
1761
|
function createRememberedCssRuntimeSignature(cssRuntimeSignature, cssRuntimeAffectingHash) {
|
|
2265
1762
|
return `${cssRuntimeSignature}:${cssRuntimeAffectingHash}`;
|
|
2266
1763
|
}
|
|
1764
|
+
/** 入口重放的干净生成结果,避免和已合并框架贡献的产物缓存混用。 */
|
|
1765
|
+
function createGeneratedReplayCacheKey(outputFile) {
|
|
1766
|
+
return `${require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile)}::__generated_replay__`;
|
|
1767
|
+
}
|
|
2267
1768
|
function normalizeRememberedSourceIdentity(file) {
|
|
2268
1769
|
return require_source_candidate_scan_signature.normalizeOutputPathKey(file.replace(/[?#].*$/, ""));
|
|
2269
1770
|
}
|
|
@@ -2303,9 +1804,23 @@ function mergeRememberedCssSources(sources, outputFile) {
|
|
|
2303
1804
|
}
|
|
2304
1805
|
function collectRememberedCssReplayGroups(sources, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, styleOutputFiles) {
|
|
2305
1806
|
const groups = /* @__PURE__ */ new Map();
|
|
1807
|
+
const outputFiles = [...styleOutputFiles ?? []];
|
|
1808
|
+
const currentOutputs = new Set(outputFiles.map(require_source_candidate_scan_signature.normalizeOutputPathKey));
|
|
1809
|
+
const relationOwner = require_web.getActiveViteSourceOutputRelationOwner();
|
|
2306
1810
|
for (const [key, remembered] of sources ?? []) {
|
|
1811
|
+
const ownedOutputs = [...relationOwner?.getOwnedOutputs(remembered.sourceFile) ?? []].filter((file) => currentOutputs.has(require_source_candidate_scan_signature.normalizeOutputPathKey(file)) && opts.cssMatcher(file));
|
|
1812
|
+
if (ownedOutputs.length === 1) {
|
|
1813
|
+
const outputKey = require_source_candidate_scan_signature.normalizeOutputPathKey(ownedOutputs[0]);
|
|
1814
|
+
const group = groups.get(outputKey) ?? [];
|
|
1815
|
+
group.push({
|
|
1816
|
+
key,
|
|
1817
|
+
remembered
|
|
1818
|
+
});
|
|
1819
|
+
groups.set(outputKey, group);
|
|
1820
|
+
continue;
|
|
1821
|
+
}
|
|
2307
1822
|
const cleanSourceFile = remembered.sourceFile.replace(/[?#].*$/, "");
|
|
2308
|
-
const resolvedOutputFile = require_web.CSS_SOURCE_OUTPUT_EXT_RE.test(cleanSourceFile) ? require_web.resolveViteCssPipelineOutputFileFromSourceFile(remembered.sourceFile, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension,
|
|
1823
|
+
const resolvedOutputFile = require_web.CSS_SOURCE_OUTPUT_EXT_RE.test(cleanSourceFile) ? require_web.resolveViteCssPipelineOutputFileFromSourceFile(remembered.sourceFile, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, outputFiles) : require_web.resolveViteCssPipelineOutputFileFromSourceFile(remembered.outputFile, opts, rootDir, isWebGeneratorTarget, preserveCssExtension, sourceRoot, styleOutputExtension, outputFiles);
|
|
2309
1824
|
const rememberedOutputFile = remembered.outputFile.replace(/[?#].*$/, "");
|
|
2310
1825
|
const outputFile = opts.cssMatcher(rememberedOutputFile) && !require_source_candidate_scan_signature.normalizeOutputPathKey(rememberedOutputFile).includes("/") && require_source_candidate_scan_signature.normalizeOutputPathKey(rememberedOutputFile) !== require_source_candidate_scan_signature.normalizeOutputPathKey(resolvedOutputFile.replace(/[?#].*$/, "")) ? remembered.outputFile : resolvedOutputFile;
|
|
2311
1826
|
const outputKey = require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile);
|
|
@@ -2341,17 +1856,17 @@ function resolveViteCssCompositionPlan(options) {
|
|
|
2341
1856
|
const vitePipelineCssAsset = options.viteProcessedCssAsset || useRememberedCssSource;
|
|
2342
1857
|
const resolvedGeneratorRawSource = vitePipelineCssAsset ? rememberedSource?.rawSource ?? options.rawSource : options.rawSource;
|
|
2343
1858
|
const generatorRawSource = options.normalizeGeneratorSource(resolvedGeneratorRawSource, outputFile);
|
|
2344
|
-
const hasCurrentTailwindGenerationDirective =
|
|
1859
|
+
const hasCurrentTailwindGenerationDirective = (0, _weapp_tailwindcss_postcss_transform.hasTailwindSourceDirectives)(options.rawSource, { importFallback: true }) || (0, _weapp_tailwindcss_postcss_transform.hasTailwindRootDirectives)(options.rawSource, { importFallback: true }) || (0, _weapp_tailwindcss_postcss_transform.hasTailwindApplyDirective)(options.rawSource);
|
|
2345
1860
|
const preserveImportedCssShell = options.shouldKeepImportedCssShell && !hasCurrentTailwindGenerationDirective;
|
|
2346
|
-
const hasRememberedApplySource = vitePipelineCssAsset && rememberedSource != null &&
|
|
1861
|
+
const hasRememberedApplySource = vitePipelineCssAsset && rememberedSource != null && (0, _weapp_tailwindcss_postcss_transform.hasTailwindApplyDirective)(generatorRawSource);
|
|
2347
1862
|
const hasDifferentRememberedCssSource = rememberedSource != null && require_web.normalizeCssSourceForCompare(rememberedSource.rawSource) !== require_web.normalizeCssSourceForCompare(options.rawSource);
|
|
2348
|
-
const hasRememberedApplyDirective = rememberedSource != null &&
|
|
1863
|
+
const hasRememberedApplyDirective = rememberedSource != null && (0, _weapp_tailwindcss_postcss_transform.hasTailwindApplyDirective)(rememberedSource.rawSource);
|
|
2349
1864
|
const hasRememberedTailwindGenerationSource = rememberedSource != null && require_web.hasTailwindGenerationSource(rememberedSource.rawSource);
|
|
2350
1865
|
const hasSameOutputRememberedTailwindGenerationSource = hasRememberedTailwindGenerationSource && rememberedSource != null && require_source_candidate_scan_signature.normalizeOutputPathKey(rememberedSource.outputFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile);
|
|
2351
1866
|
const hasStaleViteProcessedCssSource = vitePipelineCssAsset && hasDifferentRememberedCssSource && (hasCurrentTailwindGenerationDirective || hasRememberedApplyDirective || hasRememberedTailwindGenerationSource);
|
|
2352
1867
|
const generatorSourceFile = vitePipelineCssAsset ? rememberedSource?.sourceFile ?? options.assetSourceFile : options.assetSourceFile;
|
|
2353
1868
|
const originalGeneratorLayerSource = vitePipelineCssAsset ? options.getOriginalCssLayerSource?.(generatorSourceFile) : void 0;
|
|
2354
|
-
const generatorUserLayerRawSource = originalGeneratorLayerSource && require_web.normalizeCssSourceForCompare(originalGeneratorLayerSource) !== require_web.normalizeCssSourceForCompare(generatorRawSource) &&
|
|
1869
|
+
const generatorUserLayerRawSource = originalGeneratorLayerSource && require_web.normalizeCssSourceForCompare(originalGeneratorLayerSource) !== require_web.normalizeCssSourceForCompare(generatorRawSource) && (0, _weapp_tailwindcss_postcss_transform.hasUserCssLayerBlocks)(originalGeneratorLayerSource) ? options.normalizeGeneratorSource(options.normalizeGeneratorUserSource(originalGeneratorLayerSource, generatorSourceFile, options.assetSourceFile), outputFile) : void 0;
|
|
2355
1870
|
const webviewRootCssInjectionTarget = vitePipelineCssAsset ? options.resolveConfiguredRootInjectionTarget(generatorSourceFile, outputFile) : void 0;
|
|
2356
1871
|
const usesConfiguredTailwindV4FallbackSource = rememberedSource != null && require_source_candidate_scan_signature.normalizeOutputPathKey(rememberedSource.outputFile) === require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile) && require_source_candidate_scan_signature.normalizeOutputPathKey(rememberedSource.sourceFile.replace(/[?#].*$/, "")) !== require_source_candidate_scan_signature.normalizeOutputPathKey(options.file);
|
|
2357
1872
|
const configuredSourceFile = vitePipelineCssAsset && outputCssHandlerOptions.isMainChunk !== true && options.configuredSourceFileKeys.has(options.normalizeConfiguredSourceFile(generatorSourceFile)) ? generatorSourceFile : void 0;
|
|
@@ -2429,7 +1944,7 @@ function collectConfiguredTailwindV4CssSourceEntries(opts, fallbackBase) {
|
|
|
2429
1944
|
}
|
|
2430
1945
|
for (const cssSource of collectConfiguredTailwindV4CssSources(opts)) {
|
|
2431
1946
|
if (typeof cssSource.css !== "string" || cssSource.css.length === 0) continue;
|
|
2432
|
-
const base =
|
|
1947
|
+
const base = require_tailwindcss.resolveTailwindV4CssSourceBase(cssSource, fallbackBase);
|
|
2433
1948
|
const file = typeof cssSource.file === "string" && cssSource.file.length > 0 ? cssSource.file : node_path.default.join(base, "tailwind.css");
|
|
2434
1949
|
const resolvedFile = node_path.default.isAbsolute(file) ? node_path.default.resolve(file) : node_path.default.resolve(base, file);
|
|
2435
1950
|
const key = `${resolvedFile}\0${cssSource.css}`;
|
|
@@ -2484,20 +1999,19 @@ function collectCssConfigBaseCandidates(source, file, outputRoot, opts) {
|
|
|
2484
1999
|
const cssSourceCss = typeof cssSource.css === "string" ? require_web.normalizeCssSourceForCompare(cssSource.css) : void 0;
|
|
2485
2000
|
if (cssSourceFile && !require_web.isMatchingCssSourceFile(file, cssSourceFile, outputRoot) && cssSourceCss !== normalizedSource) continue;
|
|
2486
2001
|
addCandidate(cssSourceFile ? node_path.default.dirname(cssSourceFile) : void 0);
|
|
2487
|
-
addCandidate(
|
|
2002
|
+
addCandidate(require_tailwindcss.resolveTailwindV4CssSourceBase(cssSource, sourceBaseFallback));
|
|
2488
2003
|
}
|
|
2489
2004
|
return candidates;
|
|
2490
2005
|
}
|
|
2491
2006
|
function normalizeRelativeCssConfigDirectives(source, file, outputRoot, opts) {
|
|
2492
2007
|
if (!source.includes("@config")) return source;
|
|
2493
2008
|
const baseCandidates = collectCssConfigBaseCandidates(source, file, outputRoot, opts);
|
|
2494
|
-
return
|
|
2495
|
-
if (node_path.default.isAbsolute(request) || isPackageJsonImportRequest(request)) return
|
|
2009
|
+
return (0, _weapp_tailwindcss_postcss_transform.rewriteCssConfigRequests)(source, (request) => {
|
|
2010
|
+
if (node_path.default.isAbsolute(request) || isPackageJsonImportRequest(request)) return;
|
|
2496
2011
|
for (const base of baseCandidates) {
|
|
2497
2012
|
const configFile = node_path.default.resolve(base, request);
|
|
2498
|
-
if ((0, node_fs.existsSync)(configFile)) return
|
|
2013
|
+
if ((0, node_fs.existsSync)(configFile)) return require_web.slash(configFile);
|
|
2499
2014
|
}
|
|
2500
|
-
return full;
|
|
2501
2015
|
});
|
|
2502
2016
|
}
|
|
2503
2017
|
//#endregion
|
|
@@ -2604,7 +2118,7 @@ async function processViteCssBundleEntry(options) {
|
|
|
2604
2118
|
const { activeViteCssCacheFiles, addWatchFile, annotateCssSourceTrace, applyCssResultToBundle, applyViteCssCacheResult, applyViteCssTransformTaskResult, bundle, bundleFiles, cache, collectedBundlerGeneratedCssFiles, configuredTailwindV4CssSourceFileKeysForScope, configuredTailwindV4ExplicitCssEntryFileKeysForScope, context, createCandidateSignature, createCssSourceTraceCacheSignature, createCssTokenSourceMap, createCssTransformShareScopeKey, createInitialCssPipelineContext, createRuntimeAffectingSourceSignature, createScopedGeneratorCandidateSignature, createScopedGeneratorRuntime, createScopedGeneratorSourceTraceMap, createScopedSourceCandidateGetter, createScopedSourceCandidateSourceGetter, cssTaskFactories, currentSubpackageRoots, debug, defaultStyleOutputExtension, emitOrReplayCssAsset, envFlags, executeViteCssTransformTask, file, frameworkRootImportShellTargetByFile, generatorCandidatesChanged, generatorPlatform, generatorRuntime, getConfiguredTailwindV4CssSourceEntries, getCssHandlerOptions, getCssSource, getCssUserHandlerOptions, getLastCssResult, getOriginalCssLayerSource, getRememberedCssSources, getSfcSource, getSourceCandidateSources, getViteProcessedCssAssetResult, getViteProcessedCssAssetResults, hasExplicitConfiguredRootCssEntryForOutput, hasRuntimeAffectingChanges, hasViteProcessedCssResultForSource, isCssAssetProcessed, isCssImportOnlyBundleAsset, isMiniProgramStyleOutputFile, isRootMiniProgramStyleOutputFile, isSubpackageOutputFile, isTemporaryCssAssetFile, isViteProcessedCssAsset, isWebGeneratorTarget, lastCssResultByFile, lastCssSourceHashByFile, markCssAssetProcessed, measureElapsed, metrics, normalizeConfiguredTailwindV4CssEntryFileKey, normalizeGeneratorUserRawSource, normalizeMiniProgramGeneratorRawSource, normalizeOutputPathKey, normalizeRelativeCssConfigDirectives, normalizeViteCssCacheKey, onUpdate, opts, originalEntrySource, originalSource, outDir, processFiles, processViteCssCacheTask, recordCssAssetResult, recordViteProcessedCssAssetResult, rememberCssSource, rememberProcessCacheKey, removeCssCoveredByRootStyleBundleSources, resolveAssetSourceFile, resolveConfiguredCssEntryRootInjectionTarget, resolveConfiguredRootCssSourceStyle, resolveCssAssetIdentity, resolveCssAssetOutputPlan, resolveFrameworkRootImportShellPlan, resolveMatchedCssSourceOutputFile, resolveReplayCssOutputFile, resolveViteCssCompositionPlan, resolveViteCssLinkedImpactSignature, resolveViteCssPipelineOutputFile, resolveViteCssSourcePlan, resolveViteCssTransformCachePlan, resolveViteCssTransformDecisionPlan, rootDir, runtimeLinkedCssFiles, runtimeSignature, runtimeState, selectConfiguredRootCssSourceEntry, sharedCssResultCache, shouldExcludeSubpackageSourceCandidates, shouldGenerateWebCssByGenerator, shouldInjectCssIntoMainFromOutput, shouldKeepCurrentRootCssOutputForConfiguredSource, shouldKeepCurrentRootMiniProgramStyleOutputAsImportShell, shouldKeepRootMiniProgramStyleAsImportShell, shouldMoveRootMiniProgramStyleToImportShellOrigin, shouldPreserveAppCssExtension, shouldProcessTailwindGeneration, shouldSkipRawRememberedCssSource, shouldSkipRawSourceStyleAsset, shouldSkipViteAssetTransform, snapshot, sourceRoot, state, styleHandler, temporaryCssAssetSourceResolver, timeTask, transformFilter, transformRuntime, transformWebTargetCss, useIncrementalMode, usedConfiguredTailwindV4CssSourceFiles } = options;
|
|
2605
2119
|
metrics.css.total++;
|
|
2606
2120
|
const assetSourceFile = resolveAssetSourceFile(originalSource, file);
|
|
2607
|
-
const rawSource = normalizeRelativeCssConfigDirectives(isWebGeneratorTarget ? originalEntrySource :
|
|
2121
|
+
const rawSource = normalizeRelativeCssConfigDirectives(isWebGeneratorTarget ? originalEntrySource : (0, _weapp_tailwindcss_postcss_transform.normalizeMiniProgramImportShell)(originalEntrySource, {
|
|
2608
2122
|
cssOnly: true,
|
|
2609
2123
|
outputFile: originalSource.fileName || file,
|
|
2610
2124
|
outputFiles: [...bundleFiles, ...lastCssResultByFile.keys()]
|
|
@@ -2901,6 +2415,7 @@ async function processViteCssBundleEntry(options) {
|
|
|
2901
2415
|
runtimeAffectingSignatureByFile: snapshot.runtimeAffectingSignatureByFile
|
|
2902
2416
|
}) : "";
|
|
2903
2417
|
const { cssCacheKey, cssHashKey, cssSharedCacheKey, cssTaskHash, rememberedCssRuntimeSignature } = resolveViteCssTransformCachePlan({
|
|
2418
|
+
cssBundleSourceHash: isWebGeneratorTarget ? cache.computeHash(rawSource) : void 0,
|
|
2904
2419
|
cssIsMainChunk: cssHandlerOptions2.isMainChunk === true,
|
|
2905
2420
|
cssRuntimeAffectingHash,
|
|
2906
2421
|
cssShareScope,
|
|
@@ -3004,7 +2519,7 @@ function shouldSkipRawSourceStyleAsset(outputFile, file, rawSource, assetSourceF
|
|
|
3004
2519
|
if (source.length === 0) return false;
|
|
3005
2520
|
if (require_web.canProcessViteSourceStyleAsCss(source, file)) return false;
|
|
3006
2521
|
if (require_web.SOURCE_STYLE_OUTPUT_EXT_RE.test(assetSourceFile.replace(/[?#].*$/, ""))) return true;
|
|
3007
|
-
const isKnownStyleSource =
|
|
2522
|
+
const isKnownStyleSource = require_generated_css_marker.isSourceStyleRequest(assetSourceFile) || cssMatcher?.(assetSourceFile) === true;
|
|
3008
2523
|
return outputFile !== file || !isKnownStyleSource;
|
|
3009
2524
|
}
|
|
3010
2525
|
function resolveOutputFileFromMatchedCssSource(options) {
|
|
@@ -3097,30 +2612,14 @@ function applyCssResultToBundle(options) {
|
|
|
3097
2612
|
}
|
|
3098
2613
|
//#endregion
|
|
3099
2614
|
//#region src/bundlers/vite/generate-bundle/css-share-scope.ts
|
|
3100
|
-
const CSS_URL_FUNCTION_RE = /url\((?:"([^"]*)"|'([^']*)'|([^)]*))\)/gi;
|
|
3101
|
-
const CSS_PATH_INDEPENDENT_URL_RE = /^(?:[a-z][a-z\d+.-]*:|\/\/|\/|#)/i;
|
|
3102
|
-
const CSS_IMPORT_RE = /@import\b/i;
|
|
3103
|
-
function isPathIndependentCssUrl(value) {
|
|
3104
|
-
const normalized = value.trim();
|
|
3105
|
-
return normalized.length > 0 && CSS_PATH_INDEPENDENT_URL_RE.test(normalized);
|
|
3106
|
-
}
|
|
3107
|
-
function hasPathDependentCssUrl(rawSource) {
|
|
3108
|
-
CSS_URL_FUNCTION_RE.lastIndex = 0;
|
|
3109
|
-
let match = CSS_URL_FUNCTION_RE.exec(rawSource);
|
|
3110
|
-
while (match !== null) {
|
|
3111
|
-
if (!isPathIndependentCssUrl(match[1] ?? match[2] ?? match[3] ?? "")) return true;
|
|
3112
|
-
match = CSS_URL_FUNCTION_RE.exec(rawSource);
|
|
3113
|
-
}
|
|
3114
|
-
return false;
|
|
3115
|
-
}
|
|
3116
2615
|
function createCssTransformShareScope(file, rawSource) {
|
|
3117
|
-
if (
|
|
2616
|
+
if ((0, _weapp_tailwindcss_postcss_transform.hasCssLocationDependencies)(rawSource)) return `dir:${require_source_candidate_scan_signature.normalizeOutputPathKey(node_path.default.dirname(file))}`;
|
|
3118
2617
|
return "global";
|
|
3119
2618
|
}
|
|
3120
2619
|
function createCssTransformShareScopeKey(opts, file, rawSource) {
|
|
3121
2620
|
if (opts.mainCssChunkMatcher(file, opts.appType)) return `main:${require_source_candidate_scan_signature.normalizeOutputPathKey(file)}`;
|
|
3122
2621
|
const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator);
|
|
3123
|
-
if (
|
|
2622
|
+
if ((0, _weapp_tailwindcss_postcss_transform.hasTailwindGeneratedCssMarkers)(rawSource) || (0, _weapp_tailwindcss_postcss_transform.hasTailwindSourceDirectives)(rawSource, { importFallback: generatorOptions.importFallback })) return `source:${require_source_candidate_scan_signature.normalizeOutputPathKey(file)}`;
|
|
3124
2623
|
return createCssTransformShareScope(file, rawSource);
|
|
3125
2624
|
}
|
|
3126
2625
|
function createCssRuntimeSignature(runtimeSignature, generatorCandidateSignature) {
|
|
@@ -3188,147 +2687,38 @@ async function resolveRememberedCssSourcePlan(options) {
|
|
|
3188
2687
|
}
|
|
3189
2688
|
//#endregion
|
|
3190
2689
|
//#region src/bundlers/vite/generate-bundle/tailwind-v4-css-source.ts
|
|
3191
|
-
function createStableTextSignature(input) {
|
|
3192
|
-
let hash = 2166136261;
|
|
3193
|
-
for (let i = 0; i < input.length; i++) {
|
|
3194
|
-
hash ^= input.charCodeAt(i);
|
|
3195
|
-
hash = Math.imul(hash, 16777619);
|
|
3196
|
-
}
|
|
3197
|
-
return (hash >>> 0).toString(36);
|
|
3198
|
-
}
|
|
3199
|
-
function parseQuotedRequest(params) {
|
|
3200
|
-
const input = params.trim();
|
|
3201
|
-
const quote = input[0];
|
|
3202
|
-
if (quote !== "\"" && quote !== "'") return;
|
|
3203
|
-
let escaped = false;
|
|
3204
|
-
for (let index = 1; index < input.length; index++) {
|
|
3205
|
-
const char = input[index];
|
|
3206
|
-
if (escaped) {
|
|
3207
|
-
escaped = false;
|
|
3208
|
-
continue;
|
|
3209
|
-
}
|
|
3210
|
-
if (char === "\\") {
|
|
3211
|
-
escaped = true;
|
|
3212
|
-
continue;
|
|
3213
|
-
}
|
|
3214
|
-
if (char === quote) return input.slice(1, index);
|
|
3215
|
-
}
|
|
3216
|
-
}
|
|
3217
|
-
function parseSourceParams(params) {
|
|
3218
|
-
let input = params.trim();
|
|
3219
|
-
let negated = false;
|
|
3220
|
-
if (input.startsWith("not ")) {
|
|
3221
|
-
negated = true;
|
|
3222
|
-
input = input.slice(4).trim();
|
|
3223
|
-
}
|
|
3224
|
-
if (input.startsWith("inline(") && input.endsWith(")")) return {
|
|
3225
|
-
prefix: negated ? "source:inline:not" : "source:inline",
|
|
3226
|
-
value: input.slice(7, -1).trim()
|
|
3227
|
-
};
|
|
3228
|
-
const request = parseQuotedRequest(input);
|
|
3229
|
-
if (!request) return;
|
|
3230
|
-
return {
|
|
3231
|
-
prefix: negated ? "source:not" : "source",
|
|
3232
|
-
value: request
|
|
3233
|
-
};
|
|
3234
|
-
}
|
|
3235
|
-
function parseTailwindImportSource(params) {
|
|
3236
|
-
if (parseQuotedRequest(params) !== "tailwindcss") return;
|
|
3237
|
-
return /\bsource\(([^)]*)\)/.exec(params)?.[1]?.trim();
|
|
3238
|
-
}
|
|
3239
|
-
function hasExplicitTailwindV4Directive(source) {
|
|
3240
|
-
try {
|
|
3241
|
-
let found = false;
|
|
3242
|
-
_weapp_tailwindcss_postcss.postcss.parse(source).walkAtRules((rule) => {
|
|
3243
|
-
if (rule.name === "config" || rule.name === "source" || rule.name === "plugin" || rule.name === "custom-variant" || rule.name === "theme" || rule.name === "utility" || rule.name === "variant" || rule.name === "apply") {
|
|
3244
|
-
found = true;
|
|
3245
|
-
return false;
|
|
3246
|
-
}
|
|
3247
|
-
});
|
|
3248
|
-
return found;
|
|
3249
|
-
} catch {
|
|
3250
|
-
return false;
|
|
3251
|
-
}
|
|
3252
|
-
}
|
|
3253
2690
|
function collectTailwindV4SourceFingerprint(source) {
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
root.walkAtRules((rule) => {
|
|
3261
|
-
if (rule.name === "import") {
|
|
3262
|
-
const sourceMode = parseTailwindImportSource(rule.params);
|
|
3263
|
-
if (sourceMode) add("import-source", sourceMode);
|
|
3264
|
-
return;
|
|
3265
|
-
}
|
|
3266
|
-
if (rule.name === "config") {
|
|
3267
|
-
const configRequest = parseQuotedRequest(rule.params);
|
|
3268
|
-
if (configRequest) {
|
|
3269
|
-
add("config", node_path.default.basename(configRequest));
|
|
3270
|
-
add("config-request", configRequest.replace(/\\/g, "/"));
|
|
3271
|
-
}
|
|
3272
|
-
return;
|
|
3273
|
-
}
|
|
3274
|
-
if (rule.name === "source") {
|
|
3275
|
-
const parsed = parseSourceParams(rule.params);
|
|
3276
|
-
if (parsed) add(parsed.prefix, parsed.value);
|
|
3277
|
-
return;
|
|
3278
|
-
}
|
|
3279
|
-
if (rule.name === "plugin") {
|
|
3280
|
-
const request = parseQuotedRequest(rule.params);
|
|
3281
|
-
if (!request) return;
|
|
3282
|
-
add("plugin", request);
|
|
3283
|
-
add("plugin-request", request.replace(/\\/g, "/"));
|
|
3284
|
-
if (rule.nodes?.length) {
|
|
3285
|
-
add("plugin-options", `${request}:${createStableTextSignature(rule.toString())}`);
|
|
3286
|
-
rule.walkDecls((decl) => {
|
|
3287
|
-
add("plugin-option", `${request}:${decl.prop}:${decl.value}`);
|
|
3288
|
-
});
|
|
3289
|
-
}
|
|
3290
|
-
return;
|
|
3291
|
-
}
|
|
3292
|
-
if (rule.name === "custom-variant") {
|
|
3293
|
-
const [name] = rule.params.trim().split(/\s+/, 1);
|
|
3294
|
-
if (name) add("custom-variant", name);
|
|
3295
|
-
return;
|
|
3296
|
-
}
|
|
3297
|
-
if (rule.name === "theme" || rule.name === "utility" || rule.name === "variant" || rule.name === "layer") {
|
|
3298
|
-
const [name] = rule.params.trim().split(/\s+/, 1);
|
|
3299
|
-
if (name) add("directive", name);
|
|
3300
|
-
}
|
|
3301
|
-
});
|
|
3302
|
-
root.walkDecls((decl) => {
|
|
3303
|
-
if (decl.prop.startsWith("--")) add("theme-token", decl.prop);
|
|
3304
|
-
});
|
|
3305
|
-
root.walkRules((rule) => {
|
|
3306
|
-
for (const selector of rule.selectors ?? []) {
|
|
3307
|
-
const match = /\.([_a-z][\w-]*)/i.exec(selector);
|
|
3308
|
-
if (match?.[1]) add("selector", match[1]);
|
|
3309
|
-
}
|
|
3310
|
-
});
|
|
3311
|
-
} catch {}
|
|
3312
|
-
return tokens;
|
|
2691
|
+
return (0, _weapp_tailwindcss_postcss_transform.analyzeTailwindV4Source)(source, node_path.default.basename).getFingerprint();
|
|
2692
|
+
}
|
|
2693
|
+
function scoreSourceFingerprints(rawTokens, entryTokens) {
|
|
2694
|
+
let score = 0;
|
|
2695
|
+
for (const token of entryTokens) if (rawTokens.has(token)) score += token.startsWith("config:") ? 100 : 1;
|
|
2696
|
+
return score;
|
|
3313
2697
|
}
|
|
3314
2698
|
function scoreConfiguredTailwindV4SourceForRawSource(rawSource, entrySource) {
|
|
3315
2699
|
if (!rawSource) return 0;
|
|
3316
2700
|
const rawTokens = collectTailwindV4SourceFingerprint(rawSource);
|
|
3317
2701
|
if (rawTokens.size === 0) return 0;
|
|
3318
|
-
|
|
3319
|
-
let score = 0;
|
|
3320
|
-
for (const token of entryTokens) if (rawTokens.has(token)) score += token.startsWith("config:") ? 100 : 1;
|
|
3321
|
-
return score;
|
|
2702
|
+
return scoreSourceFingerprints(rawTokens, collectTailwindV4SourceFingerprint(entrySource));
|
|
3322
2703
|
}
|
|
3323
2704
|
function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSource, options = {}) {
|
|
3324
2705
|
const generationSources = entries.filter((entry) => require_web.hasTailwindGenerationSource(entry.source));
|
|
3325
2706
|
if (generationSources.length <= 1) return generationSources[0];
|
|
2707
|
+
const analyses = /* @__PURE__ */ new Map();
|
|
2708
|
+
const analyze = (source) => {
|
|
2709
|
+
let analysis = analyses.get(source);
|
|
2710
|
+
if (!analysis) {
|
|
2711
|
+
analysis = (0, _weapp_tailwindcss_postcss_transform.analyzeTailwindV4Source)(source, node_path.default.basename);
|
|
2712
|
+
analyses.set(source, analysis);
|
|
2713
|
+
}
|
|
2714
|
+
return analysis;
|
|
2715
|
+
};
|
|
3326
2716
|
const canMatchByOutputPath = Boolean(options.cwd || options.outputRoot || options.projectRoot);
|
|
3327
2717
|
const selectByOutputPath = (candidates, shouldUseScore = (score) => score > 0) => {
|
|
3328
2718
|
if (!canMatchByOutputPath) return;
|
|
3329
2719
|
const scoredSources = candidates.map((entry) => ({
|
|
3330
2720
|
entry,
|
|
3331
|
-
score:
|
|
2721
|
+
score: require_generated_css_marker.scoreTailwindV4CssSourceFileMatch(outputFile, entry.file, {
|
|
3332
2722
|
cwd: options.cwd,
|
|
3333
2723
|
outputRoot: options.outputRoot,
|
|
3334
2724
|
projectRoot: options.projectRoot
|
|
@@ -3339,15 +2729,18 @@ function selectTailwindV4GenerationCssSourceForOutput(outputFile, entries, rawSo
|
|
|
3339
2729
|
return bestSources.length === 1 ? bestSources[0]?.entry : void 0;
|
|
3340
2730
|
};
|
|
3341
2731
|
const selectByRawSourceFingerprint = (candidates) => {
|
|
2732
|
+
if (!rawSource) return;
|
|
2733
|
+
const rawTokens = analyze(rawSource).getFingerprint();
|
|
2734
|
+
if (rawTokens.size === 0) return;
|
|
3342
2735
|
const scoredSources = candidates.map((entry) => ({
|
|
3343
2736
|
entry,
|
|
3344
|
-
score:
|
|
2737
|
+
score: scoreSourceFingerprints(rawTokens, analyze(entry.source).getFingerprint())
|
|
3345
2738
|
})).filter((item) => item.score > 0).sort((a, b) => b.score - a.score);
|
|
3346
2739
|
const bestScore = scoredSources[0]?.score;
|
|
3347
2740
|
const bestSources = bestScore ? scoredSources.filter((item) => item.score === bestScore) : [];
|
|
3348
2741
|
return bestSources.length === 1 ? bestSources[0]?.entry : void 0;
|
|
3349
2742
|
};
|
|
3350
|
-
const explicitSources = generationSources.filter((entry) =>
|
|
2743
|
+
const explicitSources = generationSources.filter((entry) => analyze(entry.source).hasExplicitDirectives);
|
|
3351
2744
|
const candidates = explicitSources.length === 1 ? explicitSources : generationSources;
|
|
3352
2745
|
const directoryIndexOutputPathMatched = selectByOutputPath(candidates, (score) => score >= 25e3 && score < 5e4);
|
|
3353
2746
|
if (directoryIndexOutputPathMatched) return directoryIndexOutputPathMatched;
|
|
@@ -3470,14 +2863,14 @@ async function resolveViteCssSourcePlan(options) {
|
|
|
3470
2863
|
//#region src/bundlers/vite/generate-bundle/css-transform-decision-plan.ts
|
|
3471
2864
|
function resolveViteCssTransformDecisionPlan(options) {
|
|
3472
2865
|
const hasRememberedTailwindGenerationSource = options.rememberedRawSource != null && require_web.hasTailwindGenerationSource(options.rememberedRawSource);
|
|
3473
|
-
const shouldRegenerateCollectedViteCss = options.viteProcessedCssAsset && options.useIncrementalMode && options.generatorCandidateSignatureInitialized && options.generatorCandidatesChanged && (require_web.hasTailwindGenerationSource(options.generatorRawSource) ||
|
|
2866
|
+
const shouldRegenerateCollectedViteCss = options.viteProcessedCssAsset && options.useIncrementalMode && options.generatorCandidateSignatureInitialized && options.generatorCandidatesChanged && (require_web.hasTailwindGenerationSource(options.generatorRawSource) || (0, _weapp_tailwindcss_postcss_transform.hasBundlerGeneratedCssMarker)(options.rawSource) || hasRememberedTailwindGenerationSource);
|
|
3474
2867
|
const shouldRefreshViteProcessedCssByCandidates = options.viteProcessedCssAsset && options.useIncrementalMode && options.generatorCandidateSignatureInitialized && options.generatorCandidatesChanged;
|
|
3475
2868
|
const hasRuntimeAffectingTrackedAsset = options.hasRuntimeAffectingChanges && (options.alreadyProcessedCssAsset || options.vitePipelineCssAsset);
|
|
3476
2869
|
const shouldTrackForTailwindGeneration = options.shouldProcessTailwindGeneration && (!options.useIncrementalMode || options.cssIsMainChunk || options.isProcessCssFile || options.isRuntimeLinkedCss || shouldRegenerateCollectedViteCss || hasRuntimeAffectingTrackedAsset);
|
|
3477
2870
|
const shouldTrackGeneratorRuntime = options.hasStaleViteProcessedCssSource || options.shouldRegenerateMainPackageCssWithScopedCandidates || options.hasCurrentTailwindGenerationDirective || options.hasSameOutputRememberedTailwindGenerationSource || shouldTrackForTailwindGeneration;
|
|
3478
|
-
const shouldPreserveCollectedViteCssAsset = !shouldRegenerateCollectedViteCss && (!options.generatorCandidateSignatureInitialized || !options.generatorCandidatesChanged) && (options.isCollectedBundlerGeneratedCssFile ||
|
|
3479
|
-
const strippedViteProcessedCss =
|
|
3480
|
-
const shouldPreserveStaleGeneratedCssAsset = options.hasStaleViteProcessedCssSource && shouldPreserveCollectedViteCssAsset && strippedViteProcessedCss.trim().length > 0 && options.cssAssetIdentityKind !== "generator-placeholder" && !require_web.hasTailwindGenerationSource(strippedViteProcessedCss) && !
|
|
2871
|
+
const shouldPreserveCollectedViteCssAsset = !shouldRegenerateCollectedViteCss && (!options.generatorCandidateSignatureInitialized || !options.generatorCandidatesChanged) && (options.isCollectedBundlerGeneratedCssFile || (0, _weapp_tailwindcss_postcss_transform.hasBundlerGeneratedCssMarker)(options.rawSource));
|
|
2872
|
+
const strippedViteProcessedCss = (0, _weapp_tailwindcss_postcss_transform.stripBundlerGeneratedCssMarkers)(options.rawSource);
|
|
2873
|
+
const shouldPreserveStaleGeneratedCssAsset = options.hasStaleViteProcessedCssSource && shouldPreserveCollectedViteCssAsset && strippedViteProcessedCss.trim().length > 0 && options.cssAssetIdentityKind !== "generator-placeholder" && !require_web.hasTailwindGenerationSource(strippedViteProcessedCss) && !(0, _weapp_tailwindcss_postcss_transform.hasTailwindApplyDirective)(strippedViteProcessedCss);
|
|
3481
2874
|
const shouldReuseProcessedCss = options.alreadyProcessedCssAsset && !shouldRefreshViteProcessedCssByCandidates && (!options.hasStaleViteProcessedCssSource || shouldPreserveStaleGeneratedCssAsset) && !options.hasRememberedApplySource && !options.shouldRegenerateMainPackageCssWithScopedCandidates && (!shouldTrackGeneratorRuntime || shouldPreserveCollectedViteCssAsset);
|
|
3482
2875
|
return {
|
|
3483
2876
|
shouldPreserveCollectedViteCssAsset,
|
|
@@ -3506,13 +2899,15 @@ function resolveViteCssTransformCachePlan(options) {
|
|
|
3506
2899
|
options.cssIsMainChunk ? "1" : "0",
|
|
3507
2900
|
options.cssRuntimeAffectingHash,
|
|
3508
2901
|
options.scopedGeneratorCandidateSignature,
|
|
3509
|
-
options.sourceTraceSignature
|
|
2902
|
+
options.sourceTraceSignature,
|
|
2903
|
+
...options.cssBundleSourceHash ? [options.cssBundleSourceHash] : []
|
|
3510
2904
|
].join(":"),
|
|
3511
2905
|
cssTaskHash: [
|
|
3512
2906
|
options.cssRuntimeAffectingHash,
|
|
3513
2907
|
options.scopedGeneratorCandidateSignature,
|
|
3514
2908
|
options.sourceTraceSignature,
|
|
3515
|
-
options.linkedImpactSignature
|
|
2909
|
+
options.linkedImpactSignature,
|
|
2910
|
+
...options.cssBundleSourceHash ? [options.cssBundleSourceHash] : []
|
|
3516
2911
|
].join(":"),
|
|
3517
2912
|
rememberedCssRuntimeSignature
|
|
3518
2913
|
};
|
|
@@ -3544,17 +2939,23 @@ function applyViteCssTransformTaskResult(options) {
|
|
|
3544
2939
|
return result.css;
|
|
3545
2940
|
}
|
|
3546
2941
|
//#endregion
|
|
2942
|
+
//#region src/bundlers/vite/generate-bundle/web-css-module.ts
|
|
2943
|
+
function replaceWebCssModule(source, sourceFile, generated) {
|
|
2944
|
+
const sourceKey = require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile.replace(/[?#].*$/, ""));
|
|
2945
|
+
return (0, _weapp_tailwindcss_postcss_transform.replaceViteGeneratedCssModule)(source, generated, (file) => require_source_candidate_scan_signature.normalizeOutputPathKey(file) === sourceKey);
|
|
2946
|
+
}
|
|
2947
|
+
//#endregion
|
|
3547
2948
|
//#region src/bundlers/vite/generate-bundle/css-transform-task.ts
|
|
3548
2949
|
function resolveBundleUserRawSource(options) {
|
|
3549
|
-
return options.vitePipelineCssAsset && !
|
|
2950
|
+
return options.vitePipelineCssAsset && !(0, _weapp_tailwindcss_postcss_transform.hasBundlerGeneratedCssMarker)(options.rawSource) && require_web.normalizeCssSourceForCompare(options.rawSource) !== require_web.normalizeCssSourceForCompare(options.generatorRawSource) ? options.normalizeMiniProgramGeneratorRawSource(options.normalizeGeneratorUserRawSource(options.rawSource, options.generatorSourceFile, options.assetSourceFile), options.outputFile) : void 0;
|
|
3550
2951
|
}
|
|
3551
2952
|
async function executeViteCssTransformTask(options) {
|
|
3552
2953
|
await options.runtimeState.readyPromise;
|
|
3553
2954
|
const previousGeneratorCss = options.previousCss && !options.isWebGeneratorTarget ? options.normalizeMiniProgramGeneratorRawSource(options.previousCss, options.outputFile) : options.previousCss;
|
|
3554
|
-
if (require_web.hasTailwindGenerationSource(options.generatorRawSource) || !options.isWebGeneratorTarget &&
|
|
2955
|
+
if (require_web.hasTailwindGenerationSource(options.generatorRawSource) && (!options.isWebGeneratorTarget || !(0, _weapp_tailwindcss_postcss_transform.hasBundlerGeneratedCssMarker)(options.rawSource) || (0, _weapp_tailwindcss_postcss_transform.hasTailwindRootDirectives)(options.generatorRawSource, { importFallback: true })) || !options.isWebGeneratorTarget && (0, _weapp_tailwindcss_postcss_transform.hasBundlerGeneratedCssMarker)(options.rawSource)) {
|
|
3555
2956
|
const bundleUserRawSource = resolveBundleUserRawSource(options);
|
|
3556
2957
|
const generatorUserRawSource = [options.generatorUserLayerRawSource, options.isWebGeneratorTarget ? bundleUserRawSource : void 0].filter((source) => typeof source === "string" && source.trim().length > 0).join("\n");
|
|
3557
|
-
const generated = await (options.generateCss ??
|
|
2958
|
+
const generated = await (options.generateCss ?? require_generated_css_marker.generateTailwindV4Css)({
|
|
3558
2959
|
cssHandlerOptions: options.generatorCssHandlerOptions,
|
|
3559
2960
|
cssStage: "framework-processed",
|
|
3560
2961
|
cssUserHandlerOptions: options.cssUserHandlerOptions,
|
|
@@ -3575,7 +2976,7 @@ async function executeViteCssTransformTask(options) {
|
|
|
3575
2976
|
userRawSource: generatorUserRawSource || void 0
|
|
3576
2977
|
});
|
|
3577
2978
|
if (generated) {
|
|
3578
|
-
const css = options.removeRootCoveredCssFromScopedAsset(options.annotateCss(options.transformWebTargetCss(generated.css)));
|
|
2979
|
+
const css = options.removeRootCoveredCssFromScopedAsset(options.annotateCss(options.transformWebTargetCss(options.isWebGeneratorTarget ? replaceWebCssModule(options.rawSource, options.generatorSourceFile, generated.css) ?? generated.css : generated.css)));
|
|
3579
2980
|
return {
|
|
3580
2981
|
classSet: generated.classSet,
|
|
3581
2982
|
css,
|
|
@@ -3593,7 +2994,7 @@ async function executeViteCssTransformTask(options) {
|
|
|
3593
2994
|
kind: "web",
|
|
3594
2995
|
shouldRecordCssAsset: false
|
|
3595
2996
|
};
|
|
3596
|
-
if ((0,
|
|
2997
|
+
if ((0, _weapp_tailwindcss_postcss_transform.isPureLocalCssImportWrapper)(options.generatorRawSource)) return {
|
|
3597
2998
|
css: options.annotateCss(options.generatorRawSource),
|
|
3598
2999
|
dependencies: [],
|
|
3599
3000
|
kind: "import-shell",
|
|
@@ -3633,7 +3034,7 @@ function readAssetSource$1(output) {
|
|
|
3633
3034
|
return typeof output.source === "string" ? output.source : output.source.toString();
|
|
3634
3035
|
}
|
|
3635
3036
|
function shouldFinalizeMiniProgramCssAsset(source) {
|
|
3636
|
-
return source.includes(":hover") || source.includes("does-not-exist") || (0,
|
|
3037
|
+
return source.includes(":hover") || source.includes("does-not-exist") || (0, _weapp_tailwindcss_postcss_transform.hasMiniProgramCssSpecificityPlaceholders)(source);
|
|
3637
3038
|
}
|
|
3638
3039
|
function finalizeMiniProgramCssAssetStructures(bundle, options) {
|
|
3639
3040
|
if (options.isWebGeneratorTarget) return 0;
|
|
@@ -3645,7 +3046,7 @@ function finalizeMiniProgramCssAssetStructures(bundle, options) {
|
|
|
3645
3046
|
const file = output.fileName || bundleFile;
|
|
3646
3047
|
if (!options.cssMatcher(file) || options.files && !options.files.has(file)) continue;
|
|
3647
3048
|
const rawSource = readAssetSource$1(output);
|
|
3648
|
-
const outputCss =
|
|
3049
|
+
const outputCss = (0, _weapp_tailwindcss_postcss_transform.finalizeMiniProgramCssStructure)(rawSource);
|
|
3649
3050
|
if (outputCss === rawSource) continue;
|
|
3650
3051
|
plan.write(file, outputCss);
|
|
3651
3052
|
writeTargets.set(file, output);
|
|
@@ -3672,8 +3073,8 @@ async function finalizeMiniProgramCssAssets(bundle, options) {
|
|
|
3672
3073
|
const rawSource = readAssetSource$1(output);
|
|
3673
3074
|
if (rawSource.trim().length === 0) continue;
|
|
3674
3075
|
if (options.lastCssResultByFile?.has(file)) {
|
|
3675
|
-
const structurallyCleanSource =
|
|
3676
|
-
const outputCss = (0,
|
|
3076
|
+
const structurallyCleanSource = (0, _weapp_tailwindcss_postcss_transform.finalizeMiniProgramCssStructure)(rawSource);
|
|
3077
|
+
const outputCss = (0, _weapp_tailwindcss_postcss_transform.stripMiniProgramCssSpecificityPlaceholders)(structurallyCleanSource);
|
|
3677
3078
|
if (outputCss !== rawSource) {
|
|
3678
3079
|
plan.write(file, outputCss);
|
|
3679
3080
|
writeTargets.set(file, output);
|
|
@@ -3685,7 +3086,7 @@ async function finalizeMiniProgramCssAssets(bundle, options) {
|
|
|
3685
3086
|
continue;
|
|
3686
3087
|
}
|
|
3687
3088
|
if (!shouldFinalizeMiniProgramCssAsset(rawSource)) {
|
|
3688
|
-
const structurallyCleanSource =
|
|
3089
|
+
const structurallyCleanSource = (0, _weapp_tailwindcss_postcss_transform.finalizeMiniProgramCssStructure)(rawSource);
|
|
3689
3090
|
if (structurallyCleanSource !== rawSource) {
|
|
3690
3091
|
plan.write(file, structurallyCleanSource);
|
|
3691
3092
|
writeTargets.set(file, output);
|
|
@@ -3707,8 +3108,8 @@ async function finalizeMiniProgramCssAssets(bundle, options) {
|
|
|
3707
3108
|
},
|
|
3708
3109
|
cssPresetEnv: {}
|
|
3709
3110
|
});
|
|
3710
|
-
const structurallyCleanCss =
|
|
3711
|
-
const outputCss = (0,
|
|
3111
|
+
const structurallyCleanCss = (0, _weapp_tailwindcss_postcss_transform.finalizeMiniProgramCssStructure)(css);
|
|
3112
|
+
const outputCss = (0, _weapp_tailwindcss_postcss_transform.stripMiniProgramCssSpecificityPlaceholders)(structurallyCleanCss);
|
|
3712
3113
|
if (outputCss === rawSource) continue;
|
|
3713
3114
|
plan.write(file, outputCss);
|
|
3714
3115
|
writeTargets.set(file, output);
|
|
@@ -3864,7 +3265,7 @@ async function handleUniAppXPostCssTasks(options) {
|
|
|
3864
3265
|
if (isHarmonyAppStyleTarget && applyUtilities.size > 0 && applyStyleSources.length > 0) {
|
|
3865
3266
|
const outputFile = "uni-app-x-harmony-apply.css";
|
|
3866
3267
|
const cssHandlerOptions = getCssHandlerOptions(outputFile);
|
|
3867
|
-
const generated = await
|
|
3268
|
+
const generated = await require_generated_css_marker.generateTailwindV4Css({
|
|
3868
3269
|
opts,
|
|
3869
3270
|
runtimeState,
|
|
3870
3271
|
runtime: /* @__PURE__ */ new Set(),
|
|
@@ -3882,9 +3283,9 @@ async function handleUniAppXPostCssTasks(options) {
|
|
|
3882
3283
|
styleHandler,
|
|
3883
3284
|
debug
|
|
3884
3285
|
});
|
|
3885
|
-
if (generated?.css) viteProcessedCssSources.push(
|
|
3286
|
+
if (generated?.css) viteProcessedCssSources.push(require_generated_css_marker.annotateCssSourceTrace(generated.css, {
|
|
3886
3287
|
opts,
|
|
3887
|
-
tokenSources: getSourceCandidateSourcesForEntries ?
|
|
3288
|
+
tokenSources: getSourceCandidateSourcesForEntries ? require_generated_css_marker.createCssTokenSourceMap(getSourceCandidateSourcesForEntries(void 0), opts) : void 0
|
|
3888
3289
|
}));
|
|
3889
3290
|
}
|
|
3890
3291
|
if (isHarmonyAppStyleTarget && injectUniAppXHarmonyBundleStyles(bundle, { cssSources: viteProcessedCssSources })) debug("uni-app-x harmony bundle styles inject");
|
|
@@ -3928,7 +3329,7 @@ function finalizeWebviewCssCompat(bundle, options) {
|
|
|
3928
3329
|
const file = getAssetFile(bundleFile, output);
|
|
3929
3330
|
if (!options.opts.cssMatcher(file) || !/\.css(?:$|[?#])/i.test(file)) continue;
|
|
3930
3331
|
const rawSource = readAssetSource(output);
|
|
3931
|
-
const nextCss = (0,
|
|
3332
|
+
const nextCss = (0, _weapp_tailwindcss_postcss_transform.transformWebCssSafeSelectors)((0, _weapp_tailwindcss_postcss_transform.transformWebCssCompat)(rawSource, generatorOptions.webCompat ?? true), { escapeMap: options.opts.escapeMap });
|
|
3932
3333
|
if (nextCss === rawSource) continue;
|
|
3933
3334
|
plan.write(file, nextCss);
|
|
3934
3335
|
writeTargets.set(file, output);
|
|
@@ -3990,9 +3391,9 @@ function normalizeRootMiniProgramImportShellAssets(bundle, options) {
|
|
|
3990
3391
|
updated++;
|
|
3991
3392
|
continue;
|
|
3992
3393
|
}
|
|
3993
|
-
if ((0,
|
|
3394
|
+
if ((0, _weapp_tailwindcss_postcss_transform.isPureLocalCssImportWrapper)(rootSource)) continue;
|
|
3994
3395
|
const originSource = readAssetSource(originOutput);
|
|
3995
|
-
if ((0,
|
|
3396
|
+
if ((0, _weapp_tailwindcss_postcss_transform.isPureLocalCssImportWrapper)(originSource)) {
|
|
3996
3397
|
const importedFile = resolveSingleCssImportOutputFile(originFile, originSource);
|
|
3997
3398
|
if (importedFile && require_source_candidate_scan_signature.normalizeOutputPathKey(importedFile) !== require_source_candidate_scan_signature.normalizeOutputPathKey(rootFile)) continue;
|
|
3998
3399
|
} else if (originSource.trim().length > 0 && originSource.trim() !== rootSource.trim()) continue;
|
|
@@ -4016,18 +3417,67 @@ function normalizeRootMiniProgramImportShellAssets(bundle, options) {
|
|
|
4016
3417
|
return updated;
|
|
4017
3418
|
}
|
|
4018
3419
|
//#endregion
|
|
3420
|
+
//#region src/bundlers/vite/generate-bundle/finalize/sync-processed-css.ts
|
|
3421
|
+
function syncProcessedCss(options) {
|
|
3422
|
+
const { bundle, opts, cssPipelineStrategy, createCssPipelineContext, isViteProcessedCssAsset, markCssAssetProcessed, recordCssAssetResult, recordViteProcessedCssAssetResult, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles, transformWebTargetCss, debug, recordTimingDetail, getViteProcessedCssAssetResults, onUpdate, pendingRememberedCssReplayUpdates } = options;
|
|
3423
|
+
const collectStartedAt = performance.now();
|
|
3424
|
+
collectViteProcessedCssAssetResults(bundle, {
|
|
3425
|
+
opts,
|
|
3426
|
+
cssPipelineStrategy,
|
|
3427
|
+
createCssPipelineContext,
|
|
3428
|
+
isViteProcessedCssAsset,
|
|
3429
|
+
markCssAssetProcessed,
|
|
3430
|
+
recordCssAssetResult,
|
|
3431
|
+
recordViteProcessedCssAssetResult,
|
|
3432
|
+
resolveViteProcessedCssOutputFile: (file) => require_web.resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles),
|
|
3433
|
+
subpackageRoots: collectMiniProgramSubpackageRoots(bundle),
|
|
3434
|
+
transformCss: transformWebTargetCss,
|
|
3435
|
+
debug
|
|
3436
|
+
});
|
|
3437
|
+
recordTimingDetail("finalize.processedCss.collect", collectStartedAt);
|
|
3438
|
+
const injectStartedAt = performance.now();
|
|
3439
|
+
const currentResults = new Map([...getViteProcessedCssAssetResults?.() ?? []].map(([file, record]) => [require_source_candidate_scan_signature.normalizeOutputPathKey(file), [file, record]]));
|
|
3440
|
+
for (const update of pendingRememberedCssReplayUpdates) {
|
|
3441
|
+
recordViteProcessedCssAssetResult?.(update.file, update.css, update);
|
|
3442
|
+
currentResults.set(require_source_candidate_scan_signature.normalizeOutputPathKey(update.file), [update.file, {
|
|
3443
|
+
css: update.css,
|
|
3444
|
+
injectIntoMain: update.injectIntoMain,
|
|
3445
|
+
outputFile: update.outputFile
|
|
3446
|
+
}]);
|
|
3447
|
+
}
|
|
3448
|
+
const injected = injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
3449
|
+
opts,
|
|
3450
|
+
cssPipelineStrategy,
|
|
3451
|
+
createCssPipelineContext,
|
|
3452
|
+
getViteProcessedCssAssetResults: () => currentResults.values(),
|
|
3453
|
+
markCssAssetProcessed,
|
|
3454
|
+
recordCssAssetResult,
|
|
3455
|
+
transformCss: transformWebTargetCss,
|
|
3456
|
+
shouldRemoveInjectedSourceAsset: (targetFile, record) => {
|
|
3457
|
+
if (record.injectIntoMain === false) return false;
|
|
3458
|
+
const targetFileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile);
|
|
3459
|
+
return require_source_candidate_scan_signature.normalizeOutputPathKey(record.file) !== targetFileKey;
|
|
3460
|
+
},
|
|
3461
|
+
debug,
|
|
3462
|
+
onUpdate,
|
|
3463
|
+
recordTimingDetail
|
|
3464
|
+
});
|
|
3465
|
+
recordTimingDetail("finalize.processedCss.inject", injectStartedAt);
|
|
3466
|
+
return injected;
|
|
3467
|
+
}
|
|
3468
|
+
//#endregion
|
|
4019
3469
|
//#region src/bundlers/vite/generate-bundle/finalize/bundle.ts
|
|
4020
3470
|
async function finalizeGenerateBundle(options) {
|
|
4021
|
-
const { activeProcessCacheKeys, activeProcessHashKeys, activeViteCssCacheFiles, bundle, bundleFiles, cache, cssTaskFactories, cssPipelineStrategy, createCssPipelineContext, debug,
|
|
3471
|
+
const { activeProcessCacheKeys, activeProcessHashKeys, activeViteCssCacheFiles, bundle, bundleFiles, cache, cssTaskFactories, cssPipelineStrategy, createCssPipelineContext, debug, formatIteration, generatorCandidateSignature, generatorRuntime, getCssHandlerOptions, getSourceCandidateSourcesForEntries, getSourceCandidatesForEntries, getViteCssCacheStats, getViteProcessedCssAssetResults, hmrTimingRecorder, hmrTimingStartedAt, isHarmonyAppStyleTarget, isNativeAppStyleTarget, isViteProcessedCssAsset, isWebGeneratorTarget, jsAfterCss, jsTaskFactories, lastCssResultByFile, lastCssSourceHashByFile, linkedByEntry, metrics, onEnd, onUpdate, opts, outDir, pendingLinkedUpdates, prepareJsTransformRuntime, pruneViteCssCaches, recordCssAssetResult, recordTimingDetail, runtime, runtimeState, snapshot, sourceCandidates, state, styleHandler, tasks, timingDetails, transformRuntime, useIncrementalMode } = options;
|
|
4022
3472
|
const tasksStart = performance.now();
|
|
4023
3473
|
if (cssTaskFactories.length > 0) {
|
|
4024
3474
|
const cssConcurrency = resolveViteCssTaskConcurrency(useIncrementalMode, runtimeState.tailwindRuntime.majorVersion);
|
|
4025
|
-
const cssTask =
|
|
3475
|
+
const cssTask = require_generated_css_marker.runWithConcurrency(cssTaskFactories, cssConcurrency).then(() => void 0);
|
|
4026
3476
|
if (jsAfterCss) await cssTask;
|
|
4027
3477
|
else tasks.push(cssTask);
|
|
4028
3478
|
}
|
|
4029
3479
|
prepareJsTransformRuntime?.();
|
|
4030
|
-
if (jsTaskFactories.length > 0) tasks.push(
|
|
3480
|
+
if (jsTaskFactories.length > 0) tasks.push(require_generated_css_marker.runWithConcurrency(jsTaskFactories).then(() => void 0));
|
|
4031
3481
|
await Promise.all(tasks);
|
|
4032
3482
|
recordTimingDetail("tasks", tasksStart);
|
|
4033
3483
|
for (const apply of pendingLinkedUpdates) apply();
|
|
@@ -4049,68 +3499,11 @@ async function finalizeGenerateBundle(options) {
|
|
|
4049
3499
|
styleHandler
|
|
4050
3500
|
});
|
|
4051
3501
|
recordTimingDetail("finalize.uniAppXPostCss", uniAppXPostCssStartedAt);
|
|
4052
|
-
const syncViteProcessedCssIntoMainCssAssets = () => {
|
|
4053
|
-
const collectStartedAt = performance.now();
|
|
4054
|
-
collectViteProcessedCssAssetResults(bundle, {
|
|
4055
|
-
opts,
|
|
4056
|
-
cssPipelineStrategy,
|
|
4057
|
-
createCssPipelineContext,
|
|
4058
|
-
isViteProcessedCssAsset,
|
|
4059
|
-
markCssAssetProcessed,
|
|
4060
|
-
recordCssAssetResult,
|
|
4061
|
-
recordViteProcessedCssAssetResult,
|
|
4062
|
-
resolveViteProcessedCssOutputFile: (file) => require_web.resolveViteCssPipelineOutputFile(file, opts, rootDir, isWebGeneratorTarget, shouldPreserveAppCssExtension, sourceRoot, defaultStyleOutputExtension, bundleFiles),
|
|
4063
|
-
subpackageRoots: collectMiniProgramSubpackageRoots(bundle),
|
|
4064
|
-
transformCss: transformWebTargetCss,
|
|
4065
|
-
debug
|
|
4066
|
-
});
|
|
4067
|
-
recordTimingDetail("finalize.processedCss.collect", collectStartedAt);
|
|
4068
|
-
const injectStartedAt = performance.now();
|
|
4069
|
-
let injected = injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
4070
|
-
opts,
|
|
4071
|
-
cssPipelineStrategy,
|
|
4072
|
-
createCssPipelineContext,
|
|
4073
|
-
getViteProcessedCssAssetResults,
|
|
4074
|
-
markCssAssetProcessed,
|
|
4075
|
-
recordCssAssetResult,
|
|
4076
|
-
transformCss: transformWebTargetCss,
|
|
4077
|
-
shouldRemoveInjectedSourceAsset: (targetFile, record) => {
|
|
4078
|
-
if (record.injectIntoMain === false) return false;
|
|
4079
|
-
const targetFileKey = require_source_candidate_scan_signature.normalizeOutputPathKey(targetFile);
|
|
4080
|
-
return require_source_candidate_scan_signature.normalizeOutputPathKey(record.file) !== targetFileKey;
|
|
4081
|
-
},
|
|
4082
|
-
debug,
|
|
4083
|
-
onUpdate,
|
|
4084
|
-
recordTimingDetail
|
|
4085
|
-
});
|
|
4086
|
-
if (pendingRememberedCssReplayUpdates.length > 0) {
|
|
4087
|
-
for (const update of pendingRememberedCssReplayUpdates) recordViteProcessedCssAssetResult?.(update.file, update.css, update);
|
|
4088
|
-
injected += injectViteProcessedCssIntoMainCssAssets(bundle, {
|
|
4089
|
-
opts,
|
|
4090
|
-
cssPipelineStrategy,
|
|
4091
|
-
createCssPipelineContext,
|
|
4092
|
-
getViteProcessedCssAssetResults: () => pendingRememberedCssReplayUpdates.map((update) => [update.file, {
|
|
4093
|
-
css: update.css,
|
|
4094
|
-
injectIntoMain: update.injectIntoMain,
|
|
4095
|
-
outputFile: update.outputFile
|
|
4096
|
-
}]),
|
|
4097
|
-
markCssAssetProcessed,
|
|
4098
|
-
recordCssAssetResult,
|
|
4099
|
-
transformCss: transformWebTargetCss,
|
|
4100
|
-
debug,
|
|
4101
|
-
onUpdate,
|
|
4102
|
-
recordTimingDetail
|
|
4103
|
-
});
|
|
4104
|
-
debug("inject remembered css replay updates after framework css collection: %d", pendingRememberedCssReplayUpdates.length);
|
|
4105
|
-
}
|
|
4106
|
-
recordTimingDetail("finalize.processedCss.inject", injectStartedAt);
|
|
4107
|
-
return injected;
|
|
4108
|
-
};
|
|
4109
3502
|
const processedCssStartedAt = performance.now();
|
|
4110
|
-
|
|
3503
|
+
syncProcessedCss(options);
|
|
4111
3504
|
if (isHarmonyAppStyleTarget && applyStyleSources.length > 0) {
|
|
4112
3505
|
if (injectUniAppXHarmonyBundleStyles(bundle, { cssSources: [...getViteProcessedCssAssetResults?.() ?? []].map(([, record]) => typeof record === "string" ? record : record.css) })) debug("uni-app-x harmony bundle styles inject after css assets");
|
|
4113
|
-
|
|
3506
|
+
syncProcessedCss(options);
|
|
4114
3507
|
}
|
|
4115
3508
|
recordTimingDetail("finalize.processedCss", processedCssStartedAt);
|
|
4116
3509
|
const createFinalizeCssPipelineContext = (file = "") => createCssPipelineContext?.(file);
|
|
@@ -4268,7 +3661,7 @@ function collectUnescapedDynamicCandidates(source, allowedCandidates) {
|
|
|
4268
3661
|
let quoted = QUOTED_LITERAL_RE.exec(expression);
|
|
4269
3662
|
while (quoted !== null) {
|
|
4270
3663
|
const literal = quoted[1] ?? quoted[2] ?? quoted[3] ?? "";
|
|
4271
|
-
for (const candidate of (0,
|
|
3664
|
+
for (const candidate of (0, _weapp_tailwindcss_engine.splitCandidateTokens)(literal)) {
|
|
4272
3665
|
const normalized = candidate.trim();
|
|
4273
3666
|
if (!normalized || !isArbitraryValueCandidate(normalized)) continue;
|
|
4274
3667
|
if (shouldFilterByAllowedCandidates && !allowedCandidates.has(normalized)) continue;
|
|
@@ -4341,6 +3734,16 @@ function createJsEntryResolver(jsEntries) {
|
|
|
4341
3734
|
function resolveUniAppXJsTransformEnabled$1(uniAppX) {
|
|
4342
3735
|
return uniAppX === void 0 ? true : require_tailwindcss.isUniAppXEnabled(uniAppX);
|
|
4343
3736
|
}
|
|
3737
|
+
/**
|
|
3738
|
+
* generateBundle 里每个 chunk 都会独立转译。
|
|
3739
|
+
* 生产构建再走 moduleGraph 只会把已在产物里的 JS 再 Babel 一遍;增量模式才需要它更新被跳过的 clean chunk。
|
|
3740
|
+
*/
|
|
3741
|
+
function resolveGenerateBundleJsFastPath(options) {
|
|
3742
|
+
return {
|
|
3743
|
+
experimentalJsFastPath: options.experimentalJsFastPath ?? "oxc",
|
|
3744
|
+
moduleGraphEnabled: options.useIncrementalMode
|
|
3745
|
+
};
|
|
3746
|
+
}
|
|
4344
3747
|
function createJsHandlerOptionsFactory(options) {
|
|
4345
3748
|
return (absoluteFilename, extra) => ({
|
|
4346
3749
|
...extra,
|
|
@@ -4394,30 +3797,9 @@ function isUniAppXNativeAppOutDir(outDir) {
|
|
|
4394
3797
|
}
|
|
4395
3798
|
//#endregion
|
|
4396
3799
|
//#region src/uni-app-x/border-preflight.ts
|
|
4397
|
-
const BORDER_PREFLIGHT_CLASS =
|
|
4398
|
-
/** 框架回放组件样式后恢复基础规则的顺序,确保作者 class 可以覆盖重置。 */
|
|
4399
|
-
function hoistUniAppXBorderPreflight(css) {
|
|
4400
|
-
if (!css.includes("weapp-tw-border")) return css;
|
|
4401
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
4402
|
-
const resets = root.nodes.filter((node) => node.type === "rule" && node.selector === `.weapp-tw-border`);
|
|
4403
|
-
const anchor = root.nodes.find((node) => !resets.includes(node) && node.type !== "comment" && !(node.type === "atrule" && ["charset", "import"].includes(node.name)));
|
|
4404
|
-
if (!anchor || resets.length === 0) return css;
|
|
4405
|
-
for (const reset of resets) {
|
|
4406
|
-
reset.remove();
|
|
4407
|
-
root.insertBefore(anchor, reset);
|
|
4408
|
-
}
|
|
4409
|
-
return root.toString();
|
|
4410
|
-
}
|
|
4411
|
-
/** uni-app x 移除通配符 preflight 后,用独立基础类承载用户配置的边框默认值。 */
|
|
4412
|
-
function createUniAppXBorderPreflight(options) {
|
|
4413
|
-
const declarations = (0, _weapp_tailwindcss_postcss.createInjectPreflight)(options)().filter(({ prop }) => prop === "border" || prop.startsWith("border-"));
|
|
4414
|
-
if (declarations.length === 0) return;
|
|
4415
|
-
const rule = _weapp_tailwindcss_postcss.postcss.rule({ selector: `.${BORDER_PREFLIGHT_CLASS}` });
|
|
4416
|
-
for (const declaration of declarations) rule.append(_weapp_tailwindcss_postcss.postcss.decl(declaration));
|
|
4417
|
-
return rule.toString();
|
|
4418
|
-
}
|
|
3800
|
+
const BORDER_PREFLIGHT_CLASS = _weapp_tailwindcss_postcss_transform.UNI_APP_X_BORDER_PREFLIGHT_CLASS;
|
|
4419
3801
|
function resolveUniAppXBorderPreflightOptions(options, isWeb) {
|
|
4420
|
-
const borderPreflight = isWeb ? void 0 : createUniAppXBorderPreflight(options.cssPreflight);
|
|
3802
|
+
const borderPreflight = isWeb ? void 0 : (0, _weapp_tailwindcss_postcss_transform.createUniAppXBorderPreflight)(options.cssPreflight);
|
|
4421
3803
|
return borderPreflight ? {
|
|
4422
3804
|
borderPreflight,
|
|
4423
3805
|
borderPreflightRange: options.cssPreflightRange
|
|
@@ -4435,7 +3817,7 @@ function injectBorderPreflightClass(ms, node, offset) {
|
|
|
4435
3817
|
const attribute = node.props.find((prop) => prop.type === _vue_compiler_dom.NodeTypes.ATTRIBUTE && prop.name === "class");
|
|
4436
3818
|
if (attribute?.type === _vue_compiler_dom.NodeTypes.ATTRIBUTE) {
|
|
4437
3819
|
if (attribute.value) {
|
|
4438
|
-
if (attribute.value.content.split(/\s+/).includes(
|
|
3820
|
+
if (attribute.value.content.split(/\s+/).includes(BORDER_PREFLIGHT_CLASS)) return;
|
|
4439
3821
|
const start = offset + attribute.value.loc.start.offset;
|
|
4440
3822
|
if (/^["']/.test(attribute.value.loc.source)) ms.prependRight(start + 1, `${BORDER_PREFLIGHT_CLASS} `);
|
|
4441
3823
|
else {
|
|
@@ -4468,50 +3850,8 @@ function resolveUniAppXStyleIsolationEnabled(root) {
|
|
|
4468
3850
|
}
|
|
4469
3851
|
//#endregion
|
|
4470
3852
|
//#region src/uni-app-x/vite/author-apply.ts
|
|
4471
|
-
function
|
|
4472
|
-
return
|
|
4473
|
-
}
|
|
4474
|
-
function atRuleKey(name, params) {
|
|
4475
|
-
return `${name.toLowerCase()}\0${params.replace(/\s+/g, " ").trim()}`;
|
|
4476
|
-
}
|
|
4477
|
-
/**
|
|
4478
|
-
* `@apply` 只应把声明带回作者样式,不能把 Tailwind 根入口的 preflight、
|
|
4479
|
-
* utilities 和 property 注册复制进 scoped style 模块。
|
|
4480
|
-
*/
|
|
4481
|
-
function retainUniAppXAuthorApplyCss(generatedCss, authorCss) {
|
|
4482
|
-
try {
|
|
4483
|
-
const authorRoot = _weapp_tailwindcss_postcss.postcss.parse(require_generator.removeTailwindSourceDirectives(authorCss, { importFallback: true }));
|
|
4484
|
-
const authorSelectors = /* @__PURE__ */ new Set();
|
|
4485
|
-
const authorAtRules = /* @__PURE__ */ new Set();
|
|
4486
|
-
authorRoot.walkRules((rule) => {
|
|
4487
|
-
for (const selector of rule.selectors ?? [rule.selector]) authorSelectors.add(normalizeSelector(selector));
|
|
4488
|
-
});
|
|
4489
|
-
authorRoot.walkAtRules((atRule) => {
|
|
4490
|
-
if (atRule.name !== "apply" && atRule.name !== "reference") authorAtRules.add(atRuleKey(atRule.name, atRule.params));
|
|
4491
|
-
});
|
|
4492
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(generatedCss);
|
|
4493
|
-
let changed = false;
|
|
4494
|
-
root.walkRules((rule) => {
|
|
4495
|
-
if ((rule.selectors ?? [rule.selector]).every((selector) => authorSelectors.has(normalizeSelector(selector)))) return;
|
|
4496
|
-
rule.remove();
|
|
4497
|
-
changed = true;
|
|
4498
|
-
});
|
|
4499
|
-
root.walkAtRules((atRule) => {
|
|
4500
|
-
if (authorAtRules.has(atRuleKey(atRule.name, atRule.params))) return;
|
|
4501
|
-
if (atRule.nodes?.some((node) => node.type === "rule" || node.type === "atrule")) return;
|
|
4502
|
-
atRule.remove();
|
|
4503
|
-
changed = true;
|
|
4504
|
-
});
|
|
4505
|
-
root.walkComments((comment) => {
|
|
4506
|
-
if (/tailwindcss v\d|weapp-tailwindcss (?:vite-generated-css|layer|uni-app-x web preflight reset)/i.test(comment.text)) {
|
|
4507
|
-
comment.remove();
|
|
4508
|
-
changed = true;
|
|
4509
|
-
}
|
|
4510
|
-
});
|
|
4511
|
-
return changed ? root.toString().trim() : generatedCss;
|
|
4512
|
-
} catch {
|
|
4513
|
-
return generatedCss;
|
|
4514
|
-
}
|
|
3853
|
+
function retainUniAppXAuthorApplyCss(generatedCss, authorCss, options) {
|
|
3854
|
+
return (0, _weapp_tailwindcss_postcss_transform.retainUniAppXAuthorApplyCss)(generatedCss, (0, _weapp_tailwindcss_postcss_transform.removeTailwindSourceDirectives)(authorCss, { importFallback: true }), options);
|
|
4515
3855
|
}
|
|
4516
3856
|
//#endregion
|
|
4517
3857
|
//#region src/uni-app-x/vite/harmony-apply.ts
|
|
@@ -4533,12 +3873,7 @@ function createUniAppXHarmonyApplyExpander(options) {
|
|
|
4533
3873
|
const references = authoritative ? /* @__PURE__ */ new Set() : new Set(referenceBySourceId.get(sourceKey));
|
|
4534
3874
|
for (const source of sources) {
|
|
4535
3875
|
styleSources.add(source);
|
|
4536
|
-
|
|
4537
|
-
_weapp_tailwindcss_postcss.postcss.parse(source).walkAtRules("reference", (rule) => {
|
|
4538
|
-
const reference = rule.toString();
|
|
4539
|
-
references.add(reference.endsWith(";") ? reference : `${reference};`);
|
|
4540
|
-
});
|
|
4541
|
-
} catch {}
|
|
3876
|
+
for (const reference of (0, _weapp_tailwindcss_postcss_transform.collectCssReferenceDirectives)(source)) references.add(reference);
|
|
4542
3877
|
for (const utility of collectUniAppXHarmonyApplyUtilitiesFromSources([source])) utilities.add(utility);
|
|
4543
3878
|
}
|
|
4544
3879
|
if (references.size > 0) referenceBySourceId.set(sourceKey, references);
|
|
@@ -4558,7 +3893,7 @@ function createUniAppXHarmonyApplyExpander(options) {
|
|
|
4558
3893
|
const cssFile = node_path.default.resolve(options.getResolvedConfig()?.root ?? node_process.default.cwd(), `uni-app-x-harmony-apply-${createStableHash(require_web.normalizePath((0, _weapp_tailwindcss_shared.cleanUrl)(id)))}.css`);
|
|
4559
3894
|
const generatorSource = createUniAppXHarmonyApplyGeneratorSource(sources, sourceUtilities);
|
|
4560
3895
|
const generatedCss = await options.generateCss?.(cssFile, generatorSource, {
|
|
4561
|
-
addWatchFile: hookContext.addWatchFile
|
|
3896
|
+
...hookContext.addWatchFile ? { addWatchFile: hookContext.addWatchFile.bind(hookContext) } : {},
|
|
4562
3897
|
disableSourceScan: true,
|
|
4563
3898
|
sourceCandidates: [],
|
|
4564
3899
|
transient: true
|
|
@@ -4630,7 +3965,7 @@ const UVUE_NVUE_RE$1 = /\.(?:uvue|nvue)$/;
|
|
|
4630
3965
|
const CSS_MODULE_EXPORT_RE = /^\s*export\s+default\s+(?:\{|\w|\[\])/;
|
|
4631
3966
|
const RELATIVE_REFERENCE_RE = /@reference\s+(["'])(\.\.?[\\/][^"']+)\1\s*;?/g;
|
|
4632
3967
|
function isPreprocessorRequest(id, lang) {
|
|
4633
|
-
return
|
|
3968
|
+
return require_generated_css_marker.isSourcePreprocessorRequest(id, lang);
|
|
4634
3969
|
}
|
|
4635
3970
|
function resolveUniAppXCssTarget(id) {
|
|
4636
3971
|
return UVUE_NVUE_RE$1.test((0, _weapp_tailwindcss_shared.cleanUrl)(id)) ? "uvue" : void 0;
|
|
@@ -4648,7 +3983,7 @@ function normalizeRelativeTailwindReferences(code, id) {
|
|
|
4648
3983
|
function resolvePreprocessorTransform(code, id, lang, options) {
|
|
4649
3984
|
if (!isPreprocessorRequest(id, lang)) return;
|
|
4650
3985
|
if (options.isIosPlatform) {
|
|
4651
|
-
const normalizedCode = (0,
|
|
3986
|
+
const normalizedCode = (0, _weapp_tailwindcss_postcss_transform.normalizeTailwindcssV4InfinityCalcCss)(code);
|
|
4652
3987
|
return { result: normalizedCode === code ? void 0 : {
|
|
4653
3988
|
code: normalizedCode,
|
|
4654
3989
|
map: null
|
|
@@ -4661,6 +3996,18 @@ function reportStyleWarnings(result) {
|
|
|
4661
3996
|
for (const warning of warnings) _weapp_tailwindcss_logger.logger.warn(warning.toString());
|
|
4662
3997
|
}
|
|
4663
3998
|
//#endregion
|
|
3999
|
+
//#region src/uni-app-x/vite/style-result.ts
|
|
4000
|
+
/** 将样式处理结果和源码映射统一转换为 Vite 模块结果。 */
|
|
4001
|
+
async function createUniAppXStyleResult(id, result) {
|
|
4002
|
+
reportStyleWarnings(result);
|
|
4003
|
+
const rawPostcssMap = result.map.toJSON();
|
|
4004
|
+
const map = await require_web.formatPostcssSourceMap(rawPostcssMap, require_web.normalizePath((0, _weapp_tailwindcss_shared.cleanUrl)(id)));
|
|
4005
|
+
return {
|
|
4006
|
+
code: result.css,
|
|
4007
|
+
map: JSON.stringify(map)
|
|
4008
|
+
};
|
|
4009
|
+
}
|
|
4010
|
+
//#endregion
|
|
4664
4011
|
//#region src/uni-app-x/vite/style-source.ts
|
|
4665
4012
|
const VITE_CSS_HMR_MODULE_RE = /\b(?:const\s+__vite__css\s*=|__vite__updateStyle\s*\()/;
|
|
4666
4013
|
function createUniAppXSfcStyleSources() {
|
|
@@ -4702,7 +4049,7 @@ function createUniAppXSfcStyleSources() {
|
|
|
4702
4049
|
map: null
|
|
4703
4050
|
};
|
|
4704
4051
|
}
|
|
4705
|
-
const normalized = (0,
|
|
4052
|
+
const normalized = (0, _weapp_tailwindcss_postcss_transform.normalizeUniAppXImportantApplyForSass)(style.source);
|
|
4706
4053
|
return normalized === style.source ? void 0 : {
|
|
4707
4054
|
code: normalized,
|
|
4708
4055
|
map: null
|
|
@@ -4773,7 +4120,7 @@ function createUniAppXWebSfcHmr(options) {
|
|
|
4773
4120
|
if (!enabled(ctx)) return false;
|
|
4774
4121
|
options.hmrCssModuleVersions?.clear();
|
|
4775
4122
|
const source = sources.get(ctx) ?? await ctx.read();
|
|
4776
|
-
if (hasUniAppXImportantApply(source,
|
|
4123
|
+
if (hasUniAppXImportantApply(source, _weapp_tailwindcss_postcss_transform.normalizeUniAppXImportantApplyForSass)) {
|
|
4777
4124
|
ctx.server.ws.send({
|
|
4778
4125
|
type: "full-reload",
|
|
4779
4126
|
path: ctx.file
|
|
@@ -4829,7 +4176,7 @@ function createUniAppXAssetTask(file, originalSource, outDir, options) {
|
|
|
4829
4176
|
//#region src/uni-app-x/vite.ts
|
|
4830
4177
|
let transformUVuePromise;
|
|
4831
4178
|
function loadTransformUVue() {
|
|
4832
|
-
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-
|
|
4179
|
+
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-D2KFdA3C.cjs")).then((mod) => mod.transformUVue));
|
|
4833
4180
|
return transformUVuePromise;
|
|
4834
4181
|
}
|
|
4835
4182
|
const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
@@ -4911,9 +4258,9 @@ function createUniAppXPlugins(options) {
|
|
|
4911
4258
|
code = resolvedSource.code;
|
|
4912
4259
|
if (require_web.isCSSRequest(id) || parsed.vue && parsed.type === "style") {
|
|
4913
4260
|
if (isCssModuleExport(code)) return;
|
|
4914
|
-
const sourceCode = normalizeRelativeTailwindReferences((0,
|
|
4915
|
-
const hasTailwindRoot =
|
|
4916
|
-
const hasTailwindApply =
|
|
4261
|
+
const sourceCode = normalizeRelativeTailwindReferences((0, _weapp_tailwindcss_postcss_transform.restoreUniAppXImportantApplyMarker)(code), id);
|
|
4262
|
+
const hasTailwindRoot = (0, _weapp_tailwindcss_postcss_transform.hasTailwindRootDirectives)(sourceCode, { importFallback: true });
|
|
4263
|
+
const hasTailwindApply = (0, _weapp_tailwindcss_postcss_transform.hasTailwindApplyDirective)(sourceCode);
|
|
4917
4264
|
const shouldGenerateCss = hasTailwindRoot || hasTailwindApply;
|
|
4918
4265
|
const isNativeSfcAuthorStyle = isNativeStyle && resolveUniAppXCssTarget(id) === "uvue";
|
|
4919
4266
|
if (!shouldGenerateCss && (!isNativeStyle || isNativeSfcAuthorStyle)) return;
|
|
@@ -4921,19 +4268,12 @@ function createUniAppXPlugins(options) {
|
|
|
4921
4268
|
const generatedCss = shouldGenerateCss ? await generateCss?.(id, isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot ? harmonyApply.prepareStyles(sourceCode, id) : sourceCode, {
|
|
4922
4269
|
...hookContext,
|
|
4923
4270
|
disableSourceScan: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot,
|
|
4924
|
-
|
|
4271
|
+
...isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot ? { sourceCandidates: [] } : {},
|
|
4925
4272
|
transient: isNativeSfcAuthorStyle && hasTailwindApply && !hasTailwindRoot
|
|
4926
4273
|
}) : void 0;
|
|
4927
|
-
const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? hasTailwindApply && !hasTailwindRoot ? retainUniAppXAuthorApplyCss(generatedCss, sourceCode) : generatedCss : sourceCode;
|
|
4274
|
+
const styleCode = typeof generatedCss === "string" && generatedCss.trim().length > 0 ? hasTailwindApply && !hasTailwindRoot ? retainUniAppXAuthorApplyCss(generatedCss, sourceCode, { preserveRuntimeProperties: isWebGeneratorTarget() }) : generatedCss : sourceCode;
|
|
4928
4275
|
const styleHandlerOptions = getStyleHandlerOptions(id, isNativeStyle && hasTailwindRoot ? "tailwind-root" : isNativeStyle ? "author-apply" : void 0);
|
|
4929
|
-
|
|
4930
|
-
reportStyleWarnings(postcssResult);
|
|
4931
|
-
const rawPostcssMap = postcssResult.map.toJSON();
|
|
4932
|
-
const postcssMap = await require_web.formatPostcssSourceMap(rawPostcssMap, require_web.normalizePath((0, _weapp_tailwindcss_shared.cleanUrl)(id)));
|
|
4933
|
-
return {
|
|
4934
|
-
code: postcssResult.css,
|
|
4935
|
-
map: postcssMap
|
|
4936
|
-
};
|
|
4276
|
+
return createUniAppXStyleResult(id, isWebGeneratorTarget() && typeof generatedCss === "string" && generatedCss.trim().length > 0 ? await (0, _weapp_tailwindcss_postcss_transform.postcss)().process(styleCode, styleHandlerOptions.postcssOptions.options) : await styleHandler(styleCode, styleHandlerOptions));
|
|
4937
4277
|
}
|
|
4938
4278
|
}
|
|
4939
4279
|
const harmonyApply = createUniAppXHarmonyApplyExpander({
|
|
@@ -4978,7 +4318,7 @@ function createUniAppXPlugins(options) {
|
|
|
4978
4318
|
const resolvedSource = resolveUniAppXStyleSource(code, query, generatedSource);
|
|
4979
4319
|
if (resolvedSource.skip) return;
|
|
4980
4320
|
const styleCode = query.vue && query.type === "style" && generatedSource === void 0 && !sfcStyleSources.hasGenerated(filename) ? webLocalStyle.appendToStyle(resolvedSource.code, id) : resolvedSource.code;
|
|
4981
|
-
const preprocessorCode = query.vue && query.type === "style" ? (0,
|
|
4321
|
+
const preprocessorCode = query.vue && query.type === "style" ? (0, _weapp_tailwindcss_postcss_transform.normalizeUniAppXImportantApplyForSass)(styleCode) : styleCode;
|
|
4982
4322
|
const preprocessor = resolvePreprocessorTransform(preprocessorCode, id, query.lang, {
|
|
4983
4323
|
isIosPlatform,
|
|
4984
4324
|
isNativeAppStyleTarget: isNativeAppStyleTarget()
|
|
@@ -5017,6 +4357,7 @@ function createUniAppXPlugins(options) {
|
|
|
5017
4357
|
...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
|
|
5018
4358
|
...enablePageLocalStyle ? { enablePageLocalStyle } : {},
|
|
5019
4359
|
native: true,
|
|
4360
|
+
localStyleVariants: !isNativeAppBuildTarget(id) && !isWebGeneratorTarget() ? true : void 0,
|
|
5020
4361
|
...resolveUniAppXBorderPreflightOptions(options, isWebGeneratorTarget()),
|
|
5021
4362
|
pageMatcher: resolvedUniAppXOptions.componentLocalStyles.pageMatcher,
|
|
5022
4363
|
...isWebGeneratorTarget() && customAttributesEntities.length > 0 ? { webCustomAttributeDeep: true } : {},
|
|
@@ -5288,7 +4629,7 @@ function logBundleProcessPlan(options) {
|
|
|
5288
4629
|
//#region src/bundlers/vite/generate-bundle/remembered-css-replay.ts
|
|
5289
4630
|
function shouldSkipRawRememberedCssSource(rawSource, sourceFile) {
|
|
5290
4631
|
const cleanSourceFile = sourceFile.replace(/[?#].*$/, "");
|
|
5291
|
-
return (require_web.SOURCE_STYLE_OUTPUT_EXT_RE.test(cleanSourceFile) ||
|
|
4632
|
+
return (require_web.SOURCE_STYLE_OUTPUT_EXT_RE.test(cleanSourceFile) || require_generated_css_marker.isSourcePreprocessorRequest(sourceFile)) && !require_web.canProcessViteSourceStyleAsCss(rawSource, sourceFile);
|
|
5292
4633
|
}
|
|
5293
4634
|
function resolveRememberedCssReplayOutputFile(outputFile, targetByFile) {
|
|
5294
4635
|
const outputKey = require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile);
|
|
@@ -5327,12 +4668,13 @@ async function processRememberedCssReplay(options) {
|
|
|
5327
4668
|
const rememberedCssSource = mergeRememberedCssSources(replayableRememberedGroup.map((item) => item.remembered), outputFile);
|
|
5328
4669
|
if (!rememberedCssSource) continue;
|
|
5329
4670
|
const { sourceFile } = rememberedCssSource;
|
|
5330
|
-
|
|
4671
|
+
if (normalizedBundleFiles.has(require_source_candidate_scan_signature.normalizeOutputPathKey(rememberedOutputFile)) || normalizedBundleFiles.has(require_source_candidate_scan_signature.normalizeOutputPathKey(sourceFile)) || bundleFiles.includes(rememberedOutputFile) || bundleFiles.includes(sourceFile)) continue;
|
|
4672
|
+
const rawSource = isWebGeneratorTarget ? rememberedCssSource.rawSource : (0, _weapp_tailwindcss_postcss_transform.normalizeMiniProgramImportShell)(rememberedCssSource.rawSource, {
|
|
5331
4673
|
cssOnly: true,
|
|
5332
4674
|
outputFile,
|
|
5333
4675
|
outputFiles: [...bundleFiles, ...lastCssResultByFile.keys()]
|
|
5334
4676
|
});
|
|
5335
|
-
const generatorRawSource = isWebGeneratorTarget ? rawSource :
|
|
4677
|
+
const generatorRawSource = isWebGeneratorTarget ? rawSource : (0, _weapp_tailwindcss_postcss_transform.normalizeMiniProgramGeneratorCssSource)(rawSource, outputFile, [...bundleFiles, ...lastCssResultByFile.keys()]);
|
|
5336
4678
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(outputFile));
|
|
5337
4679
|
activeViteCssCacheFiles.add(normalizeViteCssCacheKey(sourceFile));
|
|
5338
4680
|
const outputCssHandlerOptions = getCssHandlerOptions(rememberedOutputFile);
|
|
@@ -5354,24 +4696,14 @@ async function processRememberedCssReplay(options) {
|
|
|
5354
4696
|
const cssSourceChanged = changedCssFiles.has(outputFile) || changedCssFiles.has(sourceFile) || previousRawSourceHash != null && previousRawSourceHash !== rawSourceHash;
|
|
5355
4697
|
const previousCss = useIncrementalMode && !cssSourceChanged && getLastCssSourceHash(lastCssSourceHashByFile, outputFile) === cssRuntimeAffectingHash ? getLastCssResult(lastCssResultByFile, outputFile) : void 0;
|
|
5356
4698
|
const allRememberedSignaturesFresh = rememberedKeys.length > 0 && rememberedKeys.every((key) => getRememberedCssSignature?.(key) === rememberedCssRuntimeSignature);
|
|
5357
|
-
|
|
5358
|
-
const
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
const cachedCss = getLastCssResult(lastCssResultByFile, outputFile);
|
|
5363
|
-
if (cachedCss != null) {
|
|
5364
|
-
pendingRememberedCssReplayUpdates.push(...createRememberedCssReplayUpdates(cachedCss, sourceFile, outputFile, true));
|
|
5365
|
-
metrics.css.cacheHits++;
|
|
5366
|
-
debug("css replay cached result into framework root target: %s", outputFile);
|
|
5367
|
-
continue;
|
|
5368
|
-
}
|
|
5369
|
-
debug("css replay framework root target cache miss, regenerate: %s", outputFile);
|
|
5370
|
-
}
|
|
5371
|
-
}
|
|
4699
|
+
const shouldMergeReplayIntoFrameworkRootTarget = [...frameworkRootImportShellTargetByFile ?? []].some(([file, target]) => require_source_candidate_scan_signature.normalizeOutputPathKey(target) === require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile) && normalizedBundleFiles.has(require_source_candidate_scan_signature.normalizeOutputPathKey(file))) || outputFile !== rememberedOutputFile && normalizedBundleFiles.has(require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile));
|
|
4700
|
+
const generatedReplayKey = createGeneratedReplayCacheKey(outputFile);
|
|
4701
|
+
activeViteCssCacheFiles.add(generatedReplayKey);
|
|
4702
|
+
const cachedGeneratedReplayCss = allRememberedSignaturesFresh && shouldMergeReplayIntoFrameworkRootTarget ? lastCssResultByFile.get(generatedReplayKey) : void 0;
|
|
4703
|
+
if (allRememberedSignaturesFresh && !shouldMergeReplayIntoFrameworkRootTarget) continue;
|
|
5372
4704
|
const sourceTraceSources = scopedSourceCandidateSourceGetter ? await require_scoped_generator.createScopedGeneratorSourceTraceMap(generatorRawSource, sourceFile, scopedSourceCandidateSourceGetter) : void 0;
|
|
5373
|
-
const sourceTraceTokenSources = sourceTraceSources ?
|
|
5374
|
-
const annotateCss = (css) =>
|
|
4705
|
+
const sourceTraceTokenSources = sourceTraceSources ? require_generated_css_marker.createCssTokenSourceMap(sourceTraceSources, opts) : void 0;
|
|
4706
|
+
const annotateCss = (css) => require_generated_css_marker.annotateCssSourceTrace(css, {
|
|
5375
4707
|
opts,
|
|
5376
4708
|
tokenSources: sourceTraceTokenSources
|
|
5377
4709
|
});
|
|
@@ -5388,7 +4720,7 @@ async function processRememberedCssReplay(options) {
|
|
|
5388
4720
|
css: rawSource,
|
|
5389
4721
|
file: outputFile
|
|
5390
4722
|
})
|
|
5391
|
-
}) || !isRootMiniProgramStyleOutputFile$1(outputFile) && !isWebGeneratorTarget && (0,
|
|
4723
|
+
}) || !isRootMiniProgramStyleOutputFile$1(outputFile) && !isWebGeneratorTarget && (0, _weapp_tailwindcss_postcss_transform.isPureLocalCssImportWrapper)(rawSource);
|
|
5392
4724
|
const emitRememberedCssAsset = (css) => {
|
|
5393
4725
|
const plan = new require_compiler.AssetEmissionPlan();
|
|
5394
4726
|
let replayAsset;
|
|
@@ -5405,7 +4737,7 @@ async function processRememberedCssReplay(options) {
|
|
|
5405
4737
|
if (shouldPreserveLocalImportWrapper) {
|
|
5406
4738
|
cssTaskFactories.push(() => timeTask("css.replay", async () => {
|
|
5407
4739
|
const start = performance.now();
|
|
5408
|
-
const css = annotateCss(
|
|
4740
|
+
const css = annotateCss((0, _weapp_tailwindcss_postcss_transform.normalizeMiniProgramImportShell)(rawSource));
|
|
5409
4741
|
lastCssRawSourceHashByFile.set(outputFile, rawSourceHash);
|
|
5410
4742
|
rememberLastCssResult(lastCssResultByFile, lastCssSourceHashByFile, outputFile, css, cssRuntimeAffectingHash);
|
|
5411
4743
|
for (const key of rememberedKeys) setRememberedCssSignature?.(key, rememberedCssRuntimeSignature);
|
|
@@ -5418,9 +4750,23 @@ async function processRememberedCssReplay(options) {
|
|
|
5418
4750
|
}));
|
|
5419
4751
|
continue;
|
|
5420
4752
|
}
|
|
4753
|
+
if (cachedGeneratedReplayCss) {
|
|
4754
|
+
cssTaskFactories.push(() => timeTask("css.replay", async () => {
|
|
4755
|
+
const start = performance.now();
|
|
4756
|
+
lastCssRawSourceHashByFile.set(outputFile, rawSourceHash);
|
|
4757
|
+
for (const key of rememberedKeys) setRememberedCssSignature?.(key, rememberedCssRuntimeSignature);
|
|
4758
|
+
recordCssAssetResult?.(outputFile, cachedGeneratedReplayCss);
|
|
4759
|
+
pendingRememberedCssReplayUpdates.push(...createRememberedCssReplayUpdates(cachedGeneratedReplayCss, sourceFile, outputFile, true));
|
|
4760
|
+
metrics.css.elapsed += measureElapsed(start);
|
|
4761
|
+
metrics.css.cacheHits++;
|
|
4762
|
+
onUpdate(outputFile, rememberedCssSource.rawSource, cachedGeneratedReplayCss);
|
|
4763
|
+
debug("css replay reuse generated cache: %s bytes=%d", outputFile, cachedGeneratedReplayCss.length);
|
|
4764
|
+
}));
|
|
4765
|
+
continue;
|
|
4766
|
+
}
|
|
5421
4767
|
cssTaskFactories.push(() => timeTask("css.replay", async () => {
|
|
5422
4768
|
const start = performance.now();
|
|
5423
|
-
const generated = await
|
|
4769
|
+
const generated = await require_generated_css_marker.generateTailwindV4Css({
|
|
5424
4770
|
opts,
|
|
5425
4771
|
runtimeState,
|
|
5426
4772
|
runtime: scopedGeneratorRuntime,
|
|
@@ -5434,11 +4780,12 @@ async function processRememberedCssReplay(options) {
|
|
|
5434
4780
|
generatorPlatform,
|
|
5435
4781
|
styleHandler,
|
|
5436
4782
|
debug,
|
|
5437
|
-
previousCss
|
|
4783
|
+
previousCss: shouldMergeReplayIntoFrameworkRootTarget ? void 0 : previousCss
|
|
5438
4784
|
});
|
|
5439
4785
|
const css = annotateCss(generated?.css ?? (await styleHandler(generatorRawSource, cssHandlerOptions)).css);
|
|
5440
4786
|
lastCssRawSourceHashByFile.set(outputFile, rawSourceHash);
|
|
5441
4787
|
rememberLastCssResult(lastCssResultByFile, lastCssSourceHashByFile, outputFile, css, cssRuntimeAffectingHash);
|
|
4788
|
+
rememberLastCssResult(lastCssResultByFile, lastCssSourceHashByFile, generatedReplayKey, css, cssRuntimeAffectingHash);
|
|
5442
4789
|
for (const key of rememberedKeys) setRememberedCssSignature?.(key, rememberedCssRuntimeSignature);
|
|
5443
4790
|
if (generated) {
|
|
5444
4791
|
registerGeneratorDependencies({ addWatchFile }, generated.dependencies);
|
|
@@ -5498,7 +4845,7 @@ function createConfiguredCssSourceRegistry(options) {
|
|
|
5498
4845
|
return {
|
|
5499
4846
|
explicitCssEntryFiles,
|
|
5500
4847
|
getSourceEntries,
|
|
5501
|
-
normalizeGeneratorUserRawSource: (source, sourceFile, fallbackFile) => normalizeRelativeCssConfigDirectives(source, sourceFile || fallbackFile, options.outDir, options.opts),
|
|
4848
|
+
normalizeGeneratorUserRawSource: (source, sourceFile, fallbackFile) => normalizeRelativeCssConfigDirectives(source, sourceFile || (fallbackFile ?? ""), options.outDir, options.opts),
|
|
5502
4849
|
resolveMatchedSourceOutputFile: (sourceFile) => resolveOutputFileFromMatchedCssSource({
|
|
5503
4850
|
bundleFiles: options.bundleFiles,
|
|
5504
4851
|
defaultStyleOutputExtension: options.defaultStyleOutputExtension,
|
|
@@ -5952,11 +5299,11 @@ async function validateRuntimeCandidates(options) {
|
|
|
5952
5299
|
const mainCssEntry = options.cssEntries.find((entry) => options.getCssHandlerOptions(entry.file).isMainChunk) ?? options.cssEntries[0];
|
|
5953
5300
|
if (!mainCssEntry) return;
|
|
5954
5301
|
const mainCssRawSource = typeof mainCssEntry.output.source === "string" ? mainCssEntry.output.source : node_buffer.Buffer.from(mainCssEntry.output.source).toString();
|
|
5955
|
-
if (
|
|
5302
|
+
if ((0, _weapp_tailwindcss_postcss_transform.hasTailwindApplyDirective)(mainCssRawSource)) return;
|
|
5956
5303
|
const generatedCssSources = /* @__PURE__ */ new Set();
|
|
5957
5304
|
for (const [, record] of options.getViteProcessedCssAssetResults?.() ?? []) if (typeof record === "string") generatedCssSources.add(record);
|
|
5958
5305
|
else if (typeof record?.css === "string") generatedCssSources.add(record.css);
|
|
5959
|
-
const validatedSourceRuntime = await
|
|
5306
|
+
const validatedSourceRuntime = await require_generated_css_marker.validateCandidatesByGenerator({
|
|
5960
5307
|
candidates: options.sourceCandidates,
|
|
5961
5308
|
cssHandlerOptions: options.getCssHandlerOptions(mainCssEntry.file),
|
|
5962
5309
|
cssUserHandlerOptions: options.getCssUserHandlerOptions(mainCssEntry.file),
|
|
@@ -6067,10 +5414,10 @@ function createGenerateBundleHook$1(context) {
|
|
|
6067
5414
|
const transformWebTargetCss = (css) => {
|
|
6068
5415
|
return context.cssPipelineStrategy?.transformGeneratedCss?.(css, {
|
|
6069
5416
|
...cssPipelineContext,
|
|
6070
|
-
defaultWebCssCompat: (value) => (0,
|
|
5417
|
+
defaultWebCssCompat: (value) => (0, _weapp_tailwindcss_postcss_transform.transformWebCssCompat)(value, require_web.resolveViteWebCssCompatOptions(cssPipelineContext)),
|
|
6071
5418
|
removeScopedPreflight: (value) => value,
|
|
6072
5419
|
shouldApplyWebCssCompat
|
|
6073
|
-
}) ?? (shouldApplyWebCssCompat ? (0,
|
|
5420
|
+
}) ?? (shouldApplyWebCssCompat ? (0, _weapp_tailwindcss_postcss_transform.transformWebCssCompat)(css, require_web.resolveViteWebCssCompatOptions(cssPipelineContext)) : css);
|
|
6074
5421
|
};
|
|
6075
5422
|
const isNativeAppStyleTarget = context.cssPipelineStrategy?.isNativeAppStyleTarget?.(cssPipelineContext) === true;
|
|
6076
5423
|
const isHarmonyAppStyleTarget = context.cssPipelineStrategy?.isHarmonyAppStyleTarget?.(cssPipelineContext) === true;
|
|
@@ -6082,12 +5429,12 @@ function createGenerateBundleHook$1(context) {
|
|
|
6082
5429
|
const outDir = resolvedConfig?.build?.outDir ? node_path.default.resolve(rootDir, resolvedConfig.build.outDir) : rootDir;
|
|
6083
5430
|
const defaultStyleOutputExtension = require_web.resolveMiniProgramStyleOutputExtension({ files: Object.keys(bundle) });
|
|
6084
5431
|
const normalizeMiniProgramGeneratorRawSource = (source, outputFile) => {
|
|
6085
|
-
return isWebGeneratorTarget ? source :
|
|
5432
|
+
return isWebGeneratorTarget ? source : (0, _weapp_tailwindcss_postcss_transform.normalizeMiniProgramGeneratorCssSource)(source, outputFile, [...Object.keys(bundle), ...lastCssResultByFile.keys()]);
|
|
6086
5433
|
};
|
|
6087
5434
|
await runtimeState.readyPromise;
|
|
6088
5435
|
debug("start");
|
|
6089
5436
|
onStart();
|
|
6090
|
-
const collectedBundlerGeneratedCssFiles = new Set(Object.entries(bundle).filter(([, output]) => output.type === "asset" &&
|
|
5437
|
+
const collectedBundlerGeneratedCssFiles = new Set(Object.entries(bundle).filter(([, output]) => output.type === "asset" && (0, _weapp_tailwindcss_postcss_transform.hasBundlerGeneratedCssMarker)(output.source)).map(([file]) => file));
|
|
6091
5438
|
const subpackageRoots = collectMiniProgramSubpackageRoots(bundle);
|
|
6092
5439
|
if (subpackageRoots) currentSubpackageRoots = subpackageRoots;
|
|
6093
5440
|
collectViteProcessedCssAssetResults(bundle, {
|
|
@@ -6208,7 +5555,11 @@ function createGenerateBundleHook$1(context) {
|
|
|
6208
5555
|
const jsEntries = snapshot.jsEntries;
|
|
6209
5556
|
const getJsEntry = createJsEntryResolver(jsEntries);
|
|
6210
5557
|
const transformFilterSignature = createTransformFilterSignature(opts.transform);
|
|
6211
|
-
const
|
|
5558
|
+
const jsFastPath = resolveGenerateBundleJsFastPath({
|
|
5559
|
+
experimentalJsFastPath: opts.experimentalJsFastPath,
|
|
5560
|
+
useIncrementalMode
|
|
5561
|
+
});
|
|
5562
|
+
const moduleGraphOptions = jsFastPath.moduleGraphEnabled ? createBundleModuleGraphOptions(outDir, jsEntries) : void 0;
|
|
6212
5563
|
const hasRuntimeAffectingChanges = require_scoped_generator.hasRuntimeAffectingSourceChanges(snapshot.runtimeAffectingChangedByType);
|
|
6213
5564
|
const runtimeStart = performance.now();
|
|
6214
5565
|
const forceV4RuntimeRefreshBySource = forceRuntimeRefreshBySource;
|
|
@@ -6318,7 +5669,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
6318
5669
|
debug
|
|
6319
5670
|
});
|
|
6320
5671
|
const createBaseHandlerOptions = createJsHandlerOptionsFactory({
|
|
6321
|
-
getExperimentalJsFastPath: () =>
|
|
5672
|
+
getExperimentalJsFastPath: () => jsFastPath.experimentalJsFastPath,
|
|
6322
5673
|
getMajorVersion: () => runtimeState.tailwindRuntime.majorVersion,
|
|
6323
5674
|
moduleGraph: moduleGraphOptions
|
|
6324
5675
|
});
|
|
@@ -6391,7 +5742,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
6391
5742
|
await processViteCssBundleEntry({
|
|
6392
5743
|
activeViteCssCacheFiles,
|
|
6393
5744
|
addWatchFile,
|
|
6394
|
-
annotateCssSourceTrace:
|
|
5745
|
+
annotateCssSourceTrace: require_generated_css_marker.annotateCssSourceTrace,
|
|
6395
5746
|
applyCssResultToBundle,
|
|
6396
5747
|
applyViteCssCacheResult,
|
|
6397
5748
|
applyViteCssTransformTaskResult,
|
|
@@ -6403,8 +5754,8 @@ function createGenerateBundleHook$1(context) {
|
|
|
6403
5754
|
configuredTailwindV4ExplicitCssEntryFileKeysForScope,
|
|
6404
5755
|
context,
|
|
6405
5756
|
createCandidateSignature: require_scoped_generator.createCandidateSignature,
|
|
6406
|
-
createCssSourceTraceCacheSignature:
|
|
6407
|
-
createCssTokenSourceMap:
|
|
5757
|
+
createCssSourceTraceCacheSignature: require_generated_css_marker.createCssSourceTraceCacheSignature,
|
|
5758
|
+
createCssTokenSourceMap: require_generated_css_marker.createCssTokenSourceMap,
|
|
6408
5759
|
createCssTransformShareScopeKey,
|
|
6409
5760
|
createInitialCssPipelineContext,
|
|
6410
5761
|
createRuntimeAffectingSourceSignature: require_compiler.createRuntimeAffectingSourceSignature,
|
|
@@ -6620,7 +5971,7 @@ function createGenerateBundleHook$1(context) {
|
|
|
6620
5971
|
cssSources.add(typeof output.source === "string" ? output.source : node_buffer.Buffer.from(output.source).toString());
|
|
6621
5972
|
}
|
|
6622
5973
|
for (const [, record] of getViteProcessedCssAssetResults?.() ?? []) cssSources.add(typeof record === "string" ? record : record.css);
|
|
6623
|
-
for (const candidate of
|
|
5974
|
+
for (const candidate of require_generated_css_marker.collectGeneratedRawSourceCandidatesFromCss(generatorRuntime, cssSources, opts.escapeMap)) transformRuntime.add(candidate);
|
|
6624
5975
|
debug("rebuild webview JS transform class set from generated CSS: %d", transformRuntime.size);
|
|
6625
5976
|
} : void 0;
|
|
6626
5977
|
await finalizeGenerateBundle({
|
|
@@ -6691,8 +6042,11 @@ function createGenerateBundleHook(context) {
|
|
|
6691
6042
|
const relationOwner = require_web.getActiveViteSourceOutputRelationOwner();
|
|
6692
6043
|
const removalConsumer = relationOwner?.createRemovalConsumer();
|
|
6693
6044
|
const rememberCssSource = context.rememberCssSource;
|
|
6045
|
+
const frameworkRootImportShellTargetByFile = context.frameworkRootImportShellTargetByFile ?? /* @__PURE__ */ new Map();
|
|
6046
|
+
const frameworkStyleMemory = createFrameworkStyleMemory(frameworkRootImportShellTargetByFile);
|
|
6694
6047
|
const runtimeHandler = createGenerateBundleHook$1({
|
|
6695
6048
|
...context,
|
|
6049
|
+
frameworkRootImportShellTargetByFile,
|
|
6696
6050
|
rememberCssSource: rememberCssSource ? (entry, cssRuntimeSignature) => {
|
|
6697
6051
|
relationOwner?.recordOwnedOutput(entry.sourceFile, entry.outputFile);
|
|
6698
6052
|
rememberCssSource(entry, cssRuntimeSignature);
|
|
@@ -6701,9 +6055,11 @@ function createGenerateBundleHook(context) {
|
|
|
6701
6055
|
return async function generateBundle(options, bundle) {
|
|
6702
6056
|
relationOwner?.recordBundle(bundle);
|
|
6703
6057
|
const removedFiles = removalConsumer?.consume(Object.keys(bundle)) ?? [];
|
|
6058
|
+
const rememberFrameworkStyles = frameworkStyleMemory.prepare(bundle, removedFiles);
|
|
6704
6059
|
require_compiler.beginCompilerShadowRun(context.runtimeState);
|
|
6705
6060
|
const runRuntime = () => runWithRemovedBundleFiles(removedFiles, () => runtimeHandler.call(this, options, bundle));
|
|
6706
6061
|
await (relationOwner ? require_web.withViteSourceOutputRelationOwner(relationOwner, runRuntime) : runRuntime());
|
|
6062
|
+
rememberFrameworkStyles();
|
|
6707
6063
|
};
|
|
6708
6064
|
}
|
|
6709
6065
|
//#endregion
|
|
@@ -6714,8 +6070,8 @@ function linkEntryChunkStyles(bundle, options) {
|
|
|
6714
6070
|
for (const [file, asset] of assets) {
|
|
6715
6071
|
if (!options.matchesCss(file)) continue;
|
|
6716
6072
|
const targets = /* @__PURE__ */ new Set();
|
|
6717
|
-
|
|
6718
|
-
const request =
|
|
6073
|
+
_weapp_tailwindcss_postcss_transform.postcss.parse(asset.source.toString()).walkAtRules("import", (rule) => {
|
|
6074
|
+
const request = (0, _weapp_tailwindcss_postcss_transform.parseCssImportSpecifier)(rule.params)?.specifier;
|
|
6719
6075
|
if (request && !/^(?:[a-z][a-z\d+.-]*:|\/\/|\/)/i.test(request)) {
|
|
6720
6076
|
const target = node_path.default.posix.normalize(node_path.default.posix.join(node_path.default.posix.dirname(file), request));
|
|
6721
6077
|
if (assets.has(target)) targets.add(target);
|
|
@@ -6746,7 +6102,7 @@ function linkEntryChunkStyles(bundle, options) {
|
|
|
6746
6102
|
if (!target || !imports.has(target) || reaches(file, target) || reaches(target, file)) continue;
|
|
6747
6103
|
imports.get(file).add(target);
|
|
6748
6104
|
const relative = node_path.default.posix.relative(node_path.default.posix.dirname(file), target);
|
|
6749
|
-
requests.push(`@import ${
|
|
6105
|
+
requests.push(`@import ${(0, _weapp_tailwindcss_postcss_transform.quoteCssImportSpecifier)(relative.startsWith(".") ? relative : `./${relative}`)};\n`);
|
|
6750
6106
|
}
|
|
6751
6107
|
if (requests.length > 0) {
|
|
6752
6108
|
const next = requests.join("") + original;
|
|
@@ -6756,6 +6112,20 @@ function linkEntryChunkStyles(bundle, options) {
|
|
|
6756
6112
|
}
|
|
6757
6113
|
}
|
|
6758
6114
|
//#endregion
|
|
6115
|
+
//#region src/bundlers/vite/css-finalizer/final-assets.ts
|
|
6116
|
+
/** 按生成目标统一收尾已组装的 CSS 资产,供空资产和常规分支复用。 */
|
|
6117
|
+
function finalizeCssAssets(bundle, context, isWebGeneratorTarget, files) {
|
|
6118
|
+
if (isWebGeneratorTarget) return require_web.finalizeWebCssCalc(bundle, context);
|
|
6119
|
+
finalizeMiniProgramCssAssetStructures(bundle, {
|
|
6120
|
+
cssMatcher: context.opts.cssMatcher,
|
|
6121
|
+
debug: context.debug,
|
|
6122
|
+
files,
|
|
6123
|
+
isWebGeneratorTarget,
|
|
6124
|
+
onUpdate: context.opts.onUpdate,
|
|
6125
|
+
recordCssAssetResult: context.recordCssAssetResult
|
|
6126
|
+
});
|
|
6127
|
+
}
|
|
6128
|
+
//#endregion
|
|
6759
6129
|
//#region src/bundlers/vite/css-finalizer/plugin.ts
|
|
6760
6130
|
function createViteCssFinalizerOutputPlugin(context) {
|
|
6761
6131
|
return {
|
|
@@ -6833,6 +6203,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6833
6203
|
rootDir,
|
|
6834
6204
|
sourceRoot
|
|
6835
6205
|
})) {
|
|
6206
|
+
await require_web.finalizeWebCssCalc(bundle, context);
|
|
6836
6207
|
require_hmr_timing.finalizeCompilerShadowRun(runtimeState);
|
|
6837
6208
|
finishTiming();
|
|
6838
6209
|
return;
|
|
@@ -6873,8 +6244,8 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6873
6244
|
recordCssAssetResult,
|
|
6874
6245
|
targetByFile: frameworkRootImportShellTargetByFile ?? /* @__PURE__ */ new Map()
|
|
6875
6246
|
});
|
|
6876
|
-
const sourceTraceTokenSources = getSourceCandidateSourcesForEntries ?
|
|
6877
|
-
const annotateCss = (css) =>
|
|
6247
|
+
const sourceTraceTokenSources = getSourceCandidateSourcesForEntries ? require_generated_css_marker.createCssTokenSourceMap(getSourceCandidateSourcesForEntries(void 0), opts) : void 0;
|
|
6248
|
+
const annotateCss = (css) => require_generated_css_marker.annotateCssSourceTrace(css, {
|
|
6878
6249
|
opts,
|
|
6879
6250
|
tokenSources: sourceTraceTokenSources
|
|
6880
6251
|
});
|
|
@@ -6921,7 +6292,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6921
6292
|
...createCssPipelineContext("uni-app-x-harmony-apply.css"),
|
|
6922
6293
|
file: "uni-app-x-harmony-apply.css"
|
|
6923
6294
|
}) ?? {});
|
|
6924
|
-
const generated = await
|
|
6295
|
+
const generated = await require_generated_css_marker.generateTailwindV4Css({
|
|
6925
6296
|
opts,
|
|
6926
6297
|
runtimeState,
|
|
6927
6298
|
runtime: /* @__PURE__ */ new Set(),
|
|
@@ -6956,7 +6327,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6956
6327
|
const entries = Object.entries(bundle).filter(isCssOutputAssetEntry);
|
|
6957
6328
|
recordTiming("assets.enumerate", enumerateStartedAt);
|
|
6958
6329
|
if (entries.length === 0) {
|
|
6959
|
-
await injectHarmonyBundleStyles(
|
|
6330
|
+
await injectHarmonyBundleStyles();
|
|
6960
6331
|
collectViteProcessedCssAssets();
|
|
6961
6332
|
injectViteProcessedCssIntoMainCss();
|
|
6962
6333
|
linkEntryStyles();
|
|
@@ -6967,14 +6338,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6967
6338
|
onUpdate: trackFinalCssAssetUpdate,
|
|
6968
6339
|
recordCssAssetResult
|
|
6969
6340
|
});
|
|
6970
|
-
|
|
6971
|
-
cssMatcher: opts.cssMatcher,
|
|
6972
|
-
debug,
|
|
6973
|
-
files: finalCssAssetFiles,
|
|
6974
|
-
isWebGeneratorTarget,
|
|
6975
|
-
onUpdate: opts.onUpdate,
|
|
6976
|
-
recordCssAssetResult
|
|
6977
|
-
});
|
|
6341
|
+
await finalizeCssAssets(bundle, context, isWebGeneratorTarget, finalCssAssetFiles);
|
|
6978
6342
|
require_hmr_timing.finalizeCompilerShadowRun(runtimeState);
|
|
6979
6343
|
finishTiming();
|
|
6980
6344
|
return;
|
|
@@ -6995,7 +6359,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
6995
6359
|
const file = output.fileName || bundleFile;
|
|
6996
6360
|
const rawSource = output.source.toString();
|
|
6997
6361
|
if (isViteProcessedCssAsset?.(output, file)) {
|
|
6998
|
-
const cleanRawSource =
|
|
6362
|
+
const cleanRawSource = (0, _weapp_tailwindcss_postcss_transform.stripBundlerGeneratedCssMarkers)(rawSource);
|
|
6999
6363
|
const cssHandlerOptions = require_web.createCssHandlerOptions(opts, runtimeState.tailwindRuntime.majorVersion, file, outDir, cssPipelineStrategy?.getCssHandlerExtraOptions?.({
|
|
7000
6364
|
...createCssPipelineContext(file),
|
|
7001
6365
|
file
|
|
@@ -7015,7 +6379,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7015
6379
|
...cssHandlerOptions,
|
|
7016
6380
|
isMainChunk: false
|
|
7017
6381
|
};
|
|
7018
|
-
const cleanRawSource =
|
|
6382
|
+
const cleanRawSource = (0, _weapp_tailwindcss_postcss_transform.stripBundlerGeneratedCssMarkers)(rawSource);
|
|
7019
6383
|
if (cleanRawSource !== rawSource && cleanRawSource.trim().length === 0) {
|
|
7020
6384
|
writeCssAsset(file, output, cleanRawSource);
|
|
7021
6385
|
markCssAssetProcessed(output, file);
|
|
@@ -7027,7 +6391,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7027
6391
|
const processed = isCssAssetProcessed(output, file);
|
|
7028
6392
|
const rememberedMainCssSource = processed && cssHandlerOptions.isMainChunk ? getRememberedMainCssSource?.(file) : void 0;
|
|
7029
6393
|
const resolvedGeneratorRawSource = rememberedMainCssSource?.rawSource ?? cleanRawSource;
|
|
7030
|
-
const generatorRawSource = generatorBranch.isWeb ? resolvedGeneratorRawSource :
|
|
6394
|
+
const generatorRawSource = generatorBranch.isWeb ? resolvedGeneratorRawSource : (0, _weapp_tailwindcss_postcss_transform.normalizeMiniProgramGeneratorCssSource)(resolvedGeneratorRawSource, file);
|
|
7031
6395
|
const generatorSourceFile = rememberedMainCssSource?.sourceFile ?? file;
|
|
7032
6396
|
const generatorCssHandlerOptions = rememberedMainCssSource ? require_web.createCssHandlerOptions(opts, runtimeState.tailwindRuntime.majorVersion, generatorSourceFile, outDir, cssPipelineStrategy?.getCssHandlerExtraOptions?.({
|
|
7033
6397
|
...createCssPipelineContext(generatorSourceFile),
|
|
@@ -7038,7 +6402,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7038
6402
|
isMainChunk: false
|
|
7039
6403
|
} : cssUserHandlerOptions;
|
|
7040
6404
|
const generatorTransformRawSource = generatorRawSource;
|
|
7041
|
-
const generated = require_web.shouldGenerateCssByGenerator(opts, runtimeState.tailwindRuntime.majorVersion, file, generatorTransformRawSource, processed) ? await
|
|
6405
|
+
const generated = require_web.shouldGenerateCssByGenerator(opts, runtimeState.tailwindRuntime.majorVersion, file, generatorTransformRawSource, processed) ? await require_generated_css_marker.generateTailwindV4Css({
|
|
7042
6406
|
opts,
|
|
7043
6407
|
runtimeState,
|
|
7044
6408
|
runtime: generatorRuntime,
|
|
@@ -7053,7 +6417,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7053
6417
|
styleHandler: opts.styleHandler,
|
|
7054
6418
|
debug
|
|
7055
6419
|
}) : void 0;
|
|
7056
|
-
if (!generated && !generatorBranch.isWeb && (0,
|
|
6420
|
+
if (!generated && !generatorBranch.isWeb && (0, _weapp_tailwindcss_postcss_transform.isPureLocalCssImportWrapper)(generatorTransformRawSource)) {
|
|
7057
6421
|
const nextCss = generatorTransformRawSource;
|
|
7058
6422
|
if (nextCss !== rawSource) {
|
|
7059
6423
|
writeCssAsset(file, output, nextCss);
|
|
@@ -7092,14 +6456,7 @@ function createViteCssFinalizerOutputPlugin(context) {
|
|
|
7092
6456
|
onUpdate: trackFinalCssAssetUpdate,
|
|
7093
6457
|
recordCssAssetResult
|
|
7094
6458
|
});
|
|
7095
|
-
|
|
7096
|
-
cssMatcher: opts.cssMatcher,
|
|
7097
|
-
debug,
|
|
7098
|
-
files: finalCssAssetFiles,
|
|
7099
|
-
isWebGeneratorTarget,
|
|
7100
|
-
onUpdate: opts.onUpdate,
|
|
7101
|
-
recordCssAssetResult
|
|
7102
|
-
});
|
|
6459
|
+
await finalizeCssAssets(bundle, context, isWebGeneratorTarget, finalCssAssetFiles);
|
|
7103
6460
|
require_hmr_timing.finalizeCompilerShadowRun(runtimeState);
|
|
7104
6461
|
recordTiming("assets.write", writeStartedAt);
|
|
7105
6462
|
finishTiming();
|
|
@@ -7147,7 +6504,7 @@ function resolveViteServeRootMiniProgramImportShell(options) {
|
|
|
7147
6504
|
css,
|
|
7148
6505
|
file: outputFile
|
|
7149
6506
|
})
|
|
7150
|
-
}) ?
|
|
6507
|
+
}) ? (0, _weapp_tailwindcss_postcss_transform.normalizeMiniProgramImportShell)(css) : void 0;
|
|
7151
6508
|
}
|
|
7152
6509
|
//#endregion
|
|
7153
6510
|
//#region src/bundlers/vite/watch-css-post.ts
|
|
@@ -7226,8 +6583,8 @@ function createConfiguredCssEntryObserver(options) {
|
|
|
7226
6583
|
observeSourceImports(source, sourceId) {
|
|
7227
6584
|
if (!source.includes("@import")) return;
|
|
7228
6585
|
try {
|
|
7229
|
-
|
|
7230
|
-
const request = (0,
|
|
6586
|
+
_weapp_tailwindcss_postcss_transform.postcss.parse(source).walkAtRules("import", (rule) => {
|
|
6587
|
+
const request = (0, _weapp_tailwindcss_postcss_transform.parseTailwindCssDirectiveRequest)(rule.params);
|
|
7231
6588
|
if (request) observeImport(request, sourceId);
|
|
7232
6589
|
});
|
|
7233
6590
|
} catch {}
|
|
@@ -7253,7 +6610,7 @@ function createConfiguredCssEntryDiagnostics(options) {
|
|
|
7253
6610
|
plugin: {
|
|
7254
6611
|
name: "weapp-tailwindcss:configured-css-entry-observer",
|
|
7255
6612
|
transform(_code, id) {
|
|
7256
|
-
if (options.isWeb() &&
|
|
6613
|
+
if (options.isWeb() && require_generated_css_marker.isSourceStyleRequest(id)) observer.observe(id);
|
|
7257
6614
|
}
|
|
7258
6615
|
}
|
|
7259
6616
|
};
|
|
@@ -7267,7 +6624,7 @@ function createFrameworkModuleCandidateRegistrar(options) {
|
|
|
7267
6624
|
options.invalidateRecordedGeneratorCandidates();
|
|
7268
6625
|
options.cacheCurrent();
|
|
7269
6626
|
const cssHandlerOptions = options.getCssHandlerOptions(id);
|
|
7270
|
-
return
|
|
6627
|
+
return require_generated_css_marker.validateCandidatesByGenerator({
|
|
7271
6628
|
candidates,
|
|
7272
6629
|
cssHandlerOptions,
|
|
7273
6630
|
cssUserHandlerOptions: cssHandlerOptions,
|
|
@@ -7325,7 +6682,7 @@ function isWebOrNativeAppPlatform(platform) {
|
|
|
7325
6682
|
return platform === "h5" || platform === "web" || platform?.startsWith("web-") === true || platform === "app" || platform === "app-plus" || platform?.startsWith("app-") === true;
|
|
7326
6683
|
}
|
|
7327
6684
|
function isInternalUserDefinedOptions(options) {
|
|
7328
|
-
return typeof options.onLoad === "function" && typeof options.mainCssChunkMatcher === "function" && typeof options.tailwindRuntime === "object" && typeof options.refreshTailwindcssRuntime === "function";
|
|
6685
|
+
return typeof options.onLoad === "function" && typeof options.mainCssChunkMatcher === "function" && "tailwindRuntime" in options && typeof options.tailwindRuntime === "object" && "refreshTailwindcssRuntime" in options && typeof options.refreshTailwindcssRuntime === "function";
|
|
7329
6686
|
}
|
|
7330
6687
|
function isNuxtPageHotModule(id) {
|
|
7331
6688
|
if (typeof id !== "string") return false;
|
|
@@ -7335,6 +6692,41 @@ function isNuxtPageHotModule(id) {
|
|
|
7335
6692
|
return cleanId.includes("/pages/") && /\.(?:vue|tsx?|jsx?)$/.test(cleanId);
|
|
7336
6693
|
}
|
|
7337
6694
|
//#endregion
|
|
6695
|
+
//#region src/bundlers/vite/shared/framework-runtime-configuration.ts
|
|
6696
|
+
const ENV_PLATFORM_KEYS = [
|
|
6697
|
+
"UNI_PLATFORM",
|
|
6698
|
+
"UNI_UTS_PLATFORM",
|
|
6699
|
+
"TARO_ENV",
|
|
6700
|
+
"MPX_CURRENT_TARGET_MODE",
|
|
6701
|
+
"MPX_CLI_MODE"
|
|
6702
|
+
];
|
|
6703
|
+
/** 在配置基准确定后同步显式 CSS 入口,保留运行时与用户选项的一致性。 */
|
|
6704
|
+
function createFrameworkCssEntrySync(opts, rawCssEntries) {
|
|
6705
|
+
return (anchor) => {
|
|
6706
|
+
var _opts$tailwindcss;
|
|
6707
|
+
const entries = require_generator.normalizeCssEntries(rawCssEntries, anchor ?? node_process.default.cwd());
|
|
6708
|
+
if (!entries) return false;
|
|
6709
|
+
const changed = !sameStringList(opts.cssEntries, entries);
|
|
6710
|
+
opts.cssEntries = entries;
|
|
6711
|
+
opts.tailwindcss ?? (opts.tailwindcss = {});
|
|
6712
|
+
(_opts$tailwindcss = opts.tailwindcss).v4 ?? (_opts$tailwindcss.v4 = {});
|
|
6713
|
+
opts.tailwindcss.v4.cssEntries = entries;
|
|
6714
|
+
if (opts.tailwindcssRuntimeOptions?.tailwindcss?.v4) opts.tailwindcssRuntimeOptions.tailwindcss.v4.cssEntries = entries;
|
|
6715
|
+
if (opts.tailwindRuntime?.options?.tailwindcss?.v4) opts.tailwindRuntime.options.tailwindcss.v4.cssEntries = entries;
|
|
6716
|
+
return changed;
|
|
6717
|
+
};
|
|
6718
|
+
}
|
|
6719
|
+
/** 按显式配置、框架环境与输出目录顺序解析当前样式平台。 */
|
|
6720
|
+
function resolveFrameworkStylePlatform(opts, outDir) {
|
|
6721
|
+
const explicit = require_compiler.normalizeFrameworkStylePlatform(opts.cssOptions?.platform ?? opts.platform, opts.appType);
|
|
6722
|
+
if (explicit) return explicit;
|
|
6723
|
+
for (const key of ENV_PLATFORM_KEYS) {
|
|
6724
|
+
const platform = require_compiler.normalizeFrameworkStylePlatform(node_process.default.env[key], opts.appType);
|
|
6725
|
+
if (platform) return platform;
|
|
6726
|
+
}
|
|
6727
|
+
return inferPlatformFromOutDir(outDir);
|
|
6728
|
+
}
|
|
6729
|
+
//#endregion
|
|
7338
6730
|
//#region src/bundlers/vite/shared/framework-source-candidates-plugin.ts
|
|
7339
6731
|
function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
7340
6732
|
const shouldSkipSourceCandidateState = () => options.shouldSkipSourceCandidateState?.() === true;
|
|
@@ -7345,7 +6737,7 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
7345
6737
|
});
|
|
7346
6738
|
const sendSupplementalSourceHotUpdates = (ctx, modules) => {
|
|
7347
6739
|
const root = ctx.server.config?.root ?? node_process.default.cwd();
|
|
7348
|
-
const updates = modules.flatMap((mod) => [mod, ...mod.importedModules ?? []]).filter((mod) => !
|
|
6740
|
+
const updates = modules.flatMap((mod) => [mod, ...mod.importedModules ?? []]).filter((mod) => !require_generated_css_marker.isSourceStyleRequest(mod.id ?? mod.url)).map((mod) => {
|
|
7349
6741
|
let hotPath;
|
|
7350
6742
|
if (typeof mod.id === "string" && node_path.default.isAbsolute(mod.id)) {
|
|
7351
6743
|
const relative = typeof mod.url === "string" && mod.url.startsWith("/pages/") ? node_path.default.relative(node_path.default.dirname(root), mod.id) : node_path.default.relative(root, mod.id);
|
|
@@ -7368,7 +6760,7 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
7368
6760
|
};
|
|
7369
6761
|
return {
|
|
7370
6762
|
name: `${require_compiler.vitePluginName}:source-candidates`,
|
|
7371
|
-
apply,
|
|
6763
|
+
...apply === void 0 ? {} : { apply },
|
|
7372
6764
|
enforce: "pre",
|
|
7373
6765
|
async load(id) {
|
|
7374
6766
|
if (!options.shouldOwnTailwindGeneration || shouldSkipSourceCandidateState() || options.isWebOrNativeAppPlatform(options.resolveViteStylePlatform()) || !require_web.isCSSRequest(id) || !require_web.shouldCollectTransformedSourceCandidates(id)) return;
|
|
@@ -7391,9 +6783,9 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
7391
6783
|
const shouldReturnTransformedCode = transformedCode !== code;
|
|
7392
6784
|
if (options.shouldOwnTailwindGeneration && require_web.shouldCollectTransformedSourceCandidates(id)) {
|
|
7393
6785
|
options.cssMemory.rememberKnownSfcSource(id, transformedCode);
|
|
7394
|
-
if (require_web.isCSSRequest(id) &&
|
|
6786
|
+
if (require_web.isCSSRequest(id) && (0, _weapp_tailwindcss_postcss_transform.hasTailwindRootDirectives)(transformedCode, { importFallback: options.resolveCurrentGeneratorOptions().importFallback })) options.rememberTailwindRootCssModule(id);
|
|
7395
6787
|
}
|
|
7396
|
-
if (!options.shouldOwnTailwindGeneration || shouldSkipSourceCandidateState() || options.collectSourceCandidates === false || !
|
|
6788
|
+
if (!options.shouldOwnTailwindGeneration || shouldSkipSourceCandidateState() || options.collectSourceCandidates === false || !require_generated_css_marker.isSourceCandidateRequest(id) || !require_web.shouldCollectTransformedSourceCandidates(id)) return shouldReturnTransformedCode ? {
|
|
7397
6789
|
code: transformedCode,
|
|
7398
6790
|
map: null
|
|
7399
6791
|
} : void 0;
|
|
@@ -7421,7 +6813,7 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
7421
6813
|
if (shouldSkipSourceCandidateState()) return;
|
|
7422
6814
|
require_compiler.recordCompilationDependencyChanges(options.runtimeState, require_compiler.createCompilationDependencyChanges([node_path.default.resolve((0, _weapp_tailwindcss_shared.cleanUrl)(id))]));
|
|
7423
6815
|
await options.hmrTimingRecorder.measure("sourceCandidates.watchChange", async () => {
|
|
7424
|
-
if (options.shouldOwnTailwindGeneration && options.collectSourceCandidates !== false &&
|
|
6816
|
+
if (options.shouldOwnTailwindGeneration && options.collectSourceCandidates !== false && require_generated_css_marker.isSourceCandidateRequest(id)) options.invalidateRecordedGeneratorCandidates();
|
|
7425
6817
|
if (options.sourceScanSession.isDependency(id)) options.sourceScanSession.invalidate();
|
|
7426
6818
|
if (change.event === "delete") {
|
|
7427
6819
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
@@ -7438,7 +6830,7 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
7438
6830
|
}
|
|
7439
6831
|
return;
|
|
7440
6832
|
}
|
|
7441
|
-
const changedSource = options.shouldOwnTailwindGeneration &&
|
|
6833
|
+
const changedSource = options.shouldOwnTailwindGeneration && require_generated_css_marker.isSourceCandidateRequest(id) && require_web.isCSSRequest(id) ? await (0, node_fs_promises.readFile)((0, _weapp_tailwindcss_shared.cleanUrl)(id), "utf8").catch(() => void 0) : void 0;
|
|
7442
6834
|
if (typeof changedSource === "string") {
|
|
7443
6835
|
options.rememberOriginalCssLayerSource(id, changedSource);
|
|
7444
6836
|
await options.refreshTailwindRootCssSource(id, changedSource);
|
|
@@ -7459,15 +6851,15 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
7459
6851
|
if (shouldSkipSourceCandidateState()) return;
|
|
7460
6852
|
require_compiler.recordCompilationDependencyChanges(options.runtimeState, require_compiler.createCompilationDependencyChanges([node_path.default.resolve((0, _weapp_tailwindcss_shared.cleanUrl)(ctx.file))]));
|
|
7461
6853
|
return options.hmrTimingRecorder.measure("sourceCandidates.handleHotUpdate", async () => {
|
|
7462
|
-
const isSourceCandidateHotUpdate = options.shouldOwnTailwindGeneration && options.collectSourceCandidates !== false &&
|
|
7463
|
-
if (isSourceCandidateHotUpdate &&
|
|
6854
|
+
const isSourceCandidateHotUpdate = options.shouldOwnTailwindGeneration && options.collectSourceCandidates !== false && require_generated_css_marker.isSourceCandidateRequest(ctx.file);
|
|
6855
|
+
if (isSourceCandidateHotUpdate && require_generated_css_marker.isSourceStyleRequest(ctx.file)) {
|
|
7464
6856
|
for (const mod of ctx.modules) for (const id of [
|
|
7465
6857
|
mod.id,
|
|
7466
6858
|
mod.url,
|
|
7467
6859
|
mod.file
|
|
7468
6860
|
]) if (typeof id === "string" && id.length > 0) options.rememberTailwindRootCssModule(id);
|
|
7469
6861
|
}
|
|
7470
|
-
const hotSource = isSourceCandidateHotUpdate && typeof ctx.read === "function" ? await
|
|
6862
|
+
const hotSource = isSourceCandidateHotUpdate && typeof ctx.read === "function" ? await require_web.readViteHmrSource(ctx) : void 0;
|
|
7471
6863
|
if (typeof hotSource === "string" && require_web.isCSSRequest(ctx.file)) {
|
|
7472
6864
|
options.rememberOriginalCssLayerSource(ctx.file, hotSource);
|
|
7473
6865
|
await options.refreshTailwindRootCssSource(ctx.file, hotSource);
|
|
@@ -7483,11 +6875,11 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
7483
6875
|
if (isSourceCandidateHotUpdate) {
|
|
7484
6876
|
options.invalidateRecordedGeneratorCandidates();
|
|
7485
6877
|
const preserveDeletedCssInHmr = options.resolveCurrentGeneratorOptions().hmr.preserveDeletedCss;
|
|
7486
|
-
canUseHmrCandidateAppend = preserveDeletedCssInHmr && !
|
|
6878
|
+
canUseHmrCandidateAppend = preserveDeletedCssInHmr && !require_generated_css_marker.isSourceStyleRequest(ctx.file) && sourceCandidateChange !== void 0 && !sourceCandidateChange.runtimeAffecting;
|
|
7487
6879
|
if (!canUseHmrCandidateAppend) {
|
|
7488
6880
|
if (sourceCandidateChange === void 0) {
|
|
7489
6881
|
options.hmrCandidateState.clear();
|
|
7490
|
-
if (!preserveDeletedCssInHmr && !
|
|
6882
|
+
if (!preserveDeletedCssInHmr && !require_generated_css_marker.isSourceStyleRequest(ctx.file)) options.hmrCandidateState.queueFullRegeneration();
|
|
7491
6883
|
}
|
|
7492
6884
|
if (isWebLikeHotUpdate) {
|
|
7493
6885
|
await options.refreshRuntimeStateForAutoCssSources?.(true);
|
|
@@ -7496,12 +6888,12 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
7496
6888
|
}
|
|
7497
6889
|
}
|
|
7498
6890
|
if (isSourceCandidateHotUpdate) await options.sourceScanSession.waitForPendingSyncs();
|
|
7499
|
-
if (isSourceCandidateHotUpdate && !
|
|
7500
|
-
const hotTailwindCssModuleIds =
|
|
6891
|
+
if (isSourceCandidateHotUpdate && !require_generated_css_marker.isSourceStyleRequest(ctx.file)) options.hmrCandidateState.reconcileRuntimeCandidates(ctx.file, options.sourceCandidateCollector.values(), options.tailwindRootCssModuleIds);
|
|
6892
|
+
const hotTailwindCssModuleIds = require_generated_css_marker.isSourceStyleRequest(ctx.file) ? [ctx.file] : options.tailwindRootCssModuleIds;
|
|
7501
6893
|
const hotRoot = ctx.server.config?.root ?? node_process.default.cwd();
|
|
7502
6894
|
const cssModules = await require_web.resolveHotTailwindCssModules(ctx, hotTailwindCssModuleIds, options.hmrCssModuleVersions ? (modules) => options.hmrCssModuleVersions.filterModules(modules, ctx.timestamp, hotRoot) : void 0);
|
|
7503
|
-
const sourceModules = isSourceCandidateHotUpdate && !
|
|
7504
|
-
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !
|
|
6895
|
+
const sourceModules = isSourceCandidateHotUpdate && !require_generated_css_marker.isSourceStyleRequest(ctx.file) ? await require_web.resolveHotSourceModules(ctx) : ctx.modules;
|
|
6896
|
+
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !require_generated_css_marker.isSourceStyleRequest(ctx.file)) {
|
|
7505
6897
|
if (!/\.(?:uvue|nvue)$/i.test((0, _weapp_tailwindcss_shared.cleanUrl)(ctx.file))) sendSupplementalSourceHotUpdates(ctx, sourceModules);
|
|
7506
6898
|
if (sourceModules.some((mod) => {
|
|
7507
6899
|
const id = mod.id ?? mod.url;
|
|
@@ -7512,25 +6904,25 @@ function createFrameworkSourceCandidatesPlugin(options, apply) {
|
|
|
7512
6904
|
}
|
|
7513
6905
|
}
|
|
7514
6906
|
const hasHmrCandidateAppend = options.hmrCandidateState.hasPendingCandidateAppend() || canUseHmrCandidateAppend && sourceCandidateChange !== void 0 && sourceCandidateChange.addedCandidates.size > 0;
|
|
7515
|
-
if (isSourceCandidateHotUpdate && !
|
|
6907
|
+
if (isSourceCandidateHotUpdate && !require_generated_css_marker.isSourceStyleRequest(ctx.file) && !hasHmrCandidateAppend && !isWebLikeHotUpdate && (!require_web.hasSelfAcceptingNonStyleHotModule(sourceModules) && cssModules.length === 0 || cssModules.length > 0 && options.isUniViteProject())) {
|
|
7516
6908
|
require_web.sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
7517
6909
|
return [];
|
|
7518
6910
|
}
|
|
7519
|
-
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !
|
|
6911
|
+
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !require_generated_css_marker.isSourceStyleRequest(ctx.file) && sourceModules.some((mod) => options.isNuxtPageHotModule?.(mod.id ?? mod.url))) {
|
|
7520
6912
|
require_web.sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
7521
6913
|
return [];
|
|
7522
6914
|
}
|
|
7523
|
-
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !
|
|
6915
|
+
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !require_generated_css_marker.isSourceStyleRequest(ctx.file) && /\.(?:uvue|nvue)$/i.test((0, _weapp_tailwindcss_shared.cleanUrl)(ctx.file)) && !hasTemplateHotSourceModule(sourceModules)) {
|
|
7524
6916
|
require_web.sendFullReloadForUnresolvedHotUpdate(ctx);
|
|
7525
6917
|
return [];
|
|
7526
6918
|
}
|
|
7527
|
-
const shouldSendSupplementalCssHotUpdates = !(isWebLikeHotUpdate && isSourceCandidateHotUpdate && !
|
|
6919
|
+
const shouldSendSupplementalCssHotUpdates = !(isWebLikeHotUpdate && isSourceCandidateHotUpdate && !require_generated_css_marker.isSourceStyleRequest(ctx.file) && sourceCandidateChange !== void 0 && options.resolveCurrentGeneratorOptions().hmr.preserveDeletedCss && !sourceCandidateChange.runtimeAffecting && sourceCandidateChange.addedCandidates.size === 0 && sourceCandidateChange.removedCandidates.size > 0);
|
|
7528
6920
|
const supplementalCssFallbackIds = /* @__PURE__ */ new Set([...options.tailwindRootCssModuleIds, ...options.viteProcessedCssSourceFiles]);
|
|
7529
6921
|
const currentSupplementalCssFallbackIds = options.hmrCssModuleVersions?.filterIds(supplementalCssFallbackIds, ctx.timestamp, hotRoot) ?? supplementalCssFallbackIds;
|
|
7530
6922
|
if (options.hmrCandidateState.hasPendingChange()) options.hmrCandidateState.armTargets(cssModules, currentSupplementalCssFallbackIds);
|
|
7531
6923
|
if (shouldSendSupplementalCssHotUpdates && cssModules.length === 0) require_web.sendSupplementalCssHotUpdates(ctx, [], currentSupplementalCssFallbackIds);
|
|
7532
|
-
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !
|
|
7533
|
-
if (isSourceCandidateHotUpdate && !
|
|
6924
|
+
if (isWebLikeHotUpdate && isSourceCandidateHotUpdate && !require_generated_css_marker.isSourceStyleRequest(ctx.file)) return cssModules.length > 0 ? require_web.mergeHotModulesByIdentity(hotRoot, sourceModules, cssModules) : hasDifferentHotModules(sourceModules, ctx.modules) ? sourceModules : void 0;
|
|
6925
|
+
if (isSourceCandidateHotUpdate && !require_generated_css_marker.isSourceStyleRequest(ctx.file) && cssModules.length > 0) return require_web.mergeHotModulesByIdentity(hotRoot, sourceModules, cssModules);
|
|
7534
6926
|
return cssModules.length > 0 ? require_web.mergeHotModulesByIdentity(hotRoot, ctx.modules, cssModules) : void 0;
|
|
7535
6927
|
}, { emit: false });
|
|
7536
6928
|
}
|
|
@@ -7554,13 +6946,6 @@ const debug = require_compiler.createDebug();
|
|
|
7554
6946
|
const weappTailwindcssPackageDir = require_source_candidate_scan_signature.resolvePackageDir("weapp-tailwindcss");
|
|
7555
6947
|
const weappTailwindcssDirPosix = require_web.slash(weappTailwindcssPackageDir);
|
|
7556
6948
|
const generatorPlaceholderCssFile = node_path.default.join(weappTailwindcssPackageDir, "generator-placeholder.css");
|
|
7557
|
-
const ENV_PLATFORM_KEYS = [
|
|
7558
|
-
"UNI_PLATFORM",
|
|
7559
|
-
"UNI_UTS_PLATFORM",
|
|
7560
|
-
"TARO_ENV",
|
|
7561
|
-
"MPX_CURRENT_TARGET_MODE",
|
|
7562
|
-
"MPX_CLI_MODE"
|
|
7563
|
-
];
|
|
7564
6949
|
function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
7565
6950
|
debug("create vite framework plugins framework=%s", frameworkBranch.frameworkName);
|
|
7566
6951
|
const capability = options.__internalViteCapabilityProfile ?? require_web.frameworkViteCapabilityProfile;
|
|
@@ -7568,23 +6953,12 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
7568
6953
|
const hasExplicitAppType = typeof options.__internalViteRawExplicitAppType === "boolean" ? options.__internalViteRawExplicitAppType : typeof options.appType === "string" && options.appType.trim().length > 0;
|
|
7569
6954
|
const hasExplicitTailwindcssBasedir = typeof options.__internalViteRawExplicitTailwindcssBasedir === "boolean" ? options.__internalViteRawExplicitTailwindcssBasedir : typeof options.tailwindcssBasedir === "string" && options.tailwindcssBasedir.trim().length > 0;
|
|
7570
6955
|
const rawCssEntries = collectConfiguredCssEntries(rawOptions);
|
|
7571
|
-
const
|
|
6956
|
+
const deferredOptions = {
|
|
7572
6957
|
...options,
|
|
7573
6958
|
__internalDeferMissingCssEntriesWarning: true
|
|
7574
|
-
});
|
|
7575
|
-
const syncCssEntriesFromAnchor = (anchor) => {
|
|
7576
|
-
var _opts$tailwindcss;
|
|
7577
|
-
const normalizedCssEntries = require_generator.normalizeCssEntries(rawCssEntries, anchor ?? node_process.default.cwd());
|
|
7578
|
-
if (!normalizedCssEntries) return false;
|
|
7579
|
-
const changed = !sameStringList(opts.cssEntries, normalizedCssEntries);
|
|
7580
|
-
opts.cssEntries = normalizedCssEntries;
|
|
7581
|
-
opts.tailwindcss ?? (opts.tailwindcss = {});
|
|
7582
|
-
(_opts$tailwindcss = opts.tailwindcss).v4 ?? (_opts$tailwindcss.v4 = {});
|
|
7583
|
-
opts.tailwindcss.v4.cssEntries = normalizedCssEntries;
|
|
7584
|
-
if (opts.tailwindcssRuntimeOptions?.tailwindcss?.v4) opts.tailwindcssRuntimeOptions.tailwindcss.v4.cssEntries = normalizedCssEntries;
|
|
7585
|
-
if (opts.tailwindRuntime?.options?.tailwindcss?.v4) opts.tailwindRuntime.options.tailwindcss.v4.cssEntries = normalizedCssEntries;
|
|
7586
|
-
return changed;
|
|
7587
6959
|
};
|
|
6960
|
+
const opts = isInternalUserDefinedOptions(options) ? options : require_compiler.getCompilerContext(deferredOptions);
|
|
6961
|
+
const syncCssEntriesFromAnchor = createFrameworkCssEntrySync(opts, rawCssEntries);
|
|
7588
6962
|
syncCssEntriesFromAnchor(opts.tailwindcssBasedir);
|
|
7589
6963
|
const { disabled, customAttributes, onLoad, mainCssChunkMatcher, styleHandler, jsHandler, tailwindRuntime, refreshTailwindcssRuntime, uniAppX, disabledDefaultTemplateHandler, styleInjector } = opts;
|
|
7590
6964
|
const initialTailwindRuntime = tailwindRuntime;
|
|
@@ -7603,15 +6977,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
7603
6977
|
isWeb: () => resolveCurrentGeneratorBranch().isWeb
|
|
7604
6978
|
});
|
|
7605
6979
|
const hmrCssModuleVersions = require_web.createViteHmrCssModuleVersionTracker();
|
|
7606
|
-
const resolveViteStylePlatform = () =>
|
|
7607
|
-
const explicit = require_compiler.normalizeFrameworkStylePlatform(opts.cssOptions?.platform ?? opts.platform, opts.appType);
|
|
7608
|
-
if (explicit) return explicit;
|
|
7609
|
-
for (const key of ENV_PLATFORM_KEYS) {
|
|
7610
|
-
const envPlatform = require_compiler.normalizeFrameworkStylePlatform(node_process.default.env[key], opts.appType);
|
|
7611
|
-
if (envPlatform) return envPlatform;
|
|
7612
|
-
}
|
|
7613
|
-
return inferPlatformFromOutDir(resolvedConfig?.build?.outDir);
|
|
7614
|
-
};
|
|
6980
|
+
const resolveViteStylePlatform = () => resolveFrameworkStylePlatform(opts, resolvedConfig?.build?.outDir);
|
|
7615
6981
|
const resolveGeneratorPlatform = () => opts.cssOptions?.platform ?? opts.platform ?? resolveViteStylePlatform();
|
|
7616
6982
|
const resolveCurrentGeneratorOptions = () => require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
|
|
7617
6983
|
appType: opts.appType,
|
|
@@ -7639,14 +7005,14 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
7639
7005
|
const platform = resolveViteStylePlatform();
|
|
7640
7006
|
if (!shouldOwnTailwindGeneration || (platform ? isWebOrNativeAppPlatform(platform) : resolveCurrentGeneratorBranch().isWeb)) return code;
|
|
7641
7007
|
let transformedCode = code;
|
|
7642
|
-
if (transformedCode.includes("#if")) transformedCode = (0,
|
|
7643
|
-
if (transformedCode.includes("@layer")) transformedCode = (0,
|
|
7008
|
+
if (transformedCode.includes("#if")) transformedCode = (0, _weapp_tailwindcss_postcss_transform.compileCssMacroConditionalComments)(transformedCode, { ...platform ? { platform } : {} });
|
|
7009
|
+
if (transformedCode.includes("@layer")) transformedCode = (0, _weapp_tailwindcss_postcss_transform.unwrapUnsupportedCascadeLayers)(transformedCode);
|
|
7644
7010
|
return transformedCode;
|
|
7645
7011
|
};
|
|
7646
7012
|
const finalizeViteMiniProgramCss = (css) => {
|
|
7647
7013
|
const platform = resolveViteStylePlatform();
|
|
7648
7014
|
if (!shouldOwnTailwindGeneration || (platform ? isWebOrNativeAppPlatform(platform) : resolveCurrentGeneratorBranch().isWeb)) return css;
|
|
7649
|
-
return (0,
|
|
7015
|
+
return (0, _weapp_tailwindcss_postcss_transform.unwrapUnsupportedCascadeLayers)(css);
|
|
7650
7016
|
};
|
|
7651
7017
|
const shouldInferAppType = !hasExplicitAppType && !initialGeneratorBranch.isWeb;
|
|
7652
7018
|
const hasInitialTailwindCssRoots = require_generator.hasConfiguredTailwindV4CssRoots({
|
|
@@ -7672,7 +7038,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
7672
7038
|
if (require_web.isMissingInternalCssSource(file, weappTailwindcssPackageDir)) return;
|
|
7673
7039
|
const sourceFile = node_path.default.normalize(file);
|
|
7674
7040
|
const sourceBase = node_path.default.dirname(sourceFile);
|
|
7675
|
-
const sourceCss =
|
|
7041
|
+
const sourceCss = (0, _weapp_tailwindcss_postcss_transform.normalizeTailwindSourceForGenerator)((0, _weapp_tailwindcss_postcss_transform.normalizeTailwindConfigDirectives)(css, sourceBase), { importFallback: true });
|
|
7676
7042
|
if (autoCssSourceContent.get(sourceFile) === sourceCss) return;
|
|
7677
7043
|
autoCssSourceContent.set(sourceFile, sourceCss);
|
|
7678
7044
|
await syncTailwindCssSourceCandidates(sourceFile, sourceCss);
|
|
@@ -7713,7 +7079,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
7713
7079
|
for (const cssEntry of cssEntries) {
|
|
7714
7080
|
const sourceFile = node_path.default.resolve(cssEntry);
|
|
7715
7081
|
const sourceBase = node_path.default.dirname(sourceFile);
|
|
7716
|
-
const sourceCss =
|
|
7082
|
+
const sourceCss = (0, _weapp_tailwindcss_postcss_transform.normalizeTailwindSourceForGenerator)((0, _weapp_tailwindcss_postcss_transform.normalizeTailwindConfigDirectives)(await (0, node_fs_promises.readFile)(sourceFile, "utf8"), sourceBase), { importFallback: true });
|
|
7717
7083
|
if (autoCssSourceContent.get(sourceFile) === sourceCss) continue;
|
|
7718
7084
|
autoCssSourceContent.set(sourceFile, sourceCss);
|
|
7719
7085
|
await syncTailwindCssSourceCandidates(sourceFile, sourceCss);
|
|
@@ -7731,7 +7097,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
7731
7097
|
};
|
|
7732
7098
|
const customAttributesEntities = require_compiler.toCustomAttributesEntities(customAttributes);
|
|
7733
7099
|
let recordedGeneratorCandidates;
|
|
7734
|
-
const sourceCandidateCollector =
|
|
7100
|
+
const sourceCandidateCollector = require_generated_css_marker.createSourceCandidateCollector({
|
|
7735
7101
|
bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues,
|
|
7736
7102
|
customAttributesEntities,
|
|
7737
7103
|
disabledDefaultTemplateHandler
|
|
@@ -7740,11 +7106,11 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
7740
7106
|
const rememberOriginalCssLayerSource = (id, code) => {
|
|
7741
7107
|
const file = (0, _weapp_tailwindcss_shared.cleanUrl)(id);
|
|
7742
7108
|
if (!require_web.isCSSRequest(file)) return;
|
|
7743
|
-
if (!
|
|
7109
|
+
if (!(0, _weapp_tailwindcss_postcss_transform.hasUserCssLayerBlocks)(code)) {
|
|
7744
7110
|
originalCssLayerSourceByFile.delete(file);
|
|
7745
7111
|
return;
|
|
7746
7112
|
}
|
|
7747
|
-
originalCssLayerSourceByFile.set(file,
|
|
7113
|
+
originalCssLayerSourceByFile.set(file, (0, _weapp_tailwindcss_postcss_transform.splitUserCssLayerBlocks)(code).layer);
|
|
7748
7114
|
};
|
|
7749
7115
|
const processedCssAssets = /* @__PURE__ */ new WeakSet();
|
|
7750
7116
|
const processedCssAssetSourceByFile = /* @__PURE__ */ new Map();
|
|
@@ -7801,7 +7167,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
7801
7167
|
command: resolvedConfig?.command,
|
|
7802
7168
|
frameworkName: frameworkBranch.frameworkName,
|
|
7803
7169
|
isWebGeneratorTarget: resolveCurrentGeneratorBranch().isWeb,
|
|
7804
|
-
requiresSourceCandidateState:
|
|
7170
|
+
requiresSourceCandidateState: require_generated_css_marker.isCssSourceTraceEnabled(opts),
|
|
7805
7171
|
watch: resolvedConfig?.build?.watch
|
|
7806
7172
|
});
|
|
7807
7173
|
const isCurrentWebLikeStylePlatform = () => {
|
|
@@ -7821,7 +7187,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
7821
7187
|
debug,
|
|
7822
7188
|
getResolvedConfig: () => resolvedConfig,
|
|
7823
7189
|
hmrCandidateState,
|
|
7824
|
-
isCandidateRequest:
|
|
7190
|
+
isCandidateRequest: require_generated_css_marker.isSourceCandidateRequest,
|
|
7825
7191
|
isWatchLikeBuild,
|
|
7826
7192
|
opts,
|
|
7827
7193
|
runtimeState,
|
|
@@ -7906,7 +7272,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
7906
7272
|
const inferredSfcStyleRequest = require_web.isSfcStyleSourceFile(file) ? require_web.resolveSfcStyleRequestFromKnownSource(file, cssMemory.getKnownSfcSource(file), code) : file;
|
|
7907
7273
|
const requestFile = require_web.isCSSRequest(id) ? inferredSfcStyleRequest === file ? require_web.resolveViteCssPipelineRequestFile(id) : inferredSfcStyleRequest : inferredSfcStyleRequest;
|
|
7908
7274
|
if (!require_web.isCSSRequest(requestFile) || opts.htmlMatcher(file) || require_web.isHTMLRequest(file)) return;
|
|
7909
|
-
const generatorCode =
|
|
7275
|
+
const generatorCode = (0, _weapp_tailwindcss_postcss_transform.normalizeEmptyTailwindCustomVariants)(code);
|
|
7910
7276
|
const rootDir = resolvedConfig?.root ? node_path.default.resolve(resolvedConfig.root) : node_process.default.cwd();
|
|
7911
7277
|
const currentGeneratorOptions = resolveCurrentGeneratorOptions();
|
|
7912
7278
|
const currentGeneratorBranch = resolveCurrentGeneratorBranch();
|
|
@@ -7917,7 +7283,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
7917
7283
|
const shouldPreserveStyleOutputExtension = frameworkCssPipelineStrategy?.shouldPreserveStyleOutputExtension?.(cssPipelineContext) ?? frameworkCssPipelineStrategy?.isNativeAppStyleTarget?.(cssPipelineContext) === true;
|
|
7918
7284
|
const sourceRoot = resolveWeappViteSourceRoot(resolvedConfig, opts.appType);
|
|
7919
7285
|
const outputFile = require_web.resolveViteCssPipelineOutputFile(requestFile, opts, rootDir, currentGeneratorBranch.isWeb, shouldPreserveStyleOutputExtension, sourceRoot);
|
|
7920
|
-
const generatorTransformCode = currentGeneratorBranch.isWeb ? generatorCode :
|
|
7286
|
+
const generatorTransformCode = currentGeneratorBranch.isWeb ? generatorCode : (0, _weapp_tailwindcss_postcss_transform.normalizeMiniProgramGeneratorCssSource)(generatorCode, outputFile);
|
|
7921
7287
|
const fileKey = normalizeGeneratedCssCacheFile(file);
|
|
7922
7288
|
const fullRuntime = getSourceCandidates() ?? getRecordedGeneratorCandidates() ?? await ensureRuntimeClassSet();
|
|
7923
7289
|
const transient = hookContext?.transient === true;
|
|
@@ -7962,7 +7328,7 @@ function createViteFrameworkPlugins$1(options = {}, frameworkBranch) {
|
|
|
7962
7328
|
const previousTracedCss = tracedGeneratedCssByFile.get(fileKey);
|
|
7963
7329
|
if (previousTracedCss !== void 0) {
|
|
7964
7330
|
hmrCandidateState.finishTarget(file);
|
|
7965
|
-
return `${
|
|
7331
|
+
return `${(0, _weapp_tailwindcss_postcss_transform.createBundlerGeneratedCssMarker)("vite", normalizeViteProcessedCssFile(file))}
|
|
7966
7332
|
${previousTracedCss}`;
|
|
7967
7333
|
}
|
|
7968
7334
|
}
|
|
@@ -7972,7 +7338,7 @@ ${previousTracedCss}`;
|
|
|
7972
7338
|
...sourceCssHandlerOptions,
|
|
7973
7339
|
isMainChunk: outputCssHandlerOptions.isMainChunk
|
|
7974
7340
|
};
|
|
7975
|
-
const transientCssSource = transientAutoCssSources.get(file) ?? (
|
|
7341
|
+
const transientCssSource = transientAutoCssSources.get(file) ?? ((0, _weapp_tailwindcss_postcss_transform.hasTailwindRootDirectives)(generatorTransformCode, { importFallback: currentGeneratorOptions.importFallback }) || (0, _weapp_tailwindcss_postcss_transform.hasTailwindSourceDirectives)(generatorTransformCode, { importFallback: currentGeneratorOptions.importFallback }) || (0, _weapp_tailwindcss_postcss_transform.hasTailwindApplyDirective)(generatorTransformCode) ? {
|
|
7976
7342
|
base: node_path.default.dirname(node_path.default.resolve(file)),
|
|
7977
7343
|
css: generatorTransformCode,
|
|
7978
7344
|
file: node_path.default.resolve(file)
|
|
@@ -7983,9 +7349,9 @@ ${previousTracedCss}`;
|
|
|
7983
7349
|
generatorCode: generatorTransformCode
|
|
7984
7350
|
}) ?? true);
|
|
7985
7351
|
const previousCss = pendingHmrChange && !forceFullHmrCssRegeneration ? cleanGeneratedCssByFile.get(fileKey) : void 0;
|
|
7986
|
-
const previousGeneratorCss = previousCss && !currentGeneratorBranch.isWeb ?
|
|
7352
|
+
const previousGeneratorCss = previousCss && !currentGeneratorBranch.isWeb ? (0, _weapp_tailwindcss_postcss_transform.normalizeMiniProgramGeneratorCssSource)(previousCss, outputFile) : previousCss;
|
|
7987
7353
|
const hmrDebugState = hmrCandidateState.snapshotDebugState();
|
|
7988
|
-
const generated = await hmrTimingRecorder.measure(`generateCss.${resolvedConfig?.command ?? "unknown"}`, () =>
|
|
7354
|
+
const generated = await hmrTimingRecorder.measure(`generateCss.${resolvedConfig?.command ?? "unknown"}`, () => require_generated_css_marker.generateTailwindV4Css({
|
|
7989
7355
|
opts,
|
|
7990
7356
|
runtimeState,
|
|
7991
7357
|
runtime,
|
|
@@ -8026,23 +7392,23 @@ ${previousTracedCss}`;
|
|
|
8026
7392
|
const shouldApplyWebCssCompat = require_web.shouldApplyViteWebCssCompat(cssPipelineContext, frameworkCssPipelineStrategy);
|
|
8027
7393
|
const outputCss = frameworkCssPipelineStrategy?.transformGeneratedCss?.(finalizedCss, {
|
|
8028
7394
|
...cssPipelineContext,
|
|
8029
|
-
defaultWebCssCompat: (css) => (0,
|
|
8030
|
-
removeScopedPreflight: removeScopedTailwindPreflightCss,
|
|
7395
|
+
defaultWebCssCompat: (css) => (0, _weapp_tailwindcss_postcss_transform.transformWebCssCompat)(css, require_web.resolveViteWebCssCompatOptions(cssPipelineContext)),
|
|
7396
|
+
removeScopedPreflight: _weapp_tailwindcss_postcss_transform.removeScopedTailwindPreflightCss,
|
|
8031
7397
|
shouldApplyWebCssCompat
|
|
8032
|
-
}) ?? removeScopedTailwindPreflightCss(shouldApplyWebCssCompat ? (0,
|
|
7398
|
+
}) ?? (0, _weapp_tailwindcss_postcss_transform.removeScopedTailwindPreflightCss)(shouldApplyWebCssCompat ? (0, _weapp_tailwindcss_postcss_transform.transformWebCssCompat)(finalizedCss, require_web.resolveViteWebCssCompatOptions(cssPipelineContext)) : finalizedCss);
|
|
8033
7399
|
if (transient) {
|
|
8034
7400
|
for (const dependency of generated.dependencies) hookContext?.addWatchFile?.(dependency);
|
|
8035
7401
|
return outputCss;
|
|
8036
7402
|
}
|
|
8037
|
-
const tracedCss =
|
|
7403
|
+
const tracedCss = require_generated_css_marker.annotateCssSourceTrace(outputCss, {
|
|
8038
7404
|
opts,
|
|
8039
|
-
tokenSources:
|
|
7405
|
+
tokenSources: require_generated_css_marker.createCssTokenSourceMap(getSourceCandidateSourcesForEntries(void 0), opts)
|
|
8040
7406
|
});
|
|
8041
7407
|
for (const dependency of generated.dependencies) hookContext?.addWatchFile?.(dependency);
|
|
8042
7408
|
cleanGeneratedCssByFile.set(fileKey, outputCss);
|
|
8043
7409
|
tracedGeneratedCssByFile.set(fileKey, tracedCss);
|
|
8044
7410
|
generatedClassSetByFile.set(fileKey, new Set(generated.classSet));
|
|
8045
|
-
const shouldInjectGeneratedCssIntoMain = mainCssChunkMatcher(outputFile, opts.appType) ||
|
|
7411
|
+
const shouldInjectGeneratedCssIntoMain = mainCssChunkMatcher(outputFile, opts.appType) || (0, _weapp_tailwindcss_postcss_transform.hasTailwindRootDirectives)(generatorTransformCode, { importFallback: currentGeneratorOptions.importFallback }) && !require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile).includes("/");
|
|
8046
7412
|
recordViteProcessedCssAssetResult(file, tracedCss, {
|
|
8047
7413
|
injectIntoMain: shouldInjectGeneratedCssIntoMain,
|
|
8048
7414
|
outputFile
|
|
@@ -8057,7 +7423,7 @@ ${previousTracedCss}`;
|
|
|
8057
7423
|
source: tracedCss
|
|
8058
7424
|
});
|
|
8059
7425
|
markViteProcessedCssSource(file);
|
|
8060
|
-
if (
|
|
7426
|
+
if ((0, _weapp_tailwindcss_postcss_transform.hasTailwindRootDirectives)(generatorTransformCode, { importFallback: currentGeneratorOptions.importFallback })) rememberTailwindRootCssModule(id);
|
|
8061
7427
|
recordGeneratorCandidates(fullRuntime);
|
|
8062
7428
|
if (pendingHmrChange || forceFullHmrCssRegeneration) hmrCandidateState.finishTarget(file);
|
|
8063
7429
|
else if (!hmrCandidateState.hasPendingChange()) hmrCandidateState.clear();
|
|
@@ -8067,8 +7433,8 @@ ${previousTracedCss}`;
|
|
|
8067
7433
|
sourceFile: requestFile
|
|
8068
7434
|
});
|
|
8069
7435
|
debug("css generated for vite postcss pipeline: %s bytes=%d", requestFile, tracedCss.length);
|
|
8070
|
-
return `${
|
|
8071
|
-
${tracedCss}`;
|
|
7436
|
+
return `${(0, _weapp_tailwindcss_postcss_transform.createBundlerGeneratedCssMarker)("vite", normalizeViteProcessedCssFile(file))}
|
|
7437
|
+
${tracedCss}${currentGeneratorBranch.isWeb ? `\n${(0, _weapp_tailwindcss_postcss_transform.createBundlerGeneratedCssEndMarker)("vite", normalizeViteProcessedCssFile(file))}` : ""}`;
|
|
8072
7438
|
};
|
|
8073
7439
|
const generateTailwindCssForVitePipeline = require_web.createFrameworkCssGenerationQueue(normalizeGeneratedCssCacheFile, generateTailwindCssForVitePipelineNow);
|
|
8074
7440
|
const shouldDeferFrameworkPreTransformGeneration = (id, code) => frameworkCssPipelineStrategy?.shouldDeferPreTransformTailwindGeneration?.({
|
|
@@ -8083,7 +7449,7 @@ ${tracedCss}`;
|
|
|
8083
7449
|
onTailwindRootCss: registerTailwindRootCss,
|
|
8084
7450
|
onCssSourceTransform: (id, code) => cssMemory.refreshRememberedCssSourceBySourceFile(id, code),
|
|
8085
7451
|
shouldGenerateCss: (_id, code) => require_web.hasVitePipelineTailwindGenerationDirective(code),
|
|
8086
|
-
shouldDeferGeneration: (id, code) => !shouldRewriteCssImports &&
|
|
7452
|
+
shouldDeferGeneration: (id, code) => !shouldRewriteCssImports && (0, _weapp_tailwindcss_postcss_transform.hasTailwindRootDirectives)(code, { importFallback: resolveCurrentGeneratorOptions().importFallback }) || shouldDeferFrameworkPreTransformGeneration(id, code),
|
|
8087
7453
|
shouldOwnTailwindGeneration,
|
|
8088
7454
|
shouldRewrite: shouldRewriteCssImports,
|
|
8089
7455
|
weappTailwindcssDirPosix
|
|
@@ -8107,7 +7473,7 @@ ${tracedCss}`;
|
|
|
8107
7473
|
getSourceCandidates,
|
|
8108
7474
|
getSourceCandidateSource: (file) => sourceCandidateCollector.source(file),
|
|
8109
7475
|
getSourceCandidateSources: () => sourceCandidateCollector.sources(),
|
|
8110
|
-
extractSourceCandidates: (file, source) =>
|
|
7476
|
+
extractSourceCandidates: (file, source) => require_generated_css_marker.extractCandidatesFromSource(source, node_path.default.extname((0, _weapp_tailwindcss_shared.cleanUrl)(file)).slice(1) || "html", {
|
|
8111
7477
|
bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues,
|
|
8112
7478
|
customAttributesEntities,
|
|
8113
7479
|
disabledDefaultTemplateHandler
|
|
@@ -8222,7 +7588,7 @@ ${tracedCss}`;
|
|
|
8222
7588
|
if (!shouldAdaptFrameworkWatchCss()) return;
|
|
8223
7589
|
if (wrapViteCssPostTransform(config, async (css, id) => {
|
|
8224
7590
|
if (!require_web.isCSSRequest(id)) return css;
|
|
8225
|
-
if (
|
|
7591
|
+
if ((0, _weapp_tailwindcss_postcss_transform.hasBundlerGeneratedCssMarker)(css)) {
|
|
8226
7592
|
debug("preserve adapted generated css before uni-app watch cache: %s", id);
|
|
8227
7593
|
return css;
|
|
8228
7594
|
}
|
|
@@ -8235,7 +7601,7 @@ ${tracedCss}`;
|
|
|
8235
7601
|
};
|
|
8236
7602
|
const sourceCandidatesPlugin = createFrameworkSourceCandidatesPlugin({
|
|
8237
7603
|
cssMemory,
|
|
8238
|
-
hasUserCssLayerBlocks:
|
|
7604
|
+
hasUserCssLayerBlocks: _weapp_tailwindcss_postcss_transform.hasUserCssLayerBlocks,
|
|
8239
7605
|
hmrCandidateState,
|
|
8240
7606
|
hmrCssModuleVersions,
|
|
8241
7607
|
hmrTimingRecorder,
|
|
@@ -8265,7 +7631,7 @@ ${tracedCss}`;
|
|
|
8265
7631
|
}, require_web.createGenericWebProductionSourceCandidatesApply({
|
|
8266
7632
|
frameworkName: frameworkBranch.frameworkName,
|
|
8267
7633
|
getIsWebGeneratorTarget: () => resolveCurrentGeneratorBranch().isWeb,
|
|
8268
|
-
requiresSourceCandidateState:
|
|
7634
|
+
requiresSourceCandidateState: require_generated_css_marker.isCssSourceTraceEnabled(opts)
|
|
8269
7635
|
}));
|
|
8270
7636
|
const postPlugin = require_web.createFrameworkPostPlugin({
|
|
8271
7637
|
api: { registerProcessedCssAsset(entry) {
|
|
@@ -8336,13 +7702,16 @@ function wrapPluginHook(hook, before) {
|
|
|
8336
7702
|
before(...args);
|
|
8337
7703
|
return hook.apply(this, args);
|
|
8338
7704
|
};
|
|
8339
|
-
if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function")
|
|
8340
|
-
|
|
8341
|
-
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
7705
|
+
if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") {
|
|
7706
|
+
const handler = hook.handler;
|
|
7707
|
+
return {
|
|
7708
|
+
...hook,
|
|
7709
|
+
handler(...args) {
|
|
7710
|
+
before(...args);
|
|
7711
|
+
return handler.apply(this, args);
|
|
7712
|
+
}
|
|
7713
|
+
};
|
|
7714
|
+
}
|
|
8346
7715
|
return hook;
|
|
8347
7716
|
}
|
|
8348
7717
|
function wrapPluginCloseBundle(hook, dispose) {
|
|
@@ -8353,16 +7722,19 @@ function wrapPluginCloseBundle(hook, dispose) {
|
|
|
8353
7722
|
dispose.call(this);
|
|
8354
7723
|
}
|
|
8355
7724
|
};
|
|
8356
|
-
if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function")
|
|
8357
|
-
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
7725
|
+
if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") {
|
|
7726
|
+
const handler = hook.handler;
|
|
7727
|
+
return {
|
|
7728
|
+
...hook,
|
|
7729
|
+
async handler(...args) {
|
|
7730
|
+
try {
|
|
7731
|
+
return await handler.apply(this, args);
|
|
7732
|
+
} finally {
|
|
7733
|
+
dispose.call(this);
|
|
7734
|
+
}
|
|
8363
7735
|
}
|
|
8364
|
-
}
|
|
8365
|
-
}
|
|
7736
|
+
};
|
|
7737
|
+
}
|
|
8366
7738
|
return dispose;
|
|
8367
7739
|
}
|
|
8368
7740
|
function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
@@ -8374,11 +7746,11 @@ function createViteFrameworkPlugins(options = {}, frameworkBranch) {
|
|
|
8374
7746
|
}
|
|
8375
7747
|
const wrappedPlugins = plugins.map((plugin) => ({
|
|
8376
7748
|
...plugin,
|
|
8377
|
-
watchChange: wrapPluginHook(plugin
|
|
7749
|
+
watchChange: wrapPluginHook(plugin["watchChange"], (id, change) => {
|
|
8378
7750
|
if (change?.event === "delete") relationOwner.removeSource(id);
|
|
8379
7751
|
else relationOwner.observeSource(id);
|
|
8380
7752
|
}),
|
|
8381
|
-
handleHotUpdate: wrapPluginHook(plugin
|
|
7753
|
+
handleHotUpdate: wrapPluginHook(plugin["handleHotUpdate"], (context) => {
|
|
8382
7754
|
if (context?.file) relationOwner.observeSource(context.file);
|
|
8383
7755
|
})
|
|
8384
7756
|
}));
|
|
@@ -8417,12 +7789,8 @@ function createTaroAlipayBrowserslistAssetPlugin() {
|
|
|
8417
7789
|
name: "weapp-tailwindcss:taro-alipay-browserslist-asset",
|
|
8418
7790
|
enforce: "pre",
|
|
8419
7791
|
generateBundle(_options, bundle) {
|
|
8420
|
-
if (node_process.default.env
|
|
8421
|
-
bundle[".browserslistrc"] =
|
|
8422
|
-
type: "asset",
|
|
8423
|
-
fileName: ".browserslistrc",
|
|
8424
|
-
source: "defaults and fully supports es6-module"
|
|
8425
|
-
};
|
|
7792
|
+
if (node_process.default.env["TARO_ENV"] !== "alipay") return;
|
|
7793
|
+
bundle[".browserslistrc"] = createReplayCssAsset(".browserslistrc", "defaults and fully supports es6-module");
|
|
8426
7794
|
}
|
|
8427
7795
|
};
|
|
8428
7796
|
}
|
|
@@ -8495,7 +7863,7 @@ const uniAppCssPipelineStrategy = {
|
|
|
8495
7863
|
},
|
|
8496
7864
|
transformGeneratedCss(css, context) {
|
|
8497
7865
|
const webCss = context.shouldApplyWebCssCompat ? context.defaultWebCssCompat(css) : css;
|
|
8498
|
-
const safeCss = isUniAppWebviewStylePlatform(context.resolveStylePlatform()) ? (0,
|
|
7866
|
+
const safeCss = isUniAppWebviewStylePlatform(context.resolveStylePlatform()) ? (0, _weapp_tailwindcss_postcss_transform.transformWebCssSafeSelectors)(webCss, { escapeMap: context.opts.escapeMap }) : webCss;
|
|
8499
7867
|
return context.removeScopedPreflight(safeCss);
|
|
8500
7868
|
}
|
|
8501
7869
|
};
|
|
@@ -8620,16 +7988,16 @@ const uniAppXCssPipelineStrategy = {
|
|
|
8620
7988
|
return true;
|
|
8621
7989
|
},
|
|
8622
7990
|
shouldDeferEmptyScopedCssSource(context) {
|
|
8623
|
-
if (!context.cssHandlerOptions.isMainChunk &&
|
|
7991
|
+
if (!context.cssHandlerOptions.isMainChunk && (0, _weapp_tailwindcss_postcss_transform.hasTailwindApplyDirective)(context.generatorCode)) return false;
|
|
8624
7992
|
return true;
|
|
8625
7993
|
},
|
|
8626
7994
|
shouldDeferPreTransformTailwindGeneration(context) {
|
|
8627
|
-
return resolveUniAppXCssTarget(context.id) === "uvue" &&
|
|
7995
|
+
return resolveUniAppXCssTarget(context.id) === "uvue" && (0, _weapp_tailwindcss_postcss_transform.hasTailwindApplyDirective)(context.code) && !(0, _weapp_tailwindcss_postcss_transform.hasTailwindRootDirectives)(context.code, { importFallback: true });
|
|
8628
7996
|
},
|
|
8629
7997
|
transformGeneratedCss(css, context) {
|
|
8630
7998
|
const webCss = context.shouldApplyWebCssCompat ? context.defaultWebCssCompat(css) : css;
|
|
8631
|
-
const output = withUniAppXWebPreflightReset(context.removeScopedPreflight(webCss), context.currentGeneratorBranch.isWeb);
|
|
8632
|
-
return context.currentGeneratorBranch.isWeb ? output : hoistUniAppXBorderPreflight(output);
|
|
7999
|
+
const output = withUniAppXWebPreflightReset(context.removeScopedPreflight(webCss, { preserveRuntimeProperties: context.currentGeneratorBranch.isWeb }), context.currentGeneratorBranch.isWeb);
|
|
8000
|
+
return context.currentGeneratorBranch.isWeb ? output : (0, _weapp_tailwindcss_postcss_transform.hoistUniAppXBorderPreflight)(output);
|
|
8633
8001
|
}
|
|
8634
8002
|
};
|
|
8635
8003
|
function createUniAppXVitePlugins(options = {}) {
|
|
@@ -8752,7 +8120,7 @@ function resolveViteProfile(options, config, environmentName) {
|
|
|
8752
8120
|
}
|
|
8753
8121
|
const family = platformFamily(selectedPlatform ?? (config.build?.outDir ? node_path.default.basename(node_path.default.normalize(config.build.outDir)) : void 0));
|
|
8754
8122
|
if (!explicitAppType && !(rawTarget !== "web" && family !== "web")) appType = void 0;
|
|
8755
|
-
const isGenericWeb = frameworkName === "generic" && (forceGenericWeb || !explicitAppType) && rawTarget !== "weapp" &&
|
|
8123
|
+
const isGenericWeb = frameworkName === "generic" && (forceGenericWeb || !explicitAppType) && rawTarget !== "weapp" && family !== "mini-program";
|
|
8756
8124
|
const cssOnlyGenericWeb = isGenericWeb && (forceGenericWeb || rawTarget === void 0 && explicitAppType === void 0 && selectedPlatform === void 0);
|
|
8757
8125
|
const capability = isGenericWeb ? {
|
|
8758
8126
|
...require_web.createGenericWebViteCapabilityProfile(options),
|
|
@@ -8777,8 +8145,8 @@ function resolveViteProfile(options, config, environmentName) {
|
|
|
8777
8145
|
}
|
|
8778
8146
|
function invokeHook(plugin, hookName, thisArg, args) {
|
|
8779
8147
|
const hook = plugin?.[hookName];
|
|
8780
|
-
if (typeof hook === "function") return
|
|
8781
|
-
if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") return hook.handler
|
|
8148
|
+
if (typeof hook === "function") return Reflect.apply(hook, thisArg, args);
|
|
8149
|
+
if (hook && typeof hook === "object" && "handler" in hook && typeof hook.handler === "function") return Reflect.apply(hook.handler, thisArg, args);
|
|
8782
8150
|
}
|
|
8783
8151
|
function emitDeferredRuntimeLogs(opts, profile, rawOptions) {
|
|
8784
8152
|
const hasExplicitLogLevel = Object.hasOwn(rawOptions, "logLevel");
|
|
@@ -8887,7 +8255,7 @@ function createDispatcher(options) {
|
|
|
8887
8255
|
opts.appType = profile.appType;
|
|
8888
8256
|
_weapp_tailwindcss_logger.logger.debug("根据 Vite 项目根目录自动推断 appType -> %s", profile.appType);
|
|
8889
8257
|
}
|
|
8890
|
-
if (profile.isGenericWeb && (opts.generator === void 0 || typeof opts.generator === "object" && !Object.hasOwn(opts.generator, "target")) &&
|
|
8258
|
+
if (profile.isGenericWeb && (opts.generator === void 0 || typeof opts.generator === "object" && !Object.hasOwn(opts.generator, "target")) && !options.platform && !options.cssOptions?.platform && !node_process.default.env["UNI_PLATFORM"] && !node_process.default.env["UNI_UTS_PLATFORM"]) opts.generator = { target: "web" };
|
|
8891
8259
|
const capability = opts.__internalViteCapabilityProfile;
|
|
8892
8260
|
if (capability) Object.assign(capability, profile.capability);
|
|
8893
8261
|
else opts.__internalViteCapabilityProfile = profile.capability;
|
|
@@ -8935,12 +8303,6 @@ Object.defineProperty(exports, "injectBorderPreflightClass", {
|
|
|
8935
8303
|
return injectBorderPreflightClass;
|
|
8936
8304
|
}
|
|
8937
8305
|
});
|
|
8938
|
-
Object.defineProperty(exports, "isUniAppXStyleSourceEmpty", {
|
|
8939
|
-
enumerable: true,
|
|
8940
|
-
get: function() {
|
|
8941
|
-
return isUniAppXStyleSourceEmpty;
|
|
8942
|
-
}
|
|
8943
|
-
});
|
|
8944
8306
|
Object.defineProperty(exports, "shouldEnableComponentLocalStyle", {
|
|
8945
8307
|
enumerable: true,
|
|
8946
8308
|
get: function() {
|