Plumeria logo/ ✾ Plumeria
Ecosystem

zss-engine

It is the plumeria Runtime zss-engine package
You can use this to develop Zero-runtime StyleSheet CSS-in-JS libraries.

Installation

Terminal
npm i zss-engine

Overview

export type { CSSProperties } from './types/common/css-properties';
export type { CreateStyleType, ReturnType, CreateStyle } from './types/main/create';
export type { CSSHTML, CreateKeyframes } from './types/main/global';
export type { CreateValues, CreateTheme, ReturnVariableType, RxVariableSet, ReturnRx } from './types/main/vars';
export type { Join } from './types/main/join';
export { isServer, isDevelopment, isTestingDevelopment } from './utils/helper.js';
export { genBase36Hash } from './utils/hash.js';
export { transpiler } from './utils/transpiler.js';
export { build } from './utils/build.js';
export { camelToKebabCase } from './utils/helper.js';
export { injectClientCSS } from './utils/inject-client-css.js';
export { injectClientGlobalCSS } from './utils/inject-client-global-css.js';
export { injectServerCSS, getServerCSS } from './utils/inject-server-css.js';

API

Helpers

For branching the environment.

TypeScript
const isWindowDefined = typeof window !== 'undefined';
const isDocumentDefined = typeof document !== 'undefined';
export const isServer = !isWindowDefined || !isDocumentDefined;
export const isDevelopment = process.env.NODE_ENV === 'development';
export const isTestingDevelopment = process.env.NODE_ENV === 'test' || isDevelopment;

Functions

genBase36Hash

Arguments: object, number of hash lengths
Returns: string of hash

TypeScript
  const base36Hash = genBase36Hash(object, 6); 

transpiler

Argments: object: style object, hash: string
Returns: styleSheet: string

TypeScript
  const { styleSheet } = transpiler(object, base36Hash);

build

Argments: styleSheet: string, filePath: string
Returns: void

TypeScript
  build(styleSheet, filePath);

camelToKebabCase

Argments: property: string Returns: string

TypeScript
const kebab = camelToKebabCase('CreateStyle') // return create-style

injectClientCSS

Argments: hash: string, styleSheet: string
Returns: void

TypeScript
  injectClientCSS(base36Hash, styleSheet);

injectClientGlobalCSS

Argments: styleSheet: string, scoped: string
Returns: void

TypeScript
  injectClientGlobalCSS(styleSheet, 'global');

injectServerCSS

Argments: hash: string, styleSheet: string
Returns: void

TypeScript
  injectServerCSS(base36Hash, styleSheet);

getServerCSS

Argments: void Returns: styleSheet: string

TypeScript
  const serverCSS = getServerCSS();

Types

For API development.

TypeScript
// create method
CSSProperties, // supply
CreateStyle, // supply
CreateStyleType<T>, 
ReturnType<T>,
 
// global method
CSSHTMLType, // supply
 
// keyframes method
CreateKeyframes,
 
// defineConsts and defineVars method
CreateValues,
 
// defineTheme method
CreateTheme,
 
// defineVars and defineTheme return type
ReturnVariableType,
 
// rx function
 RxVariableSet,
 ReturnRx

On this page

;