@geometra/core
v1.19.5
Published
DOM-free UI framework core: components, signals, reconciler
Maintainers
Readme
@geometra/core
DOM-free UI framework core. Build declarative interfaces rendered to Canvas, terminal, or server-streamed layouts.
Install
npm install @geometra/coreKey Exports
signal,computed,effect,batch-- reactive primitivesbox,text,image-- element constructorscreateApp-- application entry pointtoSemanticHTML-- SEO-friendly HTML generationtoAccessibilityTree-- runtime accessibility tree from geometryinsertInputText,backspaceInput,deleteInput-- text-input editing primitivesgetInputCaretGeometry-- caret x/y/height from measured text linescreateTextInputHistory,undoTextInputHistory-- undo/redo state helperstransition,spring,createTweenTimeline,createPropertyTimeline,setMotionPreference-- animation utilities
Usage
import { box, text, createApp, signal } from '@geometra/core'
const count = signal(0)
const app = createApp(() =>
box({ width: 300, height: 200, padding: 20, gap: 10 }, [
text({ text: `Count: ${count.value}`, font: 'bold 24px sans-serif', lineHeight: 30 }),
box({ width: 100, height: 40, backgroundColor: '#07f', onClick: () => count.set(count.peek() + 1) }, [
text({ text: 'Click me', font: '16px sans-serif', lineHeight: 20, color: '#fff' }),
]),
])
)Text input contract
TextInputStateis immutable editor state:{ nodes: string[], selection }.selectionis node-local and may be reversed; helpers normalize internally.insertInputText/replaceInputSelectionalways collapse caret after replacement.backspaceInput/deleteInputdelete active selections first, then apply boundary merge behavior across nodes.moveInputCaretsupports range extension viaextendSelection=true.moveInputCaretandmoveInputCaretByWordaccept an optional reading direction (ltrdefault,rtlsupported) for horizontal key semantics.moveInputCaretToLineBoundaryalso accepts optional reading direction so Home/End semantics can follow visual direction in RTL contexts.getInputCaretGeometryis defined for collapsed selections with measured line metrics; expanded ranges returnnull.
Direction model baseline
- Elements may provide
dir: 'ltr' | 'rtl' | 'auto'onbox(),text(), andimage()props. dir='auto'currently inherits from parent direction (script-level auto detection is deferred).- Omitted
dirinherits from parent; root fallback isltr. - Direction metadata is kept in the declarative tree and intentionally stripped from Yoga layout props.
Accessibility guarantees and limits
toAccessibilityTree(tree, layout)emits deterministic role/name/bounds/focusable nodes for geometry-rendered UIs.- Semantic overrides (
semantic.tag,semantic.role,semantic.ariaLabel,semantic.alt) are preserved when projecting accessibility and semantic HTML output. - The core package does not directly expose native accessibility APIs; renderer integrations (for example canvas mirror strategies) are responsible for host-level assistive technology bridging.
