zss-engine 2.2.6 → 2.2.8

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.
Files changed (33) hide show
  1. package/dist/cjs/index.js +5 -9
  2. package/dist/cjs/utils/helper.js +1 -6
  3. package/dist/cjs/utils/override-longhand.js +3 -2
  4. package/dist/cjs/utils/processor-atomic.js +10 -8
  5. package/dist/esm/index.js +0 -1
  6. package/dist/esm/utils/helper.js +0 -5
  7. package/dist/esm/utils/override-longhand.js +3 -2
  8. package/dist/esm/utils/processor-atomic.js +10 -8
  9. package/dist/types/index.d.ts +1 -5
  10. package/dist/types/types/css-properties.d.ts +23 -0
  11. package/dist/types/utils/helper.d.ts +0 -3
  12. package/dist/types/utils/override-longhand.d.ts +2 -2
  13. package/dist/types/utils/processor-atomic.d.ts +2 -2
  14. package/dist/types/utils/transpile.d.ts +2 -2
  15. package/package.json +7 -7
  16. package/dist/cjs/types/main/create.js +0 -2
  17. package/dist/cjs/types/main/global.js +0 -2
  18. package/dist/cjs/types/main/variableTypes.js +0 -2
  19. package/dist/cjs/types/main/viewTransition.js +0 -2
  20. package/dist/esm/types/main/create.js +0 -1
  21. package/dist/esm/types/main/global.js +0 -1
  22. package/dist/esm/types/main/variableTypes.js +0 -1
  23. package/dist/esm/types/main/viewTransition.js +0 -1
  24. package/dist/types/types/common/css-properties.d.ts +0 -46
  25. package/dist/types/types/main/create.d.ts +0 -4
  26. package/dist/types/types/main/global.d.ts +0 -37
  27. package/dist/types/types/main/variableTypes.d.ts +0 -7
  28. package/dist/types/types/main/viewTransition.d.ts +0 -7
  29. /package/dist/cjs/types/{common/css-properties.js → css-properties.js} +0 -0
  30. /package/dist/cjs/types/{common/css-property.js → css-property.js} +0 -0
  31. /package/dist/esm/types/{common/css-properties.js → css-properties.js} +0 -0
  32. /package/dist/esm/types/{common/css-property.js → css-property.js} +0 -0
  33. /package/dist/types/types/{common/css-property.d.ts → css-property.d.ts} +0 -0
package/dist/cjs/index.js CHANGED
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exceptionCamelCase = exports.applyCssValue = exports.camelToKebabCase = exports.overrideLonghand = exports.processAtomicProps = exports.splitAtomicAndNested = exports.transpileAtomic = exports.transpile = exports.genBase36Hash = exports.isTestingDevelopment = exports.isDevelopment = exports.isServer = void 0;
4
- var helper_js_1 = require("./utils/helper.js");
5
- Object.defineProperty(exports, "isServer", { enumerable: true, get: function () { return helper_js_1.isServer; } });
6
- Object.defineProperty(exports, "isDevelopment", { enumerable: true, get: function () { return helper_js_1.isDevelopment; } });
7
- Object.defineProperty(exports, "isTestingDevelopment", { enumerable: true, get: function () { return helper_js_1.isTestingDevelopment; } });
3
+ exports.exceptionCamelCase = exports.applyCssValue = exports.camelToKebabCase = exports.overrideLonghand = exports.processAtomicProps = exports.splitAtomicAndNested = exports.transpileAtomic = exports.transpile = exports.genBase36Hash = void 0;
8
4
  var hash_js_1 = require("./utils/hash.js");
9
5
  Object.defineProperty(exports, "genBase36Hash", { enumerable: true, get: function () { return hash_js_1.genBase36Hash; } });
10
6
  var transpile_js_1 = require("./utils/transpile.js");
@@ -16,7 +12,7 @@ Object.defineProperty(exports, "splitAtomicAndNested", { enumerable: true, get:
16
12
  Object.defineProperty(exports, "processAtomicProps", { enumerable: true, get: function () { return processor_atomic_js_1.processAtomicProps; } });
17
13
  var override_longhand_js_1 = require("./utils/override-longhand.js");
18
14
  Object.defineProperty(exports, "overrideLonghand", { enumerable: true, get: function () { return override_longhand_js_1.overrideLonghand; } });
19
- var helper_js_2 = require("./utils/helper.js");
20
- Object.defineProperty(exports, "camelToKebabCase", { enumerable: true, get: function () { return helper_js_2.camelToKebabCase; } });
21
- Object.defineProperty(exports, "applyCssValue", { enumerable: true, get: function () { return helper_js_2.applyCssValue; } });
22
- Object.defineProperty(exports, "exceptionCamelCase", { enumerable: true, get: function () { return helper_js_2.exceptionCamelCase; } });
15
+ var helper_js_1 = require("./utils/helper.js");
16
+ Object.defineProperty(exports, "camelToKebabCase", { enumerable: true, get: function () { return helper_js_1.camelToKebabCase; } });
17
+ Object.defineProperty(exports, "applyCssValue", { enumerable: true, get: function () { return helper_js_1.applyCssValue; } });
18
+ Object.defineProperty(exports, "exceptionCamelCase", { enumerable: true, get: function () { return helper_js_1.exceptionCamelCase; } });
@@ -1,12 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.camelToKebabCase = exports.applyCssValue = exports.exceptionCamelCase = exports.isTestingDevelopment = exports.isDevelopment = exports.isServer = void 0;
3
+ exports.camelToKebabCase = exports.applyCssValue = exports.exceptionCamelCase = void 0;
4
4
  const hex_to_color_name_js_1 = require("./hex-to-color-name.js");
5
- const isWindowDefined = typeof window !== 'undefined';
6
- const isDocumentDefined = typeof document !== 'undefined';
7
- exports.isServer = !isWindowDefined || !isDocumentDefined;
8
- exports.isDevelopment = process.env.NODE_ENV === 'development';
9
- exports.isTestingDevelopment = process.env.NODE_ENV === 'test' || exports.isDevelopment;
10
5
  const exception = [
11
6
  'animation-iteration-count',
12
7
  'aspect-ratio',
@@ -32,15 +32,16 @@ const overrideLonghand = (style) => {
32
32
  }
33
33
  }
34
34
  const finalStyle = {};
35
+ const queryStyle = style;
35
36
  for (const prop of props) {
36
37
  if (propsToRemove.has(prop)) {
37
38
  continue;
38
39
  }
39
40
  if (prop.startsWith('@')) {
40
- finalStyle[prop] = (0, exports.overrideLonghand)(style[prop]);
41
+ finalStyle[prop] = (0, exports.overrideLonghand)(queryStyle[prop]);
41
42
  }
42
43
  else {
43
- finalStyle[prop] = style[prop];
44
+ finalStyle[prop] = queryStyle[prop];
44
45
  }
45
46
  }
46
47
  return finalStyle;
@@ -5,21 +5,23 @@ exports.processAtomicProps = processAtomicProps;
5
5
  const index_js_1 = require("../index.js");
6
6
  const shorthand_js_1 = require("./shorthand.js");
7
7
  function splitAtomicAndNested(obj, flat, nonFlat) {
8
+ const queryFlat = flat;
9
+ const queryNonFlat = nonFlat;
8
10
  Object.entries(obj).forEach(([property, value]) => {
9
11
  if (property.startsWith(':') || property.startsWith('[')) {
10
- nonFlat[property] = value;
12
+ queryNonFlat[property] = value;
11
13
  }
12
14
  else if (property.startsWith('@media') || property.startsWith('@container')) {
13
15
  const innerFlat = {};
14
16
  const innerNonFlat = {};
15
17
  splitAtomicAndNested(value, innerFlat, innerNonFlat);
16
18
  if (Object.keys(innerFlat).length)
17
- flat[property] = innerFlat;
19
+ queryFlat[property] = innerFlat;
18
20
  if (Object.keys(innerNonFlat).length)
19
- nonFlat[property] = innerNonFlat;
21
+ queryNonFlat[property] = innerNonFlat;
20
22
  }
21
23
  else {
22
- flat[property] = value;
24
+ queryFlat[property] = value;
23
25
  }
24
26
  });
25
27
  }
@@ -31,12 +33,12 @@ Object.entries(shorthand_js_1.SHORTHAND_PROPERTIES).forEach(([shorthand, longhan
31
33
  });
32
34
  function processAtomicProps(flatProps, atomicMap, parentAtRule) {
33
35
  const resultQueue = [];
34
- for (const [property, value] of Object.entries(flatProps)) {
35
- if (property.startsWith('@media') || property.startsWith('@container')) {
36
- processAtomicProps(value, atomicMap, property);
36
+ for (const [key, style] of Object.entries(flatProps)) {
37
+ if (key.startsWith('@media') || key.startsWith('@container')) {
38
+ processAtomicProps(style, atomicMap, key);
37
39
  continue;
38
40
  }
39
- resultQueue.push([property, value]);
41
+ resultQueue.push([key, style]);
40
42
  }
41
43
  for (const [property, value] of resultQueue) {
42
44
  const CSSProp = (0, index_js_1.camelToKebabCase)(property);
package/dist/esm/index.js CHANGED
@@ -1,4 +1,3 @@
1
- export { isServer, isDevelopment, isTestingDevelopment } from './utils/helper.js';
2
1
  export { genBase36Hash } from './utils/hash.js';
3
2
  export { transpile } from './utils/transpile.js';
4
3
  export { transpileAtomic } from './utils/transpile-atomic.js';
@@ -1,9 +1,4 @@
1
1
  import { hexToColorName } from './hex-to-color-name.js';
2
- const isWindowDefined = typeof window !== 'undefined';
3
- const isDocumentDefined = typeof document !== 'undefined';
4
- export const isServer = !isWindowDefined || !isDocumentDefined;
5
- export const isDevelopment = process.env.NODE_ENV === 'development';
6
- export const isTestingDevelopment = process.env.NODE_ENV === 'test' || isDevelopment;
7
2
  const exception = [
8
3
  'animation-iteration-count',
9
4
  'aspect-ratio',
@@ -29,15 +29,16 @@ export const overrideLonghand = (style) => {
29
29
  }
30
30
  }
31
31
  const finalStyle = {};
32
+ const queryStyle = style;
32
33
  for (const prop of props) {
33
34
  if (propsToRemove.has(prop)) {
34
35
  continue;
35
36
  }
36
37
  if (prop.startsWith('@')) {
37
- finalStyle[prop] = overrideLonghand(style[prop]);
38
+ finalStyle[prop] = overrideLonghand(queryStyle[prop]);
38
39
  }
39
40
  else {
40
- finalStyle[prop] = style[prop];
41
+ finalStyle[prop] = queryStyle[prop];
41
42
  }
42
43
  }
43
44
  return finalStyle;
@@ -1,21 +1,23 @@
1
1
  import { camelToKebabCase, genBase36Hash, applyCssValue, transpileAtomic } from '../index.js';
2
2
  import { SHORTHAND_PROPERTIES } from './shorthand.js';
3
3
  function splitAtomicAndNested(obj, flat, nonFlat) {
4
+ const queryFlat = flat;
5
+ const queryNonFlat = nonFlat;
4
6
  Object.entries(obj).forEach(([property, value]) => {
5
7
  if (property.startsWith(':') || property.startsWith('[')) {
6
- nonFlat[property] = value;
8
+ queryNonFlat[property] = value;
7
9
  }
8
10
  else if (property.startsWith('@media') || property.startsWith('@container')) {
9
11
  const innerFlat = {};
10
12
  const innerNonFlat = {};
11
13
  splitAtomicAndNested(value, innerFlat, innerNonFlat);
12
14
  if (Object.keys(innerFlat).length)
13
- flat[property] = innerFlat;
15
+ queryFlat[property] = innerFlat;
14
16
  if (Object.keys(innerNonFlat).length)
15
- nonFlat[property] = innerNonFlat;
17
+ queryNonFlat[property] = innerNonFlat;
16
18
  }
17
19
  else {
18
- flat[property] = value;
20
+ queryFlat[property] = value;
19
21
  }
20
22
  });
21
23
  }
@@ -27,12 +29,12 @@ Object.entries(SHORTHAND_PROPERTIES).forEach(([shorthand, longhands]) => {
27
29
  });
28
30
  function processAtomicProps(flatProps, atomicMap, parentAtRule) {
29
31
  const resultQueue = [];
30
- for (const [property, value] of Object.entries(flatProps)) {
31
- if (property.startsWith('@media') || property.startsWith('@container')) {
32
- processAtomicProps(value, atomicMap, property);
32
+ for (const [key, style] of Object.entries(flatProps)) {
33
+ if (key.startsWith('@media') || key.startsWith('@container')) {
34
+ processAtomicProps(style, atomicMap, key);
33
35
  continue;
34
36
  }
35
- resultQueue.push([property, value]);
37
+ resultQueue.push([key, style]);
36
38
  }
37
39
  for (const [property, value] of resultQueue) {
38
40
  const CSSProp = camelToKebabCase(property);
@@ -1,8 +1,4 @@
1
- export type { CSSProperties } from './types/common/css-properties';
2
- export type { CreateStyle } from './types/main/create';
3
- export type { CreateTheme } from './types/main/variableTypes';
4
- export type { ViewTransition } from './types/main/viewTransition';
5
- export { isServer, isDevelopment, isTestingDevelopment } from './utils/helper.js';
1
+ export type { CSSProperties } from './types/css-properties.js';
6
2
  export { genBase36Hash } from './utils/hash.js';
7
3
  export { transpile } from './utils/transpile.js';
8
4
  export { transpileAtomic } from './utils/transpile-atomic.js';
@@ -0,0 +1,23 @@
1
+ import type { Properties } from 'csstype';
2
+ type CSSVariableKey = `--${string}`;
3
+ type CSSVariableValue = `var(${CSSVariableKey})`;
4
+ type CSSVariableProperty = {
5
+ [key: CSSVariableKey]: string | number;
6
+ };
7
+ type BaseCSSProperties = {
8
+ [K in keyof Properties]: Properties[K] | CSSVariableValue;
9
+ };
10
+ type ArrayString = `[${string}`;
11
+ type ArraySelector = {
12
+ [key in ArrayString]: BaseCSSProperties | CSSVariableProperty;
13
+ };
14
+ type ColonString = `:${string}`;
15
+ type ColonSelector = {
16
+ [key in ColonString]: BaseCSSProperties | CSSVariableProperty;
17
+ };
18
+ type Query = `@media ${string}` | `@container ${string}`;
19
+ type QuerySelector = {
20
+ [K in Query]: BaseCSSProperties | ColonSelector | ArraySelector | CSSVariableProperty;
21
+ };
22
+ export type CSSProperties = BaseCSSProperties | ArraySelector | ColonSelector | QuerySelector | CSSVariableProperty;
23
+ export {};
@@ -1,6 +1,3 @@
1
- export declare const isServer: boolean;
2
- export declare const isDevelopment: boolean;
3
- export declare const isTestingDevelopment: boolean;
4
1
  export declare const exceptionCamelCase: string[];
5
2
  export declare const applyCssValue: (value: string | number, cssProp: string) => string;
6
3
  export declare const camelToKebabCase: (property: string) => string;
@@ -1,2 +1,2 @@
1
- import type { CreateStyle } from '../types/main/create.js';
2
- export declare const overrideLonghand: (style: CreateStyle) => CreateStyle;
1
+ import { CSSProperties } from '../types/css-properties.js';
2
+ export declare const overrideLonghand: (style: CSSProperties) => CSSProperties;
@@ -1,4 +1,4 @@
1
- import type { CSSProperties, CreateStyle } from '../index.js';
2
- declare function splitAtomicAndNested(obj: CSSProperties, flat: CreateStyle, nonFlat: CreateStyle): void;
1
+ import type { CSSProperties } from '../index.js';
2
+ declare function splitAtomicAndNested(obj: CSSProperties, flat: CSSProperties, nonFlat: CSSProperties): void;
3
3
  declare function processAtomicProps(flatProps: CSSProperties, atomicMap: Map<string, string>, parentAtRule?: string): void;
4
4
  export { splitAtomicAndNested, processAtomicProps };
@@ -1,4 +1,4 @@
1
- import type { CSSHTML } from '../types/main/global.js';
2
- export declare function transpile(object: CSSHTML, base36Hash?: string, core?: string): {
1
+ import type { CSSProperties } from '../types/css-properties.js';
2
+ export declare function transpile(object: Record<string, CSSProperties>, base36Hash?: string, core?: string): {
3
3
  styleSheet: string;
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zss-engine",
3
- "version": "2.2.6",
3
+ "version": "2.2.8",
4
4
  "description": "A CSS-in-JS transpiler engine for building zero-runtime stylesheets at build time.",
5
5
  "funding": "https://github.com/sponsors/refirst11",
6
6
  "author": "Refirst 11",
@@ -51,13 +51,13 @@
51
51
  "csstype": "3.2.3"
52
52
  },
53
53
  "devDependencies": {
54
- "@types/jest": "^29.5.14",
55
- "@types/node": "^22.18.10",
56
- "jest": "^29.7.0",
57
- "jest-environment-jsdom": "^29.7.0",
54
+ "@types/jest": "^30.0.0",
55
+ "@types/node": "^25.6.0",
56
+ "jest": "^30.3.0",
57
+ "jest-environment-jsdom": "^30.3.0",
58
58
  "rimraf": "^6.1.2",
59
- "ts-jest": "^29.4.5",
60
- "typescript": "^5.9.3"
59
+ "ts-jest": "^29.4.9",
60
+ "typescript": "^6.0.2"
61
61
  },
62
62
  "publishConfig": {
63
63
  "access": "public",
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,46 +0,0 @@
1
- import type { CSSVariableValue, CSSVariableProperty } from '../main/variableTypes';
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 CustomProperties = {
9
- [K in keyof CSSTypeProperties]: ExcludeMozInitial<CSSTypeProperties[K]>;
10
- };
11
- type BaseCSSProperties = {
12
- [K in keyof CustomProperties]: CustomProperties[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 ArrayString = `[${string}`;
34
- type ArraySelector = {
35
- [key in ArrayString]: CommonProperties | CSSVariableProperty;
36
- };
37
- type ColonString = `:${string}`;
38
- type ColonSelector = {
39
- [key in ColonString]: CommonProperties | CSSVariableProperty;
40
- };
41
- export type Query = `@media ${string}` | `@container ${string}`;
42
- type QuerySelector = {
43
- [K in Query]: CommonProperties | ColonSelector | ArraySelector | CSSVariableProperty;
44
- };
45
- export type CSSProperties = CommonProperties | ArraySelector | ColonSelector | QuerySelector | CSSVariableProperty;
46
- export {};
@@ -1,4 +0,0 @@
1
- import type { CSSProperties } from '../common/css-properties';
2
- export type CreateStyle = {
3
- [key: string]: CSSProperties;
4
- };
@@ -1,37 +0,0 @@
1
- import type { CSSProperties, Query } from '../common/css-properties';
2
- type JSXType = keyof HTMLElementTagNameMap | '*' | ':root';
3
- type HTMLSelector = {
4
- [K in JSXType]: CSSProperties;
5
- };
6
- type ClassName = `.${string}`;
7
- type ClassNameSelector = {
8
- [K in ClassName]: CSSProperties;
9
- };
10
- type Attribute = `${string}[${string}]${string}`;
11
- type AttributeSelector = {
12
- [K in Attribute]: CSSProperties;
13
- };
14
- type Consecutive = `${JSXType} ${string}`;
15
- type ConsecutiveSelector = {
16
- [K in Consecutive]: CSSProperties;
17
- };
18
- type PseudoClass = `${JSXType}:${string}`;
19
- type PseudoClassSelector = {
20
- [K in PseudoClass]: CSSProperties;
21
- };
22
- type PseudoElement = `::${string}`;
23
- type PseudoElementSelector = {
24
- [K in PseudoElement]: CSSProperties;
25
- };
26
- type KeyframesInSelector = 'from' | 'to' | `${number}%`;
27
- export type Keyframes = {
28
- [K in KeyframesInSelector]?: CSSProperties;
29
- };
30
- type KeyframesSelector = {
31
- [K in `@keyframes ${string}`]: Keyframes;
32
- };
33
- type QuerySelectorHTML = {
34
- [K in Query]: CSSHTML;
35
- };
36
- export type CSSHTML = HTMLSelector | ClassNameSelector | AttributeSelector | ConsecutiveSelector | PseudoClassSelector | PseudoElementSelector | KeyframesSelector | QuerySelectorHTML;
37
- export {};
@@ -1,7 +0,0 @@
1
- type CSSVariableKey = `--${string}`;
2
- export type CSSVariableValue = `var(${CSSVariableKey})`;
3
- export type CSSVariableProperty = {
4
- [key: CSSVariableKey]: string | number;
5
- };
6
- export type CreateTheme = Record<string, Record<string, string | number>>;
7
- export {};
@@ -1,7 +0,0 @@
1
- import { CSSProperties } from '../common/css-properties';
2
- export type ViewTransition = {
3
- group?: CSSProperties;
4
- imagePair?: CSSProperties;
5
- new?: CSSProperties;
6
- old?: CSSProperties;
7
- };