PreviewUpdateService
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.
Coordinates document parsing and renderer state without depending on a VS Code or Web UI. Use it for end-to-end rule tests and host integration; use lower-level helpers only for isolated parser or formatter tests.
Constructor
ts
new PreviewUpdateService<TUri>(
fileProvider: IFileProvider<TUri>,
registry: RuleRegistry = SNAP_TEX_RULES
)Parameters
| Parameter | Description |
|---|---|
fileProvider | Host-neutral project file reader used for inputs, bibliography, images, and included files |
registry | Registry under test; defaults to the built-in SNAP_TEX_RULES |
Instance responsibilities
The service owns one LatexDocument and one SmartRenderer. It retains diff, numbering, citation, dependency, and lazy-render state across calls to render.
Useful methods include:
renderrenderBlockByIndexresetStategetDiagnosticsgetPreviewSyncData/getSourceSyncDataisKnownFilegetBibliographyKeys/getMacroNames
Call relationships
- Constructs:
LatexDocumentandSmartRendererwith the same registry. - Used by: VS Code, Web/standalone hosts, and end-to-end tests.
text
file provider + registry -> PreviewUpdateService
-> LatexDocument + SmartRenderer
-> RenderPayload / lazy block HTML / sync datats
const service = new PreviewUpdateService(
new MemoryFileProvider(),
SNAP_TEX_RULES
);