/* tslint:disable */ /* eslint-disable */ /** How `translateMapLibre` lowers a MapLibre style. Every field is optional. */ export interface TranslateOptions { /** The translated style's `tile-size`. Defaults to 512, MapLibre's own. */ tileSize?: number; /** The translated style's `pad`, for strokes painted past a tile's edge. Defaults to 16. */ pad?: number; /** Keep `visibility: "none"` layers, switched off, instead of dropping them. */ keepHidden?: boolean; /** Convert legacy forms (`stops` functions, `{token}` strings) to expressions first. */ migrate?: boolean; /** `text-font` stack entry name → font source (`system:Helvetica`, a font URL). */ fonts?: Record; } /** What `translateMapLibre` answers with. */ export interface Translation { /** The ezu style: `new Renderer(JSON.stringify(recipe))` renders it. */ recipe: Record; /** What the translator skipped or approximated, one line each. */ warnings: string[]; } /** What `computeFrame` is asked for: a print page as scale, dpi, size and centre. */ export interface FrameRequest { /** The frame's centre in degrees (WGS84). The scale is matched at this latitude. */ centerLon: number; centerLat: number; /** The scale denominator: 1000 for 1:1000. */ scale: number; /** The output resolution. Together with `scale` it fixes the ground size of a pixel. */ dpi: number; /** The output size in pixels: `Math.round(mm / 25.4 * dpi)` from paper millimetres. */ width: number; height: number; /** Render at this zoom, deriving the tile size from it, as the CLI's `--zoom`. */ zoom?: number; /** The tile size the chosen zoom aims at. Defaults to this renderer's style. */ styleTileSize?: number; } /** Where a print frame sits on the tile grid it renders from. */ export interface Frame { /** The zoom the tiles render at. */ zoom: number; /** The tile size, in whole pixels, the tiles render at. */ tileSize: number; /** The scale denominator this zoom and tile size actually meet at the centre. */ scale: number; /** The output size in pixels, as requested. */ width: number; height: number; /** The frame's top-left corner in world pixels at this zoom and tile size. */ left: number; top: number; /** How far rounding onto whole pixels moved the frame: the centre sits at (width/2 + shift[0], height/2 + shift[1]). */ shift: [number, number]; /** The tile columns and rows the frame touches, start inclusive, end exclusive. */ tilesX: [number, number]; tilesY: [number, number]; } /** What one features node held when a render finished. */ export interface NodeFeatures { /** The node's id, as it was asked for. */ node: string; /** The tile's size in geometry units: coordinates run 0..extent, x right and y down. Absent when the render never reached the node. */ extent?: number; /** A GeoJSON FeatureCollection as text, in the coordinates asked for (tile units by default), with `node` and `extent` members of its own. */ geojson: string; } /** Which features nodes `renderTileWithFeatures` reports on, and the coordinates it writes them in. */ export interface TileFeatures { /** Node ids, in the order the collections come back. */ nodes: string[]; /** Tile units (the default), WGS84 longitude and latitude, or the rendered tile's pixels. */ coords?: "tile" | "lonlat" | "px"; } /** What `renderTileWithFeatures` hands back. */ export interface TileWithFeatures { /** The encoded tile, exactly as `renderTileWith` returns it. */ image: Uint8Array; /** One collection per node asked for, in the order asked. */ features: NodeFeatures[]; } /** Which features nodes `renderFrameWithFeatures` gathers over a page, and how it writes them. */ export interface FrameFeatures { /** One page of features per entry, in this order. `key` names the properties that identify a feature across tiles; with one, each feature is written once and the page is sorted by it. */ nodes: Array<{ node: string; key?: string[] }>; /** WGS84 longitude and latitude (the default), or page pixels. */ coords?: "lonlat" | "px"; } /** What one features node held over a whole page. */ export interface PageFeatures { /** The node's id, as it was asked for. */ node: string; /** A GeoJSON FeatureCollection as text: byte for byte the file `ezu frame --features` writes. */ geojson: string; } /** What `renderFrameWithFeatures` hands back. */ export interface FrameWithFeatures { /** The page, exactly as `renderFrame` resolves to it. */ image: Uint8Array; /** One page of features per node asked for, in the order asked. */ features: PageFeatures[]; } /** * What `renderFrame` hands each tile's `sources`: `bindSource` into the * renderer the frame has taken for itself, for what that tile's set needs * bound there. */ export class FrameBinder { private constructor(); free(): void; [Symbol.dispose](): void; /** * `Renderer.bindSource`, for the sources bound into the renderer * itself: the glyphs a tile turns out to need, or a font, sprite, * brush or image. Throws `UnknownSource` for a tile-scoped source, * which the frame renders from the returned set and would never read * here, and `StaleBinder` once this tile's `sources` has returned (or * its promise settled). */ bindSource(name: string, bytes: Uint8Array, opts?: object | null): void; } /** * What `frameFeatures` returns: features nodes' values gathered over the * tiles of a frame a host renders itself, assembled into the pages * `renderFrameWithFeatures` hands back. * * The Rust renderer's collector is handed each tile's values after the * render; here the tile renders through the collector, so the values stay * in the module rather than crossing to JS and back. It keeps the * renderer that made it alive until it is finished or freed. */ export class FrameFeatureCollector { private constructor(); free(): void; [Symbol.dispose](): void; /** * The pages: one `{ node, geojson }` per entry of the request's * `nodes`, in that order, as `renderFrameWithFeatures` hands them * back. Tiles are read rows top to bottom, then left to right, * whatever order they rendered in. The collector is used up. */ finish(): PageFeatures[]; /** * `renderTileWith` for one of the frame's tiles, also keeping what the * collector's nodes held. Pass `tileSize: frame.tileSize` in `opts` to * draw the tile `renderFrame` draws. Like `renderTileWith` it works * while a `renderFrame` holds the renderer, and leaves the glyph * budget to `trimGlyphs()`. */ renderTile(z: number, x: number, y: number, set: SourceSet, opts?: object | null): Uint8Array; } /** * Buffered log sink that captures `tracing` events from the renderer. * * Construct once near the top of your bootstrap, then either set a * callback for live forwarding (`onEvent(e => console.log(e))`) or * `drainLines()` periodically to flush into a UI panel. * * It is the Go package's `InitLog` and `DrainLogs` (the pull side) and * `WithLogger` (the push side) in one object. A class rather than two * free functions, because a browser host also wants the structured * records and the callback, which a wasip1 module's line buffer has no * room for; a Rust host installs its own `tracing` subscriber instead. */ export class LogSink { free(): void; [Symbol.dispose](): void; /** * Drop all buffered records without returning them. */ clear(): void; /** * Drain every buffered record. Returns a JS array of structured * objects `{ level, target, message, fields, timestampMs }`. */ drain(): Array; /** * Drain buffered records and return pre-formatted strings — the * same shape the CLI prints. Convenient for `console.log(lines.join('\n'))`. */ drainLines(): string[]; /** * `true` if no records are buffered. */ isEmpty(): boolean; /** * Install (idempotently) the global tracing subscriber. `level` is * an `EnvFilter` string — e.g. `"info"`, `"debug"`, * `"info,ezu_graph::eval=debug"`. Honoured on first call only. */ constructor(level: string); /** * Set (or clear with `null` / `undefined`) the per-event JS * callback. The callback receives a structured record object. * * No-op in multithreaded (`threads`) builds — events can originate * on rayon worker threads, so live forwarding to a main-thread JS * callback isn't available. Use `drain` / `drainLines` instead. */ onEvent(callback?: Function | null): void; /** * Resize the ring-buffer cap. Older entries are evicted FIFO once * the buffer reaches the new cap. Default is 4096. */ setCapacity(cap: number): void; /** * Number of records currently buffered. */ readonly len: number; } /** * Stateful WASM renderer. * * Every method takes `&self` and borrows the renderer inside, rather than * letting wasm-bindgen hold a borrow for the length of the call: * `renderFrame` awaits JS between its tiles, and the loads and read-only * queries a tile's `sources` makes (`loadSource`, `sourceTile`, …) have to * reach the same * renderer while the frame is still rendering. The `Rc` is what the * frame's promise keeps alive between tiles. */ export class Renderer { free(): void; [Symbol.dispose](): void; /** * Bind raw tile bytes under a `sources.` entry from the style. * The renderer dispatches on the source's declared `type`: * * - `mvt` / `pmtiles` → store raw MVT bytes per `(dx, dy)` neighbour * offset (centre `coord: [0, 0]`, the default). Layers are bound as * `.` (centre) or `.@dx,dy` * (neighbours) when [`render_tile`](Self::render_tile) runs. Binding only the centre * degrades cross-tile label collision to centre-only at borders. * - `dem` / `raster` → store the raw bytes per `(dx, dy)` neighbour * offset. The centre tile is `coord: [0, 0]` (default). Decoding * and 3×3 stitching happen at render time once the tile id is known. * - `geojson` (remote) → store raw bytes per `(dx, dy)` offset; * projected per tile (and neighbour) at render time. The document * bound at the centre also serves any neighbour left unbound. * * `opts` is a JS object: `{ coord?: [dx, dy], sourceZoom?: number }`. * * `sourceZoom` declares that MVT bytes are natively encoded at a * *shallower* zoom than the tile being rendered — a vector source * that stops at its `maxzoom` while the host serves deeper tiles. * The renderer then reprojects each payload from its own ancestor * into the tile's frame before rendering (MVT "overzoom"), which is * what a client would otherwise do by scaling a raster up. The * ancestor is derived, not supplied: for a tile at zoom `z`, the * ancestor at `sourceZoom` is unique, so a host that binds the * `maxzoom` tile it fetched has nothing further to compute — and * each neighbour resolves against its own ancestor, which for a 3×3 * window may be a different parent than the centre's. * * `sourceZoom` equal to the rendered zoom is accepted and does * nothing, so a host can pass its source's `maxzoom` unconditionally * and let shallow tiles take the ordinary path. Deeper than the * rendered zoom throws `UnknownSource`: there is no way to invent * detail the bytes do not carry. * * Throws `UnknownSource` if `name` doesn't match any entry in the * style's `sources` block, `MvtDecode` if MVT bytes don't parse, and * `DemDecode` for non-image DEM bytes (the decode itself runs at * render time, but obvious cases are caught here). */ bindSource(name: string, bytes: Uint8Array, opts?: object | null): void; /** * Names of every source with at least one pending binding. * Order matches the style's `sources` declaration order. */ boundSources(): string[]; /** * Go back to the render cache's default size. Throws * `FrameInProgress` while a `renderFrame` holds the renderer. */ clearCacheBudget(): void; /** * Lift the cap `setGlyphBudget` put on the glyph bank, back to where a * fresh renderer starts. It frees nothing: what is resident stays * resident, and stops being trimmed. Throws `FrameInProgress` while a * `renderFrame` holds the renderer. */ clearGlyphBudget(): void; /** * Drop every pending source binding. Call between tile renders. */ clearSources(): void; /** * Go back to rendering at the style's own `tile-size`, undoing * `setTileSize`. */ clearTileSize(): void; /** * Where a print frame sits on the tile grid: the zoom and tile size * that meet `req`'s scale, and the tiles that cover it — the * arithmetic `ezu frame` does before it renders anything, done by the * same code, so a frame computed here is the one the CLI would render. * * `req` is `{ centerLon, centerLat, scale, dpi, width, height, zoom?, * styleTileSize? }`: `scale` is the denominator (1000 for 1:1000), * `width` and `height` the output size in pixels. `zoom` fixes the * zoom, as the CLI's `--zoom` does; left out, the zoom chosen keeps * the tile size nearest `styleTileSize`, which defaults to this * renderer's style. * * The answer is `{ zoom, tileSize, scale, width, height, left, top, * shift: [x, y], tilesX: [start, end], tilesY: [start, end] }`. Hand * it to `renderFrame`, or render tiles `tilesX × tilesY` (end * exclusive) at `zoom` and `tileSize` yourself: tile `(x, y)` lands * with its top-left at `(x · tileSize − left, y · tileSize − top)`, * cropped to `width × height`. `scale` is the denominator actually * met, and `shift` how far rounding the frame onto whole pixels moved * it. * * It changes nothing on the renderer. A request out of its domain (a * non-positive scale, a latitude past the Mercator edge, a zero-sized * output), a frame across the antimeridian, and a scale that needs a * tile size outside 16..8192 px all throw `InvalidStyle`. */ computeFrame(req: FrameRequest): Frame; /** * Start gathering what features nodes hold over `frame`'s page, for a * host that renders the frame's tiles itself — with `tileSize` set to * the frame's, say — rather than through `renderFrameWithFeatures`, * which makes and drives one of its own. `request` is * `renderFrameWithFeatures`'s `{ nodes: [{ node, key? }], coords? }`. * Render each of the frame's tiles with the collector's `renderTile`, * in any order, then `finish()`. * * It changes nothing about what the renderer draws, so it works while * a `renderFrame` holds the renderer. Throws `InvalidStyle` for what * `renderFrameWithFeatures` refuses, here, before anything renders. */ frameFeatures(frame: Frame, request: FrameFeatures): FrameFeatureCollector; /** * The style's declared `legend`, or `undefined` when it declares * none. Pass a zoom to keep only the entries that apply there. * * Entries name the node that draws the symbol rather than restating * a colour, so a host lays out the labels and asks the map itself * for the swatches. The CLI's `ezu legend` renders those swatches; * in a browser, render the named node. */ legend(zoom?: number | null): any; /** * Decode a tile-scoped source's bytes — `mvt`, `pmtiles`, `dem`, * `raster`, or a remote `geojson` document — once, into a * `SourceData` that any number of `SourceSet`s can hold without * decoding it again. * * A host rendering a block of tiles loads each tile it fetched once * and binds it into the set of every tile it borders, rather than * decoding it as the centre of one tile and again as a neighbour of * each of the others. Nothing about what the renderer draws changes, * so this works while a `renderFrame` holds the renderer, which is * where a frame's callback loads its tiles. * * Throws `UnknownSource` if `name` is not declared, or is a kind bound * into the renderer itself with `bindSource` (brush, image, sprite, * font, glyphs), and the matching decode kind if the bytes do not * parse. Unlike `bindSource`, a DEM or imagery tile is decoded here, * so its decode error is thrown here and not from the render. */ loadSource(name: string, bytes: Uint8Array): SourceData; /** * What this renderer is holding, in bytes, so a host can shed load * *before* an allocation fails rather than after. * * Returns a JS object: * - `heapBytes` — wasm linear memory committed to the **module**, * shared by every `Renderer` in this instance. This is the number * that meets an isolate's memory cap. It is a high-water mark: * freeing Rust values returns them to the allocator, never to the * host, so it only ever grows. * - `glyphBytes` / `glyphRanges` — SDF bitmaps resident in the * glyph bank, and how many 256-codepoint blocks they span. Glyphs * accumulate for the life of the renderer and survive * `clearSources`, so on a long-lived instance this is usually * what grew. `glyphBudget` is the per-fontstack ceiling * `setGlyphBudget` put on them, or `Infinity` if none — note * `glyphBytes` totals *every* fontstack, so it can exceed the * budget legitimately. * - `fontBytes` — outline font files held in the font bank. * - `imageBytes` — decoded pixels of bound images and sprite * atlases. * - `cacheBytes` / `cacheBudget` — the render cache's pixel * payload against its own eviction budget; it bounds itself, so * `cacheBytes` near `cacheBudget` is steady state, not a leak. * * These are payload sizes, not an accounting of the heap: they omit * allocator overhead, decoded features, per-font glyph-path caches, * and the buffers a render is using right now. Expect the parts to * sum to less than `heapBytes`. */ memoryUsage(): object; /** * Codepoints the currently bound features can require, as * `{ [glyphsSourceName]: number[] }` sorted ascending. * * This is the precise form of * [`neededGlyphRanges`](Self::needed_glyph_ranges): a host that * can build its own glyph PBF — one message holding just these * codepoints — transfers only the glyphs the tile draws instead * of the whole 256-codepoint block around each of them. On CJK * labels that is the difference between a few thousand glyphs and * a few tens of megabytes. `bindSource` files each glyph by its * own id, so such a subset may span any number of blocks and * needs no particular `range` string. * * Hosts that can only fetch whole `{range}.pbf` files off a * MapLibre glyphs endpoint want `neededGlyphRanges` instead. Both * calls see the same set of codepoints and carry the same * over-approximation caveat. */ neededCodepoints(): object; /** * `neededCodepoints` for the features in `set` rather than the ones * bound to the renderer: what to bind into the glyphs sources before * rendering from it. */ neededCodepointsIn(set: SourceSet): object; /** * Glyph ranges the currently bound features can require, as * `{ [glyphsSourceName]: number[] }` where each number is a range * start (`0`, `256`, `512`, …) — i.e. the `{range}` in a * `…/{fontstack}/{range}.pbf` URL is `-`. * * This host cannot fetch glyph ranges lazily, so every range a * tile's labels touch must be bound before `renderTile`. Rather than * scraping every string in the MVT, call this after binding the * vector sources and bind exactly the listed ranges. * * A range holds 256 codepoints and a tile typically draws a * handful of them, so this is a coarse unit to fetch in. Hosts * that can assemble their own subset PBF should call * [`neededCodepoints`](Self::needed_codepoints) instead. * * It is an over-approximation, deliberately: a range is listed if * *any* feature in a text layer carries the codepoint in a property * the layer's `text` expression reads, without evaluating filters, * zoom ranges, or the expression itself, and it is listed for every * fontstack the layer can draw with: the stack its `font` names on * the `fonts` node wired to it, or every stack that node declares * when `font-expr` or a `format` section may pick another. So it * never omits a range a label needs, and it may name a few that go * unused. Text layers that build their string from something other * than a `get` of a feature property (a literal, a `concat` of * formatted values) contribute their literal text where it is a * plain string. * * An Arabic letter contributes the presentation-form ranges as * well as its own: it is drawn as whichever of its joined shapes * the letters around it call for, and those shapes live in * U+FB50‥U+FDFF and U+FE70‥U+FEFF. */ neededGlyphRanges(): object; /** * `neededGlyphRanges` for the features in `set` rather than the ones * bound to the renderer. */ neededGlyphRangesIn(set: SourceSet): object; /** * Build a renderer from a style JSON document. */ constructor(style_json: string); /** * Render every tile `frame` covers and copy each one's share into one * frame-sized buffer, which is what `ezu frame` does: the same tiles, * at the same tile size, cropped the same way. Resolves to straight * (un-premultiplied) RGBA, `width × height × 4` bytes, as * `format: "rgba"` is. * * The tile data stays yours to fetch, tile by tile, but it is handed * over as a value rather than bound: before each tile * `sources({ z, x, y }, binder)` is called with the tile about to * render, and the tile renders from the `SourceSet` it returns, as * `renderTileWith` does — the tile itself, the neighbours * `requestedNeighborOffsets` names, the ancestor `sourceTile` answers * past a source's max-zoom. A frame's tiles border each other, so keep * the `SourceData` `loadSource` gives you and put each one into the set * of every tile that reads it: each fetched tile is then decoded once, * not once per tile around it. The frame reads the set and leaves it * yours; returning one set for several tiles is fine. * * `sources` may return a promise, which is awaited, so it can fetch. * One that throws or rejects stops the frame with that error. It may * be `null` for a style that needs no tile data. The binder binds into * the renderer what a set turns out to need — the glyphs * `neededCodepointsIn` lists for it — with `binder.bindSource`, which * takes what `bindSource` does but refuses a tile-scoped source with * `UnknownSource`, since the frame never reads bound tile data. * Persistent sources (fonts, sprites, brushes, images) can equally be * bound once, before the call. After each tile the glyph banks are * trimmed to `setGlyphBudget`'s budget, as `renderTile` does. * * Until the promise settles the renderer is the frame's: everything * that would change what it draws — `bindSource`, `clearSources`, * `renderTile`, `trimGlyphs`, another `renderFrame` or * `renderFrameWithFeatures`, `setStyle`, `setTileSize`, * `clearTileSize`, `setGlyphBudget`, `clearGlyphBudget`, * `setCacheBudget`, `clearCacheBudget` — throws `FrameInProgress`, so a request running while `sources` awaits * cannot change the frame's tiles under it. `loadSource`, * `renderTileWith` and the queries that only read (`sourceTile`, * `requestedNeighborOffsets`, `neededCodepointsIn`, `boundSources`, …) * still work. A binder binds only for its own tile and only while that * tile's `sources` runs; kept and used later, it throws `StaleBinder`. * The renderer is given back however the frame ends, and the frame * binds no tile data, so it leaves none bound. * * The tiles render at `frame.tileSize` per render, so the renderer's * own tile size is left as it was. `opts` takes `renderTile`'s * `pad` and `params`; its `format` and `tileSize` must be left out * (or match), since the frame fixes both. * * Tiles render one after another, row by row from the top. */ renderFrame(frame: Frame, sources: ((tile: { z: number; x: number; y: number }, binder: FrameBinder) => SourceSet | Promise) | null | undefined, opts?: object | null): Promise; /** * `renderFrame`, also handing back what features nodes held over the * whole page: resolves to `{ image, features }`, where `image` is the * buffer `renderFrame` resolves to and `features` holds one * `{ node, geojson }` per entry of `request.nodes`, in that order. * `geojson` is a FeatureCollection as text, byte for byte the file * `ezu frame --features` writes for the same style, data and frame. * * `request` is `{ nodes: [{ node, key? }], coords? }`. `key` names the * properties that identify a feature across tiles — `["label-id", * "part"]` for `label-boxes`: features whose key properties are all * equal are written once, the first in reading order (rows top to * bottom, then left to right), and the page is sorted by the key. * Without one, every tile's features are written, so a feature several * tiles see appears once per tile. `coords` is `"lonlat"` (the * default), WGS84 to seven decimal places, or `"px"`, page pixels to * two. Features wholly off the page are left out; one that reaches * into it is written whole. * * The values are the ones each tile's render computed on its way to * the pixels, so this costs no second evaluation. A name that is not * a node of the style, or names one that produces something other * than features, and a key that names no property, reject with * `InvalidStyle` before anything renders. */ renderFrameWithFeatures(frame: Frame, sources: ((tile: { z: number; x: number; y: number }, binder: FrameBinder) => SourceSet | Promise) | null | undefined, request: FrameFeatures, opts?: object | null): Promise; /** * Render a single tile using whatever sources are currently bound. * * `opts` (JS object, all fields optional): * - `format`: `"png"` (default) / `"webp"` / `"rgba"` * - `tileSize`, `pad`: override the style's canvas size for this * call, in style pixels (a larger tile draws finer) * - `pixelRatio`: device pixels per style pixel, 1 to 4 (default 1). * `2` renders a retina tile: twice the size, with every width, text * size and blur doubled, the way `window.devicePixelRatio` scales * a MapLibre map * - `params`: `{ name: number | boolean | string }` — render-time * overrides for the style's declared `params`, validated the same * way the CLI's `--param` is. Omitted names keep their declared * default. * - `png`: `{ compression?: "fast" | "default" | "best" }` */ renderTile(z: number, x: number, y: number, opts?: object | null): Uint8Array; /** * Render a single tile from the tile data in `set`, as `renderTile` * does from what is bound. Nothing tile-scoped that `bindSource` bound * is read; the fonts, sprites, brushes, images and glyphs bound into * the renderer are. `opts` is `renderTile`'s. * * It changes nothing a later render depends on, so it needs no * `clearSources` and works while a `renderFrame` holds the renderer. * It does not bring the glyph banks back under a budget set with * `setGlyphBudget`, as `renderTile` does after each render; call * `trimGlyphs()` when a batch of renders is done. */ renderTileWith(z: number, x: number, y: number, set: SourceSet, opts?: object | null): Uint8Array; /** * `renderTileWith`, also handing back what each of `nodes` — ids of * nodes that produce features — held when the render finished, in the * order given: `{ image, features }`, where `image` is the bytes * `renderTileWith` returns and `features` holds one * `{ node, extent, geojson }` per name, `geojson` being a GeoJSON * FeatureCollection as text — the shape `renderFrameWithFeatures` and * the Go package hand back too. * * Each entry carries the node's id as `node` and the tile's size * in geometry units as `extent`: coordinates run `0..extent` across * the tile, `x` right and `y` down from its top-left corner. A node the * render never reached — a branch a `switch` did not take — has no * `extent` and no features. The values are the ones the render * computed on its way to the pixels, so this costs no second * evaluation. * * `nodes` is an array of ids, or `{ nodes, coords }` to write the * geometry in other coordinates: `coords` is `"tile"` (the default, * tile units as above), `"lonlat"` (WGS84, seven decimals) or `"px"` * (the rendered tile's pixels from its top-left corner, two decimals, * at the tile size the render drew at). * * Throws `InvalidStyle` before anything renders when a name is not a * node of the style, or names one that produces something other than * features, and for a `coords` it does not know. */ renderTileWithFeatures(z: number, x: number, y: number, set: SourceSet, nodes: string[] | TileFeatures, opts?: object | null): TileWithFeatures; /** * Neighbour tile offsets the active style actually asks for from * `source`, as an array of `[dx, dy]` pairs (never including the * centre `[0, 0]`). * * Cross-tile label collision and edge-continuous DEM/raster shading * are the only things that read neighbours, and only for the sources * they name. Pass each offset from this list to * `bindSource(name, bytes, { coord })` and the render gets exactly * what the recipe needs — neither a blind 3×3 per source nor, more * costly, a window short of what a stitched source wanted. An empty * array means the centre tile is enough. * * What comes back depends on the source's kind. A vector source * answers from the graph: a node that wants a neighbour names it, * and cross-tile label collision is usually the only thing that * does, so the list is often empty. A `dem` or `raster` source * answers from its own `neighbor-fetch`, which defaults to on and * means the whole 3×3 — those bind as one stitched canvas, and a * neighbour left unbound is not a missing collision candidate but a * pad filled by clamping the tile's own edge, which shows up as a * seam in whatever samples it. `neighbor-fetch: false` reports * nothing whatever the graph asks for; so does a source no node in * the graph reads. A `geojson` document covers every tile, so the one * bound at the centre also serves each offset listed for it; binding * it there as well changes nothing. * * Throws `UnknownSource` if `name` is not declared in the style. */ requestedNeighborOffsets(name: string): Array; /** * Let the render cache hold up to `bytes` of pixels instead of its * default (8 MiB). The cache keeps intermediate results a later render * can reuse — most of all what a world-anchored node computes, which * every tile around it reads too — so a host rendering many * neighbouring tiles with memory to spare renders them faster with * more, and one in a memory-capped isolate can hold it to less. * `memoryUsage().cacheBudget` reports it back. * * The cache starts empty at the new size, and keeps the size through * `setStyle` and `setTileSize`. Throws `FrameInProgress` while a * `renderFrame` holds the renderer. */ setCacheBudget(bytes: number): void; /** * Cap the glyph bytes each bound fontstack keeps resident, in * bytes. Unset, a fontstack keeps every range ever bound to it for * the life of the renderer — `clearSources` does not touch glyphs, * and on a long-lived instance rendering across a basemap that is * usually what grew. * * Trimming happens **after** each `renderTile`, not while binding, * so a render never loses glyphs that were bound for it. The tile * that just drew is therefore the most recently used, and a budget * large enough for one tile's glyphs always keeps that tile's; what * goes is what earlier tiles needed and this one did not. Set it * below one tile's worth and the ceiling still holds — the stack * empties after every render and nothing carries over, which * renders correctly but buys no reuse. * * It is a per-fontstack ceiling: a style with a regular, a medium * and an italic stack can hold three times what is set here. * * This host cannot refetch, so anything trimmed must be bound again * before the next tile that needs it. `neededCodepoints()` already * names exactly what to bind, and a host that re-binds every tile * (rather than tracking what it sent) needs no other change. * * `clearGlyphBudget()` lifts the cap again. So does a budget of * `0xFFFFFFFF` — the largest value this host can express, since an * address here is 32 bits — which is what * `memoryUsage().glyphBudget` reports as `Infinity`. A number that * big cannot be a real ceiling: it is every byte the module could * ever address. */ setGlyphBudget(bytes: number): void; /** * Replace the active style. Returns the new node count. Invalidates * the intermediate cache, drops any pending source bindings, and * goes back to the new style's own tile size. */ setStyle(style_json: string): number; /** * Render every tile at `size` px instead of the style's `tile-size`, * without editing the style. `clearTileSize()` goes back to the * style's, and so does `setStyle`. * * A print frame needs it: `computeFrame` meets the scale by choosing * the tile size, and the frame's tiles must be drawn at exactly that * size. It renders what the style with its `tile-size` edited would. * Nothing you bind depends on it — `requestedNeighborOffsets` and * `sourceTile` answer as before — and the intermediate cache, which is * sized by the tile, is dropped when the size changes. `tileSize` * keeps reporting the style's own, and a `tileSize` in one * `renderTile`'s options still wins over this. * * Throws `InvalidStyle` for a size below 1 px: `0` is not "the * style's", that is `clearTileSize`. */ setTileSize(size: number): void; /** * The tile a host should actually fetch from `name` in order to draw * `z/x/y`, as `{ z, x, y }`. * * For a source that declares `max-zoom`, a request past the ceiling * answers with the covering ancestor — bind those bytes with * `{ sourceZoom: }` and the renderer resamples or * reprojects them into the requested tile. Below the ceiling, and for * a source that declares no ceiling, the answer is the tile itself. * * This exists so the ceiling lives in one place. A host that hard-codes * the maxzoom of each source keeps a second copy of something the style * already states, and the two drift. * * `x` and `y` may be off the tile grid, which is what a host walking * a neighbourhood hands in: `x` wraps around the antimeridian, so * the western neighbour of `z/0/y` is the real tile at the far side * of the world. `y` does not wrap — there is no tile above the north * pole — and an out-of-range row comes back unchanged, so the fetch * for it misses and the stitch clamps that edge, which is what the * pole should look like. * * Throws `UnknownSource` if `name` is not declared in the style. */ sourceTile(name: string, z: number, x: number, y: number): any; /** * Every source the style declares, in declaration order, as an array * of `{ name, type, tileScoped, url?, indexUrl? }`. * * This is what a host walks before it fetches anything: `type` is the * style's own word for the kind (`"mvt"`, `"dem"`, `"glyphs"`, …) and * says what `bindSource` will do with the bytes, and `url` is where * they come from — an XYZ template for a tile pyramid, a document * URL, or, for `glyphs`, the endpoint with `{fontstack}` already * substituted and `{range}` left to fill in per block. `boundSources` * answers the opposite question, what is already bound, and cannot * start the loop. * * `tileScoped` says whether a binding of that kind is dropped by * `clearSources` and has to be rebound for the next tile; the rest go * into the persistent banks and are bound once. * * `url` is absent only for a `geojson` source with inline `data`: the * style carries the payload, so there is nothing to fetch and nothing * to bind. `indexUrl` appears on a `sprite` source whose index is a * URL rather than inline — fetch it and pass the text as * `bindSource(name, atlasBytes, { index })`. */ sources(): Array; /** * Bring every bound fontstack back under the budget `setGlyphBudget` * set; a no-op without one. `renderTile` does this after each render; * after `renderTileWith`, call it yourself once a batch is done. * Trimming can drop glyphs a frame bound for its next tile, so it * throws `FrameInProgress` while a `renderFrame` holds the renderer, * which trims after each of its tiles itself. */ trimGlyphs(): void; /** * Effective attribution declared by the style (document + * sources), joined with ` | `. Upstream TileJSON / PMTiles * metadata is the JS host's concern — merge it on that side. */ readonly attribution: string | undefined; /** * JSON Schema for the current style's `params` — types, defaults, * ranges, descriptions. The same document the CLI's tile server * serves at `/style/params`. Generate sliders and colour pickers * from this rather than parsing the style; it follows `setStyle`, * so a params panel driven off it cannot drift from the graph * being rendered. */ readonly paramsSchema: any; /** * The tile size renders use: the one `setTileSize` set, or else the * style's `tile-size`. A `tileSize` in one render's options still wins * over it. */ readonly renderTileSize: number; /** * `tile-size` declared by the current style, whatever `setTileSize` * renders at. */ readonly tileSize: number; /** * What building the current style's graph warned about: each names a * node that works but relies on something the style does not say out * loud. They are also logged when the style is built; this is for * reporting or checking them on your own terms. Follows `setStyle`. */ readonly warnings: string[]; } /** * One tile-scoped payload — a vector tile, a DEM or imagery tile, a * GeoJSON document — decoded once by `Renderer.loadSource` and ready to * sit in any number of `SourceSet`s. * * A set keeps what it holds alive, so `free()` once the sets that need it * have it, or leave it to the garbage collector. It is not tied to the * renderer that loaded it: renderers in one module share a heap, and a * render checks that its style declares the source the way the data was * loaded for. */ export class SourceData { private constructor(); free(): void; [Symbol.dispose](): void; /** * The `sources.` entry the data was loaded for. */ readonly source: string; } /** * Every tile-scoped payload one render reads, each at its place in the * 3×3 neighbourhood: the binding table `bindSource` fills, as a value you * build per tile and hand to `renderTileWith`. * * A set says nothing about the tile it is for — offsets are relative — so * pairing each tile with its neighbourhood is yours to do. Fonts, sprites, * brushes, images and glyphs are not here: they belong to the renderer, * bound once with `bindSource` and read by every render. */ export class SourceSet { free(): void; [Symbol.dispose](): void; /** * Put `data` at `opts.coord` for its source, replacing what was * there. `opts` is `bindSource`'s `{ coord?: [dx, dy], sourceZoom? }`: * `sourceZoom` says the data is an ancestor's, to be resampled or * reprojected into the tile. The set shares the data rather than * copying it. * * Throws `UnknownSource` when the source already holds data of * another kind, and for the `coord` and `sourceZoom` `bindSource` * refuses. */ bind(data: SourceData, opts?: object | null): void; /** * A copy of the set. It holds the same data, which is shared rather * than copied, so this costs a few references per entry. */ clone(): SourceSet; /** * Whether anything is bound for `source`. */ contains(source: string): boolean; /** * Whether nothing is bound at all. */ isEmpty(): boolean; /** * An empty set: a render from it draws what the style draws with no * tile data at all. */ constructor(); } /** * Wasm linear memory currently committed to this module, in bytes. * * This is the figure an isolate's memory cap applies to, and the one * to watch to shed load before an allocation fails — a refused * `memory.grow` throws `OutOfMemory` (see the `oom` module) and ends the * instance. * It never falls: freed Rust values return to the allocator for reuse, * but wasm cannot hand pages back to the host. So a drop in demand * leaves the number where its peak left it, and only a fresh instance * resets it. * * Module-wide, not per-`Renderer`. For what a given renderer is * holding, and which bank to evict, call `memoryUsage()`. */ export function heapBytes(): number; /** * The number of node ops registered in this module. It is the smoke test * for the module's life-before-main constructors: zero means they never * ran, and every style is about to fail with "unknown op". The Go * package's `OpCount`; a Rust host reads the registry itself, through * `ezu::paint::nodes::default_registry()`. */ export function opCount(): number; /** * Every registered node op, by name: which ops this build has, not just * how many. The Go package's `OpNames`. */ export function opNames(): string[]; /** * Whether the wasm binary was compiled with `+simd128`. Lets the demo * page label the renderer build accurately. */ export function simdEnabled(): boolean; /** * Whether this build supports multithreaded rendering (compiled with * the `threads` feature). When `false`, `initThreadPool` is absent and * `renderTile`'s `parallel` option is a no-op. Mirrors `simdEnabled` so * the host can label the build. */ export function threadsEnabled(): boolean; /** * Translate a MapLibre GL style into an ezu style, as `ezu translate` * does. Throws `InvalidStyle` for a style that is not JSON or that the * translator refuses, and for malformed options. The Go package's * `Runtime.TranslateMapLibre`; a Rust host calls * `ezu::translate::maplibre::convert`. */ export function translateMapLibre(style_json: string, options: TranslateOptions): Translation; export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; export interface InitOutput { readonly memory: WebAssembly.Memory; readonly __wbg_framebinder_free: (a: number, b: number) => void; readonly __wbg_framefeaturecollector_free: (a: number, b: number) => void; readonly __wbg_logsink_free: (a: number, b: number) => void; readonly __wbg_renderer_free: (a: number, b: number) => void; readonly __wbg_sourcedata_free: (a: number, b: number) => void; readonly __wbg_sourceset_free: (a: number, b: number) => void; readonly framebinder_bindSource: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number]; readonly framefeaturecollector_finish: (a: number) => [number, number, number]; readonly framefeaturecollector_renderTile: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number]; readonly heapBytes: () => number; readonly logsink_clear: (a: number) => void; readonly logsink_drain: (a: number) => any; readonly logsink_drainLines: (a: number) => [number, number]; readonly logsink_isEmpty: (a: number) => number; readonly logsink_len: (a: number) => number; readonly logsink_new: (a: number, b: number) => [number, number, number]; readonly logsink_onEvent: (a: number, b: number) => void; readonly logsink_setCapacity: (a: number, b: number) => void; readonly opCount: () => number; readonly opNames: () => [number, number]; readonly renderer_attribution: (a: number) => [number, number]; readonly renderer_bindSource: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number]; readonly renderer_boundSources: (a: number) => [number, number]; readonly renderer_clearCacheBudget: (a: number) => [number, number]; readonly renderer_clearGlyphBudget: (a: number) => [number, number]; readonly renderer_clearSources: (a: number) => [number, number]; readonly renderer_clearTileSize: (a: number) => [number, number]; readonly renderer_computeFrame: (a: number, b: any) => [number, number, number]; readonly renderer_frameFeatures: (a: number, b: any, c: any) => [number, number, number]; readonly renderer_legend: (a: number, b: number) => [number, number, number]; readonly renderer_loadSource: (a: number, b: number, c: number, d: number, e: number) => [number, number, number]; readonly renderer_memoryUsage: (a: number) => [number, number, number]; readonly renderer_neededCodepoints: (a: number) => [number, number, number]; readonly renderer_neededCodepointsIn: (a: number, b: number) => [number, number, number]; readonly renderer_neededGlyphRanges: (a: number) => [number, number, number]; readonly renderer_neededGlyphRangesIn: (a: number, b: number) => [number, number, number]; readonly renderer_new: (a: number, b: number) => [number, number, number]; readonly renderer_paramsSchema: (a: number) => [number, number, number]; readonly renderer_renderFrame: (a: number, b: any, c: number, d: number) => any; readonly renderer_renderFrameWithFeatures: (a: number, b: any, c: number, d: any, e: number) => any; readonly renderer_renderTile: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number]; readonly renderer_renderTileSize: (a: number) => number; readonly renderer_renderTileWith: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number]; readonly renderer_renderTileWithFeatures: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => [number, number, number]; readonly renderer_requestedNeighborOffsets: (a: number, b: number, c: number) => [number, number, number]; readonly renderer_setCacheBudget: (a: number, b: number) => [number, number]; readonly renderer_setGlyphBudget: (a: number, b: number) => [number, number]; readonly renderer_setStyle: (a: number, b: number, c: number) => [number, number, number]; readonly renderer_setTileSize: (a: number, b: number) => [number, number]; readonly renderer_sourceTile: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number]; readonly renderer_sources: (a: number) => [number, number, number]; readonly renderer_tileSize: (a: number) => number; readonly renderer_trimGlyphs: (a: number) => [number, number]; readonly renderer_warnings: (a: number) => [number, number]; readonly simdEnabled: () => number; readonly sourcedata_source: (a: number) => [number, number]; readonly sourceset_bind: (a: number, b: number, c: number) => [number, number]; readonly sourceset_clone: (a: number) => number; readonly sourceset_contains: (a: number, b: number, c: number) => number; readonly sourceset_isEmpty: (a: number) => number; readonly sourceset_new: () => number; readonly translateMapLibre: (a: number, b: number, c: number) => [number, number, number]; readonly threadsEnabled: () => number; readonly wasm_bindgen_40e41bdbc20eab45___convert__closures_____invoke___wasm_bindgen_40e41bdbc20eab45___JsValue__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_40e41bdbc20eab45___JsError___true_: (a: number, b: number, c: any) => [number, number]; readonly wasm_bindgen_40e41bdbc20eab45___convert__closures_____invoke___js_sys_d7d35d7b07b5c2c7___Function_fn_wasm_bindgen_40e41bdbc20eab45___JsValue_____wasm_bindgen_40e41bdbc20eab45___sys__Undefined___js_sys_d7d35d7b07b5c2c7___Function_fn_wasm_bindgen_40e41bdbc20eab45___JsValue_____wasm_bindgen_40e41bdbc20eab45___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void; readonly __wbindgen_malloc_command_export: (a: number, b: number) => number; readonly __wbindgen_realloc_command_export: (a: number, b: number, c: number, d: number) => number; readonly __wbindgen_exn_store_command_export: (a: number) => void; readonly __externref_table_alloc_command_export: () => number; readonly __wbindgen_externrefs: WebAssembly.Table; readonly __wbindgen_free_command_export: (a: number, b: number, c: number) => void; readonly __wbindgen_destroy_closure_command_export: (a: number, b: number) => void; readonly __externref_table_dealloc_command_export: (a: number) => void; readonly __externref_drop_slice_command_export: (a: number, b: number) => void; readonly __wbindgen_start: () => void; } export type SyncInitInput = BufferSource | WebAssembly.Module; /** * Instantiates the given `module`, which can either be bytes or * a precompiled `WebAssembly.Module`. * * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated. * * @returns {InitOutput} */ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput; /** * If `module_or_path` is {RequestInfo} or {URL}, makes a request and * for everything else, calls `WebAssembly.instantiate` directly. * * @param {{ module_or_path: InitInput | Promise }} module_or_path - Passing `InitInput` directly is deprecated. * * @returns {Promise} */ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise } | InitInput | Promise): Promise;