weapp-tailwindcss 5.3.2 → 5.3.4
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/source-candidates/types-and-cache.d.ts +3 -0
- package/dist/bundlers/shared/style-requests.d.ts +1 -0
- package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +1 -0
- package/dist/bundlers/vite/shared/framework-module-candidates.d.ts +15 -0
- package/dist/{context-Kvr3lLEC.js → context-4ittVpgt.js} +1 -1
- package/dist/{context-CB4Ef9U0.cjs → context-Ulhcd5lF.cjs} +3 -3
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{gulp-QJ_oz-06.cjs → gulp-CDIXMhIO.cjs} +6 -6
- package/dist/{gulp-vz36-uQP.js → gulp-DwtrU4V1.js} +3 -3
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-W3kro20F.cjs → hmr-timing-DcFB_kwB.cjs} +2 -2
- package/dist/{hmr-timing-HGlM4hX3.js → hmr-timing-utmOgn6p.js} +57 -14
- package/dist/index.cjs +3 -3
- package/dist/index.js +3 -3
- package/dist/local-style-matcher-DRpFEu1s.cjs +34 -0
- package/dist/local-style-matcher-DsiI2wIc.js +17 -0
- package/dist/{options-CKZW99r4.cjs → options-BJrtIQbH.cjs} +3 -1
- package/dist/{pipeline-helpers-t95KPu4O.cjs → pipeline-helpers-kB7Mn2Jy.cjs} +2 -2
- package/dist/presets.cjs +2 -2
- package/dist/presets.js +1 -1
- package/dist/rspack.cjs +2 -2
- package/dist/rspack.js +2 -2
- package/dist/{source-candidate-scan-signature-BSad7bMQ.cjs → source-candidate-scan-signature-C1r5mHSi.cjs} +2 -2
- package/dist/{source-candidate-scan-signature-BHCPQVoD.js → source-candidate-scan-signature-CDrLxVKu.js} +2 -2
- package/dist/{style-options-PCgz2ywM.cjs → style-options-DW30H5PV.cjs} +1 -1
- package/dist/{tailwindcss-jKzY37Sk.cjs → tailwindcss-CexDJBhx.cjs} +1 -1
- package/dist/{tailwindcss-BSEdWieh.js → tailwindcss-ChnpCv25.js} +3 -1
- package/dist/{component-local-style-CNhEhd2B.cjs → transform-BQjg2T2T.cjs} +201 -27
- package/dist/{component-local-style-C2wC8o9F.js → transform-Cp4KybBy.js} +207 -16
- package/dist/types/user-defined-options/important.d.ts +2 -0
- package/dist/uni-app-x/component-local-style.d.ts +6 -4
- package/dist/uni-app-x/local-style-matcher.d.ts +4 -0
- package/dist/uni-app-x/options.d.ts +2 -0
- package/dist/uni-app-x/style-asset/harmony-global.d.ts +2 -0
- package/dist/uni-app-x/transform.d.ts +2 -0
- package/dist/uni-app-x/vite/plugin-options.d.ts +1 -0
- package/dist/uni-app-x/vite/style-request.d.ts +0 -1
- package/dist/{v4-generation-core-BfeXEc6R.cjs → v4-generation-core-OVshPBGo.cjs} +62 -13
- package/dist/{vite-CVr0vIgh.js → vite-D1a6OfVn.js} +130 -91
- package/dist/{vite-Dy6THt54.cjs → vite-cXJPnKXp.cjs} +77 -38
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.cjs +4 -4
- package/dist/{webpack-Cf5RnhXt.cjs → webpack-DOhCcN_2.cjs} +8 -8
- package/dist/{webpack-DwtdWqwr.js → webpack-DQAbh1Z7.js} +4 -4
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +2 -2
- package/dist/transform-CgohToUV.cjs +0 -200
- package/dist/transform-DSRPiBWz.js +0 -201
|
@@ -2,17 +2,17 @@ const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
|
2
2
|
const require_framework = require("./framework.cjs");
|
|
3
3
|
const require_generator = require("./generator-DKiYbTFR.cjs");
|
|
4
4
|
const require_object = require("./object-DbHtAXRk.cjs");
|
|
5
|
-
const require_options = require("./options-
|
|
5
|
+
const require_options = require("./options-BJrtIQbH.cjs");
|
|
6
6
|
require("./utils-CuKLf1Zv.cjs");
|
|
7
|
-
const require_v4_generation_core = require("./v4-generation-core-
|
|
7
|
+
const require_v4_generation_core = require("./v4-generation-core-OVshPBGo.cjs");
|
|
8
8
|
const require_wxml = require("./wxml-CQmBCjOR.cjs");
|
|
9
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
10
|
-
const require_context = require("./context-
|
|
11
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
12
|
-
const require_style_options = require("./style-options-
|
|
13
|
-
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-
|
|
9
|
+
const require_hmr_timing = require("./hmr-timing-DcFB_kwB.cjs");
|
|
10
|
+
const require_context = require("./context-Ulhcd5lF.cjs");
|
|
11
|
+
const require_tailwindcss = require("./tailwindcss-CexDJBhx.cjs");
|
|
12
|
+
const require_style_options = require("./style-options-DW30H5PV.cjs");
|
|
13
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-C1r5mHSi.cjs");
|
|
14
|
+
const require_local_style_matcher = require("./local-style-matcher-DRpFEu1s.cjs");
|
|
14
15
|
require("./logger-TlKT3xmR.cjs");
|
|
15
|
-
const require_component_local_style = require("./component-local-style-CNhEhd2B.cjs");
|
|
16
16
|
const require_css_imports = require("./css-imports-BFMU7Hpd.cjs");
|
|
17
17
|
let node_fs = require("node:fs");
|
|
18
18
|
node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
|
|
@@ -507,6 +507,18 @@ const APP_JS_RE$1 = /(?:^|\/)App\.js$/;
|
|
|
507
507
|
const COMPONENT_JS_RE = /(?:^|\/)components\/.+\.js$/;
|
|
508
508
|
const STYLE_DECL_RE = /const\s+(_style_\d+)\s*=\s*\{/g;
|
|
509
509
|
const EXPORT_SFC_RE = /_export_sfc\(_sfc_main\s*,\s*\[/;
|
|
510
|
+
function resolveSfcSourceId(code) {
|
|
511
|
+
const match = code.match(/\[\s*["']__file["']\s*,\s*(["'])(.*?)\1\s*\]/);
|
|
512
|
+
return match?.[2] ? require_local_style_matcher.normalizeUniAppXLocalStyleId(match[2]) : void 0;
|
|
513
|
+
}
|
|
514
|
+
function shouldExcludeComponent(file, code, options) {
|
|
515
|
+
if (!options.excludeComponents) return false;
|
|
516
|
+
const sourceId = resolveSfcSourceId(code);
|
|
517
|
+
if (sourceId) return require_local_style_matcher.shouldEnableComponentLocalStyle(sourceId, options.componentMatcher);
|
|
518
|
+
const normalizedFile = require_local_style_matcher.normalizeUniAppXLocalStyleId(file);
|
|
519
|
+
if (options.componentMatcher?.(normalizedFile)) return true;
|
|
520
|
+
return COMPONENT_JS_RE.test(normalizedFile);
|
|
521
|
+
}
|
|
510
522
|
function resolveStyleAssetFile(file) {
|
|
511
523
|
if (!UVUE_TS_RE.test(file)) return;
|
|
512
524
|
return file.replace(/\.uvue\.ts$/, ".uvue");
|
|
@@ -610,7 +622,7 @@ function injectStyleOption(code, styleVarName) {
|
|
|
610
622
|
}
|
|
611
623
|
function injectUniAppXHarmonyGlobalStyles(file, code, getBundleSource, options = {}) {
|
|
612
624
|
if (!JS_RE.test(file) || APP_JS_RE$1.test(file)) return code;
|
|
613
|
-
if (
|
|
625
|
+
if (shouldExcludeComponent(file, code, options)) return code;
|
|
614
626
|
const appSource = getBundleSource?.("assets/App.js") ?? getBundleSource?.("App.js");
|
|
615
627
|
const appStyle = appSource ? mergeStyleValues(...findStyleObjectDecls(appSource).map((decl) => parseStyleObject(decl.objectText))) : void 0;
|
|
616
628
|
const parseableLocalStyles = findStyleObjectDecls(code).flatMap((decl) => {
|
|
@@ -2089,17 +2101,17 @@ function extractSfcStyleSources(source) {
|
|
|
2089
2101
|
function hasSfcStyleSources(source) {
|
|
2090
2102
|
return extractSfcStyleSources(source).length > 0;
|
|
2091
2103
|
}
|
|
2104
|
+
function resolveSfcStyleBlockLang(attrs) {
|
|
2105
|
+
const match = SFC_LANG_STYLE_ATTR_RE.exec(attrs);
|
|
2106
|
+
return match?.[1] ?? match?.[2] ?? match?.[3];
|
|
2107
|
+
}
|
|
2092
2108
|
function resolveSfcStyleHandlerSourceFile(sourceFile, styleBlocks) {
|
|
2093
2109
|
const scopedStyleBlock = styleBlocks.find((style) => style.scoped);
|
|
2094
|
-
return scopedStyleBlock ? `${sourceFile}?vue&type=style&index=${scopedStyleBlock.index}&scoped=true` : sourceFile;
|
|
2110
|
+
return scopedStyleBlock ? [`${sourceFile}?vue&type=style&index=${scopedStyleBlock.index}&scoped=true`, ...resolveSfcStyleBlockLang(scopedStyleBlock.attrs) ? [`lang=${encodeURIComponent(resolveSfcStyleBlockLang(scopedStyleBlock.attrs))}`] : []].join("&") : sourceFile;
|
|
2095
2111
|
}
|
|
2096
2112
|
function normalizeSfcStyleSourceForCompare(source) {
|
|
2097
2113
|
return source.replace(/\r\n?/g, "\n").trim();
|
|
2098
2114
|
}
|
|
2099
|
-
function resolveSfcStyleBlockLang(attrs) {
|
|
2100
|
-
const match = SFC_LANG_STYLE_ATTR_RE.exec(attrs);
|
|
2101
|
-
return match?.[1] ?? match?.[2] ?? match?.[3];
|
|
2102
|
-
}
|
|
2103
2115
|
function createSfcStyleRequest(sourceFile, styleBlock) {
|
|
2104
2116
|
const params = new URLSearchParams();
|
|
2105
2117
|
params.set("vue", "");
|
|
@@ -6239,25 +6251,12 @@ function createUniAppXNativeBuildTargetResolver(getResolvedConfig) {
|
|
|
6239
6251
|
}
|
|
6240
6252
|
//#endregion
|
|
6241
6253
|
//#region src/uni-app-x/vite/style-request.ts
|
|
6242
|
-
const preprocessorLangs = /* @__PURE__ */ new Set([
|
|
6243
|
-
"scss",
|
|
6244
|
-
"sass",
|
|
6245
|
-
"less",
|
|
6246
|
-
"styl",
|
|
6247
|
-
"stylus"
|
|
6248
|
-
]);
|
|
6249
|
-
const INLINE_LANG_RE = /lang\.([a-z]+)/i;
|
|
6250
|
-
const PREPROCESSOR_EXT_RE = /\.(?:scss|sass|less|styl|stylus)(?:\?|$)/i;
|
|
6251
6254
|
const UVUE_NVUE_RE$1 = /\.(?:uvue|nvue)$/;
|
|
6252
6255
|
const CSS_MODULE_EXPORT_RE = /^\s*export\s+default\s+(?:\{|\w|\[\])/;
|
|
6253
6256
|
const RELATIVE_REFERENCE_RE = /@reference\s+(["'])(\.\.?[\\/][^"']+)\1\s*;?/g;
|
|
6254
6257
|
const WINDOWS_ABSOLUTE_PATH_RE = /^[a-z]:[\\/]/i;
|
|
6255
6258
|
function isPreprocessorRequest(id, lang) {
|
|
6256
|
-
|
|
6257
|
-
if (normalizedLang && preprocessorLangs.has(normalizedLang)) return true;
|
|
6258
|
-
const inlineLang = id.match(INLINE_LANG_RE)?.[1];
|
|
6259
|
-
if (inlineLang && preprocessorLangs.has(inlineLang.toLowerCase())) return true;
|
|
6260
|
-
return PREPROCESSOR_EXT_RE.test(id);
|
|
6259
|
+
return require_v4_generation_core.isSourcePreprocessorRequest(id, lang);
|
|
6261
6260
|
}
|
|
6262
6261
|
function resolveUniAppXCssTarget(id) {
|
|
6263
6262
|
return UVUE_NVUE_RE$1.test((0, _weapp_tailwindcss_shared.cleanUrl)(id)) ? "uvue" : void 0;
|
|
@@ -6283,7 +6282,7 @@ function resolvePreprocessorTransform(code, id, lang, options) {
|
|
|
6283
6282
|
map: null
|
|
6284
6283
|
} };
|
|
6285
6284
|
}
|
|
6286
|
-
if (
|
|
6285
|
+
if (!options.isNativeAppStyleTarget) return { result: void 0 };
|
|
6287
6286
|
}
|
|
6288
6287
|
//#endregion
|
|
6289
6288
|
//#region src/uni-app-x/vite/web-local-style.ts
|
|
@@ -6315,7 +6314,7 @@ function createUniAppXWebLocalStyleBridge(isEnabled) {
|
|
|
6315
6314
|
//#region src/uni-app-x/vite.ts
|
|
6316
6315
|
let transformUVuePromise;
|
|
6317
6316
|
function loadTransformUVue() {
|
|
6318
|
-
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-
|
|
6317
|
+
transformUVuePromise ?? (transformUVuePromise = Promise.resolve().then(() => require("./transform-BQjg2T2T.cjs")).then((mod) => mod.transformUVue));
|
|
6319
6318
|
return transformUVuePromise;
|
|
6320
6319
|
}
|
|
6321
6320
|
const UVUE_NVUE_QUERY_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
@@ -6324,7 +6323,7 @@ function resolveUniAppXJsTransformEnabled(uniAppX) {
|
|
|
6324
6323
|
return uniAppX === void 0 ? true : require_options.isUniAppXEnabled(uniAppX);
|
|
6325
6324
|
}
|
|
6326
6325
|
function createUniAppXPlugins(options) {
|
|
6327
|
-
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, runtimeState, styleHandler, syncSourceCandidatesForHotUpdate, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, isNativeAppStyleTarget = () => false, isWebGeneratorTarget = () => require_generator.resolveUniUtsPlatform().isWeb, uniAppX, viteProcessedCssSourceFiles = [] } = options;
|
|
6326
|
+
const { appType, customAttributesEntities, disabledDefaultTemplateHandler, isIosPlatform: providedIosPlatform, mainCssChunkMatcher, registerModuleGraphCandidates, runtimeState, styleHandler, syncSourceCandidatesForHotUpdate, tailwindRootCssModuleIds = [], generateCss, jsHandler, ensureRuntimeClassSet, getResolvedConfig, isEnabled = () => true, isNativeAppStyleTarget = () => false, isWebGeneratorTarget = () => require_generator.resolveUniUtsPlatform().isWeb, uniAppX, viteProcessedCssSourceFiles = [] } = options;
|
|
6328
6327
|
const resolvedUniAppXOptions = require_options.resolveUniAppXOptions(uniAppX);
|
|
6329
6328
|
const utsPlatform = require_generator.resolveUniUtsPlatform();
|
|
6330
6329
|
const isIosPlatform = providedIosPlatform ?? utsPlatform.isAppIos;
|
|
@@ -6356,7 +6355,7 @@ function createUniAppXPlugins(options) {
|
|
|
6356
6355
|
return componentLocalStyleEnabled;
|
|
6357
6356
|
}
|
|
6358
6357
|
function shouldEnablePageLocalStyleForFile(id) {
|
|
6359
|
-
return resolvedUniAppXOptions.componentLocalStyles.enabled && (isNativeAppBuildTarget(id) ||
|
|
6358
|
+
return resolvedUniAppXOptions.componentLocalStyles.enabled && (isNativeAppBuildTarget(id) || require_local_style_matcher.shouldEnablePageLocalStyle(id, resolvedUniAppXOptions.componentLocalStyles.pageMatcher));
|
|
6360
6359
|
}
|
|
6361
6360
|
function isHarmonyBuildTarget() {
|
|
6362
6361
|
if (require_generator.resolveUniUtsPlatform().isAppHarmony) return true;
|
|
@@ -6445,8 +6444,7 @@ function createUniAppXPlugins(options) {
|
|
|
6445
6444
|
const styleCode = query.vue && query.type === "style" ? webLocalStyle.appendToStyle(code, id) : code;
|
|
6446
6445
|
const preprocessor = resolvePreprocessorTransform(styleCode, id, query.lang, {
|
|
6447
6446
|
isIosPlatform,
|
|
6448
|
-
isNativeAppStyleTarget: isNativeAppStyleTarget()
|
|
6449
|
-
isWebGeneratorTarget: isWebGeneratorTarget()
|
|
6447
|
+
isNativeAppStyleTarget: isNativeAppStyleTarget()
|
|
6450
6448
|
});
|
|
6451
6449
|
if (preprocessor) return preprocessor.result ?? (styleCode !== code ? {
|
|
6452
6450
|
code: styleCode,
|
|
@@ -6461,18 +6459,22 @@ function createUniAppXPlugins(options) {
|
|
|
6461
6459
|
nativeLocalStyleModuleIds.add((0, _weapp_tailwindcss_shared.cleanUrl)(id));
|
|
6462
6460
|
}
|
|
6463
6461
|
harmonyApply.rememberSource(code, id, true);
|
|
6462
|
+
const enableComponentLocalStyle = shouldEnableComponentLocalStyle();
|
|
6463
|
+
const enablePageLocalStyle = shouldEnablePageLocalStyleForFile(id);
|
|
6464
6464
|
const resolvedConfig = getResolvedConfig();
|
|
6465
6465
|
const shouldForceRefresh = resolvedConfig?.command === "serve" || resolvedConfig?.command === "build";
|
|
6466
|
-
const
|
|
6466
|
+
const moduleGraphCandidates = enableComponentLocalStyle || enablePageLocalStyle ? await registerModuleGraphCandidates?.(id, code) : void 0;
|
|
6467
|
+
const runtimeSet = await ensureRuntimeClassSet(shouldForceRefresh);
|
|
6468
|
+
const currentRuntimeSet = moduleGraphCandidates?.size ? /* @__PURE__ */ new Set([...runtimeSet, ...moduleGraphCandidates]) : runtimeSet;
|
|
6467
6469
|
nativeHmrReloader.remember(currentRuntimeSet);
|
|
6468
6470
|
const transformUVue = await loadTransformUVue();
|
|
6469
|
-
const enableComponentLocalStyle = shouldEnableComponentLocalStyle();
|
|
6470
|
-
const enablePageLocalStyle = shouldEnablePageLocalStyleForFile(id);
|
|
6471
6471
|
const transformOptions = require_object.omitUndefined({
|
|
6472
|
+
componentMatcher: resolvedUniAppXOptions.componentLocalStyles.componentMatcher,
|
|
6472
6473
|
...customAttributesEntities.length > 0 ? { customAttributesEntities } : {},
|
|
6473
6474
|
...disabledDefaultTemplateHandler ? { disabledDefaultTemplateHandler } : {},
|
|
6474
6475
|
...enableComponentLocalStyle ? { enableComponentLocalStyle } : {},
|
|
6475
6476
|
...enablePageLocalStyle ? { enablePageLocalStyle } : {},
|
|
6477
|
+
pageMatcher: resolvedUniAppXOptions.componentLocalStyles.pageMatcher,
|
|
6476
6478
|
...isWebGeneratorTarget() && customAttributesEntities.length > 0 ? { webCustomAttributeDeep: true } : {},
|
|
6477
6479
|
...isWebGeneratorTarget() ? { onWebLocalStyleRules: (rules) => webLocalStyle.remember(id, rules) } : {}
|
|
6478
6480
|
});
|
|
@@ -6545,6 +6547,7 @@ function createUniAppXPlugins(options) {
|
|
|
6545
6547
|
}
|
|
6546
6548
|
injectUniAppXHarmonyBundleStyles(bundle, {
|
|
6547
6549
|
cssSources,
|
|
6550
|
+
componentMatcher: resolvedUniAppXOptions.componentLocalStyles.componentMatcher,
|
|
6548
6551
|
excludeComponents: shouldEnableComponentLocalStyle()
|
|
6549
6552
|
});
|
|
6550
6553
|
}
|
|
@@ -6740,7 +6743,7 @@ function logBundleProcessPlan(options) {
|
|
|
6740
6743
|
//#region src/bundlers/vite/generate-bundle/remembered-css-replay.ts
|
|
6741
6744
|
function shouldSkipRawRememberedCssSource(rawSource, sourceFile) {
|
|
6742
6745
|
const cleanSourceFile = sourceFile.replace(/[?#].*$/, "");
|
|
6743
|
-
return SOURCE_STYLE_OUTPUT_EXT_RE.test(cleanSourceFile) && !canProcessViteSourceStyleAsCss(rawSource, sourceFile);
|
|
6746
|
+
return (SOURCE_STYLE_OUTPUT_EXT_RE.test(cleanSourceFile) || require_v4_generation_core.isSourcePreprocessorRequest(sourceFile)) && !canProcessViteSourceStyleAsCss(rawSource, sourceFile);
|
|
6744
6747
|
}
|
|
6745
6748
|
function resolveRememberedCssReplayOutputFile(outputFile, targetByFile) {
|
|
6746
6749
|
const outputKey = require_source_candidate_scan_signature.normalizeOutputPathKey(outputFile);
|
|
@@ -9476,6 +9479,29 @@ function createViteHmrCandidateState(options) {
|
|
|
9476
9479
|
};
|
|
9477
9480
|
}
|
|
9478
9481
|
//#endregion
|
|
9482
|
+
//#region src/bundlers/vite/shared/framework-module-candidates.ts
|
|
9483
|
+
function createFrameworkModuleCandidateRegistrar(options) {
|
|
9484
|
+
return async (id, source) => {
|
|
9485
|
+
await options.runtimeState.readyPromise;
|
|
9486
|
+
const candidates = await options.sourceCandidateCollector.syncModuleSource(id, source);
|
|
9487
|
+
options.invalidateRecordedGeneratorCandidates();
|
|
9488
|
+
options.cacheCurrent();
|
|
9489
|
+
const cssHandlerOptions = options.getCssHandlerOptions(id);
|
|
9490
|
+
return require_v4_generation_core.validateCandidatesByGenerator({
|
|
9491
|
+
candidates,
|
|
9492
|
+
cssHandlerOptions,
|
|
9493
|
+
cssUserHandlerOptions: cssHandlerOptions,
|
|
9494
|
+
debug: options.debug,
|
|
9495
|
+
file: (0, _weapp_tailwindcss_shared.cleanUrl)(id),
|
|
9496
|
+
generatorPlatform: options.getGeneratorPlatform(),
|
|
9497
|
+
opts: options.opts,
|
|
9498
|
+
rawSource: "",
|
|
9499
|
+
runtimeState: options.runtimeState,
|
|
9500
|
+
styleHandler: options.styleHandler
|
|
9501
|
+
});
|
|
9502
|
+
};
|
|
9503
|
+
}
|
|
9504
|
+
//#endregion
|
|
9479
9505
|
//#region src/bundlers/vite/shared/framework-plugin-order.ts
|
|
9480
9506
|
function orderFrameworkSourceCandidatePlugins(extraPlugins, rewritePlugins, sourceCandidatesPlugin, beforeExtraPlugin) {
|
|
9481
9507
|
const anchor = beforeExtraPlugin ? extraPlugins.findIndex(beforeExtraPlugin) : -1;
|
|
@@ -10783,6 +10809,17 @@ ${tracedCss}`;
|
|
|
10783
10809
|
});
|
|
10784
10810
|
const extraPluginPlatform = frameworkBranch.getExtraPluginPlatform?.() ?? {};
|
|
10785
10811
|
const syncSourceCandidatesForHotUpdate = (ctx) => syncFrameworkSourceCandidatesForHotUpdate(sourceScanSession, ctx);
|
|
10812
|
+
const registerModuleGraphCandidates = createFrameworkModuleCandidateRegistrar({
|
|
10813
|
+
cacheCurrent: sourceScanSession.cacheCurrent,
|
|
10814
|
+
debug,
|
|
10815
|
+
getCssHandlerOptions: transformCssHandlerOptions.getCssHandlerOptions,
|
|
10816
|
+
getGeneratorPlatform: resolveGeneratorPlatform,
|
|
10817
|
+
invalidateRecordedGeneratorCandidates,
|
|
10818
|
+
opts,
|
|
10819
|
+
runtimeState,
|
|
10820
|
+
sourceCandidateCollector,
|
|
10821
|
+
styleHandler
|
|
10822
|
+
});
|
|
10786
10823
|
const prepareTailwindGeneration = async () => {
|
|
10787
10824
|
if (sourceScanSession.shouldDiscoverAutoCssSources(autoCssSourcesDiscovered)) await discoverAndRegisterAutoCssSources();
|
|
10788
10825
|
await sourceScanSession.sync();
|
|
@@ -10799,6 +10836,7 @@ ${tracedCss}`;
|
|
|
10799
10836
|
isWebGeneratorTarget: () => resolveCurrentGeneratorBranch().isWeb,
|
|
10800
10837
|
jsHandler,
|
|
10801
10838
|
mainCssChunkMatcher,
|
|
10839
|
+
registerModuleGraphCandidates,
|
|
10802
10840
|
runtimeState,
|
|
10803
10841
|
styleHandler,
|
|
10804
10842
|
syncSourceCandidatesForHotUpdate,
|
|
@@ -11220,6 +11258,7 @@ function createUniAppXVitePlugins(options = {}) {
|
|
|
11220
11258
|
isWebGeneratorTarget: context.isWebGeneratorTarget,
|
|
11221
11259
|
jsHandler: context.jsHandler,
|
|
11222
11260
|
mainCssChunkMatcher: context.mainCssChunkMatcher,
|
|
11261
|
+
registerModuleGraphCandidates: context.registerModuleGraphCandidates,
|
|
11223
11262
|
runtimeState: context.runtimeState,
|
|
11224
11263
|
styleHandler: context.styleHandler,
|
|
11225
11264
|
syncSourceCandidatesForHotUpdate: context.syncSourceCandidatesForHotUpdate,
|
package/dist/vite.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_vite = require("./vite-
|
|
2
|
+
const require_vite = require("./vite-cXJPnKXp.cjs");
|
|
3
3
|
exports.WeappTailwindcss = require_vite.WeappTailwindcss;
|
|
4
4
|
exports.weappTailwindcss = require_vite.WeappTailwindcss;
|
package/dist/vite.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as WeappTailwindcss } from "./vite-
|
|
1
|
+
import { t as WeappTailwindcss } from "./vite-D1a6OfVn.js";
|
|
2
2
|
export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss };
|
|
@@ -4,11 +4,11 @@ Object.defineProperties(exports, {
|
|
|
4
4
|
});
|
|
5
5
|
const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
6
6
|
const require_generator = require("./generator-DKiYbTFR.cjs");
|
|
7
|
-
const require_options = require("./options-
|
|
8
|
-
const require_v4_generation_core = require("./v4-generation-core-
|
|
9
|
-
const require_style_options = require("./style-options-
|
|
7
|
+
const require_options = require("./options-BJrtIQbH.cjs");
|
|
8
|
+
const require_v4_generation_core = require("./v4-generation-core-OVshPBGo.cjs");
|
|
9
|
+
const require_style_options = require("./style-options-DW30H5PV.cjs");
|
|
10
10
|
const require_css_imports = require("./css-imports-BFMU7Hpd.cjs");
|
|
11
|
-
const require_pipeline_helpers = require("./pipeline-helpers-
|
|
11
|
+
const require_pipeline_helpers = require("./pipeline-helpers-kB7Mn2Jy.cjs");
|
|
12
12
|
const require_runtime_registry = require("./runtime-registry-BlIjpImP.cjs");
|
|
13
13
|
const require_watch_dependencies = require("./watch-dependencies-DLZDrWdH.cjs");
|
|
14
14
|
let node_path = require("node:path");
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
2
2
|
const require_generator = require("./generator-DKiYbTFR.cjs");
|
|
3
3
|
const require_object = require("./object-DbHtAXRk.cjs");
|
|
4
|
-
const require_options = require("./options-
|
|
4
|
+
const require_options = require("./options-BJrtIQbH.cjs");
|
|
5
5
|
const require_utils = require("./utils-CuKLf1Zv.cjs");
|
|
6
|
-
const require_v4_generation_core = require("./v4-generation-core-
|
|
6
|
+
const require_v4_generation_core = require("./v4-generation-core-OVshPBGo.cjs");
|
|
7
7
|
const require_wxml = require("./wxml-CQmBCjOR.cjs");
|
|
8
|
-
const require_hmr_timing = require("./hmr-timing-
|
|
9
|
-
const require_context = require("./context-
|
|
10
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
11
|
-
const require_style_options = require("./style-options-
|
|
12
|
-
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-
|
|
13
|
-
const require_pipeline_helpers = require("./pipeline-helpers-
|
|
8
|
+
const require_hmr_timing = require("./hmr-timing-DcFB_kwB.cjs");
|
|
9
|
+
const require_context = require("./context-Ulhcd5lF.cjs");
|
|
10
|
+
const require_tailwindcss = require("./tailwindcss-CexDJBhx.cjs");
|
|
11
|
+
const require_style_options = require("./style-options-DW30H5PV.cjs");
|
|
12
|
+
const require_source_candidate_scan_signature = require("./source-candidate-scan-signature-C1r5mHSi.cjs");
|
|
13
|
+
const require_pipeline_helpers = require("./pipeline-helpers-kB7Mn2Jy.cjs");
|
|
14
14
|
const require_css_loader_runtime = require("./css-loader-runtime-CSv0lKqV.cjs");
|
|
15
15
|
const require_runtime_registry = require("./runtime-registry-BlIjpImP.cjs");
|
|
16
16
|
let node_fs = require("node:fs");
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { $ as hasTailwindSourceDirectives, B as stripMiniProgramCssSpecificityPlaceholders, D as resolveTailwindcssOptions, F as stripUnmatchedTailwindSourceMediaCloseFragments, I as finalizeMiniProgramCss, M as removeMiniProgramInteractiveSelectors, N as removeTailwindV4GeneratorAtRules, Ot as resolveSourceScanPath, P as stripTailwindSourceMediaFragments, Pt as getTailwindV4IncrementalGenerateCacheStats, Q as hasTailwindRootDirectives, R as pruneMiniProgramGeneratedCss, V as removeTailwindV4GeneratedUserCssArtifacts, X as hasTailwindApplyDirective, _ as upsertTailwindV4CssSource, et as normalizeTailwindConfigDirectives, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, it as removeTailwindSourceDirectives, j as isCommentOnlyCss, lt as hasTailwindGeneratedCss, o as resolveRuntimeBranch, rt as parseImportRequest, ut as hasTailwindGeneratedCssMarkers } from "./generator-EnTXLBlK.js";
|
|
2
2
|
import { n as _defineProperty } from "./object-B-8IHefx.js";
|
|
3
|
-
import { f as resolveSourceScanEntries, g as resolveTailwindV4EntriesFromCssCached, l as getRuntimeClassSetSignature } from "./tailwindcss-
|
|
3
|
+
import { f as resolveSourceScanEntries, g as resolveTailwindV4EntriesFromCssCached, l as getRuntimeClassSetSignature } from "./tailwindcss-ChnpCv25.js";
|
|
4
4
|
import { r as getGroupedEntries } from "./utils-MVwpU07P.js";
|
|
5
|
-
import { $ as
|
|
5
|
+
import { $ as AssetEmissionPlan, C as isSourceStyleRequest, E as hasBundlerGeneratedCssMarker, F as processCachedTask, G as createRuntimeCompilationBuildState, H as finalizeCompilerShadowRun, I as createRuntimeClassSetManager, J as updateRuntimeCompilationBuildState, L as collectStrictEscapedRuntimeCandidates, M as createCssSourceTraceCacheSignature, N as createCssTokenSourceMap, O as stripBundlerGeneratedCssMarkers, P as isCssSourceTraceEnabled, R as createEscapeFragments, U as buildRuntimeCompilationSnapshot, W as createRuntimeCompilationAffectingSignature, X as disposeCompilerOwner, Y as createRuntimeAffectingSourceSignature, Z as beginCompilerShadowRun, _ as captureResolvedFrameworkPostcssOptions, at as createSourceCandidateStore, c as collectRawSourceClassSelectors, et as getCompilationScopeDependencyRevision, h as removeGeneratedSelectorCompatCss, j as annotateCssSourceTrace, k as finalizeMiniProgramCssStructure, l as pushConcurrentTaskFactories, lt as resolveSourceCandidateScanFiles, m as scoreTailwindV4CssSourceFileMatch, n as emitHmrTiming, nt as recordCompilationDependencyChanges, ot as isSourceCandidateRequest, q as resetRuntimeCompilationBuildState, r as generateTailwindV4Css, rt as createCompilationDependencyChanges, u as resolveTaskConcurrency, v as collectFrameworkPostcssOptionsFromLoaderEntries, w as stripRequestQuery, x as hasMiniProgramTailwindV4PreflightReset, y as createCssSourceOrderAppend, z as isPureLocalCssImportWrapper } from "./hmr-timing-utmOgn6p.js";
|
|
6
6
|
import { _ as md5Hash, m as createDebug } from "./wxml-B7OAVpXJ.js";
|
|
7
|
-
import { d as refreshTailwindRuntimeState, i as pluginName, l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, r as resolveStyleOptionsFromContext, t as getCompilerContext, u as ensureRuntimeClassSet } from "./context-
|
|
7
|
+
import { d as refreshTailwindRuntimeState, i as pluginName, l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, r as resolveStyleOptionsFromContext, t as getCompilerContext, u as ensureRuntimeClassSet } from "./context-4ittVpgt.js";
|
|
8
8
|
import { getDefaultCssPreflight } from "./defaults.js";
|
|
9
|
-
import { S as resolveWebpackFrameworkProfile, a as createCandidateSignature, b as webpackStyleInjectorDelegates, d as classifyRuntimeEntry, f as resolvePackageDir, g as toAbsoluteOutputPath, h as resolveOutputSpecifier, p as resolvePluginDisabledState, r as createScopedGeneratorRuntime, t as createSourceCandidateScanSignature, v as createBuiltinWebpackStyleInjectorPlugin } from "./source-candidate-scan-signature-
|
|
9
|
+
import { S as resolveWebpackFrameworkProfile, a as createCandidateSignature, b as webpackStyleInjectorDelegates, d as classifyRuntimeEntry, f as resolvePackageDir, g as toAbsoluteOutputPath, h as resolveOutputSpecifier, p as resolvePluginDisabledState, r as createScopedGeneratorRuntime, t as createSourceCandidateScanSignature, v as createBuiltinWebpackStyleInjectorPlugin } from "./source-candidate-scan-signature-CDrLxVKu.js";
|
|
10
10
|
import Module, { createRequire } from "node:module";
|
|
11
11
|
import fs from "node:fs";
|
|
12
12
|
import path from "node:path";
|
package/dist/webpack.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_webpack = require("./webpack-
|
|
2
|
+
const require_webpack = require("./webpack-DOhCcN_2.cjs");
|
|
3
3
|
exports.WeappTailwindcss = require_webpack.WeappTailwindcss;
|
|
4
4
|
exports.weappTailwindcss = require_webpack.WeappTailwindcss;
|
|
5
5
|
exports.weappTailwindcssPackageDir = require_webpack.weappTailwindcssPackageDir;
|
package/dist/webpack.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as weappTailwindcssPackageDir, t as WeappTailwindcss } from "./webpack-
|
|
1
|
+
import { n as weappTailwindcssPackageDir, t as WeappTailwindcss } from "./webpack-DQAbh1Z7.js";
|
|
2
2
|
export { WeappTailwindcss, WeappTailwindcss as weappTailwindcss, weappTailwindcssPackageDir };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-tailwindcss",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.3.
|
|
4
|
+
"version": "5.3.4",
|
|
5
5
|
"description": "Bring Tailwind CSS to every platform! 把 Tailwind CSS 的原子化开发体验带到全端!",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -213,9 +213,9 @@
|
|
|
213
213
|
"yaml": "^2.9.0",
|
|
214
214
|
"@weapp-tailwindcss/logger": "2.0.2",
|
|
215
215
|
"@weapp-tailwindcss/postcss": "3.2.11",
|
|
216
|
+
"@weapp-tailwindcss/shared": "2.0.2",
|
|
216
217
|
"tailwindcss-config": "2.0.3",
|
|
217
218
|
"weapp-style-injector": "1.0.3",
|
|
218
|
-
"@weapp-tailwindcss/shared": "2.0.2",
|
|
219
219
|
"@weapp-tailwindcss/reset": "0.1.3"
|
|
220
220
|
},
|
|
221
221
|
"devDependencies": {
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
const require_wxml = require("./wxml-CQmBCjOR.cjs");
|
|
2
|
-
const require_component_local_style = require("./component-local-style-CNhEhd2B.cjs");
|
|
3
|
-
let _vue_compiler_dom = require("@vue/compiler-dom");
|
|
4
|
-
//#region src/uni-app-x/transform.ts
|
|
5
|
-
function traverse(node, visitor) {
|
|
6
|
-
visitor(node);
|
|
7
|
-
if (Array.isArray(node.children)) {
|
|
8
|
-
for (const child of node.children) if (child && typeof child === "object" && "type" in child) traverse(child, visitor);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
function updateStaticAttribute(ms, prop, offset, content = prop.value?.content) {
|
|
12
|
-
if (!prop.value) return;
|
|
13
|
-
const start = offset + prop.value.loc.start.offset + 1;
|
|
14
|
-
const end = offset + prop.value.loc.end.offset - 1;
|
|
15
|
-
if (start < end) ms.update(start, end, require_wxml.replaceWxml(content ?? ""));
|
|
16
|
-
}
|
|
17
|
-
function updateStaticAttributeWithLocalStyle(ms, prop, offset, collector, deep, content = prop.value?.content) {
|
|
18
|
-
if (!prop.value) return;
|
|
19
|
-
const start = offset + prop.value.loc.start.offset + 1;
|
|
20
|
-
const end = offset + prop.value.loc.end.offset - 1;
|
|
21
|
-
if (start < end) ms.update(start, end, collector.collectAndRewriteStaticClass(content ?? "", { deep }));
|
|
22
|
-
}
|
|
23
|
-
function updateDirectiveExpression(ms, prop, offset, jsHandler, runtimeSet) {
|
|
24
|
-
if (prop.exp?.type !== _vue_compiler_dom.NodeTypes.SIMPLE_EXPRESSION) return;
|
|
25
|
-
const expression = prop.exp.content;
|
|
26
|
-
const start = offset + prop.exp.loc.start.offset;
|
|
27
|
-
const end = offset + prop.exp.loc.end.offset;
|
|
28
|
-
if (start >= end) return;
|
|
29
|
-
const generated = require_wxml.generateCode(expression, {
|
|
30
|
-
jsHandler,
|
|
31
|
-
runtimeSet,
|
|
32
|
-
wrapExpression: true
|
|
33
|
-
});
|
|
34
|
-
ms.update(start, end, generated);
|
|
35
|
-
}
|
|
36
|
-
function updateDirectiveExpressionWithLocalStyle(ms, prop, offset, jsHandler, collector, deep, runtimeSet) {
|
|
37
|
-
if (prop.exp?.type !== _vue_compiler_dom.NodeTypes.SIMPLE_EXPRESSION) return;
|
|
38
|
-
const expression = prop.exp.content;
|
|
39
|
-
const start = offset + prop.exp.loc.start.offset;
|
|
40
|
-
const end = offset + prop.exp.loc.end.offset;
|
|
41
|
-
if (start >= end) return;
|
|
42
|
-
collector.collectRuntimeClasses(expression, {
|
|
43
|
-
deep,
|
|
44
|
-
wrapExpression: true
|
|
45
|
-
});
|
|
46
|
-
const generated = require_wxml.generateCode(expression, {
|
|
47
|
-
jsHandler,
|
|
48
|
-
runtimeSet,
|
|
49
|
-
wrapExpression: true
|
|
50
|
-
});
|
|
51
|
-
ms.update(start, end, collector.rewriteTransformedCode(generated, { wrapExpression: true }));
|
|
52
|
-
}
|
|
53
|
-
function shouldEnableLocalStyle(id, options) {
|
|
54
|
-
if (options.enableComponentLocalStyle && require_component_local_style.shouldEnableComponentLocalStyle(id)) return true;
|
|
55
|
-
if (options.enablePageLocalStyle && require_component_local_style.shouldEnablePageLocalStyle(id)) return true;
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
function shouldHandleAttribute(tag, attrName, disabledDefaultTemplateHandler, matchCustomAttribute) {
|
|
59
|
-
const lowerName = attrName.toLowerCase();
|
|
60
|
-
const shouldHandleDefault = !disabledDefaultTemplateHandler && lowerName === "class";
|
|
61
|
-
const shouldHandleCustom = matchCustomAttribute?.(tag, attrName) ?? false;
|
|
62
|
-
return {
|
|
63
|
-
shouldHandleDefault,
|
|
64
|
-
shouldHandleCustom,
|
|
65
|
-
shouldHandle: shouldHandleDefault || shouldHandleCustom
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
const defaultCreateJsHandlerOptions = { babelParserOptions: { plugins: ["typescript"] } };
|
|
69
|
-
const UVUE_NVUE_RE = /\.(?:uvue|nvue)(?:\?.*)?$/;
|
|
70
|
-
const SFC_BLOCK_RE = /<(template|script|style)\b([^>]*)>/gi;
|
|
71
|
-
const SCRIPT_SETUP_RE = /(?:^|\s)setup(?:\s|=|$)/;
|
|
72
|
-
const STYLE_SCOPED_RE = /(?:^|\s)scoped(?:\s|=|$)/i;
|
|
73
|
-
function findSfcBlockEnd(code, type, contentStart) {
|
|
74
|
-
const closeTag = new RegExp(`<\\/${type}\\s*>`, "gi");
|
|
75
|
-
if (type !== "template") {
|
|
76
|
-
const match = closeTag.exec(code.slice(contentStart));
|
|
77
|
-
return match ? {
|
|
78
|
-
blockEnd: contentStart + match.index + match[0].length,
|
|
79
|
-
contentEnd: contentStart + match.index
|
|
80
|
-
} : void 0;
|
|
81
|
-
}
|
|
82
|
-
const tag = new RegExp(`<\\/?${type}\\b[^>]*>`, "gi");
|
|
83
|
-
tag.lastIndex = contentStart;
|
|
84
|
-
let depth = 1;
|
|
85
|
-
let match = tag.exec(code);
|
|
86
|
-
while (match) {
|
|
87
|
-
if (match[0].startsWith("</")) depth -= 1;
|
|
88
|
-
else if (!match[0].trimEnd().endsWith("/>")) depth += 1;
|
|
89
|
-
if (depth === 0) return {
|
|
90
|
-
blockEnd: tag.lastIndex,
|
|
91
|
-
contentEnd: match.index
|
|
92
|
-
};
|
|
93
|
-
match = tag.exec(code);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
function parseSfc(code) {
|
|
97
|
-
const descriptor = {
|
|
98
|
-
errors: [],
|
|
99
|
-
styles: []
|
|
100
|
-
};
|
|
101
|
-
for (const match of code.matchAll(SFC_BLOCK_RE)) {
|
|
102
|
-
const type = match[1];
|
|
103
|
-
const attrs = match[2] ?? "";
|
|
104
|
-
const contentStart = (match.index ?? 0) + match[0].length;
|
|
105
|
-
const blockBoundary = findSfcBlockEnd(code, type, contentStart);
|
|
106
|
-
if (!blockBoundary) {
|
|
107
|
-
descriptor.errors.push(/* @__PURE__ */ new Error(`未闭合的 ${type} SFC 块`));
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
const { contentEnd } = blockBoundary;
|
|
111
|
-
const content = code.slice(contentStart, contentEnd);
|
|
112
|
-
const block = {
|
|
113
|
-
content,
|
|
114
|
-
start: contentStart,
|
|
115
|
-
end: contentEnd,
|
|
116
|
-
attrs
|
|
117
|
-
};
|
|
118
|
-
if (type === "template" && !descriptor.template) {
|
|
119
|
-
try {
|
|
120
|
-
descriptor.template = {
|
|
121
|
-
...block,
|
|
122
|
-
ast: (0, _vue_compiler_dom.parse)(content)
|
|
123
|
-
};
|
|
124
|
-
} catch (error) {
|
|
125
|
-
descriptor.errors.push(error);
|
|
126
|
-
descriptor.template = block;
|
|
127
|
-
}
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
if (type === "script") {
|
|
131
|
-
if (SCRIPT_SETUP_RE.test(attrs)) descriptor.scriptSetup ?? (descriptor.scriptSetup = block);
|
|
132
|
-
else descriptor.script ?? (descriptor.script = block);
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
if (type === "style") descriptor.styles.push(block);
|
|
136
|
-
}
|
|
137
|
-
return descriptor;
|
|
138
|
-
}
|
|
139
|
-
function transformUVue(code, id, jsHandler, runtimeSet, options = {}) {
|
|
140
|
-
if (!UVUE_NVUE_RE.test(id)) return;
|
|
141
|
-
const { customAttributesEntities, disabledDefaultTemplateHandler = false } = options;
|
|
142
|
-
const matchCustomAttribute = require_wxml.createAttributeMatcher(customAttributesEntities);
|
|
143
|
-
const ms = new require_wxml.MagicString(code);
|
|
144
|
-
const descriptor = parseSfc(code);
|
|
145
|
-
const localStyleCollector = shouldEnableLocalStyle(id, options) ? new require_component_local_style.UniAppXComponentLocalStyleCollector(id, runtimeSet) : void 0;
|
|
146
|
-
if (descriptor.errors.length === 0) {
|
|
147
|
-
if (descriptor.template?.ast) {
|
|
148
|
-
const templateOffset = descriptor.template.start;
|
|
149
|
-
traverse(descriptor.template.ast, (node) => {
|
|
150
|
-
if (node.type !== _vue_compiler_dom.NodeTypes.ELEMENT) return;
|
|
151
|
-
const tag = node.tag;
|
|
152
|
-
for (const prop of node.props) if (prop.type === _vue_compiler_dom.NodeTypes.ATTRIBUTE) {
|
|
153
|
-
const { shouldHandle, shouldHandleCustom, shouldHandleDefault } = shouldHandleAttribute(tag, prop.name, disabledDefaultTemplateHandler, matchCustomAttribute);
|
|
154
|
-
if (!shouldHandle) continue;
|
|
155
|
-
if (localStyleCollector) updateStaticAttributeWithLocalStyle(ms, prop, templateOffset, localStyleCollector, options.webCustomAttributeDeep === true && shouldHandleCustom);
|
|
156
|
-
else updateStaticAttribute(ms, prop, templateOffset);
|
|
157
|
-
if (shouldHandleDefault) continue;
|
|
158
|
-
} else if (prop.type === _vue_compiler_dom.NodeTypes.DIRECTIVE && prop.name === "bind" && prop.arg?.type === _vue_compiler_dom.NodeTypes.SIMPLE_EXPRESSION && prop.arg.isStatic) {
|
|
159
|
-
const attrName = prop.arg.content;
|
|
160
|
-
const { shouldHandle, shouldHandleCustom } = shouldHandleAttribute(tag, attrName, disabledDefaultTemplateHandler, matchCustomAttribute);
|
|
161
|
-
if (!shouldHandle) continue;
|
|
162
|
-
if (localStyleCollector) updateDirectiveExpressionWithLocalStyle(ms, prop, templateOffset, jsHandler, localStyleCollector, options.webCustomAttributeDeep === true && shouldHandleCustom, runtimeSet);
|
|
163
|
-
else updateDirectiveExpression(ms, prop, templateOffset, jsHandler, runtimeSet);
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
if (descriptor.script) {
|
|
168
|
-
localStyleCollector?.collectRuntimeClasses(descriptor.script.content);
|
|
169
|
-
const { code } = jsHandler(descriptor.script.content, runtimeSet ?? /* @__PURE__ */ new Set(), defaultCreateJsHandlerOptions);
|
|
170
|
-
ms.update(descriptor.script.start, descriptor.script.end, localStyleCollector ? localStyleCollector.rewriteTransformedCode(code) : code);
|
|
171
|
-
}
|
|
172
|
-
if (descriptor.scriptSetup) {
|
|
173
|
-
localStyleCollector?.collectRuntimeClasses(descriptor.scriptSetup.content);
|
|
174
|
-
const { code } = jsHandler(descriptor.scriptSetup.content, runtimeSet ?? /* @__PURE__ */ new Set(), defaultCreateJsHandlerOptions);
|
|
175
|
-
ms.update(descriptor.scriptSetup.start, descriptor.scriptSetup.end, localStyleCollector ? localStyleCollector.rewriteTransformedCode(code) : code);
|
|
176
|
-
}
|
|
177
|
-
if (localStyleCollector?.hasStyles()) {
|
|
178
|
-
const scopedStyle = descriptor.styles.findLast((style) => STYLE_SCOPED_RE.test(style.attrs));
|
|
179
|
-
if (scopedStyle && options.onWebLocalStyleRules) options.onWebLocalStyleRules(localStyleCollector.toStyleRules());
|
|
180
|
-
else if (scopedStyle) {
|
|
181
|
-
const separator = scopedStyle.content.endsWith("\n") ? "" : "\n";
|
|
182
|
-
ms.appendLeft(scopedStyle.end, `${separator}${localStyleCollector.toStyleRules()}`);
|
|
183
|
-
} else ms.append(`\n${localStyleCollector.toStyleBlock()}`);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
const result = {
|
|
187
|
-
code: ms.toString(),
|
|
188
|
-
map: null
|
|
189
|
-
};
|
|
190
|
-
Object.defineProperty(result, "map", {
|
|
191
|
-
configurable: true,
|
|
192
|
-
enumerable: true,
|
|
193
|
-
get() {
|
|
194
|
-
return ms.generateMap();
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
return result;
|
|
198
|
-
}
|
|
199
|
-
//#endregion
|
|
200
|
-
exports.transformUVue = transformUVue;
|