zss-engine 2.2.8 → 2.3.0
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/index.js +2 -1
- package/dist/cjs/utils/helper.js +9 -1
- package/dist/cjs/utils/processor-atomic.js +9 -7
- package/dist/cjs/utils/transpile-atomic.js +1 -1
- package/dist/cjs/utils/transpile.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/utils/helper.js +7 -0
- package/dist/esm/utils/processor-atomic.js +5 -3
- package/dist/esm/utils/transpile-atomic.js +2 -2
- package/dist/esm/utils/transpile.js +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/helper.d.ts +1 -0
- package/dist/types/utils/override-longhand.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.exceptionCamelCase = exports.applyCssValue = exports.camelToKebabCase = exports.overrideLonghand = exports.processAtomicProps = exports.splitAtomicAndNested = exports.transpileAtomic = exports.transpile = exports.genBase36Hash = void 0;
|
|
3
|
+
exports.exceptionCamelCase = exports.isAtRule = exports.applyCssValue = exports.camelToKebabCase = exports.overrideLonghand = exports.processAtomicProps = exports.splitAtomicAndNested = exports.transpileAtomic = exports.transpile = exports.genBase36Hash = void 0;
|
|
4
4
|
var hash_js_1 = require("./utils/hash.js");
|
|
5
5
|
Object.defineProperty(exports, "genBase36Hash", { enumerable: true, get: function () { return hash_js_1.genBase36Hash; } });
|
|
6
6
|
var transpile_js_1 = require("./utils/transpile.js");
|
|
@@ -15,4 +15,5 @@ Object.defineProperty(exports, "overrideLonghand", { enumerable: true, get: func
|
|
|
15
15
|
var helper_js_1 = require("./utils/helper.js");
|
|
16
16
|
Object.defineProperty(exports, "camelToKebabCase", { enumerable: true, get: function () { return helper_js_1.camelToKebabCase; } });
|
|
17
17
|
Object.defineProperty(exports, "applyCssValue", { enumerable: true, get: function () { return helper_js_1.applyCssValue; } });
|
|
18
|
+
Object.defineProperty(exports, "isAtRule", { enumerable: true, get: function () { return helper_js_1.isAtRule; } });
|
|
18
19
|
Object.defineProperty(exports, "exceptionCamelCase", { enumerable: true, get: function () { return helper_js_1.exceptionCamelCase; } });
|
package/dist/cjs/utils/helper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.camelToKebabCase = exports.applyCssValue = exports.exceptionCamelCase = void 0;
|
|
3
|
+
exports.isAtRule = exports.camelToKebabCase = exports.applyCssValue = exports.exceptionCamelCase = void 0;
|
|
4
4
|
const hex_to_color_name_js_1 = require("./hex-to-color-name.js");
|
|
5
5
|
const exception = [
|
|
6
6
|
'animation-iteration-count',
|
|
@@ -61,3 +61,11 @@ const camelToKebabCase = (property) => {
|
|
|
61
61
|
.toLowerCase());
|
|
62
62
|
};
|
|
63
63
|
exports.camelToKebabCase = camelToKebabCase;
|
|
64
|
+
const isAtRule = (prop) => {
|
|
65
|
+
return (prop.startsWith('@media') ||
|
|
66
|
+
prop.startsWith('@container') ||
|
|
67
|
+
prop.startsWith('@supports') ||
|
|
68
|
+
prop.startsWith('@layer') ||
|
|
69
|
+
prop.startsWith('@scope'));
|
|
70
|
+
};
|
|
71
|
+
exports.isAtRule = isAtRule;
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.splitAtomicAndNested = splitAtomicAndNested;
|
|
4
4
|
exports.processAtomicProps = processAtomicProps;
|
|
5
|
-
const
|
|
5
|
+
const helper_js_1 = require("./helper.js");
|
|
6
|
+
const transpile_atomic_js_1 = require("./transpile-atomic.js");
|
|
7
|
+
const hash_js_1 = require("./hash.js");
|
|
6
8
|
const shorthand_js_1 = require("./shorthand.js");
|
|
7
9
|
function splitAtomicAndNested(obj, flat, nonFlat) {
|
|
8
10
|
const queryFlat = flat;
|
|
@@ -11,7 +13,7 @@ function splitAtomicAndNested(obj, flat, nonFlat) {
|
|
|
11
13
|
if (property.startsWith(':') || property.startsWith('[')) {
|
|
12
14
|
queryNonFlat[property] = value;
|
|
13
15
|
}
|
|
14
|
-
else if (
|
|
16
|
+
else if ((0, helper_js_1.isAtRule)(property)) {
|
|
15
17
|
const innerFlat = {};
|
|
16
18
|
const innerNonFlat = {};
|
|
17
19
|
splitAtomicAndNested(value, innerFlat, innerNonFlat);
|
|
@@ -34,21 +36,21 @@ Object.entries(shorthand_js_1.SHORTHAND_PROPERTIES).forEach(([shorthand, longhan
|
|
|
34
36
|
function processAtomicProps(flatProps, atomicMap, parentAtRule) {
|
|
35
37
|
const resultQueue = [];
|
|
36
38
|
for (const [key, style] of Object.entries(flatProps)) {
|
|
37
|
-
if (
|
|
39
|
+
if ((0, helper_js_1.isAtRule)(key)) {
|
|
38
40
|
processAtomicProps(style, atomicMap, key);
|
|
39
41
|
continue;
|
|
40
42
|
}
|
|
41
43
|
resultQueue.push([key, style]);
|
|
42
44
|
}
|
|
43
45
|
for (const [property, value] of resultQueue) {
|
|
44
|
-
const CSSProp = (0,
|
|
45
|
-
const normalizedValue = (0,
|
|
46
|
+
const CSSProp = (0, helper_js_1.camelToKebabCase)(property);
|
|
47
|
+
const normalizedValue = (0, helper_js_1.applyCssValue)(value, CSSProp);
|
|
46
48
|
const singlePropObj = { [property]: normalizedValue };
|
|
47
49
|
const styleObj = parentAtRule ? { [parentAtRule]: singlePropObj } : singlePropObj;
|
|
48
|
-
const atomicHash = (0,
|
|
50
|
+
const atomicHash = (0, hash_js_1.genBase36Hash)(styleObj, 1, 8);
|
|
49
51
|
if (atomicMap.has(atomicHash))
|
|
50
52
|
continue;
|
|
51
|
-
let styleSheet = (0,
|
|
53
|
+
let styleSheet = (0, transpile_atomic_js_1.transpileAtomic)(property, value, atomicHash);
|
|
52
54
|
if (parentAtRule) {
|
|
53
55
|
styleSheet = `${parentAtRule} { ${styleSheet} }`;
|
|
54
56
|
}
|
|
@@ -16,7 +16,7 @@ function transpileAtomic(property, value, hash, pseudo) {
|
|
|
16
16
|
selector += pseudo;
|
|
17
17
|
}
|
|
18
18
|
const atomicRule = `${selector} { ${CSSProp}: ${applyValue}; }`;
|
|
19
|
-
if (
|
|
19
|
+
if ((0, helper_js_1.isAtRule)(property)) {
|
|
20
20
|
return `${property} { ${atomicRule} }`;
|
|
21
21
|
}
|
|
22
22
|
return atomicRule;
|
|
@@ -54,7 +54,7 @@ function transpile(object, base36Hash, core) {
|
|
|
54
54
|
const styles = stringConverter(selector, value, indentLevel);
|
|
55
55
|
Object.assign(classSelector, styles);
|
|
56
56
|
}
|
|
57
|
-
else if (
|
|
57
|
+
else if ((0, helper_js_1.isAtRule)(property)) {
|
|
58
58
|
const mediaRule = property;
|
|
59
59
|
let nestedRules = '';
|
|
60
60
|
let regularRules = '';
|
package/dist/esm/index.js
CHANGED
|
@@ -3,4 +3,4 @@ export { transpile } from './utils/transpile.js';
|
|
|
3
3
|
export { transpileAtomic } from './utils/transpile-atomic.js';
|
|
4
4
|
export { splitAtomicAndNested, processAtomicProps } from './utils/processor-atomic.js';
|
|
5
5
|
export { overrideLonghand } from './utils/override-longhand.js';
|
|
6
|
-
export { camelToKebabCase, applyCssValue, exceptionCamelCase } from './utils/helper.js';
|
|
6
|
+
export { camelToKebabCase, applyCssValue, isAtRule, exceptionCamelCase } from './utils/helper.js';
|
package/dist/esm/utils/helper.js
CHANGED
|
@@ -56,3 +56,10 @@ export const camelToKebabCase = (property) => {
|
|
|
56
56
|
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')
|
|
57
57
|
.toLowerCase());
|
|
58
58
|
};
|
|
59
|
+
export const isAtRule = (prop) => {
|
|
60
|
+
return (prop.startsWith('@media') ||
|
|
61
|
+
prop.startsWith('@container') ||
|
|
62
|
+
prop.startsWith('@supports') ||
|
|
63
|
+
prop.startsWith('@layer') ||
|
|
64
|
+
prop.startsWith('@scope'));
|
|
65
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { camelToKebabCase,
|
|
1
|
+
import { camelToKebabCase, applyCssValue, isAtRule } from './helper.js';
|
|
2
|
+
import { transpileAtomic } from './transpile-atomic.js';
|
|
3
|
+
import { genBase36Hash } from './hash.js';
|
|
2
4
|
import { SHORTHAND_PROPERTIES } from './shorthand.js';
|
|
3
5
|
function splitAtomicAndNested(obj, flat, nonFlat) {
|
|
4
6
|
const queryFlat = flat;
|
|
@@ -7,7 +9,7 @@ function splitAtomicAndNested(obj, flat, nonFlat) {
|
|
|
7
9
|
if (property.startsWith(':') || property.startsWith('[')) {
|
|
8
10
|
queryNonFlat[property] = value;
|
|
9
11
|
}
|
|
10
|
-
else if (
|
|
12
|
+
else if (isAtRule(property)) {
|
|
11
13
|
const innerFlat = {};
|
|
12
14
|
const innerNonFlat = {};
|
|
13
15
|
splitAtomicAndNested(value, innerFlat, innerNonFlat);
|
|
@@ -30,7 +32,7 @@ Object.entries(SHORTHAND_PROPERTIES).forEach(([shorthand, longhands]) => {
|
|
|
30
32
|
function processAtomicProps(flatProps, atomicMap, parentAtRule) {
|
|
31
33
|
const resultQueue = [];
|
|
32
34
|
for (const [key, style] of Object.entries(flatProps)) {
|
|
33
|
-
if (
|
|
35
|
+
if (isAtRule(key)) {
|
|
34
36
|
processAtomicProps(style, atomicMap, key);
|
|
35
37
|
continue;
|
|
36
38
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { applyCssValue, camelToKebabCase } from './helper.js';
|
|
1
|
+
import { applyCssValue, camelToKebabCase, isAtRule } from './helper.js';
|
|
2
2
|
import { SHORTHAND_PROPERTIES } from './shorthand.js';
|
|
3
3
|
const ALL_LONGHANDS = new Set(Object.values(SHORTHAND_PROPERTIES).flat());
|
|
4
4
|
function transpileAtomic(property, value, hash, pseudo) {
|
|
@@ -13,7 +13,7 @@ function transpileAtomic(property, value, hash, pseudo) {
|
|
|
13
13
|
selector += pseudo;
|
|
14
14
|
}
|
|
15
15
|
const atomicRule = `${selector} { ${CSSProp}: ${applyValue}; }`;
|
|
16
|
-
if (
|
|
16
|
+
if (isAtRule(property)) {
|
|
17
17
|
return `${property} { ${atomicRule} }`;
|
|
18
18
|
}
|
|
19
19
|
return atomicRule;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { camelToKebabCase, applyCssValue } from './helper.js';
|
|
1
|
+
import { camelToKebabCase, applyCssValue, isAtRule } from './helper.js';
|
|
2
2
|
const createKeyframes = (property, content) => {
|
|
3
3
|
let keyframesRules = `${property} {\n`;
|
|
4
4
|
for (const key in content) {
|
|
@@ -51,7 +51,7 @@ export function transpile(object, base36Hash, core) {
|
|
|
51
51
|
const styles = stringConverter(selector, value, indentLevel);
|
|
52
52
|
Object.assign(classSelector, styles);
|
|
53
53
|
}
|
|
54
|
-
else if (
|
|
54
|
+
else if (isAtRule(property)) {
|
|
55
55
|
const mediaRule = property;
|
|
56
56
|
let nestedRules = '';
|
|
57
57
|
let regularRules = '';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export { transpile } from './utils/transpile.js';
|
|
|
4
4
|
export { transpileAtomic } from './utils/transpile-atomic.js';
|
|
5
5
|
export { splitAtomicAndNested, processAtomicProps } from './utils/processor-atomic.js';
|
|
6
6
|
export { overrideLonghand } from './utils/override-longhand.js';
|
|
7
|
-
export { camelToKebabCase, applyCssValue, exceptionCamelCase } from './utils/helper.js';
|
|
7
|
+
export { camelToKebabCase, applyCssValue, isAtRule, exceptionCamelCase } from './utils/helper.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CSSProperties } from '../types/css-properties.js';
|
|
1
|
+
import type { CSSProperties } from '../types/css-properties.js';
|
|
2
2
|
export declare const overrideLonghand: (style: CSSProperties) => CSSProperties;
|
package/package.json
CHANGED