zss-engine 0.2.91 → 0.2.93
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 +4 -18
- package/dist/cjs/utils/shorthand.js +10 -1
- package/dist/cjs/utils/transpile-atomic.js +7 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/utils/processor-atomic.js +4 -18
- package/dist/esm/utils/shorthand.js +9 -0
- package/dist/esm/utils/transpile-atomic.js +7 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/utils/processor-atomic.d.ts +1 -1
- package/dist/types/utils/shorthand.d.ts +1 -0
- 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.isHashInStyleSheets = exports.injectClientGlobalCSS = exports.injectClientQuery = 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;
|
|
3
|
+
exports.isHashInStyleSheets = exports.injectClientGlobalCSS = exports.injectClientQuery = exports.injectClientCSS = exports.applyCssValue = exports.camelToKebabCase = exports.build = exports.LONG_TO_SHORT = exports.SHORTHAND_PROPERTIES = 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; } });
|
|
@@ -14,6 +14,9 @@ Object.defineProperty(exports, "transpileAtomic", { enumerable: true, get: funct
|
|
|
14
14
|
var processor_atomic_js_1 = require("./utils/processor-atomic.js");
|
|
15
15
|
Object.defineProperty(exports, "splitAtomicAndNested", { enumerable: true, get: function () { return processor_atomic_js_1.splitAtomicAndNested; } });
|
|
16
16
|
Object.defineProperty(exports, "processAtomicProps", { enumerable: true, get: function () { return processor_atomic_js_1.processAtomicProps; } });
|
|
17
|
+
var shorthand_js_1 = require("./utils/shorthand.js");
|
|
18
|
+
Object.defineProperty(exports, "SHORTHAND_PROPERTIES", { enumerable: true, get: function () { return shorthand_js_1.SHORTHAND_PROPERTIES; } });
|
|
19
|
+
Object.defineProperty(exports, "LONG_TO_SHORT", { enumerable: true, get: function () { return shorthand_js_1.LONG_TO_SHORT; } });
|
|
17
20
|
var build_js_1 = require("./utils/build.js");
|
|
18
21
|
Object.defineProperty(exports, "build", { enumerable: true, get: function () { return build_js_1.build; } });
|
|
19
22
|
var helper_js_2 = require("./utils/helper.js");
|
|
@@ -29,28 +29,14 @@ 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, atomicHashes, allStyleSheets,
|
|
32
|
+
function processAtomicProps(flatProps, atomicHashes, allStyleSheets, parentAtRule) {
|
|
33
|
+
const resultQueue = [];
|
|
33
34
|
for (const [property, value] of Object.entries(flatProps)) {
|
|
34
35
|
if (property.startsWith('@media') || property.startsWith('@container')) {
|
|
35
|
-
|
|
36
|
-
processAtomicProps(value, atomicHashes, allStyleSheets, seen, nestedQueue, property);
|
|
36
|
+
processAtomicProps(value, atomicHashes, allStyleSheets, property);
|
|
37
37
|
continue;
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
if (shorthand_js_1.SHORTHAND_PROPERTIES[kebab]) {
|
|
41
|
-
const longhands = shorthand_js_1.SHORTHAND_PROPERTIES[kebab];
|
|
42
|
-
longhands.forEach(longhand => seen.delete(longhand));
|
|
43
|
-
seen.add(kebab);
|
|
44
|
-
resultQueue.push([property, value]);
|
|
45
|
-
}
|
|
46
|
-
else if (kebab in LONG_TO_SHORT) {
|
|
47
|
-
seen.add(kebab);
|
|
48
|
-
resultQueue.push([property, value]);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
seen.add(kebab);
|
|
52
|
-
resultQueue.push([property, value]);
|
|
53
|
-
}
|
|
39
|
+
resultQueue.push([property, value]);
|
|
54
40
|
}
|
|
55
41
|
for (const [property, value] of resultQueue) {
|
|
56
42
|
const CSSProp = (0, index_js_1.camelToKebabCase)(property);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SHORTHAND_PROPERTIES = void 0;
|
|
3
|
+
exports.LONG_TO_SHORT = exports.SHORTHAND_PROPERTIES = void 0;
|
|
4
4
|
exports.SHORTHAND_PROPERTIES = {
|
|
5
5
|
margin: ['margin-top', 'margin-bottom', 'margin-left', 'margin-right'],
|
|
6
6
|
padding: ['padding-top', 'padding-bottom', 'padding-left', 'padding-right'],
|
|
@@ -78,3 +78,12 @@ exports.SHORTHAND_PROPERTIES = {
|
|
|
78
78
|
'text-emphasis': ['text-emphasis-style', 'text-emphasis-color'],
|
|
79
79
|
mask: ['mask-image', 'mask-mode', 'mask-position', 'mask-size', 'mask-repeat', 'mask-origin', 'mask-clip', 'mask-composite'],
|
|
80
80
|
};
|
|
81
|
+
exports.LONG_TO_SHORT = {};
|
|
82
|
+
Object.entries(exports.SHORTHAND_PROPERTIES).forEach(([shorthand, longhands]) => {
|
|
83
|
+
longhands.forEach(longhand => {
|
|
84
|
+
if (!exports.LONG_TO_SHORT[longhand]) {
|
|
85
|
+
exports.LONG_TO_SHORT[longhand] = [];
|
|
86
|
+
}
|
|
87
|
+
exports.LONG_TO_SHORT[longhand].push(shorthand);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -2,11 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transpileAtomic = transpileAtomic;
|
|
4
4
|
const helper_js_1 = require("./helper.js");
|
|
5
|
+
const shorthand_js_1 = require("./shorthand.js");
|
|
6
|
+
const ALL_LONGHANDS = new Set(Object.values(shorthand_js_1.SHORTHAND_PROPERTIES).flat());
|
|
5
7
|
function transpileAtomic(property, value, hash) {
|
|
6
8
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
7
9
|
const CSSProp = (0, helper_js_1.camelToKebabCase)(property);
|
|
8
10
|
const applyValue = (0, helper_js_1.applyCssValue)(value, CSSProp);
|
|
9
|
-
|
|
11
|
+
let selector = `.${hash}`;
|
|
12
|
+
if (ALL_LONGHANDS.has(CSSProp)) {
|
|
13
|
+
selector += ':not(#\\#)';
|
|
14
|
+
}
|
|
15
|
+
const atomicRule = `${selector} { ${CSSProp}: ${applyValue}; }`;
|
|
10
16
|
if (property.startsWith('@media') || property.startsWith('@container')) {
|
|
11
17
|
return `${property} { ${atomicRule} }`;
|
|
12
18
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export { genBase36Hash } from './utils/hash.js';
|
|
|
3
3
|
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
|
+
export { SHORTHAND_PROPERTIES, LONG_TO_SHORT } from './utils/shorthand.js';
|
|
6
7
|
export { build } from './utils/build.js';
|
|
7
8
|
export { camelToKebabCase, applyCssValue } from './utils/helper.js';
|
|
8
9
|
export { injectClientCSS, injectClientQuery } from './utils/inject-client-css.js';
|
|
@@ -25,28 +25,14 @@ Object.entries(SHORTHAND_PROPERTIES).forEach(([shorthand, longhands]) => {
|
|
|
25
25
|
LONG_TO_SHORT[long] = shorthand;
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
|
-
function processAtomicProps(flatProps, atomicHashes, allStyleSheets,
|
|
28
|
+
function processAtomicProps(flatProps, atomicHashes, allStyleSheets, parentAtRule) {
|
|
29
|
+
const resultQueue = [];
|
|
29
30
|
for (const [property, value] of Object.entries(flatProps)) {
|
|
30
31
|
if (property.startsWith('@media') || property.startsWith('@container')) {
|
|
31
|
-
|
|
32
|
-
processAtomicProps(value, atomicHashes, allStyleSheets, seen, nestedQueue, property);
|
|
32
|
+
processAtomicProps(value, atomicHashes, allStyleSheets, property);
|
|
33
33
|
continue;
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
if (SHORTHAND_PROPERTIES[kebab]) {
|
|
37
|
-
const longhands = SHORTHAND_PROPERTIES[kebab];
|
|
38
|
-
longhands.forEach(longhand => seen.delete(longhand));
|
|
39
|
-
seen.add(kebab);
|
|
40
|
-
resultQueue.push([property, value]);
|
|
41
|
-
}
|
|
42
|
-
else if (kebab in LONG_TO_SHORT) {
|
|
43
|
-
seen.add(kebab);
|
|
44
|
-
resultQueue.push([property, value]);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
seen.add(kebab);
|
|
48
|
-
resultQueue.push([property, value]);
|
|
49
|
-
}
|
|
35
|
+
resultQueue.push([property, value]);
|
|
50
36
|
}
|
|
51
37
|
for (const [property, value] of resultQueue) {
|
|
52
38
|
const CSSProp = camelToKebabCase(property);
|
|
@@ -75,3 +75,12 @@ export const SHORTHAND_PROPERTIES = {
|
|
|
75
75
|
'text-emphasis': ['text-emphasis-style', 'text-emphasis-color'],
|
|
76
76
|
mask: ['mask-image', 'mask-mode', 'mask-position', 'mask-size', 'mask-repeat', 'mask-origin', 'mask-clip', 'mask-composite'],
|
|
77
77
|
};
|
|
78
|
+
export const LONG_TO_SHORT = {};
|
|
79
|
+
Object.entries(SHORTHAND_PROPERTIES).forEach(([shorthand, longhands]) => {
|
|
80
|
+
longhands.forEach(longhand => {
|
|
81
|
+
if (!LONG_TO_SHORT[longhand]) {
|
|
82
|
+
LONG_TO_SHORT[longhand] = [];
|
|
83
|
+
}
|
|
84
|
+
LONG_TO_SHORT[longhand].push(shorthand);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { applyCssValue, camelToKebabCase } from './helper.js';
|
|
2
|
+
import { SHORTHAND_PROPERTIES } from './shorthand.js';
|
|
3
|
+
const ALL_LONGHANDS = new Set(Object.values(SHORTHAND_PROPERTIES).flat());
|
|
2
4
|
function transpileAtomic(property, value, hash) {
|
|
3
5
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
4
6
|
const CSSProp = camelToKebabCase(property);
|
|
5
7
|
const applyValue = applyCssValue(value, CSSProp);
|
|
6
|
-
|
|
8
|
+
let selector = `.${hash}`;
|
|
9
|
+
if (ALL_LONGHANDS.has(CSSProp)) {
|
|
10
|
+
selector += ':not(#\\#)';
|
|
11
|
+
}
|
|
12
|
+
const atomicRule = `${selector} { ${CSSProp}: ${applyValue}; }`;
|
|
7
13
|
if (property.startsWith('@media') || property.startsWith('@container')) {
|
|
8
14
|
return `${property} { ${atomicRule} }`;
|
|
9
15
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,6 +8,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
10
|
export { splitAtomicAndNested, processAtomicProps } from './utils/processor-atomic.js';
|
|
11
|
+
export { SHORTHAND_PROPERTIES, LONG_TO_SHORT } from './utils/shorthand.js';
|
|
11
12
|
export { build } from './utils/build.js';
|
|
12
13
|
export { camelToKebabCase, applyCssValue } from './utils/helper.js';
|
|
13
14
|
export { injectClientCSS, injectClientQuery } from './utils/inject-client-css.js';
|
|
@@ -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, atomicHashes: Set<string>, allStyleSheets: Set<string>,
|
|
3
|
+
declare function processAtomicProps(flatProps: CSSProperties, atomicHashes: Set<string>, allStyleSheets: Set<string>, parentAtRule?: string): void;
|
|
4
4
|
export { splitAtomicAndNested, processAtomicProps };
|