weapp-tailwindcss 5.5.6 → 5.5.8
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 +1 -1
- 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 -1
- package/dist/bundlers/shared/framework-css-composition.d.ts +1 -1
- package/dist/bundlers/shared/framework-postcss.d.ts +1 -25
- package/dist/bundlers/shared/framework-user-css.d.ts +1 -4
- package/dist/bundlers/shared/generated-css-marker.d.ts +1 -10
- 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 -23
- 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 -12
- package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +1 -2
- 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 -60
- 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 -64
- package/dist/bundlers/shared/generator-css/user-css/apply-only.d.ts +1 -10
- 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 -4
- package/dist/bundlers/shared/generator-css/user-css/generated-cleanup.d.ts +1 -6
- 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 -13
- 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 -7
- package/dist/bundlers/shared/style-requests.d.ts +1 -5
- package/dist/bundlers/shared/v4-generation-core.d.ts +1 -20
- package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/css-transform-task.d.ts +2 -2
- package/dist/bundlers/vite/processed-css-assets/cleanup.d.ts +1 -1
- package/dist/bundlers/vite/processed-css-assets/coverage.d.ts +1 -12
- 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/framework-module-candidates.d.ts +2 -2
- 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/source-candidate-cache.d.ts +1 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.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/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/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-D3GBwxoa.js → compiler-CThodfGH.js} +3098 -3067
- package/dist/{compiler-C8FqI-P3.cjs → compiler-DbwS3329.cjs} +20979 -20870
- package/dist/core/compiler/generation-cache.d.ts +4 -2
- package/dist/core/compiler/types.d.ts +1 -1
- package/dist/core.cjs +7 -7
- package/dist/core.d.ts +2 -2
- package/dist/core.js +2 -2
- package/dist/css-cleanup-B6FUJC3z.cjs +1 -0
- package/dist/{css-imports-XvtI1zCY.cjs → css-imports-R_RDMjPz.cjs} +7 -21
- package/dist/css-macro/auto.d.ts +1 -1
- package/dist/css-macro/postcss.cjs +1 -1
- package/dist/css-macro.cjs +2 -2
- package/dist/css-macro.js +1 -1
- package/dist/final-css-cleanup-B6FUJC3z.cjs +1 -0
- package/dist/{final-css-cleanup-u_sI2p56.js → final-css-cleanup-BOzhuhGz.js} +3 -2
- package/dist/framework.cjs +1 -1
- package/dist/{v4-generation-core-Cz1D7wm1.cjs → generated-css-marker-B0RyziOH.cjs} +638 -1546
- 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-BExe5RBF.cjs → gulp-CngHA9cU.cjs} +27 -26
- package/dist/{gulp-BhkIIk7J.js → gulp-DhddVxGA.js} +6 -5
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-CoiJIqDu.cjs → hmr-timing-Dc4c1VRg.cjs} +13 -13
- package/dist/{hmr-timing-B9Yt86-U.js → hmr-timing-xPpat-km.js} +518 -1360
- 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/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/oxc-parser.d.ts +4 -0
- package/dist/pipeline-helpers-EUud9R2K.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-B6Y1bxzM.js → scoped-generator-DlQrVbuC.js} +7 -6
- package/dist/{scoped-generator-BUBls_oM.cjs → scoped-generator-lbTwL6mD.cjs} +9 -9
- package/dist/{source-candidate-scan-signature-DNuGKTqf.js → source-candidate-scan-signature-BjVQYL-C.js} +3 -3
- package/dist/{source-candidate-scan-signature-BtJZp28T.cjs → source-candidate-scan-signature-nG-rg809.cjs} +4 -4
- package/dist/style-injector/internal.d.ts +35 -35
- package/dist/style-injector/options.d.ts +1 -1
- package/dist/tailwindcss/miniprogram.d.ts +1 -1
- package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -1
- 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 -3
- 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/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-CBYjzRmV.cjs → tailwindcss-U3KIUegn.cjs} +65 -264
- package/dist/{tailwindcss-B_4E52WF.js → tailwindcss-kSd0ykiX.js} +71 -243
- package/dist/{transform-CkEnJYIP.js → transform-BAon9ykq.js} +25 -16
- package/dist/{transform-FkqbTBJR.cjs → transform-DVg4q8hh.cjs} +32 -23
- package/dist/types/index.d.ts +2 -2
- package/dist/types/user-defined-options/general.d.ts +1 -1
- package/dist/uni-app-x/border-preflight.d.ts +1 -1
- package/dist/uni-app-x/component-local-style.d.ts +3 -1
- package/dist/uni-app-x/vite/style-result.d.ts +1 -1
- 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-lP35OguX.js → vite-D-RGkmOE.js} +62 -674
- package/dist/{vite-DxuKPZlp.cjs → vite-IX83wh_L.cjs} +217 -828
- 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 +33 -28
- package/dist/weapp-tw-runtime-classset-loader.cjs +5 -18
- package/dist/{web-Dfz_jpNj.js → web--kA4HUTm.js} +16 -115
- package/dist/{web-DhDxhlkq.cjs → web-DHfZ_KC9.cjs} +83 -192
- package/dist/{webpack-R2Sbggiy.cjs → webpack-BetjemzT.cjs} +87 -87
- package/dist/{webpack-D6jp1o3m.js → webpack-Bhkd27Rs.js} +28 -441
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +12 -7
- package/dist/final-css-cleanup-CDTmVAye.cjs +0 -1
- package/dist/generator-Bvr4WmuF.cjs +0 -3891
- package/dist/generator-C0BJjyLM.js +0 -3343
- package/dist/pipeline-helpers-BOjTEmMi.cjs +0 -971
|
@@ -0,0 +1,1868 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-fg3euq-1.cjs");
|
|
2
|
+
const require_framework = require("./framework.cjs");
|
|
3
|
+
require("./auto-B1OyRrE8.cjs");
|
|
4
|
+
require("./utils-CuKLf1Zv.cjs");
|
|
5
|
+
let node_fs = require("node:fs");
|
|
6
|
+
node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
|
|
7
|
+
let node_path = require("node:path");
|
|
8
|
+
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
9
|
+
let node_process = require("node:process");
|
|
10
|
+
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
11
|
+
let _weapp_tailwindcss_engine = require("@weapp-tailwindcss/engine");
|
|
12
|
+
let _weapp_tailwindcss_postcss_transform = require("@weapp-tailwindcss/postcss/transform");
|
|
13
|
+
let lru_cache = require("lru-cache");
|
|
14
|
+
let node_module = require("node:module");
|
|
15
|
+
let _weapp_tailwindcss_source_scan = require("@weapp-tailwindcss/source-scan");
|
|
16
|
+
//#region src/runtime-branch/generator-target-env.ts
|
|
17
|
+
const explicitGeneratorTargetEnvKeys = ["WEAPP_TW_TARGET", "WEAPP_TAILWINDCSS_TARGET"];
|
|
18
|
+
const uniWebPlatformEnvKeys = ["UNI_PLATFORM", "UNI_UTS_PLATFORM"];
|
|
19
|
+
const mpxWebPlatformEnvKeys = ["MPX_CLI_MODE", "MPX_CURRENT_TARGET_MODE"];
|
|
20
|
+
function getEnvValue(key) {
|
|
21
|
+
return typeof node_process.default === "undefined" ? void 0 : node_process.default.env[key];
|
|
22
|
+
}
|
|
23
|
+
function normalizeGeneratorTargetValue(value) {
|
|
24
|
+
return value === "weapp" || value === "web" ? value : void 0;
|
|
25
|
+
}
|
|
26
|
+
function isUniWebPlatform(value) {
|
|
27
|
+
const normalized = value?.trim().toLowerCase();
|
|
28
|
+
return normalized === "h5" || normalized?.startsWith("web") === true;
|
|
29
|
+
}
|
|
30
|
+
function isUniAppWebViewPlatform(value) {
|
|
31
|
+
const normalized = value?.trim().toLowerCase();
|
|
32
|
+
return normalized === "app" || normalized === "app-plus";
|
|
33
|
+
}
|
|
34
|
+
function isUniNativeAppPlatform(value) {
|
|
35
|
+
return (value?.trim().toLowerCase())?.startsWith("app-") === true;
|
|
36
|
+
}
|
|
37
|
+
function isMpxWebPlatform(value) {
|
|
38
|
+
return value?.trim().toLowerCase() === "web";
|
|
39
|
+
}
|
|
40
|
+
function inferGeneratorTargetFromExplicitEnv() {
|
|
41
|
+
for (const key of explicitGeneratorTargetEnvKeys) {
|
|
42
|
+
const target = normalizeGeneratorTargetValue(getEnvValue(key));
|
|
43
|
+
if (target !== void 0) return target;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function shouldUseWebGeneratorTargetFromEnv() {
|
|
47
|
+
return uniWebPlatformEnvKeys.some((key) => isUniWebPlatform(getEnvValue(key))) || isUniAppWebViewPlatform(getEnvValue("UNI_PLATFORM")) && !isUniNativeAppPlatform(getEnvValue("UNI_UTS_PLATFORM")) || mpxWebPlatformEnvKeys.some((key) => isMpxWebPlatform(getEnvValue(key))) || getEnvValue("TARO_ENV") === "h5";
|
|
48
|
+
}
|
|
49
|
+
function shouldUseUniAppWebRpxCompatibility(appType) {
|
|
50
|
+
return appType === "uni-app-vite" || appType === "uni-app-x" || shouldUseWebGeneratorTargetFromEnv();
|
|
51
|
+
}
|
|
52
|
+
function shouldUseUniAppViteWebViewGeneratorTarget(appType, platform = getEnvValue("UNI_PLATFORM")) {
|
|
53
|
+
return appType === "uni-app-vite" && isUniAppWebViewPlatform(platform);
|
|
54
|
+
}
|
|
55
|
+
function inferGeneratorTargetFromEnv() {
|
|
56
|
+
return inferGeneratorTargetFromExplicitEnv() ?? (shouldUseWebGeneratorTargetFromEnv() ? "web" : "weapp");
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/tailwindcss/v4-engine/candidates.ts
|
|
60
|
+
const UNSUPPORTED_MINI_PROGRAM_TAILWIND_V4_CANDIDATE_RE = /(?:^|:)(?:has-)?(?:group|peer|in|not-in)-[^\s:]*\/|(?:^|:)(?:has-)?(?:in|not-in)-\[/;
|
|
61
|
+
function isUnsupportedMiniProgramTailwindV4Candidate(candidate) {
|
|
62
|
+
return UNSUPPORTED_MINI_PROGRAM_TAILWIND_V4_CANDIDATE_RE.test(candidate);
|
|
63
|
+
}
|
|
64
|
+
function filterUnsupportedMiniProgramTailwindV4Candidates(candidates) {
|
|
65
|
+
if (!candidates) return;
|
|
66
|
+
return new Set([...candidates].filter((candidate) => !isUnsupportedMiniProgramTailwindV4Candidate(candidate)));
|
|
67
|
+
}
|
|
68
|
+
const INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX = 12e3;
|
|
69
|
+
const INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX = 2097152;
|
|
70
|
+
const incrementalGenerateCache = new lru_cache.LRUCache({ max: 8 });
|
|
71
|
+
const incrementalGenerateTaskCache = new lru_cache.LRUCache({ max: 32 });
|
|
72
|
+
function collectCandidates(candidates) {
|
|
73
|
+
return new Set(candidates ?? []);
|
|
74
|
+
}
|
|
75
|
+
function hasRemovedCandidates(previousCandidates, nextCandidates) {
|
|
76
|
+
for (const candidate of previousCandidates) if (!nextCandidates.has(candidate)) return true;
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
function createStableJson(value) {
|
|
80
|
+
if (value === void 0) return "undefined";
|
|
81
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
82
|
+
if (Array.isArray(value)) return `[${value.map((item) => createStableJson(item)).join(",")}]`;
|
|
83
|
+
return `{${Object.keys(value).sort().map((key) => {
|
|
84
|
+
const record = value;
|
|
85
|
+
return `${JSON.stringify(key)}:${createStableJson(record[key])}`;
|
|
86
|
+
}).join(",")}}`;
|
|
87
|
+
}
|
|
88
|
+
function createDependencyFingerprint(files) {
|
|
89
|
+
return files.map((file) => {
|
|
90
|
+
try {
|
|
91
|
+
const stat = node_fs.default.statSync(file);
|
|
92
|
+
return `${file}:${stat.size}:${stat.mtimeMs}`;
|
|
93
|
+
} catch {
|
|
94
|
+
return `${file}:missing`;
|
|
95
|
+
}
|
|
96
|
+
}).join("|");
|
|
97
|
+
}
|
|
98
|
+
function createTailwindV4SourceCacheKey(source) {
|
|
99
|
+
return [
|
|
100
|
+
source.projectRoot,
|
|
101
|
+
source.base,
|
|
102
|
+
createStableJson(source.baseFallbacks),
|
|
103
|
+
source.css,
|
|
104
|
+
createDependencyFingerprint(source.dependencies)
|
|
105
|
+
].join("\0");
|
|
106
|
+
}
|
|
107
|
+
function createIncrementalGenerateCacheKey(source, target, styleOptions) {
|
|
108
|
+
return [
|
|
109
|
+
createTailwindV4SourceCacheKey(source),
|
|
110
|
+
target,
|
|
111
|
+
createStableJson(styleOptions)
|
|
112
|
+
].join("\0");
|
|
113
|
+
}
|
|
114
|
+
function createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources) {
|
|
115
|
+
return [
|
|
116
|
+
cacheKey,
|
|
117
|
+
scanSources === true ? "scan:1" : "scan:0",
|
|
118
|
+
[...requestedCandidates].sort().join("\n")
|
|
119
|
+
].join("\0");
|
|
120
|
+
}
|
|
121
|
+
function runIncrementalGenerateTask(cacheKey, requestedCandidates, scanSources, task) {
|
|
122
|
+
const taskKey = createIncrementalGenerateTaskCacheKey(cacheKey, requestedCandidates, scanSources);
|
|
123
|
+
const cachedTask = incrementalGenerateTaskCache.get(taskKey);
|
|
124
|
+
if (cachedTask) return cachedTask;
|
|
125
|
+
const promise = task();
|
|
126
|
+
incrementalGenerateTaskCache.set(taskKey, promise);
|
|
127
|
+
promise.finally(() => {
|
|
128
|
+
if (incrementalGenerateTaskCache.get(taskKey) === promise) incrementalGenerateTaskCache.delete(taskKey);
|
|
129
|
+
});
|
|
130
|
+
return promise;
|
|
131
|
+
}
|
|
132
|
+
function createIncrementalDesignSystemPromise(source, cacheKey) {
|
|
133
|
+
const promise = (0, _weapp_tailwindcss_engine.loadTailwindV4DesignSystem)(source);
|
|
134
|
+
promise.catch(() => {
|
|
135
|
+
if (incrementalGenerateCache.get(cacheKey)?.designSystemPromise === promise) incrementalGenerateCache.delete(cacheKey);
|
|
136
|
+
});
|
|
137
|
+
return promise;
|
|
138
|
+
}
|
|
139
|
+
function resolveTargetCandidates(candidates, target) {
|
|
140
|
+
const collected = collectCandidates(candidates);
|
|
141
|
+
return target === "weapp" ? filterUnsupportedMiniProgramTailwindV4Candidates(collected) : collected;
|
|
142
|
+
}
|
|
143
|
+
function collectSeenCandidates(generated) {
|
|
144
|
+
return new Set(generated.classSet);
|
|
145
|
+
}
|
|
146
|
+
function createIncrementalStyleOptions(styleOptions) {
|
|
147
|
+
return {
|
|
148
|
+
...styleOptions,
|
|
149
|
+
isMainChunk: false
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function resolveStyleOptions(source, options) {
|
|
153
|
+
return (0, _weapp_tailwindcss_postcss_transform.hasCssMacroTailwindV4Source)(source.css) ? (0, _weapp_tailwindcss_postcss_transform.withCssMacroStyleOptions)(options) : options;
|
|
154
|
+
}
|
|
155
|
+
function createStableTextSignature(input) {
|
|
156
|
+
let hash = 2166136261;
|
|
157
|
+
for (let i = 0; i < input.length; i++) {
|
|
158
|
+
hash ^= input.charCodeAt(i);
|
|
159
|
+
hash = Math.imul(hash, 16777619);
|
|
160
|
+
}
|
|
161
|
+
return (hash >>> 0).toString(36);
|
|
162
|
+
}
|
|
163
|
+
function summarizeIncrementalCacheKey(key) {
|
|
164
|
+
return {
|
|
165
|
+
keyHash: createStableTextSignature(key),
|
|
166
|
+
keyBytes: key.length
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates) {
|
|
170
|
+
return cached.seenCandidates.size + missingCandidates.length > 12e3 || cached.css.length > 2097152 || cached.rawCss.length > 2097152 || requestedCandidates.size > 12e3;
|
|
171
|
+
}
|
|
172
|
+
function shouldAdmitIncrementalEntry(requestedCandidates, generated) {
|
|
173
|
+
return requestedCandidates.size <= 12e3 && generated.css.length <= 2097152 && generated.rawCss.length <= 2097152;
|
|
174
|
+
}
|
|
175
|
+
function seedIncrementalGenerateCache(options) {
|
|
176
|
+
if (!shouldAdmitIncrementalEntry(options.requestedCandidates, options.generated)) return false;
|
|
177
|
+
const cacheKey = createIncrementalGenerateCacheKey(options.compatibleSource, options.target, options.styleOptions);
|
|
178
|
+
const customPropertyValues = (0, _weapp_tailwindcss_postcss_transform.collectCustomPropertyValues)(options.compatibleSource.css);
|
|
179
|
+
(0, _weapp_tailwindcss_postcss_transform.mergeCustomPropertyValues)(customPropertyValues, options.generated.css);
|
|
180
|
+
incrementalGenerateCache.set(cacheKey, {
|
|
181
|
+
seenCandidates: collectSeenCandidates(options.generated),
|
|
182
|
+
classSet: new Set(options.generated.classSet),
|
|
183
|
+
css: options.generated.css,
|
|
184
|
+
rawCss: options.generated.rawCss,
|
|
185
|
+
customPropertyValues,
|
|
186
|
+
designSystemPromise: createIncrementalDesignSystemPromise(options.compatibleSource, cacheKey),
|
|
187
|
+
dependencies: options.generated.dependencies,
|
|
188
|
+
sources: options.generated.sources,
|
|
189
|
+
root: options.generated.root,
|
|
190
|
+
target: options.generated.target
|
|
191
|
+
});
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
function shouldNormalizeRpxLengthCandidatesForTarget(target, styleOptions) {
|
|
195
|
+
if (target !== "web") return true;
|
|
196
|
+
return shouldUseUniAppWebRpxCompatibility(styleOptions?.appType);
|
|
197
|
+
}
|
|
198
|
+
function normalizeTargetRpxLengthCandidates(candidates, target, styleOptions) {
|
|
199
|
+
return shouldNormalizeRpxLengthCandidatesForTarget(target, styleOptions) ? (0, _weapp_tailwindcss_postcss_transform.normalizeRpxLengthCandidates)(candidates) : {
|
|
200
|
+
candidates: new Set(candidates),
|
|
201
|
+
restoreCandidates: /* @__PURE__ */ new Map()
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/tailwindcss/v4-engine/generator/cache-stats.ts
|
|
206
|
+
function getTailwindV4IncrementalGenerateCacheStats() {
|
|
207
|
+
return {
|
|
208
|
+
max: 8,
|
|
209
|
+
entryCandidatesMax: INCREMENTAL_GENERATE_ENTRY_CANDIDATES_MAX,
|
|
210
|
+
entryCssBytesMax: INCREMENTAL_GENERATE_ENTRY_CSS_BYTES_MAX,
|
|
211
|
+
size: incrementalGenerateCache.size,
|
|
212
|
+
taskMax: 32,
|
|
213
|
+
taskSize: incrementalGenerateTaskCache.size,
|
|
214
|
+
entries: [...incrementalGenerateCache.entries()].map(([key, entry]) => ({
|
|
215
|
+
...summarizeIncrementalCacheKey(key),
|
|
216
|
+
candidates: entry.seenCandidates.size,
|
|
217
|
+
classSet: entry.classSet.size,
|
|
218
|
+
cssBytes: entry.css.length,
|
|
219
|
+
rawCssBytes: entry.rawCss.length
|
|
220
|
+
})),
|
|
221
|
+
keys: [...incrementalGenerateCache.keys()].map(summarizeIncrementalCacheKey),
|
|
222
|
+
taskKeys: [...incrementalGenerateTaskCache.keys()].map(summarizeIncrementalCacheKey)
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region src/tailwindcss/v4-engine/css-macro-source.ts
|
|
227
|
+
function resolveCssMacroTailwindV4Source(source) {
|
|
228
|
+
const css = (0, _weapp_tailwindcss_postcss_transform.transformCssMacroTailwindV4Source)(source.css);
|
|
229
|
+
return css === source.css ? source : {
|
|
230
|
+
...source,
|
|
231
|
+
css
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/tailwindcss/v4-engine/miniprogram.ts
|
|
236
|
+
function transformTailwindV4CssByTarget(css, target, options) {
|
|
237
|
+
return (0, _weapp_tailwindcss_postcss_transform.transformTailwindV4GeneratedCss)(css, target, options, shouldUseUniAppWebRpxCompatibility(options?.appType));
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/tailwindcss/v4-engine/tailwind-v4-default-colors.ts
|
|
241
|
+
const TAILWIND_V4_COLOR_STEPS = [
|
|
242
|
+
"50",
|
|
243
|
+
"100",
|
|
244
|
+
"200",
|
|
245
|
+
"300",
|
|
246
|
+
"400",
|
|
247
|
+
"500",
|
|
248
|
+
"600",
|
|
249
|
+
"700",
|
|
250
|
+
"800",
|
|
251
|
+
"900",
|
|
252
|
+
"950"
|
|
253
|
+
];
|
|
254
|
+
const TAILWIND_V4_COLOR_PALETTE = {
|
|
255
|
+
slate: [
|
|
256
|
+
"#f8fafc",
|
|
257
|
+
"#f1f5f9",
|
|
258
|
+
"#e2e8f0",
|
|
259
|
+
"#cad5e2",
|
|
260
|
+
"#90a1b9",
|
|
261
|
+
"#62748e",
|
|
262
|
+
"#45556c",
|
|
263
|
+
"#314158",
|
|
264
|
+
"#1d293d",
|
|
265
|
+
"#0f172b",
|
|
266
|
+
"#020618"
|
|
267
|
+
],
|
|
268
|
+
gray: [
|
|
269
|
+
"#f9fafb",
|
|
270
|
+
"#f3f4f6",
|
|
271
|
+
"#e5e7eb",
|
|
272
|
+
"#d1d5dc",
|
|
273
|
+
"#99a1af",
|
|
274
|
+
"#6a7282",
|
|
275
|
+
"#4a5565",
|
|
276
|
+
"#364153",
|
|
277
|
+
"#1e2939",
|
|
278
|
+
"#101828",
|
|
279
|
+
"#030712"
|
|
280
|
+
],
|
|
281
|
+
zinc: [
|
|
282
|
+
"#fafafa",
|
|
283
|
+
"#f4f4f5",
|
|
284
|
+
"#e4e4e7",
|
|
285
|
+
"#d4d4d8",
|
|
286
|
+
"#9f9fa9",
|
|
287
|
+
"#71717b",
|
|
288
|
+
"#52525c",
|
|
289
|
+
"#3f3f46",
|
|
290
|
+
"#27272a",
|
|
291
|
+
"#18181b",
|
|
292
|
+
"#09090b"
|
|
293
|
+
],
|
|
294
|
+
neutral: [
|
|
295
|
+
"#fafafa",
|
|
296
|
+
"#f5f5f5",
|
|
297
|
+
"#e5e5e5",
|
|
298
|
+
"#d4d4d4",
|
|
299
|
+
"#a1a1a1",
|
|
300
|
+
"#737373",
|
|
301
|
+
"#525252",
|
|
302
|
+
"#404040",
|
|
303
|
+
"#262626",
|
|
304
|
+
"#171717",
|
|
305
|
+
"#0a0a0a"
|
|
306
|
+
],
|
|
307
|
+
stone: [
|
|
308
|
+
"#fafaf9",
|
|
309
|
+
"#f5f5f4",
|
|
310
|
+
"#e7e5e4",
|
|
311
|
+
"#d6d3d1",
|
|
312
|
+
"#a6a09b",
|
|
313
|
+
"#79716b",
|
|
314
|
+
"#57534d",
|
|
315
|
+
"#44403b",
|
|
316
|
+
"#292524",
|
|
317
|
+
"#1c1917",
|
|
318
|
+
"#0c0a09"
|
|
319
|
+
],
|
|
320
|
+
mauve: [
|
|
321
|
+
"#fafafa",
|
|
322
|
+
"#f3f1f3",
|
|
323
|
+
"#e7e4e7",
|
|
324
|
+
"#d7d0d7",
|
|
325
|
+
"#a89ea9",
|
|
326
|
+
"#79697b",
|
|
327
|
+
"#594c5b",
|
|
328
|
+
"#463947",
|
|
329
|
+
"#2a212c",
|
|
330
|
+
"#1d161e",
|
|
331
|
+
"#0c090c"
|
|
332
|
+
],
|
|
333
|
+
olive: [
|
|
334
|
+
"#fbfbf9",
|
|
335
|
+
"#f4f4f0",
|
|
336
|
+
"#e8e8e3",
|
|
337
|
+
"#d8d8d0",
|
|
338
|
+
"#abab9c",
|
|
339
|
+
"#7c7c67",
|
|
340
|
+
"#5b5b4b",
|
|
341
|
+
"#474739",
|
|
342
|
+
"#2b2b22",
|
|
343
|
+
"#1d1d16",
|
|
344
|
+
"#0c0c09"
|
|
345
|
+
],
|
|
346
|
+
mist: [
|
|
347
|
+
"#f9fbfb",
|
|
348
|
+
"#f1f3f3",
|
|
349
|
+
"#e3e7e8",
|
|
350
|
+
"#d0d6d8",
|
|
351
|
+
"#9ca8ab",
|
|
352
|
+
"#67787c",
|
|
353
|
+
"#4b585b",
|
|
354
|
+
"#394447",
|
|
355
|
+
"#22292b",
|
|
356
|
+
"#161b1d",
|
|
357
|
+
"#090b0c"
|
|
358
|
+
],
|
|
359
|
+
taupe: [
|
|
360
|
+
"#fbfaf9",
|
|
361
|
+
"#f3f1f1",
|
|
362
|
+
"#e8e4e3",
|
|
363
|
+
"#d8d2d0",
|
|
364
|
+
"#aba09c",
|
|
365
|
+
"#7c6d67",
|
|
366
|
+
"#5b4f4b",
|
|
367
|
+
"#473c39",
|
|
368
|
+
"#2b2422",
|
|
369
|
+
"#1d1816",
|
|
370
|
+
"#0c0a09"
|
|
371
|
+
],
|
|
372
|
+
red: [
|
|
373
|
+
"#fef2f2",
|
|
374
|
+
"#ffe2e2",
|
|
375
|
+
"#ffc9c9",
|
|
376
|
+
"#ffa2a2",
|
|
377
|
+
"#ff6467",
|
|
378
|
+
"#fb2c36",
|
|
379
|
+
"#e7000b",
|
|
380
|
+
"#c10007",
|
|
381
|
+
"#9f0712",
|
|
382
|
+
"#82181a",
|
|
383
|
+
"#460809"
|
|
384
|
+
],
|
|
385
|
+
orange: [
|
|
386
|
+
"#fff7ed",
|
|
387
|
+
"#ffedd4",
|
|
388
|
+
"#ffd6a7",
|
|
389
|
+
"#ffb86a",
|
|
390
|
+
"#ff8904",
|
|
391
|
+
"#ff6900",
|
|
392
|
+
"#f54900",
|
|
393
|
+
"#ca3500",
|
|
394
|
+
"#9f2d00",
|
|
395
|
+
"#7e2a0c",
|
|
396
|
+
"#441306"
|
|
397
|
+
],
|
|
398
|
+
amber: [
|
|
399
|
+
"#fffbeb",
|
|
400
|
+
"#fef3c6",
|
|
401
|
+
"#fee685",
|
|
402
|
+
"#ffd230",
|
|
403
|
+
"#ffb900",
|
|
404
|
+
"#fe9a00",
|
|
405
|
+
"#e17100",
|
|
406
|
+
"#bb4d00",
|
|
407
|
+
"#973c00",
|
|
408
|
+
"#7b3306",
|
|
409
|
+
"#461901"
|
|
410
|
+
],
|
|
411
|
+
yellow: [
|
|
412
|
+
"#fefce8",
|
|
413
|
+
"#fef9c2",
|
|
414
|
+
"#fff085",
|
|
415
|
+
"#ffdf20",
|
|
416
|
+
"#fdc700",
|
|
417
|
+
"#f0b100",
|
|
418
|
+
"#d08700",
|
|
419
|
+
"#a65f00",
|
|
420
|
+
"#894b00",
|
|
421
|
+
"#733e0a",
|
|
422
|
+
"#432004"
|
|
423
|
+
],
|
|
424
|
+
lime: [
|
|
425
|
+
"#f7fee7",
|
|
426
|
+
"#ecfcca",
|
|
427
|
+
"#d8f999",
|
|
428
|
+
"#bbf451",
|
|
429
|
+
"#9ae600",
|
|
430
|
+
"#7ccf00",
|
|
431
|
+
"#5ea500",
|
|
432
|
+
"#497d00",
|
|
433
|
+
"#3c6300",
|
|
434
|
+
"#35530e",
|
|
435
|
+
"#192e03"
|
|
436
|
+
],
|
|
437
|
+
green: [
|
|
438
|
+
"#f0fdf4",
|
|
439
|
+
"#dcfce7",
|
|
440
|
+
"#b9f8cf",
|
|
441
|
+
"#7bf1a8",
|
|
442
|
+
"#05df72",
|
|
443
|
+
"#00c950",
|
|
444
|
+
"#00a63e",
|
|
445
|
+
"#008236",
|
|
446
|
+
"#016630",
|
|
447
|
+
"#0d542b",
|
|
448
|
+
"#032e15"
|
|
449
|
+
],
|
|
450
|
+
emerald: [
|
|
451
|
+
"#ecfdf5",
|
|
452
|
+
"#d0fae5",
|
|
453
|
+
"#a4f4cf",
|
|
454
|
+
"#5ee9b5",
|
|
455
|
+
"#00d492",
|
|
456
|
+
"#00bc7d",
|
|
457
|
+
"#009966",
|
|
458
|
+
"#007a55",
|
|
459
|
+
"#006045",
|
|
460
|
+
"#004f3b",
|
|
461
|
+
"#002c22"
|
|
462
|
+
],
|
|
463
|
+
teal: [
|
|
464
|
+
"#f0fdfa",
|
|
465
|
+
"#cbfbf1",
|
|
466
|
+
"#96f7e4",
|
|
467
|
+
"#46ecd5",
|
|
468
|
+
"#00d5be",
|
|
469
|
+
"#00bba7",
|
|
470
|
+
"#009689",
|
|
471
|
+
"#00786f",
|
|
472
|
+
"#005f5a",
|
|
473
|
+
"#0b4f4a",
|
|
474
|
+
"#022f2e"
|
|
475
|
+
],
|
|
476
|
+
cyan: [
|
|
477
|
+
"#ecfeff",
|
|
478
|
+
"#cefafe",
|
|
479
|
+
"#a2f4fd",
|
|
480
|
+
"#53eafd",
|
|
481
|
+
"#00d3f2",
|
|
482
|
+
"#00b8db",
|
|
483
|
+
"#0092b8",
|
|
484
|
+
"#007595",
|
|
485
|
+
"#005f78",
|
|
486
|
+
"#104e64",
|
|
487
|
+
"#053345"
|
|
488
|
+
],
|
|
489
|
+
sky: [
|
|
490
|
+
"#f0f9ff",
|
|
491
|
+
"#dff2fe",
|
|
492
|
+
"#b8e6fe",
|
|
493
|
+
"#74d4ff",
|
|
494
|
+
"#00bcff",
|
|
495
|
+
"#00a6f4",
|
|
496
|
+
"#0084d1",
|
|
497
|
+
"#0069a8",
|
|
498
|
+
"#00598a",
|
|
499
|
+
"#024a70",
|
|
500
|
+
"#052f4a"
|
|
501
|
+
],
|
|
502
|
+
blue: [
|
|
503
|
+
"#eff6ff",
|
|
504
|
+
"#dbeafe",
|
|
505
|
+
"#bedbff",
|
|
506
|
+
"#8ec5ff",
|
|
507
|
+
"#51a2ff",
|
|
508
|
+
"#2b7fff",
|
|
509
|
+
"#155dfc",
|
|
510
|
+
"#1447e6",
|
|
511
|
+
"#193cb8",
|
|
512
|
+
"#1c398e",
|
|
513
|
+
"#162456"
|
|
514
|
+
],
|
|
515
|
+
indigo: [
|
|
516
|
+
"#eef2ff",
|
|
517
|
+
"#e0e7ff",
|
|
518
|
+
"#c6d2ff",
|
|
519
|
+
"#a3b3ff",
|
|
520
|
+
"#7c86ff",
|
|
521
|
+
"#615fff",
|
|
522
|
+
"#4f39f6",
|
|
523
|
+
"#432dd7",
|
|
524
|
+
"#372aac",
|
|
525
|
+
"#312c85",
|
|
526
|
+
"#1e1a4d"
|
|
527
|
+
],
|
|
528
|
+
violet: [
|
|
529
|
+
"#f5f3ff",
|
|
530
|
+
"#ede9fe",
|
|
531
|
+
"#ddd6ff",
|
|
532
|
+
"#c4b4ff",
|
|
533
|
+
"#a684ff",
|
|
534
|
+
"#8e51ff",
|
|
535
|
+
"#7f22fe",
|
|
536
|
+
"#7008e7",
|
|
537
|
+
"#5d0ec0",
|
|
538
|
+
"#4d179a",
|
|
539
|
+
"#2f0d68"
|
|
540
|
+
],
|
|
541
|
+
purple: [
|
|
542
|
+
"#faf5ff",
|
|
543
|
+
"#f3e8ff",
|
|
544
|
+
"#e9d4ff",
|
|
545
|
+
"#dab2ff",
|
|
546
|
+
"#c27aff",
|
|
547
|
+
"#ad46ff",
|
|
548
|
+
"#9810fa",
|
|
549
|
+
"#8200db",
|
|
550
|
+
"#6e11b0",
|
|
551
|
+
"#59168b",
|
|
552
|
+
"#3c0366"
|
|
553
|
+
],
|
|
554
|
+
fuchsia: [
|
|
555
|
+
"#fdf4ff",
|
|
556
|
+
"#fae8ff",
|
|
557
|
+
"#f6cfff",
|
|
558
|
+
"#f4a8ff",
|
|
559
|
+
"#ed6aff",
|
|
560
|
+
"#e12afb",
|
|
561
|
+
"#c800de",
|
|
562
|
+
"#a800b7",
|
|
563
|
+
"#8a0194",
|
|
564
|
+
"#721378",
|
|
565
|
+
"#4b004f"
|
|
566
|
+
],
|
|
567
|
+
pink: [
|
|
568
|
+
"#fdf2f8",
|
|
569
|
+
"#fce7f3",
|
|
570
|
+
"#fccee8",
|
|
571
|
+
"#fda5d5",
|
|
572
|
+
"#fb64b6",
|
|
573
|
+
"#f6339a",
|
|
574
|
+
"#e60076",
|
|
575
|
+
"#c6005c",
|
|
576
|
+
"#a3004c",
|
|
577
|
+
"#861043",
|
|
578
|
+
"#510424"
|
|
579
|
+
],
|
|
580
|
+
rose: [
|
|
581
|
+
"#fff1f2",
|
|
582
|
+
"#ffe4e6",
|
|
583
|
+
"#ffccd3",
|
|
584
|
+
"#ffa1ad",
|
|
585
|
+
"#ff637e",
|
|
586
|
+
"#ff2056",
|
|
587
|
+
"#ec003f",
|
|
588
|
+
"#c70036",
|
|
589
|
+
"#a50036",
|
|
590
|
+
"#8b0836",
|
|
591
|
+
"#4d0218"
|
|
592
|
+
]
|
|
593
|
+
};
|
|
594
|
+
function createTailwindV4DefaultColorThemeCss() {
|
|
595
|
+
const declarations = [" --color-black: #000;", " --color-white: #fff;"];
|
|
596
|
+
for (const [color, values] of Object.entries(TAILWIND_V4_COLOR_PALETTE)) for (let index = 0; index < TAILWIND_V4_COLOR_STEPS.length; index++) declarations.push(` --color-${color}-${TAILWIND_V4_COLOR_STEPS[index]}: ${values[index]};`);
|
|
597
|
+
return [
|
|
598
|
+
"@theme {",
|
|
599
|
+
...declarations,
|
|
600
|
+
"}"
|
|
601
|
+
].join("\n");
|
|
602
|
+
}
|
|
603
|
+
//#endregion
|
|
604
|
+
//#region src/tailwindcss/v4-engine/generator/css-compat.ts
|
|
605
|
+
const require$2 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
606
|
+
const tailwindThemeCssCache = /* @__PURE__ */ new Map();
|
|
607
|
+
function readCachedCss(file) {
|
|
608
|
+
const cached = tailwindThemeCssCache.get(file);
|
|
609
|
+
if (cached !== void 0) return cached;
|
|
610
|
+
const css = (0, node_fs.readFileSync)(file, "utf8");
|
|
611
|
+
tailwindThemeCssCache.set(file, css);
|
|
612
|
+
return css;
|
|
613
|
+
}
|
|
614
|
+
function resolveTailwindV4ThemeCssFromImport(css) {
|
|
615
|
+
const root = _weapp_tailwindcss_postcss_transform.postcss.parse(css);
|
|
616
|
+
let resolved;
|
|
617
|
+
root.walkAtRules("import", (rule) => {
|
|
618
|
+
if (resolved) return;
|
|
619
|
+
const specifier = (0, _weapp_tailwindcss_postcss_transform.parseCssImportSpecifier)(rule.params)?.specifier;
|
|
620
|
+
if (!specifier || !node_path.default.isAbsolute(specifier) || node_path.default.basename(specifier) !== "index.css") return;
|
|
621
|
+
const themeCss = node_path.default.join(node_path.default.dirname(specifier), "theme.css");
|
|
622
|
+
if ((0, node_fs.existsSync)(themeCss)) resolved = themeCss;
|
|
623
|
+
});
|
|
624
|
+
return resolved;
|
|
625
|
+
}
|
|
626
|
+
function resolveTailwindV4ThemeCssFromBase(base) {
|
|
627
|
+
try {
|
|
628
|
+
return (0, node_module.createRequire)(node_path.default.join(base, "package.json")).resolve("tailwindcss/theme.css");
|
|
629
|
+
} catch {
|
|
630
|
+
try {
|
|
631
|
+
return require$2.resolve("tailwindcss/theme.css");
|
|
632
|
+
} catch {
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
function resolveTailwindV4DefaultThemeCss(source) {
|
|
638
|
+
try {
|
|
639
|
+
const themeCss = resolveTailwindV4ThemeCssFromImport(source.css) ?? resolveTailwindV4ThemeCssFromBase(source.base);
|
|
640
|
+
return themeCss ? readCachedCss(themeCss) : createTailwindV4DefaultColorThemeCss();
|
|
641
|
+
} catch {
|
|
642
|
+
return createTailwindV4DefaultColorThemeCss();
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
function applyMiniProgramTailwindV4DefaultColorCss(css, source) {
|
|
646
|
+
const themeCss = resolveTailwindV4DefaultThemeCss(source);
|
|
647
|
+
return (0, _weapp_tailwindcss_postcss_transform.insertTailwindThemeCss)(css, themeCss);
|
|
648
|
+
}
|
|
649
|
+
function createCompatibleSource(source, target) {
|
|
650
|
+
const filteredSourceCss = target === "weapp" ? (0, _weapp_tailwindcss_postcss_transform.removeTailwindV4PreflightImports)(source.css) : source.css;
|
|
651
|
+
const sourceCss = target === "weapp" ? applyMiniProgramTailwindV4DefaultColorCss(filteredSourceCss, source) : filteredSourceCss;
|
|
652
|
+
const compatibleSourceCss = (0, _weapp_tailwindcss_postcss_transform.removeUnsupportedThemeVendorKeyframes)(sourceCss);
|
|
653
|
+
return compatibleSourceCss === source.css ? source : {
|
|
654
|
+
...source,
|
|
655
|
+
css: compatibleSourceCss
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
//#endregion
|
|
659
|
+
//#region \0@oxc-project+runtime@0.148.0/helpers/esm/typeof.js
|
|
660
|
+
function _typeof(o) {
|
|
661
|
+
"@babel/helpers - typeof";
|
|
662
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
663
|
+
return typeof o;
|
|
664
|
+
} : function(o) {
|
|
665
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
666
|
+
}, _typeof(o);
|
|
667
|
+
}
|
|
668
|
+
//#endregion
|
|
669
|
+
//#region \0@oxc-project+runtime@0.148.0/helpers/esm/toPrimitive.js
|
|
670
|
+
function toPrimitive(t, r) {
|
|
671
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
672
|
+
var e = t[Symbol.toPrimitive];
|
|
673
|
+
if (void 0 !== e) {
|
|
674
|
+
var i = e.call(t, r || "default");
|
|
675
|
+
if ("object" != _typeof(i)) return i;
|
|
676
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
677
|
+
}
|
|
678
|
+
return ("string" === r ? String : Number)(t);
|
|
679
|
+
}
|
|
680
|
+
//#endregion
|
|
681
|
+
//#region \0@oxc-project+runtime@0.148.0/helpers/esm/toPropertyKey.js
|
|
682
|
+
function toPropertyKey(t) {
|
|
683
|
+
var i = toPrimitive(t, "string");
|
|
684
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
685
|
+
}
|
|
686
|
+
//#endregion
|
|
687
|
+
//#region \0@oxc-project+runtime@0.148.0/helpers/esm/defineProperty.js
|
|
688
|
+
function _defineProperty(e, r, t) {
|
|
689
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
690
|
+
value: t,
|
|
691
|
+
enumerable: !0,
|
|
692
|
+
configurable: !0,
|
|
693
|
+
writable: !0
|
|
694
|
+
}) : e[r] = t, e;
|
|
695
|
+
}
|
|
696
|
+
//#endregion
|
|
697
|
+
//#region src/tailwindcss/v4-engine/generator/native-session.ts
|
|
698
|
+
var TailwindV4NativeSessionPool = class {
|
|
699
|
+
constructor(createSession = _weapp_tailwindcss_engine.createTailwindGenerationSession) {
|
|
700
|
+
this.createSession = createSession;
|
|
701
|
+
_defineProperty(this, "sessions", /* @__PURE__ */ new Map());
|
|
702
|
+
_defineProperty(this, "disposed", false);
|
|
703
|
+
}
|
|
704
|
+
generate(target, sourceKey, source, request) {
|
|
705
|
+
const entry = this.getSession(target, sourceKey, source);
|
|
706
|
+
const generated = entry.pending.then(() => entry.session.generate(request));
|
|
707
|
+
entry.pending = generated.then(() => void 0, () => void 0);
|
|
708
|
+
return generated;
|
|
709
|
+
}
|
|
710
|
+
dispose() {
|
|
711
|
+
for (const entry of this.sessions.values()) this.disposeEntry(entry);
|
|
712
|
+
this.sessions.clear();
|
|
713
|
+
this.disposed = true;
|
|
714
|
+
}
|
|
715
|
+
get size() {
|
|
716
|
+
return this.sessions.size;
|
|
717
|
+
}
|
|
718
|
+
getSession(target, sourceKey, source) {
|
|
719
|
+
if (this.disposed) throw new Error("TailwindV4NativeSessionPool 已释放。");
|
|
720
|
+
const cached = this.sessions.get(target);
|
|
721
|
+
if (cached?.sourceKey === sourceKey) return cached;
|
|
722
|
+
if (cached) this.disposeEntry(cached);
|
|
723
|
+
const session = this.createSession(source);
|
|
724
|
+
const entry = {
|
|
725
|
+
pending: Promise.resolve(),
|
|
726
|
+
session,
|
|
727
|
+
sourceKey
|
|
728
|
+
};
|
|
729
|
+
this.sessions.set(target, entry);
|
|
730
|
+
return entry;
|
|
731
|
+
}
|
|
732
|
+
disposeEntry(entry) {
|
|
733
|
+
entry.pending.then(() => entry.session.dispose());
|
|
734
|
+
}
|
|
735
|
+
};
|
|
736
|
+
function createEngineSourceEntries(sources, sourceId) {
|
|
737
|
+
return sources.map((source, index) => ({
|
|
738
|
+
id: `${sourceId}:candidate-source:${index}`,
|
|
739
|
+
...source
|
|
740
|
+
}));
|
|
741
|
+
}
|
|
742
|
+
function serializeTailwindGenerationArtifact(artifact) {
|
|
743
|
+
return [...artifact.fragments].sort((left, right) => left.order - right.order).map((fragment) => fragment.root.toString()).join("\n");
|
|
744
|
+
}
|
|
745
|
+
//#endregion
|
|
746
|
+
//#region src/tailwindcss/v4-engine/generator/scan-sources.ts
|
|
747
|
+
async function resolveScanSources(source, scanSources) {
|
|
748
|
+
if (scanSources !== true) return scanSources;
|
|
749
|
+
const definitions = [];
|
|
750
|
+
const append = (css, base, from) => {
|
|
751
|
+
try {
|
|
752
|
+
definitions.push({
|
|
753
|
+
root: _weapp_tailwindcss_postcss_transform.postcss.parse(css, { from }),
|
|
754
|
+
base
|
|
755
|
+
});
|
|
756
|
+
} catch {}
|
|
757
|
+
};
|
|
758
|
+
append(source.css, source.base, source.dependencies[0]);
|
|
759
|
+
for (const file of source.dependencies.slice(1)) try {
|
|
760
|
+
append((0, node_fs.readFileSync)(file, "utf8"), node_path.default.dirname(file), file);
|
|
761
|
+
} catch {}
|
|
762
|
+
const scan = await (0, _weapp_tailwindcss_postcss_transform.resolveCssScanSources)(definitions, {
|
|
763
|
+
base: source.base,
|
|
764
|
+
defaultBase: source.projectRoot ?? source.cwd ?? source.base,
|
|
765
|
+
automatic: "fallback",
|
|
766
|
+
requireImport: true,
|
|
767
|
+
pattern: "**/*",
|
|
768
|
+
configResolution: "module",
|
|
769
|
+
ignoredPatterns: _weapp_tailwindcss_source_scan.LEGACY_SOURCE_IGNORED_PATTERNS
|
|
770
|
+
});
|
|
771
|
+
return scan.entries.some((entry) => !entry.negated) || scan.explicitEntries.length + scan.configEntries.length > 0 ? scan.entries : false;
|
|
772
|
+
}
|
|
773
|
+
function resolveCompiledSourceRoot(source) {
|
|
774
|
+
try {
|
|
775
|
+
const descriptor = (0, _weapp_tailwindcss_postcss_transform.describeCssSources)(_weapp_tailwindcss_postcss_transform.postcss.parse(source.css));
|
|
776
|
+
for (const item of descriptor.imports) {
|
|
777
|
+
if (item.none) return "none";
|
|
778
|
+
if (item.sourcePath) return {
|
|
779
|
+
base: source.base,
|
|
780
|
+
pattern: item.sourcePath
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
} catch {}
|
|
784
|
+
return null;
|
|
785
|
+
}
|
|
786
|
+
//#endregion
|
|
787
|
+
//#region src/tailwindcss/v4-engine/generator/style-context.ts
|
|
788
|
+
function resolveGenerationStyleContext(sourceCss, generatedCss, options) {
|
|
789
|
+
const calc = options?.cssOptions?.cssCalc ?? options?.cssCalc;
|
|
790
|
+
const include = Array.isArray(calc) ? calc : calc && typeof calc === "object" ? calc.includeCustomProperties : void 0;
|
|
791
|
+
if (calc !== true && !include?.length) return options;
|
|
792
|
+
const customPropertyValues = (0, _weapp_tailwindcss_postcss_transform.collectCustomPropertyValues)(sourceCss);
|
|
793
|
+
(0, _weapp_tailwindcss_postcss_transform.mergeCustomPropertyValues)(customPropertyValues, generatedCss);
|
|
794
|
+
for (const [name, value] of options?.customPropertyValues ?? []) customPropertyValues.set(name, value);
|
|
795
|
+
return {
|
|
796
|
+
...options,
|
|
797
|
+
customPropertyValues
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
//#endregion
|
|
801
|
+
//#region src/tailwindcss/v4-engine/generator/engine.ts
|
|
802
|
+
function isCssSyntaxError(error) {
|
|
803
|
+
return error instanceof Error && error.name === "CssSyntaxError";
|
|
804
|
+
}
|
|
805
|
+
function createTailwindV4Engine(source) {
|
|
806
|
+
const generationSessions = new TailwindV4NativeSessionPool();
|
|
807
|
+
const incrementalCacheKeys = /* @__PURE__ */ new Set();
|
|
808
|
+
const validationEngine = (0, _weapp_tailwindcss_engine.createTailwindV4Engine)(source);
|
|
809
|
+
async function generateOnce(generateSource, options = {}) {
|
|
810
|
+
const { scanSources = true, styleOptions, target = "weapp", ...patchOptions } = options;
|
|
811
|
+
const resolvedStyleOptions = resolveStyleOptions(generateSource, styleOptions);
|
|
812
|
+
const compatibleSource = createCompatibleSource(resolveCssMacroTailwindV4Source(generateSource), target);
|
|
813
|
+
const compiledScan = options.scanMode === "compiled";
|
|
814
|
+
const resolvedScanSources = compiledScan ? void 0 : await resolveScanSources(generateSource, scanSources);
|
|
815
|
+
const filesystemCandidates = Array.isArray(resolvedScanSources) ? new Set(await (0, _weapp_tailwindcss_engine.extractRawCandidates)(resolvedScanSources, { ...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues } })) : void 0;
|
|
816
|
+
const resolvedCandidates = resolveTargetCandidates(/* @__PURE__ */ new Set([...collectCandidates(patchOptions.candidates), ...filesystemCandidates ?? []]), target);
|
|
817
|
+
let normalizedCandidates = normalizeTargetRpxLengthCandidates(resolvedCandidates, target, resolvedStyleOptions);
|
|
818
|
+
const sourceId = compatibleSource.dependencies[0] ?? compatibleSource.base;
|
|
819
|
+
const generationRequest = {
|
|
820
|
+
...compiledScan ? {
|
|
821
|
+
scanSources,
|
|
822
|
+
excludeFiles: options.excludeFiles ?? [],
|
|
823
|
+
prepareCandidates: (candidates) => {
|
|
824
|
+
normalizedCandidates = normalizeTargetRpxLengthCandidates(resolveTargetCandidates(candidates, target), target, resolvedStyleOptions);
|
|
825
|
+
return normalizedCandidates.candidates;
|
|
826
|
+
}
|
|
827
|
+
} : {},
|
|
828
|
+
...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues },
|
|
829
|
+
...patchOptions.sources === void 0 ? {} : { sourceEntries: createEngineSourceEntries(patchOptions.sources, sourceId) },
|
|
830
|
+
candidates: compiledScan ? resolvedCandidates : normalizedCandidates.candidates
|
|
831
|
+
};
|
|
832
|
+
let generatedCss;
|
|
833
|
+
let classSet;
|
|
834
|
+
let rawCandidates;
|
|
835
|
+
let dependencies;
|
|
836
|
+
try {
|
|
837
|
+
const artifact = await generationSessions.generate(target, createTailwindV4SourceCacheKey(compatibleSource), compatibleSource, generationRequest);
|
|
838
|
+
generatedCss = serializeTailwindGenerationArtifact(artifact);
|
|
839
|
+
classSet = artifact.classSet;
|
|
840
|
+
rawCandidates = artifact.rawCandidates;
|
|
841
|
+
dependencies = artifact.dependencies;
|
|
842
|
+
} catch (error) {
|
|
843
|
+
if (compiledScan || !isCssSyntaxError(error)) throw error;
|
|
844
|
+
const legacyEngine = (0, _weapp_tailwindcss_engine.createTailwindV4Engine)(compatibleSource);
|
|
845
|
+
try {
|
|
846
|
+
const legacyResult = await legacyEngine.generate({
|
|
847
|
+
...patchOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: patchOptions.bareArbitraryValues },
|
|
848
|
+
...patchOptions.sources === void 0 ? {} : { sources: patchOptions.sources },
|
|
849
|
+
candidates: normalizedCandidates.candidates,
|
|
850
|
+
scanSources: false
|
|
851
|
+
});
|
|
852
|
+
generatedCss = legacyResult.css;
|
|
853
|
+
classSet = legacyResult.classSet;
|
|
854
|
+
rawCandidates = legacyResult.rawCandidates;
|
|
855
|
+
dependencies = legacyResult.dependencies;
|
|
856
|
+
} finally {
|
|
857
|
+
legacyEngine.dispose?.();
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
const sources = Array.isArray(resolvedScanSources) ? resolvedScanSources : [];
|
|
861
|
+
const rawCss = (0, _weapp_tailwindcss_postcss_transform.restoreRpxLengthCssSelectors)(generatedCss, normalizedCandidates.restoreCandidates);
|
|
862
|
+
const css = await transformTailwindV4CssByTarget(rawCss, target, resolveGenerationStyleContext(compatibleSource.css, rawCss, resolvedStyleOptions));
|
|
863
|
+
return {
|
|
864
|
+
classSet: (0, _weapp_tailwindcss_postcss_transform.restoreRpxLengthCandidates)(classSet, normalizedCandidates.restoreCandidates),
|
|
865
|
+
rawCandidates: (0, _weapp_tailwindcss_postcss_transform.restoreRpxLengthCandidates)(rawCandidates, normalizedCandidates.restoreCandidates),
|
|
866
|
+
dependencies,
|
|
867
|
+
root: resolveCompiledSourceRoot(compatibleSource),
|
|
868
|
+
sources,
|
|
869
|
+
css,
|
|
870
|
+
rawCss,
|
|
871
|
+
target
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
async function generateWithIncrementalCache(options = {}) {
|
|
875
|
+
const target = options.target ?? "weapp";
|
|
876
|
+
const cssMacroSource = resolveCssMacroTailwindV4Source(source);
|
|
877
|
+
const compatibleSource = createCompatibleSource(cssMacroSource, target);
|
|
878
|
+
const requestedCandidates = resolveTargetCandidates(options.candidates, target);
|
|
879
|
+
const styleOptions = resolveStyleOptions(source, options.styleOptions);
|
|
880
|
+
if ((options.sources?.length ?? 0) > 0 || options.bareArbitraryValues !== void 0 || Array.isArray(options.scanSources)) return generateOnce(cssMacroSource, options);
|
|
881
|
+
const cacheKey = createIncrementalGenerateCacheKey(compatibleSource, target, styleOptions);
|
|
882
|
+
incrementalCacheKeys.add(cacheKey);
|
|
883
|
+
if (options.scanSources === true) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
884
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
885
|
+
if (!seedIncrementalGenerateCache({
|
|
886
|
+
compatibleSource,
|
|
887
|
+
generated,
|
|
888
|
+
requestedCandidates,
|
|
889
|
+
styleOptions,
|
|
890
|
+
target
|
|
891
|
+
})) incrementalGenerateCache.delete(cacheKey);
|
|
892
|
+
return generated;
|
|
893
|
+
});
|
|
894
|
+
const cached = incrementalGenerateCache.get(cacheKey);
|
|
895
|
+
if (cached) {
|
|
896
|
+
if (hasRemovedCandidates(cached.seenCandidates, requestedCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
897
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
898
|
+
if (!seedIncrementalGenerateCache({
|
|
899
|
+
compatibleSource,
|
|
900
|
+
generated,
|
|
901
|
+
requestedCandidates,
|
|
902
|
+
styleOptions,
|
|
903
|
+
target
|
|
904
|
+
})) incrementalGenerateCache.delete(cacheKey);
|
|
905
|
+
return generated;
|
|
906
|
+
});
|
|
907
|
+
const missingCandidates = [...requestedCandidates].filter((candidate) => !cached.seenCandidates.has(candidate));
|
|
908
|
+
if (missingCandidates.length === 0) return {
|
|
909
|
+
css: cached.css,
|
|
910
|
+
rawCss: cached.rawCss,
|
|
911
|
+
incrementalCss: "",
|
|
912
|
+
incrementalRawCss: "",
|
|
913
|
+
classSet: new Set(cached.classSet),
|
|
914
|
+
rawCandidates: new Set(cached.seenCandidates),
|
|
915
|
+
dependencies: cached.dependencies,
|
|
916
|
+
sources: cached.sources,
|
|
917
|
+
root: cached.root,
|
|
918
|
+
target: cached.target
|
|
919
|
+
};
|
|
920
|
+
if (shouldRebuildIncrementalEntry(cached, requestedCandidates, missingCandidates)) return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
921
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
922
|
+
if (!seedIncrementalGenerateCache({
|
|
923
|
+
compatibleSource,
|
|
924
|
+
generated,
|
|
925
|
+
requestedCandidates,
|
|
926
|
+
styleOptions,
|
|
927
|
+
target
|
|
928
|
+
})) incrementalGenerateCache.delete(cacheKey);
|
|
929
|
+
return generated;
|
|
930
|
+
});
|
|
931
|
+
return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
932
|
+
const designSystem = await cached.designSystemPromise;
|
|
933
|
+
const normalizedMissing = normalizeTargetRpxLengthCandidates(missingCandidates, target, styleOptions);
|
|
934
|
+
const normalizedMissingCandidates = [...normalizedMissing.candidates];
|
|
935
|
+
const cssByCandidate = designSystem.candidatesToCss(normalizedMissingCandidates);
|
|
936
|
+
const rawCssParts = [];
|
|
937
|
+
const classSet = /* @__PURE__ */ new Set();
|
|
938
|
+
for (let index = 0; index < normalizedMissingCandidates.length; index += 1) {
|
|
939
|
+
const candidate = normalizedMissingCandidates[index];
|
|
940
|
+
const css = cssByCandidate[index];
|
|
941
|
+
if (candidate && typeof css === "string" && css.trim().length > 0) {
|
|
942
|
+
rawCssParts.push((0, _weapp_tailwindcss_postcss_transform.restoreRpxLengthCssSelectors)(css, normalizedMissing.restoreCandidates));
|
|
943
|
+
classSet.add(normalizedMissing.restoreCandidates.get(candidate) ?? candidate);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
const rawCss = rawCssParts.join("\n");
|
|
947
|
+
const incrementalCss = rawCss.length > 0 ? await transformTailwindV4CssByTarget(rawCss, target, {
|
|
948
|
+
...createIncrementalStyleOptions(styleOptions),
|
|
949
|
+
customPropertyValues: cached.customPropertyValues
|
|
950
|
+
}) : "";
|
|
951
|
+
for (const candidate of missingCandidates) cached.seenCandidates.add(candidate);
|
|
952
|
+
for (const className of classSet) cached.classSet.add(className);
|
|
953
|
+
cached.css = [cached.css, incrementalCss].filter(Boolean).join("\n");
|
|
954
|
+
cached.rawCss = [cached.rawCss, rawCss].filter(Boolean).join("\n");
|
|
955
|
+
(0, _weapp_tailwindcss_postcss_transform.mergeCustomPropertyValues)(cached.customPropertyValues, incrementalCss);
|
|
956
|
+
return {
|
|
957
|
+
css: cached.css,
|
|
958
|
+
rawCss: cached.rawCss,
|
|
959
|
+
incrementalCss,
|
|
960
|
+
incrementalRawCss: rawCss,
|
|
961
|
+
classSet: new Set(cached.classSet),
|
|
962
|
+
rawCandidates: new Set(cached.seenCandidates),
|
|
963
|
+
dependencies: cached.dependencies,
|
|
964
|
+
sources: cached.sources,
|
|
965
|
+
root: cached.root,
|
|
966
|
+
target: cached.target
|
|
967
|
+
};
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
return runIncrementalGenerateTask(cacheKey, requestedCandidates, options.scanSources, async () => {
|
|
971
|
+
const generated = await generateOnce(cssMacroSource, options);
|
|
972
|
+
seedIncrementalGenerateCache({
|
|
973
|
+
compatibleSource,
|
|
974
|
+
generated,
|
|
975
|
+
requestedCandidates,
|
|
976
|
+
styleOptions,
|
|
977
|
+
target
|
|
978
|
+
});
|
|
979
|
+
return generated;
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
async function generate(options = {}) {
|
|
983
|
+
return options.incrementalCache && options.scanMode !== "compiled" ? generateWithIncrementalCache(options) : generateOnce(source, options);
|
|
984
|
+
}
|
|
985
|
+
return {
|
|
986
|
+
source,
|
|
987
|
+
loadDesignSystem: validationEngine.loadDesignSystem,
|
|
988
|
+
validateCandidates: validationEngine.validateCandidates,
|
|
989
|
+
generate,
|
|
990
|
+
dispose() {
|
|
991
|
+
validationEngine.dispose?.();
|
|
992
|
+
generationSessions.dispose();
|
|
993
|
+
for (const cacheKey of incrementalCacheKeys) incrementalGenerateCache.delete(cacheKey);
|
|
994
|
+
incrementalCacheKeys.clear();
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
//#endregion
|
|
999
|
+
//#region src/utils/options.ts
|
|
1000
|
+
function resolveBooleanObjectOption(value, enabledValue) {
|
|
1001
|
+
if (!value) return false;
|
|
1002
|
+
if (value === true) return enabledValue;
|
|
1003
|
+
return value;
|
|
1004
|
+
}
|
|
1005
|
+
function normalizeStringListOption(value) {
|
|
1006
|
+
if (!value) return;
|
|
1007
|
+
const values = typeof value === "string" ? [value] : Array.isArray(value) ? value : void 0;
|
|
1008
|
+
if (!values) return;
|
|
1009
|
+
const normalized = values.map((entry) => typeof entry === "string" ? entry.trim() : "").filter((entry) => entry.length > 0);
|
|
1010
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
1011
|
+
}
|
|
1012
|
+
//#endregion
|
|
1013
|
+
//#region src/tailwindcss/runtime-options.ts
|
|
1014
|
+
function resolveTailwindcssOptions(options) {
|
|
1015
|
+
return options?.tailwindcss ?? options?.tailwind;
|
|
1016
|
+
}
|
|
1017
|
+
function normalizeExtendLengthUnits(value) {
|
|
1018
|
+
if (value === void 0) return;
|
|
1019
|
+
const resolved = resolveBooleanObjectOption(value, { enabled: true });
|
|
1020
|
+
return resolved && typeof resolved === "object" ? {
|
|
1021
|
+
enabled: true,
|
|
1022
|
+
...resolved
|
|
1023
|
+
} : resolved;
|
|
1024
|
+
}
|
|
1025
|
+
function normalizeTailwindcssRuntimeOptions(options) {
|
|
1026
|
+
return options;
|
|
1027
|
+
}
|
|
1028
|
+
/** 清除可选字段中的 undefined,再交给引擎候选校验与生成契约。 */
|
|
1029
|
+
function resolveRuntimeBareArbitraryValues(options) {
|
|
1030
|
+
const value = resolveTailwindcssOptions(options)?.v4?.bareArbitraryValues;
|
|
1031
|
+
return value && typeof value === "object" ? value.units === void 0 ? {} : { units: value.units } : value;
|
|
1032
|
+
}
|
|
1033
|
+
//#endregion
|
|
1034
|
+
//#region src/utils/object.ts
|
|
1035
|
+
function definedEntries(value) {
|
|
1036
|
+
return Object.entries(value).filter(([, item]) => item !== void 0);
|
|
1037
|
+
}
|
|
1038
|
+
function omitUndefined(value) {
|
|
1039
|
+
return Object.fromEntries(definedEntries(value));
|
|
1040
|
+
}
|
|
1041
|
+
//#endregion
|
|
1042
|
+
//#region src/context/workspace.ts
|
|
1043
|
+
const IGNORED_WORKSPACE_DIRS = /* @__PURE__ */ new Set([
|
|
1044
|
+
"node_modules",
|
|
1045
|
+
".git",
|
|
1046
|
+
".hg",
|
|
1047
|
+
".svn",
|
|
1048
|
+
".turbo",
|
|
1049
|
+
".output",
|
|
1050
|
+
".next",
|
|
1051
|
+
"dist",
|
|
1052
|
+
"build"
|
|
1053
|
+
]);
|
|
1054
|
+
function findWorkspaceRoot(startDir) {
|
|
1055
|
+
if (!startDir) return;
|
|
1056
|
+
let current = node_path.default.resolve(startDir);
|
|
1057
|
+
while (true) {
|
|
1058
|
+
const workspaceFile = node_path.default.join(current, "pnpm-workspace.yaml");
|
|
1059
|
+
if ((0, node_fs.existsSync)(workspaceFile)) return current;
|
|
1060
|
+
const parent = node_path.default.dirname(current);
|
|
1061
|
+
if (parent === current) return;
|
|
1062
|
+
current = parent;
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
function findNearestPackageRoot(startDir) {
|
|
1066
|
+
if (!startDir) return;
|
|
1067
|
+
let current = node_path.default.resolve(startDir);
|
|
1068
|
+
while (true) {
|
|
1069
|
+
const pkgPath = node_path.default.join(current, "package.json");
|
|
1070
|
+
if ((0, node_fs.existsSync)(pkgPath)) return current;
|
|
1071
|
+
const parent = node_path.default.dirname(current);
|
|
1072
|
+
if (parent === current) return;
|
|
1073
|
+
current = parent;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
function findWorkspacePackageDir(rootDir, packageName) {
|
|
1077
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1078
|
+
const queue = [node_path.default.resolve(rootDir)];
|
|
1079
|
+
while (queue.length > 0) {
|
|
1080
|
+
const current = queue.shift();
|
|
1081
|
+
const normalized = node_path.default.normalize(current);
|
|
1082
|
+
if (visited.has(normalized)) continue;
|
|
1083
|
+
visited.add(normalized);
|
|
1084
|
+
try {
|
|
1085
|
+
const pkgPath = node_path.default.join(normalized, "package.json");
|
|
1086
|
+
if ((0, node_fs.existsSync)(pkgPath)) {
|
|
1087
|
+
if (JSON.parse((0, node_fs.readFileSync)(pkgPath, "utf8"))?.name === packageName) return normalized;
|
|
1088
|
+
}
|
|
1089
|
+
} catch {}
|
|
1090
|
+
let entries;
|
|
1091
|
+
try {
|
|
1092
|
+
entries = (0, node_fs.readdirSync)(normalized, { withFileTypes: true });
|
|
1093
|
+
} catch {
|
|
1094
|
+
continue;
|
|
1095
|
+
}
|
|
1096
|
+
for (const entry of entries) {
|
|
1097
|
+
if (!entry.isDirectory() || IGNORED_WORKSPACE_DIRS.has(entry.name) || entry.isSymbolicLink?.()) continue;
|
|
1098
|
+
queue.push(node_path.default.join(normalized, entry.name));
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
//#endregion
|
|
1103
|
+
//#region src/tailwindcss/v4/css-entries.ts
|
|
1104
|
+
const TAILWIND_V4_CSS_ENTRY_RE = /\.css(?:[?#].*)?$/i;
|
|
1105
|
+
function isTailwindV4CssEntry(entry) {
|
|
1106
|
+
return typeof entry === "string" && TAILWIND_V4_CSS_ENTRY_RE.test(entry.trim());
|
|
1107
|
+
}
|
|
1108
|
+
function guessBasedirFromEntries(entries) {
|
|
1109
|
+
if (!entries) return;
|
|
1110
|
+
for (const entry of entries) {
|
|
1111
|
+
if (typeof entry !== "string") continue;
|
|
1112
|
+
const trimmed = entry.trim();
|
|
1113
|
+
if (!trimmed || !node_path.default.isAbsolute(trimmed)) continue;
|
|
1114
|
+
if (!isTailwindV4CssEntry(trimmed)) continue;
|
|
1115
|
+
const entryDir = node_path.default.dirname(trimmed);
|
|
1116
|
+
const resolved = findNearestPackageRoot(entryDir) ?? entryDir;
|
|
1117
|
+
if (resolved) return resolved;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
function normalizeCssEntries(entries, anchor) {
|
|
1121
|
+
if (!entries || entries.length === 0) return;
|
|
1122
|
+
const normalized = /* @__PURE__ */ new Set();
|
|
1123
|
+
for (const entry of entries) {
|
|
1124
|
+
if (typeof entry !== "string") continue;
|
|
1125
|
+
const trimmed = entry.trim();
|
|
1126
|
+
if (trimmed.length === 0) continue;
|
|
1127
|
+
if (!isTailwindV4CssEntry(trimmed)) continue;
|
|
1128
|
+
const resolved = node_path.default.isAbsolute(trimmed) ? node_path.default.normalize(trimmed) : node_path.default.normalize(node_path.default.resolve(anchor, trimmed));
|
|
1129
|
+
normalized.add(resolved);
|
|
1130
|
+
}
|
|
1131
|
+
return normalized.size > 0 ? [...normalized] : void 0;
|
|
1132
|
+
}
|
|
1133
|
+
function isSubPath(parent, child) {
|
|
1134
|
+
if (!parent || !child) return false;
|
|
1135
|
+
const relative = node_path.default.relative(parent, child);
|
|
1136
|
+
return relative === "" || !relative.startsWith("..") && !node_path.default.isAbsolute(relative);
|
|
1137
|
+
}
|
|
1138
|
+
function resolveCssEntryBase(entryDir, options) {
|
|
1139
|
+
const normalizedDir = node_path.default.normalize(entryDir);
|
|
1140
|
+
const { preferredBaseDir, workspaceRoot } = options;
|
|
1141
|
+
if (preferredBaseDir && isSubPath(preferredBaseDir, normalizedDir)) return preferredBaseDir;
|
|
1142
|
+
if (workspaceRoot && isSubPath(workspaceRoot, normalizedDir)) return workspaceRoot;
|
|
1143
|
+
const packageRoot = findNearestPackageRoot(normalizedDir);
|
|
1144
|
+
if (packageRoot) return node_path.default.normalize(packageRoot);
|
|
1145
|
+
return normalizedDir;
|
|
1146
|
+
}
|
|
1147
|
+
function groupCssEntriesByBase(entries, options = {}) {
|
|
1148
|
+
const normalizedOptions = {
|
|
1149
|
+
preferredBaseDir: options.preferredBaseDir ? node_path.default.normalize(options.preferredBaseDir) : void 0,
|
|
1150
|
+
workspaceRoot: options.workspaceRoot ? node_path.default.normalize(options.workspaceRoot) : void 0
|
|
1151
|
+
};
|
|
1152
|
+
const groups = /* @__PURE__ */ new Map();
|
|
1153
|
+
for (const entry of entries) {
|
|
1154
|
+
const baseDir = resolveCssEntryBase(node_path.default.dirname(entry), normalizedOptions);
|
|
1155
|
+
const bucket = groups.get(baseDir);
|
|
1156
|
+
if (bucket) bucket.push(entry);
|
|
1157
|
+
else groups.set(baseDir, [entry]);
|
|
1158
|
+
}
|
|
1159
|
+
return groups;
|
|
1160
|
+
}
|
|
1161
|
+
//#endregion
|
|
1162
|
+
//#region src/tailwindcss/v4/css-sources.ts
|
|
1163
|
+
function hasCssEntriesValue(value) {
|
|
1164
|
+
if (typeof value === "string") return isTailwindV4CssEntry(value);
|
|
1165
|
+
return Array.isArray(value) && value.some(isTailwindV4CssEntry);
|
|
1166
|
+
}
|
|
1167
|
+
function hasCssSourcesValue(value) {
|
|
1168
|
+
return Array.isArray(value) && value.some((source) => {
|
|
1169
|
+
const file = source?.file;
|
|
1170
|
+
return typeof source === "object" && source !== null && typeof file === "string" && isTailwindV4CssEntry(file) && typeof source.css === "string" && source.css.trim().length > 0;
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
function isTailwindV4CssSourceRoot(source) {
|
|
1174
|
+
return typeof source === "object" && source !== null && typeof source.file === "string" && isTailwindV4CssEntry(source.file);
|
|
1175
|
+
}
|
|
1176
|
+
function filterTailwindV4CssSourceRoots(sources) {
|
|
1177
|
+
const filtered = sources?.filter(isTailwindV4CssSourceRoot);
|
|
1178
|
+
return filtered && filtered.length > 0 ? filtered : void 0;
|
|
1179
|
+
}
|
|
1180
|
+
function hasConfiguredTailwindV4CssRoots(options) {
|
|
1181
|
+
return hasCssEntriesValue(options.cssEntries) || hasCssEntriesValue(options.tailwindcss?.v4?.cssEntries) || hasCssEntriesValue(options.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssEntries) || hasCssSourcesValue(options.tailwindcss?.v4?.cssSources) || hasCssSourcesValue(options.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssSources);
|
|
1182
|
+
}
|
|
1183
|
+
function normalizeCssSourceFile(file) {
|
|
1184
|
+
if (!file) return;
|
|
1185
|
+
return node_path.default.isAbsolute(file) ? node_path.default.normalize(file) : file;
|
|
1186
|
+
}
|
|
1187
|
+
function normalizeCssSourceBase(base) {
|
|
1188
|
+
if (!base) return;
|
|
1189
|
+
return node_path.default.resolve(base);
|
|
1190
|
+
}
|
|
1191
|
+
function normalizeDependencies(dependencies) {
|
|
1192
|
+
return dependencies?.map(normalizeCssSourceFile).filter((dependency) => typeof dependency === "string" && dependency.length > 0);
|
|
1193
|
+
}
|
|
1194
|
+
function isSameCssSource(a, b) {
|
|
1195
|
+
return a.css === b.css && normalizeCssSourceBase(a.base) === normalizeCssSourceBase(b.base) && normalizeCssSourceFile(a.file) === normalizeCssSourceFile(b.file) && JSON.stringify(normalizeDependencies(a.dependencies)) === JSON.stringify(normalizeDependencies(b.dependencies));
|
|
1196
|
+
}
|
|
1197
|
+
function upsertTailwindV4CssSource(opts, source) {
|
|
1198
|
+
if (!isTailwindV4CssEntry(source.file)) return false;
|
|
1199
|
+
const normalizedSource = omitUndefined({
|
|
1200
|
+
...source,
|
|
1201
|
+
...source.base === void 0 ? {} : { base: normalizeCssSourceBase(source.base) },
|
|
1202
|
+
...source.file === void 0 ? {} : { file: normalizeCssSourceFile(source.file) },
|
|
1203
|
+
...source.dependencies === void 0 ? {} : { dependencies: normalizeDependencies(source.dependencies) }
|
|
1204
|
+
});
|
|
1205
|
+
const tailwindcss = opts.tailwindcss ?? {};
|
|
1206
|
+
const v4 = tailwindcss.v4 ?? {};
|
|
1207
|
+
const cssSources = [...v4.cssSources ?? []];
|
|
1208
|
+
const sourceFile = normalizeCssSourceFile(normalizedSource.file);
|
|
1209
|
+
const existingIndex = cssSources.findIndex((candidate) => normalizeCssSourceFile(candidate.file) === sourceFile);
|
|
1210
|
+
if (existingIndex >= 0) {
|
|
1211
|
+
const existing = cssSources[existingIndex];
|
|
1212
|
+
if (!existing) {
|
|
1213
|
+
cssSources[existingIndex] = normalizedSource;
|
|
1214
|
+
return true;
|
|
1215
|
+
}
|
|
1216
|
+
const nextSource = {
|
|
1217
|
+
...existing,
|
|
1218
|
+
...normalizedSource
|
|
1219
|
+
};
|
|
1220
|
+
if (isSameCssSource(existing, nextSource)) return false;
|
|
1221
|
+
cssSources[existingIndex] = nextSource;
|
|
1222
|
+
} else cssSources.push(normalizedSource);
|
|
1223
|
+
opts.tailwindcss = {
|
|
1224
|
+
...tailwindcss,
|
|
1225
|
+
v4: {
|
|
1226
|
+
...v4,
|
|
1227
|
+
cssSources
|
|
1228
|
+
}
|
|
1229
|
+
};
|
|
1230
|
+
return true;
|
|
1231
|
+
}
|
|
1232
|
+
function removeTailwindV4CssSource(opts, file) {
|
|
1233
|
+
const tailwindcss = opts.tailwindcss;
|
|
1234
|
+
const v4 = tailwindcss?.v4;
|
|
1235
|
+
const cssSources = v4?.cssSources;
|
|
1236
|
+
if (!cssSources || cssSources.length === 0) return false;
|
|
1237
|
+
const sourceFile = normalizeCssSourceFile(file);
|
|
1238
|
+
const nextCssSources = cssSources.filter((source) => normalizeCssSourceFile(source.file) !== sourceFile);
|
|
1239
|
+
if (nextCssSources.length === cssSources.length) return false;
|
|
1240
|
+
opts.tailwindcss = {
|
|
1241
|
+
...tailwindcss,
|
|
1242
|
+
v4: {
|
|
1243
|
+
...v4,
|
|
1244
|
+
cssSources: nextCssSources
|
|
1245
|
+
}
|
|
1246
|
+
};
|
|
1247
|
+
return true;
|
|
1248
|
+
}
|
|
1249
|
+
//#endregion
|
|
1250
|
+
//#region src/tailwindcss/v4-engine/source.ts
|
|
1251
|
+
const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
1252
|
+
function isCssEntryPoint(file) {
|
|
1253
|
+
return typeof file === "string" && node_path.default.basename(file) === "index.css" && (0, node_fs.existsSync)(file);
|
|
1254
|
+
}
|
|
1255
|
+
function resolvePackageCssEntryPoint(specifier) {
|
|
1256
|
+
try {
|
|
1257
|
+
const resolved = require$1.resolve(specifier);
|
|
1258
|
+
if (isCssEntryPoint(resolved)) return resolved;
|
|
1259
|
+
} catch {}
|
|
1260
|
+
const packageName = specifier.replace(/\/index\.css$/, "");
|
|
1261
|
+
if (packageName !== "tailwindcss") return;
|
|
1262
|
+
try {
|
|
1263
|
+
const packageJson = require$1.resolve(`${packageName}/package.json`);
|
|
1264
|
+
const cssEntry = node_path.default.resolve(node_path.default.dirname(packageJson), "index.css");
|
|
1265
|
+
if (isCssEntryPoint(cssEntry)) return cssEntry;
|
|
1266
|
+
} catch {}
|
|
1267
|
+
try {
|
|
1268
|
+
const packageJson = (0, node_module.createRequire)(require$1.resolve("@weapp-tailwindcss/engine")).resolve("tailwindcss/package.json");
|
|
1269
|
+
const cssEntry = node_path.default.resolve(node_path.default.dirname(packageJson), "index.css");
|
|
1270
|
+
if (isCssEntryPoint(cssEntry)) return cssEntry;
|
|
1271
|
+
} catch {}
|
|
1272
|
+
}
|
|
1273
|
+
function isPostcssPluginImportTarget(value) {
|
|
1274
|
+
if (!value) return false;
|
|
1275
|
+
return value === "@tailwindcss/postcss" || value.includes("/postcss");
|
|
1276
|
+
}
|
|
1277
|
+
function uniqueDefined(values) {
|
|
1278
|
+
return [...new Set(values.filter((value) => typeof value === "string" && value.length > 0))];
|
|
1279
|
+
}
|
|
1280
|
+
function resolveCssImportFile(base, specifier) {
|
|
1281
|
+
const normalizedSpecifier = node_path.default.sep === "\\" ? specifier.replaceAll("/", "\\") : specifier.replaceAll("\\", "/");
|
|
1282
|
+
return node_path.default.resolve(base, normalizedSpecifier);
|
|
1283
|
+
}
|
|
1284
|
+
function getProjectRoot(runtime) {
|
|
1285
|
+
return runtime.options?.projectRoot ?? node_process.default.cwd();
|
|
1286
|
+
}
|
|
1287
|
+
function resolveBase(value, fallback) {
|
|
1288
|
+
return value === void 0 ? fallback : node_path.default.isAbsolute(value) ? node_path.default.resolve(value) : node_path.default.resolve(fallback, value);
|
|
1289
|
+
}
|
|
1290
|
+
function resolveConfigDir(config, projectRoot) {
|
|
1291
|
+
if (!config) return;
|
|
1292
|
+
const configPath = node_path.default.isAbsolute(config) ? config : node_path.default.resolve(projectRoot, config);
|
|
1293
|
+
return node_path.default.dirname(configPath);
|
|
1294
|
+
}
|
|
1295
|
+
function isBarePackageSpecifier(specifier) {
|
|
1296
|
+
return !specifier.startsWith(".") && !specifier.startsWith("/") && !specifier.startsWith("#") && !specifier.includes("\\") && !/^[a-z][a-z\d+.-]*:/i.test(specifier);
|
|
1297
|
+
}
|
|
1298
|
+
function isPackageJsonImportSpecifier(specifier) {
|
|
1299
|
+
return typeof specifier === "string" && specifier.startsWith("#");
|
|
1300
|
+
}
|
|
1301
|
+
function createTailwindV4CssImportSpecifierSet(packageName) {
|
|
1302
|
+
const specifiers = /* @__PURE__ */ new Set(["tailwindcss"]);
|
|
1303
|
+
if (packageName && isBarePackageSpecifier(packageName)) specifiers.add(packageName);
|
|
1304
|
+
return specifiers;
|
|
1305
|
+
}
|
|
1306
|
+
function normalizeTailwindV4CssPackageImports(css, packageName) {
|
|
1307
|
+
if (!css.includes("tailwindcss")) return css;
|
|
1308
|
+
const importSpecifiers = createTailwindV4CssImportSpecifierSet(packageName);
|
|
1309
|
+
return (0, _weapp_tailwindcss_postcss_transform.rewriteCssImportSpecifiers)(css, (specifier) => {
|
|
1310
|
+
return importSpecifiers.has(specifier) ? resolvePackageCssEntryPoint(`${specifier}/index.css`) : void 0;
|
|
1311
|
+
}, {
|
|
1312
|
+
atRuleNames: ["import", "reference"],
|
|
1313
|
+
tolerateInvalidCss: true
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
function normalizeTailwindV4CssSources(cssSources, packageName, projectRoot) {
|
|
1317
|
+
if (!cssSources?.length) return cssSources;
|
|
1318
|
+
let changed = false;
|
|
1319
|
+
const normalizedCssSources = cssSources.map((cssSource) => {
|
|
1320
|
+
const file = typeof cssSource.file === "string" && cssSource.file.length > 0 ? node_path.default.isAbsolute(cssSource.file) ? node_path.default.resolve(cssSource.file) : node_path.default.resolve(projectRoot ?? node_process.default.cwd(), cssSource.file) : void 0;
|
|
1321
|
+
const base = typeof cssSource.base === "string" && cssSource.base.length > 0 ? node_path.default.isAbsolute(cssSource.base) ? node_path.default.resolve(cssSource.base) : node_path.default.resolve(projectRoot ?? node_process.default.cwd(), cssSource.base) : file ? node_path.default.dirname(file) : void 0;
|
|
1322
|
+
if (typeof cssSource.css !== "string") {
|
|
1323
|
+
if (file === cssSource.file && base === cssSource.base) return cssSource;
|
|
1324
|
+
changed = true;
|
|
1325
|
+
return {
|
|
1326
|
+
...cssSource,
|
|
1327
|
+
...base === void 0 ? {} : { base },
|
|
1328
|
+
...file === void 0 ? {} : { file }
|
|
1329
|
+
};
|
|
1330
|
+
}
|
|
1331
|
+
const configBase = base ?? projectRoot ?? node_process.default.cwd();
|
|
1332
|
+
const css = normalizeTailwindV4CssPackageImports((0, _weapp_tailwindcss_postcss_transform.normalizeEmptyTailwindCustomVariants)((0, _weapp_tailwindcss_postcss_transform.normalizeTailwindConfigDirectives)(cssSource.css, configBase)), packageName);
|
|
1333
|
+
if (css === cssSource.css && file === cssSource.file && base === cssSource.base) return cssSource;
|
|
1334
|
+
changed = true;
|
|
1335
|
+
return {
|
|
1336
|
+
...cssSource,
|
|
1337
|
+
css,
|
|
1338
|
+
...base === void 0 ? {} : { base },
|
|
1339
|
+
...file === void 0 ? {} : { file }
|
|
1340
|
+
};
|
|
1341
|
+
});
|
|
1342
|
+
return changed ? normalizedCssSources : cssSources;
|
|
1343
|
+
}
|
|
1344
|
+
function normalizeTailwindV4CssEntrySources(cssEntries, packageName) {
|
|
1345
|
+
if (!cssEntries?.length) return;
|
|
1346
|
+
const remainingCssEntries = [];
|
|
1347
|
+
const cssSources = [];
|
|
1348
|
+
const graphs = /* @__PURE__ */ new Map();
|
|
1349
|
+
const themeVariables = /* @__PURE__ */ new Map();
|
|
1350
|
+
const collectCssGraph = (file, visiting = /* @__PURE__ */ new Set()) => {
|
|
1351
|
+
const normalizedFile = node_path.default.resolve(file);
|
|
1352
|
+
const cached = graphs.get(normalizedFile);
|
|
1353
|
+
if (cached) return cached;
|
|
1354
|
+
const graph = /* @__PURE__ */ new Set([normalizedFile]);
|
|
1355
|
+
graphs.set(normalizedFile, graph);
|
|
1356
|
+
if (visiting.has(normalizedFile) || !(0, node_fs.existsSync)(normalizedFile)) return graph;
|
|
1357
|
+
const nextVisiting = new Set(visiting).add(normalizedFile);
|
|
1358
|
+
let root;
|
|
1359
|
+
try {
|
|
1360
|
+
root = _weapp_tailwindcss_postcss_transform.postcss.parse((0, node_fs.readFileSync)(normalizedFile, "utf8"));
|
|
1361
|
+
} catch {
|
|
1362
|
+
return graph;
|
|
1363
|
+
}
|
|
1364
|
+
themeVariables.set(normalizedFile, (0, _weapp_tailwindcss_postcss_transform.collectRpxThemeVariables)(root));
|
|
1365
|
+
const base = node_path.default.dirname(normalizedFile);
|
|
1366
|
+
root.walkAtRules("import", (rule) => {
|
|
1367
|
+
const parsed = (0, _weapp_tailwindcss_postcss_transform.parseCssImportSpecifier)(rule.params);
|
|
1368
|
+
if (!parsed || !parsed.specifier.startsWith(".")) return;
|
|
1369
|
+
const importedFile = resolveCssImportFile(base, parsed.specifier);
|
|
1370
|
+
const resolved = (node_path.default.extname(importedFile) ? [importedFile] : [
|
|
1371
|
+
importedFile,
|
|
1372
|
+
`${importedFile}.css`,
|
|
1373
|
+
`${importedFile}.pcss`,
|
|
1374
|
+
`${importedFile}.scss`,
|
|
1375
|
+
`${importedFile}.sass`
|
|
1376
|
+
]).find((candidate) => (0, node_fs.existsSync)(candidate));
|
|
1377
|
+
if (!resolved) return;
|
|
1378
|
+
for (const dependency of collectCssGraph(resolved, nextVisiting)) graph.add(dependency);
|
|
1379
|
+
});
|
|
1380
|
+
return graph;
|
|
1381
|
+
};
|
|
1382
|
+
const createCssSource = (file, dependencies) => {
|
|
1383
|
+
const normalizedFile = node_path.default.resolve(file);
|
|
1384
|
+
const base = node_path.default.dirname(normalizedFile);
|
|
1385
|
+
const rawCss = (0, node_fs.readFileSync)(normalizedFile, "utf8");
|
|
1386
|
+
const entrySource = (0, _weapp_tailwindcss_postcss_transform.resolveCssEntrySource)(rawCss, base, { removeConfig: false });
|
|
1387
|
+
const config = entrySource?.config && (0, node_fs.existsSync)(entrySource.config) ? entrySource.config : entrySource?.configRequest && !node_path.default.isAbsolute(entrySource.configRequest) && !isPackageJsonImportSpecifier(entrySource.configRequest) ? node_path.default.resolve(base, entrySource.configRequest) : entrySource?.config;
|
|
1388
|
+
return {
|
|
1389
|
+
file: normalizedFile,
|
|
1390
|
+
base,
|
|
1391
|
+
css: normalizeTailwindV4CssPackageImports((0, _weapp_tailwindcss_postcss_transform.normalizeEmptyTailwindCustomVariants)((0, _weapp_tailwindcss_postcss_transform.normalizeConfigDirective)(rawCss, config)), packageName),
|
|
1392
|
+
dependencies: [...dependencies],
|
|
1393
|
+
rpxThemeVariables: [...new Set([...dependencies].flatMap((dependency) => themeVariables.get(dependency) ?? []))]
|
|
1394
|
+
};
|
|
1395
|
+
};
|
|
1396
|
+
const rootEntries = [];
|
|
1397
|
+
for (const cssEntry of cssEntries) {
|
|
1398
|
+
const normalizedCssEntry = cssEntry.replace(/[?#].*$/, "");
|
|
1399
|
+
const file = node_path.default.resolve(normalizedCssEntry);
|
|
1400
|
+
if (!(0, node_fs.existsSync)(file)) {
|
|
1401
|
+
remainingCssEntries.push(normalizedCssEntry);
|
|
1402
|
+
continue;
|
|
1403
|
+
}
|
|
1404
|
+
rootEntries.push(file);
|
|
1405
|
+
}
|
|
1406
|
+
const entryGraphs = rootEntries.map((entry) => [entry, collectCssGraph(entry)]);
|
|
1407
|
+
const nestedEntries = /* @__PURE__ */ new Set();
|
|
1408
|
+
for (const [entry] of entryGraphs) for (const [otherEntry, otherGraph] of entryGraphs) if (entry !== otherEntry && otherGraph.has(entry)) {
|
|
1409
|
+
nestedEntries.add(entry);
|
|
1410
|
+
break;
|
|
1411
|
+
}
|
|
1412
|
+
const selectedEntries = entryGraphs.filter(([entry]) => !nestedEntries.has(entry));
|
|
1413
|
+
const roots = selectedEntries.length > 0 ? selectedEntries : entryGraphs.slice(0, 1);
|
|
1414
|
+
for (const [rootEntry, dependencies] of roots) cssSources.push(createCssSource(rootEntry, dependencies));
|
|
1415
|
+
return {
|
|
1416
|
+
cssEntries: remainingCssEntries,
|
|
1417
|
+
cssSources
|
|
1418
|
+
};
|
|
1419
|
+
}
|
|
1420
|
+
function normalizeTailwindV4SourceOptions(options) {
|
|
1421
|
+
if (!options) return options;
|
|
1422
|
+
const cssBase = resolveBase(options.base, options.projectRoot ?? options.cwd ?? node_process.default.cwd());
|
|
1423
|
+
const css = options.css === void 0 ? void 0 : normalizeTailwindV4CssPackageImports((0, _weapp_tailwindcss_postcss_transform.normalizeEmptyTailwindCustomVariants)((0, _weapp_tailwindcss_postcss_transform.normalizeTailwindConfigDirectives)(options.css, cssBase)), options.packageName);
|
|
1424
|
+
const entrySources = normalizeTailwindV4CssEntrySources(options.cssEntries, options.packageName);
|
|
1425
|
+
const configuredCssSources = filterTailwindV4CssSourceRoots(options.cssSources);
|
|
1426
|
+
const cssSources = normalizeTailwindV4CssSources(configuredCssSources || entrySources?.cssSources ? [...configuredCssSources ?? [], ...entrySources?.cssSources ?? []] : void 0, options.packageName, options.projectRoot);
|
|
1427
|
+
const cssEntries = entrySources?.cssEntries ?? options.cssEntries;
|
|
1428
|
+
if (css === options.css && cssSources === options.cssSources && cssEntries === options.cssEntries) return options;
|
|
1429
|
+
return {
|
|
1430
|
+
...options,
|
|
1431
|
+
...css === void 0 ? {} : { css },
|
|
1432
|
+
...cssEntries === void 0 ? {} : { cssEntries },
|
|
1433
|
+
...cssSources === void 0 ? {} : { cssSources }
|
|
1434
|
+
};
|
|
1435
|
+
}
|
|
1436
|
+
function resolveTailwindCssImportTarget(runtime) {
|
|
1437
|
+
const configuredPackageName = resolveTailwindcssOptions(runtime.options)?.packageName;
|
|
1438
|
+
if (typeof configuredPackageName === "string" && configuredPackageName.length > 0 && !isPostcssPluginImportTarget(configuredPackageName)) return configuredPackageName;
|
|
1439
|
+
const packageName = runtime.packageInfo?.name;
|
|
1440
|
+
if (typeof packageName === "string" && packageName.length > 0 && !isPostcssPluginImportTarget(packageName)) return packageName;
|
|
1441
|
+
return "tailwindcss";
|
|
1442
|
+
}
|
|
1443
|
+
function readTailwindV4Options(runtime) {
|
|
1444
|
+
return resolveTailwindcssOptions(runtime.options)?.v4 ?? runtime.options?.tailwind?.v4;
|
|
1445
|
+
}
|
|
1446
|
+
function isRawTailwindcssPatchOptions(options) {
|
|
1447
|
+
return Boolean(options && "tailwindcss" in options);
|
|
1448
|
+
}
|
|
1449
|
+
function resolveEngineTailwindV4SourceOptions(runtime) {
|
|
1450
|
+
if (runtime.options) {
|
|
1451
|
+
const projectRoot = getProjectRoot(runtime);
|
|
1452
|
+
const tailwindOptions = resolveTailwindcssOptions(runtime.options);
|
|
1453
|
+
const tailwindV4Options = readTailwindV4Options(runtime);
|
|
1454
|
+
const cwd = resolveBase(tailwindOptions?.cwd, projectRoot);
|
|
1455
|
+
const configuredBase = tailwindV4Options?.configuredBase ?? (isRawTailwindcssPatchOptions(runtime.options) ? tailwindV4Options?.base : void 0);
|
|
1456
|
+
const baseFallbacks = uniqueDefined([
|
|
1457
|
+
configuredBase,
|
|
1458
|
+
cwd,
|
|
1459
|
+
projectRoot,
|
|
1460
|
+
resolveConfigDir(tailwindOptions?.config, projectRoot)
|
|
1461
|
+
]);
|
|
1462
|
+
return {
|
|
1463
|
+
projectRoot,
|
|
1464
|
+
cwd,
|
|
1465
|
+
...configuredBase === void 0 ? {} : { base: configuredBase },
|
|
1466
|
+
baseFallbacks,
|
|
1467
|
+
...tailwindV4Options?.cssSources === void 0 ? {} : { cssSources: tailwindV4Options.cssSources },
|
|
1468
|
+
...tailwindV4Options?.cssEntries === void 0 ? {} : { cssEntries: tailwindV4Options.cssEntries },
|
|
1469
|
+
packageName: resolveTailwindCssImportTarget(runtime)
|
|
1470
|
+
};
|
|
1471
|
+
}
|
|
1472
|
+
return {
|
|
1473
|
+
projectRoot: getProjectRoot(runtime),
|
|
1474
|
+
packageName: resolveTailwindCssImportTarget(runtime)
|
|
1475
|
+
};
|
|
1476
|
+
}
|
|
1477
|
+
function resolveTailwindV4SourceOptionsFromRuntime(runtime) {
|
|
1478
|
+
const tailwindV4Options = readTailwindV4Options(runtime);
|
|
1479
|
+
return normalizeTailwindV4SourceOptions(omitUndefined({
|
|
1480
|
+
...resolveEngineTailwindV4SourceOptions(runtime),
|
|
1481
|
+
sources: tailwindV4Options?.sources
|
|
1482
|
+
}));
|
|
1483
|
+
}
|
|
1484
|
+
async function resolveTailwindV4Source(options) {
|
|
1485
|
+
const normalizedOptions = normalizeTailwindV4SourceOptions(options);
|
|
1486
|
+
const source = await (0, _weapp_tailwindcss_engine.resolveTailwindV4Source)(normalizedOptions);
|
|
1487
|
+
const variables = normalizedOptions?.cssSources?.flatMap((cssSource) => cssSource.rpxThemeVariables ?? []) ?? [];
|
|
1488
|
+
if (variables.length) source.rpxThemeVariables = [...new Set(variables)];
|
|
1489
|
+
return source;
|
|
1490
|
+
}
|
|
1491
|
+
function resolveTailwindV4SourceFromRuntimeOptions(options) {
|
|
1492
|
+
const projectRoot = options?.projectRoot ?? node_process.default.cwd();
|
|
1493
|
+
const tailwindOptions = options?.tailwindcss;
|
|
1494
|
+
const v4Options = tailwindOptions?.v4;
|
|
1495
|
+
return resolveTailwindV4Source({
|
|
1496
|
+
projectRoot,
|
|
1497
|
+
cwd: resolveBase(tailwindOptions?.cwd, projectRoot),
|
|
1498
|
+
packageName: tailwindOptions?.packageName ?? "tailwindcss",
|
|
1499
|
+
...v4Options ?? {}
|
|
1500
|
+
});
|
|
1501
|
+
}
|
|
1502
|
+
async function resolveTailwindV4SourceFromRuntime(runtime) {
|
|
1503
|
+
return resolveTailwindV4Source(resolveTailwindV4SourceOptionsFromRuntime(runtime));
|
|
1504
|
+
}
|
|
1505
|
+
//#endregion
|
|
1506
|
+
//#region src/runtime-branch/create-branch.ts
|
|
1507
|
+
function createRuntimeBranch(base, platformFamily, options) {
|
|
1508
|
+
const { context, tailwindcssVersion } = base;
|
|
1509
|
+
return {
|
|
1510
|
+
tailwindcssVersion,
|
|
1511
|
+
generatorTarget: context.generatorTarget,
|
|
1512
|
+
platformFamily,
|
|
1513
|
+
platform: options.platform,
|
|
1514
|
+
nativeAppPlatform: options.nativeAppPlatform,
|
|
1515
|
+
isTailwindV4: tailwindcssVersion === 4,
|
|
1516
|
+
isWeb: platformFamily === "web",
|
|
1517
|
+
isMiniProgram: platformFamily === "mini-program",
|
|
1518
|
+
isNativeApp: platformFamily === "native-app"
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1521
|
+
//#endregion
|
|
1522
|
+
//#region src/runtime-branch/mini-program.ts
|
|
1523
|
+
function createMiniProgramRuntimeBranch(base) {
|
|
1524
|
+
const { context, uniUtsPlatform } = base;
|
|
1525
|
+
return createRuntimeBranch(base, "mini-program", { platform: typeof context.platform === "string" && context.platform.length > 0 ? context.platform : uniUtsPlatform.isMp ? uniUtsPlatform.normalized : context.platform });
|
|
1526
|
+
}
|
|
1527
|
+
//#endregion
|
|
1528
|
+
//#region src/utils/uni-platform.ts
|
|
1529
|
+
function resolveUniUtsPlatform(value = node_process.default.env["UNI_UTS_PLATFORM"]) {
|
|
1530
|
+
return require_framework.resolveUniUtsPlatform(value);
|
|
1531
|
+
}
|
|
1532
|
+
//#endregion
|
|
1533
|
+
//#region src/runtime-branch/platform.ts
|
|
1534
|
+
function isRuntimeUniAppXEnabled(value) {
|
|
1535
|
+
return value === true || typeof value === "object" && value?.enabled !== false;
|
|
1536
|
+
}
|
|
1537
|
+
function normalizeRuntimeUniUtsPlatform(value) {
|
|
1538
|
+
return typeof value === "object" && value !== null ? value : resolveUniUtsPlatform(value);
|
|
1539
|
+
}
|
|
1540
|
+
function resolveNativeAppPlatform(platform) {
|
|
1541
|
+
if (platform.isAppAndroid) return "android";
|
|
1542
|
+
if (platform.isAppIos) return "ios";
|
|
1543
|
+
if (platform.isAppHarmony) return "harmony";
|
|
1544
|
+
return "unknown";
|
|
1545
|
+
}
|
|
1546
|
+
function resolveExplicitOrEnvPlatform(context, uniUtsPlatform) {
|
|
1547
|
+
if (typeof context.platform === "string" && context.platform.length > 0) return context.platform;
|
|
1548
|
+
return uniUtsPlatform.normalized;
|
|
1549
|
+
}
|
|
1550
|
+
//#endregion
|
|
1551
|
+
//#region src/runtime-branch/native-app.ts
|
|
1552
|
+
function createNativeAppRuntimeBranch(base) {
|
|
1553
|
+
return createRuntimeBranch(base, "native-app", {
|
|
1554
|
+
platform: resolveExplicitOrEnvPlatform(base.context, base.uniUtsPlatform),
|
|
1555
|
+
nativeAppPlatform: resolveNativeAppPlatform(base.uniUtsPlatform)
|
|
1556
|
+
});
|
|
1557
|
+
}
|
|
1558
|
+
//#endregion
|
|
1559
|
+
//#region src/runtime-branch/tailwind-version.ts
|
|
1560
|
+
function resolveTailwindcssBranchVersion(_majorVersion) {
|
|
1561
|
+
return 4;
|
|
1562
|
+
}
|
|
1563
|
+
//#endregion
|
|
1564
|
+
//#region src/runtime-branch/web.ts
|
|
1565
|
+
function createWebRuntimeBranch(base) {
|
|
1566
|
+
return createRuntimeBranch(base, "web", { platform: resolveExplicitOrEnvPlatform(base.context, base.uniUtsPlatform) });
|
|
1567
|
+
}
|
|
1568
|
+
//#endregion
|
|
1569
|
+
//#region src/runtime-branch/index.ts
|
|
1570
|
+
function shouldUseNativeAppBranch(base, uniUtsPlatform) {
|
|
1571
|
+
return base.appType === "uni-app-x" && isRuntimeUniAppXEnabled(base.uniAppX) && uniUtsPlatform.isApp;
|
|
1572
|
+
}
|
|
1573
|
+
function resolveRuntimeBranch(context) {
|
|
1574
|
+
const uniUtsPlatform = normalizeRuntimeUniUtsPlatform(context.uniUtsPlatform);
|
|
1575
|
+
const base = {
|
|
1576
|
+
context,
|
|
1577
|
+
tailwindcssVersion: resolveTailwindcssBranchVersion(context.tailwindcssMajorVersion),
|
|
1578
|
+
uniUtsPlatform
|
|
1579
|
+
};
|
|
1580
|
+
if (context.generatorTarget === "web") return createWebRuntimeBranch(base);
|
|
1581
|
+
if (shouldUseNativeAppBranch(context, uniUtsPlatform)) return createNativeAppRuntimeBranch(base);
|
|
1582
|
+
return createMiniProgramRuntimeBranch(base);
|
|
1583
|
+
}
|
|
1584
|
+
function resolveGeneratorRuntimeBranch(options, context = {}) {
|
|
1585
|
+
return options.branch ?? resolveRuntimeBranch({
|
|
1586
|
+
...context,
|
|
1587
|
+
generatorTarget: options.target
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
function shouldUseMiniProgramCssBranch(branch) {
|
|
1591
|
+
return branch.platformFamily === "mini-program" || branch.platformFamily === "native-app";
|
|
1592
|
+
}
|
|
1593
|
+
function shouldUseNativeAppCssBranch(branch) {
|
|
1594
|
+
return branch.platformFamily === "native-app";
|
|
1595
|
+
}
|
|
1596
|
+
//#endregion
|
|
1597
|
+
//#region src/generator/options.ts
|
|
1598
|
+
function normalizeWeappTailwindcssGeneratorOptions(options, context = {}) {
|
|
1599
|
+
const enabled = options !== false;
|
|
1600
|
+
const objectOptions = enabled ? options : void 0;
|
|
1601
|
+
const target = objectOptions?.target ?? (shouldUseUniAppViteWebViewGeneratorTarget(context.appType, context.platform) ? "web" : inferGeneratorTargetFromEnv());
|
|
1602
|
+
const branch = resolveRuntimeBranch({
|
|
1603
|
+
...context,
|
|
1604
|
+
generatorTarget: target
|
|
1605
|
+
});
|
|
1606
|
+
const hasExplicitTarget = objectOptions !== void 0 && Object.hasOwn(objectOptions, "target");
|
|
1607
|
+
const webCompat = objectOptions?.webCompat ?? (!hasExplicitTarget && branch.isWeb ? true : void 0);
|
|
1608
|
+
if (objectOptions == null) return {
|
|
1609
|
+
enabled,
|
|
1610
|
+
target,
|
|
1611
|
+
branch,
|
|
1612
|
+
webCompat,
|
|
1613
|
+
hmr: { preserveDeletedCss: true },
|
|
1614
|
+
importFallback: false,
|
|
1615
|
+
bareArbitraryValues: void 0
|
|
1616
|
+
};
|
|
1617
|
+
return {
|
|
1618
|
+
enabled,
|
|
1619
|
+
target,
|
|
1620
|
+
branch,
|
|
1621
|
+
config: objectOptions.config,
|
|
1622
|
+
styleOptions: objectOptions.styleOptions,
|
|
1623
|
+
webCompat,
|
|
1624
|
+
hmr: { preserveDeletedCss: objectOptions.hmr?.preserveDeletedCss ?? true },
|
|
1625
|
+
importFallback: objectOptions.importFallback ?? false,
|
|
1626
|
+
bareArbitraryValues: objectOptions.bareArbitraryValues
|
|
1627
|
+
};
|
|
1628
|
+
}
|
|
1629
|
+
//#endregion
|
|
1630
|
+
//#region src/generator/index.ts
|
|
1631
|
+
function createWeappTailwindcssGenerator(source) {
|
|
1632
|
+
return createTailwindV4Engine(source);
|
|
1633
|
+
}
|
|
1634
|
+
async function resolveTailwindSourceFromRuntime(tailwindRuntime) {
|
|
1635
|
+
return resolveTailwindV4SourceFromRuntime(tailwindRuntime);
|
|
1636
|
+
}
|
|
1637
|
+
async function createWeappTailwindcssGeneratorFromRuntime(tailwindRuntime) {
|
|
1638
|
+
return createWeappTailwindcssGenerator(await resolveTailwindSourceFromRuntime(tailwindRuntime));
|
|
1639
|
+
}
|
|
1640
|
+
//#endregion
|
|
1641
|
+
Object.defineProperty(exports, "_defineProperty", {
|
|
1642
|
+
enumerable: true,
|
|
1643
|
+
get: function() {
|
|
1644
|
+
return _defineProperty;
|
|
1645
|
+
}
|
|
1646
|
+
});
|
|
1647
|
+
Object.defineProperty(exports, "createTailwindV4Engine", {
|
|
1648
|
+
enumerable: true,
|
|
1649
|
+
get: function() {
|
|
1650
|
+
return createTailwindV4Engine;
|
|
1651
|
+
}
|
|
1652
|
+
});
|
|
1653
|
+
Object.defineProperty(exports, "createWeappTailwindcssGenerator", {
|
|
1654
|
+
enumerable: true,
|
|
1655
|
+
get: function() {
|
|
1656
|
+
return createWeappTailwindcssGenerator;
|
|
1657
|
+
}
|
|
1658
|
+
});
|
|
1659
|
+
Object.defineProperty(exports, "createWeappTailwindcssGeneratorFromRuntime", {
|
|
1660
|
+
enumerable: true,
|
|
1661
|
+
get: function() {
|
|
1662
|
+
return createWeappTailwindcssGeneratorFromRuntime;
|
|
1663
|
+
}
|
|
1664
|
+
});
|
|
1665
|
+
Object.defineProperty(exports, "filterTailwindV4CssSourceRoots", {
|
|
1666
|
+
enumerable: true,
|
|
1667
|
+
get: function() {
|
|
1668
|
+
return filterTailwindV4CssSourceRoots;
|
|
1669
|
+
}
|
|
1670
|
+
});
|
|
1671
|
+
Object.defineProperty(exports, "filterUnsupportedMiniProgramTailwindV4Candidates", {
|
|
1672
|
+
enumerable: true,
|
|
1673
|
+
get: function() {
|
|
1674
|
+
return filterUnsupportedMiniProgramTailwindV4Candidates;
|
|
1675
|
+
}
|
|
1676
|
+
});
|
|
1677
|
+
Object.defineProperty(exports, "findNearestPackageRoot", {
|
|
1678
|
+
enumerable: true,
|
|
1679
|
+
get: function() {
|
|
1680
|
+
return findNearestPackageRoot;
|
|
1681
|
+
}
|
|
1682
|
+
});
|
|
1683
|
+
Object.defineProperty(exports, "findWorkspacePackageDir", {
|
|
1684
|
+
enumerable: true,
|
|
1685
|
+
get: function() {
|
|
1686
|
+
return findWorkspacePackageDir;
|
|
1687
|
+
}
|
|
1688
|
+
});
|
|
1689
|
+
Object.defineProperty(exports, "findWorkspaceRoot", {
|
|
1690
|
+
enumerable: true,
|
|
1691
|
+
get: function() {
|
|
1692
|
+
return findWorkspaceRoot;
|
|
1693
|
+
}
|
|
1694
|
+
});
|
|
1695
|
+
Object.defineProperty(exports, "getTailwindV4IncrementalGenerateCacheStats", {
|
|
1696
|
+
enumerable: true,
|
|
1697
|
+
get: function() {
|
|
1698
|
+
return getTailwindV4IncrementalGenerateCacheStats;
|
|
1699
|
+
}
|
|
1700
|
+
});
|
|
1701
|
+
Object.defineProperty(exports, "groupCssEntriesByBase", {
|
|
1702
|
+
enumerable: true,
|
|
1703
|
+
get: function() {
|
|
1704
|
+
return groupCssEntriesByBase;
|
|
1705
|
+
}
|
|
1706
|
+
});
|
|
1707
|
+
Object.defineProperty(exports, "guessBasedirFromEntries", {
|
|
1708
|
+
enumerable: true,
|
|
1709
|
+
get: function() {
|
|
1710
|
+
return guessBasedirFromEntries;
|
|
1711
|
+
}
|
|
1712
|
+
});
|
|
1713
|
+
Object.defineProperty(exports, "hasConfiguredTailwindV4CssRoots", {
|
|
1714
|
+
enumerable: true,
|
|
1715
|
+
get: function() {
|
|
1716
|
+
return hasConfiguredTailwindV4CssRoots;
|
|
1717
|
+
}
|
|
1718
|
+
});
|
|
1719
|
+
Object.defineProperty(exports, "isTailwindV4CssEntry", {
|
|
1720
|
+
enumerable: true,
|
|
1721
|
+
get: function() {
|
|
1722
|
+
return isTailwindV4CssEntry;
|
|
1723
|
+
}
|
|
1724
|
+
});
|
|
1725
|
+
Object.defineProperty(exports, "normalizeCssEntries", {
|
|
1726
|
+
enumerable: true,
|
|
1727
|
+
get: function() {
|
|
1728
|
+
return normalizeCssEntries;
|
|
1729
|
+
}
|
|
1730
|
+
});
|
|
1731
|
+
Object.defineProperty(exports, "normalizeExtendLengthUnits", {
|
|
1732
|
+
enumerable: true,
|
|
1733
|
+
get: function() {
|
|
1734
|
+
return normalizeExtendLengthUnits;
|
|
1735
|
+
}
|
|
1736
|
+
});
|
|
1737
|
+
Object.defineProperty(exports, "normalizeStringListOption", {
|
|
1738
|
+
enumerable: true,
|
|
1739
|
+
get: function() {
|
|
1740
|
+
return normalizeStringListOption;
|
|
1741
|
+
}
|
|
1742
|
+
});
|
|
1743
|
+
Object.defineProperty(exports, "normalizeTailwindcssRuntimeOptions", {
|
|
1744
|
+
enumerable: true,
|
|
1745
|
+
get: function() {
|
|
1746
|
+
return normalizeTailwindcssRuntimeOptions;
|
|
1747
|
+
}
|
|
1748
|
+
});
|
|
1749
|
+
Object.defineProperty(exports, "normalizeWeappTailwindcssGeneratorOptions", {
|
|
1750
|
+
enumerable: true,
|
|
1751
|
+
get: function() {
|
|
1752
|
+
return normalizeWeappTailwindcssGeneratorOptions;
|
|
1753
|
+
}
|
|
1754
|
+
});
|
|
1755
|
+
Object.defineProperty(exports, "omitUndefined", {
|
|
1756
|
+
enumerable: true,
|
|
1757
|
+
get: function() {
|
|
1758
|
+
return omitUndefined;
|
|
1759
|
+
}
|
|
1760
|
+
});
|
|
1761
|
+
Object.defineProperty(exports, "removeTailwindV4CssSource", {
|
|
1762
|
+
enumerable: true,
|
|
1763
|
+
get: function() {
|
|
1764
|
+
return removeTailwindV4CssSource;
|
|
1765
|
+
}
|
|
1766
|
+
});
|
|
1767
|
+
Object.defineProperty(exports, "resolveBooleanObjectOption", {
|
|
1768
|
+
enumerable: true,
|
|
1769
|
+
get: function() {
|
|
1770
|
+
return resolveBooleanObjectOption;
|
|
1771
|
+
}
|
|
1772
|
+
});
|
|
1773
|
+
Object.defineProperty(exports, "resolveCssMacroTailwindV4Source", {
|
|
1774
|
+
enumerable: true,
|
|
1775
|
+
get: function() {
|
|
1776
|
+
return resolveCssMacroTailwindV4Source;
|
|
1777
|
+
}
|
|
1778
|
+
});
|
|
1779
|
+
Object.defineProperty(exports, "resolveGeneratorRuntimeBranch", {
|
|
1780
|
+
enumerable: true,
|
|
1781
|
+
get: function() {
|
|
1782
|
+
return resolveGeneratorRuntimeBranch;
|
|
1783
|
+
}
|
|
1784
|
+
});
|
|
1785
|
+
Object.defineProperty(exports, "resolveRuntimeBareArbitraryValues", {
|
|
1786
|
+
enumerable: true,
|
|
1787
|
+
get: function() {
|
|
1788
|
+
return resolveRuntimeBareArbitraryValues;
|
|
1789
|
+
}
|
|
1790
|
+
});
|
|
1791
|
+
Object.defineProperty(exports, "resolveRuntimeBranch", {
|
|
1792
|
+
enumerable: true,
|
|
1793
|
+
get: function() {
|
|
1794
|
+
return resolveRuntimeBranch;
|
|
1795
|
+
}
|
|
1796
|
+
});
|
|
1797
|
+
Object.defineProperty(exports, "resolveTailwindSourceFromRuntime", {
|
|
1798
|
+
enumerable: true,
|
|
1799
|
+
get: function() {
|
|
1800
|
+
return resolveTailwindSourceFromRuntime;
|
|
1801
|
+
}
|
|
1802
|
+
});
|
|
1803
|
+
Object.defineProperty(exports, "resolveTailwindV4Source", {
|
|
1804
|
+
enumerable: true,
|
|
1805
|
+
get: function() {
|
|
1806
|
+
return resolveTailwindV4Source;
|
|
1807
|
+
}
|
|
1808
|
+
});
|
|
1809
|
+
Object.defineProperty(exports, "resolveTailwindV4SourceFromRuntime", {
|
|
1810
|
+
enumerable: true,
|
|
1811
|
+
get: function() {
|
|
1812
|
+
return resolveTailwindV4SourceFromRuntime;
|
|
1813
|
+
}
|
|
1814
|
+
});
|
|
1815
|
+
Object.defineProperty(exports, "resolveTailwindV4SourceFromRuntimeOptions", {
|
|
1816
|
+
enumerable: true,
|
|
1817
|
+
get: function() {
|
|
1818
|
+
return resolveTailwindV4SourceFromRuntimeOptions;
|
|
1819
|
+
}
|
|
1820
|
+
});
|
|
1821
|
+
Object.defineProperty(exports, "resolveTailwindV4SourceOptionsFromRuntime", {
|
|
1822
|
+
enumerable: true,
|
|
1823
|
+
get: function() {
|
|
1824
|
+
return resolveTailwindV4SourceOptionsFromRuntime;
|
|
1825
|
+
}
|
|
1826
|
+
});
|
|
1827
|
+
Object.defineProperty(exports, "resolveTailwindcssOptions", {
|
|
1828
|
+
enumerable: true,
|
|
1829
|
+
get: function() {
|
|
1830
|
+
return resolveTailwindcssOptions;
|
|
1831
|
+
}
|
|
1832
|
+
});
|
|
1833
|
+
Object.defineProperty(exports, "resolveUniUtsPlatform", {
|
|
1834
|
+
enumerable: true,
|
|
1835
|
+
get: function() {
|
|
1836
|
+
return resolveUniUtsPlatform;
|
|
1837
|
+
}
|
|
1838
|
+
});
|
|
1839
|
+
Object.defineProperty(exports, "shouldUseMiniProgramCssBranch", {
|
|
1840
|
+
enumerable: true,
|
|
1841
|
+
get: function() {
|
|
1842
|
+
return shouldUseMiniProgramCssBranch;
|
|
1843
|
+
}
|
|
1844
|
+
});
|
|
1845
|
+
Object.defineProperty(exports, "shouldUseNativeAppCssBranch", {
|
|
1846
|
+
enumerable: true,
|
|
1847
|
+
get: function() {
|
|
1848
|
+
return shouldUseNativeAppCssBranch;
|
|
1849
|
+
}
|
|
1850
|
+
});
|
|
1851
|
+
Object.defineProperty(exports, "shouldUseUniAppWebRpxCompatibility", {
|
|
1852
|
+
enumerable: true,
|
|
1853
|
+
get: function() {
|
|
1854
|
+
return shouldUseUniAppWebRpxCompatibility;
|
|
1855
|
+
}
|
|
1856
|
+
});
|
|
1857
|
+
Object.defineProperty(exports, "transformTailwindV4CssByTarget", {
|
|
1858
|
+
enumerable: true,
|
|
1859
|
+
get: function() {
|
|
1860
|
+
return transformTailwindV4CssByTarget;
|
|
1861
|
+
}
|
|
1862
|
+
});
|
|
1863
|
+
Object.defineProperty(exports, "upsertTailwindV4CssSource", {
|
|
1864
|
+
enumerable: true,
|
|
1865
|
+
get: function() {
|
|
1866
|
+
return upsertTailwindV4CssSource;
|
|
1867
|
+
}
|
|
1868
|
+
});
|