@csszyx/runtime 0.10.7 → 0.10.9
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 +6 -2
- package/dist/index.d.cts +10 -3
- package/dist/index.d.mts +10 -3
- package/dist/index.mjs +6 -2
- package/dist/lite.d.cts +16 -7
- package/dist/lite.d.mts +16 -7
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
const browser = require('@csszyx/compiler/browser');
|
|
4
4
|
const colorVar = require('@csszyx/compiler/color-var');
|
|
5
5
|
|
|
6
|
+
function sortStrings(values) {
|
|
7
|
+
return [...values].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
8
|
+
}
|
|
9
|
+
|
|
6
10
|
function verifyRecoveryToken(element, manifest) {
|
|
7
11
|
const token = element.getAttribute("data-sz-recovery-token");
|
|
8
12
|
if (!token) {
|
|
@@ -145,7 +149,7 @@ function verifyMangleChecksum(expectedChecksum) {
|
|
|
145
149
|
return actualChecksum === expectedChecksum;
|
|
146
150
|
}
|
|
147
151
|
async function computeMangleChecksumAsync(map) {
|
|
148
|
-
const canonical = Object.keys(map)
|
|
152
|
+
const canonical = sortStrings(Object.keys(map)).map((key) => `${key}:${map[key]}`).join("|");
|
|
149
153
|
const bytes = new TextEncoder().encode(canonical);
|
|
150
154
|
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
151
155
|
let hex = "";
|
|
@@ -298,7 +302,7 @@ function getSSRContext() {
|
|
|
298
302
|
};
|
|
299
303
|
}
|
|
300
304
|
function validateHydrationClass(className, expectedClassName) {
|
|
301
|
-
const normalize = (s) => s.split(/\s+/).filter(Boolean)
|
|
305
|
+
const normalize = (s) => sortStrings(s.split(/\s+/).filter(Boolean)).join(" ");
|
|
302
306
|
return normalize(className) === normalize(expectedClassName);
|
|
303
307
|
}
|
|
304
308
|
function startHydration() {
|
package/dist/index.d.cts
CHANGED
|
@@ -11,11 +11,18 @@ export { __szColorVar } from '@csszyx/compiler/color-var';
|
|
|
11
11
|
*
|
|
12
12
|
* @module @csszyx/runtime/concatenate
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
14
|
/**
|
|
16
|
-
* Type for sz input
|
|
15
|
+
* Type for sz input — a pre-compiled class string, an sz object, a recursive
|
|
16
|
+
* array of those, or a falsy guard (skipped).
|
|
17
|
+
*
|
|
18
|
+
* The object member is the broad `object` rather than `SzObject` so that a
|
|
19
|
+
* precise `SzProps` / `SzPropValue` value (the type the JSX augmentation gives
|
|
20
|
+
* `sz` on a host element) forwards into the runtime helpers without a cast: a
|
|
21
|
+
* named type with specific keys is assignable to `object`, but not to
|
|
22
|
+
* `SzObject`'s `{ [k: string]: SzValue }` index signature. The runtime lowers the
|
|
23
|
+
* keys it recognizes and ignores the rest, so the looser input type is sound.
|
|
17
24
|
*/
|
|
18
|
-
type SzInput = string |
|
|
25
|
+
type SzInput = string | object | SzInput[] | null | undefined | false;
|
|
19
26
|
/**
|
|
20
27
|
* Zero-overhead className passthrough/concatenation helper.
|
|
21
28
|
*
|
package/dist/index.d.mts
CHANGED
|
@@ -11,11 +11,18 @@ export { __szColorVar } from '@csszyx/compiler/color-var';
|
|
|
11
11
|
*
|
|
12
12
|
* @module @csszyx/runtime/concatenate
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
14
|
/**
|
|
16
|
-
* Type for sz input
|
|
15
|
+
* Type for sz input — a pre-compiled class string, an sz object, a recursive
|
|
16
|
+
* array of those, or a falsy guard (skipped).
|
|
17
|
+
*
|
|
18
|
+
* The object member is the broad `object` rather than `SzObject` so that a
|
|
19
|
+
* precise `SzProps` / `SzPropValue` value (the type the JSX augmentation gives
|
|
20
|
+
* `sz` on a host element) forwards into the runtime helpers without a cast: a
|
|
21
|
+
* named type with specific keys is assignable to `object`, but not to
|
|
22
|
+
* `SzObject`'s `{ [k: string]: SzValue }` index signature. The runtime lowers the
|
|
23
|
+
* keys it recognizes and ignores the rest, so the looser input type is sound.
|
|
17
24
|
*/
|
|
18
|
-
type SzInput = string |
|
|
25
|
+
type SzInput = string | object | SzInput[] | null | undefined | false;
|
|
19
26
|
/**
|
|
20
27
|
* Zero-overhead className passthrough/concatenation helper.
|
|
21
28
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { MAX_SZ_DEPTH, SzDepthError, transform as transform$1, isForbiddenSzKey } from '@csszyx/compiler/browser';
|
|
2
2
|
export { __szColorVar } from '@csszyx/compiler/color-var';
|
|
3
3
|
|
|
4
|
+
function sortStrings(values) {
|
|
5
|
+
return [...values].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
6
|
+
}
|
|
7
|
+
|
|
4
8
|
function verifyRecoveryToken(element, manifest) {
|
|
5
9
|
const token = element.getAttribute("data-sz-recovery-token");
|
|
6
10
|
if (!token) {
|
|
@@ -143,7 +147,7 @@ function verifyMangleChecksum(expectedChecksum) {
|
|
|
143
147
|
return actualChecksum === expectedChecksum;
|
|
144
148
|
}
|
|
145
149
|
async function computeMangleChecksumAsync(map) {
|
|
146
|
-
const canonical = Object.keys(map)
|
|
150
|
+
const canonical = sortStrings(Object.keys(map)).map((key) => `${key}:${map[key]}`).join("|");
|
|
147
151
|
const bytes = new TextEncoder().encode(canonical);
|
|
148
152
|
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
149
153
|
let hex = "";
|
|
@@ -296,7 +300,7 @@ function getSSRContext() {
|
|
|
296
300
|
};
|
|
297
301
|
}
|
|
298
302
|
function validateHydrationClass(className, expectedClassName) {
|
|
299
|
-
const normalize = (s) => s.split(/\s+/).filter(Boolean)
|
|
303
|
+
const normalize = (s) => sortStrings(s.split(/\s+/).filter(Boolean)).join(" ");
|
|
300
304
|
return normalize(className) === normalize(expectedClassName);
|
|
301
305
|
}
|
|
302
306
|
function startHydration() {
|
package/dist/lite.d.cts
CHANGED
|
@@ -16,13 +16,22 @@ export { __szColorVar } from '@csszyx/compiler/color-var';
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Input to the lite runtime helpers: a pre-compiled class string or a falsy
|
|
20
|
+
* guard (skipped). The lite path has no compiler, so it never accepts objects —
|
|
21
|
+
* unlike the full `SzInput` from `@csszyx/runtime`, which also takes sz objects.
|
|
22
|
+
* Named distinctly so the two do not look interchangeable.
|
|
20
23
|
*/
|
|
21
|
-
type
|
|
24
|
+
type SzStringInput = string | null | undefined | false;
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Renamed to {@link SzStringInput} — the lite helpers accept only
|
|
27
|
+
* pre-compiled class strings, and the bare name collided with the object-accepting
|
|
28
|
+
* `SzInput` from `@csszyx/runtime`. This alias is kept for back-compat.
|
|
29
|
+
*/
|
|
30
|
+
type SzInput = SzStringInput;
|
|
22
31
|
/**
|
|
23
32
|
* Zero-overhead className passthrough/concatenation.
|
|
24
33
|
*
|
|
25
|
-
* @param {...
|
|
34
|
+
* @param {...SzStringInput[]} classes - Class names to concatenate
|
|
26
35
|
* @returns {string} Combined className string
|
|
27
36
|
*
|
|
28
37
|
* @example
|
|
@@ -31,7 +40,7 @@ type SzInput = string | null | undefined | false;
|
|
|
31
40
|
* _sz('base', isActive && 'active') // conditional
|
|
32
41
|
* ```
|
|
33
42
|
*/
|
|
34
|
-
declare function _sz(...classes:
|
|
43
|
+
declare function _sz(...classes: SzStringInput[]): string;
|
|
35
44
|
/**
|
|
36
45
|
* Merges className strings from compiled array sz props, deduplicating tokens.
|
|
37
46
|
*
|
|
@@ -39,10 +48,10 @@ declare function _sz(...classes: SzInput[]): string;
|
|
|
39
48
|
* element is a runtime conditional. All arguments must be pre-compiled strings
|
|
40
49
|
* (the compiler resolves each element to a string before passing it here).
|
|
41
50
|
*
|
|
42
|
-
* @param {...
|
|
51
|
+
* @param {...SzStringInput[]} classes - Pre-compiled class strings to merge
|
|
43
52
|
* @returns {string} Merged className string with duplicate tokens removed
|
|
44
53
|
*/
|
|
45
|
-
declare function _szMerge(...classes:
|
|
54
|
+
declare function _szMerge(...classes: SzStringInput[]): string;
|
|
46
55
|
/**
|
|
47
56
|
* Two-argument optimized concatenation.
|
|
48
57
|
* @param a - first class string
|
|
@@ -52,4 +61,4 @@ declare function _szMerge(...classes: SzInput[]): string;
|
|
|
52
61
|
declare function _sz2(a: string, b: string): string;
|
|
53
62
|
|
|
54
63
|
export { _sz, _sz2, _szMerge };
|
|
55
|
-
export type { SzInput };
|
|
64
|
+
export type { SzInput, SzStringInput };
|
package/dist/lite.d.mts
CHANGED
|
@@ -16,13 +16,22 @@ export { __szColorVar } from '@csszyx/compiler/color-var';
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Input to the lite runtime helpers: a pre-compiled class string or a falsy
|
|
20
|
+
* guard (skipped). The lite path has no compiler, so it never accepts objects —
|
|
21
|
+
* unlike the full `SzInput` from `@csszyx/runtime`, which also takes sz objects.
|
|
22
|
+
* Named distinctly so the two do not look interchangeable.
|
|
20
23
|
*/
|
|
21
|
-
type
|
|
24
|
+
type SzStringInput = string | null | undefined | false;
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Renamed to {@link SzStringInput} — the lite helpers accept only
|
|
27
|
+
* pre-compiled class strings, and the bare name collided with the object-accepting
|
|
28
|
+
* `SzInput` from `@csszyx/runtime`. This alias is kept for back-compat.
|
|
29
|
+
*/
|
|
30
|
+
type SzInput = SzStringInput;
|
|
22
31
|
/**
|
|
23
32
|
* Zero-overhead className passthrough/concatenation.
|
|
24
33
|
*
|
|
25
|
-
* @param {...
|
|
34
|
+
* @param {...SzStringInput[]} classes - Class names to concatenate
|
|
26
35
|
* @returns {string} Combined className string
|
|
27
36
|
*
|
|
28
37
|
* @example
|
|
@@ -31,7 +40,7 @@ type SzInput = string | null | undefined | false;
|
|
|
31
40
|
* _sz('base', isActive && 'active') // conditional
|
|
32
41
|
* ```
|
|
33
42
|
*/
|
|
34
|
-
declare function _sz(...classes:
|
|
43
|
+
declare function _sz(...classes: SzStringInput[]): string;
|
|
35
44
|
/**
|
|
36
45
|
* Merges className strings from compiled array sz props, deduplicating tokens.
|
|
37
46
|
*
|
|
@@ -39,10 +48,10 @@ declare function _sz(...classes: SzInput[]): string;
|
|
|
39
48
|
* element is a runtime conditional. All arguments must be pre-compiled strings
|
|
40
49
|
* (the compiler resolves each element to a string before passing it here).
|
|
41
50
|
*
|
|
42
|
-
* @param {...
|
|
51
|
+
* @param {...SzStringInput[]} classes - Pre-compiled class strings to merge
|
|
43
52
|
* @returns {string} Merged className string with duplicate tokens removed
|
|
44
53
|
*/
|
|
45
|
-
declare function _szMerge(...classes:
|
|
54
|
+
declare function _szMerge(...classes: SzStringInput[]): string;
|
|
46
55
|
/**
|
|
47
56
|
* Two-argument optimized concatenation.
|
|
48
57
|
* @param a - first class string
|
|
@@ -52,4 +61,4 @@ declare function _szMerge(...classes: SzInput[]): string;
|
|
|
52
61
|
declare function _sz2(a: string, b: string): string;
|
|
53
62
|
|
|
54
63
|
export { _sz, _sz2, _szMerge };
|
|
55
|
-
export type { SzInput };
|
|
64
|
+
export type { SzInput, SzStringInput };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@csszyx/runtime",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.9",
|
|
4
4
|
"description": "Runtime helpers and hydration guards for csszyx",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"csszyx",
|
|
@@ -49,15 +49,15 @@
|
|
|
49
49
|
"dist"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@csszyx/compiler": "0.10.
|
|
53
|
-
"@csszyx/core": "0.10.
|
|
52
|
+
"@csszyx/compiler": "0.10.9",
|
|
53
|
+
"@csszyx/core": "0.10.9"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/node": "^20.11.0",
|
|
57
57
|
"jsdom": "^23.0.0",
|
|
58
58
|
"typescript": "^6.0.3",
|
|
59
59
|
"vite-plugin-wasm": "^3.3.0",
|
|
60
|
-
"vitest": "^4.1.
|
|
60
|
+
"vitest": "^4.1.9",
|
|
61
61
|
"unbuild": "^3.6.1"
|
|
62
62
|
},
|
|
63
63
|
"optionalDependencies": {
|