PreviewUpdateService.getPreviewSyncData
How to read this API
These are TypeScript APIs compiled into SnapTeX; a .tex project cannot load them at runtime.
function name(...)is a helper that your rule imports and calls.apply(...),render(...),extract(...), andcollect(...)are callbacks that your rule implements and SnapTeX calls.renderer.name(...),context.name(...),input.name(...), anddeps.name(...)are methods SnapTeX supplies to callbacks; do not import or construct them.service.name(...)is an instance method called after your host or test constructsPreviewUpdateService.
Register extension declarations through SNAP_TEX_RULES in src/rules.ts. See Source API Scope for imports, value ownership, output safety, rebuilds, and testing.
Maps a source cursor position to preview synchronization data.
Signature
ts
service.getPreviewSyncData(
filePath: string,
line: number,
character?: number
)Parameters
line and optional character identify the editor position in filePath.
Call relationships
- Delegates to:
SmartRenderer.getPreviewSyncData. - Reads: source map, block map, and stored AST sync hints when available.
- Does not: parse AST or render blocks during the sync request.
Call it only after render has established current document state.
Returns
{ index, ratio, sourceStart?, sourceEnd? } for a known source position, or null when no current document/source mapping exists. index identifies the preview block and ratio is its estimated vertical position; AST source hints may add exact block-relative offsets.