@weapp-tailwindcss/runtime 0.1.10 → 0.1.11-dev.20261117.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/index.cjs +18 -17
- package/dist/index.d.cts +1 -11
- package/dist/index.d.mts +1 -11
- package/dist/index.mjs +8 -12
- package/package.json +15 -6
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let clsx = require("clsx");
|
|
3
|
-
let
|
|
4
|
-
|
|
3
|
+
let _weapp_tailwindcss_escape = require("@weapp-tailwindcss/escape");
|
|
4
|
+
// src/transformer-probes.ts
|
|
5
5
|
const probes = /* @__PURE__ */ new WeakMap();
|
|
6
6
|
const unescapePattern = /u[0-9a-f]{3,}/i;
|
|
7
|
-
const escapeNeedles = Object.keys(
|
|
7
|
+
const escapeNeedles = Object.keys(_weapp_tailwindcss_escape.MappingChars2String).filter(Boolean);
|
|
8
8
|
/** 仅为已知默认转换器登记可证明安全的跳过条件,不改变公开类型。 */
|
|
9
9
|
function registerTransformProbe(transform, direction) {
|
|
10
10
|
probes.set(transform, direction === "identity" ? () => false : direction === "unescape" ? (value) => value.includes("_") || unescapePattern.test(value) : (value) => escapeNeedles.some((needle) => value.includes(needle)));
|
|
@@ -13,8 +13,7 @@ function registerTransformProbe(transform, direction) {
|
|
|
13
13
|
function needsTransform(transform, value) {
|
|
14
14
|
return probes.get(transform)?.(value) ?? true;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
//#region src/transformers.ts
|
|
16
|
+
// src/transformers.ts
|
|
18
17
|
const identity = (value) => value;
|
|
19
18
|
registerTransformProbe(identity, "identity");
|
|
20
19
|
function isConfig(value) {
|
|
@@ -22,9 +21,9 @@ function isConfig(value) {
|
|
|
22
21
|
}
|
|
23
22
|
function mergeWithDefaultMap(map) {
|
|
24
23
|
if (!map) return;
|
|
25
|
-
if (map ===
|
|
24
|
+
if (map === _weapp_tailwindcss_escape.MappingChars2String) return _weapp_tailwindcss_escape.MappingChars2String;
|
|
26
25
|
return {
|
|
27
|
-
...
|
|
26
|
+
..._weapp_tailwindcss_escape.MappingChars2String,
|
|
28
27
|
...map
|
|
29
28
|
};
|
|
30
29
|
}
|
|
@@ -32,7 +31,7 @@ function resolveSharedMap(options) {
|
|
|
32
31
|
const { escape, unescape } = options ?? {};
|
|
33
32
|
if (isConfig(escape) && escape.map) return mergeWithDefaultMap(escape.map);
|
|
34
33
|
if (isConfig(unescape) && unescape.map) return mergeWithDefaultMap(unescape.map);
|
|
35
|
-
return
|
|
34
|
+
return _weapp_tailwindcss_escape.MappingChars2String;
|
|
36
35
|
}
|
|
37
36
|
function resolveTransformers(options) {
|
|
38
37
|
const sharedMap = resolveSharedMap(options);
|
|
@@ -56,9 +55,9 @@ function resolveTransformers(options) {
|
|
|
56
55
|
};
|
|
57
56
|
else unescapeOptions = { map: sharedMap };
|
|
58
57
|
}
|
|
59
|
-
const escapeFn = escapeEnabled ? (value) => (0,
|
|
60
|
-
const unescapeFn = unescapeEnabled ? (value) => (0,
|
|
61
|
-
if (sharedMap ===
|
|
58
|
+
const escapeFn = escapeEnabled ? (value) => (0, _weapp_tailwindcss_escape.escape)(value, escapeOptions) : identity;
|
|
59
|
+
const unescapeFn = unescapeEnabled ? (value) => (0, _weapp_tailwindcss_escape.unescape)(value, unescapeOptions) : identity;
|
|
60
|
+
if (sharedMap === _weapp_tailwindcss_escape.MappingChars2String) {
|
|
62
61
|
if (escapeEnabled && !isConfig(escapeConfig)) registerTransformProbe(escapeFn, "escape");
|
|
63
62
|
if (unescapeEnabled && !isConfig(unescapeConfig)) registerTransformProbe(unescapeFn, "unescape");
|
|
64
63
|
}
|
|
@@ -67,8 +66,7 @@ function resolveTransformers(options) {
|
|
|
67
66
|
unescape: unescapeFn
|
|
68
67
|
};
|
|
69
68
|
}
|
|
70
|
-
|
|
71
|
-
//#region src/create-runtime.ts
|
|
69
|
+
// src/create-runtime.ts
|
|
72
70
|
const CACHE_LIMIT = 256;
|
|
73
71
|
function hasWhitespace(value) {
|
|
74
72
|
return value.includes(" ") || value.includes(" ") || value.includes("\n") || value.includes("\r") || value.includes("\f") || value.includes("\v");
|
|
@@ -139,8 +137,7 @@ function createRuntimeFactory(options) {
|
|
|
139
137
|
};
|
|
140
138
|
};
|
|
141
139
|
}
|
|
142
|
-
|
|
143
|
-
//#region src/rpx-length.ts
|
|
140
|
+
// src/rpx-length.ts
|
|
144
141
|
const DEFAULT_PREFIXES = [
|
|
145
142
|
"text",
|
|
146
143
|
"border",
|
|
@@ -196,8 +193,12 @@ function createRpxLengthTransform(prefixes = DEFAULT_PREFIXES) {
|
|
|
196
193
|
};
|
|
197
194
|
}
|
|
198
195
|
const weappTwIgnore = String.raw;
|
|
199
|
-
|
|
200
|
-
|
|
196
|
+
Object.defineProperty(exports, "clsx", {
|
|
197
|
+
enumerable: true,
|
|
198
|
+
get: function() {
|
|
199
|
+
return clsx.clsx;
|
|
200
|
+
}
|
|
201
|
+
});
|
|
201
202
|
exports.createRpxLengthTransform = createRpxLengthTransform;
|
|
202
203
|
exports.createRuntimeFactory = createRuntimeFactory;
|
|
203
204
|
exports.identity = identity;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ClassValue, ClassValue as ClassValue$1, clsx as clsxFn } from "clsx";
|
|
2
|
-
import { EscapeOptions, UnescapeOptions } from "@weapp-
|
|
3
|
-
//#region src/types.d.ts
|
|
2
|
+
import { EscapeOptions, UnescapeOptions } from "@weapp-tailwindcss/escape";
|
|
4
3
|
type EscapeConfig = boolean | EscapeOptions;
|
|
5
4
|
type UnescapeConfig = boolean | UnescapeOptions;
|
|
6
5
|
interface CreateOptions {
|
|
@@ -15,8 +14,6 @@ type TailwindMergeLibraryFn = (...inputs: any[]) => string;
|
|
|
15
14
|
type TailwindMergeRuntime = (...inputs: ClassValue$1[]) => string;
|
|
16
15
|
type TailwindMergeFactory<TFactory extends (...args: any[]) => TailwindMergeLibraryFn> = (...args: Parameters<TFactory>) => TailwindMergeRuntime;
|
|
17
16
|
type TailwindMergeVersion = 2 | 3;
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/create-runtime.d.ts
|
|
20
17
|
type TailwindMergeFactoryFn = (...args: any[]) => TailwindMergeLibraryFn;
|
|
21
18
|
interface TransformResult {
|
|
22
19
|
value: string;
|
|
@@ -49,8 +46,6 @@ export declare function createRuntimeFactory<TTwMerge extends TailwindMergeLibra
|
|
|
49
46
|
extendTailwindMerge: TailwindMergeFactory<TExtendFactory>;
|
|
50
47
|
createTailwindMerge: TailwindMergeFactory<TCreateFactory>;
|
|
51
48
|
};
|
|
52
|
-
//#endregion
|
|
53
|
-
//#region src/rpx-length.d.ts
|
|
54
49
|
type ReplacementCounters = Record<string, number>;
|
|
55
50
|
export declare function createRpxLengthTransform(prefixes?: readonly ["text", "border", "bg", "outline", "ring"]): {
|
|
56
51
|
prepareValue: (value: string) => string | {
|
|
@@ -61,15 +56,10 @@ export declare function createRpxLengthTransform(prefixes?: readonly ["text", "b
|
|
|
61
56
|
};
|
|
62
57
|
restoreValue: (value: string, metadata?: unknown) => string;
|
|
63
58
|
};
|
|
64
|
-
//#endregion
|
|
65
|
-
//#region src/transformers.d.ts
|
|
66
59
|
declare const identity: (value: string) => string;
|
|
67
60
|
export declare function resolveTransformers(options?: CreateOptions): Transformers;
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/index.d.ts
|
|
70
61
|
export declare const weappTwIgnore: (template: {
|
|
71
62
|
raw: readonly string[] | ArrayLike<string>;
|
|
72
63
|
}, ...substitutions: any[]) => string;
|
|
73
64
|
export type ClsxFn = typeof clsxFn;
|
|
74
|
-
//#endregion
|
|
75
65
|
export { type ClassValue, type CreateOptions, type EscapeConfig, type TailwindMergeFactory, type TailwindMergeLibraryFn, type TailwindMergeRuntime, type TailwindMergeVersion, type Transformers, type UnescapeConfig, clsxFn as clsx, identity };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ClassValue, ClassValue as ClassValue$1, clsx as clsxFn } from "clsx";
|
|
2
|
-
import { EscapeOptions, UnescapeOptions } from "@weapp-
|
|
3
|
-
//#region src/types.d.ts
|
|
2
|
+
import { EscapeOptions, UnescapeOptions } from "@weapp-tailwindcss/escape";
|
|
4
3
|
type EscapeConfig = boolean | EscapeOptions;
|
|
5
4
|
type UnescapeConfig = boolean | UnescapeOptions;
|
|
6
5
|
interface CreateOptions {
|
|
@@ -15,8 +14,6 @@ type TailwindMergeLibraryFn = (...inputs: any[]) => string;
|
|
|
15
14
|
type TailwindMergeRuntime = (...inputs: ClassValue$1[]) => string;
|
|
16
15
|
type TailwindMergeFactory<TFactory extends (...args: any[]) => TailwindMergeLibraryFn> = (...args: Parameters<TFactory>) => TailwindMergeRuntime;
|
|
17
16
|
type TailwindMergeVersion = 2 | 3;
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/create-runtime.d.ts
|
|
20
17
|
type TailwindMergeFactoryFn = (...args: any[]) => TailwindMergeLibraryFn;
|
|
21
18
|
interface TransformResult {
|
|
22
19
|
value: string;
|
|
@@ -49,8 +46,6 @@ export declare function createRuntimeFactory<TTwMerge extends TailwindMergeLibra
|
|
|
49
46
|
extendTailwindMerge: TailwindMergeFactory<TExtendFactory>;
|
|
50
47
|
createTailwindMerge: TailwindMergeFactory<TCreateFactory>;
|
|
51
48
|
};
|
|
52
|
-
//#endregion
|
|
53
|
-
//#region src/rpx-length.d.ts
|
|
54
49
|
type ReplacementCounters = Record<string, number>;
|
|
55
50
|
export declare function createRpxLengthTransform(prefixes?: readonly ["text", "border", "bg", "outline", "ring"]): {
|
|
56
51
|
prepareValue: (value: string) => string | {
|
|
@@ -61,15 +56,10 @@ export declare function createRpxLengthTransform(prefixes?: readonly ["text", "b
|
|
|
61
56
|
};
|
|
62
57
|
restoreValue: (value: string, metadata?: unknown) => string;
|
|
63
58
|
};
|
|
64
|
-
//#endregion
|
|
65
|
-
//#region src/transformers.d.ts
|
|
66
59
|
declare const identity: (value: string) => string;
|
|
67
60
|
export declare function resolveTransformers(options?: CreateOptions): Transformers;
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/index.d.ts
|
|
70
61
|
export declare const weappTwIgnore: (template: {
|
|
71
62
|
raw: readonly string[] | ArrayLike<string>;
|
|
72
63
|
}, ...substitutions: any[]) => string;
|
|
73
64
|
export type ClsxFn = typeof clsxFn;
|
|
74
|
-
//#endregion
|
|
75
65
|
export { type ClassValue, type CreateOptions, type EscapeConfig, type TailwindMergeFactory, type TailwindMergeLibraryFn, type TailwindMergeRuntime, type TailwindMergeVersion, type Transformers, type UnescapeConfig, clsxFn as clsx, identity };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { clsx, clsx as
|
|
2
|
-
import { MappingChars2String, escape, unescape } from "@weapp-
|
|
3
|
-
|
|
1
|
+
import { clsx, clsx as clsx$1 } from "clsx";
|
|
2
|
+
import { MappingChars2String, escape, unescape } from "@weapp-tailwindcss/escape";
|
|
3
|
+
// src/transformer-probes.ts
|
|
4
4
|
const probes = /* @__PURE__ */ new WeakMap();
|
|
5
5
|
const unescapePattern = /u[0-9a-f]{3,}/i;
|
|
6
6
|
const escapeNeedles = Object.keys(MappingChars2String).filter(Boolean);
|
|
@@ -12,8 +12,7 @@ function registerTransformProbe(transform, direction) {
|
|
|
12
12
|
function needsTransform(transform, value) {
|
|
13
13
|
return probes.get(transform)?.(value) ?? true;
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
//#region src/transformers.ts
|
|
15
|
+
// src/transformers.ts
|
|
17
16
|
const identity = (value) => value;
|
|
18
17
|
registerTransformProbe(identity, "identity");
|
|
19
18
|
function isConfig(value) {
|
|
@@ -66,8 +65,7 @@ function resolveTransformers(options) {
|
|
|
66
65
|
unescape: unescapeFn
|
|
67
66
|
};
|
|
68
67
|
}
|
|
69
|
-
|
|
70
|
-
//#region src/create-runtime.ts
|
|
68
|
+
// src/create-runtime.ts
|
|
71
69
|
const CACHE_LIMIT = 256;
|
|
72
70
|
function hasWhitespace(value) {
|
|
73
71
|
return value.includes(" ") || value.includes(" ") || value.includes("\n") || value.includes("\r") || value.includes("\f") || value.includes("\v");
|
|
@@ -86,7 +84,7 @@ function wrapRuntimeAggregator(fn, transformers, prepareValue, restoreValue) {
|
|
|
86
84
|
return (...inputs) => {
|
|
87
85
|
let rawInput;
|
|
88
86
|
if (inputs.length === 1 && typeof inputs[0] === "string") rawInput = inputs[0];
|
|
89
|
-
else rawInput = clsx(...inputs);
|
|
87
|
+
else rawInput = clsx$1(...inputs);
|
|
90
88
|
if (!rawInput) return rawInput;
|
|
91
89
|
const cached = cache.get(rawInput);
|
|
92
90
|
if (cached !== void 0) {
|
|
@@ -138,8 +136,7 @@ function createRuntimeFactory(options) {
|
|
|
138
136
|
};
|
|
139
137
|
};
|
|
140
138
|
}
|
|
141
|
-
|
|
142
|
-
//#region src/rpx-length.ts
|
|
139
|
+
// src/rpx-length.ts
|
|
143
140
|
const DEFAULT_PREFIXES = [
|
|
144
141
|
"text",
|
|
145
142
|
"border",
|
|
@@ -195,5 +192,4 @@ function createRpxLengthTransform(prefixes = DEFAULT_PREFIXES) {
|
|
|
195
192
|
};
|
|
196
193
|
}
|
|
197
194
|
const weappTwIgnore = String.raw;
|
|
198
|
-
|
|
199
|
-
export { clsxFn as clsx, createRpxLengthTransform, createRuntimeFactory, identity, resolveTransformers, weappTwIgnore, wrapRuntimeAggregator };
|
|
195
|
+
export { clsx, createRpxLengthTransform, createRuntimeFactory, identity, resolveTransformers, weappTwIgnore, wrapRuntimeAggregator };
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-tailwindcss/runtime",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.11-dev.20261117.1",
|
|
5
5
|
"description": "Shared runtime adapters for cross-platform Tailwind CSS class utilities. 跨端 Tailwind CSS 类名工具的共享运行时适配层。",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://tw.weapp.dev/docs/community/merge/runtime-api",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/
|
|
11
|
+
"url": "git+https://github.com/weapp-tailwindcss/weapp-tailwindcss.git",
|
|
12
12
|
"directory": "packages-runtime/runtime"
|
|
13
13
|
},
|
|
14
14
|
"bugs": {
|
|
15
|
-
"url": "https://github.com/
|
|
15
|
+
"url": "https://github.com/weapp-tailwindcss/weapp-tailwindcss/issues"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
18
18
|
"tailwindcss",
|
|
@@ -43,12 +43,21 @@
|
|
|
43
43
|
"node": "^20.19.0 || >=22.12.0"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
|
-
"access": "public"
|
|
46
|
+
"access": "public",
|
|
47
|
+
"tag": "snapshot-nightly",
|
|
48
|
+
"registry": "https://registry.npmjs.org/"
|
|
47
49
|
},
|
|
48
50
|
"dependencies": {
|
|
49
|
-
"@weapp-
|
|
51
|
+
"@weapp-tailwindcss/escape": "0.0.2-dev.20261117.1",
|
|
50
52
|
"clsx": "^2.1.1"
|
|
51
53
|
},
|
|
54
|
+
"repoctlSnapshot": {
|
|
55
|
+
"kind": "nightly",
|
|
56
|
+
"commit": "06815a1e532fd96bd3f8a73388c4b8b5788c817d",
|
|
57
|
+
"buildId": "44004731642-1",
|
|
58
|
+
"identityKey": "862d5b2edc889f9f141a37385bdde3217931e28f4fdf9ac0f32d4b4ca814bf1c",
|
|
59
|
+
"tag": "snapshot-nightly"
|
|
60
|
+
},
|
|
52
61
|
"scripts": {
|
|
53
62
|
"dev": "tsdown -w",
|
|
54
63
|
"build": "tsdown",
|
|
@@ -59,4 +68,4 @@
|
|
|
59
68
|
"lint": "eslint .",
|
|
60
69
|
"lint:fix": "eslint . --fix"
|
|
61
70
|
}
|
|
62
|
-
}
|
|
71
|
+
}
|