/** * Public PDS runtime object exported to consumers. * * This object exposes the core runtime building blocks for the Pure Design System. * It intentionally provides a small, stable surface area so consuming apps can: * - programmatically generate design system artifacts (via `Generator`), * - adopt styles into Shadow DOM (via `adoptLayers` / `adoptPrimitives`), * - query runtime mode and obtain constructable stylesheets (via `registry`). * * Common events in the PDS ecosystem (emitted by other packages/components): * - `design-updated` — emitted by the designer component when the in-memory design changes (detail: { config }). * - `pds-generated` — emitted by the PDS configurator when generation completes (detail: { modules, meta }). * - `pds-error` — emitted by the PDS configurator when generation fails (detail: Error). * * Error handling notes: * - Methods that perform dynamic imports (e.g. `adoptLayers` via the registry) may log and return fallbacks * rather than throwing; consumers should check return values (e.g. null) and listen for `pds-error` in UI flows. * - `createStylesheet(css)` will throw synchronously if the provided CSS cannot be parsed by the browser's * `CSSStyleSheet.replaceSync()` — callers should guard invalid input or wrap calls in try/catch. */ export type PDSAPI = { /** * - Generator class to produce design system assets */ Generator: typeof import("./pds-core/pds-generator.js").Generator; /** * - Singleton runtime registry for live/static mode */ registry: import("./pds-core/pds-registry.js").PDSRegistry; /** * - Ontology helpers and metadata for components */ ontology: any; /** * - Adopt multiple layers into a ShadowRoot. May log errors and fallback to additionalSheets when static imports fail. */ adoptLayers: (shadowRoot: ShadowRoot, layers?: string[], additionalSheets?: CSSStyleSheet[]) => Promise; /** * - Adopt primitives layer into a ShadowRoot. Designed as a convenience for components. */ adoptPrimitives: (shadowRoot: ShadowRoot, additionalSheets?: CSSStyleSheet[]) => Promise; /** * - Create a constructable stylesheet from CSS text. */ createStylesheet: (css: string) => CSSStyleSheet; }; /** @type {PDSAPI & PDSBase} */ export const PDS: PDSAPI & PDSBase; /** * Validate a design configuration for accessibility sanity checks. * Currently validates color contrast for primary buttons and base surface text * in both light and dark themes. * * @param {object} designConfig - A full or partial PDS config object * @param {object} [options] * @param {number} [options.minContrast=4.5] - Minimum contrast ratio for normal text * @returns {{ ok: boolean, issues: Array<{path:string, message:string, ratio:number, min:number, context?:string}> }} */ export function validateDesign(designConfig?: object, options?: { minContrast?: number; }): { ok: boolean; issues: Array<{ path: string; message: string; ratio: number; min: number; context?: string; }>; }; /** * Public PDS runtime object exported to consumers. * * This object exposes the core runtime building blocks for the Pure Design System. * It intentionally provides a small, stable surface area so consuming apps can: * - programmatically generate design system artifacts (via `Generator`), * - adopt styles into Shadow DOM (via `adoptLayers` / `adoptPrimitives`), * - query runtime mode and obtain constructable stylesheets (via `registry`). * * Common events in the PDS ecosystem (emitted by other packages/components): * - `design-updated` — emitted by the designer component when the in-memory design changes (detail: { config }). * - `pds-generated` — emitted by the PDS configurator when generation completes (detail: { modules, meta }). * - `pds-error` — emitted by the PDS configurator when generation fails (detail: Error). * * Error handling notes: * - Methods that perform dynamic imports (e.g. `adoptLayers` via the registry) may log and return fallbacks * rather than throwing; consumers should check return values (e.g. null) and listen for `pds-error` in UI flows. * - `createStylesheet(css)` will throw synchronously if the provided CSS cannot be parsed by the browser's * `CSSStyleSheet.replaceSync()` — callers should guard invalid input or wrap calls in try/catch. * * @typedef {Object} PDSAPI * @property {typeof import("./pds-core/pds-generator.js").Generator} Generator - Generator class to produce design system assets * @property {import("./pds-core/pds-registry.js").PDSRegistry} registry - Singleton runtime registry for live/static mode * @property {any} ontology - Ontology helpers and metadata for components * @property {(shadowRoot: ShadowRoot, layers?: string[], additionalSheets?: CSSStyleSheet[]) => Promise} adoptLayers - Adopt multiple layers into a ShadowRoot. May log errors and fallback to additionalSheets when static imports fail. * @property {(shadowRoot: ShadowRoot, additionalSheets?: CSSStyleSheet[]) => Promise} adoptPrimitives - Adopt primitives layer into a ShadowRoot. Designed as a convenience for components. * @property {(css:string) => CSSStyleSheet} createStylesheet - Create a constructable stylesheet from CSS text. @throws {DOMException} on invalid CSS in some browsers. * @property {() => boolean} isLiveMode - Returns true when running in live/designer-backed mode * @property {(el: Element) => import("./pds-core/pds-ontology.js").ComponentDef | null} findComponentForElement - Helper to find a component definition for a DOM element */ /** * Workspace for the Pure Design System runtime API * PDS is now an EventTarget so consumers can subscribe to a single, consistent * event bus instead of listening on window/document or individual elements. */ declare class PDSBase extends EventTarget { } export {}; //# sourceMappingURL=pds.d.ts.map