weapp-tailwindcss 5.0.0-next.9 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/auto-DEHRmEAx.mjs +200 -0
- package/dist/auto-dPpsm6FB.js +238 -0
- package/dist/bundle-state-CBF5YX1m.js +529 -0
- package/dist/bundle-state-CQmxxx0R.mjs +413 -0
- package/dist/bundlers/shared/cache.d.ts +9 -7
- package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +1 -2
- package/dist/bundlers/shared/css-cleanup.d.ts +1 -3
- package/dist/bundlers/shared/css-imports.d.ts +3 -3
- package/dist/bundlers/shared/generated-css-marker.d.ts +3 -0
- package/dist/bundlers/shared/generator-css/directives.d.ts +11 -3
- package/dist/bundlers/shared/generator-css/markers.d.ts +12 -0
- package/dist/bundlers/shared/generator-css/source-files.d.ts +9 -6
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +16 -2
- package/dist/bundlers/shared/generator-css/user-layer-order.d.ts +10 -0
- package/dist/bundlers/shared/generator-css.d.ts +6 -2
- package/dist/bundlers/shared/hmr-timing.d.ts +22 -0
- package/dist/bundlers/shared/style-requests.d.ts +2 -0
- package/dist/bundlers/vite/bundle-state.d.ts +1 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +6 -0
- package/dist/bundlers/vite/generate-bundle/candidates.d.ts +1 -1
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -1
- package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +13 -1
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +10 -2
- package/dist/bundlers/vite/index.d.ts +5 -2
- package/dist/bundlers/vite/processed-css-assets.d.ts +32 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +8 -5
- package/dist/bundlers/vite/runtime-class-set.d.ts +5 -1
- package/dist/bundlers/vite/serve-css-generation.d.ts +11 -0
- package/dist/bundlers/vite/source-candidates.d.ts +24 -2
- package/dist/bundlers/vite/source-scan.d.ts +26 -0
- package/dist/bundlers/vite/static-config-content.d.ts +5 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +5 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +5 -1
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +8 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -1
- package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +31 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +2 -8
- package/dist/bundlers/webpack/loaders/weapp-tw-runtime-classset-loader.d.ts +3 -7
- package/dist/cache/index.d.ts +6 -6
- package/dist/{chunk-8l464Juk.js → chunk-C5U5_Hdc.js} +14 -0
- package/dist/cli/context.d.ts +1 -11
- package/dist/cli/doctor/types.d.ts +11 -11
- package/dist/cli/vscode-entry.d.ts +3 -3
- package/dist/cli.js +684 -41
- package/dist/cli.mjs +682 -40
- package/dist/context/runtime-package-replacements.d.ts +2 -0
- package/dist/context/style-options.d.ts +3 -0
- package/dist/context/tailwindcss.d.ts +1 -1
- package/dist/core.js +1 -2
- package/dist/core.mjs +1 -1
- package/dist/css-macro/auto.d.ts +11 -0
- package/dist/css-macro/constants.d.ts +5 -2
- package/dist/css-macro/postcss.d.ts +1 -0
- package/dist/css-macro/postcss.js +7 -46
- package/dist/css-macro/postcss.mjs +2 -46
- package/dist/css-macro.js +16 -7
- package/dist/css-macro.mjs +15 -6
- package/dist/defaults-8xrgzxFY.mjs +151 -0
- package/dist/defaults-zKUH2mDe.js +193 -0
- package/dist/defaults.js +6 -150
- package/dist/defaults.mjs +1 -143
- package/dist/escape.js +10 -2
- package/dist/escape.mjs +10 -2
- package/dist/generator/options.d.ts +11 -6
- package/dist/generator/types.d.ts +3 -3
- package/dist/generator-CvmsIQFI.js +92 -0
- package/dist/generator-DDtsUvkH.mjs +67 -0
- package/dist/generator.js +12 -12
- package/dist/generator.mjs +2 -1
- package/dist/gulp.js +163 -40
- package/dist/gulp.mjs +155 -32
- package/dist/incremental-runtime-class-set-BffodqHh.js +2366 -0
- package/dist/incremental-runtime-class-set-DArodvWs.mjs +2291 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +17 -5
- package/dist/index.mjs +6 -5
- package/dist/js/babel/cache-options.d.ts +3 -0
- package/dist/js/babel/parse.d.ts +7 -4
- package/dist/js/precheck.d.ts +2 -2
- package/dist/js/replacement-cache.d.ts +5 -0
- package/dist/{postcss-w48mGIhe.mjs → postcss-BzNYQUOH.mjs} +54 -114
- package/dist/postcss-C7BMYpEF.mjs +169 -0
- package/dist/postcss-CiYLsqZn.js +192 -0
- package/dist/{postcss-QIXwT40c.js → postcss-DE0TOtV9.js} +60 -121
- package/dist/postcss-html-transform.js +1 -1
- package/dist/postcss.js +1 -1
- package/dist/postcss.mjs +1 -1
- package/dist/precheck-BzYPm-EG.js +4842 -0
- package/dist/precheck-jZvTVXXG.mjs +4716 -0
- package/dist/presets/index.d.ts +1 -0
- package/dist/presets/uni-app-x.d.ts +1 -0
- package/dist/presets.js +27 -13
- package/dist/presets.mjs +25 -13
- package/dist/reset.js +1 -1
- package/dist/runtime-registry-DpcR3IHI.js +5496 -0
- package/dist/shared/mpx.d.ts +1 -0
- package/dist/source-candidates-BuTlMabx.mjs +322 -0
- package/dist/source-candidates-CxoIaS88.js +335 -0
- package/dist/tailwindcss/miniprogram.d.ts +1 -5
- package/dist/tailwindcss/remove-unsupported-css.d.ts +1 -2
- package/dist/tailwindcss/runtime/cache.d.ts +4 -3
- package/dist/tailwindcss/runtime.d.ts +9 -9
- package/dist/tailwindcss/source-scan.d.ts +35 -0
- package/dist/tailwindcss/v3-engine/types.d.ts +19 -14
- package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
- package/dist/tailwindcss/v4/patcher.d.ts +1 -1
- package/dist/tailwindcss/v4-engine/source.d.ts +2 -2
- package/dist/tailwindcss/v4-engine/types.d.ts +18 -5
- package/dist/{tailwindcss-C5IgPlQ0.mjs → tailwindcss-CCZcu0lr.mjs} +75 -98
- package/dist/{tailwindcss-Bu-RWIHx.js → tailwindcss-DZckITp1.js} +83 -106
- package/dist/typedoc.export.d.ts +1 -1
- package/dist/types/index.d.ts +51 -41
- package/dist/types/shared.d.ts +3 -0
- package/dist/types/typedoc-tailwindcss-patch.d.ts +67 -0
- package/dist/types/user-defined-options/general.d.ts +25 -22
- package/dist/types/user-defined-options/important.d.ts +32 -27
- package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
- package/dist/types/user-defined-options/matcher.d.ts +6 -6
- package/dist/unocss/index.d.ts +2 -0
- package/dist/utils/object.d.ts +9 -0
- package/dist/utils/options.d.ts +2 -0
- package/dist/utils/regex.d.ts +1 -0
- package/dist/{utils-BiShvil9.js → utils-D7Ygohep.js} +2 -2
- package/dist/{utils-Btw1iOVV.mjs → utils-DsaS975I.mjs} +1 -1
- package/dist/v3-engine-DGBhUnjn.mjs +3419 -0
- package/dist/v3-engine-M6Aqru5T.js +3714 -0
- package/dist/vite-BBcQIJpD.mjs +24493 -0
- package/dist/vite-DgRkWVPG.js +24507 -0
- package/dist/vite.js +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/weapp-tw-css-import-rewrite-loader.js +5456 -22
- package/dist/weapp-tw-runtime-classset-loader.js +32 -9
- package/dist/{webpack-BzN2ly34.js → webpack-D-gb4ZvO.js} +341 -96
- package/dist/{webpack-DJazm5sT.mjs → webpack-D43aMQzO.mjs} +323 -79
- package/dist/webpack.d.ts +1 -3
- package/dist/webpack.js +3 -4
- package/dist/webpack.mjs +2 -2
- package/dist/wxml/utils/codegen/legacy-visitor.d.ts +2 -4
- package/package.json +22 -20
- package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +0 -3
- package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +0 -4
- package/dist/bundlers/shared/css-cleanup/selectors.d.ts +0 -8
- package/dist/cache-BVAiJV3J.js +0 -502
- package/dist/cache-CHs4DXui.mjs +0 -434
- package/dist/constants-BoB_6lFw.js +0 -73
- package/dist/constants-E_loJC49.mjs +0 -44
- package/dist/generator-DKkhJbOg.js +0 -1531
- package/dist/generator-UBmfduYg.mjs +0 -1432
- package/dist/generator-css-Bwp3nbrl.js +0 -1381
- package/dist/generator-css-DeLLmp2N.mjs +0 -1342
- package/dist/lightningcss/index.d.ts +0 -8
- package/dist/lightningcss/style-handler/options.d.ts +0 -3
- package/dist/lightningcss/style-handler/selector-transform.d.ts +0 -10
- package/dist/lightningcss/style-handler/selector-utils.d.ts +0 -10
- package/dist/lightningcss/style-handler.d.ts +0 -17
- package/dist/precheck-B32p-gLI.js +0 -2736
- package/dist/precheck-B4RH6ZNN.mjs +0 -2622
- package/dist/run-tasks-B50A3pxt.js +0 -128
- package/dist/run-tasks-DdNi-hkk.mjs +0 -91
- package/dist/runtime-patch-CwN5ya72.mjs +0 -71
- package/dist/runtime-patch-D6mBo_KB.js +0 -85
- package/dist/vite-By5KQi9s.js +0 -2419
- package/dist/vite-Cyp42bBf.mjs +0 -2406
- /package/dist/{logger-Bub1jggA.mjs → logger-BNzxZbZj.mjs} +0 -0
- /package/dist/{logger-BRy6XPQ2.js → logger-TlKT3xmR.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export { weappTailwindcssPostcssPlugin } from './postcss';
|
|
|
5
5
|
export type { WeappTailwindcssPostcssPluginOptions } from './postcss';
|
|
6
6
|
export type * from './types';
|
|
7
7
|
export { WeappTailwindcss } from './vite';
|
|
8
|
-
export {
|
|
8
|
+
export { weappTailwindcssPackageDir } from './webpack';
|
|
9
|
+
export { unitConversionComposeRules, unitConversionPresets, } from '@weapp-tailwindcss/postcss';
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_generator = require("./generator-
|
|
2
|
+
const require_generator = require("./generator-CvmsIQFI.js");
|
|
3
3
|
const require_gulp = require("./gulp.js");
|
|
4
|
-
const require_postcss = require("./postcss-
|
|
5
|
-
const require_vite = require("./vite-
|
|
6
|
-
const require_webpack = require("./webpack-
|
|
7
|
-
|
|
4
|
+
const require_postcss = require("./postcss-DE0TOtV9.js");
|
|
5
|
+
const require_vite = require("./vite-DgRkWVPG.js");
|
|
6
|
+
const require_webpack = require("./webpack-D-gb4ZvO.js");
|
|
7
|
+
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
|
|
8
8
|
exports.WeappTailwindcss = require_vite.WeappTailwindcss;
|
|
9
9
|
exports.createPlugins = require_gulp.createPlugins;
|
|
10
10
|
exports.createWeappTailwindcssGenerator = require_generator.createWeappTailwindcssGenerator;
|
|
11
|
+
Object.defineProperty(exports, "unitConversionComposeRules", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function() {
|
|
14
|
+
return _weapp_tailwindcss_postcss.unitConversionComposeRules;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "unitConversionPresets", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return _weapp_tailwindcss_postcss.unitConversionPresets;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
11
23
|
exports.weappTailwindcssPackageDir = require_webpack.weappTailwindcssPackageDir;
|
|
12
24
|
exports.weappTailwindcssPostcssPlugin = require_postcss.weappTailwindcssPostcssPlugin;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { t as createWeappTailwindcssGenerator } from "./generator-
|
|
1
|
+
import { t as createWeappTailwindcssGenerator } from "./generator-DDtsUvkH.mjs";
|
|
2
2
|
import { WeappTailwindcss as createPlugins } from "./gulp.mjs";
|
|
3
|
-
import { t as weappTailwindcssPostcssPlugin } from "./postcss-
|
|
4
|
-
import { t as WeappTailwindcss } from "./vite-
|
|
5
|
-
import { n as weappTailwindcssPackageDir
|
|
6
|
-
|
|
3
|
+
import { t as weappTailwindcssPostcssPlugin } from "./postcss-BzNYQUOH.mjs";
|
|
4
|
+
import { t as WeappTailwindcss } from "./vite-BBcQIJpD.mjs";
|
|
5
|
+
import { n as weappTailwindcssPackageDir } from "./webpack-D43aMQzO.mjs";
|
|
6
|
+
import { unitConversionComposeRules, unitConversionPresets } from "@weapp-tailwindcss/postcss";
|
|
7
|
+
export { WeappTailwindcss, createPlugins, createWeappTailwindcssGenerator, unitConversionComposeRules, unitConversionPresets, weappTailwindcssPackageDir, weappTailwindcssPostcssPlugin };
|
package/dist/js/babel/parse.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { ParseResult, ParserOptions } from '@babel/parser';
|
|
2
2
|
import type { File } from '@babel/types';
|
|
3
3
|
import { LRUCache } from 'lru-cache';
|
|
4
|
+
export type BabelParseOptions = ParserOptions & {
|
|
5
|
+
cache?: boolean | undefined;
|
|
6
|
+
cacheKey?: string | undefined;
|
|
7
|
+
cacheMaxEntries?: number | undefined;
|
|
8
|
+
cacheMaxSourceLength?: number | undefined;
|
|
9
|
+
};
|
|
4
10
|
export declare const parseCache: LRUCache<string, ParseResult<File>>;
|
|
5
11
|
export declare function genCacheKey(source: string, options: any): string;
|
|
6
|
-
export declare function babelParse(code: string, opts?:
|
|
7
|
-
cache?: boolean;
|
|
8
|
-
cacheKey?: string;
|
|
9
|
-
})): ParseResult<File>;
|
|
12
|
+
export declare function babelParse(code: string, opts?: BabelParseOptions): ParseResult<File>;
|
package/dist/js/precheck.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function shouldSkipJsTransform(rawSource: string, options?:
|
|
1
|
+
import type { IJsHandlerOptions } from '../types';
|
|
2
|
+
export declare function shouldSkipJsTransform(rawSource: string, options?: IJsHandlerOptions): boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IJsHandlerOptions } from '../types';
|
|
2
|
+
type EscapeMap = NonNullable<IJsHandlerOptions['escapeMap']>;
|
|
3
|
+
export declare function getReplacementCacheStore(escapeMap?: EscapeMap): Map<string, string>;
|
|
4
|
+
export declare function getReplacement(candidate: string, escapeMap: EscapeMap | undefined, store?: Map<string, string>): string;
|
|
5
|
+
export {};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { A as collectCssInlineSourceCandidates, F as parseConfigParam, H as readInstalledPackageMajorVersion, I as resolveCssSourceEntries, M as expandTailwindSourceEntries, O as DEFAULT_SOURCE_SCAN_EXTENSIONS, P as normalizeLegacyContentEntries, j as createSourceScanPattern, t as resolveTailwindV3Source, y as resolveTailwindV4Source$1 } from "./v3-engine-DGBhUnjn.mjs";
|
|
2
|
+
import { i as normalizeWeappTailwindcssGeneratorOptions, t as createWeappTailwindcssGenerator } from "./generator-DDtsUvkH.mjs";
|
|
3
3
|
import postcss from "postcss";
|
|
4
|
-
import
|
|
4
|
+
import { extractRawCandidatesWithPositions, extractValidCandidates } from "tailwindcss-patch";
|
|
5
5
|
import process from "node:process";
|
|
6
|
-
import
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { readFile } from "node:fs/promises";
|
|
7
8
|
import { loadConfig } from "tailwindcss-config";
|
|
8
|
-
import { readFile, stat } from "node:fs/promises";
|
|
9
|
-
import fg from "fast-glob";
|
|
10
9
|
//#region src/postcss/config-directive.ts
|
|
11
10
|
function quoteCssString(value) {
|
|
12
11
|
return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
|
|
@@ -61,85 +60,10 @@ function addSourceDependencyMessages(result, files) {
|
|
|
61
60
|
}
|
|
62
61
|
//#endregion
|
|
63
62
|
//#region src/postcss/source-files.ts
|
|
64
|
-
const POSTCSS_SOURCE_PATTERN =
|
|
65
|
-
"html",
|
|
66
|
-
"wxml",
|
|
67
|
-
"axml",
|
|
68
|
-
"jxml",
|
|
69
|
-
"ksml",
|
|
70
|
-
"ttml",
|
|
71
|
-
"qml",
|
|
72
|
-
"tyml",
|
|
73
|
-
"xhsml",
|
|
74
|
-
"swan",
|
|
75
|
-
"vue",
|
|
76
|
-
"mpx",
|
|
77
|
-
"js",
|
|
78
|
-
"jsx",
|
|
79
|
-
"ts",
|
|
80
|
-
"tsx"
|
|
81
|
-
].join(",")}}`;
|
|
82
|
-
function parseLocalSourceParam(params) {
|
|
83
|
-
const value = params.trim();
|
|
84
|
-
if (!value || value === "none" || value.startsWith("not ") || value.startsWith("inline(")) return;
|
|
85
|
-
return /^(['"])(.+)\1$/.exec(value)?.[2];
|
|
86
|
-
}
|
|
87
|
-
function parseConfigParam(params) {
|
|
88
|
-
const value = params.trim();
|
|
89
|
-
return /^(['"])(.+)\1$/.exec(value)?.[2];
|
|
90
|
-
}
|
|
91
|
-
function parseSourceFileParam(params) {
|
|
92
|
-
const value = params.trim();
|
|
93
|
-
if (!value || value === "none" || value.startsWith("inline(")) return;
|
|
94
|
-
const negated = value.startsWith("not ");
|
|
95
|
-
const sourceValue = negated ? value.slice(4).trim() : value;
|
|
96
|
-
const match = /^(['"])(.+)\1$/.exec(sourceValue);
|
|
97
|
-
return match?.[2] ? {
|
|
98
|
-
negated,
|
|
99
|
-
sourcePath: match[2]
|
|
100
|
-
} : void 0;
|
|
101
|
-
}
|
|
63
|
+
const POSTCSS_SOURCE_PATTERN = createSourceScanPattern(DEFAULT_SOURCE_SCAN_EXTENSIONS);
|
|
102
64
|
function getSourceExtension(file) {
|
|
103
65
|
return path.extname(file).slice(1) || void 0;
|
|
104
66
|
}
|
|
105
|
-
async function pathExistsAsDirectory(file) {
|
|
106
|
-
try {
|
|
107
|
-
return (await stat(file)).isDirectory();
|
|
108
|
-
} catch {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
async function expandLocalSourceFiles(sourcePath, base) {
|
|
113
|
-
const absoluteSource = path.isAbsolute(sourcePath) ? sourcePath : path.resolve(base, sourcePath);
|
|
114
|
-
if (await pathExistsAsDirectory(absoluteSource)) return fg(POSTCSS_SOURCE_PATTERN, {
|
|
115
|
-
absolute: true,
|
|
116
|
-
cwd: absoluteSource,
|
|
117
|
-
onlyFiles: true
|
|
118
|
-
});
|
|
119
|
-
return fg(sourcePath, {
|
|
120
|
-
absolute: true,
|
|
121
|
-
cwd: base,
|
|
122
|
-
onlyFiles: true
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
async function resolveTailwindSourceEntry(sourcePath, base, negated) {
|
|
126
|
-
const absoluteSource = path.isAbsolute(sourcePath) ? path.resolve(sourcePath) : path.resolve(base, sourcePath);
|
|
127
|
-
if (await pathExistsAsDirectory(absoluteSource)) return {
|
|
128
|
-
base: absoluteSource,
|
|
129
|
-
negated,
|
|
130
|
-
pattern: POSTCSS_SOURCE_PATTERN
|
|
131
|
-
};
|
|
132
|
-
if (path.isAbsolute(sourcePath)) return {
|
|
133
|
-
base: path.dirname(absoluteSource),
|
|
134
|
-
negated,
|
|
135
|
-
pattern: path.basename(absoluteSource)
|
|
136
|
-
};
|
|
137
|
-
return {
|
|
138
|
-
base,
|
|
139
|
-
negated,
|
|
140
|
-
pattern: sourcePath
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
67
|
function collectConfigPaths(root, base) {
|
|
144
68
|
const configPaths = [];
|
|
145
69
|
root.walkAtRules("config", (rule) => {
|
|
@@ -148,65 +72,81 @@ function collectConfigPaths(root, base) {
|
|
|
148
72
|
});
|
|
149
73
|
return [...new Set(configPaths)];
|
|
150
74
|
}
|
|
151
|
-
function
|
|
152
|
-
if (
|
|
153
|
-
|
|
154
|
-
if (typeof content === "object" && content !== null && "files" in content) return normalizeContentFiles(content.files);
|
|
155
|
-
return [];
|
|
75
|
+
function resolveOptionConfigPath(config, base) {
|
|
76
|
+
if (!config) return;
|
|
77
|
+
return path.isAbsolute(config) ? config : path.resolve(base, config);
|
|
156
78
|
}
|
|
157
|
-
async function collectConfigContentFiles(root, base) {
|
|
158
|
-
const configPaths = collectConfigPaths(root, base);
|
|
79
|
+
async function collectConfigContentFiles(root, base, options) {
|
|
80
|
+
const configPaths = [...new Set([...resolveOptionConfigPath(options.config, base) ? [resolveOptionConfigPath(options.config, base)] : [], ...collectConfigPaths(root, base)])];
|
|
159
81
|
const files = [];
|
|
160
82
|
for (const configPath of configPaths) {
|
|
161
|
-
const
|
|
83
|
+
const contentEntries = normalizeLegacyContentEntries((await loadConfig({
|
|
162
84
|
config: configPath,
|
|
163
85
|
cwd: path.dirname(configPath)
|
|
164
|
-
}))?.config.content);
|
|
165
|
-
|
|
86
|
+
}))?.config.content, path.dirname(configPath));
|
|
87
|
+
files.push(...await expandTailwindSourceEntries(contentEntries));
|
|
166
88
|
}
|
|
167
89
|
return {
|
|
168
90
|
configPaths,
|
|
169
91
|
files: [...new Set(files)]
|
|
170
92
|
};
|
|
171
93
|
}
|
|
94
|
+
async function collectConfiguredContentEntries(root, base, options) {
|
|
95
|
+
const configPath = resolveOptionConfigPath(options.generator?.config ?? options.config, base) ?? collectConfigPaths(root, base)[0];
|
|
96
|
+
if (!configPath) return [];
|
|
97
|
+
const resolvedConfigPath = path.isAbsolute(configPath) ? configPath : path.resolve(base, configPath);
|
|
98
|
+
return normalizeLegacyContentEntries((await loadConfig({
|
|
99
|
+
config: resolvedConfigPath,
|
|
100
|
+
cwd: path.dirname(resolvedConfigPath)
|
|
101
|
+
}))?.config.content, path.dirname(resolvedConfigPath));
|
|
102
|
+
}
|
|
103
|
+
async function collectRawCandidatesFromSourceEntries(sourceEntries) {
|
|
104
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
105
|
+
const files = await expandTailwindSourceEntries(sourceEntries);
|
|
106
|
+
await Promise.all(files.map(async (file) => {
|
|
107
|
+
const matches = await extractRawCandidatesWithPositions(await readFile(file, "utf8"), getSourceExtension(file));
|
|
108
|
+
for (const match of matches) {
|
|
109
|
+
const candidate = match?.rawCandidate;
|
|
110
|
+
if (typeof candidate === "string" && candidate.length > 0) candidates.add(candidate);
|
|
111
|
+
}
|
|
112
|
+
}));
|
|
113
|
+
return candidates;
|
|
114
|
+
}
|
|
172
115
|
async function collectAutoTailwindCandidates(root, result, options) {
|
|
173
116
|
if (options.scanSources === false) return /* @__PURE__ */ new Set();
|
|
174
117
|
const base = resolvePostcssBase(result, options);
|
|
175
118
|
const projectRoot = resolvePostcssProjectRoot(result, options);
|
|
176
|
-
const
|
|
177
|
-
|
|
119
|
+
const sourceEntries = [];
|
|
120
|
+
const hasSourceNone = root.toString().includes("source(none)");
|
|
121
|
+
const inlineCandidates = collectCssInlineSourceCandidates(root);
|
|
122
|
+
const configuredContentEntries = options.version === 3 ? await collectConfiguredContentEntries(root, base, options) : [];
|
|
123
|
+
if (configuredContentEntries.length > 0) sourceEntries.push(...configuredContentEntries);
|
|
124
|
+
else if (!hasSourceNone) sourceEntries.push({
|
|
178
125
|
base,
|
|
179
126
|
negated: false,
|
|
180
127
|
pattern: POSTCSS_SOURCE_PATTERN
|
|
181
|
-
}));
|
|
182
|
-
root.walkAtRules("source", (rule) => {
|
|
183
|
-
const parsed = parseSourceFileParam(rule.params);
|
|
184
|
-
if (!parsed) return;
|
|
185
|
-
sourceEntryTasks.push(resolveTailwindSourceEntry(parsed.sourcePath, base, parsed.negated));
|
|
186
128
|
});
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
const candidates = await extractValidCandidates({
|
|
129
|
+
sourceEntries.push(...await resolveCssSourceEntries(root, base, POSTCSS_SOURCE_PATTERN));
|
|
130
|
+
const candidates = sourceEntries.length === 0 ? [] : options.version === 3 ? await collectRawCandidatesFromSourceEntries(sourceEntries) : await extractValidCandidates({
|
|
190
131
|
base,
|
|
191
132
|
css: root.toString(),
|
|
192
133
|
cwd: projectRoot,
|
|
193
134
|
sources: sourceEntries
|
|
194
135
|
});
|
|
195
|
-
return new Set(candidates);
|
|
136
|
+
return new Set([...[...candidates].filter((candidate) => !inlineCandidates.excluded.has(candidate)), ...inlineCandidates.included]);
|
|
196
137
|
}
|
|
197
138
|
async function collectPostcssLocalSources(root, result, options) {
|
|
198
139
|
const base = resolvePostcssBase(result, options);
|
|
199
|
-
const
|
|
200
|
-
root
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
})));
|
|
140
|
+
const sourceEntries = await resolveCssSourceEntries(root, base, POSTCSS_SOURCE_PATTERN);
|
|
141
|
+
const configContentFiles = await collectConfigContentFiles(root, base, options);
|
|
142
|
+
const files = [...new Set([...await expandTailwindSourceEntries(sourceEntries), ...configContentFiles.files])];
|
|
143
|
+
const sources = await Promise.all(files.map(async (file) => {
|
|
144
|
+
const extension = getSourceExtension(file);
|
|
145
|
+
return {
|
|
146
|
+
content: await readFile(file, "utf8"),
|
|
147
|
+
...extension === void 0 ? {} : { extension }
|
|
148
|
+
};
|
|
149
|
+
}));
|
|
210
150
|
return {
|
|
211
151
|
files: [...files, ...configContentFiles.configPaths],
|
|
212
152
|
sources
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
//#region src/css-macro/constants.ts
|
|
2
|
+
const queryKey = "weapp-tw-platform";
|
|
3
|
+
const ifdefAtRule = "weapp-tw-ifdef";
|
|
4
|
+
const ifndefAtRule = "weapp-tw-ifndef";
|
|
5
|
+
function quoteAtRuleParam(value) {
|
|
6
|
+
return `"${value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}"`;
|
|
7
|
+
}
|
|
8
|
+
function createConditionalAtRule(value) {
|
|
9
|
+
return `@${ifdefAtRule} ${quoteAtRuleParam(value)}{&}`;
|
|
10
|
+
}
|
|
11
|
+
function createNegativeConditionalAtRule(value) {
|
|
12
|
+
return `@${ifndefAtRule} ${quoteAtRuleParam(value)}{&}`;
|
|
13
|
+
}
|
|
14
|
+
const UNESCAPED_UNDERSCORE_RE = /(?<!\\)_/g;
|
|
15
|
+
const WHITESPACE_RE = /\s+/g;
|
|
16
|
+
const LOGICAL_OPERATOR_RE = /\s*(\|\||&&)\s*/g;
|
|
17
|
+
function normalComment(text) {
|
|
18
|
+
if (typeof text === "string") {
|
|
19
|
+
const normalized = text.replaceAll(UNESCAPED_UNDERSCORE_RE, " ").replaceAll(WHITESPACE_RE, " ").trim();
|
|
20
|
+
if (normalized.includes("\\")) return normalized;
|
|
21
|
+
return normalized.replaceAll(LOGICAL_OPERATOR_RE, " $1 ").replaceAll(WHITESPACE_RE, " ").trim();
|
|
22
|
+
}
|
|
23
|
+
return text;
|
|
24
|
+
}
|
|
25
|
+
function ifdef(text) {
|
|
26
|
+
return {
|
|
27
|
+
start: `#ifdef ${normalComment(text)}`,
|
|
28
|
+
end: `#endif`
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function ifndef(text) {
|
|
32
|
+
return {
|
|
33
|
+
start: `#ifndef ${normalComment(text)}`,
|
|
34
|
+
end: `#endif`
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const QUERY_KEY_REGEX = new RegExp(`\\(\\s*${queryKey}\\s*:\\s*"([^)]*)"\\)`, "g");
|
|
38
|
+
function matchCustomPropertyFromValue(str, cb) {
|
|
39
|
+
let index = 0;
|
|
40
|
+
QUERY_KEY_REGEX.lastIndex = 0;
|
|
41
|
+
let arr = QUERY_KEY_REGEX.exec(str);
|
|
42
|
+
while (arr !== null) {
|
|
43
|
+
cb(arr, index);
|
|
44
|
+
index++;
|
|
45
|
+
arr = QUERY_KEY_REGEX.exec(str);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function parseConditionalAtRuleParam(params) {
|
|
49
|
+
const value = params.trim();
|
|
50
|
+
const quoted = /^(['"])((?:\\.|(?!\1).)*)\1/.exec(value);
|
|
51
|
+
if (!quoted) return value;
|
|
52
|
+
return quoted[2]?.replaceAll(/\\(["'\\])/g, "$1") ?? "";
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/css-macro/postcss.ts
|
|
56
|
+
const IFDEF_ENDIF_RE = /#(?:ifn?def|endif)/;
|
|
57
|
+
const CONDITIONAL_COMMENT_SPACING = " ";
|
|
58
|
+
const CSS_MACRO_POSTCSS_PLUGIN_NAME = "postcss-weapp-tw-css-macro-plugin";
|
|
59
|
+
const creator = () => {
|
|
60
|
+
return {
|
|
61
|
+
postcssPlugin: CSS_MACRO_POSTCSS_PLUGIN_NAME,
|
|
62
|
+
prepare() {
|
|
63
|
+
function replaceAtRuleWithConditionalComments(atRule, helper, comment) {
|
|
64
|
+
const hasPreviousNode = Boolean(atRule.prev());
|
|
65
|
+
const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
|
|
66
|
+
const startComment = helper.comment({
|
|
67
|
+
raws: {
|
|
68
|
+
left: CONDITIONAL_COMMENT_SPACING,
|
|
69
|
+
right: CONDITIONAL_COMMENT_SPACING
|
|
70
|
+
},
|
|
71
|
+
text: comment.start
|
|
72
|
+
});
|
|
73
|
+
const endComment = helper.comment({
|
|
74
|
+
raws: {
|
|
75
|
+
left: CONDITIONAL_COMMENT_SPACING,
|
|
76
|
+
right: CONDITIONAL_COMMENT_SPACING
|
|
77
|
+
},
|
|
78
|
+
text: comment.end
|
|
79
|
+
});
|
|
80
|
+
const nextNodes = [
|
|
81
|
+
startComment,
|
|
82
|
+
...clonedNodes,
|
|
83
|
+
endComment
|
|
84
|
+
];
|
|
85
|
+
atRule.replaceWith(nextNodes);
|
|
86
|
+
startComment.raws.before = hasPreviousNode ? "\n" : "";
|
|
87
|
+
startComment.raws["after"] = "\n";
|
|
88
|
+
if (clonedNodes[0]) clonedNodes[0].raws.before = "\n";
|
|
89
|
+
endComment.raws.before = "\n";
|
|
90
|
+
endComment.raws["after"] = "\n";
|
|
91
|
+
const nextNode = endComment?.next();
|
|
92
|
+
if (nextNode) nextNode.raws.before = "\n";
|
|
93
|
+
}
|
|
94
|
+
function replaceNestedAtRuleWithConditionalRule(atRule, helper, comment) {
|
|
95
|
+
if (atRule.parent?.type !== "rule") return false;
|
|
96
|
+
const parentRule = atRule.parent;
|
|
97
|
+
const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
|
|
98
|
+
const conditionalRule = parentRule.clone();
|
|
99
|
+
conditionalRule.removeAll();
|
|
100
|
+
conditionalRule.append(...clonedNodes);
|
|
101
|
+
const startComment = helper.comment({
|
|
102
|
+
raws: {
|
|
103
|
+
left: CONDITIONAL_COMMENT_SPACING,
|
|
104
|
+
right: CONDITIONAL_COMMENT_SPACING
|
|
105
|
+
},
|
|
106
|
+
text: comment.start
|
|
107
|
+
});
|
|
108
|
+
const endComment = helper.comment({
|
|
109
|
+
raws: {
|
|
110
|
+
left: CONDITIONAL_COMMENT_SPACING,
|
|
111
|
+
right: CONDITIONAL_COMMENT_SPACING
|
|
112
|
+
},
|
|
113
|
+
text: comment.end
|
|
114
|
+
});
|
|
115
|
+
const nextNodes = [
|
|
116
|
+
startComment,
|
|
117
|
+
conditionalRule,
|
|
118
|
+
endComment
|
|
119
|
+
];
|
|
120
|
+
const hasPreviousNode = Boolean(parentRule.prev());
|
|
121
|
+
atRule.remove();
|
|
122
|
+
if ((parentRule.nodes?.length ?? 0) === 0) parentRule.replaceWith(nextNodes);
|
|
123
|
+
else parentRule.after(nextNodes);
|
|
124
|
+
startComment.raws.before = hasPreviousNode ? "\n" : "";
|
|
125
|
+
startComment.raws["after"] = "\n";
|
|
126
|
+
conditionalRule.raws.before = "\n";
|
|
127
|
+
endComment.raws.before = "\n";
|
|
128
|
+
endComment.raws["after"] = "\n";
|
|
129
|
+
const nextNode = endComment.next();
|
|
130
|
+
if (nextNode) nextNode.raws.before = "\n";
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
AtRule(atRule, helper) {
|
|
135
|
+
if (atRule.name === "weapp-tw-ifdef" || atRule.name === "weapp-tw-ifndef") {
|
|
136
|
+
const text = parseConditionalAtRuleParam(atRule.params);
|
|
137
|
+
const comment = atRule.name === "weapp-tw-ifndef" ? ifndef(text) : ifdef(text);
|
|
138
|
+
if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
|
|
139
|
+
replaceAtRuleWithConditionalComments(atRule, helper, comment);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (atRule.name === "media") {
|
|
143
|
+
const values = [];
|
|
144
|
+
matchCustomPropertyFromValue(atRule.params, (arr) => {
|
|
145
|
+
const value = arr[1];
|
|
146
|
+
if (value) values.push(value);
|
|
147
|
+
});
|
|
148
|
+
if (values.length > 0) {
|
|
149
|
+
const isNegative = atRule.params.includes("not");
|
|
150
|
+
const text = values.join(" ");
|
|
151
|
+
const comment = isNegative ? ifndef(text) : ifdef(text);
|
|
152
|
+
if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
|
|
153
|
+
replaceAtRuleWithConditionalComments(atRule, helper, comment);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
CommentExit(comment) {
|
|
158
|
+
if (IFDEF_ENDIF_RE.test(comment.text)) {
|
|
159
|
+
comment.raws.left = CONDITIONAL_COMMENT_SPACING;
|
|
160
|
+
comment.raws.right = CONDITIONAL_COMMENT_SPACING;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
creator.postcss = true;
|
|
168
|
+
//#endregion
|
|
169
|
+
export { createNegativeConditionalAtRule as i, creator as n, createConditionalAtRule as r, CSS_MACRO_POSTCSS_PLUGIN_NAME as t };
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
//#region src/css-macro/constants.ts
|
|
2
|
+
const queryKey = "weapp-tw-platform";
|
|
3
|
+
const ifdefAtRule = "weapp-tw-ifdef";
|
|
4
|
+
const ifndefAtRule = "weapp-tw-ifndef";
|
|
5
|
+
function quoteAtRuleParam(value) {
|
|
6
|
+
return `"${value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}"`;
|
|
7
|
+
}
|
|
8
|
+
function createConditionalAtRule(value) {
|
|
9
|
+
return `@${ifdefAtRule} ${quoteAtRuleParam(value)}{&}`;
|
|
10
|
+
}
|
|
11
|
+
function createNegativeConditionalAtRule(value) {
|
|
12
|
+
return `@${ifndefAtRule} ${quoteAtRuleParam(value)}{&}`;
|
|
13
|
+
}
|
|
14
|
+
const UNESCAPED_UNDERSCORE_RE = /(?<!\\)_/g;
|
|
15
|
+
const WHITESPACE_RE = /\s+/g;
|
|
16
|
+
const LOGICAL_OPERATOR_RE = /\s*(\|\||&&)\s*/g;
|
|
17
|
+
function normalComment(text) {
|
|
18
|
+
if (typeof text === "string") {
|
|
19
|
+
const normalized = text.replaceAll(UNESCAPED_UNDERSCORE_RE, " ").replaceAll(WHITESPACE_RE, " ").trim();
|
|
20
|
+
if (normalized.includes("\\")) return normalized;
|
|
21
|
+
return normalized.replaceAll(LOGICAL_OPERATOR_RE, " $1 ").replaceAll(WHITESPACE_RE, " ").trim();
|
|
22
|
+
}
|
|
23
|
+
return text;
|
|
24
|
+
}
|
|
25
|
+
function ifdef(text) {
|
|
26
|
+
return {
|
|
27
|
+
start: `#ifdef ${normalComment(text)}`,
|
|
28
|
+
end: `#endif`
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function ifndef(text) {
|
|
32
|
+
return {
|
|
33
|
+
start: `#ifndef ${normalComment(text)}`,
|
|
34
|
+
end: `#endif`
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const QUERY_KEY_REGEX = new RegExp(`\\(\\s*${queryKey}\\s*:\\s*"([^)]*)"\\)`, "g");
|
|
38
|
+
function matchCustomPropertyFromValue(str, cb) {
|
|
39
|
+
let index = 0;
|
|
40
|
+
QUERY_KEY_REGEX.lastIndex = 0;
|
|
41
|
+
let arr = QUERY_KEY_REGEX.exec(str);
|
|
42
|
+
while (arr !== null) {
|
|
43
|
+
cb(arr, index);
|
|
44
|
+
index++;
|
|
45
|
+
arr = QUERY_KEY_REGEX.exec(str);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function parseConditionalAtRuleParam(params) {
|
|
49
|
+
const value = params.trim();
|
|
50
|
+
const quoted = /^(['"])((?:\\.|(?!\1).)*)\1/.exec(value);
|
|
51
|
+
if (!quoted) return value;
|
|
52
|
+
return quoted[2]?.replaceAll(/\\(["'\\])/g, "$1") ?? "";
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/css-macro/postcss.ts
|
|
56
|
+
const IFDEF_ENDIF_RE = /#(?:ifn?def|endif)/;
|
|
57
|
+
const CONDITIONAL_COMMENT_SPACING = " ";
|
|
58
|
+
const CSS_MACRO_POSTCSS_PLUGIN_NAME = "postcss-weapp-tw-css-macro-plugin";
|
|
59
|
+
const creator = () => {
|
|
60
|
+
return {
|
|
61
|
+
postcssPlugin: CSS_MACRO_POSTCSS_PLUGIN_NAME,
|
|
62
|
+
prepare() {
|
|
63
|
+
function replaceAtRuleWithConditionalComments(atRule, helper, comment) {
|
|
64
|
+
const hasPreviousNode = Boolean(atRule.prev());
|
|
65
|
+
const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
|
|
66
|
+
const startComment = helper.comment({
|
|
67
|
+
raws: {
|
|
68
|
+
left: CONDITIONAL_COMMENT_SPACING,
|
|
69
|
+
right: CONDITIONAL_COMMENT_SPACING
|
|
70
|
+
},
|
|
71
|
+
text: comment.start
|
|
72
|
+
});
|
|
73
|
+
const endComment = helper.comment({
|
|
74
|
+
raws: {
|
|
75
|
+
left: CONDITIONAL_COMMENT_SPACING,
|
|
76
|
+
right: CONDITIONAL_COMMENT_SPACING
|
|
77
|
+
},
|
|
78
|
+
text: comment.end
|
|
79
|
+
});
|
|
80
|
+
const nextNodes = [
|
|
81
|
+
startComment,
|
|
82
|
+
...clonedNodes,
|
|
83
|
+
endComment
|
|
84
|
+
];
|
|
85
|
+
atRule.replaceWith(nextNodes);
|
|
86
|
+
startComment.raws.before = hasPreviousNode ? "\n" : "";
|
|
87
|
+
startComment.raws["after"] = "\n";
|
|
88
|
+
if (clonedNodes[0]) clonedNodes[0].raws.before = "\n";
|
|
89
|
+
endComment.raws.before = "\n";
|
|
90
|
+
endComment.raws["after"] = "\n";
|
|
91
|
+
const nextNode = endComment?.next();
|
|
92
|
+
if (nextNode) nextNode.raws.before = "\n";
|
|
93
|
+
}
|
|
94
|
+
function replaceNestedAtRuleWithConditionalRule(atRule, helper, comment) {
|
|
95
|
+
if (atRule.parent?.type !== "rule") return false;
|
|
96
|
+
const parentRule = atRule.parent;
|
|
97
|
+
const clonedNodes = (atRule.nodes ?? []).map((node) => node.clone());
|
|
98
|
+
const conditionalRule = parentRule.clone();
|
|
99
|
+
conditionalRule.removeAll();
|
|
100
|
+
conditionalRule.append(...clonedNodes);
|
|
101
|
+
const startComment = helper.comment({
|
|
102
|
+
raws: {
|
|
103
|
+
left: CONDITIONAL_COMMENT_SPACING,
|
|
104
|
+
right: CONDITIONAL_COMMENT_SPACING
|
|
105
|
+
},
|
|
106
|
+
text: comment.start
|
|
107
|
+
});
|
|
108
|
+
const endComment = helper.comment({
|
|
109
|
+
raws: {
|
|
110
|
+
left: CONDITIONAL_COMMENT_SPACING,
|
|
111
|
+
right: CONDITIONAL_COMMENT_SPACING
|
|
112
|
+
},
|
|
113
|
+
text: comment.end
|
|
114
|
+
});
|
|
115
|
+
const nextNodes = [
|
|
116
|
+
startComment,
|
|
117
|
+
conditionalRule,
|
|
118
|
+
endComment
|
|
119
|
+
];
|
|
120
|
+
const hasPreviousNode = Boolean(parentRule.prev());
|
|
121
|
+
atRule.remove();
|
|
122
|
+
if ((parentRule.nodes?.length ?? 0) === 0) parentRule.replaceWith(nextNodes);
|
|
123
|
+
else parentRule.after(nextNodes);
|
|
124
|
+
startComment.raws.before = hasPreviousNode ? "\n" : "";
|
|
125
|
+
startComment.raws["after"] = "\n";
|
|
126
|
+
conditionalRule.raws.before = "\n";
|
|
127
|
+
endComment.raws.before = "\n";
|
|
128
|
+
endComment.raws["after"] = "\n";
|
|
129
|
+
const nextNode = endComment.next();
|
|
130
|
+
if (nextNode) nextNode.raws.before = "\n";
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
AtRule(atRule, helper) {
|
|
135
|
+
if (atRule.name === "weapp-tw-ifdef" || atRule.name === "weapp-tw-ifndef") {
|
|
136
|
+
const text = parseConditionalAtRuleParam(atRule.params);
|
|
137
|
+
const comment = atRule.name === "weapp-tw-ifndef" ? ifndef(text) : ifdef(text);
|
|
138
|
+
if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
|
|
139
|
+
replaceAtRuleWithConditionalComments(atRule, helper, comment);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (atRule.name === "media") {
|
|
143
|
+
const values = [];
|
|
144
|
+
matchCustomPropertyFromValue(atRule.params, (arr) => {
|
|
145
|
+
const value = arr[1];
|
|
146
|
+
if (value) values.push(value);
|
|
147
|
+
});
|
|
148
|
+
if (values.length > 0) {
|
|
149
|
+
const isNegative = atRule.params.includes("not");
|
|
150
|
+
const text = values.join(" ");
|
|
151
|
+
const comment = isNegative ? ifndef(text) : ifdef(text);
|
|
152
|
+
if (replaceNestedAtRuleWithConditionalRule(atRule, helper, comment)) return;
|
|
153
|
+
replaceAtRuleWithConditionalComments(atRule, helper, comment);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
CommentExit(comment) {
|
|
158
|
+
if (IFDEF_ENDIF_RE.test(comment.text)) {
|
|
159
|
+
comment.raws.left = CONDITIONAL_COMMENT_SPACING;
|
|
160
|
+
comment.raws.right = CONDITIONAL_COMMENT_SPACING;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
creator.postcss = true;
|
|
168
|
+
//#endregion
|
|
169
|
+
Object.defineProperty(exports, "CSS_MACRO_POSTCSS_PLUGIN_NAME", {
|
|
170
|
+
enumerable: true,
|
|
171
|
+
get: function() {
|
|
172
|
+
return CSS_MACRO_POSTCSS_PLUGIN_NAME;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
Object.defineProperty(exports, "createConditionalAtRule", {
|
|
176
|
+
enumerable: true,
|
|
177
|
+
get: function() {
|
|
178
|
+
return createConditionalAtRule;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
Object.defineProperty(exports, "createNegativeConditionalAtRule", {
|
|
182
|
+
enumerable: true,
|
|
183
|
+
get: function() {
|
|
184
|
+
return createNegativeConditionalAtRule;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
Object.defineProperty(exports, "creator", {
|
|
188
|
+
enumerable: true,
|
|
189
|
+
get: function() {
|
|
190
|
+
return creator;
|
|
191
|
+
}
|
|
192
|
+
});
|