Complete reference
Full API.
Every supported constructor, option, method, event, return contract, and runtime distinction across the active White Label projects. Use the package guides when you need deeper lifecycle, security, or architecture guidance.
Observable state
white-label-model
Own object, array, or Map state with synchronous change notifications, deep mutation observation, and optional whole-state runtime validation.
Requirements
- Node.js ^22.18.0 or >=24.11.0
- npm >=11
- Native Proxy support
- Native Map support when using Map state
Import
import {Model} from 'white-label-model';const {Model} = require('white-label-model');Core API
new Model(data?, validator?)- Create an observable root state container.
- Returns
- A Model instance.
- Throws / rejects
- TypeError when the initial root shape is unsupported or initial validation fails.
- Runtime
- Browser + Node.js
initialize()- Start the lifecycle for chaining and composition.
- Returns
- The same Model instance.
- Runtime
- Browser + Node.js
get() / get(key)- Read the complete observable root or one object property, array index, or Map entry.
- Returns
- The root state, one resolved value, or undefined when a keyed lookup does not resolve.
- Runtime
- Browser + Node.js
set(data, silent?)- Replace the complete root state with another supported root shape.
- Returns
- true when accepted; false for unsupported or validator-rejected data.
- Events / side effects
- change → set unless silent.
- Runtime
- Browser + Node.js
update(partial, silent?) / update(key, value, silent?)- Shallow-merge an object root or replace/shallow-merge one existing array or Map member.
- Returns
- true when accepted; false for an invalid call, missing member, or validator rejection.
- Events / side effects
- change → update unless silent.
- Runtime
- Browser + Node.js
push(valueOrValues, silent?) / push(key, value, silent?)- Append array values or insert Map entries.
- Returns
- true when accepted; false for invalid calls, object roots, or validator rejection.
- Events / side effects
- change → push unless silent.
- Runtime
- Browser + Node.js
delete(key, silent?)- Delete one object property, array index, or Map entry.
- Returns
- true when removed; false when the member is missing/invalid or validation rejects the resulting state.
- Events / side effects
- change → delete unless silent.
- Runtime
- Browser + Node.js
clear(silent?)- Reset the root to an empty value of the same shape.
- Returns
- true.
- Events / side effects
- change → clear unless silent.
- Runtime
- Browser + Node.js
destroy()- Clear state silently and release listeners.
- Returns
- The same Model instance after cleanup.
- Runtime
- Browser + Node.js
Current compatibility surface
These methods are publicly declared today but are not part of the recommended state-management workflow. They are documented here so the reference matches the shipped API exactly.
serviceGet()- Compatibility placeholder; performs no I/O in the current implementation.
- Returns
- Promise resolving to {}.
- Runtime
- Browser + Node.js
servicePatch()- Compatibility placeholder; performs no I/O in the current implementation.
- Returns
- Promise resolving to {}.
- Runtime
- Browser + Node.js
servicePost()- Compatibility placeholder; performs no I/O in the current implementation.
- Returns
- Promise resolving to {}.
- Runtime
- Browser + Node.js
servicePut()- Compatibility placeholder; performs no I/O in the current implementation.
- Returns
- Promise resolving to {}.
- Runtime
- Browser + Node.js
Inherited utility methods
Model currently inherits these public utility methods. Application code normally does not need them for ordinary Model usage.
isMap(value)- Return whether a value is a native Map, including cross-realm Maps.
- Returns
- boolean.
- Runtime
- Browser + Node.js
isFinite(value)- Accept finite numeric values without coercion.
- Returns
- boolean.
- Runtime
- Browser + Node.js
isPlainObject(value)- Return whether a value is an ordinary or null-prototype object rather than a class instance.
- Returns
- boolean.
- Runtime
- Browser + Node.js
pullAt(array, index)- Remove one array member in place.
- Returns
- The same array.
- Runtime
- Browser + Node.js
extend(object1, object2)- Create a safe shallow merge while blocking prototype-pollution keys.
- Returns
- A new merged object.
- Runtime
- Browser + Node.js
message(messages, data)- Emit local events and optional namespaced mediator events.
- Returns
- false for falsey data; true after emitting requested events.
- Runtime
- Browser + Node.js
Rendering and lifecycle
white-label-view
Render state through explicit browser or server lifecycles, with optional first-party JSX and no component-framework runtime.
Requirements
- Node.js ^22.18.0 or >=24.11.0 for installation/development/server rendering
- Browser DOM only for the default browser entrypoint
- No DOM globals required by white-label-view/server
Import
import View from 'white-label-view';import View from 'white-label-view/server';import {raw} from 'white-label-view/jsx-runtime';Browser constructor settings
new View(settings?)- Create a browser View.
- Returns
- A View instance.
- Runtime
- Browser
Browser View API
update(element, data)- In-place update hook used before template replacement.
- Returns
- boolean; true means handled, false uses normal template rendering.
- Runtime
- Browser
setModel(model?)- Move model binding and synchronously render current data.
- Returns
- The same View instance.
- Runtime
- Browser
initialize()- Perform the initial synchronous render and lifecycle setup.
- Returns
- The same View instance.
- Runtime
- Browser
requestRender()- Render now or queue one animation-frame render when batching is enabled.
- Returns
- The same View instance.
- Runtime
- Browser
addChild(child)- Give this View cleanup ownership of another View without automatically mounting it.
- Returns
- The parent View.
- Throws / rejects
- TypeError for ownership cycles or a child already owned elsewhere.
- Runtime
- Browser
releaseChild(child)- Relinquish cleanup ownership without destroying the child.
- Returns
- The parent View.
- Runtime
- Browser
destroy()- Release listeners, binding, queued work, owned children, and the DOM root.
- Returns
- The same View instance; it may be initialized again.
- Runtime
- Browser
initializeModelBinding()- Subscribe once to an observable model's change event.
- Returns
- undefined.
- Runtime
- Browser
destroyModelBinding()- Release the owned model subscription and cancel queued rendering.
- Returns
- undefined.
- Runtime
- Browser
addListeners()- Subclass hook called after root installation.
- Returns
- The same View instance by default.
- Runtime
- Browser
removeListeners()- Subclass hook called before root replacement or destruction.
- Returns
- The same View instance by default.
- Runtime
- Browser
afterMount()- Subclass hook called after insertion/adoption and listener setup.
- Returns
- The same View instance by default.
- Runtime
- Browser
delegate(scope?)- Create a caller-owned delegated-event registry scoped to an element or the current root.
- Returns
- DelegatedEvents registry.
- Runtime
- Browser
render()- Synchronously mount, preserve, update, or replace the root.
- Returns
- The same View instance.
- Throws / rejects
- TypeError when template output does not resolve to exactly one browser element.
- Runtime
- Browser
DelegatedEvents API
delegated.on(type, selector, callback, options?)- Register a native delegated event listener. once is consumed only by a matching event.
- Returns
- The same DelegatedEvents registry.
- Runtime
- Browser
delegated.off(type, selector?, callback?, options?)- Remove matching delegated registrations, optionally scoped by selector/callback/capture.
- Returns
- The same DelegatedEvents registry.
- Runtime
- Browser
delegated.clear()- Remove every native and abort listener owned by the registry.
- Returns
- The same DelegatedEvents registry.
- Runtime
- Browser
Server View API
setModel(model?)- Move model binding and synchronously render current data.
- Returns
- The same server View.
- Runtime
- Node.js / DOM-free
initialize()- Render current state and initialize the server lifecycle.
- Returns
- The same server View.
- Runtime
- Node.js / DOM-free
addChild(child)- Register child cleanup ownership.
- Returns
- The parent server View.
- Throws / rejects
- TypeError for ownership cycles or conflicting ownership.
- Runtime
- Node.js / DOM-free
releaseChild(child)- Release ownership without destroying the child.
- Returns
- The parent server View.
- Runtime
- Node.js / DOM-free
initializeModelBinding()- Subscribe to observable model changes.
- Returns
- The same server View.
- Runtime
- Node.js / DOM-free
destroyModelBinding()- Release the model subscription.
- Returns
- The same server View.
- Runtime
- Node.js / DOM-free
render()- Synchronously render the template into stored HTML.
- Returns
- The same server View.
- Throws / rejects
- TypeError for output that is neither a string nor White Label JSX markup.
- Runtime
- Node.js / DOM-free
toString()- Read the most recently rendered HTML.
- Returns
- HTML string, or an empty string before/after output is cleared.
- Runtime
- Node.js / DOM-free
destroy()- Destroy children, release subscriptions, and clear stored output.
- Returns
- The same server View.
- Runtime
- Node.js / DOM-free
JSX runtime API
raw(value)- Mark caller-owned markup as trusted so it is inserted without escaping.
- Returns
- RawMarkup.
- Runtime
- Browser + Node.js
isJSXMarkup(value)- Identify output created by the White Label JSX runtime.
- Returns
- Type-predicate boolean.
- Runtime
- Browser + Node.js
jsx(type, props)- Automatic JSX runtime entry point.
- Returns
- JSXMarkup.
- Runtime
- Browser + Node.js
jsxs(type, props)- Automatic JSX runtime alias used for multi-child output.
- Returns
- JSXMarkup.
- Runtime
- Browser + Node.js
jsxDEV(type, props)- Development JSX runtime alias.
- Returns
- JSXMarkup.
- Runtime
- Browser + Node.js
Fragment- Fragment token understood by the JSX runtime.
- Returns
- symbol.
- Runtime
- Browser + Node.js
Application events
white-label-mediator
A small synchronous Node-compatible event bus for exchanging named application intent without direct module coupling.
Requirements
- Node.js ^22.18.0 or >=24.11.0 for installation/development
- No DOM dependency
Import
import Mediator from 'white-label-mediator';const mediator = new Mediator();Mediator API
new Mediator<Events>()- Create an independent event bus, optionally with a compile-time event map.
- Returns
- A Mediator instance.
- Runtime
- Browser + Node.js
initialize()- Start the lifecycle for composition/chaining.
- Returns
- The same Mediator instance.
- Runtime
- Browser + Node.js
destroy()- Remove every listener from this mediator instance.
- Returns
- The same Mediator instance after cleanup.
- Runtime
- Browser + Node.js
on(name, callback)- Subscribe to a named event.
- Returns
- The same Mediator instance for chaining.
- Runtime
- Browser + Node.js
once(name, callback)- Subscribe for one delivery.
- Returns
- The same Mediator instance for chaining.
- Runtime
- Browser + Node.js
emit(name, ...payload)- Synchronously publish an event.
- Returns
- true when at least one listener exists; otherwise false.
- Runtime
- Browser + Node.js
removeListener(name, callback)- Release one owned subscription using the same callback reference.
- Returns
- The same Mediator instance for chaining.
- Runtime
- Browser + Node.js
removeAllListeners(name?)- Use the standard EventEmitter broad-cleanup contract.
- Returns
- The same Mediator instance.
- Runtime
- Browser + Node.js
listenerCount(name)- Inspect current listener count for an event.
- Returns
- number.
- Runtime
- Browser + Node.js
off(name, callback)- Node EventEmitter alias for removeListener().
- Returns
- The same Mediator instance.
- Runtime
- Browser + Node.js
addListener(name, callback)- Node EventEmitter alias for on().
- Returns
- The same Mediator instance.
- Runtime
- Browser + Node.js
URL to application intent
white-label-router
Use one route contract across browser and server runtimes while preserving real links, URL semantics, History API behavior, and requestable server routes.
Requirements
- Node.js ^22.18.0 or >=24.11.0
- Browser History API/location/DOM events only for browser enhancement
- Directly requestable server routes for public browser URLs
Import
import Router from 'white-label-router';const router = new Router();Configuration properties
router.routes- Ordered route table containing route functions or lifecycle route objects.
- Returns
- Configuration property.
- Runtime
- Browser + Node.js
router.scope- Application Element passed to callbacks; null is valid on server paths.
- Returns
- Configuration property.
- Runtime
- Browser + Node.js
router.mediator- Optional EventEmitter-compatible source for router:navigate messages.
- Returns
- Configuration property.
- Runtime
- Browser + Node.js
route.title- Document title applied after browser routing; retained as pageTitle state on servers.
- Returns
- Route configuration.
- Runtime
- Browser + Node.js
route.focus- Selector to focus after browser navigation; defaults to main h1, false preserves focus.
- Returns
- Route configuration.
- Runtime
- Browser
route.secure(scope, location)- Navigation guard. Only an exact true result allows the route.
- Returns
- unknown; navigation accepts only true.
- Runtime
- Browser + Node.js
route.view- Route function or lifecycle object with initialize() and optional destroy().
- Returns
- Route configuration.
- Runtime
- Browser + Node.js
Router API
new Router()- Create an independent router with empty routes and isolated listener state.
- Returns
- A Router instance.
- Runtime
- Browser + Node.js
initialize(url?)- Dispatch the current browser URL or an explicit server URL and attach applicable listeners.
- Returns
- The same Router instance.
- Runtime
- Browser + Node.js
addListeners()- Attach browser and optional mediator handlers once.
- Returns
- The same Router instance.
- Runtime
- Browser + Node.js
destroy()- Release routing listeners owned by the instance.
- Returns
- The same Router instance after cleanup.
- Runtime
- Browser + Node.js
removeListeners()- Release listeners owned by this router; subclasses may extend this lifecycle hook.
- Returns
- The same Router instance.
- Runtime
- Browser + Node.js
eventPushStateClick(event)- Intercept an eligible same-origin data-pushstate link while preserving native browser actions that should not be enhanced.
- Returns
- Router instance after handled navigation; true when native/default handling should continue.
- Runtime
- Browser
eventPopState()- Dispatch the authoritative current browser history location without adding a new entry.
- Returns
- The same Router instance.
- Runtime
- Browser
parseQueryString(query)- Decode query parameters using URLSearchParams and keep the last duplicate value.
- Returns
- Plain Record<string, string>.
- Runtime
- Browser + Node.js
setLocationData(data?)- Rebuild decoded path/query/mediator payload for the selected route.
- Returns
- undefined; updates locationData in place.
- Runtime
- Browser + Node.js
applyPageContext(route)- Apply configured title and focus after routing when the runtime supports those effects.
- Returns
- The same Router instance.
- Runtime
- Browser + Node.js
navigate(url?, data?, isPopState?)- Match a route, enforce its guard, transition view lifecycle, and update browser history when applicable.
- Returns
- The same Router on success; false for rejected guards, cross-origin browser URLs, or routes without runnable view behavior.
- Runtime
- Browser + Node.js
Project creation
generator-white-label
Create a production-oriented TypeScript starter that composes the White Label packages, with optional JSX or equivalent plain-TypeScript templates.
Requirements
- Node.js ^22.18.0 or >=24.11.0
- npm >=11
Import
npx generator-white-label create my-projectnpm install --global generator-white-label
white-label create my-projectimport {createProject} from 'generator-white-label';CLI contract
white-label create <destination>- Create a project in the target directory.
- Returns
- Process success after scaffold creation; file-system failures surface as command errors.
- Runtime
- Node.js CLI
--jsx- Generate JSX/TSX page and view templates using the White Label JSX runtime.
- Returns
- CLI option.
- Runtime
- Node.js CLI
--no-jsx- Generate equivalent plain-TypeScript templates that return HTML strings.
- Returns
- CLI option.
- Runtime
- Node.js CLI
white-label --help- Show command usage.
- Returns
- CLI help output.
- Runtime
- Node.js CLI
Programmatic API
createProject(options)- Write a complete White Label scaffold using the same implementation as the CLI.
- Returns
- Promise<void>; resolves with undefined when creation is complete.
- Throws / rejects
- Promise rejects on filesystem or scaffold-writing failures.
- Runtime
- Node.js