Skip to content

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(...), and collect(...) are callbacks that your rule implements and SnapTeX calls.
  • renderer.name(...), context.name(...), input.name(...), and deps.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 constructs PreviewUpdateService.

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 ​

ParameterDescription
fileProviderHost-neutral project file reader used for inputs, bibliography, images, and included files
registryRegistry 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:

Call relationships ​

  • Constructs: LatexDocument and SmartRenderer with 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 data
ts
const service = new PreviewUpdateService(
    new MemoryFileProvider(),
    SNAP_TEX_RULES
);

See also ​

A fast structural preview, not a replacement for a full TeX compiler.