weapp-tailwindcss 5.0.0-next.1 → 5.0.0-next.11
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 +4 -5
- package/bin/weapp-tailwindcss.js +1 -21
- package/dist/bundle-state-BRkhpjio.js +448 -0
- package/dist/bundle-state-BrtFgX-A.mjs +369 -0
- package/dist/bundlers/shared/cache.d.ts +6 -6
- package/dist/bundlers/shared/css-cleanup/at-rules.d.ts +2 -0
- package/dist/bundlers/shared/css-cleanup/color-gamut.d.ts +3 -0
- package/dist/bundlers/shared/css-cleanup/root-cleanups.d.ts +4 -0
- package/dist/bundlers/shared/css-cleanup/selectors.d.ts +8 -0
- package/dist/bundlers/shared/css-cleanup.d.ts +1 -2
- package/dist/bundlers/shared/css-imports.d.ts +3 -3
- package/dist/bundlers/shared/generator-css/config-directive.d.ts +2 -0
- package/dist/bundlers/shared/generator-css/directives.d.ts +20 -0
- package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +7 -0
- package/dist/bundlers/shared/generator-css/legacy-selectors.d.ts +5 -0
- package/dist/bundlers/shared/generator-css/legacy-units.d.ts +1 -0
- package/dist/bundlers/shared/generator-css/markers.d.ts +16 -0
- package/dist/bundlers/shared/generator-css/source-files.d.ts +11 -0
- package/dist/bundlers/shared/generator-css/source-resolver.d.ts +10 -0
- package/dist/bundlers/shared/generator-css.d.ts +12 -20
- package/dist/bundlers/shared/hmr-timing.d.ts +5 -0
- package/dist/bundlers/shared/style-requests.d.ts +2 -0
- package/dist/bundlers/vite/css-finalizer.d.ts +4 -1
- package/dist/bundlers/vite/generate-bundle/candidates.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +20 -0
- package/dist/bundlers/vite/generate-bundle/css-share-scope.d.ts +3 -0
- package/dist/bundlers/vite/generate-bundle/dirty-state.d.ts +1 -0
- package/dist/bundlers/vite/generate-bundle/js-entries.d.ts +2 -0
- package/dist/bundlers/vite/generate-bundle/js-handler-options.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle/js-linking.d.ts +13 -0
- package/dist/bundlers/vite/generate-bundle/metrics.d.ts +17 -0
- package/dist/bundlers/vite/generate-bundle/process-plan.d.ts +9 -0
- package/dist/bundlers/vite/generate-bundle/rollup-assets.d.ts +7 -0
- package/dist/bundlers/vite/generate-bundle/signatures.d.ts +8 -0
- package/dist/bundlers/vite/generate-bundle.d.ts +16 -2
- package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +4 -1
- package/dist/bundlers/vite/index.d.ts +1 -1
- package/dist/bundlers/vite/official-tailwind-plugins.d.ts +5 -0
- package/dist/bundlers/vite/postcss-config.d.ts +6 -0
- package/dist/bundlers/vite/rewrite-css-imports.d.ts +5 -3
- package/dist/bundlers/vite/runtime-class-set.d.ts +22 -0
- package/dist/bundlers/vite/source-candidates.d.ts +18 -0
- package/dist/bundlers/vite/source-scan.d.ts +9 -0
- package/dist/bundlers/vite/tailwind-basedir.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +1 -0
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +5 -2
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +4 -3
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v5.d.ts +1 -0
- package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +3 -1
- package/dist/cache/index.d.ts +6 -6
- package/dist/cache-B_9E7FxF.js +517 -0
- package/dist/cache-DEDxBMIw.mjs +443 -0
- package/dist/cli/context.d.ts +1 -14
- package/dist/cli/doctor/types.d.ts +11 -11
- package/dist/cli/helpers.d.ts +1 -2
- package/dist/cli/mount-options.d.ts +2 -0
- package/dist/cli/types.d.ts +0 -2
- package/dist/cli/vscode-entry.d.ts +3 -3
- package/dist/cli.js +126 -602
- package/dist/cli.mjs +135 -610
- package/dist/constants.d.ts +1 -2
- package/dist/core.js +13 -20
- package/dist/core.mjs +8 -14
- package/dist/css-macro/postcss.js +3 -2
- package/dist/css-macro/postcss.mjs +3 -2
- package/dist/css-macro.d.ts +1 -0
- package/dist/css-macro.js +2 -2
- package/dist/css-macro.mjs +2 -2
- package/dist/defaults.d.ts +15 -1
- package/dist/defaults.js +33 -14
- package/dist/defaults.mjs +30 -15
- package/dist/escape.js +10 -2
- package/dist/escape.mjs +10 -2
- package/dist/generator/index.d.ts +1 -1
- package/dist/generator/options.d.ts +10 -7
- package/dist/generator/types.d.ts +3 -2
- package/dist/generator-CahkD2vq.mjs +1469 -0
- package/dist/generator-Ck1Dd1V0.js +1568 -0
- package/dist/generator.js +1 -1
- package/dist/generator.mjs +1 -1
- package/dist/gulp.js +149 -47
- package/dist/gulp.mjs +144 -42
- package/dist/incremental-runtime-class-set-CBMefNHQ.js +1744 -0
- package/dist/incremental-runtime-class-set-DaS2yw5c.mjs +1687 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/index.mjs +5 -5
- package/dist/js/index.d.ts +1 -0
- package/dist/js/literal-transform.d.ts +2 -0
- package/dist/js/precheck.d.ts +2 -2
- package/dist/lightningcss/style-handler/selector-transform.d.ts +1 -1
- package/dist/lightningcss/style-handler.d.ts +3 -3
- package/dist/logger-CZUxvJJD.mjs +2 -0
- package/dist/logger-EVNB9z7i.js +1 -0
- package/dist/postcss/config-directive.d.ts +1 -0
- package/dist/postcss/context.d.ts +9 -0
- package/dist/postcss/source-files.d.ts +8 -0
- package/dist/postcss/tailwind-version.d.ts +3 -0
- package/dist/postcss-BdcRlSpp.js +243 -0
- package/dist/postcss-Bs-RbNzK.js +5477 -0
- package/dist/postcss-xZDiTRII.mjs +234 -0
- package/dist/postcss.d.ts +2 -2
- package/dist/postcss.js +3 -274
- package/dist/postcss.mjs +1 -267
- package/dist/{recorder-rn_2v_nd.js → precheck-D5eEdqeH.js} +168 -304
- package/dist/{recorder-B_XyZ576.mjs → precheck-DtBGFS-n.mjs} +134 -269
- package/dist/presets.js +13 -11
- package/dist/presets.mjs +11 -9
- package/dist/reset.d.ts +1 -0
- package/dist/runtime-patch-CqB-A4zA.js +85 -0
- package/dist/runtime-patch-DGKsVkiG.mjs +71 -0
- package/dist/shared/mpx.d.ts +1 -0
- package/dist/source-scan-CIVTa3Cj.js +297 -0
- package/dist/source-scan-CJ0y0XBj.mjs +258 -0
- package/dist/tailwindcss/miniprogram.d.ts +5 -1
- package/dist/tailwindcss/patcher-options.d.ts +3 -51
- package/dist/tailwindcss/patcher.d.ts +1 -2
- package/dist/tailwindcss/runtime/cache.d.ts +3 -3
- package/dist/tailwindcss/runtime-patch.d.ts +5 -0
- package/dist/tailwindcss/runtime.d.ts +11 -12
- package/dist/tailwindcss/source-scan.d.ts +25 -0
- package/dist/tailwindcss/targets.d.ts +1 -5
- package/dist/tailwindcss/v3-engine/types.d.ts +14 -14
- package/dist/tailwindcss/v4/css-entries.d.ts +2 -2
- package/dist/tailwindcss/v4/css-sources.d.ts +5 -0
- package/dist/tailwindcss/v4/patcher-options.d.ts +1 -23
- package/dist/tailwindcss/v4/patcher.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/candidates.d.ts +2 -0
- package/dist/tailwindcss/v4-engine/miniprogram.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/tailwind-v3-compatibility.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/tailwind-v3-default-colors.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/tailwind-v4-default-colors.d.ts +1 -0
- package/dist/tailwindcss/v4-engine/types.d.ts +6 -3
- package/dist/tailwindcss/version.d.ts +4 -0
- package/dist/tailwindcss-B78nj6n7.js +644 -0
- package/dist/tailwindcss-DGM8lHUj.mjs +593 -0
- package/dist/typedoc.export.d.ts +0 -2
- package/dist/types/index.d.ts +45 -48
- package/dist/types/shared.d.ts +3 -0
- package/dist/types/user-defined-options/general.d.ts +21 -23
- package/dist/types/user-defined-options/important.d.ts +31 -28
- package/dist/types/user-defined-options/lifecycle.d.ts +4 -4
- package/dist/types/user-defined-options/matcher.d.ts +6 -6
- package/dist/uni-app-x/vite.d.ts +1 -1
- package/dist/utils/disabled.d.ts +2 -3
- package/dist/utils/object.d.ts +9 -0
- package/dist/{utils-DmC9_In3.js → utils-4ODFyoqD.js} +1 -1
- package/dist/{utils-7DUGTFED.mjs → utils-CGBVVNm6.mjs} +1 -1
- package/dist/{vite-BHpAqldo.js → vite-BEj9JOOA.js} +1245 -876
- package/dist/{vite-C8JlHiyR.mjs → vite-C8S1wfyQ.mjs} +1208 -842
- package/dist/vite.d.ts +1 -2
- package/dist/vite.js +3 -4
- package/dist/vite.mjs +2 -2
- package/dist/weapp-tw-css-import-rewrite-loader.js +129 -15
- package/dist/weapp-tw-runtime-classset-loader.js +44 -6
- package/dist/webpack-Dm1IXTIh.js +778 -0
- package/dist/webpack-ZGIKKpFf.mjs +768 -0
- package/dist/webpack.js +1 -1
- package/dist/webpack.mjs +1 -1
- package/package.json +26 -39
- package/dist/bundlers/shared/generator-candidates.d.ts +0 -5
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-assets.d.ts +0 -14
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4-loaders.d.ts +0 -15
- package/dist/bundlers/webpack/BaseUnifiedPlugin/v4.d.ts +0 -9
- package/dist/bundlers/webpack/shared/css-imports.d.ts +0 -6
- package/dist/cli/config.d.ts +0 -5
- package/dist/cli/helpers/patch-cwd.d.ts +0 -1
- package/dist/cli/mount-options/patch-status.d.ts +0 -2
- package/dist/cli/patch-options.d.ts +0 -6
- package/dist/cli/tokens.d.ts +0 -4
- package/dist/cli/workspace/package-dirs.d.ts +0 -3
- package/dist/cli/workspace/patch-package.d.ts +0 -3
- package/dist/cli/workspace/patch-utils.d.ts +0 -3
- package/dist/cli/workspace/types.d.ts +0 -11
- package/dist/cli/workspace/workspace-globs.d.ts +0 -2
- package/dist/cli/workspace/workspace-io.d.ts +0 -1
- package/dist/cli/workspace/workspace-lock.d.ts +0 -1
- package/dist/cli/workspace.d.ts +0 -2
- package/dist/css-imports-BbrbluP9.js +0 -177
- package/dist/css-imports-CSdPq_Sc.mjs +0 -128
- package/dist/experimental/index.d.ts +0 -2
- package/dist/experimental/oxc/ast-utils.d.ts +0 -30
- package/dist/experimental/oxc/index.d.ts +0 -2
- package/dist/experimental/oxc/module-specifiers.d.ts +0 -2
- package/dist/experimental/shared/cache.d.ts +0 -3
- package/dist/experimental/shared/transform.d.ts +0 -3
- package/dist/experimental/shared.d.ts +0 -8
- package/dist/experimental/swc/ast-utils.d.ts +0 -30
- package/dist/experimental/swc/index.d.ts +0 -2
- package/dist/experimental/swc/module-specifiers.d.ts +0 -2
- package/dist/generator-CZ-JXw6T.js +0 -492
- package/dist/generator-Dwxgra97.mjs +0 -399
- package/dist/generator-css-CnYjiMrD.js +0 -1084
- package/dist/generator-css-DhPFjSzK.mjs +0 -1057
- package/dist/js/syntax.d.ts +0 -10
- package/dist/loader-anchors-DvwgIYdA.mjs +0 -205
- package/dist/loader-anchors-cprm4Klq.js +0 -273
- package/dist/logger-BZ45DZJT.js +0 -1003
- package/dist/logger-BoVx1Dbt.mjs +0 -935
- package/dist/patcher-options-6gJN2EXy.js +0 -115
- package/dist/patcher-options-DQfR5xxT.mjs +0 -92
- package/dist/tailwindcss/recorder.d.ts +0 -13
- package/dist/tailwindcss/targets/paths.d.ts +0 -13
- package/dist/tailwindcss/targets/record-io.d.ts +0 -5
- package/dist/tailwindcss/targets/recorder.d.ts +0 -3
- package/dist/tailwindcss/targets/types.d.ts +0 -35
- package/dist/types/disabled-options.d.ts +0 -4
- package/dist/webpack-CABjKGGQ.mjs +0 -441
- package/dist/webpack-DNIJ0ysE.js +0 -456
- package/dist/webpack4.d.ts +0 -4
- package/dist/webpack4.js +0 -387
- package/dist/webpack4.mjs +0 -379
- package/scripts/postinstall.mjs +0 -59
- /package/dist/{constants-B-_T5UnW.mjs → constants-BG12WAKw.mjs} +0 -0
- /package/dist/{constants-p1dyh1x1.js → constants-BeeyfJ9k.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export { createPlugins } from './gulp';
|
|
|
4
4
|
export { weappTailwindcssPostcssPlugin } from './postcss';
|
|
5
5
|
export type { WeappTailwindcssPostcssPluginOptions } from './postcss';
|
|
6
6
|
export type * from './types';
|
|
7
|
-
export {
|
|
7
|
+
export { WeappTailwindcss } from './vite';
|
|
8
8
|
export { UnifiedWebpackPluginV5, weappTailwindcssPackageDir } from './webpack';
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_generator = require("./generator-
|
|
2
|
+
const require_generator = require("./generator-Ck1Dd1V0.js");
|
|
3
3
|
const require_gulp = require("./gulp.js");
|
|
4
|
-
const require_postcss = require("./postcss.js");
|
|
5
|
-
const require_vite = require("./vite-
|
|
6
|
-
const require_webpack = require("./webpack-
|
|
7
|
-
exports.UnifiedViteWeappTailwindcssPlugin = require_vite.UnifiedViteWeappTailwindcssPlugin;
|
|
4
|
+
const require_postcss = require("./postcss-BdcRlSpp.js");
|
|
5
|
+
const require_vite = require("./vite-BEj9JOOA.js");
|
|
6
|
+
const require_webpack = require("./webpack-Dm1IXTIh.js");
|
|
8
7
|
exports.UnifiedWebpackPluginV5 = require_webpack.UnifiedWebpackPluginV5;
|
|
8
|
+
exports.WeappTailwindcss = require_vite.WeappTailwindcss;
|
|
9
9
|
exports.createPlugins = require_gulp.createPlugins;
|
|
10
10
|
exports.createWeappTailwindcssGenerator = require_generator.createWeappTailwindcssGenerator;
|
|
11
11
|
exports.weappTailwindcssPackageDir = require_webpack.weappTailwindcssPackageDir;
|
|
12
|
-
exports.weappTailwindcssPostcssPlugin = require_postcss;
|
|
12
|
+
exports.weappTailwindcssPostcssPlugin = require_postcss.weappTailwindcssPostcssPlugin;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as createWeappTailwindcssGenerator } from "./generator-
|
|
1
|
+
import { t as createWeappTailwindcssGenerator } from "./generator-CahkD2vq.mjs";
|
|
2
2
|
import { WeappTailwindcss as createPlugins } from "./gulp.mjs";
|
|
3
|
-
import weappTailwindcssPostcssPlugin from "./postcss.mjs";
|
|
4
|
-
import { t as
|
|
5
|
-
import { n as weappTailwindcssPackageDir, t as UnifiedWebpackPluginV5 } from "./webpack-
|
|
6
|
-
export {
|
|
3
|
+
import { t as weappTailwindcssPostcssPlugin } from "./postcss-xZDiTRII.mjs";
|
|
4
|
+
import { t as WeappTailwindcss } from "./vite-C8S1wfyQ.mjs";
|
|
5
|
+
import { n as weappTailwindcssPackageDir, t as UnifiedWebpackPluginV5 } from "./webpack-ZGIKKpFf.mjs";
|
|
6
|
+
export { UnifiedWebpackPluginV5, WeappTailwindcss, createPlugins, createWeappTailwindcssGenerator, weappTailwindcssPackageDir, weappTailwindcssPostcssPlugin };
|
package/dist/js/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CreateJsHandlerOptions, JsHandler } from '../types';
|
|
2
2
|
import { jsHandler } from './babel';
|
|
3
3
|
export { jsHandler, };
|
|
4
|
+
export { transformLiteralText } from './literal-transform';
|
|
4
5
|
export declare function createJsHandler(options: CreateJsHandlerOptions): JsHandler;
|
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;
|
|
@@ -3,7 +3,7 @@ import type { SelectorComponent } from 'lightningcss';
|
|
|
3
3
|
type CustomAtRules = Record<string, never>;
|
|
4
4
|
export interface SelectorTransformContext {
|
|
5
5
|
options: IStyleHandlerOptions;
|
|
6
|
-
childCombinatorReplacement?: SelectorComponent[];
|
|
6
|
+
childCombinatorReplacement?: SelectorComponent[] | undefined;
|
|
7
7
|
}
|
|
8
8
|
export declare function buildChildCombinatorReplacement(options: IStyleHandlerOptions): SelectorComponent[] | undefined;
|
|
9
9
|
export declare function createVisitor(ctx: SelectorTransformContext): import("lightningcss").Visitor<CustomAtRules>;
|
|
@@ -3,12 +3,12 @@ import type { TransformOptions, Warning } from 'lightningcss';
|
|
|
3
3
|
type CustomAtRules = Record<string, never>;
|
|
4
4
|
export interface LightningcssStyleHandlerResult {
|
|
5
5
|
code: string;
|
|
6
|
-
map?: string;
|
|
6
|
+
map?: string | undefined;
|
|
7
7
|
warnings: Warning[];
|
|
8
8
|
}
|
|
9
9
|
export interface LightningcssTransformConfig {
|
|
10
|
-
filename?: string;
|
|
11
|
-
transformOptions?: Omit<TransformOptions<CustomAtRules>, 'filename' | 'code' | 'visitor'
|
|
10
|
+
filename?: string | undefined;
|
|
11
|
+
transformOptions?: Omit<TransformOptions<CustomAtRules>, 'filename' | 'code' | 'visitor'> | undefined;
|
|
12
12
|
}
|
|
13
13
|
interface LightningcssStyleHandler {
|
|
14
14
|
(rawSource: string, overrideOptions?: Partial<IStyleHandlerOptions>): Promise<LightningcssStyleHandlerResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require("@weapp-tailwindcss/logger");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function prependConfigDirective(css: string, config: string | undefined): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Result, Root } from 'postcss';
|
|
2
|
+
import type { WeappTailwindcssGenerateResult } from '../generator';
|
|
3
|
+
import type { WeappTailwindcssPostcssPluginOptions } from '../postcss';
|
|
4
|
+
export declare function resolveInputFile(result: Result): string | undefined;
|
|
5
|
+
export declare function resolvePostcssBase(result: Result, options: WeappTailwindcssPostcssPluginOptions): string;
|
|
6
|
+
export declare function resolvePostcssProjectRoot(result: Result, options: WeappTailwindcssPostcssPluginOptions): string;
|
|
7
|
+
export declare function replaceRootCss(root: Root, css: string, result: Result): void;
|
|
8
|
+
export declare function addDependencyMessages(result: Result, generated: WeappTailwindcssGenerateResult): void;
|
|
9
|
+
export declare function addSourceDependencyMessages(result: Result, files: string[]): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Result, Root } from 'postcss';
|
|
2
|
+
import type { TailwindV4CandidateSource } from '../generator';
|
|
3
|
+
import type { WeappTailwindcssPostcssPluginOptions } from '../postcss';
|
|
4
|
+
export declare function collectAutoTailwindCandidates(root: Root, result: Result, options: WeappTailwindcssPostcssPluginOptions): Promise<Set<string>>;
|
|
5
|
+
export declare function collectPostcssLocalSources(root: Root, result: Result, options: WeappTailwindcssPostcssPluginOptions): Promise<{
|
|
6
|
+
files: string[];
|
|
7
|
+
sources: TailwindV4CandidateSource[];
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Result, Root } from 'postcss';
|
|
2
|
+
import type { WeappTailwindcssPostcssPluginOptions } from '../postcss';
|
|
3
|
+
export declare function resolvePostcssTailwindVersion(root: Root, result: Result, options: WeappTailwindcssPostcssPluginOptions): import("../tailwindcss/version").SupportedTailwindcssMajorVersion;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
+
const require_cache = require("./cache-B_9E7FxF.js");
|
|
3
|
+
const require_generator = require("./generator-Ck1Dd1V0.js");
|
|
4
|
+
const require_source_scan = require("./source-scan-CIVTa3Cj.js");
|
|
5
|
+
let postcss = require("postcss");
|
|
6
|
+
postcss = require_chunk.__toESM(postcss);
|
|
7
|
+
let node_path = require("node:path");
|
|
8
|
+
node_path = require_chunk.__toESM(node_path);
|
|
9
|
+
let node_process = require("node:process");
|
|
10
|
+
node_process = require_chunk.__toESM(node_process);
|
|
11
|
+
let tailwindcss_patch = require("tailwindcss-patch");
|
|
12
|
+
let tailwindcss_config = require("tailwindcss-config");
|
|
13
|
+
let node_fs_promises = require("node:fs/promises");
|
|
14
|
+
//#region src/postcss/config-directive.ts
|
|
15
|
+
function quoteCssString(value) {
|
|
16
|
+
return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
|
|
17
|
+
}
|
|
18
|
+
function toCssPath(value) {
|
|
19
|
+
return value.replaceAll("\\", "/");
|
|
20
|
+
}
|
|
21
|
+
function prependConfigDirective(css, config) {
|
|
22
|
+
if (!config || /@config\s+/.test(css)) return css;
|
|
23
|
+
return `@config "${quoteCssString(toCssPath(config))}";\n${css}`;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/postcss/context.ts
|
|
27
|
+
const PLUGIN_NAME$1 = "weapp-tailwindcss";
|
|
28
|
+
function resolveInputFile(result) {
|
|
29
|
+
const from = result.opts.from;
|
|
30
|
+
if (typeof from !== "string" || from.length === 0) return;
|
|
31
|
+
return node_path.default.isAbsolute(from) ? from : node_path.default.resolve(node_process.default.cwd(), from);
|
|
32
|
+
}
|
|
33
|
+
function resolvePostcssBase(result, options) {
|
|
34
|
+
if (options.base) return options.base;
|
|
35
|
+
const inputFile = resolveInputFile(result);
|
|
36
|
+
return inputFile ? node_path.default.dirname(inputFile) : node_process.default.cwd();
|
|
37
|
+
}
|
|
38
|
+
function resolvePostcssProjectRoot(result, options) {
|
|
39
|
+
if (options.projectRoot) return options.projectRoot;
|
|
40
|
+
const inputFile = resolveInputFile(result);
|
|
41
|
+
return inputFile ? node_path.default.dirname(inputFile) : node_process.default.cwd();
|
|
42
|
+
}
|
|
43
|
+
function replaceRootCss(root, css, result) {
|
|
44
|
+
root.removeAll();
|
|
45
|
+
try {
|
|
46
|
+
const nextRoot = postcss.default.parse(css, { from: resolveInputFile(result) });
|
|
47
|
+
root.append(nextRoot.nodes);
|
|
48
|
+
} catch {
|
|
49
|
+
root.raws = { after: css };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function addDependencyMessages(result, generated) {
|
|
53
|
+
for (const file of generated.dependencies) result.messages.push({
|
|
54
|
+
type: "dependency",
|
|
55
|
+
plugin: PLUGIN_NAME$1,
|
|
56
|
+
file
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function addSourceDependencyMessages(result, files) {
|
|
60
|
+
for (const file of files) result.messages.push({
|
|
61
|
+
type: "dependency",
|
|
62
|
+
plugin: PLUGIN_NAME$1,
|
|
63
|
+
file
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/postcss/source-files.ts
|
|
68
|
+
const POSTCSS_SOURCE_PATTERN = require_source_scan.createSourceScanPattern([
|
|
69
|
+
"html",
|
|
70
|
+
"wxml",
|
|
71
|
+
"axml",
|
|
72
|
+
"jxml",
|
|
73
|
+
"ksml",
|
|
74
|
+
"ttml",
|
|
75
|
+
"qml",
|
|
76
|
+
"tyml",
|
|
77
|
+
"xhsml",
|
|
78
|
+
"swan",
|
|
79
|
+
"vue",
|
|
80
|
+
"mpx",
|
|
81
|
+
"js",
|
|
82
|
+
"jsx",
|
|
83
|
+
"ts",
|
|
84
|
+
"tsx"
|
|
85
|
+
]);
|
|
86
|
+
function getSourceExtension(file) {
|
|
87
|
+
return node_path.default.extname(file).slice(1) || void 0;
|
|
88
|
+
}
|
|
89
|
+
function collectConfigPaths(root, base) {
|
|
90
|
+
const configPaths = [];
|
|
91
|
+
root.walkAtRules("config", (rule) => {
|
|
92
|
+
const configPath = require_source_scan.parseConfigParam(rule.params);
|
|
93
|
+
if (configPath) configPaths.push(node_path.default.isAbsolute(configPath) ? configPath : node_path.default.resolve(base, configPath));
|
|
94
|
+
});
|
|
95
|
+
return [...new Set(configPaths)];
|
|
96
|
+
}
|
|
97
|
+
function resolveOptionConfigPath(config, base) {
|
|
98
|
+
if (!config) return;
|
|
99
|
+
return node_path.default.isAbsolute(config) ? config : node_path.default.resolve(base, config);
|
|
100
|
+
}
|
|
101
|
+
async function collectConfigContentFiles(root, base, options) {
|
|
102
|
+
const configPaths = [...new Set([...resolveOptionConfigPath(options.config, base) ? [resolveOptionConfigPath(options.config, base)] : [], ...collectConfigPaths(root, base)])];
|
|
103
|
+
const files = [];
|
|
104
|
+
for (const configPath of configPaths) {
|
|
105
|
+
const contentEntries = require_source_scan.normalizeLegacyContentEntries((await (0, tailwindcss_config.loadConfig)({
|
|
106
|
+
config: configPath,
|
|
107
|
+
cwd: node_path.default.dirname(configPath)
|
|
108
|
+
}))?.config.content, node_path.default.dirname(configPath));
|
|
109
|
+
files.push(...await require_source_scan.expandTailwindSourceEntries(contentEntries));
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
configPaths,
|
|
113
|
+
files: [...new Set(files)]
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
async function collectConfiguredContentEntries(root, base, options) {
|
|
117
|
+
const configPath = resolveOptionConfigPath(options.config, base) ?? collectConfigPaths(root, base)[0];
|
|
118
|
+
if (!configPath) return [];
|
|
119
|
+
const resolvedConfigPath = node_path.default.isAbsolute(configPath) ? configPath : node_path.default.resolve(base, configPath);
|
|
120
|
+
return require_source_scan.normalizeLegacyContentEntries((await (0, tailwindcss_config.loadConfig)({
|
|
121
|
+
config: resolvedConfigPath,
|
|
122
|
+
cwd: node_path.default.dirname(resolvedConfigPath)
|
|
123
|
+
}))?.config.content, node_path.default.dirname(resolvedConfigPath));
|
|
124
|
+
}
|
|
125
|
+
async function collectAutoTailwindCandidates(root, result, options) {
|
|
126
|
+
if (options.scanSources === false) return /* @__PURE__ */ new Set();
|
|
127
|
+
const base = resolvePostcssBase(result, options);
|
|
128
|
+
const projectRoot = resolvePostcssProjectRoot(result, options);
|
|
129
|
+
const sourceEntries = [];
|
|
130
|
+
const hasSourceNone = root.toString().includes("source(none)");
|
|
131
|
+
const inlineCandidates = require_source_scan.collectCssInlineSourceCandidates(root);
|
|
132
|
+
const configuredContentEntries = options.version === 3 ? await collectConfiguredContentEntries(root, base, options) : [];
|
|
133
|
+
if (configuredContentEntries.length > 0) sourceEntries.push(...configuredContentEntries);
|
|
134
|
+
else if (!hasSourceNone) sourceEntries.push({
|
|
135
|
+
base,
|
|
136
|
+
negated: false,
|
|
137
|
+
pattern: POSTCSS_SOURCE_PATTERN
|
|
138
|
+
});
|
|
139
|
+
sourceEntries.push(...await require_source_scan.resolveCssSourceEntries(root, base, POSTCSS_SOURCE_PATTERN));
|
|
140
|
+
const candidates = sourceEntries.length === 0 ? [] : await (0, tailwindcss_patch.extractValidCandidates)({
|
|
141
|
+
base,
|
|
142
|
+
css: root.toString(),
|
|
143
|
+
cwd: projectRoot,
|
|
144
|
+
sources: sourceEntries
|
|
145
|
+
});
|
|
146
|
+
return new Set([...candidates.filter((candidate) => !inlineCandidates.excluded.has(candidate)), ...inlineCandidates.included]);
|
|
147
|
+
}
|
|
148
|
+
async function collectPostcssLocalSources(root, result, options) {
|
|
149
|
+
const base = resolvePostcssBase(result, options);
|
|
150
|
+
const sourceEntries = await require_source_scan.resolveCssSourceEntries(root, base, POSTCSS_SOURCE_PATTERN);
|
|
151
|
+
const configContentFiles = await collectConfigContentFiles(root, base, options);
|
|
152
|
+
const files = [...new Set([...await require_source_scan.expandTailwindSourceEntries(sourceEntries), ...configContentFiles.files])];
|
|
153
|
+
const sources = await Promise.all(files.map(async (file) => {
|
|
154
|
+
const extension = getSourceExtension(file);
|
|
155
|
+
return {
|
|
156
|
+
content: await (0, node_fs_promises.readFile)(file, "utf8"),
|
|
157
|
+
...extension === void 0 ? {} : { extension }
|
|
158
|
+
};
|
|
159
|
+
}));
|
|
160
|
+
return {
|
|
161
|
+
files: [...files, ...configContentFiles.configPaths],
|
|
162
|
+
sources
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/postcss/tailwind-version.ts
|
|
167
|
+
function hasTailwindV4CssSyntax(root) {
|
|
168
|
+
let hasV4Syntax = false;
|
|
169
|
+
root.walkAtRules((rule) => {
|
|
170
|
+
if (rule.name === "theme" || rule.name === "source" || rule.name === "custom-variant") hasV4Syntax = true;
|
|
171
|
+
if (rule.name === "import" && /(['"])tailwindcss\1/.test(rule.params)) hasV4Syntax = true;
|
|
172
|
+
});
|
|
173
|
+
return hasV4Syntax;
|
|
174
|
+
}
|
|
175
|
+
function resolvePostcssTailwindVersion(root, result, options) {
|
|
176
|
+
const packageName = options.packageName ?? "tailwindcss";
|
|
177
|
+
const installedVersion = require_cache.readInstalledPackageMajorVersion(packageName, resolvePostcssProjectRoot(result, options));
|
|
178
|
+
if (installedVersion) return installedVersion;
|
|
179
|
+
if (options.version) return options.version;
|
|
180
|
+
if (packageName === "@tailwindcss/postcss" || packageName.includes("tailwindcss4")) return 4;
|
|
181
|
+
if (packageName.includes("tailwindcss3")) return 3;
|
|
182
|
+
if (hasTailwindV4CssSyntax(root)) return 4;
|
|
183
|
+
return 4;
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/postcss.ts
|
|
187
|
+
const PLUGIN_NAME = "weapp-tailwindcss";
|
|
188
|
+
const weappTailwindcssPostcssPlugin = (options = {}) => {
|
|
189
|
+
return {
|
|
190
|
+
postcssPlugin: PLUGIN_NAME,
|
|
191
|
+
async Once(root, { result }) {
|
|
192
|
+
const { candidates, generator: userGeneratorOptions, scanSources, sources, styleOptions, ...sourceOptions } = options;
|
|
193
|
+
const generatorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions(userGeneratorOptions);
|
|
194
|
+
const tailwindVersion = resolvePostcssTailwindVersion(root, result, options);
|
|
195
|
+
const [collectedSources, autoCandidates] = await Promise.all([collectPostcssLocalSources(root, result, options), collectAutoTailwindCandidates(root, result, options)]);
|
|
196
|
+
const generatorConfig = generatorOptions.config ?? options.config;
|
|
197
|
+
const generator = require_generator.createWeappTailwindcssGenerator(tailwindVersion === 3 ? await require_generator.resolveTailwindV3Source({
|
|
198
|
+
config: generatorConfig,
|
|
199
|
+
css: sourceOptions.css ?? root.toString(),
|
|
200
|
+
base: resolvePostcssBase(result, options),
|
|
201
|
+
cwd: resolvePostcssProjectRoot(result, options),
|
|
202
|
+
projectRoot: resolvePostcssProjectRoot(result, options),
|
|
203
|
+
packageName: options.packageName,
|
|
204
|
+
postcssPlugin: options.postcssPlugin
|
|
205
|
+
}) : await require_generator.resolveTailwindV4Source({
|
|
206
|
+
...sourceOptions,
|
|
207
|
+
css: prependConfigDirective(sourceOptions.css ?? root.toString(), generatorConfig),
|
|
208
|
+
base: resolvePostcssBase(result, options),
|
|
209
|
+
projectRoot: resolvePostcssProjectRoot(result, options)
|
|
210
|
+
}));
|
|
211
|
+
const generateOptions = {
|
|
212
|
+
candidates: new Set([...autoCandidates, ...candidates ?? []]),
|
|
213
|
+
scanSources: scanSources ?? false,
|
|
214
|
+
sources: [...collectedSources.sources, ...sources ?? []],
|
|
215
|
+
styleOptions: {
|
|
216
|
+
...generatorOptions.styleOptions,
|
|
217
|
+
...styleOptions
|
|
218
|
+
},
|
|
219
|
+
tailwindcssV3Compatibility: generatorOptions.tailwindcssV3Compatibility,
|
|
220
|
+
target: generatorOptions.target
|
|
221
|
+
};
|
|
222
|
+
const generated = await generator.generate(generateOptions);
|
|
223
|
+
replaceRootCss(root, generated.css, result);
|
|
224
|
+
addDependencyMessages(result, generated);
|
|
225
|
+
addSourceDependencyMessages(result, collectedSources.files);
|
|
226
|
+
result.messages.push({
|
|
227
|
+
type: "weapp-tailwindcss:generated",
|
|
228
|
+
plugin: PLUGIN_NAME,
|
|
229
|
+
target: generated.target,
|
|
230
|
+
classSet: generated.classSet,
|
|
231
|
+
rawCss: generated.rawCss
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
weappTailwindcssPostcssPlugin.postcss = true;
|
|
237
|
+
//#endregion
|
|
238
|
+
Object.defineProperty(exports, "weappTailwindcssPostcssPlugin", {
|
|
239
|
+
enumerable: true,
|
|
240
|
+
get: function() {
|
|
241
|
+
return weappTailwindcssPostcssPlugin;
|
|
242
|
+
}
|
|
243
|
+
});
|