weapp-tailwindcss 5.4.2 → 5.5.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.md +13 -1
- package/README.zh-CN.md +13 -1
- package/dist/bundlers/shared/final-css-cleanup.d.ts +1 -1
- package/dist/bundlers/shared/v4-generation-core.d.ts +1 -0
- package/dist/bundlers/vite/capability-profile.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer/web-plugin.d.ts +3 -0
- package/dist/bundlers/vite/css-handler-options.d.ts +32 -0
- package/dist/bundlers/vite/{generate-bundle/css-output.d.ts → css-output.d.ts} +1 -1
- package/dist/bundlers/vite/frameworks/generic/web.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +2 -32
- package/dist/bundlers/vite/generate-bundle/finalize/root-import-shell.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +2 -2
- package/dist/bundlers/vite/generate-bundle/runtime.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/uni-app-x-postprocess.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle.d.ts +1 -1
- package/dist/bundlers/vite/runtime-class-set.d.ts +1 -5
- package/dist/bundlers/vite/shared/create-css-only-plugins-runtime.d.ts +3 -0
- package/dist/cache-CBJFB1HN.cjs +223 -0
- package/dist/compiler/events.d.ts +32 -0
- package/dist/compiler/host.d.ts +13 -0
- package/dist/compiler/index.d.ts +3 -0
- package/dist/compiler/runtime-state.d.ts +17 -0
- package/dist/compiler-B0YSc0DY.js +4877 -0
- package/dist/{wxml-o-CUulAM.cjs → compiler-D2ZJc3uA.cjs} +3649 -283
- package/dist/core.cjs +6 -3
- package/dist/core.d.ts +2 -0
- package/dist/core.js +4 -4
- package/dist/defaults-B5ep0ojb.js +120 -0
- package/dist/defaults-BI9j1znS.cjs +156 -0
- package/dist/defaults.cjs +5 -121
- package/dist/defaults.js +1 -116
- package/dist/final-css-cleanup-B0HUBtiE.js +308 -0
- package/dist/final-css-cleanup-DSjczga3.cjs +138 -0
- package/dist/{generator-WlhrtNa3.cjs → generator-DsrQ9txU.cjs} +62 -5
- package/dist/{generator-BjK5PRR-.js → generator-DyXTBPmE.js} +47 -2
- package/dist/generator.cjs +1 -1
- package/dist/generator.js +1 -1
- package/dist/{gulp-ChecVI6A.cjs → gulp-C9ENAx3f.cjs} +30 -28
- package/dist/{gulp-D6LcfRz_.js → gulp-DXeQfvVC.js} +7 -7
- package/dist/gulp.cjs +1 -1
- package/dist/gulp.js +1 -1
- package/dist/{hmr-timing-afnWvy7u.cjs → hmr-timing-Cz4IesEM.cjs} +6 -229
- package/dist/{hmr-timing-CqDfjvqE.js → hmr-timing-DNxQm-bN.js} +6 -1258
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/{pipeline-helpers-DxPFMGxz.cjs → pipeline-helpers-CSGnR5gh.cjs} +6 -5
- package/dist/postcss.cjs +1 -1
- package/dist/postcss.js +1 -1
- package/dist/presets.cjs +4 -4
- package/dist/presets.js +2 -2
- package/dist/rspack.cjs +2 -2
- package/dist/rspack.js +2 -2
- package/dist/runtime-state-BBQcA0n5.cjs +54 -0
- package/dist/{source-candidate-scan-signature-FywFU3Rg.cjs → scoped-generator-TVjEaOeP.cjs} +5 -123
- package/dist/{source-candidate-scan-signature-BVScymyM.js → scoped-generator-kRj_5Axx.js} +4 -92
- package/dist/source-candidate-scan-signature-B7cUxqqX.cjs +129 -0
- package/dist/source-candidate-scan-signature-CsP4BQNa.js +92 -0
- package/dist/style-injector/internal.d.ts +1 -1
- package/dist/style-injector/vite-web.d.ts +3 -0
- package/dist/{tailwindcss-9xmoCkaR.js → tailwindcss-BK9S7zuq.js} +1 -2
- package/dist/{tailwindcss-D3jltF7M.cjs → tailwindcss-C-jBBQfw.cjs} +8 -9
- package/dist/{transform-DQhgAarN.js → transform-CfOzh007.js} +3 -3
- package/dist/{transform-C6k9zTQR.cjs → transform-DUPOPZ54.cjs} +27 -27
- package/dist/uni-app-x/vite/style-source.d.ts +11 -0
- package/dist/{v4-generation-core-CPKNwzjz.cjs → v4-generation-core-CRNUU_Rr.cjs} +29 -1172
- package/dist/vite/web.cjs +27 -0
- package/dist/vite/web.d.ts +1 -0
- package/dist/vite/web.js +25 -0
- package/dist/{vite-D3aCtpmv.js → vite-BXe-axax.js} +263 -3587
- package/dist/{vite-D-gmOkPN.cjs → vite-D_mAIfTU.cjs} +514 -3798
- package/dist/vite-web.d.ts +4 -0
- 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/web-B2Ea9K4B.cjs +4361 -0
- package/dist/web-Cv7ualrU.js +3796 -0
- package/dist/{webpack-B-6a8Z8F.js → webpack-7Um2GFtx.js} +13 -12
- package/dist/{webpack-yAne9ZYu.cjs → webpack-Ce04-btG.cjs} +51 -49
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +13 -4
- package/dist/cache-options-DavPxrhC.cjs +0 -16
- package/dist/cache-options-DwBtLwQe.js +0 -5
- package/dist/compiler-B-m9VGqj.cjs +0 -2316
- package/dist/compiler-BgMj2E5l.js +0 -2051
- package/dist/local-style-matcher-DRpFEu1s.cjs +0 -34
- package/dist/local-style-matcher-DsiI2wIc.js +0 -17
- package/dist/object-B-8IHefx.js +0 -47
- package/dist/object-DbHtAXRk.cjs +0 -58
- package/dist/wxml-CvKyV69S.js +0 -1822
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jt as toPosixPath } from "./generator-DyXTBPmE.js";
|
|
2
|
+
import "./tailwindcss-BK9S7zuq.js";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
//#region src/style-injector/options.ts
|
|
6
|
+
function normalizeStyleInjectorOptions(options) {
|
|
7
|
+
if (options === true) return {};
|
|
8
|
+
if (!options) return;
|
|
9
|
+
return options;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/bundlers/shared/module-graph.ts
|
|
13
|
+
const QUERY_HASH_RE = /[?#].*$/u;
|
|
14
|
+
const PROTOCOL_RE = /^[a-z][a-z+.-]*:/iu;
|
|
15
|
+
const WINDOWS_ABSOLUTE_RE = /^[a-z]:[\\/]/iu;
|
|
16
|
+
const VIRTUAL_PREFIX = "\0";
|
|
17
|
+
const JS_EXTENSIONS = [
|
|
18
|
+
".js",
|
|
19
|
+
".mjs",
|
|
20
|
+
".cjs"
|
|
21
|
+
];
|
|
22
|
+
function normalizeOutputPathKey(value) {
|
|
23
|
+
return path.normalize(value).replace(/\\/g, "/");
|
|
24
|
+
}
|
|
25
|
+
function stripQueryAndHash(specifier) {
|
|
26
|
+
return specifier.replace(QUERY_HASH_RE, "");
|
|
27
|
+
}
|
|
28
|
+
function isResolvableSpecifier(specifier) {
|
|
29
|
+
if (!specifier) return false;
|
|
30
|
+
const normalized = stripQueryAndHash(specifier);
|
|
31
|
+
if (normalized.startsWith(VIRTUAL_PREFIX)) return false;
|
|
32
|
+
if (path.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) return true;
|
|
33
|
+
return !PROTOCOL_RE.test(normalized);
|
|
34
|
+
}
|
|
35
|
+
function toAbsoluteOutputPath(fileName, outDir) {
|
|
36
|
+
if (path.isAbsolute(fileName) || WINDOWS_ABSOLUTE_RE.test(fileName)) return path.normalize(fileName);
|
|
37
|
+
return path.resolve(outDir, fileName);
|
|
38
|
+
}
|
|
39
|
+
function matchWithExtensions(candidate, hasOutput) {
|
|
40
|
+
if (hasOutput(candidate)) return candidate;
|
|
41
|
+
if (!path.extname(candidate)) for (const ext of JS_EXTENSIONS) {
|
|
42
|
+
const extended = `${candidate}${ext}`;
|
|
43
|
+
if (hasOutput(extended)) return extended;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function resolveOutputSpecifier(specifier, importer, outDir, hasOutput) {
|
|
47
|
+
if (!isResolvableSpecifier(specifier)) return;
|
|
48
|
+
const normalized = stripQueryAndHash(specifier);
|
|
49
|
+
let candidate;
|
|
50
|
+
if (path.isAbsolute(normalized) || WINDOWS_ABSOLUTE_RE.test(normalized)) candidate = path.normalize(normalized);
|
|
51
|
+
else if (normalized.startsWith("/")) candidate = path.resolve(outDir, normalized.slice(1));
|
|
52
|
+
else candidate = path.resolve(path.dirname(importer), normalized);
|
|
53
|
+
return matchWithExtensions(candidate, hasOutput);
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/utils/resolve-package.ts
|
|
57
|
+
const require = createRequire(import.meta.url);
|
|
58
|
+
function resolvePackageDir(name) {
|
|
59
|
+
const pkgPath = require.resolve(`${name}/package.json`);
|
|
60
|
+
return path.dirname(pkgPath);
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/bundlers/shared/source-candidate-scan-signature.ts
|
|
64
|
+
function normalizeSignaturePath(value) {
|
|
65
|
+
return toPosixPath(path.resolve(value));
|
|
66
|
+
}
|
|
67
|
+
function serializeInlineCandidates(inlineCandidates) {
|
|
68
|
+
return {
|
|
69
|
+
excluded: [...inlineCandidates?.excluded ?? []].sort(),
|
|
70
|
+
included: [...inlineCandidates?.included ?? []].sort()
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function serializeSourceEntries(entries) {
|
|
74
|
+
return (entries ?? []).map((entry) => ({
|
|
75
|
+
base: normalizeSignaturePath(entry.base),
|
|
76
|
+
negated: entry.negated,
|
|
77
|
+
pattern: entry.pattern
|
|
78
|
+
})).sort((a, b) => `${a.base}\0${a.pattern}\0${a.negated}`.localeCompare(`${b.base}\0${b.pattern}\0${b.negated}`));
|
|
79
|
+
}
|
|
80
|
+
function createSourceCandidateScanSignature(input) {
|
|
81
|
+
return JSON.stringify({
|
|
82
|
+
inlineCandidates: serializeInlineCandidates(input.inlineCandidates),
|
|
83
|
+
outDir: input.outDir ? normalizeSignaturePath(input.outDir) : void 0,
|
|
84
|
+
roots: input.roots.map((root) => ({
|
|
85
|
+
entries: serializeSourceEntries(root.entries),
|
|
86
|
+
root: normalizeSignaturePath(root.root)
|
|
87
|
+
})),
|
|
88
|
+
scanAllSources: input.scanAllSources ?? false
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
export { toAbsoluteOutputPath as a, resolveOutputSpecifier as i, resolvePackageDir as n, normalizeStyleInjectorOptions as o, normalizeOutputPathKey as r, createSourceCandidateScanSignature as t };
|
|
@@ -6,7 +6,7 @@ export type ViteStyleInjectorDelegateFactory = (options: NonNullable<ReturnType<
|
|
|
6
6
|
export type WebpackStyleInjectorDelegateFactory = (options: NonNullable<ReturnType<typeof normalizeWebpackStyleInjectorOptions>>) => WebpackObjectPluginInstance;
|
|
7
7
|
declare function normalizeWebpackStyleInjectorOptions(options: WeappTailwindcssStyleInjectorUserOptions | undefined): WebpackWeappStyleInjectorOptions | undefined;
|
|
8
8
|
export declare const viteStyleInjectorDelegates: {
|
|
9
|
-
generic: (options: import("./options.js").WeappTailwindcssStyleInjectorOptions) => Plugin<any>[];
|
|
9
|
+
generic: (options: import("./options.js").WeappTailwindcssStyleInjectorOptions) => import("vite").Plugin<any>[];
|
|
10
10
|
taro: (options: import("./options.js").WeappTailwindcssStyleInjectorOptions) => Plugin<any>[];
|
|
11
11
|
uniApp: (options: import("./options.js").WeappTailwindcssStyleInjectorOptions) => Plugin<any>[];
|
|
12
12
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { C as findWorkspacePackageDir, D as
|
|
2
|
-
import { t as omitUndefined } from "./object-B-8IHefx.js";
|
|
1
|
+
import { At as resolveTailwindV4CssSourceBase, C as findWorkspacePackageDir, Ct as expandTailwindSourceEntries, D as normalizeTailwindcssRuntimeOptions, Dt as parseConfigParam, E as normalizeExtendLengthUnits, Et as normalizeLegacyContentEntries, Ft as resolveCssMacroTailwindV4Source, O as resolveTailwindcssOptions, Ot as resolveCssSourceEntries, S as findNearestPackageRoot, St as FULL_SOURCE_SCAN_PATTERN, T as omitUndefined, b as isTailwindV4CssEntry, d as resolveTailwindV4SourceFromRuntime, h as hasConfiguredTailwindV4CssRoots, i as normalizeWeappTailwindcssGeneratorOptions, k as normalizeStringListOption, m as filterTailwindV4CssSourceRoots, p as resolveTailwindV4SourceOptionsFromRuntime, v as groupCssEntriesByBase, w as findWorkspaceRoot, x as normalizeCssEntries, y as guessBasedirFromEntries, zt as loadTailwindV4DesignSystem } from "./generator-DyXTBPmE.js";
|
|
3
2
|
import { n as defuOverrideArray$1 } from "./utils-MVwpU07P.js";
|
|
4
3
|
import { createRequire } from "node:module";
|
|
5
4
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-Ctb5zv51.cjs");
|
|
2
|
-
const require_generator = require("./generator-
|
|
3
|
-
const require_object = require("./object-DbHtAXRk.cjs");
|
|
2
|
+
const require_generator = require("./generator-DsrQ9txU.cjs");
|
|
4
3
|
require("./utils-CuKLf1Zv.cjs");
|
|
5
4
|
let node_fs = require("node:fs");
|
|
6
5
|
let node_path = require("node:path");
|
|
@@ -1210,7 +1209,7 @@ function createTailwindcssRuntime(options) {
|
|
|
1210
1209
|
const resolvePaths = createDefaultResolvePaths(cache.cwd ?? normalizedBasedir ?? node_process.default.cwd());
|
|
1211
1210
|
const normalizedUserOptions = require_generator.normalizeTailwindcssRuntimeOptions(tailwindcssRuntimeOptions);
|
|
1212
1211
|
const extendLengthUnits = require_generator.normalizeExtendLengthUnits(supportCustomLengthUnits ?? true);
|
|
1213
|
-
const baseTailwindOptions = (0, _weapp_tailwindcss_shared.defuOverrideArray)(tailwindcss ?? {},
|
|
1212
|
+
const baseTailwindOptions = (0, _weapp_tailwindcss_shared.defuOverrideArray)(tailwindcss ?? {}, require_generator.omitUndefined({
|
|
1214
1213
|
cwd: normalizedBasedir,
|
|
1215
1214
|
resolve: { paths: resolvePaths }
|
|
1216
1215
|
}));
|
|
@@ -1220,11 +1219,11 @@ function createTailwindcssRuntime(options) {
|
|
|
1220
1219
|
const resolvedPlugin = resolveModuleFromPaths(baseTailwindOptions.postcssPlugin, resolvePaths);
|
|
1221
1220
|
if (resolvedPlugin) baseTailwindOptions.postcssPlugin = resolvedPlugin;
|
|
1222
1221
|
}
|
|
1223
|
-
const baseOptions =
|
|
1222
|
+
const baseOptions = require_generator.omitUndefined({
|
|
1224
1223
|
projectRoot: normalizedBasedir,
|
|
1225
1224
|
cache,
|
|
1226
1225
|
tailwindcss: baseTailwindOptions,
|
|
1227
|
-
apply:
|
|
1226
|
+
apply: require_generator.omitUndefined({
|
|
1228
1227
|
exposeContext: true,
|
|
1229
1228
|
extendLengthUnits
|
|
1230
1229
|
})
|
|
@@ -1316,7 +1315,7 @@ function createMultiTailwindcssRuntime(runtimes) {
|
|
|
1316
1315
|
}
|
|
1317
1316
|
if (result.classSet) for (const className of result.classSet) aggregatedSet.add(className);
|
|
1318
1317
|
}
|
|
1319
|
-
return
|
|
1318
|
+
return require_generator.omitUndefined({
|
|
1320
1319
|
classList: aggregatedList,
|
|
1321
1320
|
classSet: aggregatedSet,
|
|
1322
1321
|
filename
|
|
@@ -1380,7 +1379,7 @@ function createTailwindcssRuntimeForBase(baseDir, cssEntries, options) {
|
|
|
1380
1379
|
const hasCssEntries = Boolean(cssEntries?.length);
|
|
1381
1380
|
const defaultTailwindcssConfig = {
|
|
1382
1381
|
cwd: baseDir,
|
|
1383
|
-
v4: hasCssEntries ?
|
|
1382
|
+
v4: hasCssEntries ? require_generator.omitUndefined({ cssEntries }) : require_generator.omitUndefined({
|
|
1384
1383
|
base: baseDir,
|
|
1385
1384
|
cssEntries
|
|
1386
1385
|
})
|
|
@@ -1408,7 +1407,7 @@ function createTailwindcssRuntimeForBase(baseDir, cssEntries, options) {
|
|
|
1408
1407
|
packageName: configuredPackageName ?? mergedTailwindOptions.packageName ?? readPackageNameFromBaseDir(baseDir) ?? "tailwindcss"
|
|
1409
1408
|
};
|
|
1410
1409
|
if (supportedResolvedTailwindVersion) tailwindOptionsForPackage.version = supportedResolvedTailwindVersion;
|
|
1411
|
-
return createTailwindcssRuntime(
|
|
1410
|
+
return createTailwindcssRuntime(require_generator.omitUndefined({
|
|
1412
1411
|
basedir: baseDir,
|
|
1413
1412
|
supportCustomLengthUnits: supportCustomLengthUnits ?? true,
|
|
1414
1413
|
tailwindcss: tailwindOptionsForPackage,
|
|
@@ -1595,7 +1594,7 @@ function createTailwindcssRuntimeFromContext(ctx) {
|
|
|
1595
1594
|
bareArbitraryValues: arbitraryValues?.bareArbitraryValues
|
|
1596
1595
|
};
|
|
1597
1596
|
const workspaceRoot = require_generator.findWorkspaceRoot(resolvedTailwindcssBasedir) ?? (absoluteCssEntryBasedir ? require_generator.findWorkspaceRoot(absoluteCssEntryBasedir) : void 0);
|
|
1598
|
-
const groupedCssEntries = normalizedCssEntries ? require_generator.groupCssEntriesByBase(normalizedCssEntries,
|
|
1597
|
+
const groupedCssEntries = normalizedCssEntries ? require_generator.groupCssEntriesByBase(normalizedCssEntries, require_generator.omitUndefined({
|
|
1599
1598
|
preferredBaseDir: resolvedTailwindcssBasedir,
|
|
1600
1599
|
workspaceRoot
|
|
1601
1600
|
})) : void 0;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { n as shouldEnableComponentLocalStyle, r as shouldEnablePageLocalStyle } from "./
|
|
1
|
+
import { Mt as _defineProperty } from "./generator-DyXTBPmE.js";
|
|
2
|
+
import { G as replaceWxml, H as analyzeSource, J as traverse$1, U as JsTokenUpdater, V as createAttributeMatcher, W as isClassContextLiteralPath, _ as generateCode, q as babelParse } from "./compiler-B0YSc0DY.js";
|
|
3
|
+
import { n as shouldEnableComponentLocalStyle, r as shouldEnablePageLocalStyle } from "./vite-BXe-axax.js";
|
|
4
4
|
import { splitCandidateTokens } from "@tailwindcss-mangle/engine";
|
|
5
5
|
import { UNI_APP_X_IMPORTANT_APPLY_MARKER, normalizeUniAppXImportantApplyForSass } from "@weapp-tailwindcss/postcss";
|
|
6
6
|
import MagicString from "magic-string";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
1
|
+
const require_generator = require("./generator-DsrQ9txU.cjs");
|
|
2
|
+
const require_compiler = require("./compiler-D2ZJc3uA.cjs");
|
|
3
|
+
const require_vite = require("./vite-D_mAIfTU.cjs");
|
|
4
4
|
let _tailwindcss_mangle_engine = require("@tailwindcss-mangle/engine");
|
|
5
5
|
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
6
6
|
let _vue_compiler_dom = require("@vue/compiler-dom");
|
|
@@ -60,14 +60,14 @@ function isClassAssignmentTarget(path, names) {
|
|
|
60
60
|
return object.isThisExpression() && isClassBindingName(property, names);
|
|
61
61
|
}
|
|
62
62
|
function collectClassBindingNames(ast, names) {
|
|
63
|
-
|
|
63
|
+
require_compiler.traverse(ast, { ReferencedIdentifier(path) {
|
|
64
64
|
names.add(path.node.name);
|
|
65
65
|
} });
|
|
66
66
|
}
|
|
67
67
|
function collectClassBindingRoots(ast, names) {
|
|
68
68
|
const roots = /* @__PURE__ */ new WeakSet();
|
|
69
69
|
if (names.size === 0) return roots;
|
|
70
|
-
|
|
70
|
+
require_compiler.traverse(ast, {
|
|
71
71
|
Program(path) {
|
|
72
72
|
for (const name of names) {
|
|
73
73
|
const binding = path.scope.getBinding(name);
|
|
@@ -128,7 +128,7 @@ function serializeApplyUtility(utility, options = {}) {
|
|
|
128
128
|
}
|
|
129
129
|
function isRuntimeCandidate(candidate, runtimeSet) {
|
|
130
130
|
if (!runtimeSet || runtimeSet.size === 0) return false;
|
|
131
|
-
return runtimeSet.has(candidate) || runtimeSet.has(
|
|
131
|
+
return runtimeSet.has(candidate) || runtimeSet.has(require_compiler.replaceWxml(candidate));
|
|
132
132
|
}
|
|
133
133
|
function hasTopLevelVariant(candidate) {
|
|
134
134
|
let bracketDepth = 0;
|
|
@@ -176,10 +176,10 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
176
176
|
constructor(fileId, runtimeSet) {
|
|
177
177
|
this.fileId = fileId;
|
|
178
178
|
this.runtimeSet = runtimeSet;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
179
|
+
require_generator._defineProperty(this, "aliasByUtility", /* @__PURE__ */ new Map());
|
|
180
|
+
require_generator._defineProperty(this, "aliasByLookup", /* @__PURE__ */ new Map());
|
|
181
|
+
require_generator._defineProperty(this, "classBindingNames", /* @__PURE__ */ new Set());
|
|
182
|
+
require_generator._defineProperty(this, "deepUtilities", /* @__PURE__ */ new Set());
|
|
183
183
|
}
|
|
184
184
|
ensureAlias(utility) {
|
|
185
185
|
const cached = this.aliasByUtility.get(utility);
|
|
@@ -187,7 +187,7 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
187
187
|
const alias = createAlias(this.fileId, utility, this.aliasByUtility.size);
|
|
188
188
|
this.aliasByUtility.set(utility, alias);
|
|
189
189
|
this.aliasByLookup.set(utility, alias);
|
|
190
|
-
this.aliasByLookup.set(
|
|
190
|
+
this.aliasByLookup.set(require_compiler.replaceWxml(utility), alias);
|
|
191
191
|
return alias;
|
|
192
192
|
}
|
|
193
193
|
rewriteLiteral(literal) {
|
|
@@ -196,7 +196,7 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
196
196
|
let rewritten = literal;
|
|
197
197
|
for (const candidate of candidates) {
|
|
198
198
|
if (!isRuntimeCandidate(candidate, this.runtimeSet)) continue;
|
|
199
|
-
rewritten = rewritten.replace(candidate, hasTopLevelVariant(candidate) ?
|
|
199
|
+
rewritten = rewritten.replace(candidate, hasTopLevelVariant(candidate) ? require_compiler.replaceWxml(candidate) : this.ensureAlias(candidate));
|
|
200
200
|
}
|
|
201
201
|
return rewritten;
|
|
202
202
|
}
|
|
@@ -210,17 +210,17 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
210
210
|
collectRuntimeClasses(rawSource, options = {}) {
|
|
211
211
|
const wrapped = options.wrapExpression ? `${EXPRESSION_WRAPPER_PREFIX}${rawSource}${EXPRESSION_WRAPPER_SUFFIX}` : rawSource;
|
|
212
212
|
try {
|
|
213
|
-
const ast =
|
|
213
|
+
const ast = require_compiler.babelParse(wrapped, {
|
|
214
214
|
plugins: ["typescript"],
|
|
215
215
|
sourceType: options.wrapExpression ? "module" : "unambiguous"
|
|
216
216
|
});
|
|
217
217
|
if (options.wrapExpression) collectClassBindingNames(ast, this.classBindingNames);
|
|
218
218
|
const classBindingRoots = options.wrapExpression ? void 0 : collectClassBindingRoots(ast, this.classBindingNames);
|
|
219
|
-
const analysis =
|
|
219
|
+
const analysis = require_compiler.analyzeSource(ast, {}, void 0, false);
|
|
220
220
|
for (const path of analysis.targetPaths) {
|
|
221
221
|
const { literal } = extractLiteralValue(path);
|
|
222
222
|
const candidates = (0, _tailwindcss_mangle_engine.splitCandidateTokens)(literal);
|
|
223
|
-
const classContext = options.wrapExpression ||
|
|
223
|
+
const classContext = options.wrapExpression || require_compiler.isClassContextLiteralPath(path) || isClassBindingLiteralPath(path, classBindingRoots);
|
|
224
224
|
for (const candidate of candidates) {
|
|
225
225
|
if (!candidate || !classContext || !isRuntimeCandidate(candidate, this.runtimeSet)) continue;
|
|
226
226
|
if (!hasTopLevelVariant(candidate)) {
|
|
@@ -235,16 +235,16 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
235
235
|
if (this.aliasByLookup.size === 0) return rawSource;
|
|
236
236
|
const wrapped = options.wrapExpression ? `${EXPRESSION_WRAPPER_PREFIX}${rawSource}${EXPRESSION_WRAPPER_SUFFIX}` : rawSource;
|
|
237
237
|
try {
|
|
238
|
-
const ast =
|
|
238
|
+
const ast = require_compiler.babelParse(wrapped, {
|
|
239
239
|
plugins: ["typescript"],
|
|
240
240
|
sourceType: options.wrapExpression ? "module" : "unambiguous"
|
|
241
241
|
});
|
|
242
242
|
const classBindingRoots = options.wrapExpression ? void 0 : collectClassBindingRoots(ast, this.classBindingNames);
|
|
243
|
-
const analysis =
|
|
243
|
+
const analysis = require_compiler.analyzeSource(ast, {}, void 0, false);
|
|
244
244
|
if (analysis.targetPaths.length === 0) return rawSource;
|
|
245
|
-
const updater = new
|
|
245
|
+
const updater = new require_compiler.JsTokenUpdater();
|
|
246
246
|
for (const path of analysis.targetPaths) {
|
|
247
|
-
if (!options.wrapExpression && !
|
|
247
|
+
if (!options.wrapExpression && !require_compiler.isClassContextLiteralPath(path) && !isClassBindingLiteralPath(path, classBindingRoots)) continue;
|
|
248
248
|
const { literal, offset } = extractLiteralValue(path);
|
|
249
249
|
const candidates = (0, _tailwindcss_mangle_engine.splitCandidateTokens)(literal);
|
|
250
250
|
if (candidates.length === 0) continue;
|
|
@@ -268,7 +268,7 @@ var UniAppXComponentLocalStyleCollector = class {
|
|
|
268
268
|
});
|
|
269
269
|
}
|
|
270
270
|
if (updater.length === 0) return rawSource;
|
|
271
|
-
const ms = new
|
|
271
|
+
const ms = new require_compiler.MagicString(wrapped);
|
|
272
272
|
updater.updateMagicString(ms);
|
|
273
273
|
if (options.wrapExpression) {
|
|
274
274
|
ms.remove(0, 2);
|
|
@@ -311,7 +311,7 @@ function updateStaticAttribute(ms, prop, offset, content = prop.value?.content)
|
|
|
311
311
|
if (!prop.value) return;
|
|
312
312
|
const start = offset + prop.value.loc.start.offset + 1;
|
|
313
313
|
const end = offset + prop.value.loc.end.offset - 1;
|
|
314
|
-
if (start < end) ms.update(start, end,
|
|
314
|
+
if (start < end) ms.update(start, end, require_compiler.replaceWxml(content ?? ""));
|
|
315
315
|
}
|
|
316
316
|
function updateStaticAttributeWithLocalStyle(ms, prop, offset, collector, deep, content = prop.value?.content) {
|
|
317
317
|
if (!prop.value) return;
|
|
@@ -325,7 +325,7 @@ function updateDirectiveExpression(ms, prop, offset, jsHandler, runtimeSet) {
|
|
|
325
325
|
const start = offset + prop.exp.loc.start.offset;
|
|
326
326
|
const end = offset + prop.exp.loc.end.offset;
|
|
327
327
|
if (start >= end) return;
|
|
328
|
-
const generated =
|
|
328
|
+
const generated = require_compiler.generateCode(expression, {
|
|
329
329
|
jsHandler,
|
|
330
330
|
runtimeSet,
|
|
331
331
|
wrapExpression: true
|
|
@@ -342,7 +342,7 @@ function updateDirectiveExpressionWithLocalStyle(ms, prop, offset, jsHandler, co
|
|
|
342
342
|
deep,
|
|
343
343
|
wrapExpression: true
|
|
344
344
|
});
|
|
345
|
-
const generated =
|
|
345
|
+
const generated = require_compiler.generateCode(expression, {
|
|
346
346
|
jsHandler,
|
|
347
347
|
runtimeSet,
|
|
348
348
|
wrapExpression: true
|
|
@@ -350,8 +350,8 @@ function updateDirectiveExpressionWithLocalStyle(ms, prop, offset, jsHandler, co
|
|
|
350
350
|
ms.update(start, end, collector.rewriteTransformedCode(generated, { wrapExpression: true }));
|
|
351
351
|
}
|
|
352
352
|
function shouldEnableLocalStyle(id, options) {
|
|
353
|
-
if (options.enableComponentLocalStyle &&
|
|
354
|
-
if (options.enablePageLocalStyle &&
|
|
353
|
+
if (options.enableComponentLocalStyle && require_vite.shouldEnableComponentLocalStyle(id, options.componentMatcher)) return true;
|
|
354
|
+
if (options.enablePageLocalStyle && require_vite.shouldEnablePageLocalStyle(id, options.pageMatcher)) return true;
|
|
355
355
|
return false;
|
|
356
356
|
}
|
|
357
357
|
function shouldHandleAttribute(tag, attrName, disabledDefaultTemplateHandler, matchCustomAttribute) {
|
|
@@ -438,8 +438,8 @@ function parseSfc(code) {
|
|
|
438
438
|
function transformUVue(code, id, jsHandler, runtimeSet, options = {}) {
|
|
439
439
|
if (!UVUE_NVUE_RE.test(id)) return;
|
|
440
440
|
const { customAttributesEntities, disabledDefaultTemplateHandler = false } = options;
|
|
441
|
-
const matchCustomAttribute =
|
|
442
|
-
const ms = new
|
|
441
|
+
const matchCustomAttribute = require_compiler.createAttributeMatcher(customAttributesEntities);
|
|
442
|
+
const ms = new require_compiler.MagicString(code);
|
|
443
443
|
const descriptor = parseSfc(code);
|
|
444
444
|
if (options.native || options.onWebLocalStyleRules) for (const style of descriptor.styles) {
|
|
445
445
|
const normalized = (0, _weapp_tailwindcss_postcss.normalizeUniAppXImportantApplyForSass)(style.content);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { parseVueRequest } from '../../bundlers/vite/query.js';
|
|
2
|
+
type VueStyleQuery = ReturnType<typeof parseVueRequest>['query'];
|
|
3
|
+
export declare function resolveUniAppXStyleSource(code: string, query: VueStyleQuery): {
|
|
4
|
+
code: string;
|
|
5
|
+
skip?: never;
|
|
6
|
+
} | {
|
|
7
|
+
skip: true;
|
|
8
|
+
code?: never;
|
|
9
|
+
};
|
|
10
|
+
export declare function hasUniAppXImportantApply(source: string, normalize: (source: string) => string): boolean;
|
|
11
|
+
export {};
|