zss-engine 0.2.90 → 0.2.91
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 +1 -1
- package/dist/cjs/utils/processor-atomic.js +4 -12
- package/dist/cjs/utils/transpile.js +1 -3
- package/dist/esm/utils/hash.js +1 -1
- package/dist/esm/utils/processor-atomic.js +4 -12
- package/dist/esm/utils/transpile.js +1 -3
- package/dist/types/utils/processor-atomic.d.ts +1 -1
- package/package.json +17 -8
- package/readme.md +7 -0
package/dist/cjs/utils/hash.js
CHANGED
|
@@ -16,7 +16,7 @@ function deepNormalize(obj) {
|
|
|
16
16
|
const pairs = keys.map(key => `"${key}":${deepNormalize(recordObj[key])}`);
|
|
17
17
|
return '{' + pairs.join(',') + '}';
|
|
18
18
|
}
|
|
19
|
-
function murmurhash3_32(str, seed
|
|
19
|
+
function murmurhash3_32(str, seed) {
|
|
20
20
|
let h = seed;
|
|
21
21
|
const len = str.length;
|
|
22
22
|
const c1 = 0xcc9e2d51;
|
|
@@ -18,9 +18,6 @@ function splitAtomicAndNested(obj, flat, nonFlat) {
|
|
|
18
18
|
if (Object.keys(innerNonFlat).length)
|
|
19
19
|
nonFlat[property] = innerNonFlat;
|
|
20
20
|
}
|
|
21
|
-
else if (typeof value === 'object' && value !== null) {
|
|
22
|
-
flat[property] = value;
|
|
23
|
-
}
|
|
24
21
|
else {
|
|
25
22
|
flat[property] = value;
|
|
26
23
|
}
|
|
@@ -32,26 +29,21 @@ Object.entries(shorthand_js_1.SHORTHAND_PROPERTIES).forEach(([shorthand, longhan
|
|
|
32
29
|
LONG_TO_SHORT[long] = shorthand;
|
|
33
30
|
});
|
|
34
31
|
});
|
|
35
|
-
function processAtomicProps(flatProps, atomicHashes, allStyleSheets, parentAtRule) {
|
|
36
|
-
const seen = new Set();
|
|
37
|
-
const resultQueue = [];
|
|
32
|
+
function processAtomicProps(flatProps, atomicHashes, allStyleSheets, seen, resultQueue, parentAtRule) {
|
|
38
33
|
for (const [property, value] of Object.entries(flatProps)) {
|
|
39
34
|
if (property.startsWith('@media') || property.startsWith('@container')) {
|
|
40
|
-
|
|
35
|
+
const nestedQueue = [];
|
|
36
|
+
processAtomicProps(value, atomicHashes, allStyleSheets, seen, nestedQueue, property);
|
|
41
37
|
continue;
|
|
42
38
|
}
|
|
43
39
|
const kebab = (0, index_js_1.camelToKebabCase)(property);
|
|
44
40
|
if (shorthand_js_1.SHORTHAND_PROPERTIES[kebab]) {
|
|
45
41
|
const longhands = shorthand_js_1.SHORTHAND_PROPERTIES[kebab];
|
|
46
|
-
longhands.forEach(
|
|
42
|
+
longhands.forEach(longhand => seen.delete(longhand));
|
|
47
43
|
seen.add(kebab);
|
|
48
44
|
resultQueue.push([property, value]);
|
|
49
45
|
}
|
|
50
46
|
else if (kebab in LONG_TO_SHORT) {
|
|
51
|
-
const shorthand = LONG_TO_SHORT[kebab];
|
|
52
|
-
if (seen.has(shorthand)) {
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
47
|
seen.add(kebab);
|
|
56
48
|
resultQueue.push([property, value]);
|
|
57
49
|
}
|
|
@@ -31,13 +31,11 @@ function transpile(object, base36Hash, core) {
|
|
|
31
31
|
return core === '--global' ? property : `.${base36Hash}`;
|
|
32
32
|
};
|
|
33
33
|
const rules = (indent, rulesValue, property) => {
|
|
34
|
-
if (typeof property !== 'string')
|
|
35
|
-
return '';
|
|
36
34
|
const value = rulesValue[property];
|
|
37
35
|
const cssProp = (0, helper_js_1.camelToKebabCase)(property);
|
|
38
36
|
return `${indent}${cssProp}: ${value};\n`;
|
|
39
37
|
};
|
|
40
|
-
const stringConverter = (className, properties, indentLevel
|
|
38
|
+
const stringConverter = (className, properties, indentLevel) => {
|
|
41
39
|
const classSelector = {};
|
|
42
40
|
const indent = ''.repeat(indentLevel);
|
|
43
41
|
const innerIndent = ' '.repeat(indentLevel + 1);
|
package/dist/esm/utils/hash.js
CHANGED
|
@@ -13,7 +13,7 @@ function deepNormalize(obj) {
|
|
|
13
13
|
const pairs = keys.map(key => `"${key}":${deepNormalize(recordObj[key])}`);
|
|
14
14
|
return '{' + pairs.join(',') + '}';
|
|
15
15
|
}
|
|
16
|
-
function murmurhash3_32(str, seed
|
|
16
|
+
function murmurhash3_32(str, seed) {
|
|
17
17
|
let h = seed;
|
|
18
18
|
const len = str.length;
|
|
19
19
|
const c1 = 0xcc9e2d51;
|
|
@@ -14,9 +14,6 @@ function splitAtomicAndNested(obj, flat, nonFlat) {
|
|
|
14
14
|
if (Object.keys(innerNonFlat).length)
|
|
15
15
|
nonFlat[property] = innerNonFlat;
|
|
16
16
|
}
|
|
17
|
-
else if (typeof value === 'object' && value !== null) {
|
|
18
|
-
flat[property] = value;
|
|
19
|
-
}
|
|
20
17
|
else {
|
|
21
18
|
flat[property] = value;
|
|
22
19
|
}
|
|
@@ -28,26 +25,21 @@ Object.entries(SHORTHAND_PROPERTIES).forEach(([shorthand, longhands]) => {
|
|
|
28
25
|
LONG_TO_SHORT[long] = shorthand;
|
|
29
26
|
});
|
|
30
27
|
});
|
|
31
|
-
function processAtomicProps(flatProps, atomicHashes, allStyleSheets, parentAtRule) {
|
|
32
|
-
const seen = new Set();
|
|
33
|
-
const resultQueue = [];
|
|
28
|
+
function processAtomicProps(flatProps, atomicHashes, allStyleSheets, seen, resultQueue, parentAtRule) {
|
|
34
29
|
for (const [property, value] of Object.entries(flatProps)) {
|
|
35
30
|
if (property.startsWith('@media') || property.startsWith('@container')) {
|
|
36
|
-
|
|
31
|
+
const nestedQueue = [];
|
|
32
|
+
processAtomicProps(value, atomicHashes, allStyleSheets, seen, nestedQueue, property);
|
|
37
33
|
continue;
|
|
38
34
|
}
|
|
39
35
|
const kebab = camelToKebabCase(property);
|
|
40
36
|
if (SHORTHAND_PROPERTIES[kebab]) {
|
|
41
37
|
const longhands = SHORTHAND_PROPERTIES[kebab];
|
|
42
|
-
longhands.forEach(
|
|
38
|
+
longhands.forEach(longhand => seen.delete(longhand));
|
|
43
39
|
seen.add(kebab);
|
|
44
40
|
resultQueue.push([property, value]);
|
|
45
41
|
}
|
|
46
42
|
else if (kebab in LONG_TO_SHORT) {
|
|
47
|
-
const shorthand = LONG_TO_SHORT[kebab];
|
|
48
|
-
if (seen.has(shorthand)) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
43
|
seen.add(kebab);
|
|
52
44
|
resultQueue.push([property, value]);
|
|
53
45
|
}
|
|
@@ -28,13 +28,11 @@ export function transpile(object, base36Hash, core) {
|
|
|
28
28
|
return core === '--global' ? property : `.${base36Hash}`;
|
|
29
29
|
};
|
|
30
30
|
const rules = (indent, rulesValue, property) => {
|
|
31
|
-
if (typeof property !== 'string')
|
|
32
|
-
return '';
|
|
33
31
|
const value = rulesValue[property];
|
|
34
32
|
const cssProp = camelToKebabCase(property);
|
|
35
33
|
return `${indent}${cssProp}: ${value};\n`;
|
|
36
34
|
};
|
|
37
|
-
const stringConverter = (className, properties, indentLevel
|
|
35
|
+
const stringConverter = (className, properties, indentLevel) => {
|
|
38
36
|
const classSelector = {};
|
|
39
37
|
const indent = ''.repeat(indentLevel);
|
|
40
38
|
const innerIndent = ' '.repeat(indentLevel + 1);
|
|
@@ -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: CSSProperties, atomicHashes: Set<string>, allStyleSheets: Set<string>, seen: Set<string>, resultQueue: Array<[string, string | number]>, parentAtRule?: string): void;
|
|
4
4
|
export { splitAtomicAndNested, processAtomicProps };
|
package/package.json
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zss-engine",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.91",
|
|
4
4
|
"description": "Zero-runtime StyleSheet Engine",
|
|
5
|
+
"funding": "https://github.com/sponsors/refirst11",
|
|
6
|
+
"author": "Refirst 11",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/zss-in-js/zss-engine.git",
|
|
11
|
+
"directory": "packages/core"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/zss-in-js/zss-engine/issues"
|
|
15
|
+
},
|
|
5
16
|
"keywords": [
|
|
6
17
|
"zero-runtime",
|
|
7
18
|
"stylesheet",
|
|
19
|
+
"atomic",
|
|
8
20
|
"engine",
|
|
9
21
|
"css-in-js"
|
|
10
22
|
],
|
|
11
|
-
"author": "Refirst",
|
|
12
|
-
"repository": "github:zss-in-js/zss-engine",
|
|
13
|
-
"license": "MIT",
|
|
14
23
|
"sideEffects": false,
|
|
15
24
|
"exports": {
|
|
16
25
|
"./package.json": "./package.json",
|
|
@@ -30,18 +39,18 @@
|
|
|
30
39
|
"build": "rimraf dist && pnpm esm && pnpm cjs",
|
|
31
40
|
"cjs": "tsc --project tsconfig.cjs.json",
|
|
32
41
|
"esm": "tsc --project tsconfig.esm.json",
|
|
33
|
-
"test": "jest"
|
|
42
|
+
"test": "jest --coverage"
|
|
34
43
|
},
|
|
35
44
|
"dependencies": {
|
|
36
45
|
"csstype": "3.1.3"
|
|
37
46
|
},
|
|
38
47
|
"devDependencies": {
|
|
39
48
|
"@types/jest": "^29.5.14",
|
|
40
|
-
"@types/node": "^22.
|
|
49
|
+
"@types/node": "^22.18.10",
|
|
41
50
|
"jest": "^29.7.0",
|
|
42
51
|
"jest-environment-jsdom": "^29.7.0",
|
|
43
52
|
"rimraf": "^6.0.1",
|
|
44
|
-
"ts-jest": "^29.
|
|
45
|
-
"typescript": "^5.
|
|
53
|
+
"ts-jest": "^29.4.5",
|
|
54
|
+
"typescript": "^5.9.3"
|
|
46
55
|
}
|
|
47
56
|
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
[](https://codecov.io/github/zss-in-js/zss-engine)
|
|
2
|
+
|
|
3
|
+
> Zero-runtime StyleSheet Engine
|
|
4
|
+
|
|
5
|
+
## License
|
|
6
|
+
|
|
7
|
+
[MIT](https://github.com/zss-in-js/zss-engine/blob/main/license) License © 2023-PRESENT [Refirst 11](https://github.com/refirst11)
|