weapp-tailwindcss 5.0.0-next.14 → 5.0.0-next.16
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/{bundle-state-CxtGmT4t.js → bundle-state-5CBF59C0.js} +1 -1
- package/dist/{bundle-state-BOBbxYzQ.mjs → bundle-state-CUuNIG4-.mjs} +1 -1
- package/dist/bundlers/shared/generator-css/markers.d.ts +12 -0
- package/dist/bundlers/shared/generator-css.d.ts +1 -1
- package/dist/bundlers/vite/css-finalizer.d.ts +1 -0
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/{generator-CRORPkpW.js → generator-BTf14-zB.js} +1 -1
- package/dist/{generator-C9H44wEF.mjs → generator-BjB20Esq.mjs} +1 -1
- package/dist/generator.js +2 -2
- package/dist/generator.mjs +2 -2
- package/dist/gulp.js +5 -5
- package/dist/gulp.mjs +5 -5
- package/dist/{incremental-runtime-class-set-B4EXHHii.js → incremental-runtime-class-set-DtYQ57bs.js} +158 -33
- package/dist/{incremental-runtime-class-set-DoKrMrEh.mjs → incremental-runtime-class-set-Dten3guT.mjs} +158 -33
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{postcss-BFxu5_cs.mjs → postcss-CBUuHzjH.mjs} +2 -2
- package/dist/{postcss-Vqn4IlO3.js → postcss-CbrupBCk.js} +2 -2
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/{precheck-DCresEiu.mjs → precheck-CL0BmEi5.mjs} +2 -2
- package/dist/{precheck-CZHcFX8k.js → precheck-CfyWVL3l.js} +2 -2
- package/dist/presets.js +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/{source-candidates-CK70jGo7.mjs → source-candidates-D9iHMeLE.mjs} +1 -1
- package/dist/{source-candidates-BvbvkIPP.js → source-candidates-bTqXER8H.js} +1 -1
- package/dist/{tailwindcss-7k0LFa12.mjs → tailwindcss-CJ487R7-.mjs} +5 -3
- package/dist/{tailwindcss-CN0K7G-l.js → tailwindcss-CSdlV4y2.js} +5 -3
- package/dist/{v3-engine-DwV1E6rX.js → v3-engine-B1AJfKB1.js} +60 -2
- package/dist/{v3-engine-D61eilBl.mjs → v3-engine-BBvwlLWp.mjs} +60 -2
- package/dist/{vite-DJ0P9Hrp.js → vite-Br-D3jQe.js} +32 -15
- package/dist/{vite-DCmKrTo0.mjs → vite-CPhJAYeg.mjs} +32 -15
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +2 -1
- package/dist/{webpack-8y4NOMnT.js → webpack-DNcEK3jn.js} +5 -5
- package/dist/{webpack-CbO4jjkH.mjs → webpack-om3uHco-.mjs} +5 -5
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_precheck = require("./precheck-
|
|
2
|
+
const require_precheck = require("./precheck-CfyWVL3l.js");
|
|
3
3
|
let node_module = require("node:module");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_chunk.__toESM(node_path);
|
|
@@ -8,7 +8,19 @@ export declare const TAILWIND_BANNER_GLOBAL_RE: RegExp;
|
|
|
8
8
|
export declare const VITE_MARKER_RE: RegExp;
|
|
9
9
|
export declare function createCssAppend(base: string, extra: string): string;
|
|
10
10
|
export declare function splitTailwindV4GeneratedCss(rawSource: string, rawTailwindCss: string): string | undefined;
|
|
11
|
+
export declare function splitTailwindV4GeneratedCssBySourceOrder(rawSource: string, rawTailwindCss: string): {
|
|
12
|
+
before: string;
|
|
13
|
+
after: string;
|
|
14
|
+
} | undefined;
|
|
15
|
+
export declare function splitGeneratorPlaceholderCssBySourceOrder(rawSource: string, rawTailwindCss?: string): {
|
|
16
|
+
before: string;
|
|
17
|
+
after: string;
|
|
18
|
+
} | undefined;
|
|
11
19
|
export declare function removeTailwindGeneratedCssByBanner(rawSource: string): string | undefined;
|
|
20
|
+
export declare function splitTailwindGeneratedCssByBanner(rawSource: string, start?: number): {
|
|
21
|
+
before: string;
|
|
22
|
+
after: string;
|
|
23
|
+
} | undefined;
|
|
12
24
|
export declare function stripTailwindBanner(css: string): string;
|
|
13
25
|
export declare function stripTailwindBanners(css: string): string;
|
|
14
26
|
export declare function stripGeneratorPlaceholderMarkers(css: string): string;
|
|
@@ -4,7 +4,7 @@ import type { InternalUserDefinedOptions } from '../../types';
|
|
|
4
4
|
export { hasTailwindSourceDirectives, normalizeTailwindSourceForGenerator, removeTailwindSourceDirectives, resolveCssEntrySource, } from './generator-css/directives';
|
|
5
5
|
export { removeTailwindApplyRules, } from './generator-css/legacy-compat';
|
|
6
6
|
export { inheritLegacyUnitConvertedDeclarations, } from './generator-css/legacy-units';
|
|
7
|
-
export { createCssAppend, hasTailwindGeneratedCss, hasTailwindGeneratedCssMarkers, removeTailwindGeneratedCssByBanner, splitTailwindV4GeneratedCss, stripGeneratorPlaceholderMarkers, stripTailwindBanner, stripTailwindBanners, } from './generator-css/markers';
|
|
7
|
+
export { createCssAppend, hasTailwindGeneratedCss, hasTailwindGeneratedCssMarkers, removeTailwindGeneratedCssByBanner, splitGeneratorPlaceholderCssBySourceOrder, splitTailwindGeneratedCssByBanner, splitTailwindV4GeneratedCss, splitTailwindV4GeneratedCssBySourceOrder, stripGeneratorPlaceholderMarkers, stripTailwindBanner, stripTailwindBanners, } from './generator-css/markers';
|
|
8
8
|
export { resolveGeneratorSource, } from './generator-css/source-resolver';
|
|
9
9
|
export interface GenerateCssByGeneratorOptions {
|
|
10
10
|
opts: InternalUserDefinedOptions;
|
|
@@ -19,6 +19,7 @@ interface CssFinalizerContext {
|
|
|
19
19
|
getSourceCandidatesForEntries?: ((entries: TailwindSourceEntry[] | undefined) => Set<string>) | undefined;
|
|
20
20
|
waitForSourceCandidateSyncs?: () => Promise<void>;
|
|
21
21
|
rememberMainCssSource?: (file: string, rawSource: string) => void;
|
|
22
|
+
getRememberedMainCssSource?: (file: string) => string | undefined;
|
|
22
23
|
}
|
|
23
24
|
export declare function createViteCssFinalizerOutputPlugin(context: CssFinalizerContext): Plugin;
|
|
24
25
|
export {};
|
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-CfyWVL3l.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-CL0BmEi5.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 });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as createTailwindV4Engine, i as createTailwindV3Engine, n as resolveTailwindV3SourceFromPatcher, x as resolveTailwindV4SourceFromPatcher } from "./v3-engine-
|
|
1
|
+
import { C as createTailwindV4Engine, i as createTailwindV3Engine, n as resolveTailwindV3SourceFromPatcher, x as resolveTailwindV4SourceFromPatcher } from "./v3-engine-BBvwlLWp.mjs";
|
|
2
2
|
//#region src/generator/options.ts
|
|
3
3
|
function normalizeWeappTailwindcssGeneratorOptions(options) {
|
|
4
4
|
if (options == null) return {
|
package/dist/generator.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("./chunk-8l464Juk.js");
|
|
3
|
-
const require_v3_engine = require("./v3-engine-
|
|
4
|
-
const require_generator = require("./generator-
|
|
3
|
+
const require_v3_engine = require("./v3-engine-B1AJfKB1.js");
|
|
4
|
+
const require_generator = require("./generator-BTf14-zB.js");
|
|
5
5
|
let tailwindcss_patch = require("tailwindcss-patch");
|
|
6
6
|
exports.createWeappTailwindcssGenerator = require_generator.createWeappTailwindcssGenerator;
|
|
7
7
|
exports.createWeappTailwindcssGeneratorFromPatcher = require_generator.createWeappTailwindcssGeneratorFromPatcher;
|
package/dist/generator.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { S as resolveTailwindV4SourceOptionsFromPatcher, T as transformTailwindV4CssToWeapp, a as transformTailwindV3CssByTarget, b as resolveTailwindV4SourceFromPatchOptions, n as resolveTailwindV3SourceFromPatcher, o as transformTailwindV3CssToWeapp, r as resolveTailwindV3SourceOptionsFromPatcher, t as resolveTailwindV3Source, w as transformTailwindV4CssByTarget, x as resolveTailwindV4SourceFromPatcher, y as resolveTailwindV4Source } from "./v3-engine-
|
|
2
|
-
import { i as normalizeWeappTailwindcssGeneratorOptions, n as createWeappTailwindcssGeneratorFromPatcher, r as resolveTailwindSourceFromPatcher, t as createWeappTailwindcssGenerator } from "./generator-
|
|
1
|
+
import { S as resolveTailwindV4SourceOptionsFromPatcher, T as transformTailwindV4CssToWeapp, a as transformTailwindV3CssByTarget, b as resolveTailwindV4SourceFromPatchOptions, n as resolveTailwindV3SourceFromPatcher, o as transformTailwindV3CssToWeapp, r as resolveTailwindV3SourceOptionsFromPatcher, t as resolveTailwindV3Source, w as transformTailwindV4CssByTarget, x as resolveTailwindV4SourceFromPatcher, y as resolveTailwindV4Source } from "./v3-engine-BBvwlLWp.mjs";
|
|
2
|
+
import { i as normalizeWeappTailwindcssGeneratorOptions, n as createWeappTailwindcssGeneratorFromPatcher, r as resolveTailwindSourceFromPatcher, t as createWeappTailwindcssGenerator } from "./generator-BjB20Esq.mjs";
|
|
3
3
|
export { createWeappTailwindcssGenerator, createWeappTailwindcssGeneratorFromPatcher, normalizeWeappTailwindcssGeneratorOptions, resolveTailwindSourceFromPatcher, resolveTailwindV3Source, resolveTailwindV3SourceFromPatcher, resolveTailwindV3SourceOptionsFromPatcher, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions, resolveTailwindV4SourceFromPatcher, resolveTailwindV4SourceOptionsFromPatcher, transformTailwindV3CssByTarget, transformTailwindV3CssToWeapp, transformTailwindV4CssByTarget, transformTailwindV4CssToWeapp };
|
package/dist/gulp.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
3
|
-
const require_v3_engine = require("./v3-engine-
|
|
4
|
-
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-
|
|
5
|
-
const require_precheck = require("./precheck-
|
|
6
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
7
|
-
const require_source_candidates = require("./source-candidates-
|
|
3
|
+
const require_v3_engine = require("./v3-engine-B1AJfKB1.js");
|
|
4
|
+
const require_incremental_runtime_class_set = require("./incremental-runtime-class-set-DtYQ57bs.js");
|
|
5
|
+
const require_precheck = require("./precheck-CfyWVL3l.js");
|
|
6
|
+
const require_tailwindcss = require("./tailwindcss-CSdlV4y2.js");
|
|
7
|
+
const require_source_candidates = require("./source-candidates-bTqXER8H.js");
|
|
8
8
|
let node_fs = require("node:fs");
|
|
9
9
|
node_fs = require_chunk.__toESM(node_fs);
|
|
10
10
|
let node_path = require("node:path");
|
package/dist/gulp.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { F as createDebug, _ as resolveViteSourceScanEntries, l as getRuntimeClassSetSignature } from "./v3-engine-
|
|
2
|
-
import { i as generateCssByGenerator, l as normalizeTailwindSourceForGenerator, o as processCachedTask, r as emitHmrTiming, s as hasTailwindRootDirectives, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-
|
|
3
|
-
import { _ as ensureRuntimeClassSet, g as createTailwindRuntimeReadyPromise, n as getCompilerContext, t as shouldSkipJsTransform } from "./precheck-
|
|
4
|
-
import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-
|
|
5
|
-
import { t as createSourceCandidateCollector } from "./source-candidates-
|
|
1
|
+
import { F as createDebug, _ as resolveViteSourceScanEntries, l as getRuntimeClassSetSignature } from "./v3-engine-BBvwlLWp.mjs";
|
|
2
|
+
import { i as generateCssByGenerator, l as normalizeTailwindSourceForGenerator, o as processCachedTask, r as emitHmrTiming, s as hasTailwindRootDirectives, t as createBundleRuntimeClassSetManager } from "./incremental-runtime-class-set-Dten3guT.mjs";
|
|
3
|
+
import { _ as ensureRuntimeClassSet, g as createTailwindRuntimeReadyPromise, n as getCompilerContext, t as shouldSkipJsTransform } from "./precheck-CL0BmEi5.mjs";
|
|
4
|
+
import { c as upsertTailwindV4CssSource, s as hasConfiguredTailwindV4CssRoots } from "./tailwindcss-CJ487R7-.mjs";
|
|
5
|
+
import { t as createSourceCandidateCollector } from "./source-candidates-D9iHMeLE.mjs";
|
|
6
6
|
import fs from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import process from "node:process";
|
package/dist/{incremental-runtime-class-set-B4EXHHii.js → incremental-runtime-class-set-DtYQ57bs.js}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_v3_engine = require("./v3-engine-
|
|
3
|
-
const require_generator = require("./generator-
|
|
4
|
-
const require_precheck = require("./precheck-
|
|
5
|
-
const require_tailwindcss = require("./tailwindcss-
|
|
2
|
+
const require_v3_engine = require("./v3-engine-B1AJfKB1.js");
|
|
3
|
+
const require_generator = require("./generator-BTf14-zB.js");
|
|
4
|
+
const require_precheck = require("./precheck-CfyWVL3l.js");
|
|
5
|
+
const require_tailwindcss = require("./tailwindcss-CSdlV4y2.js");
|
|
6
6
|
let node_fs = require("node:fs");
|
|
7
7
|
let postcss = require("postcss");
|
|
8
8
|
postcss = require_chunk.__toESM(postcss);
|
|
@@ -17,6 +17,7 @@ const TAILWIND_GENERATED_CSS_MARKER_RE = /\/\*!\s*tailwindcss v|@property\s+--tw
|
|
|
17
17
|
const GENERATOR_PLACEHOLDER_MARKER_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\//i;
|
|
18
18
|
const GENERATOR_PLACEHOLDER_MARKER_GLOBAL_RE = /\/\*!\s*weapp-tailwindcss generator-placeholder\s*\*\/\s*/gi;
|
|
19
19
|
const TAILWIND_BANNER_PREFIX_RE = /^\/\*!\s*tailwindcss v[^*]*\*\/\s*/i;
|
|
20
|
+
const TAILWIND_BANNER_RE = /\/\*!\s*tailwindcss v[^*]*\*\//i;
|
|
20
21
|
const TAILWIND_BANNER_GLOBAL_RE = /\/\*!\s*tailwindcss v[^*]*\*\/\s*/gi;
|
|
21
22
|
const VITE_MARKER_RE = /\/\*\$vite\$:[^*]*\*\//g;
|
|
22
23
|
function createCssAppend(base, extra) {
|
|
@@ -24,14 +25,45 @@ function createCssAppend(base, extra) {
|
|
|
24
25
|
if (!extra) return base;
|
|
25
26
|
return `${base}\n${extra}`;
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
+
function splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss) {
|
|
28
29
|
const trimmedRaw = rawSource.trim();
|
|
29
30
|
const trimmedTailwind = rawTailwindCss.trim();
|
|
30
|
-
if (trimmedRaw === trimmedTailwind) return
|
|
31
|
-
|
|
31
|
+
if (trimmedRaw === trimmedTailwind) return {
|
|
32
|
+
before: "",
|
|
33
|
+
after: ""
|
|
34
|
+
};
|
|
35
|
+
if (trimmedTailwind.startsWith(trimmedRaw)) return {
|
|
36
|
+
before: "",
|
|
37
|
+
after: ""
|
|
38
|
+
};
|
|
32
39
|
const start = rawSource.indexOf(rawTailwindCss);
|
|
33
40
|
if (start === -1) return;
|
|
34
|
-
return
|
|
41
|
+
return {
|
|
42
|
+
before: rawSource.slice(0, start),
|
|
43
|
+
after: rawSource.slice(start + rawTailwindCss.length)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss) {
|
|
47
|
+
const match = GENERATOR_PLACEHOLDER_MARKER_RE.exec(rawSource);
|
|
48
|
+
if (!match || match.index === void 0) return;
|
|
49
|
+
let afterStart = match.index + match[0].length;
|
|
50
|
+
while (/\s/.test(rawSource[afterStart] ?? "")) afterStart++;
|
|
51
|
+
if (rawTailwindCss && rawSource.slice(afterStart).startsWith(rawTailwindCss)) {
|
|
52
|
+
afterStart += rawTailwindCss.length;
|
|
53
|
+
while (/\s/.test(rawSource[afterStart] ?? "")) afterStart++;
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
before: rawSource.slice(0, match.index),
|
|
57
|
+
after: rawSource.slice(afterStart)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function splitTailwindGeneratedCssByBanner(rawSource, start) {
|
|
61
|
+
const match = start === void 0 ? TAILWIND_BANNER_RE.exec(rawSource) : { index: start };
|
|
62
|
+
if (!match || match.index === void 0) return;
|
|
63
|
+
return {
|
|
64
|
+
before: rawSource.slice(0, match.index),
|
|
65
|
+
after: [...rawSource.slice(match.index).matchAll(VITE_MARKER_RE)].map((item) => item[0]).join("\n")
|
|
66
|
+
};
|
|
35
67
|
}
|
|
36
68
|
function stripTailwindBanner(css) {
|
|
37
69
|
return css.replace(TAILWIND_BANNER_PREFIX_RE, "");
|
|
@@ -75,6 +107,7 @@ const TAILWIND_ROOT_DIRECTIVE_NAMES = new Set([
|
|
|
75
107
|
const TAILWIND_ROOT_DIRECTIVE_RE = /@(?:import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/[^"')\s]*)?|tailwind|config|custom-variant|plugin|source|theme|utility|variant)\b/;
|
|
76
108
|
const TAILWIND_EXTRACTABLE_DIRECTIVE_RE = /^\s*@(?:import|tailwind|config|source|reference|plugin)\b[\s\S]*?(?:;|$)/;
|
|
77
109
|
const TAILWIND_EXTRACTABLE_BLOCK_DIRECTIVE_RE = /^\s*@(?:theme|utility|variant|custom-variant)\b[\s\S]*$/;
|
|
110
|
+
const TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE = /^\s*@layer\s[^;{]+;\s*$/;
|
|
78
111
|
function parseImportRequest(params) {
|
|
79
112
|
return /^(?:url\(\s*)?(["']?)([^"')\s]+)\1\s*\)?/.exec(params.trim())?.[2];
|
|
80
113
|
}
|
|
@@ -131,7 +164,7 @@ function extractTailwindDirectiveLines(rawSource, options = {}) {
|
|
|
131
164
|
for (const line of stripGeneratorPlaceholderMarkers(rawSource).split(/\r?\n/)) {
|
|
132
165
|
const trimmed = line.trim();
|
|
133
166
|
if (!trimmed || trimmed.startsWith("//")) continue;
|
|
134
|
-
const directive = TAILWIND_EXTRACTABLE_DIRECTIVE_RE.exec(line)?.[0] ?? TAILWIND_EXTRACTABLE_BLOCK_DIRECTIVE_RE.exec(line)?.[0];
|
|
167
|
+
const directive = TAILWIND_EXTRACTABLE_DIRECTIVE_RE.exec(line)?.[0] ?? TAILWIND_EXTRACTABLE_BLOCK_DIRECTIVE_RE.exec(line)?.[0] ?? TAILWIND_EXTRACTABLE_LAYER_STATEMENT_RE.exec(line)?.[0];
|
|
135
168
|
if (!directive) continue;
|
|
136
169
|
const normalized = normalizeTailwindDirectiveLine(directive.trimEnd(), options);
|
|
137
170
|
const normalizedTrimmed = normalized.trim();
|
|
@@ -1456,6 +1489,57 @@ function createStableJson(value) {
|
|
|
1456
1489
|
function createLegacyCompatTransformCacheKey(source, options) {
|
|
1457
1490
|
return `${createStableJson(options)}\0${source}`;
|
|
1458
1491
|
}
|
|
1492
|
+
function countUnclosedBlocks(source) {
|
|
1493
|
+
let depth = 0;
|
|
1494
|
+
let quote;
|
|
1495
|
+
let inComment = false;
|
|
1496
|
+
let escaped = false;
|
|
1497
|
+
for (let index = 0; index < source.length; index += 1) {
|
|
1498
|
+
const char = source[index];
|
|
1499
|
+
const next = source[index + 1];
|
|
1500
|
+
if (inComment) {
|
|
1501
|
+
if (char === "*" && next === "/") {
|
|
1502
|
+
inComment = false;
|
|
1503
|
+
index += 1;
|
|
1504
|
+
}
|
|
1505
|
+
continue;
|
|
1506
|
+
}
|
|
1507
|
+
if (quote) {
|
|
1508
|
+
if (escaped) {
|
|
1509
|
+
escaped = false;
|
|
1510
|
+
continue;
|
|
1511
|
+
}
|
|
1512
|
+
if (char === "\\") {
|
|
1513
|
+
escaped = true;
|
|
1514
|
+
continue;
|
|
1515
|
+
}
|
|
1516
|
+
if (char === quote) quote = void 0;
|
|
1517
|
+
continue;
|
|
1518
|
+
}
|
|
1519
|
+
if (char === "/" && next === "*") {
|
|
1520
|
+
inComment = true;
|
|
1521
|
+
index += 1;
|
|
1522
|
+
continue;
|
|
1523
|
+
}
|
|
1524
|
+
if (char === "\"" || char === "'") {
|
|
1525
|
+
quote = char;
|
|
1526
|
+
continue;
|
|
1527
|
+
}
|
|
1528
|
+
if (char === "{") depth += 1;
|
|
1529
|
+
else if (char === "}" && depth > 0) depth -= 1;
|
|
1530
|
+
}
|
|
1531
|
+
return depth;
|
|
1532
|
+
}
|
|
1533
|
+
function closeTrailingUnclosedBlocks(source) {
|
|
1534
|
+
try {
|
|
1535
|
+
postcss.default.parse(source);
|
|
1536
|
+
return source;
|
|
1537
|
+
} catch (error) {
|
|
1538
|
+
if (error.reason !== "Unclosed block") return source;
|
|
1539
|
+
const unclosedBlocks = countUnclosedBlocks(source);
|
|
1540
|
+
return unclosedBlocks > 0 ? `${source}${"}".repeat(unclosedBlocks)}` : source;
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1459
1543
|
function removeTailwindApplyRules(rawSource) {
|
|
1460
1544
|
try {
|
|
1461
1545
|
const root = postcss.default.parse(rawSource);
|
|
@@ -1477,7 +1561,7 @@ function removeTailwindApplyRules(rawSource) {
|
|
|
1477
1561
|
function resolveLegacyCompatCssSource(rawSource) {
|
|
1478
1562
|
const cached = legacyCompatSourceCache.get(rawSource);
|
|
1479
1563
|
if (cached !== void 0) return cached;
|
|
1480
|
-
const resolved = removeUnsupportedMiniProgramAtRules(removeTailwindApplyRules(removeTailwindSourceDirectives(stripTailwindBanners(rawSource))));
|
|
1564
|
+
const resolved = closeTrailingUnclosedBlocks(removeUnsupportedMiniProgramAtRules(removeTailwindApplyRules(removeTailwindSourceDirectives(closeTrailingUnclosedBlocks(stripTailwindBanners(rawSource))))));
|
|
1481
1565
|
setLimitedCacheValue(legacyCompatSourceCache, rawSource, resolved);
|
|
1482
1566
|
return resolved;
|
|
1483
1567
|
}
|
|
@@ -1635,6 +1719,55 @@ function resolveGeneratorStyleOptions(opts, cssHandlerOptions, generatorStyleOpt
|
|
|
1635
1719
|
function isLocalImportRequest(request) {
|
|
1636
1720
|
return request.length > 0 && !request.startsWith("tailwindcss") && !request.startsWith("weapp-tailwindcss") && !request.startsWith("data:") && !REMOTE_IMPORT_RE.test(request);
|
|
1637
1721
|
}
|
|
1722
|
+
function isCommentOnlyCss(source) {
|
|
1723
|
+
try {
|
|
1724
|
+
const root = postcss.default.parse(source);
|
|
1725
|
+
return root.nodes.length > 0 && root.nodes.every((node) => node.type === "comment");
|
|
1726
|
+
} catch {
|
|
1727
|
+
return false;
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
function stripTailwindSourceMediaFragments(source) {
|
|
1731
|
+
return source.replace(/^\s*@media\s+source\([^)]*\)\s*\{\s*$/gm, "").replace(/^\s*\}\s*(?=@(?:source|theme|config|plugin|utility|variant|custom-variant)\b)/gm, "").replace(/^\s*\}\s*\/\*\s*source\([^)]*\)\s*\*\/\s*$/gm, "");
|
|
1732
|
+
}
|
|
1733
|
+
function stripLeadingTailwindSourceMediaCloseFragment(source) {
|
|
1734
|
+
return source.replace(/^\s*\}\s*(?:\n|$)/, "");
|
|
1735
|
+
}
|
|
1736
|
+
function stripUnmatchedTailwindSourceMediaCloseFragments(source) {
|
|
1737
|
+
try {
|
|
1738
|
+
postcss.default.parse(source);
|
|
1739
|
+
return source;
|
|
1740
|
+
} catch {
|
|
1741
|
+
return stripLeadingTailwindSourceMediaCloseFragment(source).replace(/\s*\}\s*$/, "");
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
function createCssSourceOrderAppend(base, extra) {
|
|
1745
|
+
if (!base) return extra;
|
|
1746
|
+
if (!extra) return base;
|
|
1747
|
+
if (/\s$/.test(base) || /^\s/.test(extra)) return `${base}${extra}`;
|
|
1748
|
+
return `${base}\n${extra}`;
|
|
1749
|
+
}
|
|
1750
|
+
function splitRawSourceByGeneratedCssOrder(rawSource, rawTailwindCss) {
|
|
1751
|
+
const placeholderParts = splitGeneratorPlaceholderCssBySourceOrder(rawSource, rawTailwindCss);
|
|
1752
|
+
if (placeholderParts) return placeholderParts;
|
|
1753
|
+
const exactParts = splitTailwindV4GeneratedCssBySourceOrder(rawSource, rawTailwindCss);
|
|
1754
|
+
if (exactParts) return exactParts;
|
|
1755
|
+
return splitTailwindGeneratedCssByBanner(rawSource);
|
|
1756
|
+
}
|
|
1757
|
+
async function transformGeneratorUserCss(source, options) {
|
|
1758
|
+
if (source.trim().length === 0) return "";
|
|
1759
|
+
const cleanedSource = removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(source)), { importFallback: options.importFallback });
|
|
1760
|
+
if (cleanedSource.trim().length === 0) return "";
|
|
1761
|
+
const userSource = stripUnmatchedTailwindSourceMediaCloseFragments(removeTailwindSourceDirectives(stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(options.generatorTarget === "weapp" ? removeUnsupportedMiniProgramAtRules(cleanedSource) : cleanedSource)), { importFallback: options.importFallback }));
|
|
1762
|
+
if (userSource.trim().length === 0) return "";
|
|
1763
|
+
if (isCommentOnlyCss(userSource)) return userSource;
|
|
1764
|
+
if (options.generatorTarget !== "weapp") return userSource;
|
|
1765
|
+
const { css } = await options.styleHandler(userSource, {
|
|
1766
|
+
...options.generatorStyleOptions,
|
|
1767
|
+
...options.cssUserHandlerOptions
|
|
1768
|
+
});
|
|
1769
|
+
return removeUnsupportedMiniProgramAtRules(css);
|
|
1770
|
+
}
|
|
1638
1771
|
function isPureLocalCssImportWrapper(css) {
|
|
1639
1772
|
let hasImport = false;
|
|
1640
1773
|
try {
|
|
@@ -1691,7 +1824,7 @@ async function generateCssByGenerator(options) {
|
|
|
1691
1824
|
const { opts, runtimeState, runtime, rawSource, file, cssHandlerOptions, cssUserHandlerOptions, getSourceCandidatesForEntries, styleHandler, debug } = options;
|
|
1692
1825
|
const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(opts.generator);
|
|
1693
1826
|
const majorVersion = runtimeState.twPatcher.majorVersion;
|
|
1694
|
-
const effectiveRawSource = normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback });
|
|
1827
|
+
const effectiveRawSource = stripUnmatchedTailwindSourceMediaCloseFragments(stripTailwindSourceMediaFragments(normalizeTailwindSourceDirectives(rawSource, { importFallback: generatorOptions.importFallback })));
|
|
1695
1828
|
const cleanedLocalImportWrapper = cleanLocalCssImportWrapperTailwindDirectives(effectiveRawSource);
|
|
1696
1829
|
if (cleanedLocalImportWrapper !== void 0) return {
|
|
1697
1830
|
css: generatorOptions.target === "weapp" ? removeUnsupportedMiniProgramAtRules(cleanedLocalImportWrapper) : cleanedLocalImportWrapper,
|
|
@@ -1756,29 +1889,21 @@ async function generateCssByGenerator(options) {
|
|
|
1756
1889
|
incremental: true
|
|
1757
1890
|
};
|
|
1758
1891
|
}
|
|
1759
|
-
const
|
|
1760
|
-
|
|
1892
|
+
const hasMatchedCssSourceFile = sources.some((source) => source.__weappTailwindcssMeta?.matchedCssSourceFile);
|
|
1893
|
+
const orderedExtraCss = hasMatchedCssSourceFile ? splitTailwindV4GeneratedCssBySourceOrder(effectiveRawSource, generated.rawCss) : splitRawSourceByGeneratedCssOrder(effectiveRawSource, generated.rawCss);
|
|
1894
|
+
if (orderedExtraCss) {
|
|
1761
1895
|
let css = stripTailwindBanner(generated.css);
|
|
1762
1896
|
if (generated.target === "weapp") css = inheritLegacyUnitConvertedDeclarations(css, effectiveRawSource);
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
if (generated.target === "weapp") {
|
|
1774
|
-
const { css: userCss } = await styleHandler(extraSource, {
|
|
1775
|
-
...generatorStyleOptions,
|
|
1776
|
-
...cssUserHandlerOptions
|
|
1777
|
-
});
|
|
1778
|
-
css = createCssAppend(css, removeUnsupportedMiniProgramAtRules(userCss));
|
|
1779
|
-
} else css = createCssAppend(css, extraSource);
|
|
1780
|
-
}
|
|
1781
|
-
}
|
|
1897
|
+
const userCssOptions = {
|
|
1898
|
+
generatorTarget: generated.target,
|
|
1899
|
+
generatorStyleOptions,
|
|
1900
|
+
cssUserHandlerOptions,
|
|
1901
|
+
styleHandler,
|
|
1902
|
+
importFallback: generatorOptions.importFallback
|
|
1903
|
+
};
|
|
1904
|
+
const beforeUserCss = await transformGeneratorUserCss(orderedExtraCss.before, userCssOptions);
|
|
1905
|
+
const afterUserCss = await transformGeneratorUserCss(orderedExtraCss.after, userCssOptions);
|
|
1906
|
+
css = createCssSourceOrderAppend(createCssSourceOrderAppend(beforeUserCss, css), afterUserCss);
|
|
1782
1907
|
if (generated.target === "weapp") {
|
|
1783
1908
|
css = await appendLegacyCompatCss(css, effectiveRawSource, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
|
|
1784
1909
|
css = await appendLegacyContainerCompatCss(css, effectiveRawSource, file, runtime, configuredContainerCompat, generated.target, styleHandler, cssHandlerOptions, generatorStyleOptions);
|
|
@@ -1793,7 +1918,7 @@ async function generateCssByGenerator(options) {
|
|
|
1793
1918
|
debug("tailwind direct css generation prefix mismatch, append transformed bundle css %s", file);
|
|
1794
1919
|
let css = stripTailwindBanner(generated.css);
|
|
1795
1920
|
if (generated.target === "weapp") css = inheritLegacyUnitConvertedDeclarations(css, effectiveRawSource);
|
|
1796
|
-
if (
|
|
1921
|
+
if (hasMatchedCssSourceFile || generated.target === "web") return {
|
|
1797
1922
|
css: finalizeMiniProgramGeneratorCss(css, generated.target, majorVersion, opts.cssPreflight),
|
|
1798
1923
|
target: generated.target,
|
|
1799
1924
|
source: "generator",
|