@weapp-tailwindcss/merge 1.3.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-2KHGHDND.js +71 -0
- package/dist/chunk-2VBLBSOS.js +53 -0
- package/dist/{chunk-HLKKHLS5.js → chunk-7WDGWM6R.js} +1 -1
- package/dist/{chunk-QKJSGQ4H.cjs → chunk-EJHUA3F5.cjs} +2 -2
- package/dist/chunk-PZ4IYNKU.cjs +71 -0
- package/dist/chunk-V4RUVSPV.cjs +53 -0
- package/dist/cva.cjs +5 -3
- package/dist/cva.d.cts +2 -1
- package/dist/cva.d.ts +2 -1
- package/dist/cva.js +6 -4
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -3
- package/dist/postinstall.cjs +198 -21
- package/dist/postinstall.d.cts +2 -0
- package/dist/postinstall.d.ts +2 -0
- package/dist/postinstall.js +209 -0
- package/dist/types-DSXe0vN9.d.cts +15 -0
- package/dist/types-DSXe0vN9.d.ts +15 -0
- package/dist/v3.cjs +4 -5
- package/dist/v3.d.cts +4 -2
- package/dist/v3.d.ts +4 -2
- package/dist/v3.js +3 -4
- package/dist/v4.cjs +4 -4
- package/dist/v4.d.cts +4 -2
- package/dist/v4.d.ts +4 -2
- package/dist/v4.js +3 -3
- package/dist/variants.cjs +76 -0
- package/dist/variants.d.cts +19 -0
- package/dist/variants.d.ts +19 -0
- package/dist/variants.js +76 -0
- package/package.json +9 -3
- package/scripts/postinstall.mjs +83 -0
- package/dist/chunk-4KECYPIX.js +0 -210
- package/dist/chunk-BWF73VRW.cjs +0 -210
- package/dist/chunk-JONLHXMV.cjs +0 -44
- package/dist/chunk-NNOJ7CWV.js +0 -44
- package/dist/types-NMbxxvgq.d.cts +0 -13
- package/dist/types-NMbxxvgq.d.ts +0 -13
- package/scripts/postinstall.cjs +0 -14
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
// src/postinstall.ts
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import process from "process";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
import { getPackageInfoSync } from "local-pkg";
|
|
7
|
+
import satisfies from "semver/functions/satisfies.js";
|
|
8
|
+
var LOG_PREFIX = "[weapp-tailwindcss/merge]";
|
|
9
|
+
var FALLBACK_VARIANT = "v4";
|
|
10
|
+
var EXTENSIONS = ["cjs", "d.cts", "d.ts", "js"];
|
|
11
|
+
function printLine(message, stream) {
|
|
12
|
+
stream.write(`${LOG_PREFIX} ${message}
|
|
13
|
+
`);
|
|
14
|
+
}
|
|
15
|
+
function info(message) {
|
|
16
|
+
printLine(message, process.stdout);
|
|
17
|
+
}
|
|
18
|
+
function warn(message) {
|
|
19
|
+
printLine(message, process.stderr);
|
|
20
|
+
}
|
|
21
|
+
function error(message) {
|
|
22
|
+
printLine(message, process.stderr);
|
|
23
|
+
}
|
|
24
|
+
function describeVariant(variant) {
|
|
25
|
+
if (variant === "v3") {
|
|
26
|
+
return "tailwind-merge@2 runtime (Tailwind CSS v3)";
|
|
27
|
+
}
|
|
28
|
+
return "tailwind-merge@3 runtime (Tailwind CSS v4)";
|
|
29
|
+
}
|
|
30
|
+
function parseBooleanEnv(name) {
|
|
31
|
+
const value = process.env[name];
|
|
32
|
+
if (!value) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return ["1", "true", "yes", "on"].includes(value.trim().toLowerCase());
|
|
36
|
+
}
|
|
37
|
+
function parseVariantEnv(value) {
|
|
38
|
+
if (!value) {
|
|
39
|
+
return void 0;
|
|
40
|
+
}
|
|
41
|
+
const normalized = value.trim().toLowerCase().replace(/^v/, "");
|
|
42
|
+
if (normalized === "3") {
|
|
43
|
+
return "v3";
|
|
44
|
+
}
|
|
45
|
+
if (normalized === "4") {
|
|
46
|
+
return "v4";
|
|
47
|
+
}
|
|
48
|
+
warn(`Unknown runtime variant "${value}". Supported values are "v3" and "v4".`);
|
|
49
|
+
return void 0;
|
|
50
|
+
}
|
|
51
|
+
function readEnvConfig() {
|
|
52
|
+
const forcedVariantEnv = process.env.WEAPP_TW_MERGE_TARGET_VERSION ?? process.env.WEAPP_TW_MERGE_FORCE_VERSION;
|
|
53
|
+
const forcedVariant = parseVariantEnv(forcedVariantEnv);
|
|
54
|
+
return {
|
|
55
|
+
forcedVariant,
|
|
56
|
+
disableFallback: parseBooleanEnv("WEAPP_TW_MERGE_DISABLE_FALLBACK") || parseBooleanEnv("WEAPP_TW_MERGE_NO_FALLBACK"),
|
|
57
|
+
strict: parseBooleanEnv("WEAPP_TW_MERGE_STRICT")
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function unique(values) {
|
|
61
|
+
return Array.from(new Set(values.filter((value) => value != null)));
|
|
62
|
+
}
|
|
63
|
+
function detectTailwindInfo() {
|
|
64
|
+
const searchRoots = unique([
|
|
65
|
+
process.env.WEAPP_TW_MERGE_RESOLVE_ROOT,
|
|
66
|
+
process.env.INIT_CWD,
|
|
67
|
+
process.env.npm_config_local_prefix,
|
|
68
|
+
process.env.PWD,
|
|
69
|
+
process.cwd()
|
|
70
|
+
]);
|
|
71
|
+
for (const root of searchRoots) {
|
|
72
|
+
try {
|
|
73
|
+
const info2 = getPackageInfoSync("tailwindcss", { paths: [root] });
|
|
74
|
+
if (info2?.version) {
|
|
75
|
+
return {
|
|
76
|
+
version: info2.version,
|
|
77
|
+
rootPath: info2.rootPath
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
} catch {
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const info2 = getPackageInfoSync("tailwindcss");
|
|
85
|
+
if (info2?.version) {
|
|
86
|
+
return {
|
|
87
|
+
version: info2.version,
|
|
88
|
+
rootPath: info2.rootPath
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
} catch {
|
|
92
|
+
}
|
|
93
|
+
return void 0;
|
|
94
|
+
}
|
|
95
|
+
function resolveVariant(env, tailwindInfo) {
|
|
96
|
+
if (env.forcedVariant) {
|
|
97
|
+
return {
|
|
98
|
+
variant: env.forcedVariant,
|
|
99
|
+
reason: "forced by environment",
|
|
100
|
+
detected: true
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (tailwindInfo) {
|
|
104
|
+
const target = satisfies(tailwindInfo.version, "^4.0.0-0") ? "v4" : "v3";
|
|
105
|
+
return {
|
|
106
|
+
variant: target,
|
|
107
|
+
reason: `tailwindcss@${tailwindInfo.version}`,
|
|
108
|
+
detected: true
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
reason: "tailwindcss not found",
|
|
113
|
+
detected: false
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function readFile(pathname) {
|
|
117
|
+
return fs.readFileSync(pathname);
|
|
118
|
+
}
|
|
119
|
+
function copyFileIfChanged(source, target) {
|
|
120
|
+
const sourceBuffer = readFile(source);
|
|
121
|
+
if (fs.existsSync(target)) {
|
|
122
|
+
try {
|
|
123
|
+
const targetBuffer = readFile(target);
|
|
124
|
+
if (targetBuffer.equals(sourceBuffer)) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
} catch {
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
fs.writeFileSync(target, sourceBuffer);
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
function ensureVariant(distDir, variant) {
|
|
134
|
+
const changedFiles = [];
|
|
135
|
+
for (const ext of EXTENSIONS) {
|
|
136
|
+
const source = path.resolve(distDir, `${variant}.${ext}`);
|
|
137
|
+
if (!fs.existsSync(source)) {
|
|
138
|
+
throw new Error(`Missing source file ${path.relative(process.cwd(), source)}`);
|
|
139
|
+
}
|
|
140
|
+
const target = path.resolve(distDir, `index.${ext}`);
|
|
141
|
+
if (copyFileIfChanged(source, target)) {
|
|
142
|
+
changedFiles.push(path.basename(target));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
changedFiles
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function main() {
|
|
150
|
+
const resolveDistDir = () => {
|
|
151
|
+
if (typeof __dirname === "string") {
|
|
152
|
+
return path.resolve(__dirname, "../dist");
|
|
153
|
+
}
|
|
154
|
+
const getImportMetaUrl = new Function("return import.meta.url");
|
|
155
|
+
return fileURLToPath(new URL("../dist/", getImportMetaUrl()));
|
|
156
|
+
};
|
|
157
|
+
const distDir = resolveDistDir();
|
|
158
|
+
if (!fs.existsSync(distDir)) {
|
|
159
|
+
warn("dist directory not found. Skipping runtime switch.");
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const envConfig = readEnvConfig();
|
|
163
|
+
const tailwindInfo = detectTailwindInfo();
|
|
164
|
+
const resolution = resolveVariant(envConfig, tailwindInfo);
|
|
165
|
+
let targetVariant;
|
|
166
|
+
if (!resolution.variant) {
|
|
167
|
+
warn(`${resolution.reason}.`);
|
|
168
|
+
if (envConfig.disableFallback) {
|
|
169
|
+
warn("Fallback is disabled. Default entry will keep the bundled runtime.");
|
|
170
|
+
warn('You can import "@weapp-tailwindcss/merge/v3" or "@weapp-tailwindcss/merge/v4" manually when needed.');
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
targetVariant = FALLBACK_VARIANT;
|
|
174
|
+
info(`Fallback to ${describeVariant(targetVariant)}.`);
|
|
175
|
+
} else {
|
|
176
|
+
targetVariant = resolution.variant;
|
|
177
|
+
info(`Using ${describeVariant(targetVariant)} (${resolution.reason}).`);
|
|
178
|
+
}
|
|
179
|
+
try {
|
|
180
|
+
const { changedFiles } = ensureVariant(distDir, targetVariant);
|
|
181
|
+
if (changedFiles.length > 0) {
|
|
182
|
+
info(`Updated entry files: ${changedFiles.join(", ")}`);
|
|
183
|
+
} else {
|
|
184
|
+
info("Entry files already match the requested runtime.");
|
|
185
|
+
}
|
|
186
|
+
} catch (err) {
|
|
187
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
188
|
+
error(`Failed to switch runtime to ${targetVariant}. ${message}`);
|
|
189
|
+
if (envConfig.disableFallback || targetVariant === FALLBACK_VARIANT) {
|
|
190
|
+
warn("Leaving existing files untouched. Import a specific runtime manually if required.");
|
|
191
|
+
} else {
|
|
192
|
+
try {
|
|
193
|
+
const { changedFiles } = ensureVariant(distDir, FALLBACK_VARIANT);
|
|
194
|
+
if (changedFiles.length > 0) {
|
|
195
|
+
info(`Reverted to fallback runtime (${describeVariant(FALLBACK_VARIANT)}).`);
|
|
196
|
+
} else {
|
|
197
|
+
info("Fallback runtime was already in use. No changes applied.");
|
|
198
|
+
}
|
|
199
|
+
} catch (fallbackErr) {
|
|
200
|
+
const fallbackMessage = fallbackErr instanceof Error ? fallbackErr.message : String(fallbackErr);
|
|
201
|
+
error(`Failed to apply fallback runtime. ${fallbackMessage}`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (envConfig.strict) {
|
|
205
|
+
process.exitCode = process.exitCode ?? 1;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
main();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EscapeOptions, UnescapeOptions } from '@weapp-core/escape';
|
|
2
|
+
import { ClassValue } from 'clsx';
|
|
3
|
+
|
|
4
|
+
type EscapeConfig = false | EscapeOptions;
|
|
5
|
+
type UnescapeConfig = false | UnescapeOptions;
|
|
6
|
+
interface CreateOptions {
|
|
7
|
+
escape?: EscapeConfig;
|
|
8
|
+
unescape?: UnescapeConfig;
|
|
9
|
+
}
|
|
10
|
+
type TailwindMergeLibraryFn = (...inputs: any[]) => string;
|
|
11
|
+
type TailwindMergeRuntime = (...inputs: ClassValue[]) => string;
|
|
12
|
+
type TailwindMergeFactory<TFactory extends (...args: any[]) => TailwindMergeLibraryFn> = (...args: Parameters<TFactory>) => TailwindMergeRuntime;
|
|
13
|
+
type TailwindMergeVersion = 2 | 3;
|
|
14
|
+
|
|
15
|
+
export type { CreateOptions as C, EscapeConfig as E, TailwindMergeVersion as T, UnescapeConfig as U, TailwindMergeRuntime as a, TailwindMergeFactory as b };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EscapeOptions, UnescapeOptions } from '@weapp-core/escape';
|
|
2
|
+
import { ClassValue } from 'clsx';
|
|
3
|
+
|
|
4
|
+
type EscapeConfig = false | EscapeOptions;
|
|
5
|
+
type UnescapeConfig = false | UnescapeOptions;
|
|
6
|
+
interface CreateOptions {
|
|
7
|
+
escape?: EscapeConfig;
|
|
8
|
+
unescape?: UnescapeConfig;
|
|
9
|
+
}
|
|
10
|
+
type TailwindMergeLibraryFn = (...inputs: any[]) => string;
|
|
11
|
+
type TailwindMergeRuntime = (...inputs: ClassValue[]) => string;
|
|
12
|
+
type TailwindMergeFactory<TFactory extends (...args: any[]) => TailwindMergeLibraryFn> = (...args: Parameters<TFactory>) => TailwindMergeRuntime;
|
|
13
|
+
type TailwindMergeVersion = 2 | 3;
|
|
14
|
+
|
|
15
|
+
export type { CreateOptions as C, EscapeConfig as E, TailwindMergeVersion as T, UnescapeConfig as U, TailwindMergeRuntime as a, TailwindMergeFactory as b };
|
package/dist/v3.cjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var _chunkJONLHXMVcjs = require('./chunk-JONLHXMV.cjs');
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
var _chunkV4RUVSPVcjs = require('./chunk-V4RUVSPV.cjs');
|
|
5
|
+
require('./chunk-PZ4IYNKU.cjs');
|
|
7
6
|
|
|
8
7
|
// src/v3.ts
|
|
9
8
|
|
|
@@ -14,7 +13,7 @@ var _chunkBWF73VRWcjs = require('./chunk-BWF73VRW.cjs');
|
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
var _tailwindmergev2 = require('tailwind-merge-v2');
|
|
17
|
-
var create =
|
|
16
|
+
var create = _chunkV4RUVSPVcjs.createRuntimeFactory.call(void 0, {
|
|
18
17
|
createTailwindMerge: _tailwindmergev2.createTailwindMerge,
|
|
19
18
|
extendTailwindMerge: _tailwindmergev2.extendTailwindMerge,
|
|
20
19
|
twJoin: _tailwindmergev2.twJoin,
|
|
@@ -38,4 +37,4 @@ var {
|
|
|
38
37
|
|
|
39
38
|
|
|
40
39
|
|
|
41
|
-
exports.create = create; exports.createTailwindMerge = createTailwindMerge; exports.extendTailwindMerge = extendTailwindMerge; exports.getDefaultConfig = _tailwindmergev2.getDefaultConfig; exports.mergeConfigs = _tailwindmergev2.mergeConfigs; exports.tailwindMergeVersion = tailwindMergeVersion; exports.twJoin = twJoin; exports.twMerge = twMerge; exports.weappTwIgnore =
|
|
40
|
+
exports.create = create; exports.createTailwindMerge = createTailwindMerge; exports.extendTailwindMerge = extendTailwindMerge; exports.getDefaultConfig = _tailwindmergev2.getDefaultConfig; exports.mergeConfigs = _tailwindmergev2.mergeConfigs; exports.tailwindMergeVersion = tailwindMergeVersion; exports.twJoin = twJoin; exports.twMerge = twMerge; exports.weappTwIgnore = _chunkV4RUVSPVcjs.weappTwIgnore;
|
package/dist/v3.d.cts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as tailwind_merge_v2 from 'tailwind-merge-v2';
|
|
2
2
|
import { createTailwindMerge as createTailwindMerge$1 } from 'tailwind-merge-v2';
|
|
3
3
|
export { getDefaultConfig, mergeConfigs } from 'tailwind-merge-v2';
|
|
4
|
-
import { C as CreateOptions, T as TailwindMergeVersion, a as TailwindMergeRuntime, b as TailwindMergeFactory } from './types-
|
|
4
|
+
import { C as CreateOptions, T as TailwindMergeVersion, a as TailwindMergeRuntime, b as TailwindMergeFactory } from './types-DSXe0vN9.cjs';
|
|
5
|
+
export { E as EscapeConfig, U as UnescapeConfig } from './types-DSXe0vN9.cjs';
|
|
5
6
|
export { ClassValue } from 'clsx';
|
|
6
7
|
export { weappTwIgnore } from 'weapp-tailwindcss/escape';
|
|
8
|
+
import '@weapp-core/escape';
|
|
7
9
|
|
|
8
10
|
declare const create: (createOptions?: CreateOptions) => {
|
|
9
11
|
version: TailwindMergeVersion;
|
|
@@ -18,4 +20,4 @@ declare const twJoin: TailwindMergeRuntime;
|
|
|
18
20
|
declare const extendTailwindMerge: TailwindMergeFactory<(<AdditionalClassGroupIds extends string = never, AdditionalThemeGroupIds extends string = never>(configExtension: tailwind_merge_v2.ConfigExtension<tailwind_merge_v2.DefaultClassGroupIds | AdditionalClassGroupIds, tailwind_merge_v2.DefaultThemeGroupIds | AdditionalThemeGroupIds> | ((config: tailwind_merge_v2.Config<string, string>) => tailwind_merge_v2.Config<string, string>), ...createConfig: ((config: tailwind_merge_v2.Config<string, string>) => tailwind_merge_v2.Config<string, string>)[]) => (...classLists: tailwind_merge_v2.ClassNameValue[]) => string)>;
|
|
19
21
|
declare const createTailwindMerge: TailwindMergeFactory<typeof createTailwindMerge$1>;
|
|
20
22
|
|
|
21
|
-
export { create, createTailwindMerge, extendTailwindMerge, tailwindMergeVersion, twJoin, twMerge };
|
|
23
|
+
export { CreateOptions, create, createTailwindMerge, extendTailwindMerge, tailwindMergeVersion, twJoin, twMerge };
|
package/dist/v3.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as tailwind_merge_v2 from 'tailwind-merge-v2';
|
|
2
2
|
import { createTailwindMerge as createTailwindMerge$1 } from 'tailwind-merge-v2';
|
|
3
3
|
export { getDefaultConfig, mergeConfigs } from 'tailwind-merge-v2';
|
|
4
|
-
import { C as CreateOptions, T as TailwindMergeVersion, a as TailwindMergeRuntime, b as TailwindMergeFactory } from './types-
|
|
4
|
+
import { C as CreateOptions, T as TailwindMergeVersion, a as TailwindMergeRuntime, b as TailwindMergeFactory } from './types-DSXe0vN9.js';
|
|
5
|
+
export { E as EscapeConfig, U as UnescapeConfig } from './types-DSXe0vN9.js';
|
|
5
6
|
export { ClassValue } from 'clsx';
|
|
6
7
|
export { weappTwIgnore } from 'weapp-tailwindcss/escape';
|
|
8
|
+
import '@weapp-core/escape';
|
|
7
9
|
|
|
8
10
|
declare const create: (createOptions?: CreateOptions) => {
|
|
9
11
|
version: TailwindMergeVersion;
|
|
@@ -18,4 +20,4 @@ declare const twJoin: TailwindMergeRuntime;
|
|
|
18
20
|
declare const extendTailwindMerge: TailwindMergeFactory<(<AdditionalClassGroupIds extends string = never, AdditionalThemeGroupIds extends string = never>(configExtension: tailwind_merge_v2.ConfigExtension<tailwind_merge_v2.DefaultClassGroupIds | AdditionalClassGroupIds, tailwind_merge_v2.DefaultThemeGroupIds | AdditionalThemeGroupIds> | ((config: tailwind_merge_v2.Config<string, string>) => tailwind_merge_v2.Config<string, string>), ...createConfig: ((config: tailwind_merge_v2.Config<string, string>) => tailwind_merge_v2.Config<string, string>)[]) => (...classLists: tailwind_merge_v2.ClassNameValue[]) => string)>;
|
|
19
21
|
declare const createTailwindMerge: TailwindMergeFactory<typeof createTailwindMerge$1>;
|
|
20
22
|
|
|
21
|
-
export { create, createTailwindMerge, extendTailwindMerge, tailwindMergeVersion, twJoin, twMerge };
|
|
23
|
+
export { CreateOptions, create, createTailwindMerge, extendTailwindMerge, tailwindMergeVersion, twJoin, twMerge };
|
package/dist/v3.js
CHANGED
package/dist/v4.cjs
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
require('./chunk-JONLHXMV.cjs');
|
|
10
|
+
var _chunkEJHUA3F5cjs = require('./chunk-EJHUA3F5.cjs');
|
|
12
11
|
|
|
13
12
|
|
|
14
|
-
var
|
|
13
|
+
var _chunkV4RUVSPVcjs = require('./chunk-V4RUVSPV.cjs');
|
|
14
|
+
require('./chunk-PZ4IYNKU.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
@@ -22,4 +22,4 @@ var _chunkBWF73VRWcjs = require('./chunk-BWF73VRW.cjs');
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
exports.create =
|
|
25
|
+
exports.create = _chunkEJHUA3F5cjs.create; exports.createTailwindMerge = _chunkEJHUA3F5cjs.createTailwindMerge; exports.extendTailwindMerge = _chunkEJHUA3F5cjs.extendTailwindMerge; exports.getDefaultConfig = _chunkEJHUA3F5cjs.getDefaultConfig; exports.mergeConfigs = _chunkEJHUA3F5cjs.mergeConfigs; exports.tailwindMergeVersion = _chunkEJHUA3F5cjs.tailwindMergeVersion; exports.twJoin = _chunkEJHUA3F5cjs.twJoin; exports.twMerge = _chunkEJHUA3F5cjs.twMerge; exports.weappTwIgnore = _chunkV4RUVSPVcjs.weappTwIgnore;
|
package/dist/v4.d.cts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as tailwind_merge from 'tailwind-merge';
|
|
2
2
|
import { createTailwindMerge as createTailwindMerge$1 } from 'tailwind-merge';
|
|
3
3
|
export { getDefaultConfig, mergeConfigs } from 'tailwind-merge';
|
|
4
|
-
import { C as CreateOptions, T as TailwindMergeVersion, a as TailwindMergeRuntime, b as TailwindMergeFactory } from './types-
|
|
4
|
+
import { C as CreateOptions, T as TailwindMergeVersion, a as TailwindMergeRuntime, b as TailwindMergeFactory } from './types-DSXe0vN9.cjs';
|
|
5
|
+
export { E as EscapeConfig, U as UnescapeConfig } from './types-DSXe0vN9.cjs';
|
|
5
6
|
export { ClassValue } from 'clsx';
|
|
6
7
|
export { weappTwIgnore } from 'weapp-tailwindcss/escape';
|
|
8
|
+
import '@weapp-core/escape';
|
|
7
9
|
|
|
8
10
|
declare const create: (createOptions?: CreateOptions) => {
|
|
9
11
|
version: TailwindMergeVersion;
|
|
@@ -18,4 +20,4 @@ declare const twJoin: TailwindMergeRuntime;
|
|
|
18
20
|
declare const extendTailwindMerge: TailwindMergeFactory<(<AdditionalClassGroupIds extends string = never, AdditionalThemeGroupIds extends string = never>(configExtension: tailwind_merge.ConfigExtension<tailwind_merge.DefaultClassGroupIds | AdditionalClassGroupIds, tailwind_merge.DefaultThemeGroupIds | AdditionalThemeGroupIds> | ((config: tailwind_merge.Config<string, string>) => tailwind_merge.Config<string, string>), ...createConfig: ((config: tailwind_merge.Config<string, string>) => tailwind_merge.Config<string, string>)[]) => (...classLists: tailwind_merge.ClassNameValue[]) => string)>;
|
|
19
21
|
declare const createTailwindMerge: TailwindMergeFactory<typeof createTailwindMerge$1>;
|
|
20
22
|
|
|
21
|
-
export { create, createTailwindMerge, extendTailwindMerge, tailwindMergeVersion, twJoin, twMerge };
|
|
23
|
+
export { CreateOptions, create, createTailwindMerge, extendTailwindMerge, tailwindMergeVersion, twJoin, twMerge };
|
package/dist/v4.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as tailwind_merge from 'tailwind-merge';
|
|
2
2
|
import { createTailwindMerge as createTailwindMerge$1 } from 'tailwind-merge';
|
|
3
3
|
export { getDefaultConfig, mergeConfigs } from 'tailwind-merge';
|
|
4
|
-
import { C as CreateOptions, T as TailwindMergeVersion, a as TailwindMergeRuntime, b as TailwindMergeFactory } from './types-
|
|
4
|
+
import { C as CreateOptions, T as TailwindMergeVersion, a as TailwindMergeRuntime, b as TailwindMergeFactory } from './types-DSXe0vN9.js';
|
|
5
|
+
export { E as EscapeConfig, U as UnescapeConfig } from './types-DSXe0vN9.js';
|
|
5
6
|
export { ClassValue } from 'clsx';
|
|
6
7
|
export { weappTwIgnore } from 'weapp-tailwindcss/escape';
|
|
8
|
+
import '@weapp-core/escape';
|
|
7
9
|
|
|
8
10
|
declare const create: (createOptions?: CreateOptions) => {
|
|
9
11
|
version: TailwindMergeVersion;
|
|
@@ -18,4 +20,4 @@ declare const twJoin: TailwindMergeRuntime;
|
|
|
18
20
|
declare const extendTailwindMerge: TailwindMergeFactory<(<AdditionalClassGroupIds extends string = never, AdditionalThemeGroupIds extends string = never>(configExtension: tailwind_merge.ConfigExtension<tailwind_merge.DefaultClassGroupIds | AdditionalClassGroupIds, tailwind_merge.DefaultThemeGroupIds | AdditionalThemeGroupIds> | ((config: tailwind_merge.Config<string, string>) => tailwind_merge.Config<string, string>), ...createConfig: ((config: tailwind_merge.Config<string, string>) => tailwind_merge.Config<string, string>)[]) => (...classLists: tailwind_merge.ClassNameValue[]) => string)>;
|
|
19
21
|
declare const createTailwindMerge: TailwindMergeFactory<typeof createTailwindMerge$1>;
|
|
20
22
|
|
|
21
|
-
export { create, createTailwindMerge, extendTailwindMerge, tailwindMergeVersion, twJoin, twMerge };
|
|
23
|
+
export { CreateOptions, create, createTailwindMerge, extendTailwindMerge, tailwindMergeVersion, twJoin, twMerge };
|
package/dist/v4.js
CHANGED
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
tailwindMergeVersion,
|
|
8
8
|
twJoin,
|
|
9
9
|
twMerge
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-NNOJ7CWV.js";
|
|
10
|
+
} from "./chunk-7WDGWM6R.js";
|
|
12
11
|
import {
|
|
13
12
|
weappTwIgnore
|
|
14
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-2VBLBSOS.js";
|
|
14
|
+
import "./chunk-2KHGHDND.js";
|
|
15
15
|
export {
|
|
16
16
|
create,
|
|
17
17
|
createTailwindMerge,
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkEJHUA3F5cjs = require('./chunk-EJHUA3F5.cjs');
|
|
4
|
+
require('./chunk-V4RUVSPV.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkPZ4IYNKUcjs = require('./chunk-PZ4IYNKU.cjs');
|
|
8
|
+
|
|
9
|
+
// src/variants.ts
|
|
10
|
+
var _tailwindvariants = require('tailwind-variants');
|
|
11
|
+
var _chunkIFWU2MEMjs = require('tailwind-variants/dist/chunk-IFWU2MEM.js');
|
|
12
|
+
function createVariantsRuntime(options) {
|
|
13
|
+
const transformers = _chunkPZ4IYNKUcjs.resolveTransformers.call(void 0, options);
|
|
14
|
+
const tailwindMergeRuntime = _chunkEJHUA3F5cjs.create.call(void 0, options);
|
|
15
|
+
let cachedConfig;
|
|
16
|
+
let cachedMergeFn = tailwindMergeRuntime.twMerge;
|
|
17
|
+
const getMergeFn = (config) => {
|
|
18
|
+
if (!config) {
|
|
19
|
+
return tailwindMergeRuntime.twMerge;
|
|
20
|
+
}
|
|
21
|
+
if (config === cachedConfig) {
|
|
22
|
+
return cachedMergeFn;
|
|
23
|
+
}
|
|
24
|
+
cachedConfig = config;
|
|
25
|
+
cachedMergeFn = tailwindMergeRuntime.extendTailwindMerge(config);
|
|
26
|
+
return cachedMergeFn;
|
|
27
|
+
};
|
|
28
|
+
const cn2 = (...classes) => {
|
|
29
|
+
const aggregated = _tailwindvariants.cnBase.call(void 0, ...classes);
|
|
30
|
+
return (config) => {
|
|
31
|
+
if (aggregated == null) {
|
|
32
|
+
return aggregated;
|
|
33
|
+
}
|
|
34
|
+
const shouldMerge = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _ => _.twMerge]), () => ( true));
|
|
35
|
+
if (!shouldMerge) {
|
|
36
|
+
const normalized = transformers.unescape(aggregated);
|
|
37
|
+
return transformers.escape(normalized);
|
|
38
|
+
}
|
|
39
|
+
const mergeFn = getMergeFn(_optionalChain([config, 'optionalAccess', _2 => _2.twMergeConfig]));
|
|
40
|
+
return mergeFn(aggregated);
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
const factory = _chunkIFWU2MEMjs.c.call(void 0, cn2);
|
|
44
|
+
const cnBase2 = (...classes) => {
|
|
45
|
+
const aggregated = _tailwindvariants.cnBase.call(void 0, ...classes);
|
|
46
|
+
if (aggregated == null) {
|
|
47
|
+
return aggregated;
|
|
48
|
+
}
|
|
49
|
+
const normalized = transformers.unescape(aggregated);
|
|
50
|
+
return transformers.escape(normalized);
|
|
51
|
+
};
|
|
52
|
+
return {
|
|
53
|
+
cnBase: cnBase2,
|
|
54
|
+
cn: cn2,
|
|
55
|
+
tv: factory.tv,
|
|
56
|
+
createTV: factory.createTV
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function create2(options) {
|
|
60
|
+
return createVariantsRuntime(options);
|
|
61
|
+
}
|
|
62
|
+
var variantsRuntime = create2();
|
|
63
|
+
var {
|
|
64
|
+
cnBase,
|
|
65
|
+
cn,
|
|
66
|
+
tv,
|
|
67
|
+
createTV
|
|
68
|
+
} = variantsRuntime;
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
exports.cn = cn; exports.cnBase = cnBase; exports.create = create2; exports.createTV = createTV; exports.defaultConfig = _tailwindvariants.defaultConfig; exports.tv = tv;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CnOptions, TWMConfig, CnReturn, cnBase as cnBase$1, TV, createTV as createTV$1 } from 'tailwind-variants';
|
|
2
|
+
export { CnOptions, CnReturn, TV, TVConfig, TWMConfig, TWMergeConfig, defaultConfig } from 'tailwind-variants';
|
|
3
|
+
import { C as CreateOptions } from './types-DSXe0vN9.cjs';
|
|
4
|
+
import '@weapp-core/escape';
|
|
5
|
+
import 'clsx';
|
|
6
|
+
|
|
7
|
+
type TailwindVariantsCn = <T extends CnOptions>(...classes: T) => (config?: TWMConfig) => CnReturn;
|
|
8
|
+
declare function create(options?: CreateOptions): {
|
|
9
|
+
cnBase: (...classes: Parameters<typeof cnBase$1>) => string | undefined;
|
|
10
|
+
cn: TailwindVariantsCn;
|
|
11
|
+
tv: TV;
|
|
12
|
+
createTV: typeof createTV$1;
|
|
13
|
+
};
|
|
14
|
+
declare const cnBase: (...classes: Parameters<typeof cnBase$1>) => string | undefined;
|
|
15
|
+
declare const cn: TailwindVariantsCn;
|
|
16
|
+
declare const tv: TV;
|
|
17
|
+
declare const createTV: typeof createTV$1;
|
|
18
|
+
|
|
19
|
+
export { cn, cnBase, create, createTV, tv };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CnOptions, TWMConfig, CnReturn, cnBase as cnBase$1, TV, createTV as createTV$1 } from 'tailwind-variants';
|
|
2
|
+
export { CnOptions, CnReturn, TV, TVConfig, TWMConfig, TWMergeConfig, defaultConfig } from 'tailwind-variants';
|
|
3
|
+
import { C as CreateOptions } from './types-DSXe0vN9.js';
|
|
4
|
+
import '@weapp-core/escape';
|
|
5
|
+
import 'clsx';
|
|
6
|
+
|
|
7
|
+
type TailwindVariantsCn = <T extends CnOptions>(...classes: T) => (config?: TWMConfig) => CnReturn;
|
|
8
|
+
declare function create(options?: CreateOptions): {
|
|
9
|
+
cnBase: (...classes: Parameters<typeof cnBase$1>) => string | undefined;
|
|
10
|
+
cn: TailwindVariantsCn;
|
|
11
|
+
tv: TV;
|
|
12
|
+
createTV: typeof createTV$1;
|
|
13
|
+
};
|
|
14
|
+
declare const cnBase: (...classes: Parameters<typeof cnBase$1>) => string | undefined;
|
|
15
|
+
declare const cn: TailwindVariantsCn;
|
|
16
|
+
declare const tv: TV;
|
|
17
|
+
declare const createTV: typeof createTV$1;
|
|
18
|
+
|
|
19
|
+
export { cn, cnBase, create, createTV, tv };
|
package/dist/variants.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
create
|
|
3
|
+
} from "./chunk-7WDGWM6R.js";
|
|
4
|
+
import "./chunk-2VBLBSOS.js";
|
|
5
|
+
import {
|
|
6
|
+
resolveTransformers
|
|
7
|
+
} from "./chunk-2KHGHDND.js";
|
|
8
|
+
|
|
9
|
+
// src/variants.ts
|
|
10
|
+
import { defaultConfig, cnBase as tailwindVariantsCnBase } from "tailwind-variants";
|
|
11
|
+
import { c as createTailwindVariantsFactory } from "tailwind-variants/dist/chunk-IFWU2MEM.js";
|
|
12
|
+
function createVariantsRuntime(options) {
|
|
13
|
+
const transformers = resolveTransformers(options);
|
|
14
|
+
const tailwindMergeRuntime = create(options);
|
|
15
|
+
let cachedConfig;
|
|
16
|
+
let cachedMergeFn = tailwindMergeRuntime.twMerge;
|
|
17
|
+
const getMergeFn = (config) => {
|
|
18
|
+
if (!config) {
|
|
19
|
+
return tailwindMergeRuntime.twMerge;
|
|
20
|
+
}
|
|
21
|
+
if (config === cachedConfig) {
|
|
22
|
+
return cachedMergeFn;
|
|
23
|
+
}
|
|
24
|
+
cachedConfig = config;
|
|
25
|
+
cachedMergeFn = tailwindMergeRuntime.extendTailwindMerge(config);
|
|
26
|
+
return cachedMergeFn;
|
|
27
|
+
};
|
|
28
|
+
const cn2 = (...classes) => {
|
|
29
|
+
const aggregated = tailwindVariantsCnBase(...classes);
|
|
30
|
+
return (config) => {
|
|
31
|
+
if (aggregated == null) {
|
|
32
|
+
return aggregated;
|
|
33
|
+
}
|
|
34
|
+
const shouldMerge = config?.twMerge ?? true;
|
|
35
|
+
if (!shouldMerge) {
|
|
36
|
+
const normalized = transformers.unescape(aggregated);
|
|
37
|
+
return transformers.escape(normalized);
|
|
38
|
+
}
|
|
39
|
+
const mergeFn = getMergeFn(config?.twMergeConfig);
|
|
40
|
+
return mergeFn(aggregated);
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
const factory = createTailwindVariantsFactory(cn2);
|
|
44
|
+
const cnBase2 = (...classes) => {
|
|
45
|
+
const aggregated = tailwindVariantsCnBase(...classes);
|
|
46
|
+
if (aggregated == null) {
|
|
47
|
+
return aggregated;
|
|
48
|
+
}
|
|
49
|
+
const normalized = transformers.unescape(aggregated);
|
|
50
|
+
return transformers.escape(normalized);
|
|
51
|
+
};
|
|
52
|
+
return {
|
|
53
|
+
cnBase: cnBase2,
|
|
54
|
+
cn: cn2,
|
|
55
|
+
tv: factory.tv,
|
|
56
|
+
createTV: factory.createTV
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function create2(options) {
|
|
60
|
+
return createVariantsRuntime(options);
|
|
61
|
+
}
|
|
62
|
+
var variantsRuntime = create2();
|
|
63
|
+
var {
|
|
64
|
+
cnBase,
|
|
65
|
+
cn,
|
|
66
|
+
tv,
|
|
67
|
+
createTV
|
|
68
|
+
} = variantsRuntime;
|
|
69
|
+
export {
|
|
70
|
+
cn,
|
|
71
|
+
cnBase,
|
|
72
|
+
create2 as create,
|
|
73
|
+
createTV,
|
|
74
|
+
defaultConfig,
|
|
75
|
+
tv
|
|
76
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-tailwindcss/merge",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"description": "weapp-tailwindcss",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -38,6 +38,11 @@
|
|
|
38
38
|
"types": "./dist/v4.d.ts",
|
|
39
39
|
"import": "./dist/v4.js",
|
|
40
40
|
"require": "./dist/v4.cjs"
|
|
41
|
+
},
|
|
42
|
+
"./variants": {
|
|
43
|
+
"types": "./dist/variants.d.ts",
|
|
44
|
+
"import": "./dist/variants.js",
|
|
45
|
+
"require": "./dist/variants.cjs"
|
|
41
46
|
}
|
|
42
47
|
},
|
|
43
48
|
"main": "./dist/index.cjs",
|
|
@@ -48,6 +53,7 @@
|
|
|
48
53
|
"scripts"
|
|
49
54
|
],
|
|
50
55
|
"dependencies": {
|
|
56
|
+
"@weapp-core/escape": "^5.0.1",
|
|
51
57
|
"class-variance-authority": "^0.7.1",
|
|
52
58
|
"clsx": "^2.1.1",
|
|
53
59
|
"local-pkg": "^1.1.2",
|
|
@@ -57,7 +63,7 @@
|
|
|
57
63
|
"tailwind-variants": "^3.1.1"
|
|
58
64
|
},
|
|
59
65
|
"devDependencies": {
|
|
60
|
-
"weapp-tailwindcss": "4.
|
|
66
|
+
"weapp-tailwindcss": "4.7.0"
|
|
61
67
|
},
|
|
62
68
|
"scripts": {
|
|
63
69
|
"dev": "tsup --watch --sourcemap",
|
|
@@ -67,6 +73,6 @@
|
|
|
67
73
|
"release": "pnpm publish",
|
|
68
74
|
"lint": "eslint .",
|
|
69
75
|
"lint:fix": "eslint . --fix",
|
|
70
|
-
"
|
|
76
|
+
"postinstall": "node scripts/postinstall.mjs"
|
|
71
77
|
}
|
|
72
78
|
}
|