weapp-tailwindcss 5.0.0-next.7 → 5.0.0-next.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundlers/shared/generator-css/directives.d.ts +2 -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-Dnpl-IY2.js → generator-css-Bwp3nbrl.js} +209 -146
- package/dist/{generator-css-B938WI9a.mjs → generator-css-DeLLmp2N.mjs} +204 -147
- 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-D0CoRblu.js → vite-By5KQi9s.js} +59 -27
- package/dist/{vite-BXChkciE.mjs → vite-Cyp42bBf.mjs} +59 -27
- 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-BzN2ly34.js} +46 -10
- package/dist/{webpack-BNdGm9KL.mjs → webpack-DJazm5sT.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,8 @@
|
|
|
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;
|
|
5
|
+
export declare function hasTailwindApplyDirective(rawSource: string): boolean;
|
|
4
6
|
export declare function resolveCssEntrySource(rawSource: string, base: string, options?: {
|
|
5
7
|
removeConfig?: boolean;
|
|
6
8
|
}): {
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_generator = require("./generator-
|
|
3
|
-
const require_precheck = require("./precheck-
|
|
2
|
+
const require_generator = require("./generator-DKkhJbOg.js");
|
|
3
|
+
const require_precheck = require("./precheck-B32p-gLI.js");
|
|
4
4
|
let postcss = require("postcss");
|
|
5
5
|
postcss = require_chunk.__toESM(postcss);
|
|
6
6
|
let node_path = require("node:path");
|
|
@@ -8,6 +8,193 @@ node_path = require_chunk.__toESM(node_path);
|
|
|
8
8
|
let node_process = require("node:process");
|
|
9
9
|
node_process = require_chunk.__toESM(node_process);
|
|
10
10
|
let node_fs = require("node:fs");
|
|
11
|
+
//#region src/bundlers/shared/generator-css/markers.ts
|
|
12
|
+
const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
|
|
13
|
+
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)-/;
|
|
14
|
+
const GENERATOR_PLACEHOLDER_MARKER_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\//i;
|
|
15
|
+
const GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\/\s*/gi;
|
|
16
|
+
const TAILWIND_BANNER_PREFIX_RE = /^\/\*!\s*tailwindcss v[^*]*\*\/\s*/i;
|
|
17
|
+
const TAILWIND_BANNER_GLOBAL_RE = /\/\*!\s*tailwindcss v[^*]*\*\/\s*/gi;
|
|
18
|
+
const VITE_MARKER_RE = /\/\*\$vite\$:[^*]*\*\//g;
|
|
19
|
+
function createCssAppend(base, extra) {
|
|
20
|
+
if (!base) return extra;
|
|
21
|
+
if (!extra) return base;
|
|
22
|
+
return `${base}\n${extra}`;
|
|
23
|
+
}
|
|
24
|
+
function splitTailwindV4GeneratedCss(rawSource, rawTailwindCss) {
|
|
25
|
+
const trimmedRaw = rawSource.trim();
|
|
26
|
+
const trimmedTailwind = rawTailwindCss.trim();
|
|
27
|
+
if (trimmedRaw === trimmedTailwind) return "";
|
|
28
|
+
if (trimmedTailwind.startsWith(trimmedRaw)) return "";
|
|
29
|
+
const start = rawSource.indexOf(rawTailwindCss);
|
|
30
|
+
if (start === -1) return;
|
|
31
|
+
return createCssAppend(rawSource.slice(0, start), rawSource.slice(start + rawTailwindCss.length));
|
|
32
|
+
}
|
|
33
|
+
function stripTailwindBanner(css) {
|
|
34
|
+
return css.replace(TAILWIND_BANNER_PREFIX_RE, "");
|
|
35
|
+
}
|
|
36
|
+
function stripTailwindBanners(css) {
|
|
37
|
+
return css.replace(TAILWIND_BANNER_GLOBAL_RE, "");
|
|
38
|
+
}
|
|
39
|
+
function stripGeneratorPlaceholderMarkers(css) {
|
|
40
|
+
return css.replace(GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE, "");
|
|
41
|
+
}
|
|
42
|
+
function hasTailwindGeneratedCss(rawSource) {
|
|
43
|
+
return TAILWIND_V4_BANNER_RE.test(rawSource);
|
|
44
|
+
}
|
|
45
|
+
function hasTailwindGeneratedCssMarkers(rawSource) {
|
|
46
|
+
return TAILWIND_GENERATED_CSS_MARKER_RE.test(rawSource) || GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/bundlers/shared/generator-css/directives.ts
|
|
50
|
+
const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = new Set([
|
|
51
|
+
"config",
|
|
52
|
+
"custom-variant",
|
|
53
|
+
"layer",
|
|
54
|
+
"plugin",
|
|
55
|
+
"reference",
|
|
56
|
+
"source",
|
|
57
|
+
"tailwind",
|
|
58
|
+
"theme",
|
|
59
|
+
"utility",
|
|
60
|
+
"variant"
|
|
61
|
+
]);
|
|
62
|
+
const TAILWIND_ROOT_DIRECTIVE_NAMES = new Set([
|
|
63
|
+
"config",
|
|
64
|
+
"custom-variant",
|
|
65
|
+
"plugin",
|
|
66
|
+
"source",
|
|
67
|
+
"tailwind",
|
|
68
|
+
"theme",
|
|
69
|
+
"utility",
|
|
70
|
+
"variant"
|
|
71
|
+
]);
|
|
72
|
+
const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|tailwind|config|custom-variant|plugin|source|theme|utility|variant)\b/;
|
|
73
|
+
function parseImportRequest(params) {
|
|
74
|
+
return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
|
|
75
|
+
}
|
|
76
|
+
function parseConfigRequest(params) {
|
|
77
|
+
return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
|
|
78
|
+
}
|
|
79
|
+
function isPackageJsonImportRequest(request) {
|
|
80
|
+
return typeof request === "string" && request.startsWith("#");
|
|
81
|
+
}
|
|
82
|
+
function isTailwindImportAtRule(node) {
|
|
83
|
+
if (node.name === "tailwind") return true;
|
|
84
|
+
if (node.name !== "import") return false;
|
|
85
|
+
const request = parseImportRequest(node.params);
|
|
86
|
+
return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
|
|
87
|
+
}
|
|
88
|
+
function isTailwindSourceDirective(node) {
|
|
89
|
+
if (node.type !== "atrule") return false;
|
|
90
|
+
const atRule = node;
|
|
91
|
+
if (isTailwindImportAtRule(atRule)) return true;
|
|
92
|
+
if (atRule.name === "import" && isPackageJsonImportRequest(parseImportRequest(atRule.params))) return true;
|
|
93
|
+
return TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES.has(atRule.name);
|
|
94
|
+
}
|
|
95
|
+
function isTailwindGenerationDirective(node) {
|
|
96
|
+
if (node.type !== "atrule") return false;
|
|
97
|
+
const atRule = node;
|
|
98
|
+
const request = atRule.name === "import" ? parseImportRequest(atRule.params) : atRule.name === "config" || atRule.name === "plugin" || atRule.name === "reference" ? parseConfigRequest(atRule.params) : void 0;
|
|
99
|
+
return isTailwindImportAtRule(atRule) || isPackageJsonImportRequest(request) || atRule.name === "apply" || atRule.name === "layer" || atRule.name === "config" || atRule.name === "source";
|
|
100
|
+
}
|
|
101
|
+
function removeTailwindSourceDirectives(rawSource) {
|
|
102
|
+
try {
|
|
103
|
+
const source = stripGeneratorPlaceholderMarkers(rawSource);
|
|
104
|
+
const root = postcss.default.parse(source);
|
|
105
|
+
let removed = false;
|
|
106
|
+
root.walk((node) => {
|
|
107
|
+
if (isTailwindSourceDirective(node)) {
|
|
108
|
+
node.remove();
|
|
109
|
+
removed = true;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return removed ? root.toString() : source;
|
|
113
|
+
} catch {
|
|
114
|
+
return stripGeneratorPlaceholderMarkers(rawSource);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function hasTailwindSourceDirectives(rawSource) {
|
|
118
|
+
try {
|
|
119
|
+
if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
|
|
120
|
+
const root = postcss.default.parse(rawSource);
|
|
121
|
+
let found = false;
|
|
122
|
+
root.walk((node) => {
|
|
123
|
+
if (isTailwindGenerationDirective(node)) {
|
|
124
|
+
found = true;
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
return found;
|
|
129
|
+
} catch {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function hasTailwindRootDirectives(rawSource) {
|
|
134
|
+
if (!TAILWIND_ROOT_DIRECTIVE_RE.test(rawSource)) return false;
|
|
135
|
+
try {
|
|
136
|
+
const root = postcss.default.parse(rawSource);
|
|
137
|
+
let found = false;
|
|
138
|
+
root.walkAtRules((node) => {
|
|
139
|
+
const request = node.name === "import" ? parseImportRequest(node.params) : node.name === "config" || node.name === "plugin" ? parseConfigRequest(node.params) : void 0;
|
|
140
|
+
if (isTailwindImportAtRule(node) || isPackageJsonImportRequest(request) || TAILWIND_ROOT_DIRECTIVE_NAMES.has(node.name)) {
|
|
141
|
+
found = true;
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return found;
|
|
146
|
+
} catch {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function hasTailwindApplyDirective(rawSource) {
|
|
151
|
+
if (!rawSource.includes("@apply")) return false;
|
|
152
|
+
try {
|
|
153
|
+
const root = postcss.default.parse(rawSource);
|
|
154
|
+
let found = false;
|
|
155
|
+
root.walkAtRules("apply", () => {
|
|
156
|
+
found = true;
|
|
157
|
+
return false;
|
|
158
|
+
});
|
|
159
|
+
return found;
|
|
160
|
+
} catch {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function resolveCssEntrySource(rawSource, base, options = {}) {
|
|
165
|
+
try {
|
|
166
|
+
const root = postcss.default.parse(rawSource);
|
|
167
|
+
let found = false;
|
|
168
|
+
let config;
|
|
169
|
+
let configRequest;
|
|
170
|
+
let removedConfig = false;
|
|
171
|
+
const removeConfig = options.removeConfig ?? true;
|
|
172
|
+
root.walk((node) => {
|
|
173
|
+
if (isTailwindGenerationDirective(node)) found = true;
|
|
174
|
+
if (node.type === "atrule" && node.name === "config") {
|
|
175
|
+
const configPath = parseConfigRequest(node.params);
|
|
176
|
+
if (configPath && !config) {
|
|
177
|
+
configRequest = configPath;
|
|
178
|
+
config = isPackageJsonImportRequest(configPath) ? void 0 : node_path.default.isAbsolute(configPath) ? configPath : node_path.default.resolve(base, configPath);
|
|
179
|
+
}
|
|
180
|
+
if (removeConfig) {
|
|
181
|
+
node.remove();
|
|
182
|
+
removedConfig = true;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
if (!found) return;
|
|
187
|
+
return {
|
|
188
|
+
css: removedConfig ? root.toString() : rawSource,
|
|
189
|
+
config,
|
|
190
|
+
configRequest,
|
|
191
|
+
base
|
|
192
|
+
};
|
|
193
|
+
} catch {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
//#endregion
|
|
11
198
|
//#region src/bundlers/shared/cache.ts
|
|
12
199
|
async function processCachedTask({ cache, cacheKey, hashKey = cacheKey, rawSource, hash, readCache, applyResult, transform, onCacheHit }) {
|
|
13
200
|
let cacheHit = false;
|
|
@@ -373,149 +560,6 @@ function finalizeMiniProgramCss(css) {
|
|
|
373
560
|
}
|
|
374
561
|
}
|
|
375
562
|
//#endregion
|
|
376
|
-
//#region src/bundlers/shared/generator-css/markers.ts
|
|
377
|
-
const TAILWIND_V4_BANNER_RE = /\/\*!\s*tailwindcss v4\./;
|
|
378
|
-
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)-/;
|
|
379
|
-
const GENERATOR_PLACEHOLDER_MARKER_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\//i;
|
|
380
|
-
const GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\/\s*/gi;
|
|
381
|
-
const TAILWIND_BANNER_PREFIX_RE = /^\/\*!\s*tailwindcss v[^*]*\*\/\s*/i;
|
|
382
|
-
const TAILWIND_BANNER_GLOBAL_RE = /\/\*!\s*tailwindcss v[^*]*\*\/\s*/gi;
|
|
383
|
-
const VITE_MARKER_RE = /\/\*\$vite\$:[^*]*\*\//g;
|
|
384
|
-
function createCssAppend(base, extra) {
|
|
385
|
-
if (!base) return extra;
|
|
386
|
-
if (!extra) return base;
|
|
387
|
-
return `${base}\n${extra}`;
|
|
388
|
-
}
|
|
389
|
-
function splitTailwindV4GeneratedCss(rawSource, rawTailwindCss) {
|
|
390
|
-
const trimmedRaw = rawSource.trim();
|
|
391
|
-
const trimmedTailwind = rawTailwindCss.trim();
|
|
392
|
-
if (trimmedRaw === trimmedTailwind) return "";
|
|
393
|
-
if (trimmedTailwind.startsWith(trimmedRaw)) return "";
|
|
394
|
-
const start = rawSource.indexOf(rawTailwindCss);
|
|
395
|
-
if (start === -1) return;
|
|
396
|
-
return createCssAppend(rawSource.slice(0, start), rawSource.slice(start + rawTailwindCss.length));
|
|
397
|
-
}
|
|
398
|
-
function stripTailwindBanner(css) {
|
|
399
|
-
return css.replace(TAILWIND_BANNER_PREFIX_RE, "");
|
|
400
|
-
}
|
|
401
|
-
function stripTailwindBanners(css) {
|
|
402
|
-
return css.replace(TAILWIND_BANNER_GLOBAL_RE, "");
|
|
403
|
-
}
|
|
404
|
-
function stripGeneratorPlaceholderMarkers(css) {
|
|
405
|
-
return css.replace(GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE, "");
|
|
406
|
-
}
|
|
407
|
-
function hasTailwindGeneratedCss(rawSource) {
|
|
408
|
-
return TAILWIND_V4_BANNER_RE.test(rawSource);
|
|
409
|
-
}
|
|
410
|
-
function hasTailwindGeneratedCssMarkers(rawSource) {
|
|
411
|
-
return TAILWIND_GENERATED_CSS_MARKER_RE.test(rawSource) || GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource);
|
|
412
|
-
}
|
|
413
|
-
//#endregion
|
|
414
|
-
//#region src/bundlers/shared/generator-css/directives.ts
|
|
415
|
-
const TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES = new Set([
|
|
416
|
-
"config",
|
|
417
|
-
"custom-variant",
|
|
418
|
-
"layer",
|
|
419
|
-
"plugin",
|
|
420
|
-
"reference",
|
|
421
|
-
"source",
|
|
422
|
-
"tailwind",
|
|
423
|
-
"theme",
|
|
424
|
-
"utility",
|
|
425
|
-
"variant"
|
|
426
|
-
]);
|
|
427
|
-
function parseImportRequest(params) {
|
|
428
|
-
return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
|
|
429
|
-
}
|
|
430
|
-
function parseConfigRequest(params) {
|
|
431
|
-
return /^(["'])(.+)\1\s*;?$/.exec(params.trim())?.[2];
|
|
432
|
-
}
|
|
433
|
-
function isPackageJsonImportRequest(request) {
|
|
434
|
-
return typeof request === "string" && request.startsWith("#");
|
|
435
|
-
}
|
|
436
|
-
function isTailwindImportAtRule(node) {
|
|
437
|
-
if (node.name === "tailwind") return true;
|
|
438
|
-
if (node.name !== "import") return false;
|
|
439
|
-
const request = parseImportRequest(node.params);
|
|
440
|
-
return request === "tailwindcss" || request === "tailwindcss4" || request?.startsWith("tailwindcss/") || request?.startsWith("tailwindcss4/");
|
|
441
|
-
}
|
|
442
|
-
function isTailwindSourceDirective(node) {
|
|
443
|
-
if (node.type !== "atrule") return false;
|
|
444
|
-
if (isTailwindImportAtRule(node)) return true;
|
|
445
|
-
if (node.name === "import" && isPackageJsonImportRequest(parseImportRequest(node.params))) return true;
|
|
446
|
-
return TAILWIND_REMOVABLE_SOURCE_DIRECTIVE_NAMES.has(node.name);
|
|
447
|
-
}
|
|
448
|
-
function isTailwindGenerationDirective(node) {
|
|
449
|
-
if (node.type !== "atrule") return false;
|
|
450
|
-
const request = node.name === "import" ? parseImportRequest(node.params) : node.name === "config" || node.name === "plugin" || node.name === "reference" ? parseConfigRequest(node.params) : void 0;
|
|
451
|
-
return isTailwindImportAtRule(node) || isPackageJsonImportRequest(request) || node.name === "apply" || node.name === "layer" || node.name === "config" || node.name === "source";
|
|
452
|
-
}
|
|
453
|
-
function removeTailwindSourceDirectives(rawSource) {
|
|
454
|
-
try {
|
|
455
|
-
const source = stripGeneratorPlaceholderMarkers(rawSource);
|
|
456
|
-
const root = postcss.default.parse(source);
|
|
457
|
-
let removed = false;
|
|
458
|
-
root.walk((node) => {
|
|
459
|
-
if (isTailwindSourceDirective(node)) {
|
|
460
|
-
node.remove();
|
|
461
|
-
removed = true;
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
return removed ? root.toString() : source;
|
|
465
|
-
} catch {
|
|
466
|
-
return stripGeneratorPlaceholderMarkers(rawSource);
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
function hasTailwindSourceDirectives(rawSource) {
|
|
470
|
-
try {
|
|
471
|
-
if (GENERATOR_PLACEHOLDER_MARKER_RE.test(rawSource)) return true;
|
|
472
|
-
const root = postcss.default.parse(rawSource);
|
|
473
|
-
let found = false;
|
|
474
|
-
root.walk((node) => {
|
|
475
|
-
if (isTailwindGenerationDirective(node)) {
|
|
476
|
-
found = true;
|
|
477
|
-
return false;
|
|
478
|
-
}
|
|
479
|
-
});
|
|
480
|
-
return found;
|
|
481
|
-
} catch {
|
|
482
|
-
return false;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
function resolveCssEntrySource(rawSource, base, options = {}) {
|
|
486
|
-
try {
|
|
487
|
-
const root = postcss.default.parse(rawSource);
|
|
488
|
-
let found = false;
|
|
489
|
-
let config;
|
|
490
|
-
let configRequest;
|
|
491
|
-
let removedConfig = false;
|
|
492
|
-
const removeConfig = options.removeConfig ?? true;
|
|
493
|
-
root.walk((node) => {
|
|
494
|
-
if (isTailwindGenerationDirective(node)) found = true;
|
|
495
|
-
if (node.type === "atrule" && node.name === "config") {
|
|
496
|
-
const configPath = parseConfigRequest(node.params);
|
|
497
|
-
if (configPath && !config) {
|
|
498
|
-
configRequest = configPath;
|
|
499
|
-
config = isPackageJsonImportRequest(configPath) ? void 0 : node_path.default.isAbsolute(configPath) ? configPath : node_path.default.resolve(base, configPath);
|
|
500
|
-
}
|
|
501
|
-
if (removeConfig) {
|
|
502
|
-
node.remove();
|
|
503
|
-
removedConfig = true;
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
});
|
|
507
|
-
if (!found) return;
|
|
508
|
-
return {
|
|
509
|
-
css: removedConfig ? root.toString() : rawSource,
|
|
510
|
-
config,
|
|
511
|
-
configRequest,
|
|
512
|
-
base
|
|
513
|
-
};
|
|
514
|
-
} catch {
|
|
515
|
-
return;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
//#endregion
|
|
519
563
|
//#region src/bundlers/shared/generator-css/legacy-selectors.ts
|
|
520
564
|
const CLASS_SELECTOR_RE = /(?:^|[^\w-])\.[_a-z\u00A0-\uFFFF\\-]/i;
|
|
521
565
|
const MINI_PROGRAM_THEME_SCOPE_SELECTORS = new Set([
|
|
@@ -872,6 +916,13 @@ function tryResolveTailwindV4SourceOptions(runtimeState) {
|
|
|
872
916
|
return;
|
|
873
917
|
}
|
|
874
918
|
}
|
|
919
|
+
function hasConfiguredTailwindV4CssSource(sourceOptions) {
|
|
920
|
+
return Boolean(sourceOptions?.css) || Boolean(sourceOptions?.cssSources?.length);
|
|
921
|
+
}
|
|
922
|
+
function createTailwindV4ApplyReferenceSource(css, sourceOptions) {
|
|
923
|
+
if (!hasTailwindApplyDirective(css) || hasTailwindRootDirectives(css)) return css;
|
|
924
|
+
return `@reference "${sourceOptions.packageName ?? "tailwindcss"}";\n${css}`;
|
|
925
|
+
}
|
|
875
926
|
async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions) {
|
|
876
927
|
const cssEntrySource = resolveCssEntrySource(rawSource, resolveCssSourceBase(file, cssHandlerOptions), { removeConfig: majorVersion === 3 });
|
|
877
928
|
if (majorVersion === 3) {
|
|
@@ -892,6 +943,11 @@ async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, fil
|
|
|
892
943
|
});
|
|
893
944
|
}
|
|
894
945
|
const sourceOptions = tryResolveTailwindV4SourceOptions(runtimeState);
|
|
946
|
+
const configuredCssSource = sourceOptions && hasConfiguredTailwindV4CssSource(sourceOptions) && hasTailwindGeneratedCssMarkers(rawSource) ? await require_generator.resolveTailwindV4Source(sourceOptions) : void 0;
|
|
947
|
+
if (configuredCssSource) return generatorOptions?.config ? {
|
|
948
|
+
...configuredCssSource,
|
|
949
|
+
css: prependConfigDirective(configuredCssSource.css, generatorOptions.config)
|
|
950
|
+
} : configuredCssSource;
|
|
895
951
|
const shouldPreferSourceSideEntry = shouldResolveSourceSideCssEntry(rawSource) || Boolean(cssEntrySource?.css.includes("weapp-tailwindcss generator-placeholder"));
|
|
896
952
|
const sourceSideEntrySource = sourceOptions && shouldPreferSourceSideEntry ? resolveSourceSideCssEntrySource(file, sourceOptions, { removeConfig: false }) : void 0;
|
|
897
953
|
const matchedCssEntrySource = sourceOptions && cssEntrySource ? await resolveMatchingTailwindV4CssEntry(rawSource, file, sourceOptions) : void 0;
|
|
@@ -915,10 +971,11 @@ async function resolveGeneratorSource(majorVersion, runtimeState, rawSource, fil
|
|
|
915
971
|
}
|
|
916
972
|
const resolvedSourceOptions = sourceOptions ?? {};
|
|
917
973
|
const config = resolveExistingConfigPath(resolvedEntrySource.config, resolvedEntrySource.configRequest, file, resolvedSourceOptions);
|
|
974
|
+
const css = createTailwindV4ApplyReferenceSource(normalizeConfigDirective(prependConfigDirective(resolvedEntrySource.css, generatorOptions?.config), config), resolvedSourceOptions);
|
|
918
975
|
return require_generator.resolveTailwindV4Source({
|
|
919
976
|
...resolvedSourceOptions,
|
|
920
977
|
base: resolvedEntrySource.base,
|
|
921
|
-
css
|
|
978
|
+
css
|
|
922
979
|
});
|
|
923
980
|
}
|
|
924
981
|
async function resolveGeneratorSources(majorVersion, runtimeState, rawSource, file, cssHandlerOptions, generatorOptions) {
|
|
@@ -1298,6 +1355,12 @@ Object.defineProperty(exports, "hasTailwindGeneratedCssMarkers", {
|
|
|
1298
1355
|
return hasTailwindGeneratedCssMarkers;
|
|
1299
1356
|
}
|
|
1300
1357
|
});
|
|
1358
|
+
Object.defineProperty(exports, "hasTailwindRootDirectives", {
|
|
1359
|
+
enumerable: true,
|
|
1360
|
+
get: function() {
|
|
1361
|
+
return hasTailwindRootDirectives;
|
|
1362
|
+
}
|
|
1363
|
+
});
|
|
1301
1364
|
Object.defineProperty(exports, "hasTailwindSourceDirectives", {
|
|
1302
1365
|
enumerable: true,
|
|
1303
1366
|
get: function() {
|