zss-engine 0.2.10 → 0.2.12
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 +30 -236
- package/dist/index.mjs +8 -225
- package/dist/types/common/css-properties.js +2 -0
- package/dist/types/common/css-properties.mjs +1 -0
- package/dist/types/common/css-property.js +2 -0
- package/dist/types/common/css-property.mjs +1 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.mjs +5 -0
- package/dist/types/main/create.js +2 -0
- package/dist/types/main/create.mjs +1 -0
- package/dist/types/main/global.js +2 -0
- package/dist/types/main/global.mjs +1 -0
- package/dist/types/main/vars.js +2 -0
- package/dist/types/main/vars.mjs +1 -0
- package/dist/utils/build.js +27 -0
- package/dist/utils/build.mjs +23 -0
- package/dist/utils/hash.js +34 -0
- package/dist/utils/hash.mjs +31 -0
- package/dist/utils/helper.js +21 -0
- package/dist/utils/helper.mjs +16 -0
- package/dist/utils/inject-client-css.js +51 -0
- package/dist/utils/inject-client-css.mjs +47 -0
- package/dist/utils/inject-client-global-css.js +18 -0
- package/dist/utils/inject-client-global-css.mjs +15 -0
- package/dist/utils/inject-server-css.js +11 -0
- package/dist/utils/inject-server-css.mjs +7 -0
- package/dist/utils/transpiler.js +125 -0
- package/dist/utils/transpiler.mjs +122 -0
- package/package.json +6 -4
- package/types/index.d.ts +8 -130
- package/types/types/common/css-properties.d.ts +46 -0
- package/types/types/common/css-property.d.ts +5 -0
- package/types/types/index.d.ts +5 -0
- package/types/types/main/create.d.ts +10 -0
- package/types/types/main/global.d.ts +37 -0
- package/types/types/main/vars.d.ts +10 -0
- package/types/utils/build.d.ts +1 -0
- package/types/utils/hash.d.ts +2 -0
- package/types/utils/helper.d.ts +6 -0
- package/types/utils/inject-client-css.d.ts +2 -0
- package/types/utils/inject-client-global-css.d.ts +1 -0
- package/types/utils/inject-server-css.d.ts +2 -0
- package/types/utils/transpiler.d.ts +4 -0
- package/dist/build-12x-B3dvmUcg.mjs +0 -52
- package/dist/build-12x-C7vH1H69.js +0 -54
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { CSSVariableValue } from '../main/vars';
|
|
2
|
+
import type { Properties, Property } from 'csstype';
|
|
3
|
+
type ColorValue = Exclude<Property.Color, '-moz-initial'> | (string & {});
|
|
4
|
+
type CSSColorProperty = Exclude<ColorValue, SystemColorKeyword>;
|
|
5
|
+
type SystemColorKeyword = 'ActiveBorder' | 'ActiveCaption' | 'AppWorkspace' | 'Background' | 'ButtonFace' | 'ButtonHighlight' | 'ButtonShadow' | 'ButtonText' | 'CaptionText' | 'GrayText' | 'Highlight' | 'HighlightText' | 'InactiveBorder' | 'InactiveCaption' | 'InactiveCaptionText' | 'InfoBackground' | 'InfoText' | 'Menu' | 'MenuText' | 'Scrollbar' | 'ThreeDDarkShadow' | 'ThreeDFace' | 'ThreeDHighlight' | 'ThreeDLightShadow' | 'ThreeDShadow' | 'Window' | 'WindowFrame' | 'WindowText';
|
|
6
|
+
type ExcludeMozInitial<T> = Exclude<T, '-moz-initial'>;
|
|
7
|
+
type CSSTypeProperties = Properties<number | (string & {})>;
|
|
8
|
+
type CSSProperties = {
|
|
9
|
+
[K in keyof CSSTypeProperties]: ExcludeMozInitial<CSSTypeProperties[K]>;
|
|
10
|
+
};
|
|
11
|
+
type BaseCSSProperties = {
|
|
12
|
+
[K in keyof CSSProperties]: CSSProperties[K] | CSSVariableValue;
|
|
13
|
+
};
|
|
14
|
+
interface CommonProperties extends BaseCSSProperties {
|
|
15
|
+
accentColor?: CSSColorProperty;
|
|
16
|
+
color?: CSSColorProperty;
|
|
17
|
+
borderLeftColor?: CSSColorProperty;
|
|
18
|
+
borderRightColor?: CSSColorProperty;
|
|
19
|
+
borderTopColor?: CSSColorProperty;
|
|
20
|
+
borderBottomColor?: CSSColorProperty;
|
|
21
|
+
borderBlockColor?: CSSColorProperty;
|
|
22
|
+
borderBlockStartColor?: CSSColorProperty;
|
|
23
|
+
borderBlockEndColor?: CSSColorProperty;
|
|
24
|
+
borderInlineColor?: CSSColorProperty;
|
|
25
|
+
borderInlineStartColor?: CSSColorProperty;
|
|
26
|
+
borderInlineEndColor?: CSSColorProperty;
|
|
27
|
+
backgroundColor?: CSSColorProperty;
|
|
28
|
+
outlineColor?: CSSColorProperty;
|
|
29
|
+
textDecorationColor?: CSSColorProperty;
|
|
30
|
+
caretColor?: CSSColorProperty;
|
|
31
|
+
columnRuleColor?: CSSColorProperty;
|
|
32
|
+
}
|
|
33
|
+
type AndString = `&${string}`;
|
|
34
|
+
type AndStringType = {
|
|
35
|
+
[key in AndString]: CommonProperties;
|
|
36
|
+
};
|
|
37
|
+
type Colon = `:${string}`;
|
|
38
|
+
type ColonType = {
|
|
39
|
+
[key in Colon]: CommonProperties;
|
|
40
|
+
};
|
|
41
|
+
export type MediaQuery = `@media ${string}`;
|
|
42
|
+
type MediaQueryType = {
|
|
43
|
+
[K in MediaQuery]: CommonProperties | ColonType | AndStringType;
|
|
44
|
+
};
|
|
45
|
+
export type CustomProperties = CommonProperties | ColonType | AndStringType | MediaQueryType;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CustomProperties } from '../common/css-properties';
|
|
2
|
+
export type CreateStyle<T> = {
|
|
3
|
+
readonly [K in keyof T]: T[K] extends CustomProperties ? CustomProperties : T[K];
|
|
4
|
+
};
|
|
5
|
+
export type ClassesStyle = {
|
|
6
|
+
[key: string]: CustomProperties;
|
|
7
|
+
};
|
|
8
|
+
export type ReturnType<T> = {
|
|
9
|
+
[key in keyof T]: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CustomProperties, MediaQuery } from '../common/css-properties';
|
|
2
|
+
type JSXType = keyof HTMLElementTagNameMap | '*' | ':root';
|
|
3
|
+
type HTMLType = {
|
|
4
|
+
[K in JSXType]: CustomProperties;
|
|
5
|
+
};
|
|
6
|
+
type ClassName = `.${string}`;
|
|
7
|
+
type ClassNameType = {
|
|
8
|
+
[K in ClassName]: CustomProperties;
|
|
9
|
+
};
|
|
10
|
+
type Attribute = `${string}[${string}]${string}`;
|
|
11
|
+
type AttributeType = {
|
|
12
|
+
[K in Attribute]: CustomProperties;
|
|
13
|
+
};
|
|
14
|
+
type Consecutive = `${JSXType} ${string}`;
|
|
15
|
+
type ConsecutiveType = {
|
|
16
|
+
[K in Consecutive]: CustomProperties;
|
|
17
|
+
};
|
|
18
|
+
type PseudoClass = `${JSXType}:${string}`;
|
|
19
|
+
type PseudoClassType = {
|
|
20
|
+
[K in PseudoClass]: CustomProperties;
|
|
21
|
+
};
|
|
22
|
+
type PseudoElement = `::${string}`;
|
|
23
|
+
type PseudoElementType = {
|
|
24
|
+
[K in PseudoElement]: CustomProperties;
|
|
25
|
+
};
|
|
26
|
+
type KeyframeSelector = 'from' | 'to' | `${number}%`;
|
|
27
|
+
export type KeyframesDefinition = {
|
|
28
|
+
[K in KeyframeSelector]?: CustomProperties;
|
|
29
|
+
};
|
|
30
|
+
type KeyframesType = {
|
|
31
|
+
[K in `@keyframes ${string}`]: KeyframesDefinition;
|
|
32
|
+
};
|
|
33
|
+
type MediaQueryHTMLType = {
|
|
34
|
+
[K in MediaQuery]: CustomHTMLType;
|
|
35
|
+
};
|
|
36
|
+
export type CustomHTMLType = HTMLType | ClassNameType | AttributeType | ConsecutiveType | PseudoClassType | PseudoElementType | KeyframesType | MediaQueryHTMLType;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type VarsDefinition = Record<string, string | number | Record<string, string | number>>;
|
|
2
|
+
type CSSVariableKey = `--${string}`;
|
|
3
|
+
export type CSSVariableValue = `var(${CSSVariableKey})`;
|
|
4
|
+
type CSSVariableProperties = {
|
|
5
|
+
[key: CSSVariableKey]: string | number;
|
|
6
|
+
};
|
|
7
|
+
export type VarsTransformed = {
|
|
8
|
+
[key: string]: CSSVariableProperties;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const build: (styleSheet: string, filePath: string, global?: string) => Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const isServer: boolean;
|
|
2
|
+
export declare const isDevelopment: boolean;
|
|
3
|
+
export declare const isDevAndTest: boolean;
|
|
4
|
+
export declare const isDevServer: boolean;
|
|
5
|
+
export declare const applyCssValue: (value: string | number, cssProp: string) => string;
|
|
6
|
+
export declare const camelToKebabCase: (property: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function injectClientGlobalCSS(sheet: string, scoped: string): void;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
'use server';
|
|
2
|
-
import __node_cjsModule from 'node:module';
|
|
3
|
-
|
|
4
|
-
const isWindowDefined = typeof window !== 'undefined';
|
|
5
|
-
const isDocumentDefined = typeof document !== 'undefined';
|
|
6
|
-
const isServer = !isWindowDefined || !isDocumentDefined;
|
|
7
|
-
const isDevelopment = process.env.NODE_ENV === 'development';
|
|
8
|
-
const isDevAndTest = process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test';
|
|
9
|
-
const isDevServer = isDevelopment && isServer;
|
|
10
|
-
const exception = [
|
|
11
|
-
'line-height',
|
|
12
|
-
'font-weight',
|
|
13
|
-
'opacity',
|
|
14
|
-
'scale',
|
|
15
|
-
'z-index',
|
|
16
|
-
'column-count',
|
|
17
|
-
'order',
|
|
18
|
-
'orphans',
|
|
19
|
-
'widows'
|
|
20
|
-
];
|
|
21
|
-
const applyCssValue = (value, cssProp)=>{
|
|
22
|
-
if (typeof value === 'number') {
|
|
23
|
-
return exception.includes(cssProp) ? value.toString() : value + 'px';
|
|
24
|
-
}
|
|
25
|
-
return value;
|
|
26
|
-
};
|
|
27
|
-
const camelToKebabCase = (property)=>{
|
|
28
|
-
return property.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const require = __node_cjsModule.createRequire(import.meta.url);
|
|
32
|
-
|
|
33
|
-
const build = async (styleSheet, filePath, global)=>{
|
|
34
|
-
if (!isServer) return;
|
|
35
|
-
const fs = require('fs');
|
|
36
|
-
const { styleText } = require('util');
|
|
37
|
-
const message = global === '--global' ? styleText('underline', `✅Generated global CSS\n\n`) : styleText('underline', `✅Generated create CSS\n\n`);
|
|
38
|
-
try {
|
|
39
|
-
if (fs.existsSync(filePath)) {
|
|
40
|
-
const cssData = fs.readFileSync(filePath, 'utf-8');
|
|
41
|
-
if (!cssData.includes(styleSheet)) {
|
|
42
|
-
fs.appendFileSync(filePath, styleSheet, 'utf-8');
|
|
43
|
-
if (process.argv.includes('--log')) console.log(message + styleSheet);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return;
|
|
47
|
-
} catch (error) {
|
|
48
|
-
console.error('Error writing to file:', error);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export { applyCssValue as a, build as b, camelToKebabCase as c, isDevelopment as d, isDevAndTest as e, isDevServer as f, isServer as i };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
'use server';
|
|
2
|
-
const isWindowDefined = typeof window !== 'undefined';
|
|
3
|
-
const isDocumentDefined = typeof document !== 'undefined';
|
|
4
|
-
const isServer = !isWindowDefined || !isDocumentDefined;
|
|
5
|
-
const isDevelopment = process.env.NODE_ENV === 'development';
|
|
6
|
-
const isDevAndTest = process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test';
|
|
7
|
-
const isDevServer = isDevelopment && isServer;
|
|
8
|
-
const exception = [
|
|
9
|
-
'line-height',
|
|
10
|
-
'font-weight',
|
|
11
|
-
'opacity',
|
|
12
|
-
'scale',
|
|
13
|
-
'z-index',
|
|
14
|
-
'column-count',
|
|
15
|
-
'order',
|
|
16
|
-
'orphans',
|
|
17
|
-
'widows'
|
|
18
|
-
];
|
|
19
|
-
const applyCssValue = (value, cssProp)=>{
|
|
20
|
-
if (typeof value === 'number') {
|
|
21
|
-
return exception.includes(cssProp) ? value.toString() : value + 'px';
|
|
22
|
-
}
|
|
23
|
-
return value;
|
|
24
|
-
};
|
|
25
|
-
const camelToKebabCase = (property)=>{
|
|
26
|
-
return property.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const build = async (styleSheet, filePath, global)=>{
|
|
30
|
-
if (!isServer) return;
|
|
31
|
-
const fs = require('fs');
|
|
32
|
-
const { styleText } = require('util');
|
|
33
|
-
const message = global === '--global' ? styleText('underline', `✅Generated global CSS\n\n`) : styleText('underline', `✅Generated create CSS\n\n`);
|
|
34
|
-
try {
|
|
35
|
-
if (fs.existsSync(filePath)) {
|
|
36
|
-
const cssData = fs.readFileSync(filePath, 'utf-8');
|
|
37
|
-
if (!cssData.includes(styleSheet)) {
|
|
38
|
-
fs.appendFileSync(filePath, styleSheet, 'utf-8');
|
|
39
|
-
if (process.argv.includes('--log')) console.log(message + styleSheet);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return;
|
|
43
|
-
} catch (error) {
|
|
44
|
-
console.error('Error writing to file:', error);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
exports.applyCssValue = applyCssValue;
|
|
49
|
-
exports.build = build;
|
|
50
|
-
exports.camelToKebabCase = camelToKebabCase;
|
|
51
|
-
exports.isDevAndTest = isDevAndTest;
|
|
52
|
-
exports.isDevServer = isDevServer;
|
|
53
|
-
exports.isDevelopment = isDevelopment;
|
|
54
|
-
exports.isServer = isServer;
|