zss-engine 0.2.49 → 0.2.51
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 +4 -1
- package/dist/cjs/utils/processor-atomic.js +46 -0
- package/dist/cjs/utils/transpile-atomic.js +3 -3
- package/dist/cjs/utils/transpile.js +3 -3
- package/dist/esm/index.js +1 -0
- package/dist/esm/utils/processor-atomic.js +43 -0
- package/dist/esm/utils/transpile-atomic.js +1 -1
- package/dist/esm/utils/transpile.js +3 -3
- package/package.json +1 -1
- package/types/index.d.ts +1 -0
- package/types/utils/hash.d.ts +2 -2
- package/types/utils/processor-atomic.d.ts +4 -0
- package/types/utils/transpile.d.ts +2 -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.getServerCSS = exports.injectServerCSS = exports.injectClientGlobalCSS = exports.injectClientCSS = exports.applyCssValue = exports.camelToKebabCase = exports.build = exports.transpileAtomic = exports.transpile = exports.genBase36Hash = exports.isTestingDevelopment = exports.isDevelopment = exports.isServer = void 0;
|
|
3
|
+
exports.getServerCSS = exports.injectServerCSS = exports.injectClientGlobalCSS = exports.injectClientCSS = exports.applyCssValue = exports.camelToKebabCase = exports.build = 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,6 +11,9 @@ 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 processor_atomic_js_1 = require("./utils/processor-atomic.js");
|
|
15
|
+
Object.defineProperty(exports, "splitAtomicAndNested", { enumerable: true, get: function () { return processor_atomic_js_1.splitAtomicAndNested; } });
|
|
16
|
+
Object.defineProperty(exports, "processAtomicProps", { enumerable: true, get: function () { return processor_atomic_js_1.processAtomicProps; } });
|
|
14
17
|
var build_js_1 = require("./utils/build.js");
|
|
15
18
|
Object.defineProperty(exports, "build", { enumerable: true, get: function () { return build_js_1.build; } });
|
|
16
19
|
var helper_js_2 = require("./utils/helper.js");
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.splitAtomicAndNested = splitAtomicAndNested;
|
|
4
|
+
exports.processAtomicProps = processAtomicProps;
|
|
5
|
+
const index_js_1 = require("../index.js");
|
|
6
|
+
function splitAtomicAndNested(obj, flat, nonFlat) {
|
|
7
|
+
Object.entries(obj).forEach(([property, value]) => {
|
|
8
|
+
if (property.startsWith(':') || property.startsWith('&')) {
|
|
9
|
+
nonFlat[property] = value;
|
|
10
|
+
}
|
|
11
|
+
else if (property.startsWith('@media') || property.startsWith('@container')) {
|
|
12
|
+
const innerFlat = {};
|
|
13
|
+
const innerNonFlat = {};
|
|
14
|
+
splitAtomicAndNested(value, innerFlat, innerNonFlat);
|
|
15
|
+
if (Object.keys(innerFlat).length)
|
|
16
|
+
flat[property] = innerFlat;
|
|
17
|
+
if (Object.keys(innerNonFlat).length)
|
|
18
|
+
nonFlat[property] = innerNonFlat;
|
|
19
|
+
}
|
|
20
|
+
else if (typeof value === 'object' && value !== null) {
|
|
21
|
+
flat[property] = value;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
flat[property] = value;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function processAtomicProps(flatProps, parentAtRule, atomicHashes, allStyleSheets) {
|
|
29
|
+
Object.entries(flatProps).forEach(([property, value]) => {
|
|
30
|
+
if (property.startsWith('@media') || property.startsWith('@container')) {
|
|
31
|
+
processAtomicProps(value, property);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
const CSSProp = (0, index_js_1.camelToKebabCase)(property);
|
|
35
|
+
const normalizedValue = (0, index_js_1.applyCssValue)(value, CSSProp);
|
|
36
|
+
const singlePropObj = { [property]: normalizedValue };
|
|
37
|
+
const atomicHash = (0, index_js_1.genBase36Hash)(singlePropObj, 6);
|
|
38
|
+
atomicHashes?.push(atomicHash);
|
|
39
|
+
let styleSheet = (0, index_js_1.transpileAtomic)(property, value, atomicHash);
|
|
40
|
+
if (parentAtRule) {
|
|
41
|
+
styleSheet = `${parentAtRule} { ${styleSheet} }`;
|
|
42
|
+
}
|
|
43
|
+
allStyleSheets?.push(styleSheet);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transpileAtomic = transpileAtomic;
|
|
4
|
-
const
|
|
4
|
+
const helper_js_1 = require("./helper.js");
|
|
5
5
|
function transpileAtomic(property, value, hash) {
|
|
6
6
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
7
|
-
const CSSProp = (0,
|
|
8
|
-
const applyValue = (0,
|
|
7
|
+
const CSSProp = (0, helper_js_1.camelToKebabCase)(property);
|
|
8
|
+
const applyValue = (0, helper_js_1.applyCssValue)(value, CSSProp);
|
|
9
9
|
const atomicRule = `.${hash} { ${CSSProp}: ${applyValue}; }`;
|
|
10
10
|
if (property.startsWith('@media') || property.startsWith('@container')) {
|
|
11
11
|
return `${property} {\n ${atomicRule}\n}\n`;
|
|
@@ -27,8 +27,8 @@ const createKeyframes = (property, content) => {
|
|
|
27
27
|
function transpile(object, base36Hash, core) {
|
|
28
28
|
let styleSheet = '';
|
|
29
29
|
const mediaQueries = [];
|
|
30
|
-
const
|
|
31
|
-
return core === '--global' ? property : `.${
|
|
30
|
+
const classNameApply = (property) => {
|
|
31
|
+
return core === '--global' ? property : `.${base36Hash}`;
|
|
32
32
|
};
|
|
33
33
|
const rules = (indent, rulesValue, property) => {
|
|
34
34
|
if (typeof property !== 'string')
|
|
@@ -108,7 +108,7 @@ function transpile(object, base36Hash, core) {
|
|
|
108
108
|
const keyframesContent = object[property];
|
|
109
109
|
styleSheet += createKeyframes(property, keyframesContent);
|
|
110
110
|
}
|
|
111
|
-
const classSelectors = stringConverter(
|
|
111
|
+
const classSelectors = stringConverter(classNameApply(property), object[property], 1);
|
|
112
112
|
for (const selector in classSelectors) {
|
|
113
113
|
if (!selector.startsWith('@keyframes') && classSelectors[selector]) {
|
|
114
114
|
styleSheet += selector + ' {\n' + classSelectors[selector] + '}\n';
|
package/dist/esm/index.js
CHANGED
|
@@ -2,6 +2,7 @@ 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 { splitAtomicAndNested, processAtomicProps } from './utils/processor-atomic.js';
|
|
5
6
|
export { build } from './utils/build.js';
|
|
6
7
|
export { camelToKebabCase, applyCssValue } from './utils/helper.js';
|
|
7
8
|
export { injectClientCSS } from './utils/inject-client-css.js';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { camelToKebabCase, genBase36Hash, applyCssValue, transpileAtomic } from '../index.js';
|
|
2
|
+
function splitAtomicAndNested(obj, flat, nonFlat) {
|
|
3
|
+
Object.entries(obj).forEach(([property, value]) => {
|
|
4
|
+
if (property.startsWith(':') || property.startsWith('&')) {
|
|
5
|
+
nonFlat[property] = value;
|
|
6
|
+
}
|
|
7
|
+
else if (property.startsWith('@media') || property.startsWith('@container')) {
|
|
8
|
+
const innerFlat = {};
|
|
9
|
+
const innerNonFlat = {};
|
|
10
|
+
splitAtomicAndNested(value, innerFlat, innerNonFlat);
|
|
11
|
+
if (Object.keys(innerFlat).length)
|
|
12
|
+
flat[property] = innerFlat;
|
|
13
|
+
if (Object.keys(innerNonFlat).length)
|
|
14
|
+
nonFlat[property] = innerNonFlat;
|
|
15
|
+
}
|
|
16
|
+
else if (typeof value === 'object' && value !== null) {
|
|
17
|
+
flat[property] = value;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
flat[property] = value;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function processAtomicProps(flatProps, parentAtRule, atomicHashes, allStyleSheets) {
|
|
25
|
+
Object.entries(flatProps).forEach(([property, value]) => {
|
|
26
|
+
if (property.startsWith('@media') || property.startsWith('@container')) {
|
|
27
|
+
processAtomicProps(value, property);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
const CSSProp = camelToKebabCase(property);
|
|
31
|
+
const normalizedValue = applyCssValue(value, CSSProp);
|
|
32
|
+
const singlePropObj = { [property]: normalizedValue };
|
|
33
|
+
const atomicHash = genBase36Hash(singlePropObj, 6);
|
|
34
|
+
atomicHashes?.push(atomicHash);
|
|
35
|
+
let styleSheet = transpileAtomic(property, value, atomicHash);
|
|
36
|
+
if (parentAtRule) {
|
|
37
|
+
styleSheet = `${parentAtRule} { ${styleSheet} }`;
|
|
38
|
+
}
|
|
39
|
+
allStyleSheets?.push(styleSheet);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export { splitAtomicAndNested, processAtomicProps };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { applyCssValue, camelToKebabCase } from './helper';
|
|
1
|
+
import { applyCssValue, camelToKebabCase } from './helper.js';
|
|
2
2
|
function transpileAtomic(property, value, hash) {
|
|
3
3
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
4
4
|
const CSSProp = camelToKebabCase(property);
|
|
@@ -24,8 +24,8 @@ const createKeyframes = (property, content) => {
|
|
|
24
24
|
export function transpile(object, base36Hash, core) {
|
|
25
25
|
let styleSheet = '';
|
|
26
26
|
const mediaQueries = [];
|
|
27
|
-
const
|
|
28
|
-
return core === '--global' ? property : `.${
|
|
27
|
+
const classNameApply = (property) => {
|
|
28
|
+
return core === '--global' ? property : `.${base36Hash}`;
|
|
29
29
|
};
|
|
30
30
|
const rules = (indent, rulesValue, property) => {
|
|
31
31
|
if (typeof property !== 'string')
|
|
@@ -105,7 +105,7 @@ export function transpile(object, base36Hash, core) {
|
|
|
105
105
|
const keyframesContent = object[property];
|
|
106
106
|
styleSheet += createKeyframes(property, keyframesContent);
|
|
107
107
|
}
|
|
108
|
-
const classSelectors = stringConverter(
|
|
108
|
+
const classSelectors = stringConverter(classNameApply(property), object[property], 1);
|
|
109
109
|
for (const selector in classSelectors) {
|
|
110
110
|
if (!selector.startsWith('@keyframes') && classSelectors[selector]) {
|
|
111
111
|
styleSheet += selector + ' {\n' + classSelectors[selector] + '}\n';
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ 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 { splitAtomicAndNested, processAtomicProps } from './utils/processor-atomic.js';
|
|
10
11
|
export { build } from './utils/build.js';
|
|
11
12
|
export { camelToKebabCase, applyCssValue } from './utils/helper.js';
|
|
12
13
|
export { injectClientCSS } from './utils/inject-client-css.js';
|
package/types/utils/hash.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CreateStyle, CreateKeyframes } from '../index.js';
|
|
2
|
-
export declare function genBase36Hash(object: CreateStyle | CreateKeyframes, n: number): string;
|
|
1
|
+
import { CreateStyle, CreateKeyframes, CSSProperties } from '../index.js';
|
|
2
|
+
export declare function genBase36Hash(object: CreateStyle | CSSProperties | CreateKeyframes, n: number): string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CSSProperties, CreateStyle } from '../index.js';
|
|
2
|
+
declare function splitAtomicAndNested(obj: CSSProperties, flat: CreateStyle, nonFlat: CreateStyle): void;
|
|
3
|
+
declare function processAtomicProps(flatProps: Record<string, unknown>, parentAtRule?: string, atomicHashes?: string[], allStyleSheets?: string[]): void;
|
|
4
|
+
export { splitAtomicAndNested, processAtomicProps };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CSSHTML } from '../index.js';
|
|
2
|
-
export declare function transpile(object: CSSHTML, base36Hash?: string, core?: string): {
|
|
1
|
+
import type { CSSProperties, CSSHTML, CreateStyle } from '../index.js';
|
|
2
|
+
export declare function transpile(object: CSSHTML | CreateStyle | CSSProperties, base36Hash?: string, core?: string): {
|
|
3
3
|
styleSheet: string;
|
|
4
4
|
};
|