weapp-tailwindcss 5.0.0-next.7 → 5.0.0-next.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundlers/shared/generator-css/directives.d.ts +1 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +2 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -0
- package/dist/{cache-DPN5yKSX.js → cache-BVAiJV3J.js} +5 -0
- package/dist/{cache-nq0_XJoS.mjs → cache-CHs4DXui.mjs} +5 -0
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/css-macro.js +1 -1
- package/dist/css-macro.mjs +1 -1
- package/dist/defaults.js +1 -1
- package/dist/defaults.mjs +1 -1
- package/dist/{generator-TOp4uz7c.js → generator-DKkhJbOg.js} +3 -2
- package/dist/{generator-CzfdCZyd.mjs → generator-UBmfduYg.mjs} +3 -2
- package/dist/{generator-css-B938WI9a.mjs → generator-css-BIapP56i.mjs} +184 -146
- package/dist/{generator-css-Dnpl-IY2.js → generator-css-Mksw8PgB.js} +189 -145
- package/dist/generator.js +1 -1
- package/dist/generator.mjs +1 -1
- package/dist/gulp.js +20 -5
- package/dist/gulp.mjs +20 -5
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{postcss-WsXlC7A-.js → postcss-QIXwT40c.js} +2 -2
- package/dist/{postcss-BtAP6sQO.mjs → postcss-w48mGIhe.mjs} +2 -2
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-Dka94ArV.js → precheck-B32p-gLI.js} +5 -5
- package/dist/{precheck-DlrmwCc-.mjs → precheck-B4RH6ZNN.mjs} +5 -5
- package/dist/presets.js +3 -3
- package/dist/presets.mjs +3 -3
- package/dist/{runtime-patch-pGdCqAEu.mjs → runtime-patch-CwN5ya72.mjs} +1 -1
- package/dist/{runtime-patch-qwuisukL.js → runtime-patch-D6mBo_KB.js} +1 -1
- package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
- package/dist/{tailwindcss-T1U5T-iF.js → tailwindcss-Bu-RWIHx.js} +68 -3
- package/dist/{tailwindcss-BIJ185GB.mjs → tailwindcss-C5IgPlQ0.mjs} +57 -4
- package/dist/{vite-BXChkciE.mjs → vite-BwgRVgxH.mjs} +56 -25
- package/dist/{vite-D0CoRblu.js → vite-DyZuiyap.js} +56 -25
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +10 -1
- package/dist/{webpack-D-sUCY0u.js → webpack-CNV2dx3Q.js} +46 -10
- package/dist/{webpack-BNdGm9KL.mjs → webpack-CT6EEENx.mjs} +46 -10
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +4 -4
- /package/dist/{utils-VZvGusYs.js → utils-BiShvil9.js} +0 -0
- /package/dist/{utils-BJjKRQgf.mjs → utils-Btw1iOVV.mjs} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare function parseImportRequest(params: string): string | undefined;
|
|
2
2
|
export declare function removeTailwindSourceDirectives(rawSource: string): string;
|
|
3
3
|
export declare function hasTailwindSourceDirectives(rawSource: string): boolean;
|
|
4
|
+
export declare function hasTailwindRootDirectives(rawSource: string): boolean;
|
|
4
5
|
export declare function resolveCssEntrySource(rawSource: string, base: string, options?: {
|
|
5
6
|
removeConfig?: boolean;
|
|
6
7
|
}): {
|
|
@@ -7,6 +7,7 @@ interface RewriteCssImportsOptions {
|
|
|
7
7
|
shouldRewrite: boolean;
|
|
8
8
|
rootImport?: string;
|
|
9
9
|
weappTailwindcssDirPosix: string;
|
|
10
|
+
onTailwindRootCss?: (id: string, code: string) => Promise<void> | void;
|
|
10
11
|
}
|
|
11
12
|
export declare function createRewriteCssImportsPlugins(options: RewriteCssImportsOptions): Plugin[];
|
|
12
13
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TailwindV4CssSource } from 'tailwindcss-patch';
|
|
1
2
|
import type { Compiler } from 'webpack';
|
|
2
3
|
import type { AppType, InternalUserDefinedOptions } from '../../../types';
|
|
3
4
|
interface SetupWebpackV5LoadersOptions {
|
|
@@ -7,6 +8,7 @@ interface SetupWebpackV5LoadersOptions {
|
|
|
7
8
|
weappTailwindcssPackageDir: string;
|
|
8
9
|
shouldRewriteCssImports: boolean;
|
|
9
10
|
runtimeLoaderPath?: string;
|
|
11
|
+
registerAutoCssSource?: (source: TailwindV4CssSource) => Promise<void> | void;
|
|
10
12
|
getClassSetInLoader: () => Promise<void>;
|
|
11
13
|
getRuntimeWatchDependencies: () => {
|
|
12
14
|
files: ReadonlySet<string>;
|
|
@@ -4,6 +4,7 @@ export declare const weappTailwindcssPackageDir: string;
|
|
|
4
4
|
export declare class UnifiedWebpackPluginV5 implements IBaseWebpackPlugin {
|
|
5
5
|
options: InternalUserDefinedOptions;
|
|
6
6
|
appType?: AppType;
|
|
7
|
+
private hasInitialTailwindCssRoots;
|
|
7
8
|
constructor(options?: UserDefinedOptions);
|
|
8
9
|
apply(compiler: Compiler): void;
|
|
9
10
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TailwindV4CssSource } from 'tailwindcss-patch';
|
|
1
2
|
import type webpack from 'webpack';
|
|
2
3
|
import type { AppType } from '../../../types';
|
|
3
4
|
import { Buffer } from 'node:buffer';
|
|
@@ -5,6 +6,7 @@ interface CssImportRewriteLoaderOptions {
|
|
|
5
6
|
tailwindcssImportRewrite?: {
|
|
6
7
|
pkgDir: string;
|
|
7
8
|
appType?: AppType;
|
|
9
|
+
registerCssSource?: (source: TailwindV4CssSource) => Promise<void> | void;
|
|
8
10
|
};
|
|
9
11
|
}
|
|
10
12
|
export declare function transformCssImportRewriteSource(source: string | Buffer, options: CssImportRewriteLoaderOptions | undefined): string | Buffer<ArrayBufferLike>;
|
|
@@ -360,6 +360,10 @@ function getTailwindTrackedFiles(twPatcher) {
|
|
|
360
360
|
const configPath = tailwindOptions?.config;
|
|
361
361
|
if (typeof configPath === "string" && configPath.length > 0) tracked.add(configPath);
|
|
362
362
|
for (const entry of tailwindOptions?.v4?.cssEntries ?? []) if (typeof entry === "string" && entry.length > 0) tracked.add(entry);
|
|
363
|
+
for (const source of tailwindOptions?.v4?.cssSources ?? []) {
|
|
364
|
+
if (typeof source.file === "string" && source.file.length > 0) tracked.add(source.file);
|
|
365
|
+
for (const dependency of source.dependencies ?? []) if (typeof dependency === "string" && dependency.length > 0) tracked.add(dependency);
|
|
366
|
+
}
|
|
363
367
|
return tracked;
|
|
364
368
|
}
|
|
365
369
|
function normalizeSignatureValue(value) {
|
|
@@ -390,6 +394,7 @@ function getTailwindOptionsSignature(twPatcher) {
|
|
|
390
394
|
configuredBase: readOptionalProperty(tailwindOptions?.v4, "configuredBase"),
|
|
391
395
|
css: tailwindOptions?.v4?.css,
|
|
392
396
|
cssEntries: tailwindOptions?.v4?.cssEntries,
|
|
397
|
+
cssSources: tailwindOptions?.v4?.cssSources,
|
|
393
398
|
hasUserDefinedSources: readOptionalProperty(tailwindOptions?.v4, "hasUserDefinedSources"),
|
|
394
399
|
sources: tailwindOptions?.v4?.sources
|
|
395
400
|
}
|
|
@@ -357,6 +357,10 @@ function getTailwindTrackedFiles(twPatcher) {
|
|
|
357
357
|
const configPath = tailwindOptions?.config;
|
|
358
358
|
if (typeof configPath === "string" && configPath.length > 0) tracked.add(configPath);
|
|
359
359
|
for (const entry of tailwindOptions?.v4?.cssEntries ?? []) if (typeof entry === "string" && entry.length > 0) tracked.add(entry);
|
|
360
|
+
for (const source of tailwindOptions?.v4?.cssSources ?? []) {
|
|
361
|
+
if (typeof source.file === "string" && source.file.length > 0) tracked.add(source.file);
|
|
362
|
+
for (const dependency of source.dependencies ?? []) if (typeof dependency === "string" && dependency.length > 0) tracked.add(dependency);
|
|
363
|
+
}
|
|
360
364
|
return tracked;
|
|
361
365
|
}
|
|
362
366
|
function normalizeSignatureValue(value) {
|
|
@@ -387,6 +391,7 @@ function getTailwindOptionsSignature(twPatcher) {
|
|
|
387
391
|
configuredBase: readOptionalProperty(tailwindOptions?.v4, "configuredBase"),
|
|
388
392
|
css: tailwindOptions?.v4?.css,
|
|
389
393
|
cssEntries: tailwindOptions?.v4?.cssEntries,
|
|
394
|
+
cssSources: tailwindOptions?.v4?.cssSources,
|
|
390
395
|
hasUserDefinedSources: readOptionalProperty(tailwindOptions?.v4, "hasUserDefinedSources"),
|
|
391
396
|
sources: tailwindOptions?.v4?.sources
|
|
392
397
|
}
|
package/dist/core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("./chunk-8l464Juk.js");
|
|
3
|
-
const require_precheck = require("./precheck-
|
|
3
|
+
const require_precheck = require("./precheck-B32p-gLI.js");
|
|
4
4
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
5
5
|
//#region src/core.ts
|
|
6
6
|
const DEFAULT_MAIN_CHUNK_STYLE_OPTIONS = Object.freeze({ isMainChunk: true });
|
package/dist/core.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as ensureRuntimeClassSet, g as createTailwindRuntimeReadyPromise, n as getCompilerContext, t as shouldSkipJsTransform } from "./precheck-
|
|
1
|
+
import { _ as ensureRuntimeClassSet, g as createTailwindRuntimeReadyPromise, n as getCompilerContext, t as shouldSkipJsTransform } from "./precheck-B4RH6ZNN.mjs";
|
|
2
2
|
import { defuOverrideArray } from "@weapp-tailwindcss/shared";
|
|
3
3
|
//#region src/core.ts
|
|
4
4
|
const DEFAULT_MAIN_CHUNK_STYLE_OPTIONS = Object.freeze({ isMainChunk: true });
|
package/dist/css-macro.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
require("./utils-
|
|
2
|
+
require("./utils-BiShvil9.js");
|
|
3
3
|
const require_constants = require("./constants-BoB_6lFw.js");
|
|
4
4
|
let tailwindcss_plugin = require("tailwindcss/plugin");
|
|
5
5
|
tailwindcss_plugin = require_chunk.__toESM(tailwindcss_plugin);
|
package/dist/css-macro.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as defu } from "./utils-
|
|
1
|
+
import { t as defu } from "./utils-Btw1iOVV.mjs";
|
|
2
2
|
import { n as createNegativeMediaQuery, t as createMediaQuery } from "./constants-E_loJC49.mjs";
|
|
3
3
|
import plugin from "tailwindcss/plugin";
|
|
4
4
|
//#region src/css-macro/index.ts
|
package/dist/defaults.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("./chunk-8l464Juk.js");
|
|
3
|
-
require("./utils-
|
|
3
|
+
require("./utils-BiShvil9.js");
|
|
4
4
|
let _weapp_core_escape = require("@weapp-core/escape");
|
|
5
5
|
let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
|
|
6
6
|
//#region src/defaults.ts
|
package/dist/defaults.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_cache = require("./cache-
|
|
3
|
-
const require_runtime_patch = require("./runtime-patch-
|
|
2
|
+
const require_cache = require("./cache-BVAiJV3J.js");
|
|
3
|
+
const require_runtime_patch = require("./runtime-patch-D6mBo_KB.js");
|
|
4
4
|
let node_module = require("node:module");
|
|
5
5
|
let postcss = require("postcss");
|
|
6
6
|
postcss = require_chunk.__toESM(postcss);
|
|
@@ -1389,6 +1389,7 @@ function resolveTailwindV4SourceOptionsFromPatcher(patcher) {
|
|
|
1389
1389
|
base: configuredBase ?? (hasCssEntries ? void 0 : tailwindOptions?.v4?.base),
|
|
1390
1390
|
baseFallbacks: uniqueDefined([tailwindOptions?.cwd, configDir]),
|
|
1391
1391
|
css: tailwindOptions?.v4?.css,
|
|
1392
|
+
cssSources: tailwindOptions?.v4?.cssSources,
|
|
1392
1393
|
cssEntries: tailwindOptions?.v4?.cssEntries,
|
|
1393
1394
|
sources: tailwindOptions?.v4?.sources,
|
|
1394
1395
|
packageName: resolveTailwindCssImportTarget(patcher)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as createTailwindcssPatcher, c as resolveTailwindcssOptions } from "./cache-
|
|
2
|
-
import { t as ensureTailwindcssRuntimePatch } from "./runtime-patch-
|
|
1
|
+
import { a as createTailwindcssPatcher, c as resolveTailwindcssOptions } from "./cache-CHs4DXui.mjs";
|
|
2
|
+
import { t as ensureTailwindcssRuntimePatch } from "./runtime-patch-CwN5ya72.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import postcss from "postcss";
|
|
5
5
|
import path from "node:path";
|
|
@@ -1385,6 +1385,7 @@ function resolveTailwindV4SourceOptionsFromPatcher(patcher) {
|
|
|
1385
1385
|
base: configuredBase ?? (hasCssEntries ? void 0 : tailwindOptions?.v4?.base),
|
|
1386
1386
|
baseFallbacks: uniqueDefined([tailwindOptions?.cwd, configDir]),
|
|
1387
1387
|
css: tailwindOptions?.v4?.css,
|
|
1388
|
+
cssSources: tailwindOptions?.v4?.cssSources,
|
|
1388
1389
|
cssEntries: tailwindOptions?.v4?.cssEntries,
|
|
1389
1390
|
sources: tailwindOptions?.v4?.sources,
|
|
1390
1391
|
packageName: resolveTailwindCssImportTarget(patcher)
|
|
@@ -1,9 +1,182 @@
|
|
|
1
|
-
import { a as resolveTailwindV4Source, c as resolveTailwindV4SourceOptionsFromPatcher, h as resolveTailwindV3SourceOptionsFromPatcher, i as normalizeWeappTailwindcssGeneratorOptions, m as resolveTailwindV3SourceFromPatcher, p as resolveTailwindV3Source, s as resolveTailwindV4SourceFromPatcher, t as createWeappTailwindcssGenerator, v as removeUnsupportedCascadeLayers } from "./generator-
|
|
2
|
-
import { l as replaceWxml } from "./precheck-
|
|
1
|
+
import { a as resolveTailwindV4Source, c as resolveTailwindV4SourceOptionsFromPatcher, h as resolveTailwindV3SourceOptionsFromPatcher, i as normalizeWeappTailwindcssGeneratorOptions, m as resolveTailwindV3SourceFromPatcher, p as resolveTailwindV3Source, s as resolveTailwindV4SourceFromPatcher, t as createWeappTailwindcssGenerator, v as removeUnsupportedCascadeLayers } from "./generator-UBmfduYg.mjs";
|
|
2
|
+
import { l as replaceWxml } from "./precheck-B4RH6ZNN.mjs";
|
|
3
3
|
import postcss from "postcss";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import { existsSync, readFileSync } from "node:fs";
|
|
7
|
+
//#region src/bundlers/shared/generator-css/markers.ts
|
|
8
|
+
const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
|
|
9
|
+
const TAILWIND_GENERATED_CSS_MARKER_RE = /\/\*!\s*tailwindcss v|@property\s+--tw-|--tw-|:not\(#\\#\)|\.[^,{]*(?:\\:|\\\[|\\#)|(?::host|page|\.tw-root|wx-root-portal-content)[^{]*\{[^}]*--(?:color|spacing|text|font-weight|radius)-/;
|
|
10
|
+
const GENERATOR_PLACEHOLDER_MARKER_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\//i;
|
|
11
|
+
const GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\/\s*/gi;
|
|
12
|
+
const TAILWIND_BANNER_PREFIX_RE = /^\/\*!\s*tailwindcss v[^*]*\*\/\s*/i;
|
|
13
|
+
const TAILWIND_BANNER_GLOBAL_RE = /\/\*!\s*tailwindcss v[^*]*\*\/\s*/gi;
|
|
14
|
+
const VITE_MARKER_RE = /\/\*\$vite\$:[^*]*\*\//g;
|
|
15
|
+
function createCssAppend(base, extra) {
|
|
16
|
+
if (!base) return extra;
|
|
17
|
+
if (!extra) return base;
|
|
18
|
+
return `${base}\n${extra}`;
|
|
19
|
+
}
|
|
20
|
+
function splitTailwindV4GeneratedCss(rawSource, rawTailwindCss) {
|
|
21
|
+
const trimmedRaw = rawSource.trim();
|
|
22
|
+
const trimmedTailwind = rawTailwindCss.trim();
|
|
23
|
+
if (trimmedRaw === trimmedTailwind) return "";
|
|
24
|
+
if (trimmedTailwind.startsWith(trimmedRaw)) return "";
|
|
25
|
+
const start = rawSource.indexOf(rawTailwindCss);
|
|
26
|
+
if (start === -1) return;
|
|
27
|
+
return createCssAppend(rawSource.slice(0, start), rawSource.slice(start + rawTailwindCss.length));
|
|
28
|
+
}
|
|
29
|
+
function stripTailwindBanner(css) {
|
|
30
|
+
return css.replace(TAILWIND_BANNER_PREFIX_RE, "");
|
|
31
|
+
}
|
|
32
|
+
function stripTailwindBanners(css) {
|
|
33
|
+
return css.replace(TAILWIND_BANNER_GLOBAL_RE, "");
|
|
34
|
+
}
|
|
35
|
+
function stripGeneratorPlaceholderMarkers(css) {
|
|
36
|
+
return css.replace(GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE, "");
|
|
37
|
+
}
|
|
38
|
+
function hasTailwindGeneratedCss(rawSource) {
|
|
39
|
+
return TAILWIND_V4_BANNER_RE.test(rawSource);
|
|
40
|
+
}
|
|
41
|
+
function hasTailwindGeneratedCssMarkers(rawSource) {
|
|
42
|
+
return TAILWIND_GENERATED_CSS_MARKER_RE.test(rawSource) || GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/bundlers/shared/generator-css/directives.ts
|
|
46
|
+
const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = new Set([
|
|
47
|
+
"config",
|
|
48
|
+
"custom-variant",
|
|
49
|
+
"layer",
|
|
50
|
+
"plugin",
|
|
51
|
+
"reference",
|
|
52
|
+
"source",
|
|
53
|
+
"tailwind",
|
|
54
|
+
"theme",
|
|
55
|
+
"utility",
|
|
56
|
+
"variant"
|
|
57
|
+
]);
|
|
58
|
+
const TAILWIND_ROOT_DIRECTIVE_NAMES = new Set([
|
|
59
|
+
"config",
|
|
60
|
+
"custom-variant",
|
|
61
|
+
"plugin",
|
|
62
|
+
"source",
|
|
63
|
+
"tailwind",
|
|
64
|
+
"theme",
|
|
65
|
+
"utility",
|
|
66
|
+
"variant"
|
|
67
|
+
]);
|
|
68
|
+
const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|tailwind|config|custom-variant|plugin|source|theme|utility|variant)\b/;
|
|
69
|
+
function parseImportRequest(params) {
|
|
70
|
+
return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
|
|
71
|
+
}
|
|
72
|
+
function parseConfigRequest(params) {
|
|
73
|
+
return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
|
|
74
|
+
}
|
|
75
|
+
function isPackageJsonImportRequest(request) {
|
|
76
|
+
return typeof request === "string" && request.startsWith("#");
|
|
77
|
+
}
|
|
78
|
+
function isTailwindImportAtRule(node) {
|
|
79
|
+
if (node.name === "tailwind") return true;
|
|
80
|
+
if (node.name !== "import") return false;
|
|
81
|
+
const request = parseImportRequest(node.params);
|
|
82
|
+
return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
|
|
83
|
+
}
|
|
84
|
+
function isTailwindSourceDirective(node) {
|
|
85
|
+
if (node.type !== "atrule") return false;
|
|
86
|
+
const atRule = node;
|
|
87
|
+
if (isTailwindImportAtRule(atRule)) return true;
|
|
88
|
+
if (atRule.name === "import" && isPackageJsonImportRequest(parseImportRequest(atRule.params))) return true;
|
|
89
|
+
return TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES.has(atRule.name);
|
|
90
|
+
}
|
|
91
|
+
function isTailwindGenerationDirective(node) {
|
|
92
|
+
if (node.type !== "atrule") return false;
|
|
93
|
+
const atRule = node;
|
|
94
|
+
const request = atRule.name === "import" ? parseImportRequest(atRule.params) : atRule.name === "config" || atRule.name === "plugin" || atRule.name === "reference" ? parseConfigRequest(atRule.params) : void 0;
|
|
95
|
+
return isTailwindImportAtRule(atRule) || isPackageJsonImportRequest(request) || atRule.name === "apply" || atRule.name === "layer" || atRule.name === "config" || atRule.name === "source";
|
|
96
|
+
}
|
|
97
|
+
function removeTailwindSourceDirectives(rawSource) {
|
|
98
|
+
try {
|
|
99
|
+
const source = stripGeneratorPlaceholderMarkers(rawSource);
|
|
100
|
+
const root = postcss.parse(source);
|
|
101
|
+
let removed = false;
|
|
102
|
+
root.walk((node) => {
|
|
103
|
+
if (isTailwindSourceDirective(node)) {
|
|
104
|
+
node.remove();
|
|
105
|
+
removed = true;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
return removed ? root.toString() : source;
|
|
109
|
+
} catch {
|
|
110
|
+
return stripGeneratorPlaceholderMarkers(rawSource);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function hasTailwindSourceDirectives(rawSource) {
|
|
114
|
+
try {
|
|
115
|
+
if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
|
|
116
|
+
const root = postcss.parse(rawSource);
|
|
117
|
+
let found = false;
|
|
118
|
+
root.walk((node) => {
|
|
119
|
+
if (isTailwindGenerationDirective(node)) {
|
|
120
|
+
found = true;
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
return found;
|
|
125
|
+
} catch {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function hasTailwindRootDirectives(rawSource) {
|
|
130
|
+
if (!TAILWIND_ROOT_DIRECTIVE_RE.test(rawSource)) return false;
|
|
131
|
+
try {
|
|
132
|
+
const root = postcss.parse(rawSource);
|
|
133
|
+
let found = false;
|
|
134
|
+
root.walkAtRules((node) => {
|
|
135
|
+
const request = node.name === "import" ? parseImportRequest(node.params) : node.name === "config" || node.name === "plugin" ? parseConfigRequest(node.params) : void 0;
|
|
136
|
+
if (isTailwindImportAtRule(node) || isPackageJsonImportRequest(request) || TAILWIND_ROOT_DIRECTIVE_NAMES.has(node.name)) {
|
|
137
|
+
found = true;
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
return found;
|
|
142
|
+
} catch {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function resolveCssEntrySource(rawSource, base, options = {}) {
|
|
147
|
+
try {
|
|
148
|
+
const root = postcss.parse(rawSource);
|
|
149
|
+
let found = false;
|
|
150
|
+
let config;
|
|
151
|
+
let configRequest;
|
|
152
|
+
let removedConfig = false;
|
|
153
|
+
const removeConfig = options.removeConfig ?? true;
|
|
154
|
+
root.walk((node) => {
|
|
155
|
+
if (isTailwindGenerationDirective(node)) found = true;
|
|
156
|
+
if (node.type === "atrule" && node.name === "config") {
|
|
157
|
+
const configPath = parseConfigRequest(node.params);
|
|
158
|
+
if (configPath && !config) {
|
|
159
|
+
configRequest = configPath;
|
|
160
|
+
config = isPackageJsonImportRequest(configPath) ? void 0 : path.isAbsolute(configPath) ? configPath : path.resolve(base, configPath);
|
|
161
|
+
}
|
|
162
|
+
if (removeConfig) {
|
|
163
|
+
node.remove();
|
|
164
|
+
removedConfig = true;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
if (!found) return;
|
|
169
|
+
return {
|
|
170
|
+
css: removedConfig ? root.toString() : rawSource,
|
|
171
|
+
config,
|
|
172
|
+
configRequest,
|
|
173
|
+
base
|
|
174
|
+
};
|
|
175
|
+
} catch {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
7
180
|
//#region src/bundlers/shared/cache.ts
|
|
8
181
|
async function processCachedTask({ cache, cacheKey, hashKey = cacheKey, rawSource, hash, readCache, applyResult, transform, onCacheHit }) {
|
|
9
182
|
let cacheHit = false;
|
|
@@ -369,149 +542,6 @@ function finalizeMiniProgramCss(css) {
|
|
|
369
542
|
}
|
|
370
543
|
}
|
|
371
544
|
//#endregion
|
|
372
|
-
//#region src/bundlers/shared/generator-css/markers.ts
|
|
373
|
-
const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
|
|
374
|
-
const TAILWIND_GENERATED_CSS_MARKER_RE = /\/\*!\s*tailwindcss v|@property\s+--tw-|--tw-|:not\(#\\#\)|\.[^,{]*(?:\\:|\\\[|\\#)|(?::host|page|\.tw-root|wx-root-portal-content)[^{]*\{[^}]*--(?:color|spacing|text|font-weight|radius)-/;
|
|
375
|
-
const GENERATOR_PLACEHOLDER_MARKER_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\//i;
|
|
376
|
-
const GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\/\s*/gi;
|
|
377
|
-
const TAILWIND_BANNER_PREFIX_RE = /^\/\*!\s*tailwindcss v[^*]*\*\/\s*/i;
|
|
378
|
-
const TAILWIND_BANNER_GLOBAL_RE = /\/\*!\s*tailwindcss v[^*]*\*\/\s*/gi;
|
|
379
|
-
const VITE_MARKER_RE = /\/\*\$vite\$:[^*]*\*\//g;
|
|
380
|
-
function createCssAppend(base, extra) {
|
|
381
|
-
if (!base) return extra;
|
|
382
|
-
if (!extra) return base;
|
|
383
|
-
return `${base}\n${extra}`;
|
|
384
|
-
}
|
|
385
|
-
function splitTailwindV4GeneratedCss(rawSource, rawTailwindCss) {
|
|
386
|
-
const trimmedRaw = rawSource.trim();
|
|
387
|
-
const trimmedTailwind = rawTailwindCss.trim();
|
|
388
|
-
if (trimmedRaw === trimmedTailwind) return "";
|
|
389
|
-
if (trimmedTailwind.startsWith(trimmedRaw)) return "";
|
|
390
|
-
const start = rawSource.indexOf(rawTailwindCss);
|
|
391
|
-
if (start === -1) return;
|
|
392
|
-
return createCssAppend(rawSource.slice(0, start), rawSource.slice(start + rawTailwindCss.length));
|
|
393
|
-
}
|
|
394
|
-
function stripTailwindBanner(css) {
|
|
395
|
-
return css.replace(TAILWIND_BANNER_PREFIX_RE, "");
|
|
396
|
-
}
|
|
397
|
-
function stripTailwindBanners(css) {
|
|
398
|
-
return css.replace(TAILWIND_BANNER_GLOBAL_RE, "");
|
|
399
|
-
}
|
|
400
|
-
function stripGeneratorPlaceholderMarkers(css) {
|
|
401
|
-
return css.replace(GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE, "");
|
|
402
|
-
}
|
|
403
|
-
function hasTailwindGeneratedCss(rawSource) {
|
|
404
|
-
return TAILWIND_V4_BANNER_RE.test(rawSource);
|
|
405
|
-
}
|
|
406
|
-
function hasTailwindGeneratedCssMarkers(rawSource) {
|
|
407
|
-
return TAILWIND_GENERATED_CSS_MARKER_RE.test(rawSource) || GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
|
|
408
|
-
}
|
|
409
|
-
//#endregion
|
|
410
|
-
//#region src/bundlers/shared/generator-css/directives.ts
|
|
411
|
-
const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = new Set([
|
|
412
|
-
"config",
|
|
413
|
-
"custom-variant",
|
|
414
|
-
"layer",
|
|
415
|
-
"plugin",
|
|
416
|
-
"reference",
|
|
417
|
-
"source",
|
|
418
|
-
"tailwind",
|
|
419
|
-
"theme",
|
|
420
|
-
"utility",
|
|
421
|
-
"variant"
|
|
422
|
-
]);
|
|
423
|
-
function parseImportRequest(params) {
|
|
424
|
-
return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
|
|
425
|
-
}
|
|
426
|
-
function parseConfigRequest(params) {
|
|
427
|
-
return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
|
|
428
|
-
}
|
|
429
|
-
function isPackageJsonImportRequest(request) {
|
|
430
|
-
return typeof request === "string" && request.startsWith("#");
|
|
431
|
-
}
|
|
432
|
-
function isTailwindImportAtRule(node) {
|
|
433
|
-
if (node.name === "tailwind") return true;
|
|
434
|
-
if (node.name !== "import") return false;
|
|
435
|
-
const request = parseImportRequest(node.params);
|
|
436
|
-
return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
|
|
437
|
-
}
|
|
438
|
-
function isTailwindSourceDirective(node) {
|
|
439
|
-
if (node.type !== "atrule") return false;
|
|
440
|
-
if (isTailwindImportAtRule(node)) return true;
|
|
441
|
-
if (node.name === "import" && isPackageJsonImportRequest(parseImportRequest(node.params))) return true;
|
|
442
|
-
return TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES.has(node.name);
|
|
443
|
-
}
|
|
444
|
-
function isTailwindGenerationDirective(node) {
|
|
445
|
-
if (node.type !== "atrule") return false;
|
|
446
|
-
const request = node.name === "import" ? parseImportRequest(node.params) : node.name === "config" || node.name === "plugin" || node.name === "reference" ? parseConfigRequest(node.params) : void 0;
|
|
447
|
-
return isTailwindImportAtRule(node) || isPackageJsonImportRequest(request) || node.name === "apply" || node.name === "layer" || node.name === "config" || node.name === "source";
|
|
448
|
-
}
|
|
449
|
-
function removeTailwindSourceDirectives(rawSource) {
|
|
450
|
-
try {
|
|
451
|
-
const source = stripGeneratorPlaceholderMarkers(rawSource);
|
|
452
|
-
const root = postcss.parse(source);
|
|
453
|
-
let removed = false;
|
|
454
|
-
root.walk((node) => {
|
|
455
|
-
if (isTailwindSourceDirective(node)) {
|
|
456
|
-
node.remove();
|
|
457
|
-
removed = true;
|
|
458
|
-
}
|
|
459
|
-
});
|
|
460
|
-
return removed ? root.toString() : source;
|
|
461
|
-
} catch {
|
|
462
|
-
return stripGeneratorPlaceholderMarkers(rawSource);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
function hasTailwindSourceDirectives(rawSource) {
|
|
466
|
-
try {
|
|
467
|
-
if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
|
|
468
|
-
const root = postcss.parse(rawSource);
|
|
469
|
-
let found = false;
|
|
470
|
-
root.walk((node) => {
|
|
471
|
-
if (isTailwindGenerationDirective(node)) {
|
|
472
|
-
found = true;
|
|
473
|
-
return false;
|
|
474
|
-
}
|
|
475
|
-
});
|
|
476
|
-
return found;
|
|
477
|
-
} catch {
|
|
478
|
-
return false;
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
function resolveCssEntrySource(rawSource, base, options = {}) {
|
|
482
|
-
try {
|
|
483
|
-
const root = postcss.parse(rawSource);
|
|
484
|
-
let found = false;
|
|
485
|
-
let config;
|
|
486
|
-
let configRequest;
|
|
487
|
-
let removedConfig = false;
|
|
488
|
-
const removeConfig = options.removeConfig ?? true;
|
|
489
|
-
root.walk((node) => {
|
|
490
|
-
if (isTailwindGenerationDirective(node)) found = true;
|
|
491
|
-
if (node.type === "atrule" && node.name === "config") {
|
|
492
|
-
const configPath = parseConfigRequest(node.params);
|
|
493
|
-
if (configPath && !config) {
|
|
494
|
-
configRequest = configPath;
|
|
495
|
-
config = isPackageJsonImportRequest(configPath) ? void 0 : path.isAbsolute(configPath) ? configPath : path.resolve(base, configPath);
|
|
496
|
-
}
|
|
497
|
-
if (removeConfig) {
|
|
498
|
-
node.remove();
|
|
499
|
-
removedConfig = true;
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
});
|
|
503
|
-
if (!found) return;
|
|
504
|
-
return {
|
|
505
|
-
css: removedConfig ? root.toString() : rawSource,
|
|
506
|
-
config,
|
|
507
|
-
configRequest,
|
|
508
|
-
base
|
|
509
|
-
};
|
|
510
|
-
} catch {
|
|
511
|
-
return;
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
//#endregion
|
|
515
545
|
//#region src/bundlers/shared/generator-css/legacy-selectors.ts
|
|
516
546
|
const CLASS_SELECTOR_RE = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
|
|
517
547
|
const MINI_PROGRAM_THEME_SCOPE_SELECTORS = new Set([
|
|
@@ -868,6 +898,9 @@ function tryResolveTailwindV4SourceOptions(runtimeState) {
|
|
|
868
898
|
return;
|
|
869
899
|
}
|
|
870
900
|
}
|
|
901
|
+
function hasConfiguredTailwindV4CssSource(sourceOptions) {
|
|
902
|
+
return Boolean(sourceOptions?.css) || Boolean(sourceOptions?.cssSources?.length);
|
|
903
|
+
}
|
|
871
904
|
async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions) {
|
|
872
905
|
const cssEntrySource = resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions), { removeConfig: majorVersion === 3 });
|
|
873
906
|
if (majorVersion === 3) {
|
|
@@ -888,6 +921,11 @@ async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, fil
|
|
|
888
921
|
});
|
|
889
922
|
}
|
|
890
923
|
const sourceOptions = tryResolveTailwindV4SourceOptions(runtimeState);
|
|
924
|
+
const configuredCssSource = sourceOptions && hasConfiguredTailwindV4CssSource(sourceOptions) && hasTailwindGeneratedCssMarkers(rawSource) ? await resolveTailwindV4Source(sourceOptions) : void 0;
|
|
925
|
+
if (configuredCssSource) return generatorOptions?.config ? {
|
|
926
|
+
...configuredCssSource,
|
|
927
|
+
css: prependConfigDirective(configuredCssSource.css, generatorOptions.config)
|
|
928
|
+
} : configuredCssSource;
|
|
891
929
|
const shouldPreferSourceSideEntry = shouldResolveSourceSideCssEntry(rawSource) || Boolean(cssEntrySource?.css.includes("weapp-tailwindcss generator-placeholder"));
|
|
892
930
|
const sourceSideEntrySource = sourceOptions && shouldPreferSourceSideEntry ? resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: false }) : void 0;
|
|
893
931
|
const matchedCssEntrySource = sourceOptions && cssEntrySource ? await resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) : void 0;
|
|
@@ -1282,4 +1320,4 @@ async function validateCandidatesByGenerator(options) {
|
|
|
1282
1320
|
return classSet;
|
|
1283
1321
|
}
|
|
1284
1322
|
//#endregion
|
|
1285
|
-
export {
|
|
1323
|
+
export { hasTailwindSourceDirectives as a, hasTailwindRootDirectives as i, validateCandidatesByGenerator as n, hasTailwindGeneratedCssMarkers as o, processCachedTask as r, generateCssByGenerator as t };
|