API reference · Editor domain
@oriatheme/editor-core
Draft, field metadata, smart scales, diagnostics, preview, and commit sessions with no DOM, Storage, or framework dependency.Package and environment
Pure domain logic; only preview/save receive a runtime created by the consumer.
bash
pnpm add @oriatheme/editor-corebash
npm install @oriatheme/editor-corebash
yarn add @oriatheme/editor-corebash
bun add @oriatheme/editor-coreUse the package manager and lockfile already chosen by the consumer project. Examples use package-root exports only; do not deep-import from src, dist, or registry templates.
Exports
| Export | Signature | Description |
|---|---|---|
describeTokenContract | (contract?) => readonly TokenFieldDescriptor[] | Stable contract-order field metadata. |
describeToken | (path, contract?) => TokenFieldDescriptor | undefined | Looks up one editor field. |
getTokenModeScope | (path) => 'shared' | 'mode' | Returns standard-token editing scope. |
deriveSmartScale | (input: SmartScaleInput) => readonly DerivedTokenValue[] | Expands a designer-facing master value. |
preserveScaleOverrides | (derived, current, customized) => readonly DerivedTokenValue[] | Retains explicitly customized leaves. |
createThemeEditorIdentity | (source, existingThemes) => CloneIdentity | Creates a stable unused identity for preset editing. |
createThemeEditorSession | (options) => ThemeEditorSession | Creates the framework-independent draft session. |
ThemeEditorSession
| Export | Signature | Description |
|---|---|---|
getSnapshot / subscribe | () => ThemeEditorSnapshot / (listener) => unsubscribe | Read or observe immutable editor state. |
setName / setToken / setTokens | (...) => void | Change the draft by name, one token, or an atomic set. |
removeToken / resetToken / resetMode / resetAll | (...) => void | Unset or restore draft values. |
replaceFromJson / exportJson | (json) => ImportResult / () => string | Atomically import a draft or serialize it. |
preview | (runtime, mode?) => ThemeEditorPreviewResult | Previews only complete valid revisions. |
save | (runtime) => ThemeEditorSaveResult | Validates, creates/updates custom themes, or reports conflict. |
reload / destroy | (theme) => void / () => void | Adopt an external version or release session resources. |
Important types and boundaries
ThemeEditorOptions requires source and requires identity when editing a preset. ThemeEditorSaveResult fails with validation or conflict; ThemeEditorPreviewResult fails with issues. Do not copy this draft state machine into React, Vue, or a route.