OriaTheme
GitHub

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-core

Use 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

ExportSignatureDescription
describeTokenContract(contract?) => readonly TokenFieldDescriptor[]Stable contract-order field metadata.
describeToken(path, contract?) => TokenFieldDescriptor | undefinedLooks 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) => CloneIdentityCreates a stable unused identity for preset editing.
createThemeEditorSession(options) => ThemeEditorSessionCreates the framework-independent draft session.

ThemeEditorSession

ExportSignatureDescription
getSnapshot / subscribe() => ThemeEditorSnapshot / (listener) => unsubscribeRead or observe immutable editor state.
setName / setToken / setTokens(...) => voidChange the draft by name, one token, or an atomic set.
removeToken / resetToken / resetMode / resetAll(...) => voidUnset or restore draft values.
replaceFromJson / exportJson(json) => ImportResult / () => stringAtomically import a draft or serialize it.
preview(runtime, mode?) => ThemeEditorPreviewResultPreviews only complete valid revisions.
save(runtime) => ThemeEditorSaveResultValidates, creates/updates custom themes, or reports conflict.
reload / destroy(theme) => void / () => voidAdopt 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.