诊断
wrapWithDiagnostics 返回选定的边界和成本。诊断需要显式启用。
核心诊断
wrapWithDiagnostics 返回原有行数据,以及 UTF-16 边界、宽度、策略、耗时和 balanced 成本。成本是启发式指标,不是语法正确性的证明。
ts
import { wrapWithDiagnostics } from '@oddmash/juliya';
const { lines, diagnostics } = wrapWithDiagnostics(text, { width, measure });检查范围选项
为 mountJuliyaScope 显式提供 onDecision,可查看挂载、更新、排除与清理原因。sources 标识默认值、范围、规则、CSS 或属性中最终生效的设置。DOM 与 React 的 onDiagnostic 提供测量状态、Canvas 测量函数复用、内联方案复用、字体和尺寸变化以及新方案信息。保护的内联代码会报告回退,方案不代表 CSS 实际行数。默认不会记录或传输原文。回调异常会与换行处理隔离。
ts
import { mountJuliyaScope } from '@oddmash/juliya/dom';
const scope = mountJuliyaScope(root, { include: ['p'] }, {
onDecision: (_, event) => { if (event.status === 'updated') console.debug(event.options, event.sources); },
onDiagnostic: (_, event) => console.debug(event),
});