weapp-tailwindcss 5.0.13 → 5.1.1
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/README.en.md +1 -1
- package/README.md +1 -1
- package/dist/auto-Ba6hDrse.mjs +13 -0
- package/dist/auto-DtU6f3X6.js +18 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/class-selectors.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/directives.d.ts +2 -1
- package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +10 -6
- package/dist/bundlers/shared/generator-css/local-imports.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/source-resolver/matching.d.ts +0 -1
- package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +1 -1
- package/dist/bundlers/shared/generator-css/source-resolver/types.d.ts +3 -3
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +2 -2
- package/dist/bundlers/shared/generator-css/types.d.ts +13 -1
- package/dist/bundlers/shared/generator-css/user-css.d.ts +5 -1
- package/dist/bundlers/shared/generator-css/validate.d.ts +1 -0
- package/dist/bundlers/shared/run-tasks.d.ts +1 -0
- package/dist/bundlers/shared/v4-generation-core.d.ts +11 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +1 -1
- package/dist/bundlers/vite/css-memory.d.ts +16 -0
- package/dist/bundlers/vite/generate-bundle/candidates.d.ts +0 -1
- package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/css-assets.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/css-output-helpers.d.ts +39 -0
- package/dist/bundlers/vite/generate-bundle/css-output.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/env-flags.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/final-css-assets.d.ts +13 -0
- package/dist/bundlers/vite/generate-bundle/finalize.d.ts +7 -0
- package/dist/bundlers/vite/generate-bundle/html-processing.d.ts +26 -0
- package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +4 -0
- package/dist/bundlers/vite/generate-bundle/memory-debug.d.ts +21 -18
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/root-style-output.d.ts +6 -0
- package/dist/bundlers/vite/generate-bundle/runtime-linked-source-memory.d.ts +25 -0
- package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +3 -1
- package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/source-candidate-source.d.ts +9 -0
- package/dist/bundlers/vite/generate-bundle/tailwind-v4-css-source.d.ts +9 -0
- package/dist/bundlers/vite/generate-bundle/transform-filter.d.ts +15 -0
- package/dist/bundlers/vite/generate-bundle/types.d.ts +2 -1
- package/dist/bundlers/vite/generate-bundle/vite-css-cache.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle.d.ts +2 -1
- package/dist/bundlers/vite/incremental-runtime-class-set/escaped-candidates.d.ts +1 -0
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +3 -3
- package/dist/bundlers/vite/plugin-cache.d.ts +15 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
- package/dist/bundlers/vite/runtime-class-set.d.ts +5 -4
- package/dist/bundlers/vite/source-candidates/script.d.ts +1 -7
- package/dist/bundlers/vite/source-candidates.d.ts +9 -2
- package/dist/bundlers/vite/source-scan/css-entries.d.ts +2 -6
- package/dist/bundlers/vite/source-scan.d.ts +2 -2
- package/dist/bundlers/vite/uni-app-x-css-options.d.ts +1 -1
- package/dist/bundlers/vite/utils.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +26 -2
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/css-source-resolvers.d.ts +34 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +48 -11
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/js-module-graph.d.ts +37 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +199 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-cache.d.ts +28 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/source-candidate-refresh.d.ts +11 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +4 -2
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +10 -1
- package/dist/bundlers/webpack/shared/css-loader-runtime.d.ts +1 -0
- package/dist/cache/index.d.ts +1 -0
- package/dist/cli/mount-options.d.ts +2 -2
- package/dist/cli.js +138 -444
- package/dist/cli.mjs +134 -440
- package/dist/context/index.d.ts +3 -3
- package/dist/context/style-options.d.ts +5 -1
- package/dist/context/tailwindcss.d.ts +1 -1
- package/dist/{precheck-B0Z8yW7E.js → context-B6hVF7dr.js} +405 -156
- package/dist/{precheck-CRI90iL1.mjs → context-DlpKD7aN.mjs} +377 -141
- package/dist/core.js +15 -12
- package/dist/core.mjs +10 -7
- package/dist/css-macro/index.d.ts +3 -7
- package/dist/css-macro.js +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/{defaults-Bqx18S1f.mjs → defaults-BhE26nSw.mjs} +12 -13
- package/dist/{defaults-C_J_kBpw.js → defaults-CmFBmxsr.js} +11 -18
- package/dist/defaults.d.ts +2 -8
- package/dist/defaults.js +1 -2
- package/dist/defaults.mjs +2 -2
- package/dist/generator/index.d.ts +6 -7
- package/dist/generator/options.d.ts +3 -3
- package/dist/generator/types.d.ts +9 -10
- package/dist/generator-6oMJtTDO.js +170 -0
- package/dist/generator-CjzBK7h-.mjs +123 -0
- package/dist/generator.js +10 -16
- package/dist/generator.mjs +3 -3
- package/dist/{gulp-XT8Jc7lH.js → gulp-BtGq6LP9.js} +49 -87
- package/dist/{gulp-DfOQERcV.mjs → gulp-DNU10Vtc.mjs} +42 -80
- package/dist/gulp.js +1 -1
- package/dist/gulp.mjs +1 -1
- package/dist/{hmr-timing-DQIP_8qP.mjs → hmr-timing-B0KuWDjV.mjs} +1197 -858
- package/dist/{hmr-timing-BMftW7Us.js → hmr-timing-CegXR9O4.js} +1356 -927
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/js/fast-path/oxc.d.ts +4 -0
- package/dist/js/precheck.d.ts +1 -0
- package/dist/postcss.js +3 -4
- package/dist/postcss.mjs +2 -3
- package/dist/presets.js +9 -19
- package/dist/presets.mjs +8 -18
- package/dist/runtime-branch/create-branch.d.ts +2 -0
- package/dist/runtime-branch/generator-target-env.d.ts +4 -0
- package/dist/runtime-branch/index.d.ts +6 -0
- package/dist/runtime-branch/mini-program.d.ts +2 -0
- package/dist/runtime-branch/native-app.d.ts +2 -0
- package/dist/runtime-branch/platform.d.ts +6 -0
- package/dist/runtime-branch/tailwind-version.d.ts +2 -0
- package/dist/runtime-branch/types.d.ts +37 -0
- package/dist/runtime-branch/web.d.ts +2 -0
- package/dist/runtime-branch.d.ts +1 -0
- package/dist/{bundle-state-zQ2MrDdi.mjs → source-candidate-scan-signature-B5af2Ahe.mjs} +187 -17
- package/dist/{bundle-state-CKWeTEhv.js → source-candidate-scan-signature-BKYb9jxa.js} +261 -19
- package/dist/tailwindcss/candidates.d.ts +7 -0
- package/dist/tailwindcss/index.d.ts +2 -2
- package/dist/tailwindcss/runtime/cache.d.ts +6 -6
- package/dist/tailwindcss/runtime-factory.d.ts +12 -0
- package/dist/tailwindcss/runtime-options.d.ts +8 -0
- package/dist/tailwindcss/runtime-types.d.ts +87 -0
- package/dist/tailwindcss/runtime.d.ts +6 -6
- package/dist/tailwindcss/source-scan.d.ts +1 -1
- package/dist/tailwindcss/targets.d.ts +2 -2
- package/dist/tailwindcss/v4/config.d.ts +3 -3
- package/dist/tailwindcss/v4/css-entries.d.ts +1 -0
- package/dist/tailwindcss/v4/css-sources.d.ts +4 -2
- package/dist/tailwindcss/v4/index.d.ts +1 -1
- package/dist/tailwindcss/v4/multi-runtime.d.ts +2 -0
- package/dist/tailwindcss/v4/runtime-factory.d.ts +15 -0
- package/dist/tailwindcss/v4/runtime-options.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/design-system.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/generator/css-compat.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/generator/rpx-candidates.d.ts +3 -3
- package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/generator.d.ts +10 -3
- package/dist/tailwindcss/v4-engine/index.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/miniprogram.d.ts +7 -1
- package/dist/tailwindcss/v4-engine/source.d.ts +15 -7
- package/dist/tailwindcss/v4-engine/types.d.ts +17 -10
- package/dist/tailwindcss/version.d.ts +1 -1
- package/dist/tailwindcss-B5mRo0-M.mjs +1423 -0
- package/dist/tailwindcss-dbrbY4cd.js +1528 -0
- package/dist/{transform-DfcEjsZF.mjs → transform-fRBeuuK-.mjs} +2 -2
- package/dist/{transform-YmrmxuF3.js → transform-vLwZpiTE.js} +17 -17
- package/dist/typedoc.export.d.ts +1 -1
- package/dist/types/index.d.ts +16 -17
- package/dist/types/shared.d.ts +1 -1
- package/dist/types/{typedoc-tailwindcss-patch.d.ts → typedoc-tailwindcss-runtime.d.ts} +4 -10
- package/dist/types/user-defined-options/general.d.ts +5 -3
- package/dist/types/user-defined-options/important.d.ts +2 -2
- package/dist/types/user-defined-options/matcher.d.ts +7 -0
- package/dist/uni-app-x/style-asset.d.ts +1 -0
- package/dist/v4-engine-C3qSwQ-e.mjs +2376 -0
- package/dist/v4-engine-ON_oSLfO.js +2752 -0
- package/dist/{vite-DjI09vVN.mjs → vite-CWRooooa.mjs} +1417 -540
- package/dist/{vite-CXHVsHmX.js → vite-w-RkgaTY.js} +1575 -698
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +5665 -4443
- package/dist/weapp-tw-runtime-classset-loader.js +15 -4
- package/dist/webpack-8PaV1gG3.mjs +2334 -0
- package/dist/webpack-CGgBOx9l.js +2346 -0
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +6 -7
- package/dist/auto-CTp6wE5a.js +0 -33
- package/dist/auto-Cl8_hsG6.mjs +0 -22
- package/dist/bundlers/vite/incremental-runtime-class-set/v3-candidates.d.ts +0 -13
- package/dist/bundlers/vite/source-candidates/tailwind-v3-default-extractor.d.ts +0 -1
- package/dist/context/tailwindcss/rax.d.ts +0 -2
- package/dist/generator-CzpArpCL.js +0 -92
- package/dist/generator-ITLd7PTl.mjs +0 -67
- package/dist/tailwindcss/patcher-options.d.ts +0 -8
- package/dist/tailwindcss/patcher.d.ts +0 -12
- package/dist/tailwindcss/runtime-patch.d.ts +0 -5
- package/dist/tailwindcss/v3-engine/generator/cache-key.d.ts +0 -3
- package/dist/tailwindcss/v3-engine/generator/content.d.ts +0 -10
- package/dist/tailwindcss/v3-engine/generator/runtime-ready.d.ts +0 -2
- package/dist/tailwindcss/v3-engine/generator.d.ts +0 -19
- package/dist/tailwindcss/v3-engine/index.d.ts +0 -4
- package/dist/tailwindcss/v3-engine/miniprogram.d.ts +0 -4
- package/dist/tailwindcss/v3-engine/source.d.ts +0 -5
- package/dist/tailwindcss/v3-engine/types.d.ts +0 -61
- package/dist/tailwindcss/v4/multi-patcher.d.ts +0 -2
- package/dist/tailwindcss/v4/patcher-options.d.ts +0 -2
- package/dist/tailwindcss/v4/patcher.d.ts +0 -15
- package/dist/tailwindcss/v4-engine/tailwind-v3-compatibility.d.ts +0 -1
- package/dist/tailwindcss/v4-engine/tailwind-v3-default-colors.d.ts +0 -1
- package/dist/tailwindcss-DTq3uYBK.mjs +0 -556
- package/dist/tailwindcss-DZEwT3C_.js +0 -613
- package/dist/v3-engine-2rrgylhn.js +0 -4686
- package/dist/v3-engine-C6eJ0YzK.mjs +0 -4272
- package/dist/webpack-BcPpnT90.mjs +0 -1184
- package/dist/webpack-CfkUkMXG.js +0 -1196
- /package/dist/tailwindcss/{patcher-resolve.d.ts → runtime-resolve.d.ts} +0 -0
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-emK7D4bc.js");
|
|
2
|
-
const
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const
|
|
5
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
2
|
+
const require_v4_engine = require("./v4-engine-ON_oSLfO.js");
|
|
3
|
+
const require_generator = require("./generator-6oMJtTDO.js");
|
|
4
|
+
const require_context = require("./context-B6hVF7dr.js");
|
|
5
|
+
const require_tailwindcss = require("./tailwindcss-dbrbY4cd.js");
|
|
6
6
|
let node_fs = require("node:fs");
|
|
7
7
|
let node_path = require("node:path");
|
|
8
8
|
node_path = require_chunk.__toESM(node_path);
|
|
9
9
|
let node_process = require("node:process");
|
|
10
10
|
node_process = require_chunk.__toESM(node_process);
|
|
11
|
-
let
|
|
11
|
+
let _tailwindcss_mangle_engine = require("@tailwindcss-mangle/engine");
|
|
12
12
|
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
13
13
|
let lru_cache = require("lru-cache");
|
|
14
|
-
let tailwindcss_patch = require("tailwindcss-patch");
|
|
15
14
|
let node_fs_promises = require("node:fs/promises");
|
|
16
15
|
let _weapp_core_escape = require("@weapp-core/escape");
|
|
17
16
|
let _weapp_tailwindcss_shared_node = require("@weapp-tailwindcss/shared/node");
|
|
@@ -64,7 +63,7 @@ function createCssTokenSourceMap(sourcesByToken, opts) {
|
|
|
64
63
|
sources: [...sources].map((file) => normalizeSourcePath(file, root)).sort()
|
|
65
64
|
};
|
|
66
65
|
tokenSources.set(token, source);
|
|
67
|
-
const escaped =
|
|
66
|
+
const escaped = require_context.replaceWxml(token, { escapeMap: opts.escapeMap });
|
|
68
67
|
tokenSources.set(escaped, source);
|
|
69
68
|
tokenSources.set(escaped.replaceAll("\\", ""), source);
|
|
70
69
|
}
|
|
@@ -133,13 +132,39 @@ function annotateCssSourceTrace(css, options) {
|
|
|
133
132
|
}
|
|
134
133
|
}
|
|
135
134
|
//#endregion
|
|
135
|
+
//#region src/bundlers/shared/generator-css/class-selectors.ts
|
|
136
|
+
function normalizeCssClassSelector(value) {
|
|
137
|
+
return value.replace(/\\([^\da-f\r\n])/gi, "$1").replace(/\\([\da-f]{1,6})\s?/gi, (_, code) => String.fromCodePoint(Number.parseInt(code, 16)));
|
|
138
|
+
}
|
|
139
|
+
function collectRawSourceClassSelectors(rawSource) {
|
|
140
|
+
const selectors = /* @__PURE__ */ new Set();
|
|
141
|
+
try {
|
|
142
|
+
_weapp_tailwindcss_postcss.postcss.parse(rawSource).walkRules((rule) => {
|
|
143
|
+
for (const selector of rule.selectors ?? [rule.selector]) for (const match of selector.matchAll(/\.((?:\\.|[_a-z\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/gi)) selectors.add(normalizeCssClassSelector(match[1]));
|
|
144
|
+
});
|
|
145
|
+
} catch {}
|
|
146
|
+
return selectors;
|
|
147
|
+
}
|
|
148
|
+
function collectGeneratedRawSourceCandidates(candidates, rawSource, escapeMap) {
|
|
149
|
+
const selectors = collectRawSourceClassSelectors(rawSource);
|
|
150
|
+
if (selectors.size === 0) return /* @__PURE__ */ new Set();
|
|
151
|
+
const matched = /* @__PURE__ */ new Set();
|
|
152
|
+
for (const candidate of candidates) {
|
|
153
|
+
const escaped = normalizeCssClassSelector(require_context.replaceWxml(candidate, { escapeMap }));
|
|
154
|
+
if (selectors.has(candidate) || selectors.has(escaped)) matched.add(candidate);
|
|
155
|
+
}
|
|
156
|
+
return matched;
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
136
159
|
//#region src/bundlers/shared/generator-css/generation-helpers.ts
|
|
137
|
-
function
|
|
160
|
+
function hasMiniProgramTailwindV4PreflightReset(css) {
|
|
161
|
+
return /(?:^|[},])\s*view\s*,\s*text\s*,\s*::after\s*,\s*::before\s*\{[^}]*\bborder\s*:\s*0\s+solid\b/.test(css);
|
|
162
|
+
}
|
|
163
|
+
function finalizeMiniProgramGeneratorCss(css, target, _majorVersion, cssPreflight, options = {}) {
|
|
138
164
|
if (target !== "weapp") return css;
|
|
139
165
|
return (0, _weapp_tailwindcss_postcss.finalizeMiniProgramCss)(css, {
|
|
140
|
-
cssPreflight:
|
|
141
|
-
isTailwindcssV4:
|
|
142
|
-
preservePseudoContentInit: majorVersion === 3,
|
|
166
|
+
cssPreflight: options.injectPreflight !== false && !hasMiniProgramTailwindV4PreflightReset(css) ? cssPreflight : void 0,
|
|
167
|
+
isTailwindcssV4: true,
|
|
143
168
|
tailwindcssV4GradientFallback: options.styleOptions?.cssOptions?.tailwindcssV4GradientFallback ?? options.styleOptions?.tailwindcssV4GradientFallback
|
|
144
169
|
});
|
|
145
170
|
}
|
|
@@ -149,11 +174,6 @@ function shouldInjectMiniProgramPreflightForGeneratorCss(opts, options) {
|
|
|
149
174
|
return require_tailwindcss.isUniAppXEnabled(opts.uniAppX) && Boolean(options.localImports?.trim());
|
|
150
175
|
}
|
|
151
176
|
function mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtime, options) {
|
|
152
|
-
if (options.majorVersion === 3 && !options.isolateCssSource) return new Set([
|
|
153
|
-
...scopedRuntime,
|
|
154
|
-
...runtime,
|
|
155
|
-
...options.currentCssCandidates ?? []
|
|
156
|
-
]);
|
|
157
177
|
if (options.isolateCssSource) {
|
|
158
178
|
if (options.matchedCssSourceFile) return new Set([...scopedRuntime, ...options.currentCssCandidates ?? []]);
|
|
159
179
|
return new Set([...scopedRuntime, ...options.currentCssCandidates ?? []]);
|
|
@@ -161,30 +181,30 @@ function mergeScopedRuntimeWithCurrentRuntime(scopedRuntime, runtime, options) {
|
|
|
161
181
|
if (runtime.size === 0 || !options.cssHandlerOptions.isMainChunk) return scopedRuntime;
|
|
162
182
|
return new Set([...scopedRuntime, ...runtime]);
|
|
163
183
|
}
|
|
164
|
-
function shouldIsolateScopedCssSource(
|
|
184
|
+
function shouldIsolateScopedCssSource(_majorVersion, source, sourceEntries, options) {
|
|
165
185
|
if (options.target !== "weapp") return false;
|
|
166
186
|
if (source.__weappTailwindcssMeta?.isolateCssSource) return true;
|
|
167
187
|
if (source.__weappTailwindcssMeta?.matchedCssSourceFile && (sourceEntries?.length ?? 0) > 0) return true;
|
|
168
188
|
if (sourceEntries?.length === 0) return false;
|
|
169
|
-
return
|
|
189
|
+
return sourceEntries !== void 0 && options.cssHandlerOptions?.isMainChunk !== true;
|
|
170
190
|
}
|
|
171
|
-
function shouldIsolateCurrentTailwindV4CssCandidates(
|
|
172
|
-
return
|
|
191
|
+
function shouldIsolateCurrentTailwindV4CssCandidates(_majorVersion, cssHandlerOptions, options) {
|
|
192
|
+
return !cssHandlerOptions.isMainChunk && require_v4_engine.hasTailwindApplyDirective(options.rawSource) && !require_v4_engine.hasTailwindRootDirectives(options.rawSource) && !options.hasGeneratedCss && !options.hasGeneratedMarkers;
|
|
173
193
|
}
|
|
174
194
|
function shouldScanTailwindV4Sources(majorVersion, target, generatorRuntime, isolateCssSource) {
|
|
175
|
-
if (majorVersion !== 4)
|
|
195
|
+
if (majorVersion !== 4) throw new Error("weapp-tailwindcss 生成管线仅支持 Tailwind CSS v4。");
|
|
176
196
|
if (target === "web") return true;
|
|
177
197
|
if (isolateCssSource) return false;
|
|
178
198
|
return generatorRuntime.size === 0;
|
|
179
199
|
}
|
|
180
|
-
function shouldAppendWebBundleCssFallback(target,
|
|
181
|
-
return target === "web"
|
|
200
|
+
function shouldAppendWebBundleCssFallback(target, _options) {
|
|
201
|
+
return target === "web";
|
|
182
202
|
}
|
|
183
203
|
function isEmptyCssSourceOrderParts(parts) {
|
|
184
204
|
return parts.before.trim().length === 0 && parts.after.trim().length === 0;
|
|
185
205
|
}
|
|
186
206
|
function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOptions) {
|
|
187
|
-
const resolvedStyleOptions =
|
|
207
|
+
const resolvedStyleOptions = require_context.resolveStyleOptionsFromContext(opts);
|
|
188
208
|
const preflightStyleOptions = {
|
|
189
209
|
cssPreflight: resolvedStyleOptions.cssPreflight,
|
|
190
210
|
cssPreflightRange: resolvedStyleOptions.cssPreflightRange
|
|
@@ -208,15 +228,17 @@ function shouldFinalizeMarkedUserLayerComponentsCss(file) {
|
|
|
208
228
|
return !/\.(?:vue|svelte|astro|scss|sass|less|styl)(?:[?#].*)?$/i.test(file);
|
|
209
229
|
}
|
|
210
230
|
function splitRawSourceByGeneratedCssOrder(rawSource, rawTailwindCss) {
|
|
211
|
-
const placeholderParts =
|
|
231
|
+
const placeholderParts = require_v4_engine.splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss);
|
|
212
232
|
if (placeholderParts) return placeholderParts;
|
|
213
|
-
const exactParts =
|
|
233
|
+
const exactParts = require_v4_engine.splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss);
|
|
214
234
|
if (exactParts) return exactParts;
|
|
215
|
-
return
|
|
235
|
+
return require_v4_engine.splitTailwindGeneratedCssByBanner(rawSource);
|
|
216
236
|
}
|
|
217
237
|
function shouldUseGeneratorForCurrentCss(_majorVersion, cssHandlerOptions, options) {
|
|
218
|
-
const hasApplyDirectives =
|
|
219
|
-
|
|
238
|
+
const hasApplyDirectives = require_v4_engine.hasTailwindApplyDirective(options.rawSource);
|
|
239
|
+
const sourceCss = cssHandlerOptions.sourceOptions?.sourceCss;
|
|
240
|
+
const hasSourceCssDirectives = typeof sourceCss === "string" && (require_v4_engine.hasTailwindRootDirectives(sourceCss, { importFallback: true }) || require_v4_engine.hasTailwindSourceDirectives(sourceCss, { importFallback: true }) || require_v4_engine.hasTailwindApplyDirective(sourceCss));
|
|
241
|
+
return options.forceGenerator === true || options.hasGeneratedCss || options.hasGeneratedMarkers || options.hasSourceDirectives || hasApplyDirectives || hasSourceCssDirectives || cssHandlerOptions.isMainChunk && (options.configuredCssSourceCount ?? 0) > 0 || cssHandlerOptions.isMainChunk && options.rawSource.includes("weapp-tailwindcss") || options.target === "web" && cssHandlerOptions.isMainChunk && (options.runtimeCandidateCount ?? 0) > 0;
|
|
220
242
|
}
|
|
221
243
|
function createRuntimeWithCurrentCssCandidates(runtime, currentCssCandidates, isolateCurrentCssCandidates) {
|
|
222
244
|
return isolateCurrentCssCandidates ? new Set(currentCssCandidates) : currentCssCandidates.length > 0 ? new Set([...runtime, ...currentCssCandidates]) : runtime;
|
|
@@ -238,10 +260,6 @@ function mergeGeneratorResults(generatedResults) {
|
|
|
238
260
|
sources: generatedResults.flatMap((item) => item.sources)
|
|
239
261
|
};
|
|
240
262
|
}
|
|
241
|
-
const SUPPORTED_GENERATOR_MAJOR_VERSIONS$1 = new Set([3, 4]);
|
|
242
|
-
function isSupportedGeneratorMajorVersion(majorVersion) {
|
|
243
|
-
return SUPPORTED_GENERATOR_MAJOR_VERSIONS$1.has(majorVersion ?? 0);
|
|
244
|
-
}
|
|
245
263
|
//#endregion
|
|
246
264
|
//#region src/bundlers/shared/generator-css/legacy-selectors.ts
|
|
247
265
|
const CLASS_SELECTOR_RE = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
|
|
@@ -298,7 +316,7 @@ function escapeCompatSelectorClasses(selector) {
|
|
|
298
316
|
end += 1;
|
|
299
317
|
}
|
|
300
318
|
if (className.includes("\\")) {
|
|
301
|
-
result += `.${
|
|
319
|
+
result += `.${require_context.replaceWxml(unescapeSimpleCssIdent(className))}`;
|
|
302
320
|
changed = true;
|
|
303
321
|
} else result += `.${className}`;
|
|
304
322
|
index = end;
|
|
@@ -391,6 +409,21 @@ function collectGeneratedDeclarationPropsBySelector(generatedCss, selectors) {
|
|
|
391
409
|
}
|
|
392
410
|
return propsBySelector;
|
|
393
411
|
}
|
|
412
|
+
function isRuleCoveredByGeneratedProps(rule, generatedDeclarationPropsBySelector) {
|
|
413
|
+
const nodeSelectors = getRuleCompatSelectorKeys(rule);
|
|
414
|
+
if (nodeSelectors.length === 0) return false;
|
|
415
|
+
const props = /* @__PURE__ */ new Set();
|
|
416
|
+
rule.walkDecls((decl) => {
|
|
417
|
+
props.add(decl.prop);
|
|
418
|
+
});
|
|
419
|
+
if (props.size === 0) return false;
|
|
420
|
+
for (const selector of nodeSelectors) {
|
|
421
|
+
const generatedProps = generatedDeclarationPropsBySelector.get(selector);
|
|
422
|
+
if (!generatedProps) continue;
|
|
423
|
+
if ([...props].every((prop) => generatedProps.has(prop))) return true;
|
|
424
|
+
}
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
394
427
|
function removeGeneratedSelectorCompatCss(css, generatedCss) {
|
|
395
428
|
const generatedSelectors = collectGeneratedSelectors(generatedCss);
|
|
396
429
|
if (generatedSelectors.size === 0) return css;
|
|
@@ -431,6 +464,7 @@ function collectDedupedPostTransformCompatCss(css, generatedCss) {
|
|
|
431
464
|
preservedNodes.push(node.clone());
|
|
432
465
|
return;
|
|
433
466
|
}
|
|
467
|
+
if (isRuleCoveredByGeneratedProps(node, generatedDeclarationPropsBySelector)) return;
|
|
434
468
|
if (isCustomPropertyOnlyRule(node) && !isPseudoContentInitRule(node) && !hasUtilityClassSelector(node.selector)) {
|
|
435
469
|
const declarationProps = /* @__PURE__ */ new Set();
|
|
436
470
|
node.walkDecls((decl) => {
|
|
@@ -460,13 +494,23 @@ function collectDedupedPostTransformCompatCss(css, generatedCss) {
|
|
|
460
494
|
}
|
|
461
495
|
}
|
|
462
496
|
function removeDuplicatedViteMarkers(css, baseCss) {
|
|
463
|
-
if (!
|
|
464
|
-
|
|
465
|
-
return css.replace(
|
|
497
|
+
if (!require_v4_engine.VITE_MARKER_RE.test(baseCss)) return css;
|
|
498
|
+
require_v4_engine.VITE_MARKER_RE.lastIndex = 0;
|
|
499
|
+
return css.replace(require_v4_engine.VITE_MARKER_RE, "");
|
|
466
500
|
}
|
|
467
501
|
//#endregion
|
|
468
502
|
//#region src/bundlers/shared/generator-css/source-files.ts
|
|
469
503
|
const SFC_STYLE_BLOCK_RE = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
|
|
504
|
+
const STYLE_IMPORT_EXTENSIONS = [
|
|
505
|
+
".css",
|
|
506
|
+
".scss",
|
|
507
|
+
".sass",
|
|
508
|
+
".less",
|
|
509
|
+
".styl",
|
|
510
|
+
".stylus",
|
|
511
|
+
".pcss",
|
|
512
|
+
".postcss"
|
|
513
|
+
];
|
|
470
514
|
function stripStyleExtension(file) {
|
|
471
515
|
const normalized = file.replace(/[?#].*$/, "");
|
|
472
516
|
const ext = node_path.default.extname(normalized);
|
|
@@ -568,21 +612,77 @@ function extractStyleDirectiveSources(source) {
|
|
|
568
612
|
let match = SFC_STYLE_BLOCK_RE.exec(source);
|
|
569
613
|
while (match !== null) {
|
|
570
614
|
const styleSource = match[1] ?? "";
|
|
571
|
-
if (
|
|
615
|
+
if (require_v4_engine.hasTailwindSourceDirectives(styleSource, { importFallback: true })) styleSources.push(styleSource);
|
|
572
616
|
match = SFC_STYLE_BLOCK_RE.exec(source);
|
|
573
617
|
}
|
|
574
618
|
if (styleSources.length > 0) return styleSources;
|
|
575
|
-
return
|
|
619
|
+
return require_v4_engine.hasTailwindSourceDirectives(source, { importFallback: true }) ? [source] : [];
|
|
620
|
+
}
|
|
621
|
+
function extractSfcStyleSources(source) {
|
|
622
|
+
const styleSources = [];
|
|
623
|
+
SFC_STYLE_BLOCK_RE.lastIndex = 0;
|
|
624
|
+
let match = SFC_STYLE_BLOCK_RE.exec(source);
|
|
625
|
+
while (match !== null) {
|
|
626
|
+
styleSources.push(match[1] ?? "");
|
|
627
|
+
match = SFC_STYLE_BLOCK_RE.exec(source);
|
|
628
|
+
}
|
|
629
|
+
return styleSources;
|
|
630
|
+
}
|
|
631
|
+
function isLocalStyleImportRequest(request) {
|
|
632
|
+
return typeof request === "string" && request.length > 0 && (request.startsWith(".") || request.startsWith("/"));
|
|
633
|
+
}
|
|
634
|
+
function resolveLocalStyleImportFile(request, base) {
|
|
635
|
+
const normalized = (node_path.default.isAbsolute(request) ? request : node_path.default.resolve(base, request)).replace(/[?#].*$/, "");
|
|
636
|
+
if ((0, node_fs.existsSync)(normalized)) return normalized;
|
|
637
|
+
if (node_path.default.extname(normalized)) return;
|
|
638
|
+
for (const extension of STYLE_IMPORT_EXTENSIONS) {
|
|
639
|
+
const candidate = `${normalized}${extension}`;
|
|
640
|
+
if ((0, node_fs.existsSync)(candidate)) return candidate;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
function collectLocalStyleImportFiles(source, base) {
|
|
644
|
+
const files = [];
|
|
645
|
+
const sources = extractSfcStyleSources(source);
|
|
646
|
+
if (sources.length === 0) sources.push(source);
|
|
647
|
+
for (const styleSource of sources) try {
|
|
648
|
+
_weapp_tailwindcss_postcss.postcss.parse(styleSource).walkAtRules("import", (rule) => {
|
|
649
|
+
const request = require_v4_engine.parseImportRequest(rule.params);
|
|
650
|
+
if (!isLocalStyleImportRequest(request)) return;
|
|
651
|
+
const file = request ? resolveLocalStyleImportFile(request, base) : void 0;
|
|
652
|
+
if (file) files.push(file);
|
|
653
|
+
});
|
|
654
|
+
} catch {}
|
|
655
|
+
return files;
|
|
656
|
+
}
|
|
657
|
+
function extractStyleDirectiveSourcesDeep(source, sourceFile, seen) {
|
|
658
|
+
const ownSources = extractStyleDirectiveSources(source);
|
|
659
|
+
if (ownSources.length > 0) return ownSources.map((styleSource) => ({
|
|
660
|
+
source: styleSource,
|
|
661
|
+
file: sourceFile
|
|
662
|
+
}));
|
|
663
|
+
const sources = [];
|
|
664
|
+
const base = node_path.default.dirname(sourceFile);
|
|
665
|
+
for (const importedFile of collectLocalStyleImportFiles(source, base)) {
|
|
666
|
+
const normalizedImportedFile = node_path.default.resolve(importedFile);
|
|
667
|
+
if (seen.has(normalizedImportedFile)) continue;
|
|
668
|
+
seen.add(normalizedImportedFile);
|
|
669
|
+
try {
|
|
670
|
+
const importedSource = (0, node_fs.readFileSync)(normalizedImportedFile, "utf8");
|
|
671
|
+
sources.push(...extractStyleDirectiveSourcesDeep(importedSource, normalizedImportedFile, seen));
|
|
672
|
+
} catch {}
|
|
673
|
+
}
|
|
674
|
+
return sources;
|
|
576
675
|
}
|
|
577
676
|
function resolveSourceSideCssEntrySource(file, sourceOptions, resolveOptions = {}) {
|
|
578
677
|
for (const sourceFile of createSourceStylePathCandidates(file, sourceOptions)) try {
|
|
579
678
|
const source = sourceOptions.sourceFile && node_path.default.resolve(sourceOptions.sourceFile) === node_path.default.resolve(sourceFile) && typeof sourceOptions.sourceCss === "string" ? sourceOptions.sourceCss : (0, node_fs.existsSync)(sourceFile) ? (0, node_fs.readFileSync)(sourceFile, "utf8") : void 0;
|
|
580
679
|
if (source === void 0) continue;
|
|
581
|
-
|
|
582
|
-
|
|
680
|
+
const directiveSources = extractStyleDirectiveSourcesDeep(source, sourceFile, new Set([node_path.default.resolve(sourceFile)]));
|
|
681
|
+
for (const styleSource of directiveSources) {
|
|
682
|
+
const cssEntrySource = require_v4_engine.resolveCssEntrySource(styleSource.source, node_path.default.dirname(styleSource.file), resolveOptions);
|
|
583
683
|
if (cssEntrySource) return {
|
|
584
684
|
...cssEntrySource,
|
|
585
|
-
file:
|
|
685
|
+
file: styleSource.file
|
|
586
686
|
};
|
|
587
687
|
}
|
|
588
688
|
} catch {
|
|
@@ -592,14 +692,40 @@ function resolveSourceSideCssEntrySource(file, sourceOptions, resolveOptions = {
|
|
|
592
692
|
//#endregion
|
|
593
693
|
//#region src/bundlers/shared/generator-css/source-resolver/apply-reference.ts
|
|
594
694
|
function createTailwindV4ApplyReferenceSource(css, sourceOptions) {
|
|
595
|
-
|
|
596
|
-
|
|
695
|
+
return createTailwindV4SourceReferenceSource(css, sourceOptions);
|
|
696
|
+
}
|
|
697
|
+
function createTailwindV4SourceReferenceSource(css, sourceOptions) {
|
|
698
|
+
if (hasTailwindV4RootImport(css, sourceOptions)) return css;
|
|
699
|
+
const hasApplyDirective = require_v4_engine.hasTailwindApplyDirective(css);
|
|
700
|
+
if (!hasApplyDirective && !require_v4_engine.hasTailwindSourceDirectives(css, { importFallback: true })) return css;
|
|
701
|
+
const utilities = hasApplyDirective ? collectTailwindApplyUtilities(css) : [];
|
|
597
702
|
return [
|
|
598
703
|
`@import "${sourceOptions.packageName ?? "tailwindcss"}" source(none);`,
|
|
599
704
|
utilities.length > 0 ? `@source inline(${JSON.stringify(utilities.join(" "))});` : void 0,
|
|
600
705
|
css
|
|
601
706
|
].filter(Boolean).join("\n");
|
|
602
707
|
}
|
|
708
|
+
function hasTailwindV4RootImport(css, sourceOptions) {
|
|
709
|
+
try {
|
|
710
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
711
|
+
let found = false;
|
|
712
|
+
root.walkAtRules((rule) => {
|
|
713
|
+
if (rule.name === "tailwind") {
|
|
714
|
+
found = true;
|
|
715
|
+
return false;
|
|
716
|
+
}
|
|
717
|
+
if (rule.name !== "import" && rule.name !== "use" && rule.name !== "forward") return;
|
|
718
|
+
const request = require_v4_engine.parseImportRequest(rule.params);
|
|
719
|
+
if (request === (sourceOptions.packageName ?? "tailwindcss") || request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/")) {
|
|
720
|
+
found = true;
|
|
721
|
+
return false;
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
return found;
|
|
725
|
+
} catch {
|
|
726
|
+
return /@(?:import|use|forward|tailwind)(?:[\s"'(;]|$)/.test(css) && (css.includes("tailwindcss") || css.includes("tailwindcss4") || css.includes("weapp-tailwindcss"));
|
|
727
|
+
}
|
|
728
|
+
}
|
|
603
729
|
function collectTailwindApplyUtilities(css) {
|
|
604
730
|
let root;
|
|
605
731
|
try {
|
|
@@ -609,7 +735,7 @@ function collectTailwindApplyUtilities(css) {
|
|
|
609
735
|
}
|
|
610
736
|
const utilities = /* @__PURE__ */ new Set();
|
|
611
737
|
root.walkAtRules("apply", (rule) => {
|
|
612
|
-
for (const utility of (0,
|
|
738
|
+
for (const utility of (0, _tailwindcss_mangle_engine.splitCandidateTokens)(rule.params)) utilities.add(utility);
|
|
613
739
|
});
|
|
614
740
|
return [...utilities].sort();
|
|
615
741
|
}
|
|
@@ -644,11 +770,7 @@ function resolveExistingConfigPath(config, configRequest, file, sourceOptions) {
|
|
|
644
770
|
//#endregion
|
|
645
771
|
//#region src/bundlers/shared/generator-css/source-resolver/matching.ts
|
|
646
772
|
function normalizeCssSourceForCompare(css) {
|
|
647
|
-
return
|
|
648
|
-
}
|
|
649
|
-
function getOutputFileStem(file) {
|
|
650
|
-
const normalized = file.replace(/[?#].*$/, "");
|
|
651
|
-
return node_path.default.basename(normalized, node_path.default.extname(normalized));
|
|
773
|
+
return require_v4_engine.stripGeneratorPlaceholderMarkers(require_v4_engine.stripTailwindBanners(css)).trim();
|
|
652
774
|
}
|
|
653
775
|
function getOutputFileWithoutExtension(file) {
|
|
654
776
|
const normalized = file.replace(/[?#].*$/, "");
|
|
@@ -658,6 +780,12 @@ function getOutputFileWithoutExtension(file) {
|
|
|
658
780
|
function normalizeMatchPath(file) {
|
|
659
781
|
return file.split(node_path.default.sep).join("/");
|
|
660
782
|
}
|
|
783
|
+
function stripBundlerContentHash(name) {
|
|
784
|
+
return name.replace(/[._-]?[a-f0-9]{6,32}$/i, "");
|
|
785
|
+
}
|
|
786
|
+
function getMatchBasename(file) {
|
|
787
|
+
return stripBundlerContentHash(node_path.default.basename(getOutputFileWithoutExtension(file.replace(/[?#].*$/, ""))));
|
|
788
|
+
}
|
|
661
789
|
function isPathWithinRoot(file, root) {
|
|
662
790
|
const relative = node_path.default.relative(root, file);
|
|
663
791
|
return Boolean(relative) && !relative.startsWith("..") && !node_path.default.isAbsolute(relative);
|
|
@@ -667,11 +795,7 @@ function collectCssSourceMatchBases(file, roots) {
|
|
|
667
795
|
const bases = /* @__PURE__ */ new Set();
|
|
668
796
|
const addBase = (candidate) => {
|
|
669
797
|
const base = normalizeMatchPath(getOutputFileWithoutExtension(candidate));
|
|
670
|
-
if (base.length > 0)
|
|
671
|
-
bases.add(base);
|
|
672
|
-
const withoutWorkspaceSegment = base.replace(/^(?:src|dist)\//, "");
|
|
673
|
-
if (withoutWorkspaceSegment !== base && withoutWorkspaceSegment.length > 0) bases.add(withoutWorkspaceSegment);
|
|
674
|
-
}
|
|
798
|
+
if (base.length > 0) bases.add(base);
|
|
675
799
|
};
|
|
676
800
|
addBase(normalizedFile);
|
|
677
801
|
const resolvedRoots = roots.filter((root) => typeof root === "string" && root.length > 0).map((root) => node_path.default.resolve(root));
|
|
@@ -687,10 +811,13 @@ function scoreTailwindV4CssSourceFileMatch(file, cssSourceFile, sourceOptions) {
|
|
|
687
811
|
sourceOptions.cwd
|
|
688
812
|
]);
|
|
689
813
|
const sourceBases = collectCssSourceMatchBases(cssSourceFile, [sourceOptions.projectRoot, sourceOptions.cwd]);
|
|
814
|
+
const outputBasename = getMatchBasename(file);
|
|
815
|
+
const sourceBasename = getMatchBasename(cssSourceFile);
|
|
690
816
|
let bestScore = 0;
|
|
691
817
|
for (const outputBase of outputBases) for (const sourceBase of sourceBases) if (outputBase === sourceBase) bestScore = Math.max(bestScore, 1e5 + outputBase.length);
|
|
692
818
|
else if (outputBase.endsWith(`/${sourceBase}`)) bestScore = Math.max(bestScore, 5e4 + sourceBase.length);
|
|
693
819
|
else if (sourceBase.endsWith(`/${outputBase}`)) bestScore = Math.max(bestScore, 1e3 + outputBase.length);
|
|
820
|
+
if (outputBasename && outputBasename === sourceBasename) bestScore = Math.max(bestScore, 100 + outputBasename.length);
|
|
694
821
|
return bestScore;
|
|
695
822
|
}
|
|
696
823
|
//#endregion
|
|
@@ -734,12 +861,16 @@ function createCssEntrySources(cssEntries) {
|
|
|
734
861
|
}
|
|
735
862
|
function mergeCssSources(cssSources, cssEntrySources) {
|
|
736
863
|
const merged = [];
|
|
737
|
-
const
|
|
864
|
+
const fileIndex = /* @__PURE__ */ new Map();
|
|
738
865
|
const addSource = (cssSource) => {
|
|
739
866
|
const file = typeof cssSource.file === "string" && cssSource.file.length > 0 ? node_path.default.resolve(cssSource.file) : void 0;
|
|
740
867
|
if (file) {
|
|
741
|
-
|
|
742
|
-
|
|
868
|
+
const previousIndex = fileIndex.get(file);
|
|
869
|
+
if (previousIndex !== void 0) {
|
|
870
|
+
if (typeof merged[previousIndex]?.css !== "string" && typeof cssSource.css === "string") merged[previousIndex] = cssSource;
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
fileIndex.set(file, merged.length);
|
|
743
874
|
}
|
|
744
875
|
merged.push(cssSource);
|
|
745
876
|
};
|
|
@@ -748,7 +879,7 @@ function mergeCssSources(cssSources, cssEntrySources) {
|
|
|
748
879
|
return merged.length > 0 ? merged : void 0;
|
|
749
880
|
}
|
|
750
881
|
function createSingleTailwindV4SourceOptions(sourceOptions, options) {
|
|
751
|
-
return
|
|
882
|
+
return require_v4_engine.omitUndefined({
|
|
752
883
|
projectRoot: sourceOptions.projectRoot,
|
|
753
884
|
baseFallbacks: sourceOptions.baseFallbacks,
|
|
754
885
|
packageName: sourceOptions.packageName,
|
|
@@ -758,21 +889,21 @@ function createSingleTailwindV4SourceOptions(sourceOptions, options) {
|
|
|
758
889
|
}
|
|
759
890
|
async function resolveTailwindV4CssEntrySource(cssEntry, sourceOptions) {
|
|
760
891
|
const { cssEntries: _cssEntries, cssSources: _cssSources, ...singleEntrySourceOptions } = sourceOptions;
|
|
761
|
-
if (!(0, node_fs.existsSync)(cssEntry)) return
|
|
762
|
-
...
|
|
892
|
+
if (!(0, node_fs.existsSync)(cssEntry)) return require_v4_engine.resolveTailwindV4Source({
|
|
893
|
+
...require_v4_engine.omitUndefined(singleEntrySourceOptions),
|
|
763
894
|
cssEntries: [cssEntry]
|
|
764
895
|
});
|
|
765
896
|
const css = (0, node_fs.readFileSync)(cssEntry, "utf8");
|
|
766
897
|
const base = node_path.default.dirname(node_path.default.resolve(cssEntry));
|
|
767
|
-
const entrySource =
|
|
898
|
+
const entrySource = require_v4_engine.resolveCssEntrySource(css, base, { removeConfig: false });
|
|
768
899
|
const config = resolveExistingConfigPath(entrySource?.config, entrySource?.configRequest, cssEntry, {
|
|
769
900
|
...sourceOptions,
|
|
770
901
|
sourceFile: sourceOptions.sourceFile ?? cssEntry
|
|
771
902
|
});
|
|
772
|
-
return withGeneratorSourceMetadata(await
|
|
773
|
-
...
|
|
903
|
+
return withGeneratorSourceMetadata(await require_v4_engine.resolveTailwindV4Source({
|
|
904
|
+
...require_v4_engine.omitUndefined(singleEntrySourceOptions),
|
|
774
905
|
base,
|
|
775
|
-
css:
|
|
906
|
+
css: require_v4_engine.normalizeConfigDirective(css, config),
|
|
776
907
|
cssEntries: [cssEntry]
|
|
777
908
|
}), {
|
|
778
909
|
matchedCssSourceFile: cssEntry,
|
|
@@ -786,19 +917,15 @@ function canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) {
|
|
|
786
917
|
return true;
|
|
787
918
|
}
|
|
788
919
|
function shouldResolveSourceSideCssEntry(rawSource) {
|
|
789
|
-
return rawSource.includes("@apply") ||
|
|
790
|
-
}
|
|
791
|
-
function shouldPreferTailwindV3SourceSideEntry(rawSource, sourceSideEntrySource) {
|
|
792
|
-
return Boolean(sourceSideEntrySource) && !require_v3_engine.hasTailwindSourceDirectives(rawSource, { importFallback: true });
|
|
793
|
-
}
|
|
794
|
-
function shouldPreferResolvedSourceSideEntry(cssEntrySource, sourceSideEntrySource) {
|
|
795
|
-
return Boolean(sourceSideEntrySource?.config) && (Boolean(cssEntrySource?.configRequest) || !cssEntrySource?.config) && (!cssEntrySource?.config || !(0, node_fs.existsSync)(cssEntrySource.config));
|
|
920
|
+
return rawSource.includes("@apply") || require_v4_engine.hasTailwindRootDirectives(rawSource, { importFallback: true }) || require_v4_engine.hasTailwindSourceDirectives(rawSource, { importFallback: true }) || require_v4_engine.hasTailwindGeneratedCss(rawSource) || require_v4_engine.hasTailwindGeneratedCssMarkers(rawSource);
|
|
796
921
|
}
|
|
797
922
|
function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
|
|
798
923
|
const cssEntries = sourceOptions.cssEntries;
|
|
799
924
|
if (!cssEntries?.length) return;
|
|
925
|
+
const normalizedFile = node_path.default.resolve(file.replace(/[?#].*$/, ""));
|
|
926
|
+
const pathMatchedEntries = cssEntries.filter((cssEntry) => node_path.default.resolve(cssEntry.replace(/[?#].*$/, "")) === normalizedFile);
|
|
927
|
+
if (pathMatchedEntries.length === 1) return resolveTailwindV4CssEntrySource(pathMatchedEntries[0], sourceOptions);
|
|
800
928
|
const normalizedRawSource = normalizeCssSourceForCompare(rawSource);
|
|
801
|
-
const outputStem = getOutputFileStem(file);
|
|
802
929
|
const matches = cssEntries.map((cssEntry) => {
|
|
803
930
|
if (!(0, node_fs.existsSync)(cssEntry)) return;
|
|
804
931
|
try {
|
|
@@ -808,14 +935,6 @@ function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
|
|
|
808
935
|
cssEntry,
|
|
809
936
|
score: 1e6 + pathScore
|
|
810
937
|
};
|
|
811
|
-
if (pathScore > 0) return {
|
|
812
|
-
cssEntry,
|
|
813
|
-
score: pathScore
|
|
814
|
-
};
|
|
815
|
-
if (cssEntries.length === 1 && outputStem.length > 0 && getOutputFileStem(cssEntry) === outputStem) return {
|
|
816
|
-
cssEntry,
|
|
817
|
-
score: 1
|
|
818
|
-
};
|
|
819
938
|
return;
|
|
820
939
|
} catch {
|
|
821
940
|
return;
|
|
@@ -828,11 +947,23 @@ function resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) {
|
|
|
828
947
|
}
|
|
829
948
|
function normalizeTailwindV4CssSourceConfig(cssSource, sourceBase) {
|
|
830
949
|
if (typeof cssSource.css !== "string" || cssSource.css.length === 0 || !cssSource.css.includes("@config")) return cssSource;
|
|
831
|
-
const entrySource =
|
|
950
|
+
const entrySource = require_v4_engine.resolveCssEntrySource(cssSource.css, sourceBase, { removeConfig: false });
|
|
832
951
|
if (!entrySource?.config) return cssSource;
|
|
833
952
|
return {
|
|
834
953
|
...cssSource,
|
|
835
|
-
css:
|
|
954
|
+
css: require_v4_engine.normalizeConfigDirective(cssSource.css, entrySource.config)
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
function normalizeResolvedTailwindV4SourceConfig(source, file, sourceOptions) {
|
|
958
|
+
if (!("css" in source) || typeof source.css !== "string" || !source.css.includes("@config")) return source;
|
|
959
|
+
const sourceFile = typeof file === "string" && file.length > 0 ? file : source.__weappTailwindcssMeta?.matchedCssSourceFile;
|
|
960
|
+
if (!sourceFile) return source;
|
|
961
|
+
const entrySource = require_v4_engine.resolveCssEntrySource(source.css, node_path.default.dirname(node_path.default.resolve(sourceFile)), { removeConfig: false });
|
|
962
|
+
const config = resolveExistingConfigPath(entrySource?.config, entrySource?.configRequest, sourceFile, sourceOptions ?? {});
|
|
963
|
+
const normalizedCss = require_v4_engine.normalizeConfigDirective(source.css, config);
|
|
964
|
+
return normalizedCss === source.css ? source : {
|
|
965
|
+
...source,
|
|
966
|
+
css: normalizedCss
|
|
836
967
|
};
|
|
837
968
|
}
|
|
838
969
|
function hydrateTailwindV4CssSource(cssSource) {
|
|
@@ -853,7 +984,7 @@ function normalizeTailwindV4CssSourceConfigs(sourceOptions) {
|
|
|
853
984
|
let changed = false;
|
|
854
985
|
const cssSources = sourceOptions.cssSources.map((cssSource) => {
|
|
855
986
|
const hydratedCssSource = hydrateTailwindV4CssSource(cssSource);
|
|
856
|
-
const normalizedCssSource = normalizeTailwindV4CssSourceConfig(hydratedCssSource,
|
|
987
|
+
const normalizedCssSource = normalizeTailwindV4CssSourceConfig(hydratedCssSource, require_v4_engine.resolveTailwindV4CssSourceBase(hydratedCssSource, sourceBaseFallback));
|
|
857
988
|
changed || (changed = normalizedCssSource !== cssSource);
|
|
858
989
|
return normalizedCssSource;
|
|
859
990
|
});
|
|
@@ -874,18 +1005,10 @@ async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOpt
|
|
|
874
1005
|
index,
|
|
875
1006
|
score: 1e6
|
|
876
1007
|
};
|
|
877
|
-
if (typeof cssSource.file === "string") {
|
|
878
|
-
const pathScore = scoreTailwindV4CssSourceFileMatch(file, cssSource.file, sourceOptions);
|
|
879
|
-
if (pathScore > 0) return {
|
|
880
|
-
cssSource,
|
|
881
|
-
index,
|
|
882
|
-
score: pathScore
|
|
883
|
-
};
|
|
884
|
-
}
|
|
885
1008
|
if (normalizeCssSourceForCompare(cssSource.css) === normalizedRawSource) return {
|
|
886
1009
|
cssSource,
|
|
887
1010
|
index,
|
|
888
|
-
score: 1
|
|
1011
|
+
score: 1 + (typeof cssSource.file === "string" ? scoreTailwindV4CssSourceFileMatch(file, cssSource.file, sourceOptions) : 0)
|
|
889
1012
|
};
|
|
890
1013
|
}).filter((match) => Boolean(match)).sort((a, b) => b.score - a.score || a.index - b.index);
|
|
891
1014
|
const bestScore = matches[0]?.score;
|
|
@@ -895,7 +1018,7 @@ async function resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOpt
|
|
|
895
1018
|
}
|
|
896
1019
|
function tryResolveTailwindV4SourceOptions(runtimeState) {
|
|
897
1020
|
try {
|
|
898
|
-
return
|
|
1021
|
+
return require_v4_engine.resolveTailwindV4SourceOptionsFromRuntime(runtimeState.tailwindRuntime);
|
|
899
1022
|
} catch {
|
|
900
1023
|
return;
|
|
901
1024
|
}
|
|
@@ -904,12 +1027,12 @@ function hasConfiguredTailwindV4CssSource(sourceOptions) {
|
|
|
904
1027
|
return Boolean(sourceOptions?.css) || Boolean(sourceOptions?.cssSources?.length);
|
|
905
1028
|
}
|
|
906
1029
|
async function resolveSingleTailwindV4CssSource(cssSource, sourceOptions, options = {}) {
|
|
907
|
-
const sourceBase =
|
|
1030
|
+
const sourceBase = require_v4_engine.resolveTailwindV4CssSourceBase(cssSource, sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd());
|
|
908
1031
|
const normalizedCssSource = normalizeTailwindV4CssSourceConfig(cssSource, sourceBase);
|
|
909
|
-
return withGeneratorSourceMetadata(await
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
}), {
|
|
1032
|
+
return withGeneratorSourceMetadata(await require_v4_engine.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(sourceOptions, {
|
|
1033
|
+
base: sourceBase,
|
|
1034
|
+
css: normalizedCssSource.css
|
|
1035
|
+
})), {
|
|
913
1036
|
matchedCssSourceFile: options.matched && typeof normalizedCssSource.file === "string" ? normalizedCssSource.file : void 0,
|
|
914
1037
|
sourceBase,
|
|
915
1038
|
sourceCss: normalizedCssSource.css
|
|
@@ -917,8 +1040,8 @@ async function resolveSingleTailwindV4CssSource(cssSource, sourceOptions, option
|
|
|
917
1040
|
}
|
|
918
1041
|
async function resolveTailwindV4CssSourceEntries(cssSource, sourceOptions) {
|
|
919
1042
|
if (typeof cssSource.css !== "string" || cssSource.css.length === 0) return;
|
|
920
|
-
const sourceBase =
|
|
921
|
-
return
|
|
1043
|
+
const sourceBase = require_v4_engine.resolveTailwindV4CssSourceBase(cssSource, sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd());
|
|
1044
|
+
return require_tailwindcss.resolveTailwindV4EntriesFromCss(cssSource.css, sourceBase);
|
|
922
1045
|
}
|
|
923
1046
|
function countRuntimeCandidateHits(candidates, runtime) {
|
|
924
1047
|
if (!runtime?.size) return 0;
|
|
@@ -955,74 +1078,34 @@ async function resolveCandidateMatchedTailwindV4CssSource(_rawSource, _cssHandle
|
|
|
955
1078
|
function createTailwindV4CssSourceResolver(sourceOptions, generatorOptions) {
|
|
956
1079
|
return (cssSource) => resolveSingleTailwindV4CssSource(cssSource, sourceOptions).then((source) => generatorOptions?.config ? {
|
|
957
1080
|
...source,
|
|
958
|
-
css:
|
|
1081
|
+
css: require_v4_engine.prependConfigDirective(source.css, generatorOptions.config)
|
|
959
1082
|
} : source);
|
|
960
1083
|
}
|
|
961
1084
|
async function resolveTailwindV4SourceSideEntrySource(resolvedEntrySource, sourceOptions, generatorOptions, file) {
|
|
962
1085
|
if (!resolvedEntrySource) return;
|
|
963
|
-
const resolvedSourceOptions =
|
|
1086
|
+
const resolvedSourceOptions = require_v4_engine.omitUndefined(sourceOptions);
|
|
964
1087
|
const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, {
|
|
965
1088
|
...resolvedSourceOptions,
|
|
966
1089
|
sourceFile: resolvedEntrySource.file
|
|
967
1090
|
});
|
|
968
|
-
const css =
|
|
969
|
-
return withMatchedSourceSideMetadata(await
|
|
1091
|
+
const css = createTailwindV4SourceReferenceSource(require_v4_engine.normalizeConfigDirective(require_v4_engine.prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), resolvedSourceOptions);
|
|
1092
|
+
return withMatchedSourceSideMetadata(await require_v4_engine.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(resolvedSourceOptions, {
|
|
970
1093
|
base: resolvedEntrySource.base,
|
|
971
1094
|
css
|
|
972
1095
|
})), resolvedEntrySource);
|
|
973
1096
|
}
|
|
974
|
-
function
|
|
975
|
-
if (!("version" in source) || source.version !== 3) return;
|
|
976
|
-
const entries = require_v3_engine.normalizeLegacyContentEntries(source.configObject?.content, source.cwd, { relativeBase: source.config ? node_path.default.dirname(source.config) : source.cwd });
|
|
977
|
-
return entries.length > 0 ? entries : void 0;
|
|
978
|
-
}
|
|
979
|
-
function withTailwindV3SourceMetadata(source) {
|
|
980
|
-
const sourceEntries = resolveTailwindV3SourceEntries(source);
|
|
981
|
-
return sourceEntries ? withGeneratorSourceMetadata(source, { sourceEntries }) : source;
|
|
982
|
-
}
|
|
983
|
-
async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
|
|
1097
|
+
async function resolveGeneratorSource(_majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
|
|
984
1098
|
const base = resolveCssSourceBase(file, cssHandlerOptions);
|
|
985
|
-
const cssEntrySource =
|
|
1099
|
+
const cssEntrySource = require_v4_engine.resolveCssEntrySource(rawSource, base, {
|
|
986
1100
|
importFallback: generatorOptions?.importFallback ?? false,
|
|
987
|
-
removeConfig:
|
|
1101
|
+
removeConfig: false
|
|
988
1102
|
});
|
|
989
|
-
const applyEntrySource =
|
|
1103
|
+
const applyEntrySource = require_v4_engine.hasTailwindApplyDirective(rawSource) ? {
|
|
990
1104
|
base,
|
|
991
1105
|
css: rawSource
|
|
992
1106
|
} : void 0;
|
|
993
|
-
if (majorVersion === 3) {
|
|
994
|
-
const sourceOptions = require_v3_engine.resolveTailwindV3SourceOptionsFromPatcher(runtimeState.twPatcher);
|
|
995
|
-
const mergedSourceOptions = require_v3_engine.omitUndefined({
|
|
996
|
-
...sourceOptions,
|
|
997
|
-
config: generatorOptions?.config ?? sourceOptions.config,
|
|
998
|
-
sourceFile: resolvePostcssSourceFile(cssHandlerOptions),
|
|
999
|
-
...resolveCssHandlerSourceOptions(cssHandlerOptions),
|
|
1000
|
-
cssEntries: selectionOptions?.cssEntries,
|
|
1001
|
-
cssSources: createCssEntrySources(selectionOptions?.cssEntries)
|
|
1002
|
-
});
|
|
1003
|
-
const sourceSideEntrySource = canResolveSourceSideCssEntry(file, cssHandlerOptions, mergedSourceOptions) ? resolveSourceSideCssEntrySource(file, mergedSourceOptions, { removeConfig: true }) : void 0;
|
|
1004
|
-
const shouldPreferSourceSideEntry = shouldPreferResolvedSourceSideEntry(cssEntrySource, sourceSideEntrySource);
|
|
1005
|
-
const resolvedEntrySource = shouldResolveSourceSideCssEntry(rawSource) ? shouldPreferSourceSideEntry ? sourceSideEntrySource ?? cssEntrySource ?? applyEntrySource : cssEntrySource ?? applyEntrySource ?? sourceSideEntrySource : shouldPreferTailwindV3SourceSideEntry(rawSource, sourceSideEntrySource) || shouldPreferSourceSideEntry ? sourceSideEntrySource ?? cssEntrySource ?? applyEntrySource : cssEntrySource ?? applyEntrySource ?? sourceSideEntrySource;
|
|
1006
|
-
if (!resolvedEntrySource) return withTailwindV3SourceMetadata(await (generatorOptions?.config ? require_v3_engine.resolveTailwindV3Source(mergedSourceOptions) : require_v3_engine.resolveTailwindV3SourceFromPatcher(runtimeState.twPatcher)));
|
|
1007
|
-
if (cssEntrySource && !sourceSideEntrySource && !applyEntrySource && !require_v3_engine.hasTailwindRootDirectives(rawSource, { importFallback: true })) return withTailwindV3SourceMetadata(await (generatorOptions?.config ? require_v3_engine.resolveTailwindV3Source(mergedSourceOptions) : require_v3_engine.resolveTailwindV3SourceFromPatcher(runtimeState.twPatcher)));
|
|
1008
|
-
const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, require_v3_engine.omitUndefined(mergedSourceOptions));
|
|
1009
|
-
const sourceWithMetadata = withTailwindV3SourceMetadata(await require_v3_engine.resolveTailwindV3Source({
|
|
1010
|
-
...mergedSourceOptions,
|
|
1011
|
-
base: resolvedEntrySource.base,
|
|
1012
|
-
css: require_v3_engine.normalizeTailwindV3CssEntrySource(resolvedEntrySource.css),
|
|
1013
|
-
...config ? { config } : {}
|
|
1014
|
-
}));
|
|
1015
|
-
const cssEntrySourceEntries = await require_v3_engine.resolveTailwindConfigEntriesFromCssCached(rawSource, resolvedEntrySource.base);
|
|
1016
|
-
const sourceMetadata = sourceWithMetadata.__weappTailwindcssMeta;
|
|
1017
|
-
const matchedSourceFile = resolvedEntrySource.file ?? sourceSideEntrySource?.file;
|
|
1018
|
-
return withGeneratorSourceMetadata(sourceWithMetadata, {
|
|
1019
|
-
...sourceMetadata,
|
|
1020
|
-
matchedCssSourceFile: matchedSourceFile,
|
|
1021
|
-
sourceEntries: cssEntrySourceEntries?.entries ?? sourceMetadata?.sourceEntries
|
|
1022
|
-
});
|
|
1023
|
-
}
|
|
1024
1107
|
const sourceOptions = tryResolveTailwindV4SourceOptions(runtimeState);
|
|
1025
|
-
const resolvedSourceOptions = sourceOptions ?
|
|
1108
|
+
const resolvedSourceOptions = sourceOptions ? require_v4_engine.omitUndefined({
|
|
1026
1109
|
...sourceOptions,
|
|
1027
1110
|
sourceFile: sourceOptions.sourceFile ?? resolvePostcssSourceFile(cssHandlerOptions),
|
|
1028
1111
|
...resolveCssHandlerSourceOptions(cssHandlerOptions),
|
|
@@ -1030,9 +1113,9 @@ async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, fil
|
|
|
1030
1113
|
cssSources: mergeCssSources(sourceOptions.cssSources, sourceOptions.cssSources?.length ? void 0 : createCssEntrySources(selectionOptions?.cssEntries ?? sourceOptions.cssEntries))
|
|
1031
1114
|
}) : void 0;
|
|
1032
1115
|
const normalizedSourceOptions = resolvedSourceOptions ? normalizeTailwindV4CssSourceConfigs(resolvedSourceOptions) : void 0;
|
|
1033
|
-
if (applyEntrySource && !cssHandlerOptions.isMainChunk && !
|
|
1034
|
-
const css = createTailwindV4ApplyReferenceSource(
|
|
1035
|
-
return
|
|
1116
|
+
if (applyEntrySource && !cssHandlerOptions.isMainChunk && !require_v4_engine.hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false })) {
|
|
1117
|
+
const css = createTailwindV4ApplyReferenceSource(require_v4_engine.normalizeConfigDirective(require_v4_engine.prependConfigDirective(applyEntrySource.css, generatorOptions?.config), void 0), normalizedSourceOptions ?? {});
|
|
1118
|
+
return require_v4_engine.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(normalizedSourceOptions ?? {}, {
|
|
1036
1119
|
base: applyEntrySource.base,
|
|
1037
1120
|
css
|
|
1038
1121
|
}));
|
|
@@ -1043,89 +1126,93 @@ async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, fil
|
|
|
1043
1126
|
const matchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, normalizedSourceOptions) : void 0;
|
|
1044
1127
|
const candidateMatchedCssSource = normalizedSourceOptions && !matchedCssEntrySource ? await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, normalizedSourceOptions, selectionOptions) : void 0;
|
|
1045
1128
|
const singleConfiguredCssSource = normalizedSourceOptions?.cssSources?.length === 1 ? await resolveSingleTailwindV4CssSource(normalizedSourceOptions.cssSources[0], normalizedSourceOptions, { matched: true }) : void 0;
|
|
1046
|
-
const configuredCssSource = normalizedSourceOptions && hasConfiguredTailwindV4CssSource(normalizedSourceOptions) &&
|
|
1129
|
+
const configuredCssSource = normalizedSourceOptions && hasConfiguredTailwindV4CssSource(normalizedSourceOptions) && require_v4_engine.hasTailwindGeneratedCssMarkers(rawSource) ? matchedCssSource ?? candidateMatchedCssSource ?? singleConfiguredCssSource ?? await require_v4_engine.resolveTailwindV4Source(normalizedSourceOptions) : void 0;
|
|
1047
1130
|
if (configuredCssSource) return generatorOptions?.config ? {
|
|
1048
1131
|
...configuredCssSource,
|
|
1049
|
-
css:
|
|
1132
|
+
css: require_v4_engine.prependConfigDirective(configuredCssSource.css, generatorOptions.config)
|
|
1050
1133
|
} : configuredCssSource;
|
|
1051
1134
|
const mainCssEntrySource = normalizedSourceOptions && cssHandlerOptions.isMainChunk && normalizedSourceOptions.cssEntries?.length === 1 ? await resolveTailwindV4CssEntrySource(normalizedSourceOptions.cssEntries[0], normalizedSourceOptions) : void 0;
|
|
1052
1135
|
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource ?? mainCssEntrySource ?? singleConfiguredCssSource;
|
|
1053
1136
|
if (preferredCssEntrySource) return generatorOptions?.config ? {
|
|
1054
1137
|
...preferredCssEntrySource,
|
|
1055
|
-
css:
|
|
1138
|
+
css: require_v4_engine.prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
|
|
1056
1139
|
} : preferredCssEntrySource;
|
|
1057
1140
|
const resolvedEntrySource = sourceSideEntrySource ?? cssEntrySource ?? applyEntrySource;
|
|
1058
1141
|
if (!resolvedEntrySource) {
|
|
1059
|
-
const source = await
|
|
1142
|
+
const source = await require_v4_engine.resolveTailwindV4SourceFromRuntime(runtimeState.tailwindRuntime);
|
|
1060
1143
|
return generatorOptions?.config ? {
|
|
1061
1144
|
...source,
|
|
1062
|
-
css:
|
|
1145
|
+
css: require_v4_engine.prependConfigDirective(source.css, generatorOptions.config)
|
|
1063
1146
|
} : source;
|
|
1064
1147
|
}
|
|
1065
1148
|
if (sourceSideEntrySource && normalizedSourceOptions) return resolveTailwindV4SourceSideEntrySource(sourceSideEntrySource, normalizedSourceOptions, generatorOptions, file);
|
|
1066
|
-
const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file,
|
|
1149
|
+
const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, require_v4_engine.omitUndefined({
|
|
1150
|
+
...resolvedSourceOptions ?? {},
|
|
1151
|
+
sourceFile: resolvedEntrySource.file ?? resolvedSourceOptions?.sourceFile ?? resolvePostcssSourceFile(cssHandlerOptions)
|
|
1152
|
+
}));
|
|
1067
1153
|
const sourceBase = resolvedEntrySource === cssEntrySource && config ? node_path.default.dirname(config) : resolvedEntrySource.base;
|
|
1068
|
-
const css =
|
|
1069
|
-
return
|
|
1154
|
+
const css = createTailwindV4SourceReferenceSource(require_v4_engine.normalizeConfigDirective(require_v4_engine.prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), normalizedSourceOptions ?? {});
|
|
1155
|
+
return require_v4_engine.resolveTailwindV4Source(createSingleTailwindV4SourceOptions(normalizedSourceOptions ?? {}, {
|
|
1070
1156
|
base: sourceBase,
|
|
1071
1157
|
css
|
|
1072
1158
|
}));
|
|
1073
1159
|
}
|
|
1074
1160
|
async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions) {
|
|
1075
|
-
const cssEntrySource =
|
|
1161
|
+
const cssEntrySource = require_v4_engine.resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions), {
|
|
1076
1162
|
importFallback: generatorOptions?.importFallback ?? false,
|
|
1077
|
-
removeConfig:
|
|
1163
|
+
removeConfig: false
|
|
1078
1164
|
});
|
|
1079
|
-
if (
|
|
1165
|
+
if (cssEntrySource && !cssHandlerOptions.isMainChunk || !cssHandlerOptions.isMainChunk && require_v4_engine.hasTailwindApplyDirective(rawSource) && !require_v4_engine.hasTailwindRootDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false })) {
|
|
1080
1166
|
const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
|
|
1081
1167
|
return resolved ? [resolved] : [];
|
|
1082
1168
|
}
|
|
1083
1169
|
let sourceOptions;
|
|
1084
1170
|
try {
|
|
1085
|
-
const
|
|
1086
|
-
const cssEntries = selectionOptions?.cssEntries ??
|
|
1087
|
-
|
|
1088
|
-
|
|
1171
|
+
const sourceOptionsFromRuntime = require_v4_engine.resolveTailwindV4SourceOptionsFromRuntime(runtimeState.tailwindRuntime);
|
|
1172
|
+
const cssEntries = selectionOptions?.cssEntries ?? sourceOptionsFromRuntime.cssEntries;
|
|
1173
|
+
const runtimeCssSources = selectionOptions?.cssEntries ? void 0 : sourceOptionsFromRuntime.cssSources;
|
|
1174
|
+
sourceOptions = require_v4_engine.omitUndefined({
|
|
1175
|
+
...sourceOptionsFromRuntime,
|
|
1089
1176
|
sourceFile: resolvePostcssSourceFile(cssHandlerOptions),
|
|
1090
1177
|
...resolveCssHandlerSourceOptions(cssHandlerOptions),
|
|
1091
1178
|
cssEntries,
|
|
1092
|
-
cssSources: mergeCssSources(mergeCssSources(
|
|
1179
|
+
cssSources: mergeCssSources(mergeCssSources(runtimeCssSources, selectionOptions?.cssSources), void 0)
|
|
1093
1180
|
});
|
|
1094
1181
|
} catch {
|
|
1095
1182
|
const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
|
|
1096
1183
|
return resolved ? [resolved] : [];
|
|
1097
1184
|
}
|
|
1098
1185
|
const matchedCssEntrySource = sourceOptions ? await resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) : void 0;
|
|
1099
|
-
if (matchedCssEntrySource) return [generatorOptions?.config ? {
|
|
1186
|
+
if (matchedCssEntrySource) return [normalizeResolvedTailwindV4SourceConfig(generatorOptions?.config ? {
|
|
1100
1187
|
...matchedCssEntrySource,
|
|
1101
|
-
css:
|
|
1102
|
-
} : matchedCssEntrySource];
|
|
1188
|
+
css: require_v4_engine.prependConfigDirective(matchedCssEntrySource.css, generatorOptions.config)
|
|
1189
|
+
} : matchedCssEntrySource, matchedCssEntrySource.__weappTailwindcssMeta?.matchedCssSourceFile, sourceOptions)];
|
|
1103
1190
|
const sourceSideCssSource = await resolveTailwindV4SourceSideEntrySource(canResolveSourceSideCssEntry(file, cssHandlerOptions, sourceOptions) ? resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: false }) : void 0, sourceOptions, generatorOptions, file);
|
|
1104
1191
|
if (sourceSideCssSource) return [sourceSideCssSource];
|
|
1105
1192
|
const matchedCssSource = await resolveMatchingTailwindV4CssSource(rawSource, file, cssHandlerOptions, sourceOptions);
|
|
1106
1193
|
const candidateMatchedCssSource = await resolveCandidateMatchedTailwindV4CssSource(rawSource, cssHandlerOptions, sourceOptions, selectionOptions);
|
|
1107
1194
|
const preferredCssEntrySource = matchedCssEntrySource ?? matchedCssSource ?? candidateMatchedCssSource;
|
|
1108
|
-
if (preferredCssEntrySource) return [generatorOptions?.config ? {
|
|
1195
|
+
if (preferredCssEntrySource) return [normalizeResolvedTailwindV4SourceConfig(generatorOptions?.config ? {
|
|
1109
1196
|
...preferredCssEntrySource,
|
|
1110
|
-
css:
|
|
1111
|
-
} : preferredCssEntrySource];
|
|
1197
|
+
css: require_v4_engine.prependConfigDirective(preferredCssEntrySource.css, generatorOptions.config)
|
|
1198
|
+
} : preferredCssEntrySource, preferredCssEntrySource.__weappTailwindcssMeta?.matchedCssSourceFile, sourceOptions)];
|
|
1112
1199
|
if (!sourceOptions.cssEntries || sourceOptions.cssEntries.length <= 1) {
|
|
1113
1200
|
if (cssHandlerOptions.isMainChunk && sourceOptions.cssEntries?.length === 1) return [await resolveTailwindV4CssEntrySource(sourceOptions.cssEntries[0], normalizeTailwindV4CssSourceConfigs(sourceOptions)).then((source) => generatorOptions?.config ? {
|
|
1114
1201
|
...source,
|
|
1115
|
-
css:
|
|
1202
|
+
css: require_v4_engine.prependConfigDirective(source.css, generatorOptions.config)
|
|
1116
1203
|
} : source)];
|
|
1117
|
-
if (sourceOptions.cssSources?.length === 1) return [await createTailwindV4CssSourceResolver(sourceOptions, generatorOptions)(sourceOptions.cssSources[0])];
|
|
1204
|
+
if (sourceOptions.cssSources?.length === 1) return [normalizeResolvedTailwindV4SourceConfig(await createTailwindV4CssSourceResolver(sourceOptions, generatorOptions)(sourceOptions.cssSources[0]), sourceOptions.cssSources[0]?.file, sourceOptions)];
|
|
1118
1205
|
const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
|
|
1119
1206
|
return resolved ? [resolved] : [];
|
|
1120
1207
|
}
|
|
1121
|
-
if (cssHandlerOptions.isMainChunk && !cssEntrySource && !
|
|
1208
|
+
if (cssHandlerOptions.isMainChunk && !cssEntrySource && !require_v4_engine.hasTailwindGeneratedCss(rawSource) && !require_v4_engine.hasTailwindGeneratedCssMarkers(rawSource) && !require_v4_engine.hasTailwindSourceDirectives(rawSource, { importFallback: generatorOptions?.importFallback ?? false }) && !rawSource.includes("weapp-tailwindcss generator-placeholder") && !hasConfiguredTailwindV4CssSource(sourceOptions)) {
|
|
1122
1209
|
const resolved = await resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions, selectionOptions);
|
|
1123
1210
|
return resolved ? [resolved] : [];
|
|
1124
1211
|
}
|
|
1125
1212
|
const normalizedCssSourceOptions = normalizeTailwindV4CssSourceConfigs(sourceOptions);
|
|
1126
1213
|
const cssEntrySources = await Promise.all(sourceOptions.cssEntries.map((cssEntry) => resolveTailwindV4CssEntrySource(cssEntry, normalizedCssSourceOptions).then((source) => generatorOptions?.config ? {
|
|
1127
1214
|
...source,
|
|
1128
|
-
css:
|
|
1215
|
+
css: require_v4_engine.prependConfigDirective(source.css, generatorOptions.config)
|
|
1129
1216
|
} : source)));
|
|
1130
1217
|
const cssSources = sourceOptions.cssSources?.length ? await Promise.all(sourceOptions.cssSources.map(createTailwindV4CssSourceResolver(sourceOptions, generatorOptions))) : [];
|
|
1131
1218
|
return [...cssEntrySources, ...cssSources];
|
|
@@ -1134,7 +1221,7 @@ async function resolveGeneratorSourceEntries(source, runtimeState) {
|
|
|
1134
1221
|
const sourceMetadata = source.__weappTailwindcssMeta;
|
|
1135
1222
|
if (sourceMetadata?.sourceEntries) return sourceMetadata.sourceEntries;
|
|
1136
1223
|
if (!("css" in source) || !("base" in source) || !("baseFallbacks" in source)) return;
|
|
1137
|
-
const resolved = await
|
|
1224
|
+
const resolved = await require_tailwindcss.resolveTailwindV4EntriesFromCss(sourceMetadata?.sourceCss ?? source.css, sourceMetadata?.sourceBase ?? source.base);
|
|
1138
1225
|
if (resolved?.entries.length === 0 && !resolved.inlineCandidates.included.size && !resolved.inlineCandidates.excluded.size && !resolved.dependencies.length) {
|
|
1139
1226
|
if (sourceMetadata?.matchedCssSourceFile) return [];
|
|
1140
1227
|
return;
|
|
@@ -1145,144 +1232,639 @@ async function resolveGeneratorSourceEntries(source, runtimeState) {
|
|
|
1145
1232
|
return cssSource.css === source.css;
|
|
1146
1233
|
});
|
|
1147
1234
|
if (!matchingCssSource) return resolved?.entries;
|
|
1148
|
-
const sourceResolved = await
|
|
1235
|
+
const sourceResolved = await require_tailwindcss.resolveTailwindV4EntriesFromCss(matchingCssSource.css, typeof matchingCssSource.base === "string" && matchingCssSource.base.length > 0 ? matchingCssSource.base : typeof matchingCssSource.file === "string" && matchingCssSource.file.length > 0 ? node_path.default.dirname(matchingCssSource.file) : source.base);
|
|
1149
1236
|
if (sourceResolved?.entries.length) return sourceResolved.entries;
|
|
1150
1237
|
for (const dependency of matchingCssSource.dependencies ?? []) {
|
|
1151
1238
|
if (!(0, node_fs.existsSync)(dependency)) continue;
|
|
1152
1239
|
try {
|
|
1153
|
-
const dependencyResolved = await
|
|
1240
|
+
const dependencyResolved = await require_tailwindcss.resolveTailwindV4EntriesFromCss((0, node_fs.readFileSync)(dependency, "utf8"), node_path.default.dirname(dependency));
|
|
1154
1241
|
if (dependencyResolved?.entries.length) return dependencyResolved.entries;
|
|
1155
1242
|
} catch {}
|
|
1156
1243
|
}
|
|
1157
1244
|
return resolved?.entries;
|
|
1158
1245
|
}
|
|
1159
1246
|
//#endregion
|
|
1160
|
-
//#region src/bundlers/shared/generator-css/
|
|
1161
|
-
const
|
|
1162
|
-
"
|
|
1163
|
-
"
|
|
1164
|
-
"
|
|
1165
|
-
"
|
|
1166
|
-
"
|
|
1167
|
-
"
|
|
1168
|
-
"
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
"
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
"@media (min-width: 64rem) {",
|
|
1176
|
-
" .container {",
|
|
1177
|
-
" max-width: 64rem;",
|
|
1178
|
-
" }",
|
|
1179
|
-
"}",
|
|
1180
|
-
"@media (min-width: 80rem) {",
|
|
1181
|
-
" .container {",
|
|
1182
|
-
" max-width: 80rem;",
|
|
1183
|
-
" }",
|
|
1184
|
-
"}",
|
|
1185
|
-
"@media (min-width: 96rem) {",
|
|
1186
|
-
" .container {",
|
|
1187
|
-
" max-width: 96rem;",
|
|
1188
|
-
" }",
|
|
1189
|
-
"}"
|
|
1190
|
-
].join("\n");
|
|
1191
|
-
const LEGACY_COMPAT_CACHE_LIMIT = 128;
|
|
1192
|
-
const legacyCompatSourceCache = /* @__PURE__ */ new Map();
|
|
1193
|
-
const legacyCompatTransformCache = /* @__PURE__ */ new Map();
|
|
1194
|
-
function setLimitedCacheValue(cache, key, value) {
|
|
1195
|
-
if (cache.size >= LEGACY_COMPAT_CACHE_LIMIT) {
|
|
1196
|
-
const firstKey = cache.keys().next().value;
|
|
1197
|
-
if (firstKey !== void 0) cache.delete(firstKey);
|
|
1247
|
+
//#region src/bundlers/shared/generator-css/user-css.ts
|
|
1248
|
+
const TAILWIND_V4_GENERATOR_AT_RULES = new Set([
|
|
1249
|
+
"config",
|
|
1250
|
+
"custom-variant",
|
|
1251
|
+
"plugin",
|
|
1252
|
+
"source",
|
|
1253
|
+
"theme",
|
|
1254
|
+
"utility",
|
|
1255
|
+
"variant"
|
|
1256
|
+
]);
|
|
1257
|
+
function removeBalancedAtRuleBlock(source, atRuleStart) {
|
|
1258
|
+
const blockStart = source.indexOf("{", atRuleStart);
|
|
1259
|
+
if (blockStart === -1) {
|
|
1260
|
+
const semicolon = source.indexOf(";", atRuleStart);
|
|
1261
|
+
return semicolon === -1 ? source.slice(0, atRuleStart) : `${source.slice(0, atRuleStart)}${source.slice(semicolon + 1)}`;
|
|
1198
1262
|
}
|
|
1199
|
-
|
|
1263
|
+
let depth = 0;
|
|
1264
|
+
for (let index = blockStart; index < source.length; index++) {
|
|
1265
|
+
const char = source[index];
|
|
1266
|
+
if (char === "{") {
|
|
1267
|
+
depth++;
|
|
1268
|
+
continue;
|
|
1269
|
+
}
|
|
1270
|
+
if (char !== "}") continue;
|
|
1271
|
+
depth--;
|
|
1272
|
+
if (depth === 0) return `${source.slice(0, atRuleStart)}${source.slice(index + 1)}`;
|
|
1273
|
+
}
|
|
1274
|
+
return source.slice(0, atRuleStart);
|
|
1200
1275
|
}
|
|
1201
|
-
function
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1276
|
+
function removeTailwindV4GeneratorAtRulesFallback(source) {
|
|
1277
|
+
let next = source;
|
|
1278
|
+
let changed = false;
|
|
1279
|
+
const sourceMediaRE = /@media\s+source\([^)]*\)\s*\{/g;
|
|
1280
|
+
for (;;) {
|
|
1281
|
+
sourceMediaRE.lastIndex = 0;
|
|
1282
|
+
const match = sourceMediaRE.exec(next);
|
|
1283
|
+
if (!match) break;
|
|
1284
|
+
next = removeBalancedAtRuleBlock(next, match.index);
|
|
1285
|
+
changed = true;
|
|
1286
|
+
}
|
|
1287
|
+
const atRuleRE = /@(?:config|custom-variant|plugin|source|theme|utility|variant)\b/g;
|
|
1288
|
+
for (;;) {
|
|
1289
|
+
atRuleRE.lastIndex = 0;
|
|
1290
|
+
const match = atRuleRE.exec(next);
|
|
1291
|
+
if (!match) break;
|
|
1292
|
+
next = removeBalancedAtRuleBlock(next, match.index);
|
|
1293
|
+
changed = true;
|
|
1294
|
+
}
|
|
1295
|
+
return changed ? next : source;
|
|
1296
|
+
}
|
|
1297
|
+
function isTailwindGeneratedPreflightComment(text) {
|
|
1298
|
+
return text.includes("cssremedy") || text.includes("Use the user's configured") || text.includes("tailwindlabs/tailwindcss") || text.includes("Prevent padding and border from affecting element width") || text.includes("Remove default margins and padding") || text.includes("Deprecated") || text.includes("Reset all borders") || text.includes("Add the correct text decoration") || text.includes("Make elements with the HTML hidden attribute stay hidden") || text.includes("Inherit font styles in all browsers") || text.includes("Add the correct height in Firefox") || text.includes("Remove the default font size and weight for headings") || text.includes("Reset links to optimize for opt-in styling") || text.includes("Add the correct font weight in Edge and Safari") || text.includes("Use the user's configured `mono` font-family") || text.includes("Add the correct font size in all browsers") || text.includes("Prevent `sub` and `sup` elements from affecting the line height") || text.includes("Remove text indentation from table contents") || text.includes("Use the modern Firefox focus style") || text.includes("Add the correct vertical alignment") || text.includes("Add the correct display") || text.includes("Make lists unstyled by default") || text.includes("Make replaced elements `display: block` by default") || text.includes("Constrain images and videos to the parent width") || text.includes("Restore default font weight") || text.includes("Restore indentation") || text.includes("Restore space after button") || text.includes("Prevent resizing textareas horizontally") || text.includes("Remove the inner padding in Chrome and Safari") || text.includes("Ensure date/time inputs have the same height") || text.includes("Prevent height from changing on date/time inputs") || text.includes("Remove excess padding from pseudo-elements") || text.includes("Center dropdown marker shown on inputs") || text.includes("Remove the additional `:invalid` styles") || text.includes("Correct the inability to style the border radius") || text.includes("Correct the cursor style of increment and decrement buttons");
|
|
1299
|
+
}
|
|
1300
|
+
function isTailwindGeneratedThemeRule(selector, node) {
|
|
1301
|
+
if (!/(?:^|,)\s*(?::host|page|\.tw-root|wx-root-portal-content)\b/.test(selector)) return false;
|
|
1302
|
+
return node.nodes?.some((child) => child.type === "decl" && /^--(?:color|spacing|text|font|default|radius|tw-)/.test(child.prop)) ?? false;
|
|
1303
|
+
}
|
|
1304
|
+
function isTailwindGeneratedPreflightRule(selector, node) {
|
|
1305
|
+
if (selector === "view,text,::after,::before" || selector === "view, text, ::after, ::before" || selector === "*" || selector === "::after" || selector === "::before" || selector === "::backdrop" || selector === ":host" || selector === "[hidden]:not([hidden=\"until-found\"])" || selector === "[hidden]:not([hidden='until-found'])" || selector === "button,input[type=\"button\"],input[type=\"reset\"],input[type=\"submit\"]" || selector === "button, input[type=\"button\"], input[type=\"reset\"], input[type=\"submit\"]" || selector === "button,input[type='button'],input[type='reset'],input[type='submit']" || selector === "button, input[type='button'], input[type='reset'], input[type='submit']") return true;
|
|
1306
|
+
if (selector === "abbr[title]") return node.nodes?.some((child) => child.type === "decl" && child.prop === "text-decoration") ?? false;
|
|
1307
|
+
if (selector === ":host") return node.nodes?.some((child) => child.type === "decl" && child.value?.includes("--theme(")) ?? false;
|
|
1308
|
+
return false;
|
|
1209
1309
|
}
|
|
1210
|
-
function
|
|
1211
|
-
|
|
1310
|
+
function removeTailwindV4GeneratedUserCssArtifacts(source) {
|
|
1311
|
+
try {
|
|
1312
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1313
|
+
let changed = false;
|
|
1314
|
+
root.walkComments((comment) => {
|
|
1315
|
+
if (!isTailwindGeneratedPreflightComment(comment.text)) return;
|
|
1316
|
+
comment.remove();
|
|
1317
|
+
changed = true;
|
|
1318
|
+
});
|
|
1319
|
+
root.walkRules((rule) => {
|
|
1320
|
+
const selector = rule.selector.replace(/\s+/g, " ").trim();
|
|
1321
|
+
if (isTailwindGeneratedThemeRule(selector, rule) || isTailwindGeneratedPreflightRule(selector, rule)) {
|
|
1322
|
+
rule.remove();
|
|
1323
|
+
changed = true;
|
|
1324
|
+
}
|
|
1325
|
+
});
|
|
1326
|
+
root.walkAtRules((rule) => {
|
|
1327
|
+
if (rule.nodes !== void 0 && rule.nodes.length === 0) {
|
|
1328
|
+
rule.remove();
|
|
1329
|
+
changed = true;
|
|
1330
|
+
}
|
|
1331
|
+
});
|
|
1332
|
+
return changed ? root.toString() : source;
|
|
1333
|
+
} catch {
|
|
1334
|
+
return source;
|
|
1335
|
+
}
|
|
1212
1336
|
}
|
|
1213
|
-
function
|
|
1214
|
-
let
|
|
1215
|
-
let
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
const
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1337
|
+
function removeTailwindSourceMediaBlocks(source) {
|
|
1338
|
+
let next = source;
|
|
1339
|
+
let changed = false;
|
|
1340
|
+
const sourceMediaRE = /@media\s+source\([^)]*\)\s*\{/g;
|
|
1341
|
+
for (;;) {
|
|
1342
|
+
sourceMediaRE.lastIndex = 0;
|
|
1343
|
+
const match = sourceMediaRE.exec(next);
|
|
1344
|
+
if (!match) break;
|
|
1345
|
+
const blockStart = next.indexOf("{", match.index);
|
|
1346
|
+
if (blockStart === -1) break;
|
|
1347
|
+
let depth = 0;
|
|
1348
|
+
let blockEnd = -1;
|
|
1349
|
+
for (let index = blockStart; index < next.length; index++) {
|
|
1350
|
+
const char = next[index];
|
|
1351
|
+
if (char === "{") {
|
|
1352
|
+
depth++;
|
|
1353
|
+
continue;
|
|
1225
1354
|
}
|
|
1355
|
+
if (char !== "}") continue;
|
|
1356
|
+
depth--;
|
|
1357
|
+
if (depth === 0) {
|
|
1358
|
+
blockEnd = index;
|
|
1359
|
+
break;
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
if (blockEnd === -1) break;
|
|
1363
|
+
next = `${next.slice(0, match.index)}${next.slice(blockEnd + 1)}`;
|
|
1364
|
+
changed = true;
|
|
1365
|
+
}
|
|
1366
|
+
for (;;) {
|
|
1367
|
+
const atRuleStart = findTailwindSourceWrapperBlockStart(next);
|
|
1368
|
+
if (atRuleStart === -1) break;
|
|
1369
|
+
next = removeBalancedAtRuleBlock(next, atRuleStart);
|
|
1370
|
+
changed = true;
|
|
1371
|
+
}
|
|
1372
|
+
return changed ? next : source;
|
|
1373
|
+
}
|
|
1374
|
+
function terminateTailwindSourceAtRulesBeforeNextDirective(source) {
|
|
1375
|
+
if (!source.includes("@source")) return source;
|
|
1376
|
+
let next = "";
|
|
1377
|
+
let searchIndex = 0;
|
|
1378
|
+
for (;;) {
|
|
1379
|
+
const atRuleStart = source.indexOf("@source", searchIndex);
|
|
1380
|
+
if (atRuleStart === -1) {
|
|
1381
|
+
next += source.slice(searchIndex);
|
|
1382
|
+
break;
|
|
1383
|
+
}
|
|
1384
|
+
const nextChar = source[atRuleStart + 7];
|
|
1385
|
+
if (nextChar && /[\w-]/.test(nextChar)) {
|
|
1386
|
+
next += source.slice(searchIndex, atRuleStart + 7);
|
|
1387
|
+
searchIndex = atRuleStart + 7;
|
|
1226
1388
|
continue;
|
|
1227
1389
|
}
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1390
|
+
next += source.slice(searchIndex, atRuleStart);
|
|
1391
|
+
let quote;
|
|
1392
|
+
let parenDepth = 0;
|
|
1393
|
+
let terminated = false;
|
|
1394
|
+
let index = atRuleStart + 7;
|
|
1395
|
+
for (; index < source.length; index++) {
|
|
1396
|
+
const char = source[index];
|
|
1397
|
+
if (quote) {
|
|
1398
|
+
if (char === "\\") {
|
|
1399
|
+
index++;
|
|
1400
|
+
continue;
|
|
1401
|
+
}
|
|
1402
|
+
if (char === quote) quote = void 0;
|
|
1231
1403
|
continue;
|
|
1232
1404
|
}
|
|
1233
|
-
if (char === "
|
|
1234
|
-
|
|
1405
|
+
if (char === "\"" || char === "'") {
|
|
1406
|
+
quote = char;
|
|
1235
1407
|
continue;
|
|
1236
1408
|
}
|
|
1237
|
-
if (char ===
|
|
1238
|
-
|
|
1409
|
+
if (char === "(") {
|
|
1410
|
+
parenDepth++;
|
|
1411
|
+
continue;
|
|
1412
|
+
}
|
|
1413
|
+
if (char === ")" && parenDepth > 0) {
|
|
1414
|
+
parenDepth--;
|
|
1415
|
+
continue;
|
|
1416
|
+
}
|
|
1417
|
+
if (parenDepth > 0) continue;
|
|
1418
|
+
if (char === ";" || char === "{") {
|
|
1419
|
+
terminated = true;
|
|
1420
|
+
index++;
|
|
1421
|
+
break;
|
|
1422
|
+
}
|
|
1423
|
+
if (char === "@" && /^(?:config|custom-variant|plugin|source|theme|utility|variant)\b/.test(source.slice(index + 1))) break;
|
|
1239
1424
|
}
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1425
|
+
const segment = source.slice(atRuleStart, index);
|
|
1426
|
+
const trimmedSegment = segment.trimEnd();
|
|
1427
|
+
next += terminated || trimmedSegment.endsWith(";") || trimmedSegment.endsWith("{") ? segment : `${trimmedSegment};${segment.slice(trimmedSegment.length)}`;
|
|
1428
|
+
searchIndex = index;
|
|
1429
|
+
}
|
|
1430
|
+
return next;
|
|
1431
|
+
}
|
|
1432
|
+
function findTailwindSourceWrapperBlockStart(source) {
|
|
1433
|
+
let searchIndex = 0;
|
|
1434
|
+
for (;;) {
|
|
1435
|
+
const atRuleStart = source.indexOf("@source", searchIndex);
|
|
1436
|
+
if (atRuleStart === -1) return -1;
|
|
1437
|
+
const nextChar = source[atRuleStart + 7];
|
|
1438
|
+
if (nextChar && /[\w-]/.test(nextChar)) {
|
|
1439
|
+
searchIndex = atRuleStart + 7;
|
|
1243
1440
|
continue;
|
|
1244
1441
|
}
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1442
|
+
let quote;
|
|
1443
|
+
let parenDepth = 0;
|
|
1444
|
+
for (let index = atRuleStart + 7; index < source.length; index++) {
|
|
1445
|
+
const char = source[index];
|
|
1446
|
+
if (quote) {
|
|
1447
|
+
if (char === "\\") {
|
|
1448
|
+
index++;
|
|
1449
|
+
continue;
|
|
1450
|
+
}
|
|
1451
|
+
if (char === quote) quote = void 0;
|
|
1452
|
+
continue;
|
|
1453
|
+
}
|
|
1454
|
+
if (char === "\"" || char === "'") {
|
|
1455
|
+
quote = char;
|
|
1456
|
+
continue;
|
|
1457
|
+
}
|
|
1458
|
+
if (char === "(") {
|
|
1459
|
+
parenDepth++;
|
|
1460
|
+
continue;
|
|
1461
|
+
}
|
|
1462
|
+
if (char === ")" && parenDepth > 0) {
|
|
1463
|
+
parenDepth--;
|
|
1464
|
+
continue;
|
|
1465
|
+
}
|
|
1466
|
+
if (parenDepth > 0) continue;
|
|
1467
|
+
if (char === ";") {
|
|
1468
|
+
searchIndex = index + 1;
|
|
1469
|
+
break;
|
|
1470
|
+
}
|
|
1471
|
+
if (char === "{") return atRuleStart;
|
|
1248
1472
|
}
|
|
1249
|
-
if (
|
|
1250
|
-
else if (char === "}" && depth > 0) depth -= 1;
|
|
1473
|
+
if (searchIndex <= atRuleStart) return -1;
|
|
1251
1474
|
}
|
|
1252
|
-
return depth;
|
|
1253
1475
|
}
|
|
1254
|
-
function
|
|
1476
|
+
function removeTailwindApplyAtRules(source) {
|
|
1477
|
+
if (!source.includes("@apply")) return source;
|
|
1255
1478
|
try {
|
|
1256
|
-
_weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1479
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1480
|
+
let changed = false;
|
|
1481
|
+
root.walkAtRules("apply", (rule) => {
|
|
1482
|
+
rule.remove();
|
|
1483
|
+
changed = true;
|
|
1484
|
+
});
|
|
1485
|
+
root.walk((node) => {
|
|
1486
|
+
if ("nodes" in node && node.nodes?.length === 0) node.remove();
|
|
1487
|
+
});
|
|
1488
|
+
return changed ? root.toString() : source;
|
|
1489
|
+
} catch {
|
|
1257
1490
|
return source;
|
|
1258
|
-
} catch (error) {
|
|
1259
|
-
if (error.reason !== "Unclosed block") return source;
|
|
1260
|
-
const unclosedBlocks = countUnclosedBlocks(source);
|
|
1261
|
-
return unclosedBlocks > 0 ? `${source}${"}".repeat(unclosedBlocks)}` : source;
|
|
1262
1491
|
}
|
|
1263
1492
|
}
|
|
1264
|
-
function
|
|
1493
|
+
function removeTailwindV4GeneratorAtRules(source) {
|
|
1265
1494
|
try {
|
|
1266
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(
|
|
1267
|
-
let
|
|
1268
|
-
root.walkAtRules("apply", (rule) => {
|
|
1269
|
-
const parent = rule.parent;
|
|
1270
|
-
if (parent?.type === "rule") parent.remove();
|
|
1271
|
-
else rule.remove();
|
|
1272
|
-
removed = true;
|
|
1273
|
-
});
|
|
1495
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1496
|
+
let changed = false;
|
|
1274
1497
|
root.walkAtRules((rule) => {
|
|
1275
|
-
if (rule.
|
|
1498
|
+
if (rule.name === "media" && /^source\(/.test(rule.params.trim())) {
|
|
1499
|
+
rule.remove();
|
|
1500
|
+
changed = true;
|
|
1501
|
+
return;
|
|
1502
|
+
}
|
|
1503
|
+
if (!TAILWIND_V4_GENERATOR_AT_RULES.has(rule.name)) return;
|
|
1504
|
+
rule.remove();
|
|
1505
|
+
changed = true;
|
|
1276
1506
|
});
|
|
1277
|
-
return
|
|
1507
|
+
return changed ? root.toString() : source;
|
|
1278
1508
|
} catch {
|
|
1279
|
-
return
|
|
1509
|
+
return removeTailwindV4GeneratorAtRulesFallback(source);
|
|
1280
1510
|
}
|
|
1281
1511
|
}
|
|
1282
|
-
function
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1512
|
+
function isCommentOnlyCss(source) {
|
|
1513
|
+
try {
|
|
1514
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1515
|
+
return root.nodes.length > 0 && root.nodes.every((node) => node.type === "comment");
|
|
1516
|
+
} catch {
|
|
1517
|
+
return false;
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
function removeMiniProgramHoverSelectors(source, enabled = true) {
|
|
1521
|
+
if (!enabled || !source.includes(":hover")) return source;
|
|
1522
|
+
try {
|
|
1523
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1524
|
+
let changed = false;
|
|
1525
|
+
root.walkRules((rule) => {
|
|
1526
|
+
const selectors = rule.selectors ?? [rule.selector];
|
|
1527
|
+
const keptSelectors = selectors.filter((selector) => !selector.includes(":hover"));
|
|
1528
|
+
if (keptSelectors.length === selectors.length) return;
|
|
1529
|
+
changed = true;
|
|
1530
|
+
if (keptSelectors.length === 0) {
|
|
1531
|
+
rule.remove();
|
|
1532
|
+
return;
|
|
1533
|
+
}
|
|
1534
|
+
rule.selectors = keptSelectors;
|
|
1535
|
+
});
|
|
1536
|
+
root.walk((node) => {
|
|
1537
|
+
if ("nodes" in node && node.nodes?.length === 0) {
|
|
1538
|
+
node.remove();
|
|
1539
|
+
changed = true;
|
|
1540
|
+
}
|
|
1541
|
+
});
|
|
1542
|
+
return changed ? root.toString() : source;
|
|
1543
|
+
} catch {
|
|
1544
|
+
return source;
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
function removeProcessedMiniProgramUnsupportedCss(source, options) {
|
|
1548
|
+
return removeMiniProgramHoverSelectors((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(source), options.cssRemoveHoverPseudoClass);
|
|
1549
|
+
}
|
|
1550
|
+
function unwrapMiniProgramCascadeLayers(source) {
|
|
1551
|
+
if (!source.includes("@layer")) return source;
|
|
1552
|
+
try {
|
|
1553
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1554
|
+
(0, _weapp_tailwindcss_postcss.removeUnsupportedCascadeLayers)(root);
|
|
1555
|
+
return root.toString();
|
|
1556
|
+
} catch {
|
|
1557
|
+
return source;
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
function stripTailwindSourceMediaFragments(source) {
|
|
1561
|
+
let removedSourceMediaStart = false;
|
|
1562
|
+
return terminateTailwindSourceAtRulesBeforeNextDirective(removeTailwindSourceMediaBlocks(source)).split(/\r?\n/).filter((line) => {
|
|
1563
|
+
if (/^\s*@media\s+source\([^)]*\)\s*\{\s*$/.test(line)) {
|
|
1564
|
+
removedSourceMediaStart = true;
|
|
1565
|
+
return false;
|
|
1566
|
+
}
|
|
1567
|
+
if (/^\s*\}\s*\/\*\s*source\([^)]*\)\s*\*\/\s*$/.test(line)) return false;
|
|
1568
|
+
if (removedSourceMediaStart && /^\s*\}\s*$/.test(line)) {
|
|
1569
|
+
removedSourceMediaStart = false;
|
|
1570
|
+
return false;
|
|
1571
|
+
}
|
|
1572
|
+
return true;
|
|
1573
|
+
}).join("\n");
|
|
1574
|
+
}
|
|
1575
|
+
function stripLeadingTailwindSourceMediaCloseFragment(source) {
|
|
1576
|
+
return source.replace(/^\s*\}\s*(?:\n|$)/, "");
|
|
1577
|
+
}
|
|
1578
|
+
function stripUnmatchedTailwindSourceMediaCloseFragments(source) {
|
|
1579
|
+
try {
|
|
1580
|
+
_weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1581
|
+
return source;
|
|
1582
|
+
} catch {
|
|
1583
|
+
return stripLeadingTailwindSourceMediaCloseFragment(source).replace(/\s*\}\s*$/, "");
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
function splitUserCssLayerBlocks(source) {
|
|
1587
|
+
if (!source.includes("@layer")) return {
|
|
1588
|
+
layer: "",
|
|
1589
|
+
rest: source
|
|
1590
|
+
};
|
|
1591
|
+
try {
|
|
1592
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1593
|
+
const layerRoot = _weapp_tailwindcss_postcss.postcss.root();
|
|
1594
|
+
const restRoot = _weapp_tailwindcss_postcss.postcss.root();
|
|
1595
|
+
for (const node of root.nodes) (node.type === "atrule" && node.name === "layer" && node.nodes?.length ? layerRoot : restRoot).append(node.clone());
|
|
1596
|
+
return {
|
|
1597
|
+
layer: layerRoot.toString(),
|
|
1598
|
+
rest: restRoot.toString()
|
|
1599
|
+
};
|
|
1600
|
+
} catch {
|
|
1601
|
+
return {
|
|
1602
|
+
layer: source,
|
|
1603
|
+
rest: ""
|
|
1604
|
+
};
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
function hasUserCssLayerBlocks(source) {
|
|
1608
|
+
if (!source.includes("@layer")) return false;
|
|
1609
|
+
try {
|
|
1610
|
+
let hasLayerBlock = false;
|
|
1611
|
+
_weapp_tailwindcss_postcss.postcss.parse(source).walkAtRules("layer", (node) => {
|
|
1612
|
+
if (node.nodes?.length) hasLayerBlock = true;
|
|
1613
|
+
});
|
|
1614
|
+
return hasLayerBlock;
|
|
1615
|
+
} catch {
|
|
1616
|
+
return true;
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
function collectUserLayerSelectors(source) {
|
|
1620
|
+
const selectors = /* @__PURE__ */ new Set();
|
|
1621
|
+
try {
|
|
1622
|
+
_weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
|
|
1623
|
+
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
1624
|
+
const normalized = selector.trim();
|
|
1625
|
+
if (normalized) selectors.add(normalized);
|
|
1626
|
+
}
|
|
1627
|
+
});
|
|
1628
|
+
} catch {}
|
|
1629
|
+
return selectors;
|
|
1630
|
+
}
|
|
1631
|
+
function matchesUserLayerSelector(selector, userLayerSelector) {
|
|
1632
|
+
if (selector === userLayerSelector) return true;
|
|
1633
|
+
if (!selector.startsWith(userLayerSelector)) return false;
|
|
1634
|
+
const next = selector[userLayerSelector.length];
|
|
1635
|
+
return next === ":" || next === "[";
|
|
1636
|
+
}
|
|
1637
|
+
function extractGeneratedCssForUserLayerSelectors(css, userLayerSource) {
|
|
1638
|
+
const selectors = collectUserLayerSelectors(userLayerSource);
|
|
1639
|
+
if (selectors.size === 0) return {
|
|
1640
|
+
layer: "",
|
|
1641
|
+
rest: css
|
|
1642
|
+
};
|
|
1643
|
+
try {
|
|
1644
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1645
|
+
const layerRoot = _weapp_tailwindcss_postcss.postcss.root();
|
|
1646
|
+
const selectorList = [...selectors];
|
|
1647
|
+
root.walkRules((rule) => {
|
|
1648
|
+
if ((rule.selectors ?? [rule.selector]).some((selector) => selectorList.some((userSelector) => matchesUserLayerSelector(selector.trim(), userSelector)))) {
|
|
1649
|
+
layerRoot.append(rule.clone());
|
|
1650
|
+
rule.remove();
|
|
1651
|
+
}
|
|
1652
|
+
});
|
|
1653
|
+
return {
|
|
1654
|
+
layer: layerRoot.toString(),
|
|
1655
|
+
rest: root.toString()
|
|
1656
|
+
};
|
|
1657
|
+
} catch {
|
|
1658
|
+
return {
|
|
1659
|
+
layer: "",
|
|
1660
|
+
rest: css
|
|
1661
|
+
};
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
function normalizeGeneratedSelector(selector) {
|
|
1665
|
+
return selector.replace(/:not\(#\\#\)/g, "").trim();
|
|
1666
|
+
}
|
|
1667
|
+
function collectApplyOnlySourceSelectors(source) {
|
|
1668
|
+
const selectors = /* @__PURE__ */ new Set();
|
|
1669
|
+
try {
|
|
1670
|
+
_weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
|
|
1671
|
+
if (!rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) return;
|
|
1672
|
+
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
1673
|
+
const normalized = normalizeGeneratedSelector(selector);
|
|
1674
|
+
if (normalized) selectors.add(normalized);
|
|
1675
|
+
}
|
|
1676
|
+
});
|
|
1677
|
+
} catch {}
|
|
1678
|
+
return selectors;
|
|
1679
|
+
}
|
|
1680
|
+
function hasOnlyApplyBackedSourceRules(source) {
|
|
1681
|
+
let hasApplyRule = false;
|
|
1682
|
+
let hasNonApplyRule = false;
|
|
1683
|
+
try {
|
|
1684
|
+
_weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
|
|
1685
|
+
if (rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) hasApplyRule = true;
|
|
1686
|
+
else hasNonApplyRule = true;
|
|
1687
|
+
});
|
|
1688
|
+
} catch {
|
|
1689
|
+
return false;
|
|
1690
|
+
}
|
|
1691
|
+
return hasApplyRule && !hasNonApplyRule;
|
|
1692
|
+
}
|
|
1693
|
+
function filterApplyOnlyGeneratedCss(css, source) {
|
|
1694
|
+
const selectors = collectApplyOnlySourceSelectors(source);
|
|
1695
|
+
if (selectors.size === 0) return css;
|
|
1696
|
+
const selectorList = [...selectors];
|
|
1697
|
+
try {
|
|
1698
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1699
|
+
root.walkRules((rule) => {
|
|
1700
|
+
const isApplySelector = (rule.selectors ?? [rule.selector]).some((selector) => {
|
|
1701
|
+
const normalized = normalizeGeneratedSelector(selector);
|
|
1702
|
+
return selectorList.some((sourceSelector) => {
|
|
1703
|
+
if (normalized === sourceSelector) return true;
|
|
1704
|
+
if (!normalized.startsWith(sourceSelector)) return false;
|
|
1705
|
+
const next = normalized[sourceSelector.length];
|
|
1706
|
+
return next === ":" || next === "[" || next === ".";
|
|
1707
|
+
});
|
|
1708
|
+
});
|
|
1709
|
+
const isVariableRule = rule.nodes?.some((node) => node.type === "decl" && node.prop.startsWith("--"));
|
|
1710
|
+
if (!isApplySelector && !isVariableRule) rule.remove();
|
|
1711
|
+
});
|
|
1712
|
+
root.walkAtRules((rule) => {
|
|
1713
|
+
if (rule.nodes !== void 0 && rule.nodes.length === 0) rule.remove();
|
|
1714
|
+
});
|
|
1715
|
+
return root.toString();
|
|
1716
|
+
} catch {
|
|
1717
|
+
return css;
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
function shouldFilterApplyOnlyGeneratedCss(_majorVersion, target, source, options) {
|
|
1721
|
+
return target === "weapp" && require_v4_engine.hasTailwindApplyDirective(source) && !require_v4_engine.hasTailwindRootDirectives(source) && !options.hasGeneratedCss && !options.hasGeneratedMarkers && collectApplyOnlySourceSelectors(source).size > 0 && hasOnlyApplyBackedSourceRules(source);
|
|
1722
|
+
}
|
|
1723
|
+
async function transformGeneratorUserCss(source, options) {
|
|
1724
|
+
if (source.trim().length === 0) return "";
|
|
1725
|
+
if (options.processed) return stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(removeTailwindV4GeneratorAtRules(options.generatorTarget === "weapp" ? removeTailwindV4GeneratedUserCssArtifacts(removeProcessedMiniProgramUnsupportedCss(source, {
|
|
1726
|
+
...options.generatorStyleOptions,
|
|
1727
|
+
...options.cssUserHandlerOptions
|
|
1728
|
+
})) : source)));
|
|
1729
|
+
const cleanedSource = require_v4_engine.removeTailwindSourceDirectives(removeTailwindV4GeneratorAtRules(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source))), { importFallback: options.importFallback });
|
|
1730
|
+
if (cleanedSource.trim().length === 0) return "";
|
|
1731
|
+
const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindApplyAtRules(require_v4_engine.removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(unwrapMiniProgramCascadeLayers(cleanedSource))) : cleanedSource)), { importFallback: options.importFallback })));
|
|
1732
|
+
if (userSource.trim().length === 0) return "";
|
|
1733
|
+
if (isCommentOnlyCss(userSource)) return userSource;
|
|
1734
|
+
if (options.generatorTarget !== "weapp") return userSource;
|
|
1735
|
+
const { css } = await options.styleHandler(userSource, {
|
|
1736
|
+
...options.generatorStyleOptions,
|
|
1737
|
+
...options.cssUserHandlerOptions
|
|
1738
|
+
});
|
|
1739
|
+
return removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(css));
|
|
1740
|
+
}
|
|
1741
|
+
//#endregion
|
|
1742
|
+
//#region src/bundlers/shared/generator-css/legacy-compat.ts
|
|
1743
|
+
const LEGACY_CONTAINER_COMPAT_CSS = [
|
|
1744
|
+
".container {",
|
|
1745
|
+
" width: 100%;",
|
|
1746
|
+
"}",
|
|
1747
|
+
"@media (min-width: 40rem) {",
|
|
1748
|
+
" .container {",
|
|
1749
|
+
" max-width: 40rem;",
|
|
1750
|
+
" }",
|
|
1751
|
+
"}",
|
|
1752
|
+
"@media (min-width: 48rem) {",
|
|
1753
|
+
" .container {",
|
|
1754
|
+
" max-width: 48rem;",
|
|
1755
|
+
" }",
|
|
1756
|
+
"}",
|
|
1757
|
+
"@media (min-width: 64rem) {",
|
|
1758
|
+
" .container {",
|
|
1759
|
+
" max-width: 64rem;",
|
|
1760
|
+
" }",
|
|
1761
|
+
"}",
|
|
1762
|
+
"@media (min-width: 80rem) {",
|
|
1763
|
+
" .container {",
|
|
1764
|
+
" max-width: 80rem;",
|
|
1765
|
+
" }",
|
|
1766
|
+
"}",
|
|
1767
|
+
"@media (min-width: 96rem) {",
|
|
1768
|
+
" .container {",
|
|
1769
|
+
" max-width: 96rem;",
|
|
1770
|
+
" }",
|
|
1771
|
+
"}"
|
|
1772
|
+
].join("\n");
|
|
1773
|
+
const LEGACY_COMPAT_CACHE_LIMIT = 128;
|
|
1774
|
+
const legacyCompatSourceCache = /* @__PURE__ */ new Map();
|
|
1775
|
+
const legacyCompatTransformCache = /* @__PURE__ */ new Map();
|
|
1776
|
+
function setLimitedCacheValue(cache, key, value) {
|
|
1777
|
+
if (cache.size >= LEGACY_COMPAT_CACHE_LIMIT) {
|
|
1778
|
+
const firstKey = cache.keys().next().value;
|
|
1779
|
+
if (firstKey !== void 0) cache.delete(firstKey);
|
|
1780
|
+
}
|
|
1781
|
+
cache.set(key, value);
|
|
1782
|
+
}
|
|
1783
|
+
function createStableJson(value) {
|
|
1784
|
+
if (value === void 0) return "undefined";
|
|
1785
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
1786
|
+
if (Array.isArray(value)) return `[${value.map((item) => createStableJson(item)).join(",")}]`;
|
|
1787
|
+
return `{${Object.keys(value).sort().map((key) => {
|
|
1788
|
+
const record = value;
|
|
1789
|
+
return `${JSON.stringify(key)}:${createStableJson(record[key])}`;
|
|
1790
|
+
}).join(",")}}`;
|
|
1791
|
+
}
|
|
1792
|
+
function createLegacyCompatTransformCacheKey(source, options) {
|
|
1793
|
+
return `${createStableJson(options)}\0${source}`;
|
|
1794
|
+
}
|
|
1795
|
+
function countUnclosedBlocks(source) {
|
|
1796
|
+
let depth = 0;
|
|
1797
|
+
let quote;
|
|
1798
|
+
let inComment = false;
|
|
1799
|
+
let escaped = false;
|
|
1800
|
+
for (let index = 0; index < source.length; index += 1) {
|
|
1801
|
+
const char = source[index];
|
|
1802
|
+
const next = source[index + 1];
|
|
1803
|
+
if (inComment) {
|
|
1804
|
+
if (char === "*" && next === "/") {
|
|
1805
|
+
inComment = false;
|
|
1806
|
+
index += 1;
|
|
1807
|
+
}
|
|
1808
|
+
continue;
|
|
1809
|
+
}
|
|
1810
|
+
if (quote) {
|
|
1811
|
+
if (escaped) {
|
|
1812
|
+
escaped = false;
|
|
1813
|
+
continue;
|
|
1814
|
+
}
|
|
1815
|
+
if (char === "\\") {
|
|
1816
|
+
escaped = true;
|
|
1817
|
+
continue;
|
|
1818
|
+
}
|
|
1819
|
+
if (char === quote) quote = void 0;
|
|
1820
|
+
continue;
|
|
1821
|
+
}
|
|
1822
|
+
if (char === "/" && next === "*") {
|
|
1823
|
+
inComment = true;
|
|
1824
|
+
index += 1;
|
|
1825
|
+
continue;
|
|
1826
|
+
}
|
|
1827
|
+
if (char === "\"" || char === "'") {
|
|
1828
|
+
quote = char;
|
|
1829
|
+
continue;
|
|
1830
|
+
}
|
|
1831
|
+
if (char === "{") depth += 1;
|
|
1832
|
+
else if (char === "}" && depth > 0) depth -= 1;
|
|
1833
|
+
}
|
|
1834
|
+
return depth;
|
|
1835
|
+
}
|
|
1836
|
+
function closeTrailingUnclosedBlocks(source) {
|
|
1837
|
+
try {
|
|
1838
|
+
_weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1839
|
+
return source;
|
|
1840
|
+
} catch (error) {
|
|
1841
|
+
if (error.reason !== "Unclosed block") return source;
|
|
1842
|
+
const unclosedBlocks = countUnclosedBlocks(source);
|
|
1843
|
+
return unclosedBlocks > 0 ? `${source}${"}".repeat(unclosedBlocks)}` : source;
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
function removeTailwindApplyRules(rawSource) {
|
|
1847
|
+
try {
|
|
1848
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(rawSource);
|
|
1849
|
+
let removed = false;
|
|
1850
|
+
root.walkAtRules("apply", (rule) => {
|
|
1851
|
+
const parent = rule.parent;
|
|
1852
|
+
if (parent?.type === "rule") parent.remove();
|
|
1853
|
+
else rule.remove();
|
|
1854
|
+
removed = true;
|
|
1855
|
+
});
|
|
1856
|
+
root.walkAtRules((rule) => {
|
|
1857
|
+
if (rule.nodes && rule.nodes.length === 0) rule.remove();
|
|
1858
|
+
});
|
|
1859
|
+
return removed ? root.toString() : rawSource;
|
|
1860
|
+
} catch {
|
|
1861
|
+
return rawSource;
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
function resolveLegacyCompatCssSource(rawSource) {
|
|
1865
|
+
const cached = legacyCompatSourceCache.get(rawSource);
|
|
1866
|
+
if (cached !== void 0) return cached;
|
|
1867
|
+
const resolved = closeTrailingUnclosedBlocks(removeTailwindV4GeneratedUserCssArtifacts((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(removeTailwindApplyRules(require_v4_engine.removeTailwindSourceDirectives(closeTrailingUnclosedBlocks(require_v4_engine.stripTailwindBanners(rawSource)))))));
|
|
1286
1868
|
setLimitedCacheValue(legacyCompatSourceCache, rawSource, resolved);
|
|
1287
1869
|
return resolved;
|
|
1288
1870
|
}
|
|
@@ -1312,7 +1894,7 @@ function hasContainerConfigToken(rawSource) {
|
|
|
1312
1894
|
}
|
|
1313
1895
|
function hasConfiguredContainerCompat(rawSource, file, cssHandlerOptions) {
|
|
1314
1896
|
if (hasContainerConfigToken(rawSource)) return true;
|
|
1315
|
-
const cssEntrySource =
|
|
1897
|
+
const cssEntrySource = require_v4_engine.resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions));
|
|
1316
1898
|
if (!cssEntrySource?.config) return false;
|
|
1317
1899
|
try {
|
|
1318
1900
|
return /\bcontainer\b/.test((0, node_fs.readFileSync)(cssEntrySource.config, "utf8"));
|
|
@@ -1321,12 +1903,13 @@ function hasConfiguredContainerCompat(rawSource, file, cssHandlerOptions) {
|
|
|
1321
1903
|
}
|
|
1322
1904
|
}
|
|
1323
1905
|
function hasConfiguredContainerCompatSource(source) {
|
|
1906
|
+
if (typeof source.css !== "string") return false;
|
|
1324
1907
|
if (hasContainerConfigToken(source.css)) return true;
|
|
1325
|
-
const cssEntrySource =
|
|
1908
|
+
const cssEntrySource = require_v4_engine.resolveCssEntrySource(source.css, source.base);
|
|
1326
1909
|
if (cssEntrySource?.config) try {
|
|
1327
1910
|
if (/\bcontainer\b/.test((0, node_fs.readFileSync)(cssEntrySource.config, "utf8"))) return true;
|
|
1328
1911
|
} catch {}
|
|
1329
|
-
if ("config" in source && source.config) try {
|
|
1912
|
+
if ("config" in source && typeof source.config === "string") try {
|
|
1330
1913
|
if (/\bcontainer\b/.test((0, node_fs.readFileSync)(source.config, "utf8"))) return true;
|
|
1331
1914
|
} catch {}
|
|
1332
1915
|
return false;
|
|
@@ -1338,7 +1921,7 @@ async function appendLegacyCompatCss(css, rawSource, generatorTarget, styleHandl
|
|
|
1338
1921
|
const resolvedCompatSource = resolveLegacyCompatCssSource(rawSource);
|
|
1339
1922
|
const compatSource = removeGeneratedSelectorCompatCss(generatorTarget === "weapp" ? removeMiniProgramContainerCompatCss(resolvedCompatSource) : resolvedCompatSource, css);
|
|
1340
1923
|
if (compatSource.trim().length === 0) return css;
|
|
1341
|
-
if (generatorTarget !== "weapp") return
|
|
1924
|
+
if (generatorTarget !== "weapp") return require_v4_engine.createCssAppend(css, compatSource);
|
|
1342
1925
|
const styleOptions = {
|
|
1343
1926
|
...cssHandlerOptions,
|
|
1344
1927
|
...generatorStyleOptions
|
|
@@ -1349,9 +1932,9 @@ async function appendLegacyCompatCss(css, rawSource, generatorTarget, styleHandl
|
|
|
1349
1932
|
compatCss = (await styleHandler(compatSource, styleOptions)).css;
|
|
1350
1933
|
setLimitedCacheValue(legacyCompatTransformCache, compatCssCacheKey, compatCss);
|
|
1351
1934
|
}
|
|
1352
|
-
const cleanedCompatCss = collectDedupedPostTransformCompatCss(removeDuplicatedViteMarkers((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(compatCss), css), css);
|
|
1935
|
+
const cleanedCompatCss = collectDedupedPostTransformCompatCss(removeTailwindV4GeneratedUserCssArtifacts(removeDuplicatedViteMarkers((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(compatCss), css)), css);
|
|
1353
1936
|
if (cleanedCompatCss.trim().length === 0) return css;
|
|
1354
|
-
return
|
|
1937
|
+
return require_v4_engine.createCssAppend(css, cleanedCompatCss);
|
|
1355
1938
|
}
|
|
1356
1939
|
async function appendLegacyContainerCompatCss(css, rawSource, file, runtime, configuredContainerCompat, generatorTarget, styleHandler, cssHandlerOptions, generatorStyleOptions) {
|
|
1357
1940
|
if (generatorTarget === "weapp") return css;
|
|
@@ -1370,7 +1953,7 @@ async function appendLegacyContainerCompatCss(css, rawSource, file, runtime, con
|
|
|
1370
1953
|
}
|
|
1371
1954
|
const cleanedCompatCss = collectDedupedPostTransformCompatCss((0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(compatCss), css);
|
|
1372
1955
|
if (cleanedCompatCss.trim().length === 0) return css;
|
|
1373
|
-
return
|
|
1956
|
+
return require_v4_engine.createCssAppend(css, cleanedCompatCss);
|
|
1374
1957
|
}
|
|
1375
1958
|
//#endregion
|
|
1376
1959
|
//#region src/bundlers/shared/generator-css/legacy-units.ts
|
|
@@ -1419,6 +2002,8 @@ function inheritLegacyUnitConvertedDeclarations(css, legacyCss) {
|
|
|
1419
2002
|
//#endregion
|
|
1420
2003
|
//#region src/bundlers/shared/generator-css/local-imports.ts
|
|
1421
2004
|
const REMOTE_IMPORT_RE = /^(?:https?:)?\/\//i;
|
|
2005
|
+
const CSS_STYLE_EXTENSION_RE = /\.(?:css|wxss|acss|ttss|qss|jxss|tyss|scss|sass|less|styl|stylus|pcss|postcss)(?:$|[?#])/i;
|
|
2006
|
+
const SOURCE_STYLE_EXTENSION_RE = /\.(?:css|scss|sass|less|styl|stylus|pcss|postcss)(?:$|[?#])/i;
|
|
1422
2007
|
function createCssSourceOrderAppend(base, extra) {
|
|
1423
2008
|
if (!base) return extra;
|
|
1424
2009
|
if (!extra) return base;
|
|
@@ -1435,7 +2020,7 @@ function isPureLocalCssImportWrapper(css) {
|
|
|
1435
2020
|
for (const node of root.nodes) {
|
|
1436
2021
|
if (node.type === "comment") continue;
|
|
1437
2022
|
if (node.type !== "atrule" || node.name !== "import") return false;
|
|
1438
|
-
const request =
|
|
2023
|
+
const request = require_v4_engine.parseImportRequest(node.params);
|
|
1439
2024
|
if (!request || !isLocalImportRequest(request)) return false;
|
|
1440
2025
|
hasImport = true;
|
|
1441
2026
|
}
|
|
@@ -1452,7 +2037,7 @@ function cleanLocalCssImportWrapperTailwindDirectives(css) {
|
|
|
1452
2037
|
for (const node of root.nodes) {
|
|
1453
2038
|
if (node.type === "comment") continue;
|
|
1454
2039
|
if (node.type === "atrule" && node.name === "import") {
|
|
1455
|
-
const request =
|
|
2040
|
+
const request = require_v4_engine.parseImportRequest(node.params);
|
|
1456
2041
|
if (!request || !isLocalImportRequest(request)) return;
|
|
1457
2042
|
hasLocalImport = true;
|
|
1458
2043
|
continue;
|
|
@@ -1466,13 +2051,13 @@ function cleanLocalCssImportWrapperTailwindDirectives(css) {
|
|
|
1466
2051
|
} catch {
|
|
1467
2052
|
return;
|
|
1468
2053
|
}
|
|
1469
|
-
return hasLocalImport && hasTailwindDirective ? prefixLocalCssImportsWithWebpackIgnore(
|
|
2054
|
+
return hasLocalImport && hasTailwindDirective ? prefixLocalCssImportsWithWebpackIgnore(require_v4_engine.removeTailwindSourceDirectives(css)) : void 0;
|
|
1470
2055
|
}
|
|
1471
2056
|
function prefixLocalCssImportsWithWebpackIgnore(css) {
|
|
1472
2057
|
try {
|
|
1473
2058
|
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1474
2059
|
root.walkAtRules("import", (atRule) => {
|
|
1475
|
-
const request =
|
|
2060
|
+
const request = require_v4_engine.parseImportRequest(atRule.params);
|
|
1476
2061
|
if (request && isLocalImportRequest(request)) atRule.raws.before = `${atRule.raws.before ?? ""}/* webpackIgnore: true */\n`;
|
|
1477
2062
|
});
|
|
1478
2063
|
return root.toString();
|
|
@@ -1487,7 +2072,7 @@ function splitLocalCssImports(source) {
|
|
|
1487
2072
|
let changed = false;
|
|
1488
2073
|
for (const node of [...root.nodes]) {
|
|
1489
2074
|
if (node.type !== "atrule" || node.name !== "import") continue;
|
|
1490
|
-
const request =
|
|
2075
|
+
const request = require_v4_engine.parseImportRequest(node.params);
|
|
1491
2076
|
if (!request || !isLocalImportRequest(request)) continue;
|
|
1492
2077
|
importRoot.append(node.clone());
|
|
1493
2078
|
node.remove();
|
|
@@ -1506,248 +2091,40 @@ function restoreLocalCssImports(css, imports) {
|
|
|
1506
2091
|
if (!imports?.trim()) return css;
|
|
1507
2092
|
return createCssSourceOrderAppend(imports, css);
|
|
1508
2093
|
}
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
const
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
"source",
|
|
1516
|
-
"theme",
|
|
1517
|
-
"utility",
|
|
1518
|
-
"variant"
|
|
1519
|
-
]);
|
|
1520
|
-
function removeTailwindApplyAtRules(source) {
|
|
1521
|
-
if (!source.includes("@apply")) return source;
|
|
1522
|
-
try {
|
|
1523
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1524
|
-
let changed = false;
|
|
1525
|
-
root.walkAtRules("apply", (rule) => {
|
|
1526
|
-
rule.remove();
|
|
1527
|
-
changed = true;
|
|
1528
|
-
});
|
|
1529
|
-
root.walk((node) => {
|
|
1530
|
-
if ("nodes" in node && node.nodes?.length === 0) node.remove();
|
|
1531
|
-
});
|
|
1532
|
-
return changed ? root.toString() : source;
|
|
1533
|
-
} catch {
|
|
1534
|
-
return source;
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
function removeTailwindV4GeneratorAtRules(source) {
|
|
1538
|
-
try {
|
|
1539
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1540
|
-
let changed = false;
|
|
1541
|
-
root.walkAtRules((rule) => {
|
|
1542
|
-
if (!TAILWIND_V4_GENERATOR_AT_RULES.has(rule.name)) return;
|
|
1543
|
-
rule.remove();
|
|
1544
|
-
changed = true;
|
|
1545
|
-
});
|
|
1546
|
-
root.walk((node) => {
|
|
1547
|
-
if ("nodes" in node && node.nodes?.length === 0) {
|
|
1548
|
-
node.remove();
|
|
1549
|
-
changed = true;
|
|
1550
|
-
}
|
|
1551
|
-
});
|
|
1552
|
-
return changed ? root.toString() : source;
|
|
1553
|
-
} catch {
|
|
1554
|
-
return source;
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
function isCommentOnlyCss(source) {
|
|
1558
|
-
try {
|
|
1559
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1560
|
-
return root.nodes.length > 0 && root.nodes.every((node) => node.type === "comment");
|
|
1561
|
-
} catch {
|
|
1562
|
-
return false;
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
function unwrapMiniProgramCascadeLayers(source) {
|
|
1566
|
-
if (!source.includes("@layer")) return source;
|
|
1567
|
-
try {
|
|
1568
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1569
|
-
(0, _weapp_tailwindcss_postcss.removeUnsupportedCascadeLayers)(root);
|
|
1570
|
-
return root.toString();
|
|
1571
|
-
} catch {
|
|
1572
|
-
return source;
|
|
1573
|
-
}
|
|
1574
|
-
}
|
|
1575
|
-
function stripTailwindSourceMediaFragments(source) {
|
|
1576
|
-
let removedSourceMediaStart = false;
|
|
1577
|
-
return source.split(/\r?\n/).filter((line) => {
|
|
1578
|
-
if (/^\s*@media\s+source\([^)]*\)\s*\{\s*$/.test(line)) {
|
|
1579
|
-
removedSourceMediaStart = true;
|
|
1580
|
-
return false;
|
|
1581
|
-
}
|
|
1582
|
-
if (/^\s*\}\s*\/\*\s*source\([^)]*\)\s*\*\/\s*$/.test(line)) return false;
|
|
1583
|
-
if (removedSourceMediaStart && /^\s*\}\s*$/.test(line)) {
|
|
1584
|
-
removedSourceMediaStart = false;
|
|
1585
|
-
return false;
|
|
1586
|
-
}
|
|
1587
|
-
return true;
|
|
1588
|
-
}).join("\n").replace(/\}[^\S\r\n]*(?=@(?:config|source)\b)/g, "");
|
|
1589
|
-
}
|
|
1590
|
-
function stripLeadingTailwindSourceMediaCloseFragment(source) {
|
|
1591
|
-
return source.replace(/^\s*\}\s*(?:\n|$)/, "");
|
|
1592
|
-
}
|
|
1593
|
-
function stripUnmatchedTailwindSourceMediaCloseFragments(source) {
|
|
1594
|
-
try {
|
|
1595
|
-
_weapp_tailwindcss_postcss.postcss.parse(source);
|
|
1596
|
-
return source;
|
|
1597
|
-
} catch {
|
|
1598
|
-
return stripLeadingTailwindSourceMediaCloseFragment(source).replace(/\s*\}\s*$/, "");
|
|
1599
|
-
}
|
|
1600
|
-
}
|
|
1601
|
-
function splitUserCssLayerBlocks(source) {
|
|
1602
|
-
if (!source.includes("@layer")) return {
|
|
1603
|
-
layer: "",
|
|
1604
|
-
rest: source
|
|
2094
|
+
function splitRequestSuffix(request) {
|
|
2095
|
+
const suffixIndexCandidates = [request.indexOf("?"), request.indexOf("#")].filter((index) => index >= 0);
|
|
2096
|
+
const suffixIndex = suffixIndexCandidates.length > 0 ? Math.min(...suffixIndexCandidates) : -1;
|
|
2097
|
+
if (suffixIndex < 0) return {
|
|
2098
|
+
clean: request,
|
|
2099
|
+
suffix: ""
|
|
1605
2100
|
};
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
const restRoot = _weapp_tailwindcss_postcss.postcss.root();
|
|
1610
|
-
for (const node of root.nodes) (node.type === "atrule" && node.name === "layer" && node.nodes?.length ? layerRoot : restRoot).append(node.clone());
|
|
1611
|
-
return {
|
|
1612
|
-
layer: layerRoot.toString(),
|
|
1613
|
-
rest: restRoot.toString()
|
|
1614
|
-
};
|
|
1615
|
-
} catch {
|
|
1616
|
-
return {
|
|
1617
|
-
layer: source,
|
|
1618
|
-
rest: ""
|
|
1619
|
-
};
|
|
1620
|
-
}
|
|
1621
|
-
}
|
|
1622
|
-
function hasUserCssLayerBlocks(source) {
|
|
1623
|
-
if (!source.includes("@layer")) return false;
|
|
1624
|
-
try {
|
|
1625
|
-
let hasLayerBlock = false;
|
|
1626
|
-
_weapp_tailwindcss_postcss.postcss.parse(source).walkAtRules("layer", (node) => {
|
|
1627
|
-
if (node.nodes?.length) hasLayerBlock = true;
|
|
1628
|
-
});
|
|
1629
|
-
return hasLayerBlock;
|
|
1630
|
-
} catch {
|
|
1631
|
-
return true;
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
function collectUserLayerSelectors(source) {
|
|
1635
|
-
const selectors = /* @__PURE__ */ new Set();
|
|
1636
|
-
try {
|
|
1637
|
-
_weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
|
|
1638
|
-
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
1639
|
-
const normalized = selector.trim();
|
|
1640
|
-
if (normalized) selectors.add(normalized);
|
|
1641
|
-
}
|
|
1642
|
-
});
|
|
1643
|
-
} catch {}
|
|
1644
|
-
return selectors;
|
|
1645
|
-
}
|
|
1646
|
-
function matchesUserLayerSelector(selector, userLayerSelector) {
|
|
1647
|
-
if (selector === userLayerSelector) return true;
|
|
1648
|
-
if (!selector.startsWith(userLayerSelector)) return false;
|
|
1649
|
-
const next = selector[userLayerSelector.length];
|
|
1650
|
-
return next === ":" || next === "[";
|
|
1651
|
-
}
|
|
1652
|
-
function extractGeneratedCssForUserLayerSelectors(css, userLayerSource) {
|
|
1653
|
-
const selectors = collectUserLayerSelectors(userLayerSource);
|
|
1654
|
-
if (selectors.size === 0) return {
|
|
1655
|
-
layer: "",
|
|
1656
|
-
rest: css
|
|
2101
|
+
return {
|
|
2102
|
+
clean: request.slice(0, suffixIndex),
|
|
2103
|
+
suffix: request.slice(suffixIndex)
|
|
1657
2104
|
};
|
|
1658
|
-
try {
|
|
1659
|
-
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1660
|
-
const layerRoot = _weapp_tailwindcss_postcss.postcss.root();
|
|
1661
|
-
const selectorList = [...selectors];
|
|
1662
|
-
root.walkRules((rule) => {
|
|
1663
|
-
if ((rule.selectors ?? [rule.selector]).some((selector) => selectorList.some((userSelector) => matchesUserLayerSelector(selector.trim(), userSelector)))) {
|
|
1664
|
-
layerRoot.append(rule.clone());
|
|
1665
|
-
rule.remove();
|
|
1666
|
-
}
|
|
1667
|
-
});
|
|
1668
|
-
return {
|
|
1669
|
-
layer: layerRoot.toString(),
|
|
1670
|
-
rest: root.toString()
|
|
1671
|
-
};
|
|
1672
|
-
} catch {
|
|
1673
|
-
return {
|
|
1674
|
-
layer: "",
|
|
1675
|
-
rest: css
|
|
1676
|
-
};
|
|
1677
|
-
}
|
|
1678
|
-
}
|
|
1679
|
-
function normalizeGeneratedSelector(selector) {
|
|
1680
|
-
return selector.replace(/:not\(#\\#\)/g, "").trim();
|
|
1681
2105
|
}
|
|
1682
|
-
function
|
|
1683
|
-
const
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
if (!rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) return;
|
|
1687
|
-
for (const selector of rule.selectors ?? [rule.selector]) {
|
|
1688
|
-
const normalized = normalizeGeneratedSelector(selector);
|
|
1689
|
-
if (normalized) selectors.add(normalized);
|
|
1690
|
-
}
|
|
1691
|
-
});
|
|
1692
|
-
} catch {}
|
|
1693
|
-
return selectors;
|
|
1694
|
-
}
|
|
1695
|
-
function hasOnlyApplyBackedSourceRules(source) {
|
|
1696
|
-
let hasApplyRule = false;
|
|
1697
|
-
let hasNonApplyRule = false;
|
|
1698
|
-
try {
|
|
1699
|
-
_weapp_tailwindcss_postcss.postcss.parse(source).walkRules((rule) => {
|
|
1700
|
-
if (rule.nodes?.some((node) => node.type === "atrule" && node.name === "apply")) hasApplyRule = true;
|
|
1701
|
-
else hasNonApplyRule = true;
|
|
1702
|
-
});
|
|
1703
|
-
} catch {
|
|
1704
|
-
return false;
|
|
1705
|
-
}
|
|
1706
|
-
return hasApplyRule && !hasNonApplyRule;
|
|
2106
|
+
function normalizeOutputImportRequest(request, styleOutputExtension) {
|
|
2107
|
+
const normalizedStyleOutputExtension = styleOutputExtension?.startsWith(".") ? styleOutputExtension : styleOutputExtension ? `.${styleOutputExtension}` : void 0;
|
|
2108
|
+
const { clean, suffix } = splitRequestSuffix(request.replace(/\\/g, "/"));
|
|
2109
|
+
return `${clean.replace(/^(?:\.\/)?src\//, "./").replace(SOURCE_STYLE_EXTENSION_RE, normalizedStyleOutputExtension ?? ".css")}${suffix}`;
|
|
1707
2110
|
}
|
|
1708
|
-
function
|
|
1709
|
-
|
|
1710
|
-
if (selectors.size === 0) return css;
|
|
1711
|
-
const selectorList = [...selectors];
|
|
2111
|
+
function rewriteLocalCssImportRequestsForOutput(css, options = {}) {
|
|
2112
|
+
if (!css.includes("@import")) return css;
|
|
1712
2113
|
try {
|
|
1713
2114
|
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
root.walkAtRules((rule) => {
|
|
1728
|
-
if (rule.nodes !== void 0 && rule.nodes.length === 0) rule.remove();
|
|
1729
|
-
});
|
|
1730
|
-
return root.toString();
|
|
1731
|
-
} catch {
|
|
1732
|
-
return css;
|
|
1733
|
-
}
|
|
1734
|
-
}
|
|
1735
|
-
function shouldFilterApplyOnlyGeneratedCss(majorVersion, target, source, options) {
|
|
1736
|
-
return majorVersion === 4 && target === "weapp" && require_v3_engine.hasTailwindApplyDirective(source) && !require_v3_engine.hasTailwindRootDirectives(source) && !options.hasGeneratedCss && !options.hasGeneratedMarkers && collectApplyOnlySourceSelectors(source).size > 0 && hasOnlyApplyBackedSourceRules(source);
|
|
1737
|
-
}
|
|
1738
|
-
async function transformGeneratorUserCss(source, options) {
|
|
1739
|
-
if (source.trim().length === 0) return "";
|
|
1740
|
-
const cleanedSource = require_v3_engine.removeTailwindSourceDirectives(removeTailwindV4GeneratorAtRules(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source))), { importFallback: options.importFallback });
|
|
1741
|
-
if (cleanedSource.trim().length === 0) return "";
|
|
1742
|
-
const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindApplyAtRules(require_v3_engine.removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(unwrapMiniProgramCascadeLayers(cleanedSource)) : cleanedSource)), { importFallback: options.importFallback })));
|
|
1743
|
-
if (userSource.trim().length === 0) return "";
|
|
1744
|
-
if (isCommentOnlyCss(userSource)) return userSource;
|
|
1745
|
-
if (options.generatorTarget !== "weapp") return userSource;
|
|
1746
|
-
const { css } = await options.styleHandler(userSource, {
|
|
1747
|
-
...options.generatorStyleOptions,
|
|
1748
|
-
...options.cssUserHandlerOptions
|
|
1749
|
-
});
|
|
1750
|
-
return (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(css);
|
|
2115
|
+
let changed = false;
|
|
2116
|
+
root.walkAtRules("import", (atRule) => {
|
|
2117
|
+
const request = require_v4_engine.parseImportRequest(atRule.params);
|
|
2118
|
+
if (!request || !isLocalImportRequest(request) || !CSS_STYLE_EXTENSION_RE.test(request)) return;
|
|
2119
|
+
const rewritten = normalizeOutputImportRequest(request, options.styleOutputExtension);
|
|
2120
|
+
if (rewritten === request) return;
|
|
2121
|
+
atRule.params = atRule.params.replace(request, rewritten);
|
|
2122
|
+
changed = true;
|
|
2123
|
+
});
|
|
2124
|
+
return changed ? root.toString() : css;
|
|
2125
|
+
} catch {
|
|
2126
|
+
return css;
|
|
2127
|
+
}
|
|
1751
2128
|
}
|
|
1752
2129
|
//#endregion
|
|
1753
2130
|
//#region src/bundlers/shared/generator-css/user-layer-order.ts
|
|
@@ -1896,38 +2273,40 @@ async function runWithConcurrency(factories, limit = Math.min(4, Math.max(1, fac
|
|
|
1896
2273
|
await Promise.all(executing);
|
|
1897
2274
|
return results;
|
|
1898
2275
|
}
|
|
2276
|
+
function resolveTaskConcurrency(defaultLimit = 1) {
|
|
2277
|
+
const configured = Number.parseInt(node_process.default.env["WEAPP_TW_TASK_CONCURRENCY"] ?? "", 10);
|
|
2278
|
+
if (Number.isFinite(configured) && configured > 0) return configured;
|
|
2279
|
+
return defaultLimit;
|
|
2280
|
+
}
|
|
1899
2281
|
function pushConcurrentTaskFactories(queue, factories, limit) {
|
|
1900
2282
|
if (factories.length === 0) return;
|
|
1901
2283
|
queue.push(runWithConcurrency(factories, limit).then(() => void 0));
|
|
1902
2284
|
}
|
|
1903
2285
|
//#endregion
|
|
1904
2286
|
//#region src/bundlers/shared/generator-css/validate.ts
|
|
1905
|
-
const SUPPORTED_GENERATOR_MAJOR_VERSIONS = new Set([3, 4]);
|
|
1906
2287
|
async function validateCandidatesByGenerator(options) {
|
|
1907
|
-
const { candidates, cssHandlerOptions, debug, file, opts, rawSource, runtimeState
|
|
1908
|
-
const majorVersion = runtimeState.
|
|
1909
|
-
if (
|
|
1910
|
-
const
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
const
|
|
1920
|
-
|
|
1921
|
-
if (typeof generator.validateCandidates
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
}));
|
|
1930
|
-
const classSet = new Set(classSets.flatMap((item) => [...item]));
|
|
2288
|
+
const { candidates, cssHandlerOptions, debug, file, opts, rawSource, runtimeState } = options;
|
|
2289
|
+
const majorVersion = runtimeState.tailwindRuntime.majorVersion;
|
|
2290
|
+
if (majorVersion !== 4 || candidates.size === 0) return /* @__PURE__ */ new Set();
|
|
2291
|
+
const classSet = /* @__PURE__ */ new Set();
|
|
2292
|
+
try {
|
|
2293
|
+
const sources = await resolveGeneratorSources(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, {
|
|
2294
|
+
...require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator),
|
|
2295
|
+
bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues
|
|
2296
|
+
}, {
|
|
2297
|
+
cssEntries: opts.cssEntries,
|
|
2298
|
+
runtime: candidates
|
|
2299
|
+
});
|
|
2300
|
+
const classSets = await Promise.all(sources.map(async (source) => {
|
|
2301
|
+
const generator = require_generator.createWeappTailwindcssGenerator(source);
|
|
2302
|
+
if (typeof generator.validateCandidates !== "function") return /* @__PURE__ */ new Set();
|
|
2303
|
+
return generator.validateCandidates(candidates);
|
|
2304
|
+
}));
|
|
2305
|
+
for (const candidate of classSets.flatMap((item) => [...item])) classSet.add(candidate);
|
|
2306
|
+
} catch {}
|
|
2307
|
+
const rawSourceCandidates = collectGeneratedRawSourceCandidates(candidates, rawSource, opts.escapeMap);
|
|
2308
|
+
for (const candidate of rawSourceCandidates) classSet.add(candidate);
|
|
2309
|
+
for (const generatedCss of options.generatedCssSources ?? []) for (const candidate of collectGeneratedRawSourceCandidates(candidates, generatedCss, opts.escapeMap)) classSet.add(candidate);
|
|
1931
2310
|
debug("tailwind generator validated candidates: %s candidates=%d classSet=%d", file, candidates.size, classSet.size);
|
|
1932
2311
|
return classSet;
|
|
1933
2312
|
}
|
|
@@ -1938,38 +2317,97 @@ function resolveGeneratorSourceConcurrency() {
|
|
|
1938
2317
|
if (Number.isFinite(configured) && configured > 0) return configured;
|
|
1939
2318
|
return 1;
|
|
1940
2319
|
}
|
|
2320
|
+
function intersectCandidateSets(left, right) {
|
|
2321
|
+
if (left.size === 0 || right.size === 0) return /* @__PURE__ */ new Set();
|
|
2322
|
+
const [small, large] = left.size <= right.size ? [left, right] : [right, left];
|
|
2323
|
+
const matched = /* @__PURE__ */ new Set();
|
|
2324
|
+
for (const candidate of small) if (large.has(candidate)) matched.add(candidate);
|
|
2325
|
+
return matched;
|
|
2326
|
+
}
|
|
2327
|
+
function collectCssRuleIdentityMarkers(source) {
|
|
2328
|
+
const markers = /* @__PURE__ */ new Set();
|
|
2329
|
+
try {
|
|
2330
|
+
const root = _weapp_tailwindcss_postcss.postcss.parse(source);
|
|
2331
|
+
root.walkRules((rule) => {
|
|
2332
|
+
for (const selector of rule.selectors ?? [rule.selector]) for (const match of selector.matchAll(/\.((?:\\.|[_a-z\u00A0-\uFFFF-])(?:\\.|[\w\u00A0-\uFFFF-])*)/gi)) markers.add(`class:${match[1]}`);
|
|
2333
|
+
});
|
|
2334
|
+
root.walkAtRules("keyframes", (rule) => {
|
|
2335
|
+
if (rule.params) markers.add(`keyframes:${rule.params}`);
|
|
2336
|
+
});
|
|
2337
|
+
} catch {}
|
|
2338
|
+
return markers;
|
|
2339
|
+
}
|
|
2340
|
+
function isCssAlreadyRepresentedByMarkers(css, source) {
|
|
2341
|
+
const sourceMarkers = collectCssRuleIdentityMarkers(source);
|
|
2342
|
+
if (sourceMarkers.size === 0) return false;
|
|
2343
|
+
const cssMarkers = collectCssRuleIdentityMarkers(css);
|
|
2344
|
+
for (const marker of sourceMarkers) if (!cssMarkers.has(marker)) return false;
|
|
2345
|
+
return true;
|
|
2346
|
+
}
|
|
2347
|
+
function mergeGeneratedCssClassSet(classSet, candidates, css, escapeMap) {
|
|
2348
|
+
const merged = new Set(classSet);
|
|
2349
|
+
for (const candidate of collectGeneratedRawSourceCandidates(candidates, css, escapeMap)) merged.add(candidate);
|
|
2350
|
+
return merged;
|
|
2351
|
+
}
|
|
1941
2352
|
async function generateCssByGenerator(options) {
|
|
1942
|
-
const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, debug } = options;
|
|
2353
|
+
const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, userRawSource, userRawSourceProcessed, debug } = options;
|
|
1943
2354
|
const generatorOptions = {
|
|
1944
|
-
...require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator
|
|
2355
|
+
...require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator, {
|
|
2356
|
+
appType: opts.appType,
|
|
2357
|
+
platform: opts.cssOptions?.platform ?? opts.platform,
|
|
2358
|
+
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
2359
|
+
uniAppX: opts.uniAppX
|
|
2360
|
+
}),
|
|
1945
2361
|
bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues
|
|
1946
2362
|
};
|
|
1947
|
-
const
|
|
1948
|
-
|
|
2363
|
+
const generatorBranch = require_generator.resolveGeneratorRuntimeBranch(generatorOptions, {
|
|
2364
|
+
appType: opts.appType,
|
|
2365
|
+
platform: opts.cssOptions?.platform ?? opts.platform,
|
|
2366
|
+
tailwindcssMajorVersion: runtimeState.tailwindRuntime.majorVersion,
|
|
2367
|
+
uniAppX: opts.uniAppX
|
|
2368
|
+
});
|
|
2369
|
+
const majorVersion = runtimeState.tailwindRuntime.majorVersion;
|
|
2370
|
+
if (majorVersion !== 4) throw new Error("weapp-tailwindcss 生成管线仅支持 Tailwind CSS v4。");
|
|
2371
|
+
const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(require_v4_engine.normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })));
|
|
1949
2372
|
const localImportParts = splitLocalCssImports(effectiveRawSource);
|
|
2373
|
+
const localImports = options.restoreLocalCssImports === false ? void 0 : localImportParts?.imports;
|
|
1950
2374
|
const generatorRawSource = localImportParts?.source ?? effectiveRawSource;
|
|
1951
|
-
const
|
|
2375
|
+
const rawUserSource = userRawSource === void 0 ? generatorRawSource : userRawSourceProcessed ? userRawSource : stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(require_v4_engine.normalizeTailwindSourceDirectives(userRawSource, { importFallback: generatorOptions.importFallback })));
|
|
2376
|
+
const userSource = splitLocalCssImports(rawUserSource)?.source ?? rawUserSource;
|
|
2377
|
+
const userCssRawSource = removeTailwindV4GeneratorAtRules(userSource);
|
|
2378
|
+
const generatedUserCssOrderSource = require_v4_engine.hasTailwindGeneratedCss(userSource) ? require_v4_engine.splitTailwindV4GeneratedCssBySourceOrder(userSource, generatorRawSource) : void 0;
|
|
2379
|
+
const generatedUserCssRawSource = generatedUserCssOrderSource ? require_v4_engine.createCssAppend(generatedUserCssOrderSource.before, generatedUserCssOrderSource.after) : require_v4_engine.hasTailwindGeneratedCss(userSource) ? "" : userCssRawSource;
|
|
2380
|
+
const userCssOrderSource = require_v4_engine.GENERATOR_PLACEHOLDER_MARKER_RE.test(userSource) ? userSource : require_v4_engine.hasTailwindGeneratedCss(userSource) ? userSource : generatedUserCssRawSource;
|
|
2381
|
+
const hasDistinctUserRawSource = typeof userRawSource === "string" && normalizeCssSourceForCompare(generatedUserCssRawSource) !== normalizeCssSourceForCompare(generatorRawSource);
|
|
1952
2382
|
const cleanedLocalImportWrapper = cleanLocalCssImportWrapperTailwindDirectives(effectiveRawSource);
|
|
1953
2383
|
if (cleanedLocalImportWrapper !== void 0) return {
|
|
1954
|
-
css:
|
|
2384
|
+
css: require_generator.shouldUseMiniProgramCssBranch(generatorBranch) ? (0, _weapp_tailwindcss_postcss.removeUnsupportedMiniProgramAtRules)(cleanedLocalImportWrapper) : cleanedLocalImportWrapper,
|
|
2385
|
+
classSet: /* @__PURE__ */ new Set(),
|
|
1955
2386
|
target: generatorOptions.target,
|
|
1956
2387
|
source: "generator",
|
|
1957
|
-
dependencies: []
|
|
2388
|
+
dependencies: [],
|
|
2389
|
+
metadata: {
|
|
2390
|
+
file,
|
|
2391
|
+
majorVersion
|
|
2392
|
+
}
|
|
1958
2393
|
};
|
|
1959
2394
|
if (isPureLocalCssImportWrapper(effectiveRawSource)) return;
|
|
1960
|
-
const hasGeneratedCss =
|
|
1961
|
-
const hasSourceDirectives =
|
|
1962
|
-
const hasGeneratedMarkers =
|
|
1963
|
-
|
|
2395
|
+
const hasGeneratedCss = require_v4_engine.hasTailwindGeneratedCss(generatorRawSource);
|
|
2396
|
+
const hasSourceDirectives = require_v4_engine.hasTailwindSourceDirectives(generatorRawSource, { importFallback: generatorOptions.importFallback });
|
|
2397
|
+
const hasGeneratedMarkers = require_v4_engine.hasTailwindGeneratedCssMarkers(generatorRawSource);
|
|
2398
|
+
if (!shouldUseGeneratorForCurrentCss(majorVersion, cssHandlerOptions, {
|
|
2399
|
+
forceGenerator: options.forceGenerator,
|
|
1964
2400
|
hasGeneratedCss,
|
|
1965
2401
|
hasGeneratedMarkers,
|
|
1966
2402
|
hasSourceDirectives,
|
|
1967
|
-
rawSource: generatorRawSource
|
|
1968
|
-
|
|
1969
|
-
|
|
2403
|
+
rawSource: generatorRawSource,
|
|
2404
|
+
runtimeCandidateCount: runtime.size,
|
|
2405
|
+
target: generatorOptions.target,
|
|
2406
|
+
configuredCssSourceCount: options.cssSources?.length
|
|
2407
|
+
})) return;
|
|
1970
2408
|
try {
|
|
1971
2409
|
await runtimeState.readyPromise;
|
|
1972
|
-
const currentCssCandidates =
|
|
2410
|
+
const currentCssCandidates = await (0, _tailwindcss_mangle_engine.extractSourceCandidates)(generatorRawSource, "css", { ...generatorOptions.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: generatorOptions.bareArbitraryValues } });
|
|
1973
2411
|
const isolateCurrentCssCandidates = shouldIsolateCurrentTailwindV4CssCandidates(majorVersion, cssHandlerOptions, {
|
|
1974
2412
|
hasGeneratedCss,
|
|
1975
2413
|
hasGeneratedMarkers,
|
|
@@ -1987,8 +2425,9 @@ async function generateCssByGenerator(options) {
|
|
|
1987
2425
|
const sourceConcurrency = resolveGeneratorSourceConcurrency();
|
|
1988
2426
|
const generated = mergeGeneratorResults((await runWithConcurrency(sources.map((source) => async () => {
|
|
1989
2427
|
const generator = require_generator.createWeappTailwindcssGenerator(source);
|
|
1990
|
-
const sourceEntries = getSourceCandidatesForEntries
|
|
1991
|
-
const
|
|
2428
|
+
const sourceEntries = getSourceCandidatesForEntries ? await resolveGeneratorSourceEntries(source, runtimeState) : void 0;
|
|
2429
|
+
const sourceScopedRuntime = sourceEntries && sourceEntries.length > 0 ? getSourceCandidatesForEntries?.(sourceEntries) : void 0;
|
|
2430
|
+
const scopedRuntime = options.sourceCandidates && sourceScopedRuntime ? intersectCandidateSets(options.sourceCandidates, sourceScopedRuntime) : options.sourceCandidates ?? sourceScopedRuntime;
|
|
1992
2431
|
const isolateCssSource = shouldIsolateScopedCssSource(majorVersion, source, sourceEntries, {
|
|
1993
2432
|
cssHandlerOptions,
|
|
1994
2433
|
target: generatorOptions.target
|
|
@@ -2006,40 +2445,46 @@ async function generateCssByGenerator(options) {
|
|
|
2006
2445
|
majorVersion,
|
|
2007
2446
|
matchedCssSourceFile
|
|
2008
2447
|
}) : runtimeWithCurrentCss;
|
|
2009
|
-
const generatorRuntime =
|
|
2010
|
-
const useIncrementalCache = (majorVersion === 3 || majorVersion === 4) && !(majorVersion === 3 && isolateCssSource);
|
|
2448
|
+
const generatorRuntime = require_generator.shouldUseMiniProgramCssBranch(generatorBranch) ? require_v4_engine.filterUnsupportedMiniProgramTailwindV4Candidates(sourceRuntime) : sourceRuntime;
|
|
2011
2449
|
return generator.generate({
|
|
2012
2450
|
bareArbitraryValues: generatorOptions.bareArbitraryValues,
|
|
2013
2451
|
candidates: generatorRuntime,
|
|
2014
|
-
incrementalCache:
|
|
2452
|
+
incrementalCache: true,
|
|
2015
2453
|
scanSources: shouldScanTailwindV4Sources(majorVersion, generatorOptions.target, generatorRuntime, isolateCssSource),
|
|
2016
2454
|
styleOptions: generatorStyleOptions,
|
|
2017
|
-
tailwindcssV3Compatibility: generatorOptions.tailwindcssV3Compatibility,
|
|
2018
2455
|
target: generatorOptions.target
|
|
2019
2456
|
});
|
|
2020
2457
|
}), sourceConcurrency)).filter((item) => Boolean(item)));
|
|
2021
2458
|
if (!generated) return;
|
|
2022
2459
|
debug("tailwind generator result: %s rawBytes=%d cssBytes=%d candidates=%d", file, generated.rawCss.length, generated.css.length, generated.classSet.size);
|
|
2023
2460
|
if ((generated.target !== "weapp" || !hasUserCssLayerBlocks(generatorRawSource)) && typeof options.previousCss === "string" && typeof generated.incrementalCss === "string") {
|
|
2024
|
-
const incrementalCss =
|
|
2461
|
+
const incrementalCss = require_v4_engine.stripTailwindBanner(generated.incrementalCss);
|
|
2462
|
+
const finalCss = restoreLocalCssImports(incrementalCss.trim().length > 0 ? require_v4_engine.createCssAppend(options.previousCss, finalizeMiniProgramGeneratorCss(incrementalCss, generated.target, majorVersion, opts.cssPreflight, {
|
|
2463
|
+
injectPreflight: false,
|
|
2464
|
+
styleOptions: generatorStyleOptions
|
|
2465
|
+
})) : options.previousCss, localImports);
|
|
2025
2466
|
return {
|
|
2026
|
-
css:
|
|
2027
|
-
|
|
2028
|
-
styleOptions: generatorStyleOptions
|
|
2029
|
-
})) : options.previousCss, localImportParts?.imports),
|
|
2467
|
+
css: finalCss,
|
|
2468
|
+
classSet: mergeGeneratedCssClassSet(generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap),
|
|
2030
2469
|
target: generated.target,
|
|
2031
2470
|
source: "generator",
|
|
2032
2471
|
dependencies: generated.dependencies,
|
|
2033
|
-
incremental: true
|
|
2472
|
+
incremental: true,
|
|
2473
|
+
metadata: {
|
|
2474
|
+
file,
|
|
2475
|
+
majorVersion,
|
|
2476
|
+
rawCss: generated.rawCss
|
|
2477
|
+
}
|
|
2034
2478
|
};
|
|
2035
2479
|
}
|
|
2036
2480
|
const shouldFilterApplyOnlyCss = shouldFilterApplyOnlyGeneratedCss(majorVersion, generated.target, generatorRawSource, {
|
|
2037
2481
|
hasGeneratedCss,
|
|
2038
2482
|
hasGeneratedMarkers
|
|
2039
2483
|
});
|
|
2040
|
-
const
|
|
2484
|
+
const generatedCssSource = generated.target === "web" ? generated.css : require_v4_engine.stripTailwindBanner(generated.css);
|
|
2485
|
+
const generatedCss = shouldFilterApplyOnlyCss ? filterApplyOnlyGeneratedCss(generatedCssSource, generatorRawSource) : generatedCssSource;
|
|
2041
2486
|
const hasMatchedCssSourceFile = sources.some((source) => source.__weappTailwindcssMeta?.matchedCssSourceFile);
|
|
2042
|
-
const orderedExtraCss = hasMatchedCssSourceFile ?
|
|
2487
|
+
const orderedExtraCss = require_v4_engine.splitGeneratorPlaceholderCssBySourceOrder(userCssOrderSource, generated.rawCss) ?? (hasMatchedCssSourceFile ? require_v4_engine.splitTailwindV4GeneratedCssBySourceOrder(userCssOrderSource, generated.rawCss) : splitRawSourceByGeneratedCssOrder(userCssOrderSource, generated.rawCss));
|
|
2043
2488
|
const shouldAppendMatchedCssSourceCompat = !hasMatchedCssSourceFile || orderedExtraCss !== void 0;
|
|
2044
2489
|
if (orderedExtraCss) {
|
|
2045
2490
|
let css = generatedCss;
|
|
@@ -2049,7 +2494,8 @@ async function generateCssByGenerator(options) {
|
|
|
2049
2494
|
generatorStyleOptions,
|
|
2050
2495
|
cssUserHandlerOptions,
|
|
2051
2496
|
styleHandler,
|
|
2052
|
-
importFallback: generatorOptions.importFallback
|
|
2497
|
+
importFallback: generatorOptions.importFallback,
|
|
2498
|
+
processed: userRawSourceProcessed
|
|
2053
2499
|
};
|
|
2054
2500
|
const afterLayerParts = generated.target === "weapp" ? splitUserCssLayerBlocks(orderedExtraCss.after) : {
|
|
2055
2501
|
layer: "",
|
|
@@ -2067,29 +2513,54 @@ async function generateCssByGenerator(options) {
|
|
|
2067
2513
|
const userCss = await transformGeneratorUserCss(userCssRawSource, userCssOptions);
|
|
2068
2514
|
css = createCssSourceOrderAppend$1(css, userCss);
|
|
2069
2515
|
}
|
|
2516
|
+
if (generated.target === "web") {
|
|
2517
|
+
const userCss = await transformGeneratorUserCss(userCssRawSource, userCssOptions);
|
|
2518
|
+
const missingUserCss = isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
|
|
2519
|
+
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2520
|
+
}
|
|
2521
|
+
if (generated.target === "weapp" && isEmptyCssSourceOrderParts(orderedExtraCss) && hasDistinctUserRawSource && !hasGeneratedCss && !hasGeneratedMarkers && !require_v4_engine.hasTailwindApplyDirective(generatedUserCssRawSource)) {
|
|
2522
|
+
const userCss = await transformGeneratorUserCss(generatedUserCssRawSource, userCssOptions);
|
|
2523
|
+
const missingUserCss = isCssAlreadyRepresentedByMarkers(css, generatedUserCssRawSource) ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss) : userCss;
|
|
2524
|
+
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2525
|
+
}
|
|
2070
2526
|
if (generated.target === "weapp" && shouldAppendMatchedCssSourceCompat) {
|
|
2071
2527
|
if (shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
|
|
2072
|
-
if (!shouldFilterApplyOnlyCss) {
|
|
2073
|
-
css = await appendLegacyCompatCss(css,
|
|
2074
|
-
if (!isolateCurrentCssCandidates) css = await appendLegacyContainerCompatCss(css,
|
|
2528
|
+
if (!shouldFilterApplyOnlyCss && !userRawSourceProcessed && !hasGeneratedCss && !hasGeneratedMarkers) {
|
|
2529
|
+
css = await appendLegacyCompatCss(css, generatedUserCssRawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
|
|
2530
|
+
if (!isolateCurrentCssCandidates) css = await appendLegacyContainerCompatCss(css, generatedUserCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
|
|
2075
2531
|
}
|
|
2076
2532
|
} else if (generated.target === "weapp" && shouldFinalizeMarkedUserLayerComponentsCss(file)) css = reorderMarkedUserLayerComponentsCss(css);
|
|
2533
|
+
const finalCss = restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
|
|
2534
|
+
injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {
|
|
2535
|
+
cssHandlerOptions,
|
|
2536
|
+
isolateCurrentCssCandidates,
|
|
2537
|
+
localImports
|
|
2538
|
+
}),
|
|
2539
|
+
styleOptions: generatorStyleOptions
|
|
2540
|
+
}), localImports);
|
|
2077
2541
|
return {
|
|
2078
|
-
css:
|
|
2079
|
-
|
|
2080
|
-
cssHandlerOptions,
|
|
2081
|
-
isolateCurrentCssCandidates,
|
|
2082
|
-
localImports: localImportParts?.imports
|
|
2083
|
-
}),
|
|
2084
|
-
styleOptions: generatorStyleOptions
|
|
2085
|
-
}), localImportParts?.imports),
|
|
2542
|
+
css: finalCss,
|
|
2543
|
+
classSet: mergeGeneratedCssClassSet(generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap),
|
|
2086
2544
|
target: generated.target,
|
|
2087
2545
|
source: "generator",
|
|
2088
|
-
dependencies: generated.dependencies
|
|
2546
|
+
dependencies: generated.dependencies,
|
|
2547
|
+
metadata: {
|
|
2548
|
+
file,
|
|
2549
|
+
majorVersion,
|
|
2550
|
+
rawCss: generated.rawCss
|
|
2551
|
+
}
|
|
2089
2552
|
};
|
|
2090
2553
|
}
|
|
2091
2554
|
debug("tailwind direct css generation prefix mismatch, append transformed bundle css %s", file);
|
|
2092
2555
|
let css = generatedCss;
|
|
2556
|
+
if (generated.target === "weapp" && generatorRawSource.includes("weapp-tailwindcss generator-placeholder") && !hasUserCssLayerBlocks(generatorRawSource)) css = createCssSourceOrderAppend$1(await transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2557
|
+
generatorTarget: generated.target,
|
|
2558
|
+
generatorStyleOptions,
|
|
2559
|
+
cssUserHandlerOptions,
|
|
2560
|
+
styleHandler,
|
|
2561
|
+
importFallback: generatorOptions.importFallback,
|
|
2562
|
+
processed: userRawSourceProcessed
|
|
2563
|
+
}), css);
|
|
2093
2564
|
if (generated.target === "weapp") {
|
|
2094
2565
|
css = inheritLegacyUnitConvertedDeclarations(css, generatorRawSource);
|
|
2095
2566
|
if (hasUserCssLayerBlocks(generatorRawSource)) {
|
|
@@ -2099,9 +2570,10 @@ async function generateCssByGenerator(options) {
|
|
|
2099
2570
|
generatorStyleOptions,
|
|
2100
2571
|
cssUserHandlerOptions,
|
|
2101
2572
|
styleHandler,
|
|
2102
|
-
importFallback: generatorOptions.importFallback
|
|
2573
|
+
importFallback: generatorOptions.importFallback,
|
|
2574
|
+
processed: userRawSourceProcessed
|
|
2103
2575
|
});
|
|
2104
|
-
const layerCss = layerUserCss.trim().length > 0 && !
|
|
2576
|
+
const layerCss = layerUserCss.trim().length > 0 && !require_v4_engine.hasTailwindApplyDirective(layerUserCss) ? {
|
|
2105
2577
|
layer: layerUserCss,
|
|
2106
2578
|
rest: css
|
|
2107
2579
|
} : extractGeneratedCssForUserLayerSelectors(css, layerParts.layer);
|
|
@@ -2112,22 +2584,36 @@ async function generateCssByGenerator(options) {
|
|
|
2112
2584
|
}
|
|
2113
2585
|
}
|
|
2114
2586
|
if (hasMatchedCssSourceFile || generated.target === "web") {
|
|
2115
|
-
if (
|
|
2116
|
-
const userCss = await transformGeneratorUserCss(
|
|
2587
|
+
if (generated.target === "weapp" && !hasGeneratedCss && !hasGeneratedMarkers) {
|
|
2588
|
+
const userCss = await transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2117
2589
|
generatorTarget: generated.target,
|
|
2118
2590
|
generatorStyleOptions,
|
|
2119
2591
|
cssUserHandlerOptions,
|
|
2120
2592
|
styleHandler,
|
|
2121
|
-
importFallback: generatorOptions.importFallback
|
|
2593
|
+
importFallback: generatorOptions.importFallback,
|
|
2594
|
+
processed: userRawSourceProcessed
|
|
2122
2595
|
});
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2596
|
+
const missingUserCss = isCssAlreadyRepresentedByMarkers(css, generatedUserCssRawSource) ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss) : userCss;
|
|
2597
|
+
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2598
|
+
} else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasGeneratedMarkers && !hasGeneratedCss) {
|
|
2599
|
+
const userCss = await transformGeneratorUserCss(removeTailwindV4GeneratedUserCssArtifacts(userCssRawSource), {
|
|
2600
|
+
generatorTarget: generated.target,
|
|
2601
|
+
generatorStyleOptions,
|
|
2602
|
+
cssUserHandlerOptions,
|
|
2603
|
+
styleHandler,
|
|
2604
|
+
importFallback: generatorOptions.importFallback,
|
|
2605
|
+
processed: userRawSourceProcessed
|
|
2606
|
+
});
|
|
2607
|
+
const missingUserCss = (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
|
|
2608
|
+
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2609
|
+
} else if (hasMatchedCssSourceFile && generated.target === "weapp" && hasUserCssLayerBlocks(generatedUserCssRawSource)) {
|
|
2610
|
+
const layerUserCss = await transformGeneratorUserCss(splitUserCssLayerBlocks(generatedUserCssRawSource).layer, {
|
|
2126
2611
|
generatorTarget: generated.target,
|
|
2127
2612
|
generatorStyleOptions,
|
|
2128
2613
|
cssUserHandlerOptions,
|
|
2129
2614
|
styleHandler,
|
|
2130
|
-
importFallback: generatorOptions.importFallback
|
|
2615
|
+
importFallback: generatorOptions.importFallback,
|
|
2616
|
+
processed: userRawSourceProcessed
|
|
2131
2617
|
});
|
|
2132
2618
|
if (layerUserCss.trim().length > 0) {
|
|
2133
2619
|
css = createCssSourceOrderAppend$1(css, wrapUserLayerComponentsCss(layerUserCss));
|
|
@@ -2135,51 +2621,79 @@ async function generateCssByGenerator(options) {
|
|
|
2135
2621
|
}
|
|
2136
2622
|
}
|
|
2137
2623
|
if (hasMatchedCssSourceFile && generated.target === "weapp") {
|
|
2138
|
-
if (!isolateCurrentCssCandidates && !shouldFilterApplyOnlyCss) css = await appendLegacyContainerCompatCss(css,
|
|
2624
|
+
if (!isolateCurrentCssCandidates && !shouldFilterApplyOnlyCss && !userRawSourceProcessed && !hasGeneratedCss && !hasGeneratedMarkers) css = await appendLegacyContainerCompatCss(css, generatedUserCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
|
|
2139
2625
|
}
|
|
2140
2626
|
if (shouldAppendWebBundleCssFallback(generated.target, {
|
|
2141
2627
|
hasSourceDirectives,
|
|
2142
2628
|
hasMatchedCssSourceFile
|
|
2143
2629
|
})) {
|
|
2144
|
-
const userCss = await transformGeneratorUserCss(
|
|
2630
|
+
const userCss = await transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2145
2631
|
generatorTarget: generated.target,
|
|
2146
2632
|
generatorStyleOptions,
|
|
2147
2633
|
cssUserHandlerOptions,
|
|
2148
2634
|
styleHandler,
|
|
2149
|
-
importFallback: generatorOptions.importFallback
|
|
2635
|
+
importFallback: generatorOptions.importFallback,
|
|
2636
|
+
processed: userRawSourceProcessed
|
|
2150
2637
|
});
|
|
2151
|
-
|
|
2638
|
+
const missingUserCss = isCommentOnlyCss(userCss) ? "" : (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss);
|
|
2639
|
+
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2152
2640
|
}
|
|
2641
|
+
const finalCss = restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
|
|
2642
|
+
injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {
|
|
2643
|
+
cssHandlerOptions,
|
|
2644
|
+
isolateCurrentCssCandidates,
|
|
2645
|
+
localImports
|
|
2646
|
+
}),
|
|
2647
|
+
styleOptions: generatorStyleOptions
|
|
2648
|
+
}), localImports);
|
|
2153
2649
|
return {
|
|
2154
|
-
css:
|
|
2155
|
-
|
|
2156
|
-
cssHandlerOptions,
|
|
2157
|
-
isolateCurrentCssCandidates,
|
|
2158
|
-
localImports: localImportParts?.imports
|
|
2159
|
-
}),
|
|
2160
|
-
styleOptions: generatorStyleOptions
|
|
2161
|
-
}), localImportParts?.imports),
|
|
2650
|
+
css: finalCss,
|
|
2651
|
+
classSet: mergeGeneratedCssClassSet(generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap),
|
|
2162
2652
|
target: generated.target,
|
|
2163
2653
|
source: "generator",
|
|
2164
|
-
dependencies: generated.dependencies
|
|
2654
|
+
dependencies: generated.dependencies,
|
|
2655
|
+
metadata: {
|
|
2656
|
+
file,
|
|
2657
|
+
majorVersion,
|
|
2658
|
+
rawCss: generated.rawCss
|
|
2659
|
+
}
|
|
2165
2660
|
};
|
|
2166
2661
|
}
|
|
2167
|
-
if (!shouldFilterApplyOnlyCss) {
|
|
2168
|
-
css = await appendLegacyCompatCss(css,
|
|
2169
|
-
css = await appendLegacyContainerCompatCss(css,
|
|
2662
|
+
if (!shouldFilterApplyOnlyCss && !userRawSourceProcessed && !hasGeneratedCss && !hasGeneratedMarkers) {
|
|
2663
|
+
css = await appendLegacyCompatCss(css, generatedUserCssRawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
|
|
2664
|
+
css = await appendLegacyContainerCompatCss(css, generatedUserCssRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
|
|
2665
|
+
}
|
|
2666
|
+
if (generated.target === "weapp" && hasDistinctUserRawSource && !hasGeneratedCss && !hasGeneratedMarkers && !require_v4_engine.hasTailwindApplyDirective(generatedUserCssRawSource)) {
|
|
2667
|
+
const userCss = await transformGeneratorUserCss(generatedUserCssRawSource, {
|
|
2668
|
+
generatorTarget: generated.target,
|
|
2669
|
+
generatorStyleOptions,
|
|
2670
|
+
cssUserHandlerOptions,
|
|
2671
|
+
styleHandler,
|
|
2672
|
+
importFallback: generatorOptions.importFallback,
|
|
2673
|
+
processed: userRawSourceProcessed
|
|
2674
|
+
});
|
|
2675
|
+
const missingUserCss = isCssAlreadyRepresentedByMarkers(css, generatedUserCssRawSource) ? (0, _weapp_tailwindcss_postcss.filterExistingCssRules)(css, userCss) : userCss;
|
|
2676
|
+
css = createCssSourceOrderAppend$1(css, missingUserCss);
|
|
2170
2677
|
}
|
|
2678
|
+
const finalCss = restoreLocalCssImports(finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight, {
|
|
2679
|
+
injectPreflight: shouldInjectMiniProgramPreflightForGeneratorCss(opts, {
|
|
2680
|
+
cssHandlerOptions,
|
|
2681
|
+
isolateCurrentCssCandidates,
|
|
2682
|
+
localImports
|
|
2683
|
+
}),
|
|
2684
|
+
styleOptions: generatorStyleOptions
|
|
2685
|
+
}), localImports);
|
|
2171
2686
|
return {
|
|
2172
|
-
css:
|
|
2173
|
-
|
|
2174
|
-
cssHandlerOptions,
|
|
2175
|
-
isolateCurrentCssCandidates,
|
|
2176
|
-
localImports: localImportParts?.imports
|
|
2177
|
-
}),
|
|
2178
|
-
styleOptions: generatorStyleOptions
|
|
2179
|
-
}), localImportParts?.imports),
|
|
2687
|
+
css: finalCss,
|
|
2688
|
+
classSet: mergeGeneratedCssClassSet(generated.classSet, runtimeWithCurrentCss, finalCss, opts.escapeMap),
|
|
2180
2689
|
target: generated.target,
|
|
2181
2690
|
source: "generator",
|
|
2182
|
-
dependencies: generated.dependencies
|
|
2691
|
+
dependencies: generated.dependencies,
|
|
2692
|
+
metadata: {
|
|
2693
|
+
file,
|
|
2694
|
+
majorVersion,
|
|
2695
|
+
rawCss: generated.rawCss
|
|
2696
|
+
}
|
|
2183
2697
|
};
|
|
2184
2698
|
} catch (error) {
|
|
2185
2699
|
debug("tailwind direct css generation failed: %s %O", file, error);
|
|
@@ -2280,186 +2794,23 @@ function collectEscapedRuntimeCandidates(source, escapeMap, escapeFragments) {
|
|
|
2280
2794
|
}
|
|
2281
2795
|
return candidates;
|
|
2282
2796
|
}
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
"bottom",
|
|
2293
|
-
"brightness",
|
|
2294
|
-
"caret",
|
|
2295
|
-
"col",
|
|
2296
|
-
"columns",
|
|
2297
|
-
"content",
|
|
2298
|
-
"contrast",
|
|
2299
|
-
"decoration",
|
|
2300
|
-
"delay",
|
|
2301
|
-
"divide",
|
|
2302
|
-
"drop-shadow",
|
|
2303
|
-
"duration",
|
|
2304
|
-
"ease",
|
|
2305
|
-
"fill",
|
|
2306
|
-
"font",
|
|
2307
|
-
"gap",
|
|
2308
|
-
"gradient",
|
|
2309
|
-
"grid",
|
|
2310
|
-
"grayscale",
|
|
2311
|
-
"grow",
|
|
2312
|
-
"h",
|
|
2313
|
-
"hue-rotate",
|
|
2314
|
-
"indent",
|
|
2315
|
-
"inset",
|
|
2316
|
-
"invert",
|
|
2317
|
-
"leading",
|
|
2318
|
-
"left",
|
|
2319
|
-
"list",
|
|
2320
|
-
"m",
|
|
2321
|
-
"max",
|
|
2322
|
-
"mb",
|
|
2323
|
-
"min",
|
|
2324
|
-
"ml",
|
|
2325
|
-
"mr",
|
|
2326
|
-
"mt",
|
|
2327
|
-
"mx",
|
|
2328
|
-
"my",
|
|
2329
|
-
"object",
|
|
2330
|
-
"opacity",
|
|
2331
|
-
"order",
|
|
2332
|
-
"outline",
|
|
2333
|
-
"overflow",
|
|
2334
|
-
"p",
|
|
2335
|
-
"pb",
|
|
2336
|
-
"pl",
|
|
2337
|
-
"pr",
|
|
2338
|
-
"pt",
|
|
2339
|
-
"px",
|
|
2340
|
-
"py",
|
|
2341
|
-
"right",
|
|
2342
|
-
"ring",
|
|
2343
|
-
"rotate",
|
|
2344
|
-
"rounded",
|
|
2345
|
-
"row",
|
|
2346
|
-
"saturate",
|
|
2347
|
-
"scale",
|
|
2348
|
-
"scroll",
|
|
2349
|
-
"sepia",
|
|
2350
|
-
"shadow",
|
|
2351
|
-
"shrink",
|
|
2352
|
-
"skew",
|
|
2353
|
-
"space",
|
|
2354
|
-
"stroke",
|
|
2355
|
-
"text",
|
|
2356
|
-
"top",
|
|
2357
|
-
"tracking",
|
|
2358
|
-
"translate",
|
|
2359
|
-
"underline",
|
|
2360
|
-
"w",
|
|
2361
|
-
"z"
|
|
2362
|
-
]);
|
|
2363
|
-
function isUrlLikeCandidate(candidate) {
|
|
2364
|
-
return candidate.startsWith("//") || candidate.startsWith("http://") || candidate.startsWith("https://");
|
|
2365
|
-
}
|
|
2366
|
-
function getBaseUtilityCandidate(candidate) {
|
|
2367
|
-
let bracketDepth = 0;
|
|
2368
|
-
let lastVariantSeparator = -1;
|
|
2369
|
-
for (let index = 0; index < candidate.length; index++) {
|
|
2370
|
-
const char = candidate[index];
|
|
2371
|
-
if (char === "[") bracketDepth += 1;
|
|
2372
|
-
else if (char === "]") bracketDepth = Math.max(0, bracketDepth - 1);
|
|
2373
|
-
else if (char === ":" && bracketDepth === 0) lastVariantSeparator = index;
|
|
2374
|
-
}
|
|
2375
|
-
let utility = lastVariantSeparator >= 0 ? candidate.slice(lastVariantSeparator + 1) : candidate;
|
|
2376
|
-
if (utility.startsWith("!")) utility = utility.slice(1);
|
|
2377
|
-
if (utility.startsWith("-")) utility = utility.slice(1);
|
|
2378
|
-
return utility;
|
|
2379
|
-
}
|
|
2380
|
-
function getArbitraryUtilityPrefix(utility) {
|
|
2381
|
-
const bracketIndex = utility.indexOf("[");
|
|
2382
|
-
if (bracketIndex <= 0 || !utility.endsWith("]")) return;
|
|
2383
|
-
const prefix = utility.slice(0, bracketIndex).replace(/-$/, "");
|
|
2384
|
-
const firstDash = prefix.indexOf("-");
|
|
2385
|
-
return firstDash >= 0 ? prefix.slice(0, firstDash) : prefix;
|
|
2386
|
-
}
|
|
2387
|
-
function isLikelyTailwindV3ArbitraryUtility(candidate) {
|
|
2388
|
-
const utility = getBaseUtilityCandidate(candidate);
|
|
2389
|
-
if (utility.startsWith("[") && utility.endsWith("]") && utility.includes(":")) return true;
|
|
2390
|
-
const prefix = getArbitraryUtilityPrefix(utility);
|
|
2391
|
-
return Boolean(prefix && TAILWIND_V3_ARBITRARY_UTILITY_PREFIXES.has(prefix));
|
|
2392
|
-
}
|
|
2393
|
-
function isLikelyTailwindV3VariantUtility(candidate) {
|
|
2394
|
-
if (!candidate.includes(":") || isUrlLikeCandidate(candidate)) return false;
|
|
2395
|
-
const utility = getBaseUtilityCandidate(candidate);
|
|
2396
|
-
return /^[!-]?[a-z@[]/.test(utility);
|
|
2397
|
-
}
|
|
2398
|
-
function isLikelyTailwindV3OpacityModifier(candidate) {
|
|
2399
|
-
if (!candidate.includes("/") || isUrlLikeCandidate(candidate)) return false;
|
|
2400
|
-
const utility = getBaseUtilityCandidate(candidate);
|
|
2401
|
-
return /^[!-]?[a-z][\w-]*-\w[\w-]*\/(?:\d+|\[[^\]]+\])$/.test(utility);
|
|
2402
|
-
}
|
|
2403
|
-
function isHighConfidenceV3Candidate(candidate) {
|
|
2404
|
-
return isLikelyTailwindV3ArbitraryUtility(candidate) || isLikelyTailwindV3VariantUtility(candidate) || isLikelyTailwindV3OpacityModifier(candidate);
|
|
2405
|
-
}
|
|
2406
|
-
function isRawCandidateInClassContext(source, start, extension) {
|
|
2407
|
-
if (typeof start !== "number" || start <= 0) return false;
|
|
2408
|
-
const before = source.slice(Math.max(0, start - 200), start);
|
|
2409
|
-
if (extension === "html") return /\bclass\s*=\s*["'][^"']*$/i.test(before);
|
|
2410
|
-
return /\bclass(?:Name)?\s*[:=]\s*["'][^"']*$/i.test(before) || /\.classList\.(?:add|remove|toggle|contains)\([^)]*$/i.test(before);
|
|
2411
|
-
}
|
|
2412
|
-
function resolveQuotedLiteralRange(source, start) {
|
|
2413
|
-
if (typeof start !== "number" || start <= 0) return;
|
|
2414
|
-
let quote;
|
|
2415
|
-
let literalStart = -1;
|
|
2416
|
-
for (let index = start - 1; index >= 0; index--) {
|
|
2417
|
-
const char = source[index];
|
|
2418
|
-
if (char !== "\"" && char !== "'" && char !== "`") continue;
|
|
2419
|
-
quote = char;
|
|
2420
|
-
literalStart = index;
|
|
2421
|
-
break;
|
|
2422
|
-
}
|
|
2423
|
-
if (!quote) return;
|
|
2424
|
-
let escaped = false;
|
|
2425
|
-
for (let index = literalStart + 1; index < source.length; index++) {
|
|
2426
|
-
const char = source[index];
|
|
2427
|
-
if (escaped) {
|
|
2428
|
-
escaped = false;
|
|
2429
|
-
continue;
|
|
2430
|
-
}
|
|
2431
|
-
if (char === "\\") {
|
|
2432
|
-
escaped = true;
|
|
2433
|
-
continue;
|
|
2434
|
-
}
|
|
2435
|
-
if (char === quote) {
|
|
2436
|
-
if (start < index) return {
|
|
2437
|
-
start: literalStart,
|
|
2438
|
-
end: index
|
|
2439
|
-
};
|
|
2440
|
-
return;
|
|
2797
|
+
function collectStrictEscapedRuntimeCandidates(source, escapeMap, escapeFragments) {
|
|
2798
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
2799
|
+
ESCAPED_CLASS_TOKEN_RE.lastIndex = 0;
|
|
2800
|
+
let match = ESCAPED_CLASS_TOKEN_RE.exec(source);
|
|
2801
|
+
while (match) {
|
|
2802
|
+
const token = match[0];
|
|
2803
|
+
if (hasEscapeFragment(token, escapeFragments)) {
|
|
2804
|
+
const restored = (0, _weapp_core_escape.unescape)(token, { map: escapeMap });
|
|
2805
|
+
if (restored !== token && TAILWIND_RESTORED_CANDIDATE_SIGNAL_RE.test(restored) && !/\s/.test(restored)) candidates.add(restored);
|
|
2441
2806
|
}
|
|
2807
|
+
match = ESCAPED_CLASS_TOKEN_RE.exec(source);
|
|
2442
2808
|
}
|
|
2443
|
-
|
|
2444
|
-
function createHighConfidenceLiteralRanges(source, matches) {
|
|
2445
|
-
const ranges = [];
|
|
2446
|
-
for (const match of matches) {
|
|
2447
|
-
const candidate = match?.rawCandidate;
|
|
2448
|
-
if (typeof candidate !== "string" || !isHighConfidenceV3Candidate(candidate)) continue;
|
|
2449
|
-
const range = resolveQuotedLiteralRange(source, match?.start ?? source.indexOf(candidate));
|
|
2450
|
-
if (range) ranges.push(range);
|
|
2451
|
-
}
|
|
2452
|
-
return ranges;
|
|
2453
|
-
}
|
|
2454
|
-
function isRawCandidateInRanges(start, ranges) {
|
|
2455
|
-
return typeof start === "number" && ranges.some((range) => start > range.start && start < range.end);
|
|
2456
|
-
}
|
|
2457
|
-
function isRawCandidateAllowedForV3(source, candidate, start, extension, knownSourceCandidates, highConfidenceLiteralRanges = []) {
|
|
2458
|
-
return isHighConfidenceV3Candidate(candidate) || knownSourceCandidates?.has(candidate) === true || isRawCandidateInClassContext(source, start, extension) || isRawCandidateInRanges(start, highConfidenceLiteralRanges);
|
|
2809
|
+
return candidates;
|
|
2459
2810
|
}
|
|
2460
2811
|
//#endregion
|
|
2461
2812
|
//#region src/bundlers/vite/incremental-runtime-class-set.ts
|
|
2462
|
-
const debug =
|
|
2813
|
+
const debug = require_context.createDebug("[vite:runtime-set] ");
|
|
2463
2814
|
function createExtractOptions(context, source, bareArbitraryValues) {
|
|
2464
2815
|
return {
|
|
2465
2816
|
cwd: context.projectRoot,
|
|
@@ -2501,8 +2852,8 @@ function createNonSourceBaseClassSet(baseClassSet, candidateCountByClass) {
|
|
|
2501
2852
|
}
|
|
2502
2853
|
function createBundleRuntimeClassSetManager(options = {}) {
|
|
2503
2854
|
const customExtractCandidates = options.extractCandidates;
|
|
2504
|
-
const extractCandidates = customExtractCandidates ??
|
|
2505
|
-
const extractRawCandidates = options.extractRawCandidates ??
|
|
2855
|
+
const extractCandidates = customExtractCandidates ?? _tailwindcss_mangle_engine.extractValidCandidates;
|
|
2856
|
+
const extractRawCandidates = options.extractRawCandidates ?? _tailwindcss_mangle_engine.extractRawCandidatesWithPositions;
|
|
2506
2857
|
const escapeMap = options.escapeMap ?? _weapp_core_escape.MappingChars2String;
|
|
2507
2858
|
const escapeFragments = createEscapeFragments(escapeMap);
|
|
2508
2859
|
let baseClassSet = /* @__PURE__ */ new Set();
|
|
@@ -2521,25 +2872,21 @@ function createBundleRuntimeClassSetManager(options = {}) {
|
|
|
2521
2872
|
validationContext = void 0;
|
|
2522
2873
|
designSystemPromise = void 0;
|
|
2523
2874
|
}
|
|
2524
|
-
async function resolveValidationContextCached(
|
|
2525
|
-
if (!validationContext) validationContext = await
|
|
2875
|
+
async function resolveValidationContextCached(runtime) {
|
|
2876
|
+
if (!validationContext) validationContext = await require_v4_engine.resolveTailwindV4SourceFromRuntime(runtime);
|
|
2526
2877
|
return validationContext;
|
|
2527
2878
|
}
|
|
2528
2879
|
async function loadDesignSystem(context) {
|
|
2529
|
-
if (!designSystemPromise) designSystemPromise = (0,
|
|
2880
|
+
if (!designSystemPromise) designSystemPromise = (0, _tailwindcss_mangle_engine.loadTailwindV4DesignSystem)(context);
|
|
2530
2881
|
return designSystemPromise;
|
|
2531
2882
|
}
|
|
2532
2883
|
function populateCandidateValidityCacheFromDesignSystem(designSystem, unknownCandidates) {
|
|
2533
|
-
const validCandidates = (0,
|
|
2884
|
+
const validCandidates = (0, _tailwindcss_mangle_engine.resolveValidTailwindV4Candidates)(designSystem, unknownCandidates, { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } });
|
|
2534
2885
|
for (const candidate of unknownCandidates) candidateValidityCache.set(candidate, validCandidates.has(candidate));
|
|
2535
2886
|
}
|
|
2536
|
-
async function validateUnknownCandidates(
|
|
2887
|
+
async function validateUnknownCandidates(runtime, unknownCandidates) {
|
|
2537
2888
|
if (unknownCandidates.size === 0) return;
|
|
2538
|
-
|
|
2539
|
-
for (const candidate of unknownCandidates) candidateValidityCache.set(candidate, true);
|
|
2540
|
-
return;
|
|
2541
|
-
}
|
|
2542
|
-
const context = await resolveValidationContextCached(patcher);
|
|
2889
|
+
const context = await resolveValidationContextCached(runtime);
|
|
2543
2890
|
if (!customExtractCandidates) try {
|
|
2544
2891
|
populateCandidateValidityCacheFromDesignSystem(await loadDesignSystem(context), unknownCandidates);
|
|
2545
2892
|
return;
|
|
@@ -2552,23 +2899,19 @@ function createBundleRuntimeClassSetManager(options = {}) {
|
|
|
2552
2899
|
const validCandidates = new Set(await extractCandidates(createExtractOptions(context, source, options.bareArbitraryValues)));
|
|
2553
2900
|
for (const candidate of unknownCandidates) candidateValidityCache.set(candidate, validCandidates.has(candidate));
|
|
2554
2901
|
}
|
|
2555
|
-
async function extractEntryRawCandidates(entry,
|
|
2902
|
+
async function extractEntryRawCandidates(entry, _runtime, _knownSourceCandidates) {
|
|
2556
2903
|
const extension = resolveEntryExtension(entry);
|
|
2557
2904
|
const matches = options.bareArbitraryValues === void 0 || options.bareArbitraryValues === false ? await extractRawCandidates(entry.source, extension) : await extractRawCandidates(entry.source, extension, { bareArbitraryValues: options.bareArbitraryValues });
|
|
2558
|
-
const highConfidenceLiteralRanges = patcher.majorVersion === 3 && !customExtractCandidates ? createHighConfidenceLiteralRanges(entry.source, matches) : [];
|
|
2559
2905
|
const candidates = /* @__PURE__ */ new Set();
|
|
2560
2906
|
for (const match of matches) {
|
|
2561
2907
|
const candidate = match?.rawCandidate;
|
|
2562
|
-
if (typeof candidate === "string" && candidate.length > 0)
|
|
2563
|
-
if (patcher.majorVersion === 3 && !customExtractCandidates && !isRawCandidateAllowedForV3(entry.source, candidate, match.start, extension, knownSourceCandidates, highConfidenceLiteralRanges)) continue;
|
|
2564
|
-
candidates.add(candidate);
|
|
2565
|
-
}
|
|
2908
|
+
if (typeof candidate === "string" && candidate.length > 0) candidates.add(candidate);
|
|
2566
2909
|
}
|
|
2567
|
-
|
|
2910
|
+
for (const candidate of collectEscapedRuntimeCandidates(entry.source, escapeMap, escapeFragments)) candidates.add(candidate);
|
|
2568
2911
|
return candidates;
|
|
2569
2912
|
}
|
|
2570
|
-
async function sync(
|
|
2571
|
-
const nextSignature =
|
|
2913
|
+
async function sync(runtime, snapshot, options = {}) {
|
|
2914
|
+
const nextSignature = require_tailwindcss.getRuntimeClassSetSignature(runtime) ?? "runtime:missing";
|
|
2572
2915
|
const runtimeEntries = createRuntimeEntries(snapshot);
|
|
2573
2916
|
const runtimeEntriesByFile = new Map(runtimeEntries.map((entry) => [entry.file, entry]));
|
|
2574
2917
|
const currentRuntimeFiles = new Set(runtimeEntriesByFile.keys());
|
|
@@ -2593,14 +2936,14 @@ function createBundleRuntimeClassSetManager(options = {}) {
|
|
|
2593
2936
|
}
|
|
2594
2937
|
const rawCandidatesByFile = /* @__PURE__ */ new Map();
|
|
2595
2938
|
const unknownCandidates = /* @__PURE__ */ new Set();
|
|
2596
|
-
|
|
2939
|
+
for (const file of changedRuntimeFiles) {
|
|
2597
2940
|
const entry = runtimeEntriesByFile.get(file);
|
|
2598
|
-
if (!entry)
|
|
2599
|
-
const candidates = await extractEntryRawCandidates(entry,
|
|
2941
|
+
if (!entry) continue;
|
|
2942
|
+
const candidates = await extractEntryRawCandidates(entry, runtime, nextBaseClassSet);
|
|
2600
2943
|
rawCandidatesByFile.set(file, candidates);
|
|
2601
2944
|
for (const candidate of candidates) if (!candidateValidityCache.has(candidate)) unknownCandidates.add(candidate);
|
|
2602
|
-
}
|
|
2603
|
-
await validateUnknownCandidates(
|
|
2945
|
+
}
|
|
2946
|
+
await validateUnknownCandidates(runtime, unknownCandidates);
|
|
2604
2947
|
let rawCandidateCount = 0;
|
|
2605
2948
|
for (const file of changedRuntimeFiles) {
|
|
2606
2949
|
const nextRawCandidates = rawCandidatesByFile.get(file);
|
|
@@ -2630,6 +2973,52 @@ function createBundleRuntimeClassSetManager(options = {}) {
|
|
|
2630
2973
|
};
|
|
2631
2974
|
}
|
|
2632
2975
|
//#endregion
|
|
2976
|
+
//#region src/tailwindcss/candidates.ts
|
|
2977
|
+
const SCRIPT_SOURCE_CANDIDATE_EXTENSIONS = new Set([
|
|
2978
|
+
"js",
|
|
2979
|
+
"jsx",
|
|
2980
|
+
"mjs",
|
|
2981
|
+
"cjs",
|
|
2982
|
+
"ts",
|
|
2983
|
+
"tsx",
|
|
2984
|
+
"mts",
|
|
2985
|
+
"cts"
|
|
2986
|
+
]);
|
|
2987
|
+
async function extractCandidatesFromSource(source, extension, options = {}) {
|
|
2988
|
+
const candidates = options.extractor ? new Set(await options.extractor(source, extension)) : new Set(await (0, _tailwindcss_mangle_engine.extractSourceCandidates)(source, extension, { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } }));
|
|
2989
|
+
const scriptCandidates = await extractScriptStringCandidates(source, extension, options);
|
|
2990
|
+
for (const candidate of scriptCandidates) candidates.add(candidate);
|
|
2991
|
+
return candidates;
|
|
2992
|
+
}
|
|
2993
|
+
async function extractScriptStringCandidates(source, extension, options) {
|
|
2994
|
+
if (!SCRIPT_SOURCE_CANDIDATE_EXTENSIONS.has(extension)) return [];
|
|
2995
|
+
const values = /* @__PURE__ */ new Set();
|
|
2996
|
+
try {
|
|
2997
|
+
require_context.traverse(require_context.babelParse(source, {
|
|
2998
|
+
cache: true,
|
|
2999
|
+
cacheKey: `source-candidates:${extension}`,
|
|
3000
|
+
plugins: ["jsx", "typescript"],
|
|
3001
|
+
sourceType: "unambiguous"
|
|
3002
|
+
}), {
|
|
3003
|
+
noScope: true,
|
|
3004
|
+
StringLiteral(path) {
|
|
3005
|
+
values.add(path.node.value);
|
|
3006
|
+
},
|
|
3007
|
+
TemplateElement(path) {
|
|
3008
|
+
values.add(path.node.value.raw);
|
|
3009
|
+
}
|
|
3010
|
+
});
|
|
3011
|
+
} catch {
|
|
3012
|
+
return [];
|
|
3013
|
+
}
|
|
3014
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
3015
|
+
for (const value of values) {
|
|
3016
|
+
const extractedCandidates = options.extractor ? await options.extractor(value, "html") : await (0, _tailwindcss_mangle_engine.extractSourceCandidates)(value, "html", { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } });
|
|
3017
|
+
for (const candidate of extractedCandidates) candidates.add(candidate);
|
|
3018
|
+
}
|
|
3019
|
+
return candidates;
|
|
3020
|
+
}
|
|
3021
|
+
//#endregion
|
|
2633
3022
|
//#region src/bundlers/vite/source-candidates/scan-root.ts
|
|
2634
3023
|
const TAILWIND_V4_IGNORED_CONTENT_DIRS = [
|
|
2635
3024
|
".git",
|
|
@@ -2678,7 +3067,7 @@ function resolveOutDirIgnorePattern(root, outDir) {
|
|
|
2678
3067
|
if (!outDir) return;
|
|
2679
3068
|
const relative = node_path.default.relative(root, node_path.default.resolve(root, outDir));
|
|
2680
3069
|
if (!relative || relative.startsWith("..") || node_path.default.isAbsolute(relative)) return;
|
|
2681
|
-
return `${
|
|
3070
|
+
return `${require_v4_engine.toPosixPath(relative)}/**`;
|
|
2682
3071
|
}
|
|
2683
3072
|
function normalizeScanEntries(root, entries, outDirIgnore) {
|
|
2684
3073
|
const hasPositiveEntry = entries?.some((entry) => !entry.negated) === true;
|
|
@@ -2729,7 +3118,7 @@ function resolveSourceCandidateScanFiles(options) {
|
|
|
2729
3118
|
const outDirIgnore = resolveOutDirIgnorePattern(resolvedRoot, options.outDir);
|
|
2730
3119
|
const scanEntries = normalizeScanEntries(resolvedRoot, options.entries, outDirIgnore);
|
|
2731
3120
|
const ignoredSources = createDefaultIgnoredSources(resolvedRoot, outDirIgnore, options.entries, options.explicit);
|
|
2732
|
-
return (0,
|
|
3121
|
+
return (0, _tailwindcss_mangle_engine.resolveProjectSourceFiles)({
|
|
2733
3122
|
cwd: resolvedRoot,
|
|
2734
3123
|
...scanEntries === void 0 ? {} : { sources: scanEntries },
|
|
2735
3124
|
...ignoredSources.length > 0 ? { ignoredSources } : {},
|
|
@@ -2737,81 +3126,11 @@ function resolveSourceCandidateScanFiles(options) {
|
|
|
2737
3126
|
});
|
|
2738
3127
|
}
|
|
2739
3128
|
//#endregion
|
|
2740
|
-
//#region src/bundlers/vite/source-candidates/script.ts
|
|
2741
|
-
const SCRIPT_SOURCE_CANDIDATE_EXTENSIONS = new Set([
|
|
2742
|
-
"js",
|
|
2743
|
-
"jsx",
|
|
2744
|
-
"mjs",
|
|
2745
|
-
"cjs",
|
|
2746
|
-
"ts",
|
|
2747
|
-
"tsx",
|
|
2748
|
-
"mts",
|
|
2749
|
-
"cts"
|
|
2750
|
-
]);
|
|
2751
|
-
async function extractScriptStringCandidates(source, extension, options) {
|
|
2752
|
-
if (!SCRIPT_SOURCE_CANDIDATE_EXTENSIONS.has(extension)) return [];
|
|
2753
|
-
const values = /* @__PURE__ */ new Set();
|
|
2754
|
-
try {
|
|
2755
|
-
require_precheck.traverse(require_precheck.babelParse(source, {
|
|
2756
|
-
cache: true,
|
|
2757
|
-
cacheKey: `vite-source-candidates:${extension}`,
|
|
2758
|
-
plugins: ["jsx", "typescript"],
|
|
2759
|
-
sourceType: "unambiguous"
|
|
2760
|
-
}), {
|
|
2761
|
-
noScope: true,
|
|
2762
|
-
StringLiteral(path) {
|
|
2763
|
-
values.add(path.node.value);
|
|
2764
|
-
},
|
|
2765
|
-
TemplateElement(path) {
|
|
2766
|
-
values.add(path.node.value.raw);
|
|
2767
|
-
}
|
|
2768
|
-
});
|
|
2769
|
-
} catch {
|
|
2770
|
-
return [];
|
|
2771
|
-
}
|
|
2772
|
-
const candidates = /* @__PURE__ */ new Set();
|
|
2773
|
-
for (const value of values) {
|
|
2774
|
-
const extractedCandidates = options.extractor ? await options.extractor(value, "html") : await (0, tailwindcss_patch.extractSourceCandidates)(value, "html", { ...options.bareArbitraryValues === void 0 ? {} : { bareArbitraryValues: options.bareArbitraryValues } });
|
|
2775
|
-
for (const candidate of extractedCandidates) candidates.add(candidate);
|
|
2776
|
-
}
|
|
2777
|
-
return candidates;
|
|
2778
|
-
}
|
|
2779
|
-
//#endregion
|
|
2780
|
-
//#region src/bundlers/vite/source-candidates/tailwind-v3-default-extractor.ts
|
|
2781
|
-
const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
2782
|
-
const TAILWIND_V3_HTML_TOKEN_CANDIDATES = new Set([
|
|
2783
|
-
"/block",
|
|
2784
|
-
"/div",
|
|
2785
|
-
"/span",
|
|
2786
|
-
"/template",
|
|
2787
|
-
"/text",
|
|
2788
|
-
"/view",
|
|
2789
|
-
"class",
|
|
2790
|
-
"className",
|
|
2791
|
-
"div",
|
|
2792
|
-
"hover-class",
|
|
2793
|
-
"span",
|
|
2794
|
-
"template",
|
|
2795
|
-
"text",
|
|
2796
|
-
"view"
|
|
2797
|
-
]);
|
|
2798
|
-
function createTailwindV3DefaultExtractor() {
|
|
2799
|
-
try {
|
|
2800
|
-
const defaultExtractorModule = require$1("tailwindcss/lib/lib/defaultExtractor");
|
|
2801
|
-
const resolveConfigModule = require$1("tailwindcss/resolveConfig");
|
|
2802
|
-
const resolveConfig = resolveConfigModule.default ?? resolveConfigModule;
|
|
2803
|
-
const extractor = (defaultExtractorModule.defaultExtractor ?? defaultExtractorModule.default ?? defaultExtractorModule)({ tailwindConfig: resolveConfig({ content: [] }) });
|
|
2804
|
-
return (source) => new Set(extractor(source).filter((candidate) => !TAILWIND_V3_HTML_TOKEN_CANDIDATES.has(candidate)));
|
|
2805
|
-
} catch {
|
|
2806
|
-
return;
|
|
2807
|
-
}
|
|
2808
|
-
}
|
|
2809
|
-
//#endregion
|
|
2810
3129
|
//#region src/bundlers/vite/source-candidates.ts
|
|
2811
3130
|
const CLEAN_URL_RE = /[?#].*$/;
|
|
2812
3131
|
const sourceCandidateContentCache = new lru_cache.LRUCache({ max: 128 });
|
|
2813
3132
|
function cleanUrl(id) {
|
|
2814
|
-
return
|
|
3133
|
+
return require_v4_engine.resolveSourceScanPath(id.replace(CLEAN_URL_RE, ""));
|
|
2815
3134
|
}
|
|
2816
3135
|
function resolveSourceCandidateExtension(id) {
|
|
2817
3136
|
const normalized = cleanUrl(id);
|
|
@@ -2821,13 +3140,10 @@ function createSourceCandidateContentCacheKey(extension, source, bareArbitraryVa
|
|
|
2821
3140
|
return `${extension}\0${JSON.stringify(bareArbitraryValues ?? false)}\0${extractor ? "custom" : "default"}\0${(0, _weapp_tailwindcss_shared_node.md5)(source)}`;
|
|
2822
3141
|
}
|
|
2823
3142
|
async function extractCandidates(source, extension, options) {
|
|
2824
|
-
|
|
2825
|
-
const scriptCandidates = await extractScriptStringCandidates(source, extension, options);
|
|
2826
|
-
for (const candidate of scriptCandidates) candidates.add(candidate);
|
|
2827
|
-
return candidates;
|
|
3143
|
+
return extractCandidatesFromSource(source, extension, options);
|
|
2828
3144
|
}
|
|
2829
3145
|
function isSourceCandidateRequest(id) {
|
|
2830
|
-
return
|
|
3146
|
+
return require_v4_engine.FULL_SOURCE_SCAN_EXTENSION_RE.test(cleanUrl(id));
|
|
2831
3147
|
}
|
|
2832
3148
|
function removeCandidateSet(candidateCount, candidates) {
|
|
2833
3149
|
for (const candidate of candidates) {
|
|
@@ -2843,18 +3159,20 @@ function removeCandidateSet(candidateCount, candidates) {
|
|
|
2843
3159
|
function addCandidateSet(candidateCount, candidates) {
|
|
2844
3160
|
for (const candidate of candidates) candidateCount.set(candidate, (candidateCount.get(candidate) ?? 0) + 1);
|
|
2845
3161
|
}
|
|
2846
|
-
function
|
|
3162
|
+
function createSourceCandidateStore(options = {}) {
|
|
2847
3163
|
const candidatesById = /* @__PURE__ */ new Map();
|
|
2848
3164
|
const scanCandidatesById = /* @__PURE__ */ new Map();
|
|
2849
3165
|
const transformCandidatesById = /* @__PURE__ */ new Map();
|
|
2850
3166
|
const cssCandidatesById = /* @__PURE__ */ new Map();
|
|
2851
|
-
const
|
|
3167
|
+
const scanSourceById = /* @__PURE__ */ new Map();
|
|
3168
|
+
const transformSourceById = /* @__PURE__ */ new Map();
|
|
3169
|
+
const cssSourceById = /* @__PURE__ */ new Map();
|
|
2852
3170
|
const candidateCount = /* @__PURE__ */ new Map();
|
|
2853
3171
|
let inlineIncludedCandidates = /* @__PURE__ */ new Set();
|
|
2854
3172
|
let inlineExcludedCandidates = /* @__PURE__ */ new Set();
|
|
2855
3173
|
async function sync(id, source) {
|
|
2856
3174
|
const normalizedId = cleanUrl(id);
|
|
2857
|
-
|
|
3175
|
+
scanSourceById.set(normalizedId, source);
|
|
2858
3176
|
const extension = resolveSourceCandidateExtension(normalizedId);
|
|
2859
3177
|
const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues, options.extractor);
|
|
2860
3178
|
const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
|
|
@@ -2868,7 +3186,7 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2868
3186
|
}
|
|
2869
3187
|
async function syncCss(id, source) {
|
|
2870
3188
|
const normalizedId = cleanUrl(id);
|
|
2871
|
-
|
|
3189
|
+
cssSourceById.set(normalizedId, source);
|
|
2872
3190
|
const contentCacheKey = createSourceCandidateContentCacheKey("css", source, options.bareArbitraryValues, options.extractor);
|
|
2873
3191
|
const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
|
|
2874
3192
|
if (cachedCandidates) {
|
|
@@ -2881,7 +3199,7 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2881
3199
|
}
|
|
2882
3200
|
async function merge(id, source) {
|
|
2883
3201
|
const normalizedId = cleanUrl(id);
|
|
2884
|
-
|
|
3202
|
+
transformSourceById.set(normalizedId, source);
|
|
2885
3203
|
const extension = resolveSourceCandidateExtension(normalizedId);
|
|
2886
3204
|
const contentCacheKey = createSourceCandidateContentCacheKey(extension, source, options.bareArbitraryValues, options.extractor);
|
|
2887
3205
|
const cachedCandidates = sourceCandidateContentCache.get(contentCacheKey);
|
|
@@ -2915,7 +3233,7 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2915
3233
|
outDir,
|
|
2916
3234
|
root
|
|
2917
3235
|
});
|
|
2918
|
-
await Promise.all(files.map((file) => syncFile(
|
|
3236
|
+
await Promise.all(files.map((file) => syncFile(require_v4_engine.resolveSourceScanPath(file))));
|
|
2919
3237
|
}
|
|
2920
3238
|
function replaceFinal(id, nextCandidates) {
|
|
2921
3239
|
const normalizedId = cleanUrl(id);
|
|
@@ -2963,17 +3281,20 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2963
3281
|
scanCandidatesById.delete(normalizedId);
|
|
2964
3282
|
transformCandidatesById.delete(normalizedId);
|
|
2965
3283
|
cssCandidatesById.delete(normalizedId);
|
|
2966
|
-
|
|
3284
|
+
scanSourceById.delete(normalizedId);
|
|
3285
|
+
transformSourceById.delete(normalizedId);
|
|
3286
|
+
cssSourceById.delete(normalizedId);
|
|
2967
3287
|
const previousCandidates = candidatesById.get(normalizedId);
|
|
2968
3288
|
if (!previousCandidates) return;
|
|
2969
3289
|
removeCandidateSet(candidateCount, previousCandidates);
|
|
2970
3290
|
candidatesById.delete(normalizedId);
|
|
2971
3291
|
}
|
|
2972
3292
|
function source(id) {
|
|
2973
|
-
|
|
3293
|
+
const normalizedId = cleanUrl(id);
|
|
3294
|
+
return scanSourceById.get(normalizedId) ?? cssSourceById.get(normalizedId) ?? transformSourceById.get(normalizedId);
|
|
2974
3295
|
}
|
|
2975
3296
|
function sources() {
|
|
2976
|
-
return
|
|
3297
|
+
return mergeSourcesByPriority().entries();
|
|
2977
3298
|
}
|
|
2978
3299
|
function values() {
|
|
2979
3300
|
const values = new Set([...candidateCount.keys(), ...inlineIncludedCandidates]);
|
|
@@ -2987,8 +3308,8 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
2987
3308
|
if (entries?.length === 0) return new Set(inlineIncludedCandidates);
|
|
2988
3309
|
const filtered = /* @__PURE__ */ new Set();
|
|
2989
3310
|
for (const [id, candidates] of candidatesById) {
|
|
2990
|
-
if (entries !== void 0 && !
|
|
2991
|
-
if (options.excludeEntries?.length &&
|
|
3311
|
+
if (entries !== void 0 && !require_v4_engine.isFileMatchedByTailwindSourceEntries(id, entries)) continue;
|
|
3312
|
+
if (options.excludeEntries?.length && require_v4_engine.isFileMatchedByTailwindSourceEntries(id, options.excludeEntries)) continue;
|
|
2992
3313
|
for (const candidate of candidates) filtered.add(candidate);
|
|
2993
3314
|
}
|
|
2994
3315
|
for (const candidate of inlineIncludedCandidates) filtered.add(candidate);
|
|
@@ -3011,8 +3332,8 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
3011
3332
|
return sources;
|
|
3012
3333
|
}
|
|
3013
3334
|
for (const [id, candidates] of candidatesById) {
|
|
3014
|
-
if (entries !== void 0 && !
|
|
3015
|
-
if (options.excludeEntries?.length &&
|
|
3335
|
+
if (entries !== void 0 && !require_v4_engine.isFileMatchedByTailwindSourceEntries(id, entries)) continue;
|
|
3336
|
+
if (options.excludeEntries?.length && require_v4_engine.isFileMatchedByTailwindSourceEntries(id, options.excludeEntries)) continue;
|
|
3016
3337
|
for (const candidate of candidates) addCandidateSource(candidate, id);
|
|
3017
3338
|
}
|
|
3018
3339
|
for (const candidate of inlineIncludedCandidates) addCandidateSource(candidate, void 0);
|
|
@@ -3024,7 +3345,9 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
3024
3345
|
scanCandidatesById.clear();
|
|
3025
3346
|
transformCandidatesById.clear();
|
|
3026
3347
|
cssCandidatesById.clear();
|
|
3027
|
-
|
|
3348
|
+
scanSourceById.clear();
|
|
3349
|
+
transformSourceById.clear();
|
|
3350
|
+
cssSourceById.clear();
|
|
3028
3351
|
candidateCount.clear();
|
|
3029
3352
|
inlineIncludedCandidates.clear();
|
|
3030
3353
|
inlineExcludedCandidates.clear();
|
|
@@ -3045,9 +3368,12 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
3045
3368
|
return {
|
|
3046
3369
|
candidatesById: [...candidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
|
|
3047
3370
|
cssCandidatesById: [...cssCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
|
|
3371
|
+
cssSourceById: [...cssSourceById.entries()],
|
|
3048
3372
|
scanCandidatesById: [...scanCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
|
|
3049
|
-
|
|
3373
|
+
scanSourceById: [...scanSourceById.entries()],
|
|
3374
|
+
sourceById: [...mergeSourcesByPriority().entries()],
|
|
3050
3375
|
transformCandidatesById: [...transformCandidatesById.entries()].map(([id, candidates]) => [id, [...candidates]]),
|
|
3376
|
+
transformSourceById: [...transformSourceById.entries()],
|
|
3051
3377
|
inlineExcludedCandidates: [...inlineExcludedCandidates],
|
|
3052
3378
|
inlineIncludedCandidates: [...inlineIncludedCandidates]
|
|
3053
3379
|
};
|
|
@@ -3072,7 +3398,9 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
3072
3398
|
if (candidateSet.size === 0) continue;
|
|
3073
3399
|
cssCandidatesById.set(id, candidateSet);
|
|
3074
3400
|
}
|
|
3075
|
-
for (const [id, source] of snapshot.sourceById ?? [])
|
|
3401
|
+
for (const [id, source] of snapshot.scanSourceById ?? snapshot.sourceById ?? []) scanSourceById.set(id, source);
|
|
3402
|
+
for (const [id, source] of snapshot.transformSourceById ?? []) transformSourceById.set(id, source);
|
|
3403
|
+
for (const [id, source] of snapshot.cssSourceById ?? []) cssSourceById.set(id, source);
|
|
3076
3404
|
const ids = new Set([
|
|
3077
3405
|
...scanCandidatesById.keys(),
|
|
3078
3406
|
...transformCandidatesById.keys(),
|
|
@@ -3081,6 +3409,7 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
3081
3409
|
for (const id of ids) recompute(id);
|
|
3082
3410
|
}
|
|
3083
3411
|
return {
|
|
3412
|
+
syncSource: sync,
|
|
3084
3413
|
sync,
|
|
3085
3414
|
syncCss,
|
|
3086
3415
|
merge,
|
|
@@ -3100,6 +3429,16 @@ function createSourceCandidateCollector(options = {}) {
|
|
|
3100
3429
|
resetScan,
|
|
3101
3430
|
clear
|
|
3102
3431
|
};
|
|
3432
|
+
function mergeSourcesByPriority() {
|
|
3433
|
+
const sources = /* @__PURE__ */ new Map();
|
|
3434
|
+
for (const [id, source] of transformSourceById) sources.set(id, source);
|
|
3435
|
+
for (const [id, source] of cssSourceById) sources.set(id, source);
|
|
3436
|
+
for (const [id, source] of scanSourceById) sources.set(id, source);
|
|
3437
|
+
return sources;
|
|
3438
|
+
}
|
|
3439
|
+
}
|
|
3440
|
+
function createSourceCandidateCollector(options = {}) {
|
|
3441
|
+
return createSourceCandidateStore(options);
|
|
3103
3442
|
}
|
|
3104
3443
|
//#endregion
|
|
3105
3444
|
//#region src/bundlers/shared/hmr-timing.ts
|
|
@@ -3186,12 +3525,24 @@ Object.defineProperty(exports, "annotateCssSourceTrace", {
|
|
|
3186
3525
|
return annotateCssSourceTrace;
|
|
3187
3526
|
}
|
|
3188
3527
|
});
|
|
3528
|
+
Object.defineProperty(exports, "collectStrictEscapedRuntimeCandidates", {
|
|
3529
|
+
enumerable: true,
|
|
3530
|
+
get: function() {
|
|
3531
|
+
return collectStrictEscapedRuntimeCandidates;
|
|
3532
|
+
}
|
|
3533
|
+
});
|
|
3189
3534
|
Object.defineProperty(exports, "createBundleRuntimeClassSetManager", {
|
|
3190
3535
|
enumerable: true,
|
|
3191
3536
|
get: function() {
|
|
3192
3537
|
return createBundleRuntimeClassSetManager;
|
|
3193
3538
|
}
|
|
3194
3539
|
});
|
|
3540
|
+
Object.defineProperty(exports, "createCssSourceOrderAppend", {
|
|
3541
|
+
enumerable: true,
|
|
3542
|
+
get: function() {
|
|
3543
|
+
return createCssSourceOrderAppend$1;
|
|
3544
|
+
}
|
|
3545
|
+
});
|
|
3195
3546
|
Object.defineProperty(exports, "createCssSourceTraceCacheSignature", {
|
|
3196
3547
|
enumerable: true,
|
|
3197
3548
|
get: function() {
|
|
@@ -3204,6 +3555,12 @@ Object.defineProperty(exports, "createCssTokenSourceMap", {
|
|
|
3204
3555
|
return createCssTokenSourceMap;
|
|
3205
3556
|
}
|
|
3206
3557
|
});
|
|
3558
|
+
Object.defineProperty(exports, "createEscapeFragments", {
|
|
3559
|
+
enumerable: true,
|
|
3560
|
+
get: function() {
|
|
3561
|
+
return createEscapeFragments;
|
|
3562
|
+
}
|
|
3563
|
+
});
|
|
3207
3564
|
Object.defineProperty(exports, "createHmrTimingRecorder", {
|
|
3208
3565
|
enumerable: true,
|
|
3209
3566
|
get: function() {
|
|
@@ -3216,10 +3573,10 @@ Object.defineProperty(exports, "createSourceCandidateCollector", {
|
|
|
3216
3573
|
return createSourceCandidateCollector;
|
|
3217
3574
|
}
|
|
3218
3575
|
});
|
|
3219
|
-
Object.defineProperty(exports, "
|
|
3576
|
+
Object.defineProperty(exports, "createSourceCandidateStore", {
|
|
3220
3577
|
enumerable: true,
|
|
3221
3578
|
get: function() {
|
|
3222
|
-
return
|
|
3579
|
+
return createSourceCandidateStore;
|
|
3223
3580
|
}
|
|
3224
3581
|
});
|
|
3225
3582
|
Object.defineProperty(exports, "emitHmrTiming", {
|
|
@@ -3240,6 +3597,12 @@ Object.defineProperty(exports, "generateCssByGenerator", {
|
|
|
3240
3597
|
return generateCssByGenerator;
|
|
3241
3598
|
}
|
|
3242
3599
|
});
|
|
3600
|
+
Object.defineProperty(exports, "hasMiniProgramTailwindV4PreflightReset", {
|
|
3601
|
+
enumerable: true,
|
|
3602
|
+
get: function() {
|
|
3603
|
+
return hasMiniProgramTailwindV4PreflightReset;
|
|
3604
|
+
}
|
|
3605
|
+
});
|
|
3243
3606
|
Object.defineProperty(exports, "isCssSourceTraceEnabled", {
|
|
3244
3607
|
enumerable: true,
|
|
3245
3608
|
get: function() {
|
|
@@ -3276,12 +3639,78 @@ Object.defineProperty(exports, "pushConcurrentTaskFactories", {
|
|
|
3276
3639
|
return pushConcurrentTaskFactories;
|
|
3277
3640
|
}
|
|
3278
3641
|
});
|
|
3642
|
+
Object.defineProperty(exports, "removeGeneratedSelectorCompatCss", {
|
|
3643
|
+
enumerable: true,
|
|
3644
|
+
get: function() {
|
|
3645
|
+
return removeGeneratedSelectorCompatCss;
|
|
3646
|
+
}
|
|
3647
|
+
});
|
|
3648
|
+
Object.defineProperty(exports, "removeMiniProgramHoverSelectors", {
|
|
3649
|
+
enumerable: true,
|
|
3650
|
+
get: function() {
|
|
3651
|
+
return removeMiniProgramHoverSelectors;
|
|
3652
|
+
}
|
|
3653
|
+
});
|
|
3654
|
+
Object.defineProperty(exports, "removeTailwindV4GeneratedUserCssArtifacts", {
|
|
3655
|
+
enumerable: true,
|
|
3656
|
+
get: function() {
|
|
3657
|
+
return removeTailwindV4GeneratedUserCssArtifacts;
|
|
3658
|
+
}
|
|
3659
|
+
});
|
|
3660
|
+
Object.defineProperty(exports, "removeTailwindV4GeneratorAtRules", {
|
|
3661
|
+
enumerable: true,
|
|
3662
|
+
get: function() {
|
|
3663
|
+
return removeTailwindV4GeneratorAtRules;
|
|
3664
|
+
}
|
|
3665
|
+
});
|
|
3666
|
+
Object.defineProperty(exports, "resolveSourceCandidateScanFiles", {
|
|
3667
|
+
enumerable: true,
|
|
3668
|
+
get: function() {
|
|
3669
|
+
return resolveSourceCandidateScanFiles;
|
|
3670
|
+
}
|
|
3671
|
+
});
|
|
3672
|
+
Object.defineProperty(exports, "resolveTaskConcurrency", {
|
|
3673
|
+
enumerable: true,
|
|
3674
|
+
get: function() {
|
|
3675
|
+
return resolveTaskConcurrency;
|
|
3676
|
+
}
|
|
3677
|
+
});
|
|
3678
|
+
Object.defineProperty(exports, "rewriteLocalCssImportRequestsForOutput", {
|
|
3679
|
+
enumerable: true,
|
|
3680
|
+
get: function() {
|
|
3681
|
+
return rewriteLocalCssImportRequestsForOutput;
|
|
3682
|
+
}
|
|
3683
|
+
});
|
|
3279
3684
|
Object.defineProperty(exports, "runWithConcurrency", {
|
|
3280
3685
|
enumerable: true,
|
|
3281
3686
|
get: function() {
|
|
3282
3687
|
return runWithConcurrency;
|
|
3283
3688
|
}
|
|
3284
3689
|
});
|
|
3690
|
+
Object.defineProperty(exports, "scoreTailwindV4CssSourceFileMatch", {
|
|
3691
|
+
enumerable: true,
|
|
3692
|
+
get: function() {
|
|
3693
|
+
return scoreTailwindV4CssSourceFileMatch;
|
|
3694
|
+
}
|
|
3695
|
+
});
|
|
3696
|
+
Object.defineProperty(exports, "splitLocalCssImports", {
|
|
3697
|
+
enumerable: true,
|
|
3698
|
+
get: function() {
|
|
3699
|
+
return splitLocalCssImports;
|
|
3700
|
+
}
|
|
3701
|
+
});
|
|
3702
|
+
Object.defineProperty(exports, "stripTailwindSourceMediaFragments", {
|
|
3703
|
+
enumerable: true,
|
|
3704
|
+
get: function() {
|
|
3705
|
+
return stripTailwindSourceMediaFragments;
|
|
3706
|
+
}
|
|
3707
|
+
});
|
|
3708
|
+
Object.defineProperty(exports, "stripUnmatchedTailwindSourceMediaCloseFragments", {
|
|
3709
|
+
enumerable: true,
|
|
3710
|
+
get: function() {
|
|
3711
|
+
return stripUnmatchedTailwindSourceMediaCloseFragments;
|
|
3712
|
+
}
|
|
3713
|
+
});
|
|
3285
3714
|
Object.defineProperty(exports, "validateCandidatesByGenerator", {
|
|
3286
3715
|
enumerable: true,
|
|
3287
3716
|
get: function() {
|