DocsAdvanced

API reference

Core exports wrap, splitLines and segmentSentences. Browser and DOM paths are aliases. React adds JuliyaText, useJuliya and JuliyaProvider. Existing React, Vue and Svelte exports remain compatible.

Core

Use wrap, splitLines and segmentSentences for measured wrapping, explicit/forced lines and source-preserving sentence segments.

ts
import { wrap, splitLines, segmentSentences } from '@oddmash/juliya';
import type { WrapLocale, WrapOptions, WrappedLine } from '@oddmash/juliya';

DOM

Import createCanvasMeasure, observeJuliya, mountJuliya and mountJuliyaScope from /dom. DOM controllers expose update, refresh and destroy. Opt-in onDiagnostic reports measurement and wrapping events; JuliyaRuntimeDiagnostic and JuliyaDiagnosticCallback types are exported from /dom and /browser. Diagnostics.

ts
import { createCanvasMeasure, mountJuliya, observeJuliya, mountJuliyaScope } from '@oddmash/juliya/dom';

mountJuliya and observeJuliya

Mount applies breaks to an element; observe instead returns lines and measured state through a callback without replacing child nodes.

React

Use JuliyaText and useJuliya for measured JSX, JuliyaProvider for defaults and JuliyaScope for trusted owned HTML. The separate /react/server entry exports JuliyaSentenceText. Existing aliases WrapText, useKowrap and SentenceText still work; new code should use the Juliya names. Import the Provider and its consumers from the same package. JuliyaText and useJuliya accept onDiagnostic; JuliyaScope and useJuliyaScope accept scope diagnostics. Callbacks run only after client commit.

Vue and Svelte

Import juliyaDirective from /vue and juliya from /svelte; both delegate to the shared DOM adapter.

ts
import { juliyaDirective } from '@oddmash/juliya/vue';
import { juliya } from '@oddmash/juliya/svelte';