zss-engine 0.1.1 → 0.2.0

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 (39) hide show
  1. package/dist/{types → src/types}/common/css-properties.d.ts +4 -6
  2. package/dist/src/types/main/vars.d.ts +10 -0
  3. package/dist/{utils → src/utils}/helper.js +1 -1
  4. package/dist/tests/inject-client-css.test.js +9 -0
  5. package/dist/tests/inject-client-global-css.test.d.ts +1 -0
  6. package/dist/tests/inject-client-global-css.test.js +9 -0
  7. package/dist/tests/inject-server-css.test.d.ts +1 -0
  8. package/dist/tests/inject-server-css.test.js +12 -0
  9. package/dist/tests/transpiler.test.d.ts +1 -0
  10. package/dist/tests/transpiler.test.js +12 -0
  11. package/package.json +1 -1
  12. package/dist/types/common/css-variables.d.ts +0 -3
  13. package/dist/types/main/vars.d.ts +0 -1
  14. /package/dist/{index.d.ts → src/index.d.ts} +0 -0
  15. /package/dist/{index.js → src/index.js} +0 -0
  16. /package/dist/{types → src/types}/common/css-properties.js +0 -0
  17. /package/dist/{types → src/types}/common/css-property.d.ts +0 -0
  18. /package/dist/{types → src/types}/common/css-property.js +0 -0
  19. /package/dist/{types → src/types}/index.d.ts +0 -0
  20. /package/dist/{types → src/types}/index.js +0 -0
  21. /package/dist/{types → src/types}/main/create.d.ts +0 -0
  22. /package/dist/{types → src/types}/main/create.js +0 -0
  23. /package/dist/{types → src/types}/main/global.d.ts +0 -0
  24. /package/dist/{types → src/types}/main/global.js +0 -0
  25. /package/dist/{types → src/types}/main/vars.js +0 -0
  26. /package/dist/{utils → src/utils}/build.d.ts +0 -0
  27. /package/dist/{utils → src/utils}/build.js +0 -0
  28. /package/dist/{utils → src/utils}/hash.d.ts +0 -0
  29. /package/dist/{utils → src/utils}/hash.js +0 -0
  30. /package/dist/{utils → src/utils}/helper.d.ts +0 -0
  31. /package/dist/{utils → src/utils}/inject-client-css.d.ts +0 -0
  32. /package/dist/{utils → src/utils}/inject-client-css.js +0 -0
  33. /package/dist/{utils → src/utils}/inject-client-global-css.d.ts +0 -0
  34. /package/dist/{utils → src/utils}/inject-client-global-css.js +0 -0
  35. /package/dist/{utils → src/utils}/inject-server-css.d.ts +0 -0
  36. /package/dist/{utils → src/utils}/inject-server-css.js +0 -0
  37. /package/dist/{utils → src/utils}/transpiler.d.ts +0 -0
  38. /package/dist/{utils → src/utils}/transpiler.js +0 -0
  39. /package/dist/{types/common/css-variables.js → tests/inject-client-css.test.d.ts} +0 -0
@@ -1,14 +1,12 @@
1
- import type { CSSVariableValue } from './css-variables';
1
+ import type { CSSVariableValue } 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>;
5
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
6
  type ExcludeMozInitial<T> = Exclude<T, '-moz-initial'>;
7
- type PropertiesWithoutMozInitial = {
8
- [K in keyof Properties]: ExcludeMozInitial<Properties[K]>;
9
- };
10
- type CSSProperties = Omit<PropertiesWithoutMozInitial, 'fontSize'> & {
11
- fontSize: PropertiesWithoutMozInitial['fontSize'] | number;
7
+ type CSSTypeProperties = Properties<number | (string & {})>;
8
+ type CSSProperties = {
9
+ [K in keyof CSSTypeProperties]: ExcludeMozInitial<CSSTypeProperties[K]>;
12
10
  };
13
11
  type BaseCSSProperties = {
14
12
  [K in keyof CSSProperties]: CSSProperties[K] | CSSVariableValue;
@@ -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 {};
@@ -4,7 +4,7 @@ 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
6
  export const isDevServer = isDevelopment && isServer;
7
- const exception = ['line-height', 'font-weight', 'opacity', 'scale', 'z-index'];
7
+ const exception = ['line-height', 'font-weight', 'opacity', 'scale', 'z-index', 'column-count', 'order', 'orphans', 'widows'];
8
8
  export const applyCssValue = (value, cssProp) => {
9
9
  if (typeof value === 'number') {
10
10
  return exception.includes(cssProp) ? value.toString() : value + 'px';
@@ -0,0 +1,9 @@
1
+ import { injectClientCSS } from '../src';
2
+ test('injectClientCSS correctly appends style element with expected content', () => {
3
+ const hash = 'ABC12';
4
+ const sheet = `.test-class_${hash} { color: red; }`;
5
+ injectClientCSS(hash, sheet);
6
+ const styleElement = document.getElementById(hash);
7
+ expect(styleElement).not.toBeNull();
8
+ expect(styleElement?.textContent).toContain(`.test-class_${hash} { color: red; }`);
9
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { injectClientGlobalCSS } from '../src';
2
+ test('injectClientGlobalCSS correctly appends global style element with expected content', () => {
3
+ const scoped = 'global-scope';
4
+ const sheet = '.global-class { color: blue; }';
5
+ injectClientGlobalCSS(sheet, scoped);
6
+ const styleElement = document.querySelector(`[data-scope="${scoped}"]`);
7
+ expect(styleElement).not.toBeNull();
8
+ expect(styleElement?.textContent).toContain('.global-class { color: blue; }');
9
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import { getServerCSS, injectServerCSS } from '../src';
2
+ test('should inject and get server CSS correctly', () => {
3
+ const hash1 = 'abcd1';
4
+ const hash2 = 'abcd2';
5
+ const sheet1 = 'body { color: red; }';
6
+ const sheet2 = 'h1 { font-size: 20px; }';
7
+ injectServerCSS(hash1, sheet1);
8
+ injectServerCSS(hash2, sheet2);
9
+ const serverCSS = getServerCSS();
10
+ expect(serverCSS).toContain(sheet1);
11
+ expect(serverCSS).toContain(sheet2);
12
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import { genBase36Hash, transpiler } from '../src';
2
+ test('object to sheet transpiler produces expected output', async () => {
3
+ const object = {
4
+ e2e: {
5
+ color: 'aqua',
6
+ },
7
+ };
8
+ const base62Hash = genBase36Hash(object, 6);
9
+ const { styleSheet } = transpiler(object, base62Hash);
10
+ expect(styleSheet).toContain('.e2e_');
11
+ expect(styleSheet).toContain('color: aqua;');
12
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zss-engine",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Zero-runtime Style Sheet Engine",
5
5
  "keywords": [
6
6
  "zero-runtime",
@@ -1,3 +0,0 @@
1
- type CSSVariableKey = `--${string}`;
2
- export type CSSVariableValue = `var(${CSSVariableKey})`;
3
- export {};
@@ -1 +0,0 @@
1
- export type VarsDefinition = Record<string, string | Record<string, string>>;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes