zss-engine 0.2.56 → 0.2.57
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/cjs/utils/hash.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.genBase36Hash = genBase36Hash;
|
|
4
|
+
function deepNormalize(obj) {
|
|
5
|
+
if (obj === null || obj === undefined)
|
|
6
|
+
return 'null';
|
|
7
|
+
if (typeof obj !== 'object')
|
|
8
|
+
return String(obj);
|
|
9
|
+
if (Array.isArray(obj)) {
|
|
10
|
+
return '[' + obj.map(deepNormalize).join(',') + ']';
|
|
11
|
+
}
|
|
12
|
+
const keys = Object.keys(obj).sort();
|
|
13
|
+
const pairs = keys.map(key => `"${key}":${deepNormalize(obj[key])}`);
|
|
14
|
+
return '{' + pairs.join(',') + '}';
|
|
15
|
+
}
|
|
4
16
|
function murmurhash3_32(str, seed = 0) {
|
|
5
17
|
let h = seed;
|
|
6
18
|
const len = str.length;
|
|
@@ -43,7 +55,7 @@ function murmurhash3_32(str, seed = 0) {
|
|
|
43
55
|
return h >>> 0;
|
|
44
56
|
}
|
|
45
57
|
function genBase36Hash(obj, seed, length) {
|
|
46
|
-
const normalized =
|
|
58
|
+
const normalized = deepNormalize(obj);
|
|
47
59
|
const hashValue = murmurhash3_32(normalized, seed);
|
|
48
60
|
const hashStr = hashValue.toString(36);
|
|
49
61
|
const firstChar = 'abcdefghijklmnopqrstuvwxyz'[hashValue % 26];
|
package/dist/esm/utils/hash.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
function deepNormalize(obj) {
|
|
2
|
+
if (obj === null || obj === undefined)
|
|
3
|
+
return 'null';
|
|
4
|
+
if (typeof obj !== 'object')
|
|
5
|
+
return String(obj);
|
|
6
|
+
if (Array.isArray(obj)) {
|
|
7
|
+
return '[' + obj.map(deepNormalize).join(',') + ']';
|
|
8
|
+
}
|
|
9
|
+
const keys = Object.keys(obj).sort();
|
|
10
|
+
const pairs = keys.map(key => `"${key}":${deepNormalize(obj[key])}`);
|
|
11
|
+
return '{' + pairs.join(',') + '}';
|
|
12
|
+
}
|
|
1
13
|
function murmurhash3_32(str, seed = 0) {
|
|
2
14
|
let h = seed;
|
|
3
15
|
const len = str.length;
|
|
@@ -40,7 +52,7 @@ function murmurhash3_32(str, seed = 0) {
|
|
|
40
52
|
return h >>> 0;
|
|
41
53
|
}
|
|
42
54
|
export function genBase36Hash(obj, seed, length) {
|
|
43
|
-
const normalized =
|
|
55
|
+
const normalized = deepNormalize(obj);
|
|
44
56
|
const hashValue = murmurhash3_32(normalized, seed);
|
|
45
57
|
const hashStr = hashValue.toString(36);
|
|
46
58
|
const firstChar = 'abcdefghijklmnopqrstuvwxyz'[hashValue % 26];
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { CSSProperties, CreateStyle } from '../index.js';
|
|
2
2
|
declare function splitAtomicAndNested(obj: CSSProperties, flat: CreateStyle, nonFlat: CreateStyle): void;
|
|
3
|
-
declare function processAtomicProps(flatProps:
|
|
3
|
+
declare function processAtomicProps(flatProps: CreateStyle, atomicHashes: Set<string>, allStyleSheets: Set<string>, parentAtRule?: string): void;
|
|
4
4
|
export { splitAtomicAndNested, processAtomicProps };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function transpile(object: CSSHTML
|
|
1
|
+
import type { CSSHTML } from '../index.js';
|
|
2
|
+
export declare function transpile(object: CSSHTML, base36Hash?: string, core?: string): {
|
|
3
3
|
styleSheet: string;
|
|
4
4
|
};
|