zss-engine 0.2.14 → 0.2.16
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/index.js +9 -21
- package/dist/index.mjs +3 -4
- package/dist/utils/helper.js +1 -2
- package/dist/utils/helper.mjs +0 -1
- package/dist/utils/transpiler.js +12 -12
- package/dist/utils/transpiler.mjs +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +7 -4
- package/types/types/common/css-properties.d.ts +2 -2
- package/types/types/main/vars.d.ts +2 -2
- package/types/utils/helper.d.ts +0 -1
- package/types/utils/transpiler.d.ts +1 -1
- package/dist/types/index.js +0 -21
- package/dist/types/index.mjs +0 -5
- package/types/types/index.d.ts +0 -5
package/dist/index.js
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
exports.getServerCSS = exports.injectServerCSS = exports.injectClientGlobalCSS = exports.injectClientCSS = exports.build = exports.transpiler = exports.genBase36Hash = exports.isDevAndTest = exports.isDevelopment = exports.isServer = void 0;
|
|
4
|
+
var helper_1 = require("./utils/helper");
|
|
5
|
+
Object.defineProperty(exports, "isServer", { enumerable: true, get: function () { return helper_1.isServer; } });
|
|
6
|
+
Object.defineProperty(exports, "isDevelopment", { enumerable: true, get: function () { return helper_1.isDevelopment; } });
|
|
7
|
+
Object.defineProperty(exports, "isDevAndTest", { enumerable: true, get: function () { return helper_1.isDevAndTest; } });
|
|
20
8
|
var hash_1 = require("./utils/hash");
|
|
21
9
|
Object.defineProperty(exports, "genBase36Hash", { enumerable: true, get: function () { return hash_1.genBase36Hash; } });
|
|
10
|
+
var transpiler_1 = require("./utils/transpiler");
|
|
11
|
+
Object.defineProperty(exports, "transpiler", { enumerable: true, get: function () { return transpiler_1.transpiler; } });
|
|
12
|
+
var build_1 = require("./utils/build");
|
|
13
|
+
Object.defineProperty(exports, "build", { enumerable: true, get: function () { return build_1.build; } });
|
|
22
14
|
var inject_client_css_1 = require("./utils/inject-client-css");
|
|
23
15
|
Object.defineProperty(exports, "injectClientCSS", { enumerable: true, get: function () { return inject_client_css_1.injectClientCSS; } });
|
|
24
16
|
var inject_client_global_css_1 = require("./utils/inject-client-global-css");
|
|
@@ -26,7 +18,3 @@ Object.defineProperty(exports, "injectClientGlobalCSS", { enumerable: true, get:
|
|
|
26
18
|
var inject_server_css_1 = require("./utils/inject-server-css");
|
|
27
19
|
Object.defineProperty(exports, "injectServerCSS", { enumerable: true, get: function () { return inject_server_css_1.injectServerCSS; } });
|
|
28
20
|
Object.defineProperty(exports, "getServerCSS", { enumerable: true, get: function () { return inject_server_css_1.getServerCSS; } });
|
|
29
|
-
var build_1 = require("./utils/build");
|
|
30
|
-
Object.defineProperty(exports, "build", { enumerable: true, get: function () { return build_1.build; } });
|
|
31
|
-
var transpiler_1 = require("./utils/transpiler");
|
|
32
|
-
Object.defineProperty(exports, "transpiler", { enumerable: true, get: function () { return transpiler_1.transpiler; } });
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './utils/helper';
|
|
1
|
+
export { isServer, isDevelopment, isDevAndTest } from './utils/helper';
|
|
3
2
|
export { genBase36Hash } from './utils/hash';
|
|
3
|
+
export { transpiler } from './utils/transpiler';
|
|
4
|
+
export { build } from './utils/build';
|
|
4
5
|
export { injectClientCSS } from './utils/inject-client-css';
|
|
5
6
|
export { injectClientGlobalCSS } from './utils/inject-client-global-css';
|
|
6
7
|
export { injectServerCSS, getServerCSS } from './utils/inject-server-css';
|
|
7
|
-
export { build } from './utils/build';
|
|
8
|
-
export { transpiler } from './utils/transpiler';
|
package/dist/utils/helper.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.camelToKebabCase = exports.applyCssValue = exports.
|
|
3
|
+
exports.camelToKebabCase = exports.applyCssValue = exports.isDevAndTest = exports.isDevelopment = exports.isServer = void 0;
|
|
4
4
|
const isWindowDefined = typeof window !== 'undefined';
|
|
5
5
|
const isDocumentDefined = typeof document !== 'undefined';
|
|
6
6
|
exports.isServer = !isWindowDefined || !isDocumentDefined;
|
|
7
7
|
exports.isDevelopment = process.env.NODE_ENV === 'development';
|
|
8
8
|
exports.isDevAndTest = process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test';
|
|
9
|
-
exports.isDevServer = exports.isDevelopment && exports.isServer;
|
|
10
9
|
const exception = ['line-height', 'font-weight', 'opacity', 'scale', 'z-index', 'column-count', 'order', 'orphans', 'widows'];
|
|
11
10
|
const applyCssValue = (value, cssProp) => {
|
|
12
11
|
if (typeof value === 'number') {
|
package/dist/utils/helper.mjs
CHANGED
|
@@ -3,7 +3,6 @@ const isDocumentDefined = typeof document !== 'undefined';
|
|
|
3
3
|
export const isServer = !isWindowDefined || !isDocumentDefined;
|
|
4
4
|
export const isDevelopment = process.env.NODE_ENV === 'development';
|
|
5
5
|
export const isDevAndTest = process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test';
|
|
6
|
-
export const isDevServer = isDevelopment && isServer;
|
|
7
6
|
const exception = ['line-height', 'font-weight', 'opacity', 'scale', 'z-index', 'column-count', 'order', 'orphans', 'widows'];
|
|
8
7
|
export const applyCssValue = (value, cssProp) => {
|
|
9
8
|
if (typeof value === 'number') {
|
package/dist/utils/transpiler.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transpiler = transpiler;
|
|
4
|
-
const
|
|
4
|
+
const helper_1 = require("./helper");
|
|
5
5
|
const createKeyframes = (property, content) => {
|
|
6
6
|
let keyframesRules = `${property} {\n`;
|
|
7
7
|
for (const key in content) {
|
|
@@ -10,10 +10,10 @@ const createKeyframes = (property, content) => {
|
|
|
10
10
|
keyframesRules += ` ${key} {\n`;
|
|
11
11
|
for (const prop in keyframeValue) {
|
|
12
12
|
if (Object.prototype.hasOwnProperty.call(keyframeValue, prop)) {
|
|
13
|
-
const CSSProp = (0,
|
|
13
|
+
const CSSProp = (0, helper_1.camelToKebabCase)(prop);
|
|
14
14
|
const value = keyframeValue[prop];
|
|
15
15
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
16
|
-
const applyValue = (0,
|
|
16
|
+
const applyValue = (0, helper_1.applyCssValue)(value, CSSProp);
|
|
17
17
|
keyframesRules += ` ${CSSProp}: ${applyValue};\n`;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -34,7 +34,7 @@ function transpiler(object, base36Hash, core) {
|
|
|
34
34
|
if (typeof property !== 'string')
|
|
35
35
|
return '';
|
|
36
36
|
const value = rulesValue[property];
|
|
37
|
-
const cssProp = (0,
|
|
37
|
+
const cssProp = (0, helper_1.camelToKebabCase)(property);
|
|
38
38
|
return `${indent}${cssProp}: ${value};\n`;
|
|
39
39
|
};
|
|
40
40
|
const stringConverter = (className, properties, indentLevel = 0) => {
|
|
@@ -46,15 +46,15 @@ function transpiler(object, base36Hash, core) {
|
|
|
46
46
|
if (Object.prototype.hasOwnProperty.call(properties, property)) {
|
|
47
47
|
const value = properties[property];
|
|
48
48
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
49
|
-
let CSSProp = (0,
|
|
49
|
+
let CSSProp = (0, helper_1.camelToKebabCase)(property);
|
|
50
50
|
if (property.startsWith('ms')) {
|
|
51
51
|
CSSProp = `-${CSSProp}`;
|
|
52
52
|
}
|
|
53
|
-
const applyValue = (0,
|
|
53
|
+
const applyValue = (0, helper_1.applyCssValue)(value, CSSProp);
|
|
54
54
|
cssRule += ` ${CSSProp}: ${applyValue};\n`;
|
|
55
55
|
}
|
|
56
56
|
else if (!property.startsWith('@')) {
|
|
57
|
-
const kebabPseudoSelector = (0,
|
|
57
|
+
const kebabPseudoSelector = (0, helper_1.camelToKebabCase)(property.replace('&', ''));
|
|
58
58
|
const styles = stringConverter(className + kebabPseudoSelector, value, indentLevel);
|
|
59
59
|
Object.assign(classSelector, styles);
|
|
60
60
|
}
|
|
@@ -68,13 +68,13 @@ function transpiler(object, base36Hash, core) {
|
|
|
68
68
|
const isColon = mediaProp.startsWith(':');
|
|
69
69
|
const isAnd = mediaProp.startsWith('&');
|
|
70
70
|
if (isColon || isAnd) {
|
|
71
|
-
const kebabMediaProp = (0,
|
|
71
|
+
const kebabMediaProp = (0, helper_1.camelToKebabCase)(mediaProp.replace('&', ''));
|
|
72
72
|
let pseudoClassRule = '';
|
|
73
73
|
if (typeof mediaValue === 'object' && mediaValue !== null) {
|
|
74
74
|
for (const pseudoProp in mediaValue) {
|
|
75
75
|
if (Object.prototype.hasOwnProperty.call(mediaValue, pseudoProp)) {
|
|
76
|
-
const CSSProp = (0,
|
|
77
|
-
const applyValue = (0,
|
|
76
|
+
const CSSProp = (0, helper_1.camelToKebabCase)(pseudoProp);
|
|
77
|
+
const applyValue = (0, helper_1.applyCssValue)(mediaValue[pseudoProp], CSSProp);
|
|
78
78
|
pseudoClassRule += rules(innerIndent + ' ', { [pseudoProp]: applyValue }, pseudoProp);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -82,8 +82,8 @@ function transpiler(object, base36Hash, core) {
|
|
|
82
82
|
nestedRules += `${innerIndent}${className}${kebabMediaProp} {\n${pseudoClassRule}${innerIndent}}\n`;
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
|
-
const CSSProp = (0,
|
|
86
|
-
const applyValue = (0,
|
|
85
|
+
const CSSProp = (0, helper_1.camelToKebabCase)(mediaProp);
|
|
86
|
+
const applyValue = (0, helper_1.applyCssValue)(mediaValue, CSSProp);
|
|
87
87
|
regularRules += rules(innerIndent + ' ', { [mediaProp]: applyValue }, mediaProp);
|
|
88
88
|
}
|
|
89
89
|
}
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type { CustomProperties, MediaQuery } from './types/common/css-properties';
|
|
2
|
+
export type { CreateStyle, ClassesStyle, ReturnType } from './types/main/create';
|
|
3
|
+
export type { KeyframesDefinition, CustomHTMLType } from './types/main/global';
|
|
4
|
+
export type { VarsDefinition, VarsTransformed, CSSVariableProperty } from './types/main/vars';
|
|
5
|
+
export { isServer, isDevelopment, isDevAndTest } from './utils/helper';
|
|
3
6
|
export { genBase36Hash } from './utils/hash';
|
|
7
|
+
export { transpiler } from './utils/transpiler';
|
|
8
|
+
export { build } from './utils/build';
|
|
4
9
|
export { injectClientCSS } from './utils/inject-client-css';
|
|
5
10
|
export { injectClientGlobalCSS } from './utils/inject-client-global-css';
|
|
6
11
|
export { injectServerCSS, getServerCSS } from './utils/inject-server-css';
|
|
7
|
-
export { build } from './utils/build';
|
|
8
|
-
export { transpiler } from './utils/transpiler';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CSSVariableValue } from '../main/vars';
|
|
1
|
+
import type { CSSVariableValue, CSSVariableProperty } from '../main/vars';
|
|
2
2
|
import type { Properties, Property } from 'csstype';
|
|
3
3
|
type ColorValue = Exclude<Property.Color, '-moz-initial'> | (string & {});
|
|
4
4
|
type CSSColorProperty = Exclude<ColorValue, SystemColorKeyword>;
|
|
@@ -42,5 +42,5 @@ export type MediaQuery = `@media ${string}`;
|
|
|
42
42
|
type MediaQueryType = {
|
|
43
43
|
[K in MediaQuery]: CommonProperties | ColonType | AndStringType;
|
|
44
44
|
};
|
|
45
|
-
export type CustomProperties = CommonProperties | ColonType | AndStringType | MediaQueryType;
|
|
45
|
+
export type CustomProperties = CommonProperties | ColonType | CSSVariableProperty | AndStringType | MediaQueryType;
|
|
46
46
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export type VarsDefinition = Record<string, string | number | Record<string, string | number>>;
|
|
2
2
|
type CSSVariableKey = `--${string}`;
|
|
3
3
|
export type CSSVariableValue = `var(${CSSVariableKey})`;
|
|
4
|
-
type
|
|
4
|
+
export type CSSVariableProperty = {
|
|
5
5
|
[key: CSSVariableKey]: string | number;
|
|
6
6
|
};
|
|
7
7
|
export type VarsTransformed = {
|
|
8
|
-
[key: string]:
|
|
8
|
+
[key: string]: CSSVariableProperty;
|
|
9
9
|
};
|
|
10
10
|
export {};
|
package/types/utils/helper.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export declare const isServer: boolean;
|
|
2
2
|
export declare const isDevelopment: boolean;
|
|
3
3
|
export declare const isDevAndTest: boolean;
|
|
4
|
-
export declare const isDevServer: boolean;
|
|
5
4
|
export declare const applyCssValue: (value: string | number, cssProp: string) => string;
|
|
6
5
|
export declare const camelToKebabCase: (property: string) => string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClassesStyle, CustomHTMLType, VarsDefinition } from '
|
|
1
|
+
import type { ClassesStyle, CustomHTMLType, VarsDefinition } from '../index';
|
|
2
2
|
export declare function transpiler(object: ClassesStyle | CustomHTMLType | VarsDefinition, base36Hash?: string, core?: string): {
|
|
3
3
|
styleSheet: string;
|
|
4
4
|
};
|
package/dist/types/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./common/css-properties"), exports);
|
|
18
|
-
__exportStar(require("./common/css-property"), exports);
|
|
19
|
-
__exportStar(require("./main/create"), exports);
|
|
20
|
-
__exportStar(require("./main/global"), exports);
|
|
21
|
-
__exportStar(require("./main/vars"), exports);
|
package/dist/types/index.mjs
DELETED