weapp-tailwindcss 5.2.7 → 5.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundlers/shared/generator-css/directives.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/finalize/root-import-shell.d.ts +2 -1
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +4 -1
- package/dist/bundlers/vite/generate-bundle/types.d.ts +6 -0
- package/dist/bundlers/vite/hot-css-modules.d.ts +5 -3
- package/dist/bundlers/vite/module-identity.d.ts +9 -0
- package/dist/bundlers/vite/processed-css-assets/scoped-tailwind-noise.d.ts +4 -0
- package/dist/bundlers/vite/serve-css-generation.d.ts +1 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +4 -1
- package/dist/bundlers/vite/shared/framework-hmr-candidate-state.d.ts +4 -2
- package/dist/bundlers/vite/shared/framework-hmr-runtime-signature.d.ts +1 -0
- package/dist/bundlers/vite/shared/framework-source-scan-session.d.ts +4 -0
- package/dist/bundlers/vite/shared/framework-strategy.d.ts +4 -0
- package/dist/cli.js +1 -0
- package/dist/{context-YAvTyPV2.js → context-BMkbwnH8.js} +10 -23
- package/dist/{context-OqD_eBxQ.cjs → context-CByXWyhQ.cjs} +179 -25
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{generator-BE34PYSC.cjs → generator-B0dCFlP1.cjs} +10 -0
- package/dist/{generator-DYeAa2-5.js → generator-BLpOsd5O.js} +10 -0
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-BydhuCbr.js → gulp-BWhCahA2.js} +4 -4
- package/dist/{gulp-Bun9iCRE.cjs → gulp-BdoorWb5.cjs} +7 -7
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-Gs9P-QtZ.js → hmr-timing-CJocHeZr.js} +22 -14
- package/dist/{hmr-timing-D607CWrq.cjs → hmr-timing-DiYnyg_W.cjs} +3 -3
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{options-hVsoTfwL.cjs → options-zpZez7qe.cjs} +1 -1
- package/dist/{pipeline-helpers-BLpoT8fX.cjs → pipeline-helpers-CsNLoEX1.cjs} +3 -3
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +2 -2
- package/dist/presets.js +1 -1
- package/dist/rspack.cjs +1 -1
- package/dist/rspack.js +1 -1
- package/dist/{source-candidate-scan-signature-BGDNJE2r.cjs → source-candidate-scan-signature-D9FXTD9a.cjs} +3 -3
- package/dist/{source-candidate-scan-signature-CdjPWQqv.js → source-candidate-scan-signature-of-TmeOs.js} +3 -3
- package/dist/{style-options-B_ppaVIg.cjs → style-options-COpQc8fr.cjs} +2 -2
- package/dist/{tailwindcss-CTpCc_nd.js → tailwindcss-2zdmASlM.js} +1 -1
- package/dist/{tailwindcss-DcpiKvmJ.cjs → tailwindcss-LtnGCxF0.cjs} +2 -2
- package/dist/{transform-BbaPIji9.js → transform-DhDe9eSf.js} +131 -15
- package/dist/{transform-BUEyOCT7.cjs → transform-GzbxfNGA.cjs} +130 -14
- package/dist/uni-app-x/component-local-style-binding.d.ts +6 -0
- package/dist/uni-app-x/component-local-style.d.ts +2 -0
- package/dist/uni-app-x/vite/author-apply.d.ts +1 -0
- package/dist/uni-app-x/vite/harmony-apply.d.ts +4 -1
- package/dist/uni-app-x/vite/native-hmr.d.ts +2 -0
- package/dist/uni-app-x/vite/plugin-options.d.ts +29 -0
- package/dist/uni-app-x/vite/style-request.d.ts +15 -0
- package/dist/uni-app-x/vite.d.ts +3 -24
- package/dist/{v4-generation-core-BrkM1vCs.cjs → v4-generation-core-BjHT6qGC.cjs} +22 -14
- package/dist/{vite-DM-U-Ins.js → vite-8l9_S4Qi.js} +680 -230
- package/dist/{vite-n0mRgEcF.cjs → vite-Dcx59GRQ.cjs} +683 -233
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-generation-loader.cjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +5 -5
- package/dist/{webpack-BlUJf8Ru.js → webpack-CkeFhPY2.js} +6 -6
- package/dist/{webpack-Bf8yJwTO.cjs → webpack-CzQrloDg.cjs} +9 -9
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +4 -4
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Pt as getTailwindV4IncrementalGenerateCacheStats, Q as hasTailwindRootDirectives, _ as upsertTailwindV4CssSource, et as normalizeTailwindConfigDirectives, g as removeTailwindV4CssSource, h as hasConfiguredTailwindV4CssRoots, nt as normalizeTailwindSourceForGenerator, vt as prependConfigDirective } from "./generator-
|
|
2
|
-
import { l as getRuntimeClassSetSignature, p as resolveSourceScanEntries } from "./tailwindcss-
|
|
3
|
-
import { $ as invalidateCompilationScope, A as createCssSourceTraceCacheSignature, B as finalizeCompilerShadowRun, C as createBundlerGeneratedCssMarker, D as finalizeMiniProgramCssStructure, E as stripBundlerGeneratedCssMarkers, J as disposeCompilerOwner, K as updateRuntimeCompilationBuildState, N as processCachedTask, P as createRuntimeClassSetManager, Q as getCompilationScopeDependencyRevision, R as rewriteLocalCssImportRequestsForOutput, U as createRuntimeCompilationBuildState, V as buildRuntimeCompilationSnapshot, W as removeRuntimeCompilationBuildStateFiles, X as getCompilerShadowRunSnapshot, Y as beginCompilerShadowRun, Z as AssetEmissionPlan, et as recordCompilationDependencyChanges, j as createCssTokenSourceMap, k as annotateCssSourceTrace, n as emitHmrTiming, nt as createSourceCandidateCollector, q as createRuntimeAffectingSourceSignature, r as generateTailwindV4Css, tt as createCompilationDependencyChanges, w as hasBundlerGeneratedCssMarker, y as finalizeMiniProgramGeneratorCss, z as splitLocalCssImports } from "./hmr-timing-
|
|
1
|
+
import { Pt as getTailwindV4IncrementalGenerateCacheStats, Q as hasTailwindRootDirectives, _ as upsertTailwindV4CssSource, et as normalizeTailwindConfigDirectives, g as removeTailwindV4CssSource, h as hasConfiguredTailwindV4CssRoots, nt as normalizeTailwindSourceForGenerator, vt as prependConfigDirective } from "./generator-BLpOsd5O.js";
|
|
2
|
+
import { l as getRuntimeClassSetSignature, p as resolveSourceScanEntries } from "./tailwindcss-2zdmASlM.js";
|
|
3
|
+
import { $ as invalidateCompilationScope, A as createCssSourceTraceCacheSignature, B as finalizeCompilerShadowRun, C as createBundlerGeneratedCssMarker, D as finalizeMiniProgramCssStructure, E as stripBundlerGeneratedCssMarkers, J as disposeCompilerOwner, K as updateRuntimeCompilationBuildState, N as processCachedTask, P as createRuntimeClassSetManager, Q as getCompilationScopeDependencyRevision, R as rewriteLocalCssImportRequestsForOutput, U as createRuntimeCompilationBuildState, V as buildRuntimeCompilationSnapshot, W as removeRuntimeCompilationBuildStateFiles, X as getCompilerShadowRunSnapshot, Y as beginCompilerShadowRun, Z as AssetEmissionPlan, et as recordCompilationDependencyChanges, j as createCssTokenSourceMap, k as annotateCssSourceTrace, n as emitHmrTiming, nt as createSourceCandidateCollector, q as createRuntimeAffectingSourceSignature, r as generateTailwindV4Css, tt as createCompilationDependencyChanges, w as hasBundlerGeneratedCssMarker, y as finalizeMiniProgramGeneratorCss, z as splitLocalCssImports } from "./hmr-timing-CJocHeZr.js";
|
|
4
4
|
import { h as createDebug } from "./wxml-IBzZSaQC.js";
|
|
5
|
-
import { l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, t as getCompilerContext, u as ensureRuntimeClassSet } from "./context-
|
|
5
|
+
import { l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, t as getCompilerContext, u as ensureRuntimeClassSet } from "./context-BMkbwnH8.js";
|
|
6
6
|
import fs from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import process from "node:process";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-CVvi-lCc.cjs");
|
|
2
|
-
const require_generator = require("./generator-
|
|
3
|
-
const require_options = require("./options-
|
|
4
|
-
const require_v4_generation_core = require("./v4-generation-core-
|
|
2
|
+
const require_generator = require("./generator-B0dCFlP1.cjs");
|
|
3
|
+
const require_options = require("./options-zpZez7qe.cjs");
|
|
4
|
+
const require_v4_generation_core = require("./v4-generation-core-BjHT6qGC.cjs");
|
|
5
5
|
const require_wxml = require("./wxml-DSMNuUaP.cjs");
|
|
6
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
7
|
-
const require_context = require("./context-
|
|
8
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
9
|
-
const require_style_options = require("./style-options-
|
|
6
|
+
const require_hmr_timing = require("./hmr-timing-DiYnyg_W.cjs");
|
|
7
|
+
const require_context = require("./context-CByXWyhQ.cjs");
|
|
8
|
+
const require_tailwindcss = require("./tailwindcss-LtnGCxF0.cjs");
|
|
9
|
+
const require_style_options = require("./style-options-COpQc8fr.cjs");
|
|
10
10
|
let node_fs = require("node:fs");
|
|
11
11
|
node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
|
|
12
12
|
let node_path = require("node:path");
|
package/dist/gulp.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_gulp = require("./gulp-
|
|
2
|
+
const require_gulp = require("./gulp-BdoorWb5.cjs");
|
|
3
3
|
exports.WeappTailwindcss = require_gulp.createPlugins;
|
|
4
4
|
exports.createPlugins = require_gulp.createPlugins;
|
|
5
5
|
exports.weappTailwindcss = require_gulp.createPlugins;
|
package/dist/gulp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createPlugins } from "./gulp-
|
|
1
|
+
import { t as createPlugins } from "./gulp-BWhCahA2.js";
|
|
2
2
|
export { createPlugins as WeappTailwindcss, createPlugins, createPlugins as weappTailwindcss };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { $ as hasTailwindSourceDirectives, A as transformGeneratorUserCss, At as toPosixPath, F as stripUnmatchedTailwindSourceMediaCloseFragments, Ft as filterUnsupportedMiniProgramTailwindV4Candidates, G as extractGeneratedCssForUserLayerSelectors, H as filterApplyOnlyGeneratedCss, I as finalizeMiniProgramCss, J as preferScopedGeneratedCssRules, K as hasUserCssLayerBlocks, Lt as loadTailwindV4DesignSystem, N as removeTailwindV4GeneratorAtRules, Ot as resolveSourceScanPath, P as stripTailwindSourceMediaFragments, Q as hasTailwindRootDirectives, U as normalizeEmptyTailwindCustomVariants, V as removeTailwindV4GeneratedUserCssArtifacts, W as shouldFilterApplyOnlyGeneratedCss, X as hasTailwindApplyDirective, _t as normalizeConfigDirective, a as resolveGeneratorRuntimeBranch, at as resolveCssEntrySource, bt as FULL_SOURCE_SCAN_EXTENSION_RE, ct as createCssAppend, d as resolveTailwindV4SourceFromRuntime, dt as splitGeneratorPlaceholderCssBySourceOrder, ft as splitTailwindGeneratedCssByBanner, gt as stripTailwindBanners, ht as stripTailwindBanner, i as normalizeWeappTailwindcssGeneratorOptions, it as removeTailwindSourceDirectives, j as isCommentOnlyCss, kt as resolveTailwindV4CssSourceBase, lt as hasTailwindGeneratedCss, mt as stripGeneratorPlaceholderMarkers, ot as GENERATOR_PLACEHOLDER_MARKER_RE, p as resolveTailwindV4SourceOptionsFromRuntime, pt as splitTailwindV4GeneratedCssBySourceOrder, q as splitUserCssLayerBlocks, rt as parseImportRequest, s as shouldUseMiniProgramCssBranch, st as VITE_MARKER_RE, t as createWeappTailwindcssGenerator, tt as normalizeTailwindSourceDirectives, u as resolveTailwindV4Source$1, ut as hasTailwindGeneratedCssMarkers, vt as prependConfigDirective, wt as isFileMatchedByTailwindSourceEntries, z as removeUnsupportedMiniProgramAtRules } from "./generator-
|
|
1
|
+
import { $ as hasTailwindSourceDirectives, A as transformGeneratorUserCss, At as toPosixPath, F as stripUnmatchedTailwindSourceMediaCloseFragments, Ft as filterUnsupportedMiniProgramTailwindV4Candidates, G as extractGeneratedCssForUserLayerSelectors, H as filterApplyOnlyGeneratedCss, I as finalizeMiniProgramCss, J as preferScopedGeneratedCssRules, K as hasUserCssLayerBlocks, Lt as loadTailwindV4DesignSystem, N as removeTailwindV4GeneratorAtRules, Ot as resolveSourceScanPath, P as stripTailwindSourceMediaFragments, Q as hasTailwindRootDirectives, U as normalizeEmptyTailwindCustomVariants, V as removeTailwindV4GeneratedUserCssArtifacts, W as shouldFilterApplyOnlyGeneratedCss, X as hasTailwindApplyDirective, _t as normalizeConfigDirective, a as resolveGeneratorRuntimeBranch, at as resolveCssEntrySource, bt as FULL_SOURCE_SCAN_EXTENSION_RE, ct as createCssAppend, d as resolveTailwindV4SourceFromRuntime, dt as splitGeneratorPlaceholderCssBySourceOrder, ft as splitTailwindGeneratedCssByBanner, gt as stripTailwindBanners, ht as stripTailwindBanner, i as normalizeWeappTailwindcssGeneratorOptions, it as removeTailwindSourceDirectives, j as isCommentOnlyCss, kt as resolveTailwindV4CssSourceBase, lt as hasTailwindGeneratedCss, mt as stripGeneratorPlaceholderMarkers, ot as GENERATOR_PLACEHOLDER_MARKER_RE, p as resolveTailwindV4SourceOptionsFromRuntime, pt as splitTailwindV4GeneratedCssBySourceOrder, q as splitUserCssLayerBlocks, rt as parseImportRequest, s as shouldUseMiniProgramCssBranch, st as VITE_MARKER_RE, t as createWeappTailwindcssGenerator, tt as normalizeTailwindSourceDirectives, u as resolveTailwindV4Source$1, ut as hasTailwindGeneratedCssMarkers, vt as prependConfigDirective, wt as isFileMatchedByTailwindSourceEntries, z as removeUnsupportedMiniProgramAtRules } from "./generator-BLpOsd5O.js";
|
|
2
2
|
import { o as transformCssMacroCss, r as hasCssMacroTailwindV4InternalAtRules, t as hasCssMacroStyleOptions } from "./auto-2dg_uhEJ.js";
|
|
3
3
|
import { n as _defineProperty, t as omitUndefined } from "./object-Bvy6-w9r.js";
|
|
4
|
-
import { g as resolveTailwindV4EntriesFromCss, l as getRuntimeClassSetSignature, r as isUniAppXEnabled, v as includesTailwindV4PreflightDirective, y as collectCssInlineSourceCandidates } from "./tailwindcss-
|
|
4
|
+
import { g as resolveTailwindV4EntriesFromCss, l as getRuntimeClassSetSignature, r as isUniAppXEnabled, v as includesTailwindV4PreflightDirective, y as collectCssInlineSourceCandidates } from "./tailwindcss-2zdmASlM.js";
|
|
5
5
|
import { _ as traverse, g as babelParse, h as createDebug, m as replaceWxml, r as createAttributeMatcher, v as md5Hash } from "./wxml-IBzZSaQC.js";
|
|
6
|
-
import { r as resolveStyleOptionsFromContext } from "./context-
|
|
6
|
+
import { r as resolveStyleOptionsFromContext } from "./context-BMkbwnH8.js";
|
|
7
7
|
import { existsSync, readFileSync } from "node:fs";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import process from "node:process";
|
|
@@ -338,15 +338,17 @@ function createSourceCandidateStore(options = {}) {
|
|
|
338
338
|
}
|
|
339
339
|
async function syncCurrentSource(id, source) {
|
|
340
340
|
const normalizedId = cleanUrl(id);
|
|
341
|
-
transformCandidatesById.delete(normalizedId);
|
|
342
|
-
cssCandidatesById.delete(normalizedId);
|
|
343
|
-
transformSourceById.delete(normalizedId);
|
|
344
|
-
cssSourceById.delete(normalizedId);
|
|
345
|
-
recompute(normalizedId);
|
|
346
341
|
const previousFileCandidates = new Set(candidatesById.get(normalizedId) ?? []);
|
|
347
|
-
const
|
|
342
|
+
const extension = resolveSourceCandidateExtension(normalizedId);
|
|
343
|
+
const nextCandidates = await resolveCandidates(source, extension);
|
|
348
344
|
const affectedCandidates = /* @__PURE__ */ new Set([...previousFileCandidates, ...nextCandidates]);
|
|
349
345
|
const previousVisibleCandidates = collectVisibleCandidates(affectedCandidates);
|
|
346
|
+
if (extension !== "css") {
|
|
347
|
+
transformCandidatesById.delete(normalizedId);
|
|
348
|
+
cssCandidatesById.delete(normalizedId);
|
|
349
|
+
transformSourceById.delete(normalizedId);
|
|
350
|
+
cssSourceById.delete(normalizedId);
|
|
351
|
+
}
|
|
350
352
|
scanSourceById.set(normalizedId, source);
|
|
351
353
|
replaceScanLayer(normalizedId, nextCandidates);
|
|
352
354
|
return diffCandidateSets(previousVisibleCandidates, collectVisibleCandidates(affectedCandidates));
|
|
@@ -3598,14 +3600,17 @@ function collectGeneratorCssCandidates(css) {
|
|
|
3598
3600
|
//#region src/bundlers/shared/generator-css/source-resolver/apply-reference.ts
|
|
3599
3601
|
function resolveTailwindV4ApplyReference(options) {
|
|
3600
3602
|
const references = /* @__PURE__ */ new Set();
|
|
3601
|
-
for (const source of options.cssSources ?? []) if (typeof source.file === "string" && source.file.length > 0 && typeof source.css === "string" && hasTailwindRootDirectives(source.css, { importFallback: true }) &&
|
|
3603
|
+
for (const source of options.cssSources ?? []) if (typeof source.file === "string" && source.file.length > 0 && typeof source.css === "string" && hasTailwindRootDirectives(source.css, { importFallback: true }) && hasTailwindApplyContextDirective(source.css)) references.add(source.file);
|
|
3602
3604
|
return references.size === 1 ? references.values().next().value : void 0;
|
|
3603
3605
|
}
|
|
3604
|
-
function
|
|
3606
|
+
function hasTailwindApplyContextDirective(css) {
|
|
3605
3607
|
try {
|
|
3606
3608
|
let found = false;
|
|
3607
|
-
postcss.parse(css).walkAtRules(
|
|
3608
|
-
|
|
3609
|
+
postcss.parse(css).walkAtRules((rule) => {
|
|
3610
|
+
if (rule.name === "theme" || rule.name === "config") {
|
|
3611
|
+
found = true;
|
|
3612
|
+
return false;
|
|
3613
|
+
}
|
|
3609
3614
|
});
|
|
3610
3615
|
return found;
|
|
3611
3616
|
} catch {
|
|
@@ -5231,7 +5236,10 @@ async function executeGeneratorPipelineWithOwner(context) {
|
|
|
5231
5236
|
const sourceCss = options.deferCssAdaptation ? removeMatchingLocalCssImports(source.css, localImports) : source.css;
|
|
5232
5237
|
const generatorSource = options.disableSourceScan === true ? {
|
|
5233
5238
|
...source,
|
|
5234
|
-
css: removeTailwindSourceDirectives(sourceCss, {
|
|
5239
|
+
css: removeTailwindSourceDirectives(sourceCss, {
|
|
5240
|
+
importFallback: generatorOptions.importFallback,
|
|
5241
|
+
preserveApplyContext: true
|
|
5242
|
+
})
|
|
5235
5243
|
} : sourceCss === source.css ? source : {
|
|
5236
5244
|
...source,
|
|
5237
5245
|
css: sourceCss
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-CVvi-lCc.cjs");
|
|
2
|
-
const require_generator = require("./generator-
|
|
3
|
-
const require_v4_generation_core = require("./v4-generation-core-
|
|
2
|
+
const require_generator = require("./generator-B0dCFlP1.cjs");
|
|
3
|
+
const require_v4_generation_core = require("./v4-generation-core-BjHT6qGC.cjs");
|
|
4
4
|
const require_wxml = require("./wxml-DSMNuUaP.cjs");
|
|
5
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
5
|
+
const require_tailwindcss = require("./tailwindcss-LtnGCxF0.cjs");
|
|
6
6
|
let node_process = require("node:process");
|
|
7
7
|
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
8
8
|
let _tailwindcss_mangle_engine = require("@tailwindcss-mangle/engine");
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_framework = require("./framework.cjs");
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const require_gulp = require("./gulp-
|
|
3
|
+
const require_generator = require("./generator-B0dCFlP1.cjs");
|
|
4
|
+
const require_gulp = require("./gulp-BdoorWb5.cjs");
|
|
5
5
|
const require_postcss = require("./postcss.cjs");
|
|
6
|
-
const require_vite = require("./vite-
|
|
7
|
-
const require_webpack = require("./webpack-
|
|
6
|
+
const require_vite = require("./vite-Dcx59GRQ.cjs");
|
|
7
|
+
const require_webpack = require("./webpack-CzQrloDg.cjs");
|
|
8
8
|
require("./webpack.cjs");
|
|
9
9
|
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
10
10
|
exports.WeappTailwindcss = require_vite.WeappTailwindcss;
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { detectAppType, detectAppTypeFromEnv, detectAppTypeFromPackageJson, isMpxPackage, isRunningInHBuilderX, isTaroPackage, isUniAppPackage, isUniAppVitePackage, isUniAppXManifest, isUniAppXPackage, isWeappVitePackage, resolveImplicitAppTypeFromViteRoot, resolveMpxPlatform, resolvePlatform, resolveTaroPlatform, resolveUniAppXPlatform, resolveUniPlatform, resolveUniPlatformsFromEnv, resolveUniUtsPlatform } from "./framework.js";
|
|
2
|
-
import { t as createWeappTailwindcssGenerator } from "./generator-
|
|
3
|
-
import { t as createPlugins } from "./gulp-
|
|
2
|
+
import { t as createWeappTailwindcssGenerator } from "./generator-BLpOsd5O.js";
|
|
3
|
+
import { t as createPlugins } from "./gulp-BWhCahA2.js";
|
|
4
4
|
import weappTailwindcssPostcssPlugin from "./postcss.js";
|
|
5
|
-
import { t as WeappTailwindcss } from "./vite-
|
|
6
|
-
import { n as weappTailwindcssPackageDir } from "./webpack-
|
|
5
|
+
import { t as WeappTailwindcss } from "./vite-8l9_S4Qi.js";
|
|
6
|
+
import { n as weappTailwindcssPackageDir } from "./webpack-CkeFhPY2.js";
|
|
7
7
|
import "./webpack.js";
|
|
8
8
|
import { unitConversionComposeRules, unitConversionPresets } from "@weapp-tailwindcss/postcss";
|
|
9
9
|
export { WeappTailwindcss, createPlugins, createWeappTailwindcssGenerator, detectAppType, detectAppTypeFromEnv, detectAppTypeFromPackageJson, isMpxPackage, isRunningInHBuilderX, isTaroPackage, isUniAppPackage, isUniAppVitePackage, isUniAppXManifest, isUniAppXPackage, isWeappVitePackage, resolveImplicitAppTypeFromViteRoot, resolveMpxPlatform, resolvePlatform, resolveTaroPlatform, resolveUniAppXPlatform, resolveUniPlatform, resolveUniPlatformsFromEnv, resolveUniUtsPlatform, unitConversionComposeRules, unitConversionPresets, weappTailwindcssPackageDir, weappTailwindcssPostcssPlugin };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-CVvi-lCc.cjs");
|
|
2
|
-
const require_generator = require("./generator-
|
|
2
|
+
const require_generator = require("./generator-B0dCFlP1.cjs");
|
|
3
3
|
let node_fs = require("node:fs");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-CVvi-lCc.cjs");
|
|
2
|
-
const require_generator = require("./generator-
|
|
3
|
-
const require_v4_generation_core = require("./v4-generation-core-
|
|
2
|
+
const require_generator = require("./generator-B0dCFlP1.cjs");
|
|
3
|
+
const require_v4_generation_core = require("./v4-generation-core-BjHT6qGC.cjs");
|
|
4
4
|
const require_defaults = require("./defaults.cjs");
|
|
5
|
-
const require_style_options = require("./style-options-
|
|
5
|
+
const require_style_options = require("./style-options-COpQc8fr.cjs");
|
|
6
6
|
let node_path = require("node:path");
|
|
7
7
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
8
8
|
let node_process = require("node:process");
|
package/dist/postcss.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_generator = require("./generator-
|
|
5
|
+
const require_generator = require("./generator-B0dCFlP1.cjs");
|
|
6
6
|
const weappTailwindcssPostcssPlugin = (0, require("@weapp-tailwindcss/postcss").createWeappTailwindcssPostcssPlugin)({
|
|
7
7
|
createGenerator: (source) => {
|
|
8
8
|
return require_generator.createWeappTailwindcssGenerator(source);
|
package/dist/postcss.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as normalizeWeappTailwindcssGeneratorOptions, t as createWeappTailwindcssGenerator, u as resolveTailwindV4Source } from "./generator-
|
|
1
|
+
import { i as normalizeWeappTailwindcssGeneratorOptions, t as createWeappTailwindcssGenerator, u as resolveTailwindV4Source } from "./generator-BLpOsd5O.js";
|
|
2
2
|
import { createWeappTailwindcssPostcssPlugin } from "@weapp-tailwindcss/postcss";
|
|
3
3
|
const weappTailwindcssPostcssPlugin = createWeappTailwindcssPostcssPlugin({
|
|
4
4
|
createGenerator: (source) => {
|
package/dist/presets.cjs
CHANGED
|
@@ -2,9 +2,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_rolldown_runtime = require("./rolldown-runtime-CVvi-lCc.cjs");
|
|
3
3
|
const require_framework = require("./framework.cjs");
|
|
4
4
|
const require_object = require("./object-C_Vr6_S5.cjs");
|
|
5
|
-
const require_options = require("./options-
|
|
5
|
+
const require_options = require("./options-zpZez7qe.cjs");
|
|
6
6
|
require("./utils-CuKLf1Zv.cjs");
|
|
7
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
7
|
+
const require_tailwindcss = require("./tailwindcss-LtnGCxF0.cjs");
|
|
8
8
|
require("./logger-TlKT3xmR.cjs");
|
|
9
9
|
let node_path = require("node:path");
|
|
10
10
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
package/dist/presets.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveTaroPlatform, resolveUniPlatformsFromEnv } from "./framework.js";
|
|
2
2
|
import { t as omitUndefined } from "./object-Bvy6-w9r.js";
|
|
3
|
-
import { i as resolveUniAppXOptions, n as resolveTailwindcssBasedir } from "./tailwindcss-
|
|
3
|
+
import { i as resolveUniAppXOptions, n as resolveTailwindcssBasedir } from "./tailwindcss-2zdmASlM.js";
|
|
4
4
|
import { n as defuOverrideArray } from "./utils-MVwpU07P.js";
|
|
5
5
|
import { t as logger } from "./logger-BNzxZbZj.js";
|
|
6
6
|
import path from "node:path";
|
package/dist/rspack.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_rolldown_runtime = require("./rolldown-runtime-CVvi-lCc.cjs");
|
|
3
|
-
const require_webpack = require("./webpack-
|
|
3
|
+
const require_webpack = require("./webpack-CzQrloDg.cjs");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
6
6
|
//#region src/bundlers/rspack/index.ts
|
package/dist/rspack.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as weappTailwindcssPackageDir, r as __dirname, t as WeappTailwindcss } from "./webpack-
|
|
1
|
+
import { n as weappTailwindcssPackageDir, r as __dirname, t as WeappTailwindcss } from "./webpack-CkeFhPY2.js";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
//#region src/bundlers/rspack/index.ts
|
|
4
4
|
const CSS_IMPORT_REWRITE_LOADER_NAME = "weapp-tw-css-import-rewrite-loader";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-CVvi-lCc.cjs");
|
|
2
2
|
const require_framework = require("./framework.cjs");
|
|
3
|
-
const require_generator = require("./generator-
|
|
3
|
+
const require_generator = require("./generator-B0dCFlP1.cjs");
|
|
4
4
|
require("./auto-DtU6f3X6.cjs");
|
|
5
|
-
const require_options = require("./options-
|
|
6
|
-
const require_v4_generation_core = require("./v4-generation-core-
|
|
5
|
+
const require_options = require("./options-zpZez7qe.cjs");
|
|
6
|
+
const require_v4_generation_core = require("./v4-generation-core-BjHT6qGC.cjs");
|
|
7
7
|
let node_path = require("node:path");
|
|
8
8
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
9
9
|
let node_module = require("node:module");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { detectAppType } from "./framework.js";
|
|
2
|
-
import { At as toPosixPath } from "./generator-
|
|
2
|
+
import { At as toPosixPath } from "./generator-BLpOsd5O.js";
|
|
3
3
|
import { n as hasCssMacroTailwindV4CustomVariantConditionalComments } from "./auto-2dg_uhEJ.js";
|
|
4
|
-
import { _ as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions } from "./tailwindcss-
|
|
5
|
-
import { x as isSourceStyleRequest } from "./hmr-timing-
|
|
4
|
+
import { _ as resolveTailwindV4EntriesFromCssCached, i as resolveUniAppXOptions } from "./tailwindcss-2zdmASlM.js";
|
|
5
|
+
import { x as isSourceStyleRequest } from "./hmr-timing-CJocHeZr.js";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { weappStyleInjector } from "weapp-style-injector/vite";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_generator = require("./generator-
|
|
2
|
-
const require_options = require("./options-
|
|
1
|
+
const require_generator = require("./generator-B0dCFlP1.cjs");
|
|
2
|
+
const require_options = require("./options-zpZez7qe.cjs");
|
|
3
3
|
//#region src/context/style-options.ts
|
|
4
4
|
function normalizeStyleHandlerMajorVersion(majorVersion) {
|
|
5
5
|
return majorVersion === 4 ? 4 : void 0;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as findWorkspacePackageDir, Ct as expandTailwindSourceEntries, D as resolveTailwindcssOptions, Dt as resolveCssSourceEntries, E as normalizeTailwindcssRuntimeOptions, Et as parseConfigParam, Lt as loadTailwindV4DesignSystem, Nt as resolveCssMacroTailwindV4Source, O as normalizeStringListOption, S as findNearestPackageRoot, St as createTailwindSourceEntryMatcher, T as normalizeExtendLengthUnits, Tt as normalizeLegacyContentEntries, b as isTailwindV4CssEntry, d as resolveTailwindV4SourceFromRuntime, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, kt as resolveTailwindV4CssSourceBase, m as filterTailwindV4CssSourceRoots, p as resolveTailwindV4SourceOptionsFromRuntime, v as groupCssEntriesByBase, w as findWorkspaceRoot, x as normalizeCssEntries, xt as FULL_SOURCE_SCAN_PATTERN, y as guessBasedirFromEntries } from "./generator-
|
|
1
|
+
import { C as findWorkspacePackageDir, Ct as expandTailwindSourceEntries, D as resolveTailwindcssOptions, Dt as resolveCssSourceEntries, E as normalizeTailwindcssRuntimeOptions, Et as parseConfigParam, Lt as loadTailwindV4DesignSystem, Nt as resolveCssMacroTailwindV4Source, O as normalizeStringListOption, S as findNearestPackageRoot, St as createTailwindSourceEntryMatcher, T as normalizeExtendLengthUnits, Tt as normalizeLegacyContentEntries, b as isTailwindV4CssEntry, d as resolveTailwindV4SourceFromRuntime, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, kt as resolveTailwindV4CssSourceBase, m as filterTailwindV4CssSourceRoots, p as resolveTailwindV4SourceOptionsFromRuntime, v as groupCssEntriesByBase, w as findWorkspaceRoot, x as normalizeCssEntries, xt as FULL_SOURCE_SCAN_PATTERN, y as guessBasedirFromEntries } from "./generator-BLpOsd5O.js";
|
|
2
2
|
import { t as omitUndefined } from "./object-Bvy6-w9r.js";
|
|
3
3
|
import { n as defuOverrideArray$1 } from "./utils-MVwpU07P.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-CVvi-lCc.cjs");
|
|
2
|
-
const require_generator = require("./generator-
|
|
2
|
+
const require_generator = require("./generator-B0dCFlP1.cjs");
|
|
3
3
|
const require_object = require("./object-C_Vr6_S5.cjs");
|
|
4
|
-
const require_options = require("./options-
|
|
4
|
+
const require_options = require("./options-zpZez7qe.cjs");
|
|
5
5
|
require("./utils-CuKLf1Zv.cjs");
|
|
6
6
|
let node_fs = require("node:fs");
|
|
7
7
|
let node_path = require("node:path");
|
|
@@ -1,8 +1,100 @@
|
|
|
1
1
|
import { n as _defineProperty } from "./object-Bvy6-w9r.js";
|
|
2
|
-
import { g as babelParse, i as analyzeSource, m as replaceWxml, n as generateCode, o as JsTokenUpdater, r as createAttributeMatcher, u as isClassContextLiteralPath } from "./wxml-IBzZSaQC.js";
|
|
2
|
+
import { _ as traverse$1, g as babelParse, i as analyzeSource, m as replaceWxml, n as generateCode, o as JsTokenUpdater, r as createAttributeMatcher, u as isClassContextLiteralPath } from "./wxml-IBzZSaQC.js";
|
|
3
3
|
import { splitCandidateTokens } from "@tailwindcss-mangle/engine";
|
|
4
4
|
import MagicString from "magic-string";
|
|
5
5
|
import { NodeTypes, parse } from "@vue/compiler-dom";
|
|
6
|
+
//#region src/uni-app-x/component-local-style-binding.ts
|
|
7
|
+
const OPTIONS_CLASS_SECTIONS = /* @__PURE__ */ new Set(["computed", "methods"]);
|
|
8
|
+
function readStaticName(path) {
|
|
9
|
+
if (path.isIdentifier()) return path.node.name;
|
|
10
|
+
if (path.isStringLiteral()) return path.node.value;
|
|
11
|
+
}
|
|
12
|
+
function isClassBindingName(path, names) {
|
|
13
|
+
const name = readStaticName(path);
|
|
14
|
+
return name !== void 0 && names.has(name);
|
|
15
|
+
}
|
|
16
|
+
function isExportDefaultOptionsObject(path) {
|
|
17
|
+
return path?.isObjectExpression() === true && path.parentPath?.isExportDefaultDeclaration() === true;
|
|
18
|
+
}
|
|
19
|
+
function isOptionsSectionMember(path) {
|
|
20
|
+
const sectionObject = path.parentPath;
|
|
21
|
+
if (!sectionObject?.isObjectExpression()) return false;
|
|
22
|
+
const sectionProperty = sectionObject.parentPath;
|
|
23
|
+
if (!sectionProperty?.isObjectProperty() || sectionProperty.get("value").node !== sectionObject.node) return false;
|
|
24
|
+
const sectionName = readStaticName(sectionProperty.get("key"));
|
|
25
|
+
return sectionName !== void 0 && OPTIONS_CLASS_SECTIONS.has(sectionName) && isExportDefaultOptionsObject(sectionProperty.parentPath);
|
|
26
|
+
}
|
|
27
|
+
function findContainingFunction(path) {
|
|
28
|
+
let current = path;
|
|
29
|
+
while (current) {
|
|
30
|
+
if (current.isFunction()) return current;
|
|
31
|
+
current = current.parentPath;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function isOptionsDataFunction(path) {
|
|
35
|
+
if (!path) return false;
|
|
36
|
+
if (path.isObjectMethod()) return readStaticName(path.get("key")) === "data" && isExportDefaultOptionsObject(path.parentPath);
|
|
37
|
+
if (!path.isFunctionExpression() && !path.isArrowFunctionExpression()) return false;
|
|
38
|
+
const property = path.parentPath;
|
|
39
|
+
return property?.isObjectProperty() === true && property.get("value").node === path.node && readStaticName(property.get("key")) === "data" && isExportDefaultOptionsObject(property.parentPath);
|
|
40
|
+
}
|
|
41
|
+
function isOptionsDataReturnMember(path) {
|
|
42
|
+
const dataObject = path.parentPath;
|
|
43
|
+
if (!dataObject?.isObjectExpression()) return false;
|
|
44
|
+
const parent = dataObject.parentPath;
|
|
45
|
+
if (parent?.isReturnStatement()) return isOptionsDataFunction(findContainingFunction(parent));
|
|
46
|
+
if (parent?.isArrowFunctionExpression() && parent.get("body").node === dataObject.node) return isOptionsDataFunction(parent);
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
function isProgramBinding(path, name, declaration) {
|
|
50
|
+
const binding = path.scope.getBinding(name);
|
|
51
|
+
return binding?.scope.path.isProgram() === true && (declaration === void 0 || binding.path.node === declaration);
|
|
52
|
+
}
|
|
53
|
+
function isClassAssignmentTarget(path, names) {
|
|
54
|
+
const directName = readStaticName(path);
|
|
55
|
+
if (directName !== void 0) return names.has(directName) && isProgramBinding(path, directName);
|
|
56
|
+
if (!path.isMemberExpression()) return false;
|
|
57
|
+
const object = path.get("object");
|
|
58
|
+
const property = path.get("property");
|
|
59
|
+
return object.isThisExpression() && isClassBindingName(property, names);
|
|
60
|
+
}
|
|
61
|
+
function collectClassBindingNames(ast, names) {
|
|
62
|
+
traverse$1(ast, { ReferencedIdentifier(path) {
|
|
63
|
+
names.add(path.node.name);
|
|
64
|
+
} });
|
|
65
|
+
}
|
|
66
|
+
function collectClassBindingRoots(ast, names) {
|
|
67
|
+
const roots = /* @__PURE__ */ new WeakSet();
|
|
68
|
+
if (names.size === 0) return roots;
|
|
69
|
+
traverse$1(ast, {
|
|
70
|
+
Program(path) {
|
|
71
|
+
for (const name of names) {
|
|
72
|
+
const binding = path.scope.getBinding(name);
|
|
73
|
+
if (binding?.scope === path.scope) roots.add(binding.path.node);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
AssignmentExpression(path) {
|
|
77
|
+
if (isClassAssignmentTarget(path.get("left"), names)) roots.add(path.node);
|
|
78
|
+
},
|
|
79
|
+
ObjectMethod(path) {
|
|
80
|
+
if (isClassBindingName(path.get("key"), names) && isOptionsSectionMember(path)) roots.add(path.node);
|
|
81
|
+
},
|
|
82
|
+
ObjectProperty(path) {
|
|
83
|
+
if (isClassBindingName(path.get("key"), names) && (isOptionsSectionMember(path) || isOptionsDataReturnMember(path))) roots.add(path.node);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return roots;
|
|
87
|
+
}
|
|
88
|
+
function isClassBindingLiteralPath(path, roots) {
|
|
89
|
+
if (!roots) return false;
|
|
90
|
+
let current = path;
|
|
91
|
+
while (current) {
|
|
92
|
+
if (roots.has(current.node)) return true;
|
|
93
|
+
current = current.parentPath;
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
6
98
|
//#region src/uni-app-x/component-local-style.ts
|
|
7
99
|
const EXPRESSION_WRAPPER_PREFIX = "(\n";
|
|
8
100
|
const EXPRESSION_WRAPPER_SUFFIX = "\n)";
|
|
@@ -87,6 +179,7 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
87
179
|
this.runtimeSet = runtimeSet;
|
|
88
180
|
_defineProperty(this, "aliasByUtility", /* @__PURE__ */ new Map());
|
|
89
181
|
_defineProperty(this, "aliasByLookup", /* @__PURE__ */ new Map());
|
|
182
|
+
_defineProperty(this, "classBindingNames", /* @__PURE__ */ new Set());
|
|
90
183
|
}
|
|
91
184
|
ensureAlias(utility) {
|
|
92
185
|
const cached = this.aliasByUtility.get(utility);
|
|
@@ -113,17 +206,20 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
113
206
|
collectRuntimeClasses(rawSource, options = {}) {
|
|
114
207
|
const wrapped = options.wrapExpression ? `${EXPRESSION_WRAPPER_PREFIX}${rawSource}${EXPRESSION_WRAPPER_SUFFIX}` : rawSource;
|
|
115
208
|
try {
|
|
116
|
-
const
|
|
209
|
+
const ast = babelParse(wrapped, {
|
|
117
210
|
plugins: ["typescript"],
|
|
118
211
|
sourceType: options.wrapExpression ? "module" : "unambiguous"
|
|
119
|
-
})
|
|
212
|
+
});
|
|
213
|
+
if (options.wrapExpression) collectClassBindingNames(ast, this.classBindingNames);
|
|
214
|
+
const classBindingRoots = options.wrapExpression ? void 0 : collectClassBindingRoots(ast, this.classBindingNames);
|
|
215
|
+
const analysis = analyzeSource(ast, {}, void 0, false);
|
|
120
216
|
for (const path of analysis.targetPaths) {
|
|
121
217
|
const { literal } = extractLiteralValue(path);
|
|
122
218
|
const candidates = splitCandidateTokens(literal);
|
|
123
|
-
const classContext = options.wrapExpression || isClassContextLiteralPath(path);
|
|
219
|
+
const classContext = options.wrapExpression || isClassContextLiteralPath(path) || isClassBindingLiteralPath(path, classBindingRoots);
|
|
124
220
|
for (const candidate of candidates) {
|
|
125
|
-
if (!candidate || !classContext
|
|
126
|
-
if (
|
|
221
|
+
if (!candidate || !classContext || !isRuntimeCandidate(candidate, this.runtimeSet)) continue;
|
|
222
|
+
if (!hasTopLevelVariant(candidate)) this.ensureAlias(candidate);
|
|
127
223
|
}
|
|
128
224
|
}
|
|
129
225
|
} catch {}
|
|
@@ -132,13 +228,16 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
132
228
|
if (this.aliasByLookup.size === 0) return rawSource;
|
|
133
229
|
const wrapped = options.wrapExpression ? `${EXPRESSION_WRAPPER_PREFIX}${rawSource}${EXPRESSION_WRAPPER_SUFFIX}` : rawSource;
|
|
134
230
|
try {
|
|
135
|
-
const
|
|
231
|
+
const ast = babelParse(wrapped, {
|
|
136
232
|
plugins: ["typescript"],
|
|
137
233
|
sourceType: options.wrapExpression ? "module" : "unambiguous"
|
|
138
|
-
})
|
|
234
|
+
});
|
|
235
|
+
const classBindingRoots = options.wrapExpression ? void 0 : collectClassBindingRoots(ast, this.classBindingNames);
|
|
236
|
+
const analysis = analyzeSource(ast, {}, void 0, false);
|
|
139
237
|
if (analysis.targetPaths.length === 0) return rawSource;
|
|
140
238
|
const updater = new JsTokenUpdater();
|
|
141
239
|
for (const path of analysis.targetPaths) {
|
|
240
|
+
if (!options.wrapExpression && !isClassContextLiteralPath(path) && !isClassBindingLiteralPath(path, classBindingRoots)) continue;
|
|
142
241
|
const { literal, offset } = extractLiteralValue(path);
|
|
143
242
|
const candidates = splitCandidateTokens(literal);
|
|
144
243
|
if (candidates.length === 0) continue;
|
|
@@ -178,13 +277,16 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
178
277
|
}
|
|
179
278
|
toStyleBlock() {
|
|
180
279
|
if (!this.hasStyles()) return "";
|
|
181
|
-
|
|
280
|
+
return `<style scoped>\n${this.toStyleRules()}</style>\n`;
|
|
281
|
+
}
|
|
282
|
+
toStyleRules() {
|
|
283
|
+
if (!this.hasStyles()) return "";
|
|
284
|
+
const lines = [];
|
|
182
285
|
for (const [utility, alias] of this.aliasByUtility) {
|
|
183
286
|
lines.push(`.${alias} {`);
|
|
184
287
|
lines.push(` @apply ${utility};`);
|
|
185
288
|
lines.push("}");
|
|
186
289
|
}
|
|
187
|
-
lines.push("</style>");
|
|
188
290
|
return `${lines.join("\n")}\n`;
|
|
189
291
|
}
|
|
190
292
|
};
|
|
@@ -252,10 +354,14 @@ function shouldHandleAttribute(tag, attrName, disabledDefaultTemplateHandler, ma
|
|
|
252
354
|
}
|
|
253
355
|
const defaultCreateJsHandlerOptions = { babelParserOptions: { plugins: ["typescript"] } };
|
|
254
356
|
const UVUE_NVUE_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
255
|
-
const SFC_BLOCK_RE = /<(template|script)\b([^>]*)>([\s\S]*?)<\/\1>/gi;
|
|
357
|
+
const SFC_BLOCK_RE = /<(template|script|style)\b([^>]*)>([\s\S]*?)<\/\1>/gi;
|
|
256
358
|
const SCRIPT_SETUP_RE = /(?:^|\s)setup(?:\s|=|$)/;
|
|
359
|
+
const STYLE_SCOPED_RE = /(?:^|\s)scoped(?:\s|=|$)/i;
|
|
257
360
|
function parseSfc(code) {
|
|
258
|
-
const descriptor = {
|
|
361
|
+
const descriptor = {
|
|
362
|
+
errors: [],
|
|
363
|
+
styles: []
|
|
364
|
+
};
|
|
259
365
|
for (const match of code.matchAll(SFC_BLOCK_RE)) {
|
|
260
366
|
const type = match[1];
|
|
261
367
|
const attrs = match[2] ?? "";
|
|
@@ -280,8 +386,12 @@ function parseSfc(code) {
|
|
|
280
386
|
}
|
|
281
387
|
continue;
|
|
282
388
|
}
|
|
283
|
-
if (type === "script")
|
|
284
|
-
|
|
389
|
+
if (type === "script") {
|
|
390
|
+
if (SCRIPT_SETUP_RE.test(attrs)) descriptor.scriptSetup ?? (descriptor.scriptSetup = block);
|
|
391
|
+
else descriptor.script ?? (descriptor.script = block);
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
if (type === "style") descriptor.styles.push(block);
|
|
285
395
|
}
|
|
286
396
|
return descriptor;
|
|
287
397
|
}
|
|
@@ -323,7 +433,13 @@ function transformUVue(code, id, jsHandler, runtimeSet, options = {}) {
|
|
|
323
433
|
const { code } = jsHandler(descriptor.scriptSetup.content, runtimeSet ?? /* @__PURE__ */ new Set(), defaultCreateJsHandlerOptions);
|
|
324
434
|
ms.update(descriptor.scriptSetup.start, descriptor.scriptSetup.end, localStyleCollector ? localStyleCollector.rewriteTransformedCode(code) : code);
|
|
325
435
|
}
|
|
326
|
-
if (localStyleCollector?.hasStyles())
|
|
436
|
+
if (localStyleCollector?.hasStyles()) {
|
|
437
|
+
const scopedStyle = descriptor.styles.findLast((style) => STYLE_SCOPED_RE.test(style.attrs));
|
|
438
|
+
if (scopedStyle) {
|
|
439
|
+
const separator = scopedStyle.content.endsWith("\n") ? "" : "\n";
|
|
440
|
+
ms.appendLeft(scopedStyle.end, `${separator}${localStyleCollector.toStyleRules()}`);
|
|
441
|
+
} else ms.append(`\n${localStyleCollector.toStyleBlock()}`);
|
|
442
|
+
}
|
|
327
443
|
}
|
|
328
444
|
const result = {
|
|
329
445
|
code: ms.toString(),
|