zss-engine 1.0.0 → 1.2.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 +1 -3
- package/dist/cjs/utils/processor-atomic.js +4 -5
- package/dist/esm/index.js +0 -1
- package/dist/esm/utils/processor-atomic.js +4 -5
- package/dist/types/index.d.ts +1 -2
- package/dist/types/types/main/variableTypes.d.ts +3 -3
- package/dist/types/utils/processor-atomic.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cjs/utils/transform-nested-selectors.js +0 -15
- package/dist/esm/utils/transform-nested-selectors.js +0 -12
- package/dist/types/utils/transform-nested-selectors.d.ts +0 -2
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applyCssValue = exports.camelToKebabCase = exports.build = exports.overrideLonghand = exports.processAtomicProps = exports.splitAtomicAndNested = exports.
|
|
3
|
+
exports.applyCssValue = exports.camelToKebabCase = exports.build = exports.overrideLonghand = exports.processAtomicProps = exports.splitAtomicAndNested = exports.transpileAtomic = exports.transpile = exports.genBase36Hash = exports.isTestingDevelopment = exports.isDevelopment = exports.isServer = void 0;
|
|
4
4
|
var helper_js_1 = require("./utils/helper.js");
|
|
5
5
|
Object.defineProperty(exports, "isServer", { enumerable: true, get: function () { return helper_js_1.isServer; } });
|
|
6
6
|
Object.defineProperty(exports, "isDevelopment", { enumerable: true, get: function () { return helper_js_1.isDevelopment; } });
|
|
@@ -11,8 +11,6 @@ var transpile_js_1 = require("./utils/transpile.js");
|
|
|
11
11
|
Object.defineProperty(exports, "transpile", { enumerable: true, get: function () { return transpile_js_1.transpile; } });
|
|
12
12
|
var transpile_atomic_js_1 = require("./utils/transpile-atomic.js");
|
|
13
13
|
Object.defineProperty(exports, "transpileAtomic", { enumerable: true, get: function () { return transpile_atomic_js_1.transpileAtomic; } });
|
|
14
|
-
var transform_nested_selectors_js_1 = require("./utils/transform-nested-selectors.js");
|
|
15
|
-
Object.defineProperty(exports, "transformNestedSelectors", { enumerable: true, get: function () { return transform_nested_selectors_js_1.transformNestedSelectors; } });
|
|
16
14
|
var processor_atomic_js_1 = require("./utils/processor-atomic.js");
|
|
17
15
|
Object.defineProperty(exports, "splitAtomicAndNested", { enumerable: true, get: function () { return processor_atomic_js_1.splitAtomicAndNested; } });
|
|
18
16
|
Object.defineProperty(exports, "processAtomicProps", { enumerable: true, get: function () { return processor_atomic_js_1.processAtomicProps; } });
|
|
@@ -29,11 +29,11 @@ Object.entries(shorthand_js_1.SHORTHAND_PROPERTIES).forEach(([shorthand, longhan
|
|
|
29
29
|
LONG_TO_SHORT[long] = shorthand;
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
|
-
function processAtomicProps(flatProps,
|
|
32
|
+
function processAtomicProps(flatProps, atomicMap, parentAtRule) {
|
|
33
33
|
const resultQueue = [];
|
|
34
34
|
for (const [property, value] of Object.entries(flatProps)) {
|
|
35
35
|
if (property.startsWith('@media') || property.startsWith('@container')) {
|
|
36
|
-
processAtomicProps(value,
|
|
36
|
+
processAtomicProps(value, atomicMap, property);
|
|
37
37
|
continue;
|
|
38
38
|
}
|
|
39
39
|
resultQueue.push([property, value]);
|
|
@@ -44,13 +44,12 @@ function processAtomicProps(flatProps, atomicHashes, allStyleSheets, parentAtRul
|
|
|
44
44
|
const singlePropObj = { [property]: normalizedValue };
|
|
45
45
|
const styleObj = parentAtRule ? { [parentAtRule]: singlePropObj } : singlePropObj;
|
|
46
46
|
const atomicHash = (0, index_js_1.genBase36Hash)(styleObj, 1, 8);
|
|
47
|
-
if (
|
|
47
|
+
if (atomicMap.has(atomicHash))
|
|
48
48
|
continue;
|
|
49
|
-
atomicHashes.add(atomicHash);
|
|
50
49
|
let styleSheet = (0, index_js_1.transpileAtomic)(property, value, atomicHash);
|
|
51
50
|
if (parentAtRule) {
|
|
52
51
|
styleSheet = `${parentAtRule} { ${styleSheet} }`;
|
|
53
52
|
}
|
|
54
|
-
|
|
53
|
+
atomicMap.set(atomicHash, styleSheet + '\n');
|
|
55
54
|
}
|
|
56
55
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -2,7 +2,6 @@ export { isServer, isDevelopment, isTestingDevelopment } from './utils/helper.js
|
|
|
2
2
|
export { genBase36Hash } from './utils/hash.js';
|
|
3
3
|
export { transpile } from './utils/transpile.js';
|
|
4
4
|
export { transpileAtomic } from './utils/transpile-atomic.js';
|
|
5
|
-
export { transformNestedSelectors } from './utils/transform-nested-selectors.js';
|
|
6
5
|
export { splitAtomicAndNested, processAtomicProps } from './utils/processor-atomic.js';
|
|
7
6
|
export { overrideLonghand } from './utils/override-longhand.js';
|
|
8
7
|
export { build } from './utils/build.js';
|
|
@@ -25,11 +25,11 @@ Object.entries(SHORTHAND_PROPERTIES).forEach(([shorthand, longhands]) => {
|
|
|
25
25
|
LONG_TO_SHORT[long] = shorthand;
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
|
-
function processAtomicProps(flatProps,
|
|
28
|
+
function processAtomicProps(flatProps, atomicMap, parentAtRule) {
|
|
29
29
|
const resultQueue = [];
|
|
30
30
|
for (const [property, value] of Object.entries(flatProps)) {
|
|
31
31
|
if (property.startsWith('@media') || property.startsWith('@container')) {
|
|
32
|
-
processAtomicProps(value,
|
|
32
|
+
processAtomicProps(value, atomicMap, property);
|
|
33
33
|
continue;
|
|
34
34
|
}
|
|
35
35
|
resultQueue.push([property, value]);
|
|
@@ -40,14 +40,13 @@ function processAtomicProps(flatProps, atomicHashes, allStyleSheets, parentAtRul
|
|
|
40
40
|
const singlePropObj = { [property]: normalizedValue };
|
|
41
41
|
const styleObj = parentAtRule ? { [parentAtRule]: singlePropObj } : singlePropObj;
|
|
42
42
|
const atomicHash = genBase36Hash(styleObj, 1, 8);
|
|
43
|
-
if (
|
|
43
|
+
if (atomicMap.has(atomicHash))
|
|
44
44
|
continue;
|
|
45
|
-
atomicHashes.add(atomicHash);
|
|
46
45
|
let styleSheet = transpileAtomic(property, value, atomicHash);
|
|
47
46
|
if (parentAtRule) {
|
|
48
47
|
styleSheet = `${parentAtRule} { ${styleSheet} }`;
|
|
49
48
|
}
|
|
50
|
-
|
|
49
|
+
atomicMap.set(atomicHash, styleSheet + '\n');
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
export { splitAtomicAndNested, processAtomicProps };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
export type { CSSProperties } from './types/common/css-properties';
|
|
2
2
|
export type { CreateStyleType, ReturnType, CreateStyle } from './types/main/create';
|
|
3
3
|
export type { CSSHTML, CreateKeyframes } from './types/main/global';
|
|
4
|
-
export type {
|
|
4
|
+
export type { CreateTheme, CreateValues, ReturnVariableType, XVariableSet, ReturnX } from './types/main/variableTypes';
|
|
5
5
|
export type { ViewTransitionOptions } from './types/main/viewTransitionOptions';
|
|
6
6
|
export { isServer, isDevelopment, isTestingDevelopment } from './utils/helper.js';
|
|
7
7
|
export { genBase36Hash } from './utils/hash.js';
|
|
8
8
|
export { transpile } from './utils/transpile.js';
|
|
9
9
|
export { transpileAtomic } from './utils/transpile-atomic.js';
|
|
10
|
-
export { transformNestedSelectors } from './utils/transform-nested-selectors.js';
|
|
11
10
|
export { splitAtomicAndNested, processAtomicProps } from './utils/processor-atomic.js';
|
|
12
11
|
export { overrideLonghand } from './utils/override-longhand.js';
|
|
13
12
|
export { build } from './utils/build.js';
|
|
@@ -4,14 +4,14 @@ export type CSSVariableProperty = {
|
|
|
4
4
|
[key: CSSVariableKey]: string | number;
|
|
5
5
|
};
|
|
6
6
|
export type CreateValues = Record<string, string | number>;
|
|
7
|
-
export type
|
|
7
|
+
export type CreateTheme = Record<string, Record<string, string | number>>;
|
|
8
8
|
export type ReturnVariableType<T> = {
|
|
9
9
|
[K in keyof T]: CSSVariableValue;
|
|
10
10
|
};
|
|
11
|
-
export type
|
|
11
|
+
export type XVariableSet = {
|
|
12
12
|
[key: CSSVariableKey]: string;
|
|
13
13
|
};
|
|
14
|
-
export type
|
|
14
|
+
export type ReturnX = {
|
|
15
15
|
className: string;
|
|
16
16
|
style: {
|
|
17
17
|
[k: string]: string;
|
|
@@ -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: CSSProperties,
|
|
3
|
+
declare function processAtomicProps(flatProps: CSSProperties, atomicMap: Map<string, string>, parentAtRule?: string): void;
|
|
4
4
|
export { splitAtomicAndNested, processAtomicProps };
|
package/package.json
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformNestedSelectors = transformNestedSelectors;
|
|
4
|
-
function transformNestedSelectors(nonFlat) {
|
|
5
|
-
const modNonFlat = {};
|
|
6
|
-
Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
|
|
7
|
-
if (atRule.startsWith(':') || atRule.startsWith('&')) {
|
|
8
|
-
modNonFlat[`:not(#\\#)${atRule}`] = nestedObj;
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
modNonFlat[atRule] = nestedObj;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
return modNonFlat;
|
|
15
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export function transformNestedSelectors(nonFlat) {
|
|
2
|
-
const modNonFlat = {};
|
|
3
|
-
Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
|
|
4
|
-
if (atRule.startsWith(':') || atRule.startsWith('&')) {
|
|
5
|
-
modNonFlat[`:not(#\\#)${atRule}`] = nestedObj;
|
|
6
|
-
}
|
|
7
|
-
else {
|
|
8
|
-
modNonFlat[atRule] = nestedObj;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
return modNonFlat;
|
|
12
|
-
}
|