@weapp-tailwindcss/merge 1.0.0-alpha.1 → 1.0.0-alpha.3

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,100 @@
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
+ ![dm1](https://badgen.net/npm/dm/weapp-tailwindcss-webpack-plugin)
19
+ ![license](https://badgen.net/npm/license/weapp-tailwindcss)
20
+ [![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)
21
+ [![codecov](https://codecov.io/gh/sonofmagic/weapp-tailwindcss/branch/main/graph/badge.svg?token=zn05qXYznt)](https://codecov.io/gh/sonofmagic/weapp-tailwindcss)
22
+
23
+ > [!NOTE]
24
+ > 降低开发维护成本,提升开发效率的 `小程序` `tailwindcss` 全方面解决方案
25
+ >
26
+ > 小程序原生工具链 `weapp-vite` 已经发布,使用它改善你的原生小程序开发体验吧,更多详见 [官方文档](https://vite.icebreaker.top/)
27
+
28
+ \[[文档地址](https://tw.icebreaker.top)\] \| \[[加入技术交流群](https://tw.icebreaker.top/docs/community/group)\]
29
+
30
+ - [特性](#特性)
31
+ - [版本对应](#版本对应)
32
+ - [安装与使用方式](#安装与使用方式)
33
+ - [生态和解决方案](#生态和解决方案)
34
+ - [常见问题](#常见问题)
35
+ - [各个框架的模板](#各个框架的模板)
36
+ - [旧版本迁移指南](#旧版本迁移指南)
37
+ - [配置项参考](#配置项参考)
38
+ - [变更日志](#变更日志)
39
+ - [Contribute](#contribute)
40
+ - [License](#license)
41
+ - [Star History](#star-history)
42
+ - [Related projects](#related-projects)
43
+ - [weapp-vite](#weapp-vite)
44
+
45
+ ## 特性
46
+
47
+ | 不仅仅是`webpack` | 主流框架与原生开发支持 |
48
+ | --------------------------------------------------- | ----------------------------------------------- |
49
+ | ![wepback+vite+gulp](./assets/weapp-tw-plugins.png) | ![frameworks](./assets/weapp-tw-frameworks.png) |
50
+
51
+ 核心插件支持 `webpack`/`vite`/`gulp` 为基底的框架类小程序开发,涵盖了市面上几乎所有的主流的开发框架。
52
+
53
+ 同时也支持最原生的开发者工具创建的原生小程序应用。
54
+
55
+ 这些插件能够自动识别并精确处理所有 `tailwindcss` 的工具类来适配小程序环境。
56
+
57
+ ## 版本对应
58
+
59
+ 目前,`weapp-tailwindcss` 的 `2.x` 和 `3.x` 支持最新版本的 `tailwindcss v3.x.x` 版本和 `webpack5`,`webpack4`, `vite` 和 `gulp`。从 `3.2.0` 开始,`weapp-tailwindcss` 支持最原生的小程序开发方式。
60
+
61
+ > 如果你还在使用 `tailwindcss@2` 版本,那你应该使用从 `weapp-tailwindcss/webpack4` 导出的本插件的 `postcss7` `webpack4` 版本。另外请确保你的 `nodejs` 版本 `>=16.6.0`。目前低于 `16` 的长期维护版本(`偶数版本`) 都已经结束了生命周期,建议安装 `nodejs` 的 `LTS` 版本,详见 [nodejs/release](https://github.com/nodejs/release)
62
+
63
+ ## [安装与使用方式](https://tw.icebreaker.top/docs/quick-start/install)
64
+
65
+ ## [生态和解决方案](https://tw.icebreaker.top/docs/community/templates)
66
+
67
+ ## [常见问题](https://tw.icebreaker.top/docs/issues/)
68
+
69
+ ## [各个框架的模板](https://tw.icebreaker.top/docs/community/templates)
70
+
71
+ ## [旧版本迁移指南](https://tw.icebreaker.top/docs/migrations/v2)
72
+
73
+ ## [配置项参考](https://tw.icebreaker.top/docs/api/interfaces/UserDefinedOptions)
74
+
75
+ ## [变更日志](./CHANGELOG.md)
76
+
77
+ ## Contribute
78
+
79
+ 我们邀请你来贡献和帮助改进 `weapp-tailwindcss` 💚💚💚
80
+
81
+ 以下有几个方式可以参与:
82
+
83
+ - 报告错误:如果您遇到任何错误或问题,请提`issue`并提供完善的错误信息和复现方式。
84
+ - 建议:有增强 `weapp-tailwindcss` 的想法吗?请提 `issue` 来分享您的建议。
85
+ - 文档:如果您对文档有更好的见解或者更棒的修辞方式,欢迎 `pr`。
86
+ - 代码:任何人的代码都不是完美的,我们欢迎你通过 `pr` 给代码提供更好的质量与活力。
87
+
88
+ ## License
89
+
90
+ [MIT](./LICENSE)
91
+
92
+ ## Star History
93
+
94
+ [![Star History Chart](https://api.star-history.com/svg?repos=sonofmagic/weapp-tailwindcss&type=Date)](https://star-history.com/#sonofmagic/weapp-tailwindcss&Date)
95
+
96
+ ## Related projects
97
+
98
+ ### weapp-vite
99
+
100
+ [weapp-vite](https://vite.icebreaker.top/): 把现代化的开发模式带入小程序开发!
@@ -0,0 +1,200 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// ../../node_modules/.pnpm/@weapp-core+escape@3.0.2/node_modules/@weapp-core/escape/dist/index.mjs
2
+ var MappingChars2String = {
3
+ "[": "_bl_",
4
+ "]": "_br_",
5
+ "(": "_pl_",
6
+ ")": "_qr_",
7
+ "#": "_h_",
8
+ "!": "_i_",
9
+ "/": "_s_",
10
+ "\\": "_bs_",
11
+ ".": "_d_",
12
+ ":": "_c_",
13
+ "%": "_p_",
14
+ ",": "_co_",
15
+ "'": "_q_",
16
+ '"': "_dq_",
17
+ "*": "_a_",
18
+ "&": "_am_",
19
+ "@": "_at_",
20
+ "{": "_bal_",
21
+ "}": "_bar_",
22
+ // ' ': '_sp_',
23
+ "+": "_plus_",
24
+ // '-': '_m_',
25
+ ";": "_se_",
26
+ "<": "_l_",
27
+ "~": "_t_",
28
+ "=": "_e_",
29
+ ">": "_g_",
30
+ "?": "_qu_",
31
+ "^": "_ca_",
32
+ "`": "_bq_",
33
+ "|": "_b_",
34
+ "$": "_do_"
35
+ // _: '_u_'
36
+ };
37
+ var MappingChars2StringEntries = Object.entries(MappingChars2String);
38
+ var SimpleMappingChars2String = {
39
+ "[": "_",
40
+ "]": "_",
41
+ "(": "_",
42
+ ")": "_",
43
+ "{": "_",
44
+ "}": "_",
45
+ "+": "a",
46
+ ",": "b",
47
+ ":": "c",
48
+ ".": "d",
49
+ "=": "e",
50
+ ";": "f",
51
+ ">": "g",
52
+ "#": "h",
53
+ "!": "i",
54
+ "@": "j",
55
+ "^": "k",
56
+ "<": "l",
57
+ "*": "m",
58
+ "&": "n",
59
+ "?": "o",
60
+ "%": "p",
61
+ "'": "q",
62
+ "$": "r",
63
+ "/": "s",
64
+ "~": "t",
65
+ "|": "u",
66
+ "`": "v",
67
+ "\\": "w",
68
+ '"': "x"
69
+ };
70
+ var SimpleMappingChars2StringEntries = Object.entries(SimpleMappingChars2String);
71
+ var MAX_ASCII_CHAR_CODE = 127;
72
+ function isPlainObject(value) {
73
+ if (value === null || typeof value !== "object") {
74
+ return false;
75
+ }
76
+ const prototype = Object.getPrototypeOf(value);
77
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
78
+ return false;
79
+ }
80
+ if (Symbol.iterator in value) {
81
+ return false;
82
+ }
83
+ if (Symbol.toStringTag in value) {
84
+ return Object.prototype.toString.call(value) === "[object Module]";
85
+ }
86
+ return true;
87
+ }
88
+ function _defu(baseObject, defaults, namespace = ".", merger) {
89
+ if (!isPlainObject(defaults)) {
90
+ return _defu(baseObject, {}, namespace, merger);
91
+ }
92
+ const object = Object.assign({}, defaults);
93
+ for (const key in baseObject) {
94
+ if (key === "__proto__" || key === "constructor") {
95
+ continue;
96
+ }
97
+ const value = baseObject[key];
98
+ if (value === null || value === void 0) {
99
+ continue;
100
+ }
101
+ if (merger && merger(object, key, value, namespace)) {
102
+ continue;
103
+ }
104
+ if (Array.isArray(value) && Array.isArray(object[key])) {
105
+ object[key] = [...value, ...object[key]];
106
+ } else if (isPlainObject(value) && isPlainObject(object[key])) {
107
+ object[key] = _defu(
108
+ value,
109
+ object[key],
110
+ (namespace ? `${namespace}.` : "") + key.toString(),
111
+ merger
112
+ );
113
+ } else {
114
+ object[key] = value;
115
+ }
116
+ }
117
+ return object;
118
+ }
119
+ function createDefu(merger) {
120
+ return (...arguments_) => (
121
+ // eslint-disable-next-line unicorn/no-array-reduce
122
+ arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
123
+ );
124
+ }
125
+ var defu = createDefu();
126
+ function isAsciiNumber(code) {
127
+ return code >= 48 && code <= 57;
128
+ }
129
+ function handleFirstCharacter(char, nextChar, ignoreHead) {
130
+ if (!ignoreHead) {
131
+ const code = char.codePointAt(0);
132
+ if (isAsciiNumber(code)) {
133
+ return `_${char}`;
134
+ }
135
+ if (char === "-" && nextChar && isAsciiNumber(nextChar.codePointAt(0))) {
136
+ return `_${char}`;
137
+ }
138
+ if (char === "-" && nextChar === void 0) {
139
+ return `_${char}`;
140
+ }
141
+ }
142
+ return char;
143
+ }
144
+ function escape(selectors, options) {
145
+ if (selectors.length === 0) {
146
+ return "";
147
+ }
148
+ const { map, ignoreHead } = defu(options, {
149
+ map: SimpleMappingChars2String,
150
+ ignoreHead: false
151
+ });
152
+ const sb = [];
153
+ for (let i = 0; i < selectors.length; i++) {
154
+ const char = selectors[i];
155
+ const code = char.codePointAt(0);
156
+ if (code !== void 0) {
157
+ if (code > MAX_ASCII_CHAR_CODE) {
158
+ sb.push(`u${code.toString(16)}`);
159
+ } else {
160
+ const hit = map[char];
161
+ if (hit) {
162
+ sb.push(hit);
163
+ } else if (i === 0) {
164
+ sb.push(handleFirstCharacter(char, selectors[i + 1], ignoreHead));
165
+ } else {
166
+ sb.push(char);
167
+ }
168
+ }
169
+ }
170
+ }
171
+ return sb.join("");
172
+ }
173
+
174
+ // ../weapp-tailwindcss/dist/chunk-U7O2XXYR.mjs
175
+ function replaceWxml(original, options = {
176
+ keepEOL: false,
177
+ escapeMap: SimpleMappingChars2String
178
+ }) {
179
+ const { keepEOL, escapeMap, mangleContext, ignoreHead } = options;
180
+ let res = original;
181
+ if (!keepEOL) {
182
+ res = res.replaceAll(/[\n\r]+/g, "");
183
+ }
184
+ if (mangleContext) {
185
+ res = mangleContext.wxmlHandler(res);
186
+ }
187
+ res = escape(res, {
188
+ map: escapeMap,
189
+ ignoreHead
190
+ });
191
+ return res;
192
+ }
193
+
194
+ // ../weapp-tailwindcss/dist/escape.mjs
195
+ var weappTwIgnore = String.raw;
196
+
197
+
198
+
199
+
200
+ exports.replaceWxml = replaceWxml; exports.weappTwIgnore = weappTwIgnore;
@@ -0,0 +1,200 @@
1
+ // ../../node_modules/.pnpm/@weapp-core+escape@3.0.2/node_modules/@weapp-core/escape/dist/index.mjs
2
+ var MappingChars2String = {
3
+ "[": "_bl_",
4
+ "]": "_br_",
5
+ "(": "_pl_",
6
+ ")": "_qr_",
7
+ "#": "_h_",
8
+ "!": "_i_",
9
+ "/": "_s_",
10
+ "\\": "_bs_",
11
+ ".": "_d_",
12
+ ":": "_c_",
13
+ "%": "_p_",
14
+ ",": "_co_",
15
+ "'": "_q_",
16
+ '"': "_dq_",
17
+ "*": "_a_",
18
+ "&": "_am_",
19
+ "@": "_at_",
20
+ "{": "_bal_",
21
+ "}": "_bar_",
22
+ // ' ': '_sp_',
23
+ "+": "_plus_",
24
+ // '-': '_m_',
25
+ ";": "_se_",
26
+ "<": "_l_",
27
+ "~": "_t_",
28
+ "=": "_e_",
29
+ ">": "_g_",
30
+ "?": "_qu_",
31
+ "^": "_ca_",
32
+ "`": "_bq_",
33
+ "|": "_b_",
34
+ "$": "_do_"
35
+ // _: '_u_'
36
+ };
37
+ var MappingChars2StringEntries = Object.entries(MappingChars2String);
38
+ var SimpleMappingChars2String = {
39
+ "[": "_",
40
+ "]": "_",
41
+ "(": "_",
42
+ ")": "_",
43
+ "{": "_",
44
+ "}": "_",
45
+ "+": "a",
46
+ ",": "b",
47
+ ":": "c",
48
+ ".": "d",
49
+ "=": "e",
50
+ ";": "f",
51
+ ">": "g",
52
+ "#": "h",
53
+ "!": "i",
54
+ "@": "j",
55
+ "^": "k",
56
+ "<": "l",
57
+ "*": "m",
58
+ "&": "n",
59
+ "?": "o",
60
+ "%": "p",
61
+ "'": "q",
62
+ "$": "r",
63
+ "/": "s",
64
+ "~": "t",
65
+ "|": "u",
66
+ "`": "v",
67
+ "\\": "w",
68
+ '"': "x"
69
+ };
70
+ var SimpleMappingChars2StringEntries = Object.entries(SimpleMappingChars2String);
71
+ var MAX_ASCII_CHAR_CODE = 127;
72
+ function isPlainObject(value) {
73
+ if (value === null || typeof value !== "object") {
74
+ return false;
75
+ }
76
+ const prototype = Object.getPrototypeOf(value);
77
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
78
+ return false;
79
+ }
80
+ if (Symbol.iterator in value) {
81
+ return false;
82
+ }
83
+ if (Symbol.toStringTag in value) {
84
+ return Object.prototype.toString.call(value) === "[object Module]";
85
+ }
86
+ return true;
87
+ }
88
+ function _defu(baseObject, defaults, namespace = ".", merger) {
89
+ if (!isPlainObject(defaults)) {
90
+ return _defu(baseObject, {}, namespace, merger);
91
+ }
92
+ const object = Object.assign({}, defaults);
93
+ for (const key in baseObject) {
94
+ if (key === "__proto__" || key === "constructor") {
95
+ continue;
96
+ }
97
+ const value = baseObject[key];
98
+ if (value === null || value === void 0) {
99
+ continue;
100
+ }
101
+ if (merger && merger(object, key, value, namespace)) {
102
+ continue;
103
+ }
104
+ if (Array.isArray(value) && Array.isArray(object[key])) {
105
+ object[key] = [...value, ...object[key]];
106
+ } else if (isPlainObject(value) && isPlainObject(object[key])) {
107
+ object[key] = _defu(
108
+ value,
109
+ object[key],
110
+ (namespace ? `${namespace}.` : "") + key.toString(),
111
+ merger
112
+ );
113
+ } else {
114
+ object[key] = value;
115
+ }
116
+ }
117
+ return object;
118
+ }
119
+ function createDefu(merger) {
120
+ return (...arguments_) => (
121
+ // eslint-disable-next-line unicorn/no-array-reduce
122
+ arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
123
+ );
124
+ }
125
+ var defu = createDefu();
126
+ function isAsciiNumber(code) {
127
+ return code >= 48 && code <= 57;
128
+ }
129
+ function handleFirstCharacter(char, nextChar, ignoreHead) {
130
+ if (!ignoreHead) {
131
+ const code = char.codePointAt(0);
132
+ if (isAsciiNumber(code)) {
133
+ return `_${char}`;
134
+ }
135
+ if (char === "-" && nextChar && isAsciiNumber(nextChar.codePointAt(0))) {
136
+ return `_${char}`;
137
+ }
138
+ if (char === "-" && nextChar === void 0) {
139
+ return `_${char}`;
140
+ }
141
+ }
142
+ return char;
143
+ }
144
+ function escape(selectors, options) {
145
+ if (selectors.length === 0) {
146
+ return "";
147
+ }
148
+ const { map, ignoreHead } = defu(options, {
149
+ map: SimpleMappingChars2String,
150
+ ignoreHead: false
151
+ });
152
+ const sb = [];
153
+ for (let i = 0; i < selectors.length; i++) {
154
+ const char = selectors[i];
155
+ const code = char.codePointAt(0);
156
+ if (code !== void 0) {
157
+ if (code > MAX_ASCII_CHAR_CODE) {
158
+ sb.push(`u${code.toString(16)}`);
159
+ } else {
160
+ const hit = map[char];
161
+ if (hit) {
162
+ sb.push(hit);
163
+ } else if (i === 0) {
164
+ sb.push(handleFirstCharacter(char, selectors[i + 1], ignoreHead));
165
+ } else {
166
+ sb.push(char);
167
+ }
168
+ }
169
+ }
170
+ }
171
+ return sb.join("");
172
+ }
173
+
174
+ // ../weapp-tailwindcss/dist/chunk-U7O2XXYR.mjs
175
+ function replaceWxml(original, options = {
176
+ keepEOL: false,
177
+ escapeMap: SimpleMappingChars2String
178
+ }) {
179
+ const { keepEOL, escapeMap, mangleContext, ignoreHead } = options;
180
+ let res = original;
181
+ if (!keepEOL) {
182
+ res = res.replaceAll(/[\n\r]+/g, "");
183
+ }
184
+ if (mangleContext) {
185
+ res = mangleContext.wxmlHandler(res);
186
+ }
187
+ res = escape(res, {
188
+ map: escapeMap,
189
+ ignoreHead
190
+ });
191
+ return res;
192
+ }
193
+
194
+ // ../weapp-tailwindcss/dist/escape.mjs
195
+ var weappTwIgnore = String.raw;
196
+
197
+ export {
198
+ replaceWxml,
199
+ weappTwIgnore
200
+ };
package/dist/cva.cjs ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkVR7IWN2Zcjs = require('./chunk-VR7IWN2Z.cjs');
4
+
5
+ // src/cva.ts
6
+ var _classvarianceauthority = require('class-variance-authority');
7
+ function cva(...inputs) {
8
+ const fn = _classvarianceauthority.cva.call(void 0, ...inputs);
9
+ return (...props) => {
10
+ return _chunkVR7IWN2Zcjs.replaceWxml.call(void 0, fn(...props));
11
+ };
12
+ }
13
+
14
+
15
+ exports.cva = cva;
package/dist/cva.d.cts ADDED
@@ -0,0 +1,6 @@
1
+ import * as class_variance_authority_types from 'class-variance-authority/types';
2
+ import { cva as cva$1 } from 'class-variance-authority';
3
+
4
+ declare function cva(...inputs: Parameters<typeof cva$1>): (props?: class_variance_authority_types.ClassProp | undefined) => string;
5
+
6
+ export { cva };
package/dist/cva.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import * as class_variance_authority_types from 'class-variance-authority/types';
2
+ import { cva as cva$1 } from 'class-variance-authority';
3
+
4
+ declare function cva(...inputs: Parameters<typeof cva$1>): (props?: class_variance_authority_types.ClassProp | undefined) => string;
5
+
6
+ export { cva };
package/dist/cva.js ADDED
@@ -0,0 +1,15 @@
1
+ import {
2
+ replaceWxml
3
+ } from "./chunk-YR5LCHCZ.js";
4
+
5
+ // src/cva.ts
6
+ import { cva as _cva } from "class-variance-authority";
7
+ function cva(...inputs) {
8
+ const fn = _cva(...inputs);
9
+ return (...props) => {
10
+ return replaceWxml(fn(...props));
11
+ };
12
+ }
13
+ export {
14
+ cva
15
+ };
package/dist/index.cjs CHANGED
@@ -1,216 +1,15 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/index.ts
2
- var _classvarianceauthority = require('class-variance-authority');
3
- var _clsx = require('clsx');
4
- var _tailwindmerge = require('tailwind-merge');
5
-
6
- // ../../node_modules/.pnpm/@weapp-core+escape@3.0.2/node_modules/@weapp-core/escape/dist/index.mjs
7
- var MappingChars2String = {
8
- "[": "_bl_",
9
- "]": "_br_",
10
- "(": "_pl_",
11
- ")": "_qr_",
12
- "#": "_h_",
13
- "!": "_i_",
14
- "/": "_s_",
15
- "\\": "_bs_",
16
- ".": "_d_",
17
- ":": "_c_",
18
- "%": "_p_",
19
- ",": "_co_",
20
- "'": "_q_",
21
- '"': "_dq_",
22
- "*": "_a_",
23
- "&": "_am_",
24
- "@": "_at_",
25
- "{": "_bal_",
26
- "}": "_bar_",
27
- // ' ': '_sp_',
28
- "+": "_plus_",
29
- // '-': '_m_',
30
- ";": "_se_",
31
- "<": "_l_",
32
- "~": "_t_",
33
- "=": "_e_",
34
- ">": "_g_",
35
- "?": "_qu_",
36
- "^": "_ca_",
37
- "`": "_bq_",
38
- "|": "_b_",
39
- "$": "_do_"
40
- // _: '_u_'
41
- };
42
- var MappingChars2StringEntries = Object.entries(MappingChars2String);
43
- var SimpleMappingChars2String = {
44
- "[": "_",
45
- "]": "_",
46
- "(": "_",
47
- ")": "_",
48
- "{": "_",
49
- "}": "_",
50
- "+": "a",
51
- ",": "b",
52
- ":": "c",
53
- ".": "d",
54
- "=": "e",
55
- ";": "f",
56
- ">": "g",
57
- "#": "h",
58
- "!": "i",
59
- "@": "j",
60
- "^": "k",
61
- "<": "l",
62
- "*": "m",
63
- "&": "n",
64
- "?": "o",
65
- "%": "p",
66
- "'": "q",
67
- "$": "r",
68
- "/": "s",
69
- "~": "t",
70
- "|": "u",
71
- "`": "v",
72
- "\\": "w",
73
- '"': "x"
74
- };
75
- var SimpleMappingChars2StringEntries = Object.entries(SimpleMappingChars2String);
76
- var MAX_ASCII_CHAR_CODE = 127;
77
- function isPlainObject(value) {
78
- if (value === null || typeof value !== "object") {
79
- return false;
80
- }
81
- const prototype = Object.getPrototypeOf(value);
82
- if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
83
- return false;
84
- }
85
- if (Symbol.iterator in value) {
86
- return false;
87
- }
88
- if (Symbol.toStringTag in value) {
89
- return Object.prototype.toString.call(value) === "[object Module]";
90
- }
91
- return true;
92
- }
93
- function _defu(baseObject, defaults, namespace = ".", merger) {
94
- if (!isPlainObject(defaults)) {
95
- return _defu(baseObject, {}, namespace, merger);
96
- }
97
- const object = Object.assign({}, defaults);
98
- for (const key in baseObject) {
99
- if (key === "__proto__" || key === "constructor") {
100
- continue;
101
- }
102
- const value = baseObject[key];
103
- if (value === null || value === void 0) {
104
- continue;
105
- }
106
- if (merger && merger(object, key, value, namespace)) {
107
- continue;
108
- }
109
- if (Array.isArray(value) && Array.isArray(object[key])) {
110
- object[key] = [...value, ...object[key]];
111
- } else if (isPlainObject(value) && isPlainObject(object[key])) {
112
- object[key] = _defu(
113
- value,
114
- object[key],
115
- (namespace ? `${namespace}.` : "") + key.toString(),
116
- merger
117
- );
118
- } else {
119
- object[key] = value;
120
- }
121
- }
122
- return object;
123
- }
124
- function createDefu(merger) {
125
- return (...arguments_) => (
126
- // eslint-disable-next-line unicorn/no-array-reduce
127
- arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
128
- );
129
- }
130
- var defu = createDefu();
131
- function isAsciiNumber(code) {
132
- return code >= 48 && code <= 57;
133
- }
134
- function handleFirstCharacter(char, nextChar, ignoreHead) {
135
- if (!ignoreHead) {
136
- const code = char.codePointAt(0);
137
- if (isAsciiNumber(code)) {
138
- return `_${char}`;
139
- }
140
- if (char === "-" && nextChar && isAsciiNumber(nextChar.codePointAt(0))) {
141
- return `_${char}`;
142
- }
143
- if (char === "-" && nextChar === void 0) {
144
- return `_${char}`;
145
- }
146
- }
147
- return char;
148
- }
149
- function escape(selectors, options) {
150
- if (selectors.length === 0) {
151
- return "";
152
- }
153
- const { map, ignoreHead } = defu(options, {
154
- map: SimpleMappingChars2String,
155
- ignoreHead: false
156
- });
157
- const sb = [];
158
- for (let i = 0; i < selectors.length; i++) {
159
- const char = selectors[i];
160
- const code = char.codePointAt(0);
161
- if (code !== void 0) {
162
- if (code > MAX_ASCII_CHAR_CODE) {
163
- sb.push(`u${code.toString(16)}`);
164
- } else {
165
- const hit = map[char];
166
- if (hit) {
167
- sb.push(hit);
168
- } else if (i === 0) {
169
- sb.push(handleFirstCharacter(char, selectors[i + 1], ignoreHead));
170
- } else {
171
- sb.push(char);
172
- }
173
- }
174
- }
175
- }
176
- return sb.join("");
177
- }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
178
2
 
179
- // ../weapp-tailwindcss/dist/chunk-U7O2XXYR.mjs
180
- function replaceWxml(original, options = {
181
- keepEOL: false,
182
- escapeMap: SimpleMappingChars2String
183
- }) {
184
- const { keepEOL, escapeMap, mangleContext, ignoreHead } = options;
185
- let res = original;
186
- if (!keepEOL) {
187
- res = res.replaceAll(/[\n\r]+/g, "");
188
- }
189
- if (mangleContext) {
190
- res = mangleContext.wxmlHandler(res);
191
- }
192
- res = escape(res, {
193
- map: escapeMap,
194
- ignoreHead
195
- });
196
- return res;
197
- }
198
3
 
199
- // ../weapp-tailwindcss/dist/escape.mjs
200
- var weappTwIgnore = String.raw;
4
+ var _chunkVR7IWN2Zcjs = require('./chunk-VR7IWN2Z.cjs');
201
5
 
202
6
  // src/index.ts
7
+ var _clsx = require('clsx');
8
+ var _tailwindmerge = require('tailwind-merge');
203
9
  function cn(...inputs) {
204
- return replaceWxml(_tailwindmerge.twMerge.call(void 0, _clsx.clsx.call(void 0, inputs)));
205
- }
206
- function cva(...inputs) {
207
- const fn = _classvarianceauthority.cva.call(void 0, ...inputs);
208
- return (...props) => {
209
- return replaceWxml(fn(...props));
210
- };
10
+ return _chunkVR7IWN2Zcjs.replaceWxml.call(void 0, _tailwindmerge.twMerge.call(void 0, _clsx.clsx.call(void 0, inputs)));
211
11
  }
212
12
 
213
13
 
214
14
 
215
-
216
- exports.cn = cn; exports.cva = cva; exports.weappTwIgnore = weappTwIgnore;
15
+ exports.cn = cn; exports.weappTwIgnore = _chunkVR7IWN2Zcjs.weappTwIgnore;
package/dist/index.d.cts CHANGED
@@ -1,9 +1,6 @@
1
- import * as class_variance_authority_types from 'class-variance-authority/types';
2
- import { cva as cva$1 } from 'class-variance-authority';
3
1
  import { ClassValue } from 'clsx';
4
2
  export { weappTwIgnore } from 'weapp-tailwindcss/escape';
5
3
 
6
4
  declare function cn(...inputs: ClassValue[]): string;
7
- declare function cva(...inputs: Parameters<typeof cva$1>): (props?: class_variance_authority_types.ClassProp | undefined) => string;
8
5
 
9
- export { cn, cva };
6
+ export { cn };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,6 @@
1
- import * as class_variance_authority_types from 'class-variance-authority/types';
2
- import { cva as cva$1 } from 'class-variance-authority';
3
1
  import { ClassValue } from 'clsx';
4
2
  export { weappTwIgnore } from 'weapp-tailwindcss/escape';
5
3
 
6
4
  declare function cn(...inputs: ClassValue[]): string;
7
- declare function cva(...inputs: Parameters<typeof cva$1>): (props?: class_variance_authority_types.ClassProp | undefined) => string;
8
5
 
9
- export { cn, cva };
6
+ export { cn };
package/dist/index.js CHANGED
@@ -1,216 +1,15 @@
1
+ import {
2
+ replaceWxml,
3
+ weappTwIgnore
4
+ } from "./chunk-YR5LCHCZ.js";
5
+
1
6
  // src/index.ts
2
- import { cva as _cva } from "class-variance-authority";
3
7
  import { clsx } from "clsx";
4
8
  import { twMerge } from "tailwind-merge";
5
-
6
- // ../../node_modules/.pnpm/@weapp-core+escape@3.0.2/node_modules/@weapp-core/escape/dist/index.mjs
7
- var MappingChars2String = {
8
- "[": "_bl_",
9
- "]": "_br_",
10
- "(": "_pl_",
11
- ")": "_qr_",
12
- "#": "_h_",
13
- "!": "_i_",
14
- "/": "_s_",
15
- "\\": "_bs_",
16
- ".": "_d_",
17
- ":": "_c_",
18
- "%": "_p_",
19
- ",": "_co_",
20
- "'": "_q_",
21
- '"': "_dq_",
22
- "*": "_a_",
23
- "&": "_am_",
24
- "@": "_at_",
25
- "{": "_bal_",
26
- "}": "_bar_",
27
- // ' ': '_sp_',
28
- "+": "_plus_",
29
- // '-': '_m_',
30
- ";": "_se_",
31
- "<": "_l_",
32
- "~": "_t_",
33
- "=": "_e_",
34
- ">": "_g_",
35
- "?": "_qu_",
36
- "^": "_ca_",
37
- "`": "_bq_",
38
- "|": "_b_",
39
- "$": "_do_"
40
- // _: '_u_'
41
- };
42
- var MappingChars2StringEntries = Object.entries(MappingChars2String);
43
- var SimpleMappingChars2String = {
44
- "[": "_",
45
- "]": "_",
46
- "(": "_",
47
- ")": "_",
48
- "{": "_",
49
- "}": "_",
50
- "+": "a",
51
- ",": "b",
52
- ":": "c",
53
- ".": "d",
54
- "=": "e",
55
- ";": "f",
56
- ">": "g",
57
- "#": "h",
58
- "!": "i",
59
- "@": "j",
60
- "^": "k",
61
- "<": "l",
62
- "*": "m",
63
- "&": "n",
64
- "?": "o",
65
- "%": "p",
66
- "'": "q",
67
- "$": "r",
68
- "/": "s",
69
- "~": "t",
70
- "|": "u",
71
- "`": "v",
72
- "\\": "w",
73
- '"': "x"
74
- };
75
- var SimpleMappingChars2StringEntries = Object.entries(SimpleMappingChars2String);
76
- var MAX_ASCII_CHAR_CODE = 127;
77
- function isPlainObject(value) {
78
- if (value === null || typeof value !== "object") {
79
- return false;
80
- }
81
- const prototype = Object.getPrototypeOf(value);
82
- if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
83
- return false;
84
- }
85
- if (Symbol.iterator in value) {
86
- return false;
87
- }
88
- if (Symbol.toStringTag in value) {
89
- return Object.prototype.toString.call(value) === "[object Module]";
90
- }
91
- return true;
92
- }
93
- function _defu(baseObject, defaults, namespace = ".", merger) {
94
- if (!isPlainObject(defaults)) {
95
- return _defu(baseObject, {}, namespace, merger);
96
- }
97
- const object = Object.assign({}, defaults);
98
- for (const key in baseObject) {
99
- if (key === "__proto__" || key === "constructor") {
100
- continue;
101
- }
102
- const value = baseObject[key];
103
- if (value === null || value === void 0) {
104
- continue;
105
- }
106
- if (merger && merger(object, key, value, namespace)) {
107
- continue;
108
- }
109
- if (Array.isArray(value) && Array.isArray(object[key])) {
110
- object[key] = [...value, ...object[key]];
111
- } else if (isPlainObject(value) && isPlainObject(object[key])) {
112
- object[key] = _defu(
113
- value,
114
- object[key],
115
- (namespace ? `${namespace}.` : "") + key.toString(),
116
- merger
117
- );
118
- } else {
119
- object[key] = value;
120
- }
121
- }
122
- return object;
123
- }
124
- function createDefu(merger) {
125
- return (...arguments_) => (
126
- // eslint-disable-next-line unicorn/no-array-reduce
127
- arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
128
- );
129
- }
130
- var defu = createDefu();
131
- function isAsciiNumber(code) {
132
- return code >= 48 && code <= 57;
133
- }
134
- function handleFirstCharacter(char, nextChar, ignoreHead) {
135
- if (!ignoreHead) {
136
- const code = char.codePointAt(0);
137
- if (isAsciiNumber(code)) {
138
- return `_${char}`;
139
- }
140
- if (char === "-" && nextChar && isAsciiNumber(nextChar.codePointAt(0))) {
141
- return `_${char}`;
142
- }
143
- if (char === "-" && nextChar === void 0) {
144
- return `_${char}`;
145
- }
146
- }
147
- return char;
148
- }
149
- function escape(selectors, options) {
150
- if (selectors.length === 0) {
151
- return "";
152
- }
153
- const { map, ignoreHead } = defu(options, {
154
- map: SimpleMappingChars2String,
155
- ignoreHead: false
156
- });
157
- const sb = [];
158
- for (let i = 0; i < selectors.length; i++) {
159
- const char = selectors[i];
160
- const code = char.codePointAt(0);
161
- if (code !== void 0) {
162
- if (code > MAX_ASCII_CHAR_CODE) {
163
- sb.push(`u${code.toString(16)}`);
164
- } else {
165
- const hit = map[char];
166
- if (hit) {
167
- sb.push(hit);
168
- } else if (i === 0) {
169
- sb.push(handleFirstCharacter(char, selectors[i + 1], ignoreHead));
170
- } else {
171
- sb.push(char);
172
- }
173
- }
174
- }
175
- }
176
- return sb.join("");
177
- }
178
-
179
- // ../weapp-tailwindcss/dist/chunk-U7O2XXYR.mjs
180
- function replaceWxml(original, options = {
181
- keepEOL: false,
182
- escapeMap: SimpleMappingChars2String
183
- }) {
184
- const { keepEOL, escapeMap, mangleContext, ignoreHead } = options;
185
- let res = original;
186
- if (!keepEOL) {
187
- res = res.replaceAll(/[\n\r]+/g, "");
188
- }
189
- if (mangleContext) {
190
- res = mangleContext.wxmlHandler(res);
191
- }
192
- res = escape(res, {
193
- map: escapeMap,
194
- ignoreHead
195
- });
196
- return res;
197
- }
198
-
199
- // ../weapp-tailwindcss/dist/escape.mjs
200
- var weappTwIgnore = String.raw;
201
-
202
- // src/index.ts
203
9
  function cn(...inputs) {
204
10
  return replaceWxml(twMerge(clsx(inputs)));
205
11
  }
206
- function cva(...inputs) {
207
- const fn = _cva(...inputs);
208
- return (...props) => {
209
- return replaceWxml(fn(...props));
210
- };
211
- }
212
12
  export {
213
13
  cn,
214
- cva,
215
14
  weappTwIgnore
216
15
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/merge",
3
3
  "type": "module",
4
- "version": "1.0.0-alpha.1",
4
+ "version": "1.0.0-alpha.3",
5
5
  "description": "weapp-tailwindcss",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -20,6 +20,11 @@
20
20
  "types": "./dist/index.d.ts",
21
21
  "import": "./dist/index.js",
22
22
  "require": "./dist/index.cjs"
23
+ },
24
+ "./cva": {
25
+ "types": "./dist/cva.d.ts",
26
+ "import": "./dist/cva.js",
27
+ "require": "./dist/cva.cjs"
23
28
  }
24
29
  },
25
30
  "files": [
@@ -31,7 +36,7 @@
31
36
  "tailwind-merge": "^2.6.0"
32
37
  },
33
38
  "devDependencies": {
34
- "weapp-tailwindcss": "4.0.0-alpha.3"
39
+ "weapp-tailwindcss": "4.0.0-alpha.7"
35
40
  },
36
41
  "scripts": {
37
42
  "dev": "tsup --watch --sourcemap",