@weapp-tailwindcss/experimental 0.0.1 → 0.0.2-next.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 ADDED
@@ -0,0 +1,99 @@
1
+ <p align="center">
2
+
3
+ <a href="https://tw.icebreaker.top">
4
+
5
+ <img src="./assets/logo.png" alt="weapp-tailwindcss-logo" width="128">
6
+ </a>
7
+
8
+ <br>
9
+
10
+ <h1 align="center">weapp-tailwindcss</h1>
11
+
12
+ </p>
13
+
14
+ > 简体中文(zh-cn) | [English](./README_en.md)
15
+
16
+ ![star](https://badgen.net/github/stars/sonofmagic/weapp-tailwindcss)
17
+ ![dm0](https://badgen.net/npm/dm/weapp-tailwindcss)
18
+ ![license](https://badgen.net/npm/license/weapp-tailwindcss)
19
+ [![test](https://github.com/sonofmagic/weapp-tailwindcss/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/sonofmagic/weapp-tailwindcss/actions/workflows/test.yml)
20
+ [![codecov](https://codecov.io/gh/sonofmagic/weapp-tailwindcss/branch/main/graph/badge.svg?token=zn05qXYznt)](https://codecov.io/gh/sonofmagic/weapp-tailwindcss)
21
+
22
+ > [!NOTE]
23
+ > 降低开发维护成本,提升开发效率的 `小程序` `tailwindcss` 全方面解决方案
24
+ >
25
+ > `weapp-tailwindcss@4.2.x` 现已支持 `uni-app x` 同时构建 `Web`,`小程序`,`安卓`,`IOS`,`鸿蒙`,详见 [**uni-app x 专题**](https://tw.icebreaker.top/docs/uni-app-x)
26
+
27
+ \[[文档地址](https://tw.icebreaker.top)\] \| \[[备用文档地址](https://ice-tw.netlify.app/)\] \| \[[加入技术交流群](https://tw.icebreaker.top/docs/community/group)\]
28
+
29
+ - [特性](#特性)
30
+ - [版本对应](#版本对应)
31
+ - [安装与使用方式](#安装与使用方式)
32
+ - [生态和解决方案](#生态和解决方案)
33
+ - [常见问题](#常见问题)
34
+ - [各个框架的模板](#各个框架的模板)
35
+ - [旧版本迁移指南](#旧版本迁移指南)
36
+ - [配置项参考](#配置项参考)
37
+ - [Contribute](#contribute)
38
+ - [License](#license)
39
+ - [Star History](#star-history)
40
+ - [Related projects](#related-projects)
41
+ - [weapp-vite](#weapp-vite)
42
+
43
+ ## 特性
44
+
45
+ | 不仅仅是`webpack` | 主流框架与原生开发支持 |
46
+ | --------------------------------------------------- | ----------------------------------------------- |
47
+ | ![wepback+vite+gulp](./assets/weapp-tw-plugins.png) | ![frameworks](./assets/weapp-tw-frameworks.png) |
48
+
49
+ 核心插件支持 `webpack`/`vite`/`rspack`/`rollup`/`rolldown`/`gulp` 为基底的框架类小程序开发,涵盖了市面上几乎所有的主流的开发框架。
50
+
51
+ 也支持直接从各个开发者工具中,直接创建的原生小程序应用。
52
+
53
+ 这些插件能够自动识别并精确处理所有 `tailwindcss` 的工具类来适配小程序环境。
54
+
55
+ ## 版本对应
56
+
57
+ 目前,`weapp-tailwindcss` 的 `5.x` 版本
58
+
59
+ - 支持最新版本的 `tailwindcss v4` 和 `v3`。
60
+ - 支持 `webpack5`、`vite`、`rspack`、`rollup`、`rolldown` 和 `gulp` 这些打包工具,也支持纯 `Nodejs` API 的方式,集成到你自己的构建工具中。
61
+
62
+ > `weapp-tailwindcss@5` 面向 Tailwind CSS v3/v4 和现代构建链路,不再内置 Webpack4、PostCSS7、Tailwind CSS v2 兼容入口。`weapp-tailwindcss@5` 需要 `nodejs` 版本 `^20.19.0 || >=22.12.0`,建议安装 `nodejs` 的 `LTS` 版本,详见 [nodejs/release](https://github.com/nodejs/release)
63
+
64
+ ## [安装与使用方式](https://tw.icebreaker.top/docs/quick-start/install)
65
+
66
+ ## [生态和解决方案](https://tw.icebreaker.top/docs/community/templates)
67
+
68
+ ## [常见问题](https://tw.icebreaker.top/docs/issues/)
69
+
70
+ ## [各个框架的模板](https://tw.icebreaker.top/docs/community/templates)
71
+
72
+ ## [旧版本迁移指南](https://tw.icebreaker.top/docs/migrations/v2)
73
+
74
+ ## [配置项参考](https://tw.icebreaker.top/docs/api/interfaces/UserDefinedOptions)
75
+
76
+ ## Contribute
77
+
78
+ 我们邀请你来贡献和帮助改进 `weapp-tailwindcss` 💚💚💚
79
+
80
+ 以下有几个方式可以参与:
81
+
82
+ - 报告错误:如果您遇到任何错误或问题,请提`issue`并提供完善的错误信息和复现方式。
83
+ - 建议:有增强 `weapp-tailwindcss` 的想法吗?请提 `issue` 来分享您的建议。
84
+ - 文档:如果您对文档有更好的见解或者更棒的修辞方式,欢迎 `pr`。
85
+ - 代码:任何人的代码都不是完美的,我们欢迎你通过 `pr` 给代码提供更好的质量与活力。
86
+
87
+ ## License
88
+
89
+ [MIT](./LICENSE)
90
+
91
+ ## Star History
92
+
93
+ [![Star History Chart](https://api.star-history.com/svg?repos=sonofmagic/weapp-tailwindcss&type=Date)](https://star-history.com/#sonofmagic/weapp-tailwindcss&Date)
94
+
95
+ ## Related projects
96
+
97
+ ### weapp-vite
98
+
99
+ [weapp-vite](https://vite.icebreaker.top/): 把现代化的开发模式带入小程序开发!
@@ -0,0 +1,51 @@
1
+ import { IStyleHandlerOptions } from "@weapp-tailwindcss/postcss";
2
+ import * as _$lightningcss from "lightningcss";
3
+ import { Selector, SelectorComponent, TransformOptions, Warning } from "lightningcss";
4
+ import { Buffer } from "node:buffer";
5
+
6
+ //#region src/lightningcss/options.d.ts
7
+ declare function createRootSpecificityReplacer(options: IStyleHandlerOptions): ((code: string) => string) | undefined;
8
+ declare function prepareStyleOptions(options?: Partial<IStyleHandlerOptions>): IStyleHandlerOptions;
9
+ //#endregion
10
+ //#region src/lightningcss/selector-transform.d.ts
11
+ type CustomAtRules$1 = Record<string, never>;
12
+ interface SelectorTransformContext {
13
+ options: IStyleHandlerOptions;
14
+ childCombinatorReplacement?: SelectorComponent[] | undefined;
15
+ }
16
+ declare function buildChildCombinatorReplacement(options: IStyleHandlerOptions): SelectorComponent[] | undefined;
17
+ declare function createVisitor(ctx: SelectorTransformContext): _$lightningcss.Visitor<CustomAtRules$1>;
18
+ //#endregion
19
+ //#region src/lightningcss/selector-utils.d.ts
20
+ declare function createTypeSelector(name: string): SelectorComponent;
21
+ declare function cloneComponent<T>(value: T): T;
22
+ declare function cloneComponents(list: SelectorComponent[]): SelectorComponent[];
23
+ declare function normalizeNestedSelectors(selectors: Selector[] | Selector | null | undefined): Selector[] | undefined;
24
+ declare function assignNestedSelectors(target: SelectorComponent & {
25
+ selectors?: Selector[] | Selector | null;
26
+ }, value: Selector[] | undefined): void;
27
+ declare function trimCombinators(components: SelectorComponent[]): SelectorComponent[];
28
+ declare function matchesHiddenNot(component: SelectorComponent | undefined): boolean;
29
+ //#endregion
30
+ //#region src/lightningcss/index.d.ts
31
+ type CustomAtRules = Record<string, never>;
32
+ interface LightningcssStyleHandlerResult {
33
+ code: string;
34
+ map?: string | undefined;
35
+ warnings: Warning[];
36
+ }
37
+ interface LightningcssTransformConfig {
38
+ filename?: string | undefined;
39
+ transformOptions?: Omit<TransformOptions<CustomAtRules>, 'filename' | 'code' | 'visitor'> | undefined;
40
+ }
41
+ interface LightningcssStyleHandler {
42
+ (rawSource: string, overrideOptions?: Partial<IStyleHandlerOptions>): Promise<LightningcssStyleHandlerResult>;
43
+ }
44
+ declare function createLightningcssStyleHandler(options?: Partial<IStyleHandlerOptions>, config?: LightningcssTransformConfig): LightningcssStyleHandler;
45
+ declare function transformCss(css?: string | Buffer): Promise<{
46
+ code: Buffer<ArrayBuffer>;
47
+ map: Buffer<ArrayBuffer> | undefined;
48
+ warnings: Warning[];
49
+ }>;
50
+ //#endregion
51
+ export { assignNestedSelectors as a, createTypeSelector as c, trimCombinators as d, SelectorTransformContext as f, prepareStyleOptions as g, createRootSpecificityReplacer as h, transformCss as i, matchesHiddenNot as l, createVisitor as m, LightningcssTransformConfig as n, cloneComponent as o, buildChildCombinatorReplacement as p, createLightningcssStyleHandler as r, cloneComponents as s, LightningcssStyleHandlerResult as t, normalizeNestedSelectors as u };
@@ -0,0 +1,51 @@
1
+ import { Buffer } from "node:buffer";
2
+ import * as _$lightningcss from "lightningcss";
3
+ import { Selector, SelectorComponent, TransformOptions, Warning } from "lightningcss";
4
+ import { IStyleHandlerOptions } from "@weapp-tailwindcss/postcss";
5
+
6
+ //#region src/lightningcss/options.d.ts
7
+ declare function createRootSpecificityReplacer(options: IStyleHandlerOptions): ((code: string) => string) | undefined;
8
+ declare function prepareStyleOptions(options?: Partial<IStyleHandlerOptions>): IStyleHandlerOptions;
9
+ //#endregion
10
+ //#region src/lightningcss/selector-transform.d.ts
11
+ type CustomAtRules$1 = Record<string, never>;
12
+ interface SelectorTransformContext {
13
+ options: IStyleHandlerOptions;
14
+ childCombinatorReplacement?: SelectorComponent[] | undefined;
15
+ }
16
+ declare function buildChildCombinatorReplacement(options: IStyleHandlerOptions): SelectorComponent[] | undefined;
17
+ declare function createVisitor(ctx: SelectorTransformContext): _$lightningcss.Visitor<CustomAtRules$1>;
18
+ //#endregion
19
+ //#region src/lightningcss/selector-utils.d.ts
20
+ declare function createTypeSelector(name: string): SelectorComponent;
21
+ declare function cloneComponent<T>(value: T): T;
22
+ declare function cloneComponents(list: SelectorComponent[]): SelectorComponent[];
23
+ declare function normalizeNestedSelectors(selectors: Selector[] | Selector | null | undefined): Selector[] | undefined;
24
+ declare function assignNestedSelectors(target: SelectorComponent & {
25
+ selectors?: Selector[] | Selector | null;
26
+ }, value: Selector[] | undefined): void;
27
+ declare function trimCombinators(components: SelectorComponent[]): SelectorComponent[];
28
+ declare function matchesHiddenNot(component: SelectorComponent | undefined): boolean;
29
+ //#endregion
30
+ //#region src/lightningcss/index.d.ts
31
+ type CustomAtRules = Record<string, never>;
32
+ interface LightningcssStyleHandlerResult {
33
+ code: string;
34
+ map?: string | undefined;
35
+ warnings: Warning[];
36
+ }
37
+ interface LightningcssTransformConfig {
38
+ filename?: string | undefined;
39
+ transformOptions?: Omit<TransformOptions<CustomAtRules>, 'filename' | 'code' | 'visitor'> | undefined;
40
+ }
41
+ interface LightningcssStyleHandler {
42
+ (rawSource: string, overrideOptions?: Partial<IStyleHandlerOptions>): Promise<LightningcssStyleHandlerResult>;
43
+ }
44
+ declare function createLightningcssStyleHandler(options?: Partial<IStyleHandlerOptions>, config?: LightningcssTransformConfig): LightningcssStyleHandler;
45
+ declare function transformCss(css?: string | Buffer): Promise<{
46
+ code: Buffer<ArrayBuffer>;
47
+ map: Buffer<ArrayBuffer> | undefined;
48
+ warnings: Warning[];
49
+ }>;
50
+ //#endregion
51
+ export { assignNestedSelectors as a, createTypeSelector as c, trimCombinators as d, SelectorTransformContext as f, prepareStyleOptions as g, createRootSpecificityReplacer as h, transformCss as i, matchesHiddenNot as l, createVisitor as m, LightningcssTransformConfig as n, cloneComponent as o, buildChildCombinatorReplacement as p, createLightningcssStyleHandler as r, cloneComponents as s, LightningcssStyleHandlerResult as t, normalizeNestedSelectors as u };
package/dist/index.cjs CHANGED
@@ -1,2 +1,15 @@
1
- 'use strict';
2
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_lightningcss = require("./lightningcss-C8xst0tZ.cjs");
3
+ exports.assignNestedSelectors = require_lightningcss.assignNestedSelectors;
4
+ exports.buildChildCombinatorReplacement = require_lightningcss.buildChildCombinatorReplacement;
5
+ exports.cloneComponent = require_lightningcss.cloneComponent;
6
+ exports.cloneComponents = require_lightningcss.cloneComponents;
7
+ exports.createLightningcssStyleHandler = require_lightningcss.createLightningcssStyleHandler;
8
+ exports.createRootSpecificityReplacer = require_lightningcss.createRootSpecificityReplacer;
9
+ exports.createTypeSelector = require_lightningcss.createTypeSelector;
10
+ exports.createVisitor = require_lightningcss.createVisitor;
11
+ exports.matchesHiddenNot = require_lightningcss.matchesHiddenNot;
12
+ exports.normalizeNestedSelectors = require_lightningcss.normalizeNestedSelectors;
13
+ exports.prepareStyleOptions = require_lightningcss.prepareStyleOptions;
14
+ exports.transformCss = require_lightningcss.transformCss;
15
+ exports.trimCombinators = require_lightningcss.trimCombinators;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
-
2
- export { };
1
+ import { a as assignNestedSelectors, c as createTypeSelector, d as trimCombinators, f as SelectorTransformContext, g as prepareStyleOptions, h as createRootSpecificityReplacer, i as transformCss, l as matchesHiddenNot, m as createVisitor, n as LightningcssTransformConfig, o as cloneComponent, p as buildChildCombinatorReplacement, r as createLightningcssStyleHandler, s as cloneComponents, t as LightningcssStyleHandlerResult, u as normalizeNestedSelectors } from "./index-DFdHzWSy.js";
2
+ export { LightningcssStyleHandlerResult, LightningcssTransformConfig, SelectorTransformContext, assignNestedSelectors, buildChildCombinatorReplacement, cloneComponent, cloneComponents, createLightningcssStyleHandler, createRootSpecificityReplacer, createTypeSelector, createVisitor, matchesHiddenNot, normalizeNestedSelectors, prepareStyleOptions, transformCss, trimCombinators };
package/dist/index.mjs CHANGED
@@ -1 +1,2 @@
1
-
1
+ import { a as assignNestedSelectors, c as createTypeSelector, d as trimCombinators, f as createRootSpecificityReplacer, i as createVisitor, l as matchesHiddenNot, n as transformCss, o as cloneComponent, p as prepareStyleOptions, r as buildChildCombinatorReplacement, s as cloneComponents, t as createLightningcssStyleHandler, u as normalizeNestedSelectors } from "./lightningcss-hDwkBzeI.mjs";
2
+ export { assignNestedSelectors, buildChildCombinatorReplacement, cloneComponent, cloneComponents, createLightningcssStyleHandler, createRootSpecificityReplacer, createTypeSelector, createVisitor, matchesHiddenNot, normalizeNestedSelectors, prepareStyleOptions, transformCss, trimCombinators };
@@ -0,0 +1,15 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_lightningcss = require("../lightningcss-C8xst0tZ.cjs");
3
+ exports.assignNestedSelectors = require_lightningcss.assignNestedSelectors;
4
+ exports.buildChildCombinatorReplacement = require_lightningcss.buildChildCombinatorReplacement;
5
+ exports.cloneComponent = require_lightningcss.cloneComponent;
6
+ exports.cloneComponents = require_lightningcss.cloneComponents;
7
+ exports.createLightningcssStyleHandler = require_lightningcss.createLightningcssStyleHandler;
8
+ exports.createRootSpecificityReplacer = require_lightningcss.createRootSpecificityReplacer;
9
+ exports.createTypeSelector = require_lightningcss.createTypeSelector;
10
+ exports.createVisitor = require_lightningcss.createVisitor;
11
+ exports.matchesHiddenNot = require_lightningcss.matchesHiddenNot;
12
+ exports.normalizeNestedSelectors = require_lightningcss.normalizeNestedSelectors;
13
+ exports.prepareStyleOptions = require_lightningcss.prepareStyleOptions;
14
+ exports.transformCss = require_lightningcss.transformCss;
15
+ exports.trimCombinators = require_lightningcss.trimCombinators;
@@ -0,0 +1,2 @@
1
+ import { a as assignNestedSelectors, c as createTypeSelector, d as trimCombinators, f as SelectorTransformContext, g as prepareStyleOptions, h as createRootSpecificityReplacer, i as transformCss, l as matchesHiddenNot, m as createVisitor, n as LightningcssTransformConfig, o as cloneComponent, p as buildChildCombinatorReplacement, r as createLightningcssStyleHandler, s as cloneComponents, t as LightningcssStyleHandlerResult, u as normalizeNestedSelectors } from "../index-DFdHzWSy.js";
2
+ export { LightningcssStyleHandlerResult, LightningcssTransformConfig, SelectorTransformContext, assignNestedSelectors, buildChildCombinatorReplacement, cloneComponent, cloneComponents, createLightningcssStyleHandler, createRootSpecificityReplacer, createTypeSelector, createVisitor, matchesHiddenNot, normalizeNestedSelectors, prepareStyleOptions, transformCss, trimCombinators };
@@ -0,0 +1,2 @@
1
+ import { a as assignNestedSelectors, c as createTypeSelector, d as trimCombinators, f as createRootSpecificityReplacer, i as createVisitor, l as matchesHiddenNot, n as transformCss, o as cloneComponent, p as prepareStyleOptions, r as buildChildCombinatorReplacement, s as cloneComponents, t as createLightningcssStyleHandler, u as normalizeNestedSelectors } from "../lightningcss-hDwkBzeI.mjs";
2
+ export { assignNestedSelectors, buildChildCombinatorReplacement, cloneComponent, cloneComponents, createLightningcssStyleHandler, createRootSpecificityReplacer, createTypeSelector, createVisitor, matchesHiddenNot, normalizeNestedSelectors, prepareStyleOptions, transformCss, trimCombinators };
@@ -0,0 +1,374 @@
1
+ let node_buffer = require("node:buffer");
2
+ let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
3
+ let lightningcss = require("lightningcss");
4
+ let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
5
+ //#region src/lightningcss/options.ts
6
+ const FALLBACK_PLACEHOLDER_SUFFIXES = [":not(#n)", ":not(#\\#)"];
7
+ function normalizeSelectorList(value) {
8
+ if (value === void 0 || value === false) return [];
9
+ return Array.isArray(value) ? value.filter(Boolean) : [value];
10
+ }
11
+ function getSpecificityMatchingName(options) {
12
+ const feature = options.cssPresetEnv?.features?.["is-pseudo-class"];
13
+ if (feature && typeof feature === "object" && "specificityMatchingName" in feature) {
14
+ const specificityName = feature.specificityMatchingName;
15
+ return typeof specificityName === "string" && specificityName.length > 0 ? specificityName : void 0;
16
+ }
17
+ }
18
+ function createRootSpecificityReplacer(options) {
19
+ const specificityMatchingName = getSpecificityMatchingName(options);
20
+ const selectors = normalizeSelectorList(options.cssSelectorReplacement?.root);
21
+ const replaceFallbackPlaceholder = (code) => {
22
+ let output = code;
23
+ for (const suffix of FALLBACK_PLACEHOLDER_SUFFIXES) if (output.includes(suffix)) output = output.split(suffix).join("");
24
+ return output;
25
+ };
26
+ if (!specificityMatchingName || selectors.length === 0) return replaceFallbackPlaceholder;
27
+ const suffix = `:not(.${specificityMatchingName})`;
28
+ const targets = selectors.map((selector) => selector?.trim()).filter((selector) => Boolean(selector?.length)).map((selector) => ({
29
+ match: `${selector}${suffix}`,
30
+ spacedMatch: `${selector} ${suffix}`,
31
+ replacement: selector
32
+ }));
33
+ if (!targets.length) return;
34
+ return (code) => {
35
+ let output = replaceFallbackPlaceholder(code);
36
+ for (const target of targets) {
37
+ if (output.includes(target.match)) output = output.split(target.match).join(target.replacement);
38
+ if (output.includes(target.spacedMatch)) output = output.split(target.spacedMatch).join(target.replacement);
39
+ }
40
+ return output;
41
+ };
42
+ }
43
+ function getLightningDefaultOptions(options) {
44
+ const customPropertiesFeature = options?.cssPresetEnv?.features?.["custom-properties"];
45
+ return {
46
+ cssPresetEnv: {
47
+ features: {
48
+ "cascade-layers": true,
49
+ "is-pseudo-class": { specificityMatchingName: "weapp-tw-ig" },
50
+ "oklab-function": true,
51
+ "color-mix": true,
52
+ "custom-properties": customPropertiesFeature !== void 0 ? customPropertiesFeature : options?.cssCalc ? { preserve: true } : false
53
+ },
54
+ autoprefixer: { add: false }
55
+ },
56
+ cssRemoveProperty: true,
57
+ cssRemoveHoverPseudoClass: true,
58
+ cssChildCombinatorReplaceValue: ["view", "text"],
59
+ cssSelectorReplacement: {
60
+ root: [
61
+ "page",
62
+ ".tw-root",
63
+ "wx-root-portal-content"
64
+ ],
65
+ universal: ["view", "text"]
66
+ }
67
+ };
68
+ }
69
+ function prepareStyleOptions(options) {
70
+ const merged = (0, _weapp_tailwindcss_shared.defuOverrideArray)(options, getLightningDefaultOptions(options));
71
+ merged.cssInjectPreflight = (0, _weapp_tailwindcss_postcss.createInjectPreflight)(merged.cssPreflight);
72
+ return merged;
73
+ }
74
+ //#endregion
75
+ //#region src/lightningcss/selector-utils.ts
76
+ function createTypeSelector(name) {
77
+ return {
78
+ type: "type",
79
+ name
80
+ };
81
+ }
82
+ function cloneComponent(value) {
83
+ const structured = globalThis.structuredClone;
84
+ if (typeof structured === "function") return structured(value);
85
+ return JSON.parse(JSON.stringify(value));
86
+ }
87
+ function cloneComponents(list) {
88
+ return list.map(cloneComponent);
89
+ }
90
+ function normalizeNestedSelectors(selectors) {
91
+ if (!selectors) return;
92
+ if (Array.isArray(selectors)) {
93
+ if (selectors.length === 0) return [];
94
+ const first = selectors[0];
95
+ if (Array.isArray(first)) return selectors;
96
+ return [selectors];
97
+ }
98
+ return [selectors];
99
+ }
100
+ function assignNestedSelectors(target, value) {
101
+ if (!("selectors" in target)) return;
102
+ if (Array.isArray(target.selectors)) target.selectors = value ?? [];
103
+ else if (target.selectors && !Array.isArray(target.selectors)) target.selectors = value?.[0] ?? target.selectors;
104
+ }
105
+ function trimCombinators(components) {
106
+ let start = 0;
107
+ let end = components.length;
108
+ while (start < end && components[start]?.type === "combinator") start++;
109
+ while (end > start && components[end - 1]?.type === "combinator") end--;
110
+ return components.slice(start, end);
111
+ }
112
+ function matchesHiddenNot(component) {
113
+ if (!component || component.type !== "pseudo-class" || component.kind !== "not") return false;
114
+ const selectors = normalizeNestedSelectors(component.selectors);
115
+ if (!selectors || selectors.length !== 1) return false;
116
+ const [nestedSelector] = selectors;
117
+ if (!nestedSelector || nestedSelector.length !== 1) return false;
118
+ const [node] = nestedSelector;
119
+ if (!node) return false;
120
+ return node.type === "attribute" && node.name === "hidden" || node.type === "type" && node.name === "template";
121
+ }
122
+ //#endregion
123
+ //#region src/lightningcss/selector-transform.ts
124
+ function buildSelectorReplacement(value) {
125
+ if (!value) return null;
126
+ const targets = Array.isArray(value) ? value : [value];
127
+ if (!targets.length) return null;
128
+ if (targets.length === 1) return [createTypeSelector(targets[0])];
129
+ return [{
130
+ type: "pseudo-class",
131
+ kind: "is",
132
+ selectors: targets.map((name) => [createTypeSelector(name)])
133
+ }];
134
+ }
135
+ function buildChildCombinatorReplacement(options) {
136
+ const { cssChildCombinatorReplaceValue } = options;
137
+ if (!cssChildCombinatorReplaceValue) return;
138
+ const normalized = Array.isArray(cssChildCombinatorReplaceValue) ? cssChildCombinatorReplaceValue : [cssChildCombinatorReplaceValue];
139
+ if (!normalized.length) return;
140
+ const baseComponents = buildSelectorReplacement(normalized) ?? [createTypeSelector("view")];
141
+ const left = cloneComponents(baseComponents);
142
+ const right = cloneComponents(baseComponents);
143
+ return [
144
+ ...left,
145
+ {
146
+ type: "combinator",
147
+ value: "next-sibling"
148
+ },
149
+ ...right
150
+ ];
151
+ }
152
+ function transformSelectorComponent(component, ctx, transformList) {
153
+ const { options } = ctx;
154
+ if (component.type === "class") {
155
+ const cloned = cloneComponent(component);
156
+ cloned.name = (0, _weapp_tailwindcss_postcss.internalCssSelectorReplacer)(component.name, { escapeMap: options.escapeMap });
157
+ return [cloned];
158
+ }
159
+ if (component.type === "universal") {
160
+ const replacement = buildSelectorReplacement(options.cssSelectorReplacement?.universal);
161
+ if (replacement) return cloneComponents(replacement);
162
+ return [cloneComponent(component)];
163
+ }
164
+ if (component.type === "type") {
165
+ if (options.uniAppX) return [];
166
+ return [cloneComponent(component)];
167
+ }
168
+ if (component.type === "attribute") {
169
+ if (options.uniAppX) return [];
170
+ return [cloneComponent(component)];
171
+ }
172
+ if (component.type === "combinator") return [cloneComponent(component)];
173
+ if (component.type === "pseudo-element") return [cloneComponent(component)];
174
+ if (component.type === "pseudo-class") {
175
+ if (component.kind === "hover" && options.cssRemoveHoverPseudoClass) return null;
176
+ if (component.kind === "root") {
177
+ const replacement = buildSelectorReplacement(options.cssSelectorReplacement?.root);
178
+ if (replacement) return cloneComponents(replacement);
179
+ return [cloneComponent(component)];
180
+ }
181
+ const cloned = cloneComponent(component);
182
+ if ("selectors" in cloned) {
183
+ const nestedSelectors = normalizeNestedSelectors(cloned.selectors);
184
+ if (nestedSelectors) assignNestedSelectors(cloned, transformList(nestedSelectors, ctx));
185
+ }
186
+ if (cloned.kind === "where" && options.uniAppX) cloned.kind = "is";
187
+ return [cloned];
188
+ }
189
+ return [cloneComponent(component)];
190
+ }
191
+ function transformSelector(selector, ctx, transformList) {
192
+ const { childCombinatorReplacement } = ctx;
193
+ const output = [];
194
+ for (let index = 0; index < selector.length; index++) {
195
+ const component = selector[index];
196
+ if (!component) continue;
197
+ if (component.type === "combinator" && component.value === "child" && childCombinatorReplacement) {
198
+ const next = selector[index + 1];
199
+ const combinator = selector[index + 2];
200
+ const third = selector[index + 3];
201
+ if (matchesHiddenNot(next) && combinator?.type === "combinator" && (combinator.value === "next-sibling" || combinator.value === "later-sibling") && matchesHiddenNot(third)) {
202
+ output.push(cloneComponent(component));
203
+ output.push(...cloneComponents(childCombinatorReplacement));
204
+ index += 3;
205
+ continue;
206
+ }
207
+ }
208
+ const replaced = transformSelectorComponent(component, ctx, transformList);
209
+ if (replaced === null) return null;
210
+ output.push(...replaced);
211
+ }
212
+ const trimmed = trimCombinators(output);
213
+ return trimmed.length > 0 ? trimmed : null;
214
+ }
215
+ function transformSelectorList(selectors, ctx) {
216
+ const result = [];
217
+ for (const selector of selectors) {
218
+ const transformed = transformSelector(selector, ctx, transformSelectorList);
219
+ if (transformed && transformed.length > 0) result.push(transformed);
220
+ }
221
+ return result;
222
+ }
223
+ function createVisitor(ctx) {
224
+ return {
225
+ Rule(rule) {
226
+ if (rule.type === "property" && ctx.options.cssRemoveProperty) return [];
227
+ if (rule.type !== "style") return rule;
228
+ const styleRule = rule.value;
229
+ if (!styleRule.selectors) return rule;
230
+ const selectors = transformSelectorList(styleRule.selectors, ctx);
231
+ if (!selectors.length) return [];
232
+ styleRule.selectors = selectors;
233
+ return rule;
234
+ },
235
+ RuleExit(rule) {
236
+ if (rule.type !== "style") return rule;
237
+ const styleRule = rule.value;
238
+ const hasValidSelectors = (styleRule.selectors ?? []).some((selector) => selector.length > 0);
239
+ const declarationCount = styleRule.declarations?.declarations?.length ?? 0;
240
+ if (!hasValidSelectors || ctx.options.uniAppX && declarationCount === 0) return [];
241
+ return rule;
242
+ }
243
+ };
244
+ }
245
+ //#endregion
246
+ //#region src/lightningcss/index.ts
247
+ const textDecoder = new TextDecoder();
248
+ const defaultLightningFilename = "inline.css";
249
+ function omitUndefined(value) {
250
+ const result = {};
251
+ for (const [key, item] of Object.entries(value)) if (item !== void 0) result[key] = item;
252
+ return result;
253
+ }
254
+ function createPreparedRuntime(options) {
255
+ const resolvedOptions = prepareStyleOptions(options);
256
+ const ctx = omitUndefined({
257
+ options: resolvedOptions,
258
+ childCombinatorReplacement: buildChildCombinatorReplacement(resolvedOptions)
259
+ });
260
+ return omitUndefined({
261
+ options: resolvedOptions,
262
+ replaceSpecificity: createRootSpecificityReplacer(resolvedOptions),
263
+ visitor: createVisitor(ctx)
264
+ });
265
+ }
266
+ function createLightningcssStyleHandler(options, config = {}) {
267
+ const baseRuntime = createPreparedRuntime(options);
268
+ const { transformOptions, filename } = config;
269
+ const transformOverrides = transformOptions ?? {};
270
+ return async (rawSource, overrideOptions) => {
271
+ const runtime = !overrideOptions || Object.keys(overrideOptions).length === 0 ? baseRuntime : createPreparedRuntime((0, _weapp_tailwindcss_shared.defuOverrideArray)(overrideOptions, baseRuntime.options));
272
+ const lightningResult = (0, lightningcss.transform)(omitUndefined({
273
+ filename: filename ?? defaultLightningFilename,
274
+ code: node_buffer.Buffer.from(rawSource),
275
+ visitor: runtime.visitor,
276
+ minify: false,
277
+ ...transformOverrides
278
+ }));
279
+ const decodedCode = textDecoder.decode(lightningResult.code);
280
+ return omitUndefined({
281
+ code: runtime.replaceSpecificity ? runtime.replaceSpecificity(decodedCode) : decodedCode,
282
+ map: lightningResult.map ? textDecoder.decode(lightningResult.map) : void 0,
283
+ warnings: lightningResult.warnings
284
+ });
285
+ };
286
+ }
287
+ const defaultHandler = createLightningcssStyleHandler(void 0, { transformOptions: { minify: true } });
288
+ async function transformCss(css = ".foo { color: red }") {
289
+ const result = await defaultHandler(typeof css === "string" ? css : css.toString());
290
+ return {
291
+ ...result,
292
+ code: node_buffer.Buffer.from(result.code),
293
+ map: result.map ? node_buffer.Buffer.from(result.map) : void 0
294
+ };
295
+ }
296
+ //#endregion
297
+ Object.defineProperty(exports, "assignNestedSelectors", {
298
+ enumerable: true,
299
+ get: function() {
300
+ return assignNestedSelectors;
301
+ }
302
+ });
303
+ Object.defineProperty(exports, "buildChildCombinatorReplacement", {
304
+ enumerable: true,
305
+ get: function() {
306
+ return buildChildCombinatorReplacement;
307
+ }
308
+ });
309
+ Object.defineProperty(exports, "cloneComponent", {
310
+ enumerable: true,
311
+ get: function() {
312
+ return cloneComponent;
313
+ }
314
+ });
315
+ Object.defineProperty(exports, "cloneComponents", {
316
+ enumerable: true,
317
+ get: function() {
318
+ return cloneComponents;
319
+ }
320
+ });
321
+ Object.defineProperty(exports, "createLightningcssStyleHandler", {
322
+ enumerable: true,
323
+ get: function() {
324
+ return createLightningcssStyleHandler;
325
+ }
326
+ });
327
+ Object.defineProperty(exports, "createRootSpecificityReplacer", {
328
+ enumerable: true,
329
+ get: function() {
330
+ return createRootSpecificityReplacer;
331
+ }
332
+ });
333
+ Object.defineProperty(exports, "createTypeSelector", {
334
+ enumerable: true,
335
+ get: function() {
336
+ return createTypeSelector;
337
+ }
338
+ });
339
+ Object.defineProperty(exports, "createVisitor", {
340
+ enumerable: true,
341
+ get: function() {
342
+ return createVisitor;
343
+ }
344
+ });
345
+ Object.defineProperty(exports, "matchesHiddenNot", {
346
+ enumerable: true,
347
+ get: function() {
348
+ return matchesHiddenNot;
349
+ }
350
+ });
351
+ Object.defineProperty(exports, "normalizeNestedSelectors", {
352
+ enumerable: true,
353
+ get: function() {
354
+ return normalizeNestedSelectors;
355
+ }
356
+ });
357
+ Object.defineProperty(exports, "prepareStyleOptions", {
358
+ enumerable: true,
359
+ get: function() {
360
+ return prepareStyleOptions;
361
+ }
362
+ });
363
+ Object.defineProperty(exports, "transformCss", {
364
+ enumerable: true,
365
+ get: function() {
366
+ return transformCss;
367
+ }
368
+ });
369
+ Object.defineProperty(exports, "trimCombinators", {
370
+ enumerable: true,
371
+ get: function() {
372
+ return trimCombinators;
373
+ }
374
+ });
@@ -0,0 +1,297 @@
1
+ import { Buffer } from "node:buffer";
2
+ import { defuOverrideArray } from "@weapp-tailwindcss/shared";
3
+ import { transform } from "lightningcss";
4
+ import { createInjectPreflight, internalCssSelectorReplacer } from "@weapp-tailwindcss/postcss";
5
+ //#region src/lightningcss/options.ts
6
+ const FALLBACK_PLACEHOLDER_SUFFIXES = [":not(#n)", ":not(#\\#)"];
7
+ function normalizeSelectorList(value) {
8
+ if (value === void 0 || value === false) return [];
9
+ return Array.isArray(value) ? value.filter(Boolean) : [value];
10
+ }
11
+ function getSpecificityMatchingName(options) {
12
+ const feature = options.cssPresetEnv?.features?.["is-pseudo-class"];
13
+ if (feature && typeof feature === "object" && "specificityMatchingName" in feature) {
14
+ const specificityName = feature.specificityMatchingName;
15
+ return typeof specificityName === "string" && specificityName.length > 0 ? specificityName : void 0;
16
+ }
17
+ }
18
+ function createRootSpecificityReplacer(options) {
19
+ const specificityMatchingName = getSpecificityMatchingName(options);
20
+ const selectors = normalizeSelectorList(options.cssSelectorReplacement?.root);
21
+ const replaceFallbackPlaceholder = (code) => {
22
+ let output = code;
23
+ for (const suffix of FALLBACK_PLACEHOLDER_SUFFIXES) if (output.includes(suffix)) output = output.split(suffix).join("");
24
+ return output;
25
+ };
26
+ if (!specificityMatchingName || selectors.length === 0) return replaceFallbackPlaceholder;
27
+ const suffix = `:not(.${specificityMatchingName})`;
28
+ const targets = selectors.map((selector) => selector?.trim()).filter((selector) => Boolean(selector?.length)).map((selector) => ({
29
+ match: `${selector}${suffix}`,
30
+ spacedMatch: `${selector} ${suffix}`,
31
+ replacement: selector
32
+ }));
33
+ if (!targets.length) return;
34
+ return (code) => {
35
+ let output = replaceFallbackPlaceholder(code);
36
+ for (const target of targets) {
37
+ if (output.includes(target.match)) output = output.split(target.match).join(target.replacement);
38
+ if (output.includes(target.spacedMatch)) output = output.split(target.spacedMatch).join(target.replacement);
39
+ }
40
+ return output;
41
+ };
42
+ }
43
+ function getLightningDefaultOptions(options) {
44
+ const customPropertiesFeature = options?.cssPresetEnv?.features?.["custom-properties"];
45
+ return {
46
+ cssPresetEnv: {
47
+ features: {
48
+ "cascade-layers": true,
49
+ "is-pseudo-class": { specificityMatchingName: "weapp-tw-ig" },
50
+ "oklab-function": true,
51
+ "color-mix": true,
52
+ "custom-properties": customPropertiesFeature !== void 0 ? customPropertiesFeature : options?.cssCalc ? { preserve: true } : false
53
+ },
54
+ autoprefixer: { add: false }
55
+ },
56
+ cssRemoveProperty: true,
57
+ cssRemoveHoverPseudoClass: true,
58
+ cssChildCombinatorReplaceValue: ["view", "text"],
59
+ cssSelectorReplacement: {
60
+ root: [
61
+ "page",
62
+ ".tw-root",
63
+ "wx-root-portal-content"
64
+ ],
65
+ universal: ["view", "text"]
66
+ }
67
+ };
68
+ }
69
+ function prepareStyleOptions(options) {
70
+ const merged = defuOverrideArray(options, getLightningDefaultOptions(options));
71
+ merged.cssInjectPreflight = createInjectPreflight(merged.cssPreflight);
72
+ return merged;
73
+ }
74
+ //#endregion
75
+ //#region src/lightningcss/selector-utils.ts
76
+ function createTypeSelector(name) {
77
+ return {
78
+ type: "type",
79
+ name
80
+ };
81
+ }
82
+ function cloneComponent(value) {
83
+ const structured = globalThis.structuredClone;
84
+ if (typeof structured === "function") return structured(value);
85
+ return JSON.parse(JSON.stringify(value));
86
+ }
87
+ function cloneComponents(list) {
88
+ return list.map(cloneComponent);
89
+ }
90
+ function normalizeNestedSelectors(selectors) {
91
+ if (!selectors) return;
92
+ if (Array.isArray(selectors)) {
93
+ if (selectors.length === 0) return [];
94
+ const first = selectors[0];
95
+ if (Array.isArray(first)) return selectors;
96
+ return [selectors];
97
+ }
98
+ return [selectors];
99
+ }
100
+ function assignNestedSelectors(target, value) {
101
+ if (!("selectors" in target)) return;
102
+ if (Array.isArray(target.selectors)) target.selectors = value ?? [];
103
+ else if (target.selectors && !Array.isArray(target.selectors)) target.selectors = value?.[0] ?? target.selectors;
104
+ }
105
+ function trimCombinators(components) {
106
+ let start = 0;
107
+ let end = components.length;
108
+ while (start < end && components[start]?.type === "combinator") start++;
109
+ while (end > start && components[end - 1]?.type === "combinator") end--;
110
+ return components.slice(start, end);
111
+ }
112
+ function matchesHiddenNot(component) {
113
+ if (!component || component.type !== "pseudo-class" || component.kind !== "not") return false;
114
+ const selectors = normalizeNestedSelectors(component.selectors);
115
+ if (!selectors || selectors.length !== 1) return false;
116
+ const [nestedSelector] = selectors;
117
+ if (!nestedSelector || nestedSelector.length !== 1) return false;
118
+ const [node] = nestedSelector;
119
+ if (!node) return false;
120
+ return node.type === "attribute" && node.name === "hidden" || node.type === "type" && node.name === "template";
121
+ }
122
+ //#endregion
123
+ //#region src/lightningcss/selector-transform.ts
124
+ function buildSelectorReplacement(value) {
125
+ if (!value) return null;
126
+ const targets = Array.isArray(value) ? value : [value];
127
+ if (!targets.length) return null;
128
+ if (targets.length === 1) return [createTypeSelector(targets[0])];
129
+ return [{
130
+ type: "pseudo-class",
131
+ kind: "is",
132
+ selectors: targets.map((name) => [createTypeSelector(name)])
133
+ }];
134
+ }
135
+ function buildChildCombinatorReplacement(options) {
136
+ const { cssChildCombinatorReplaceValue } = options;
137
+ if (!cssChildCombinatorReplaceValue) return;
138
+ const normalized = Array.isArray(cssChildCombinatorReplaceValue) ? cssChildCombinatorReplaceValue : [cssChildCombinatorReplaceValue];
139
+ if (!normalized.length) return;
140
+ const baseComponents = buildSelectorReplacement(normalized) ?? [createTypeSelector("view")];
141
+ const left = cloneComponents(baseComponents);
142
+ const right = cloneComponents(baseComponents);
143
+ return [
144
+ ...left,
145
+ {
146
+ type: "combinator",
147
+ value: "next-sibling"
148
+ },
149
+ ...right
150
+ ];
151
+ }
152
+ function transformSelectorComponent(component, ctx, transformList) {
153
+ const { options } = ctx;
154
+ if (component.type === "class") {
155
+ const cloned = cloneComponent(component);
156
+ cloned.name = internalCssSelectorReplacer(component.name, { escapeMap: options.escapeMap });
157
+ return [cloned];
158
+ }
159
+ if (component.type === "universal") {
160
+ const replacement = buildSelectorReplacement(options.cssSelectorReplacement?.universal);
161
+ if (replacement) return cloneComponents(replacement);
162
+ return [cloneComponent(component)];
163
+ }
164
+ if (component.type === "type") {
165
+ if (options.uniAppX) return [];
166
+ return [cloneComponent(component)];
167
+ }
168
+ if (component.type === "attribute") {
169
+ if (options.uniAppX) return [];
170
+ return [cloneComponent(component)];
171
+ }
172
+ if (component.type === "combinator") return [cloneComponent(component)];
173
+ if (component.type === "pseudo-element") return [cloneComponent(component)];
174
+ if (component.type === "pseudo-class") {
175
+ if (component.kind === "hover" && options.cssRemoveHoverPseudoClass) return null;
176
+ if (component.kind === "root") {
177
+ const replacement = buildSelectorReplacement(options.cssSelectorReplacement?.root);
178
+ if (replacement) return cloneComponents(replacement);
179
+ return [cloneComponent(component)];
180
+ }
181
+ const cloned = cloneComponent(component);
182
+ if ("selectors" in cloned) {
183
+ const nestedSelectors = normalizeNestedSelectors(cloned.selectors);
184
+ if (nestedSelectors) assignNestedSelectors(cloned, transformList(nestedSelectors, ctx));
185
+ }
186
+ if (cloned.kind === "where" && options.uniAppX) cloned.kind = "is";
187
+ return [cloned];
188
+ }
189
+ return [cloneComponent(component)];
190
+ }
191
+ function transformSelector(selector, ctx, transformList) {
192
+ const { childCombinatorReplacement } = ctx;
193
+ const output = [];
194
+ for (let index = 0; index < selector.length; index++) {
195
+ const component = selector[index];
196
+ if (!component) continue;
197
+ if (component.type === "combinator" && component.value === "child" && childCombinatorReplacement) {
198
+ const next = selector[index + 1];
199
+ const combinator = selector[index + 2];
200
+ const third = selector[index + 3];
201
+ if (matchesHiddenNot(next) && combinator?.type === "combinator" && (combinator.value === "next-sibling" || combinator.value === "later-sibling") && matchesHiddenNot(third)) {
202
+ output.push(cloneComponent(component));
203
+ output.push(...cloneComponents(childCombinatorReplacement));
204
+ index += 3;
205
+ continue;
206
+ }
207
+ }
208
+ const replaced = transformSelectorComponent(component, ctx, transformList);
209
+ if (replaced === null) return null;
210
+ output.push(...replaced);
211
+ }
212
+ const trimmed = trimCombinators(output);
213
+ return trimmed.length > 0 ? trimmed : null;
214
+ }
215
+ function transformSelectorList(selectors, ctx) {
216
+ const result = [];
217
+ for (const selector of selectors) {
218
+ const transformed = transformSelector(selector, ctx, transformSelectorList);
219
+ if (transformed && transformed.length > 0) result.push(transformed);
220
+ }
221
+ return result;
222
+ }
223
+ function createVisitor(ctx) {
224
+ return {
225
+ Rule(rule) {
226
+ if (rule.type === "property" && ctx.options.cssRemoveProperty) return [];
227
+ if (rule.type !== "style") return rule;
228
+ const styleRule = rule.value;
229
+ if (!styleRule.selectors) return rule;
230
+ const selectors = transformSelectorList(styleRule.selectors, ctx);
231
+ if (!selectors.length) return [];
232
+ styleRule.selectors = selectors;
233
+ return rule;
234
+ },
235
+ RuleExit(rule) {
236
+ if (rule.type !== "style") return rule;
237
+ const styleRule = rule.value;
238
+ const hasValidSelectors = (styleRule.selectors ?? []).some((selector) => selector.length > 0);
239
+ const declarationCount = styleRule.declarations?.declarations?.length ?? 0;
240
+ if (!hasValidSelectors || ctx.options.uniAppX && declarationCount === 0) return [];
241
+ return rule;
242
+ }
243
+ };
244
+ }
245
+ //#endregion
246
+ //#region src/lightningcss/index.ts
247
+ const textDecoder = new TextDecoder();
248
+ const defaultLightningFilename = "inline.css";
249
+ function omitUndefined(value) {
250
+ const result = {};
251
+ for (const [key, item] of Object.entries(value)) if (item !== void 0) result[key] = item;
252
+ return result;
253
+ }
254
+ function createPreparedRuntime(options) {
255
+ const resolvedOptions = prepareStyleOptions(options);
256
+ const ctx = omitUndefined({
257
+ options: resolvedOptions,
258
+ childCombinatorReplacement: buildChildCombinatorReplacement(resolvedOptions)
259
+ });
260
+ return omitUndefined({
261
+ options: resolvedOptions,
262
+ replaceSpecificity: createRootSpecificityReplacer(resolvedOptions),
263
+ visitor: createVisitor(ctx)
264
+ });
265
+ }
266
+ function createLightningcssStyleHandler(options, config = {}) {
267
+ const baseRuntime = createPreparedRuntime(options);
268
+ const { transformOptions, filename } = config;
269
+ const transformOverrides = transformOptions ?? {};
270
+ return async (rawSource, overrideOptions) => {
271
+ const runtime = !overrideOptions || Object.keys(overrideOptions).length === 0 ? baseRuntime : createPreparedRuntime(defuOverrideArray(overrideOptions, baseRuntime.options));
272
+ const lightningResult = transform(omitUndefined({
273
+ filename: filename ?? defaultLightningFilename,
274
+ code: Buffer.from(rawSource),
275
+ visitor: runtime.visitor,
276
+ minify: false,
277
+ ...transformOverrides
278
+ }));
279
+ const decodedCode = textDecoder.decode(lightningResult.code);
280
+ return omitUndefined({
281
+ code: runtime.replaceSpecificity ? runtime.replaceSpecificity(decodedCode) : decodedCode,
282
+ map: lightningResult.map ? textDecoder.decode(lightningResult.map) : void 0,
283
+ warnings: lightningResult.warnings
284
+ });
285
+ };
286
+ }
287
+ const defaultHandler = createLightningcssStyleHandler(void 0, { transformOptions: { minify: true } });
288
+ async function transformCss(css = ".foo { color: red }") {
289
+ const result = await defaultHandler(typeof css === "string" ? css : css.toString());
290
+ return {
291
+ ...result,
292
+ code: Buffer.from(result.code),
293
+ map: result.map ? Buffer.from(result.map) : void 0
294
+ };
295
+ }
296
+ //#endregion
297
+ export { assignNestedSelectors as a, createTypeSelector as c, trimCombinators as d, createRootSpecificityReplacer as f, createVisitor as i, matchesHiddenNot as l, transformCss as n, cloneComponent as o, prepareStyleOptions as p, buildChildCombinatorReplacement as r, cloneComponents as s, createLightningcssStyleHandler as t, normalizeNestedSelectors as u };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/experimental",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.0.2-next.1",
5
5
  "description": "@weapp-tailwindcss/experimental",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "ISC",
@@ -20,6 +20,11 @@
20
20
  "types": "./dist/index.d.ts",
21
21
  "import": "./dist/index.mjs",
22
22
  "require": "./dist/index.cjs"
23
+ },
24
+ "./lightningcss": {
25
+ "types": "./dist/lightningcss/index.d.ts",
26
+ "import": "./dist/lightningcss/index.mjs",
27
+ "require": "./dist/lightningcss/index.cjs"
23
28
  }
24
29
  },
25
30
  "main": "./dist/index.cjs",
@@ -28,10 +33,18 @@
28
33
  "files": [
29
34
  "dist"
30
35
  ],
36
+ "engines": {
37
+ "node": "^20.19.0 || >=22.12.0"
38
+ },
39
+ "dependencies": {
40
+ "lightningcss": "^1.32.0",
41
+ "@weapp-tailwindcss/postcss": "3.0.0-next.7",
42
+ "@weapp-tailwindcss/shared": "1.1.3"
43
+ },
31
44
  "scripts": {
32
- "dev": "unbuild --stub",
33
- "build:watch": "unbuild --watch --sourcemap",
34
- "build": "unbuild",
45
+ "dev": "tsdown --watch --sourcemap",
46
+ "build:watch": "tsdown --watch --sourcemap",
47
+ "build": "tsdown",
35
48
  "test": "vitest run",
36
49
  "test:dev": "vitest",
37
50
  "release": "pnpm publish",
package/dist/index.d.cts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { };
package/dist/index.d.mts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { };