@reearth/ezu 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/simd/web/ezu.d.ts CHANGED
@@ -1,12 +1,162 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ /** What `computeFrame` is asked for: a print page as scale, dpi, size and centre. */
5
+ export interface FrameRequest {
6
+ /** The frame's centre in degrees (WGS84). The scale is matched at this latitude. */
7
+ centerLon: number;
8
+ centerLat: number;
9
+ /** The scale denominator: 1000 for 1:1000. */
10
+ scale: number;
11
+ /** The output resolution. Together with `scale` it fixes the ground size of a pixel. */
12
+ dpi: number;
13
+ /** The output size in pixels: `Math.round(mm / 25.4 * dpi)` from paper millimetres. */
14
+ width: number;
15
+ height: number;
16
+ /** Render at this zoom, deriving the tile size from it, as the CLI's `--zoom`. */
17
+ zoom?: number;
18
+ /** The tile size the chosen zoom aims at. Defaults to this renderer's style. */
19
+ styleTileSize?: number;
20
+ }
21
+
22
+ /** Where a print frame sits on the tile grid it renders from. */
23
+ export interface Frame {
24
+ /** The zoom the tiles render at. */
25
+ zoom: number;
26
+ /** The tile size, in whole pixels, the tiles render at. */
27
+ tileSize: number;
28
+ /** The scale denominator this zoom and tile size actually meet at the centre. */
29
+ scale: number;
30
+ /** The output size in pixels, as requested. */
31
+ width: number;
32
+ height: number;
33
+ /** The frame's top-left corner in world pixels at this zoom and tile size. */
34
+ left: number;
35
+ top: number;
36
+ /** How far rounding onto whole pixels moved the frame: the centre sits at (width/2 + shift[0], height/2 + shift[1]). */
37
+ shift: [number, number];
38
+ /** The tile columns and rows the frame touches, start inclusive, end exclusive. */
39
+ tilesX: [number, number];
40
+ tilesY: [number, number];
41
+ }
42
+
43
+
44
+
45
+ /** What one features node held when a render finished. */
46
+ export interface NodeFeatures {
47
+ /** The node's id, as it was asked for. */
48
+ node: string;
49
+ /** The tile's size in geometry units: coordinates run 0..extent, x right and y down. Absent when the render never reached the node. */
50
+ extent?: number;
51
+ /** A GeoJSON FeatureCollection as text, in the coordinates asked for (tile units by default), with `node` and `extent` members of its own. */
52
+ geojson: string;
53
+ }
54
+
55
+ /** Which features nodes `renderTileWithFeatures` reports on, and the coordinates it writes them in. */
56
+ export interface TileFeatures {
57
+ /** Node ids, in the order the collections come back. */
58
+ nodes: string[];
59
+ /** Tile units (the default), WGS84 longitude and latitude, or the rendered tile's pixels. */
60
+ coords?: "tile" | "lonlat" | "px";
61
+ }
62
+
63
+ /** What `renderTileWithFeatures` hands back. */
64
+ export interface TileWithFeatures {
65
+ /** The encoded tile, exactly as `renderTileWith` returns it. */
66
+ image: Uint8Array;
67
+ /** One collection per node asked for, in the order asked. */
68
+ features: NodeFeatures[];
69
+ }
70
+
71
+ /** Which features nodes `renderFrameWithFeatures` gathers over a page, and how it writes them. */
72
+ export interface FrameFeatures {
73
+ /** 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. */
74
+ nodes: Array<{ node: string; key?: string[] }>;
75
+ /** WGS84 longitude and latitude (the default), or page pixels. */
76
+ coords?: "lonlat" | "px";
77
+ }
78
+
79
+ /** What one features node held over a whole page. */
80
+ export interface PageFeatures {
81
+ /** The node's id, as it was asked for. */
82
+ node: string;
83
+ /** A GeoJSON FeatureCollection as text: byte for byte the file `ezu frame --features` writes. */
84
+ geojson: string;
85
+ }
86
+
87
+ /** What `renderFrameWithFeatures` hands back. */
88
+ export interface FrameWithFeatures {
89
+ /** The page, exactly as `renderFrame` resolves to it. */
90
+ image: Uint8Array;
91
+ /** One page of features per node asked for, in the order asked. */
92
+ features: PageFeatures[];
93
+ }
94
+
95
+
96
+
97
+ /**
98
+ * What `renderFrame` hands each tile's `sources`: `bindSource` into the
99
+ * renderer the frame has taken for itself, for what that tile's set needs
100
+ * bound there.
101
+ */
102
+ export class FrameBinder {
103
+ private constructor();
104
+ free(): void;
105
+ [Symbol.dispose](): void;
106
+ /**
107
+ * `Renderer.bindSource`, for the sources bound into the renderer
108
+ * itself: the glyphs a tile turns out to need, or a font, sprite,
109
+ * brush or image. Throws `UnknownSource` for a tile-scoped source,
110
+ * which the frame renders from the returned set and would never read
111
+ * here, and `StaleBinder` once this tile's `sources` has returned (or
112
+ * its promise settled).
113
+ */
114
+ bindSource(name: string, bytes: Uint8Array, opts?: object | null): void;
115
+ }
116
+
117
+ /**
118
+ * What `frameFeatures` returns: features nodes' values gathered over the
119
+ * tiles of a frame a host renders itself, assembled into the pages
120
+ * `renderFrameWithFeatures` hands back.
121
+ *
122
+ * The Rust renderer's collector is handed each tile's values after the
123
+ * render; here the tile renders through the collector, so the values stay
124
+ * in the module rather than crossing to JS and back. It keeps the
125
+ * renderer that made it alive until it is finished or freed.
126
+ */
127
+ export class FrameFeatureCollector {
128
+ private constructor();
129
+ free(): void;
130
+ [Symbol.dispose](): void;
131
+ /**
132
+ * The pages: one `{ node, geojson }` per entry of the request's
133
+ * `nodes`, in that order, as `renderFrameWithFeatures` hands them
134
+ * back. Tiles are read rows top to bottom, then left to right,
135
+ * whatever order they rendered in. The collector is used up.
136
+ */
137
+ finish(): PageFeatures[];
138
+ /**
139
+ * `renderTileWith` for one of the frame's tiles, also keeping what the
140
+ * collector's nodes held. Pass `tileSize: frame.tileSize` in `opts` to
141
+ * draw the tile `renderFrame` draws. Like `renderTileWith` it works
142
+ * while a `renderFrame` holds the renderer, and leaves the glyph
143
+ * budget to `trimGlyphs()`.
144
+ */
145
+ renderTile(z: number, x: number, y: number, set: SourceSet, opts?: object | null): Uint8Array;
146
+ }
147
+
4
148
  /**
5
149
  * Buffered log sink that captures `tracing` events from the renderer.
6
150
  *
7
151
  * Construct once near the top of your bootstrap, then either set a
8
152
  * callback for live forwarding (`onEvent(e => console.log(e))`) or
9
153
  * `drainLines()` periodically to flush into a UI panel.
154
+ *
155
+ * It is the Go package's `InitLog` and `DrainLogs` (the pull side) and
156
+ * `WithLogger` (the push side) in one object. A class rather than two
157
+ * free functions, because a browser host also wants the structured
158
+ * records and the callback, which a wasip1 module's line buffer has no
159
+ * room for; a Rust host installs its own `tracing` subscriber instead.
10
160
  */
11
161
  export class LogSink {
12
162
  free(): void;
@@ -57,6 +207,14 @@ export class LogSink {
57
207
 
58
208
  /**
59
209
  * Stateful WASM renderer.
210
+ *
211
+ * Every method takes `&self` and borrows the renderer inside, rather than
212
+ * letting wasm-bindgen hold a borrow for the length of the call:
213
+ * `renderFrame` awaits JS between its tiles, and the loads and read-only
214
+ * queries a tile's `sources` makes (`loadSource`, `sourceTile`, …) have to
215
+ * reach the same
216
+ * renderer while the frame is still rendering. The `Rc` is what the
217
+ * frame's promise keeps alive between tiles.
60
218
  */
61
219
  export class Renderer {
62
220
  free(): void;
@@ -68,7 +226,7 @@ export class Renderer {
68
226
  * - `mvt` / `pmtiles` → store raw MVT bytes per `(dx, dy)` neighbour
69
227
  * offset (centre `coord: [0, 0]`, the default). Layers are bound as
70
228
  * `<source>.<layer>` (centre) or `<source>.<layer>@dx,dy`
71
- * (neighbours) when [`render_tile`] runs. Binding only the centre
229
+ * (neighbours) when [`render_tile`](Self::render_tile) runs. Binding only the centre
72
230
  * degrades cross-tile label collision to centre-only at borders.
73
231
  * - `dem` / `raster` → store the raw bytes per `(dx, dy)` neighbour
74
232
  * offset. The centre tile is `coord: [0, 0]` (default). Decoding
@@ -107,10 +265,69 @@ export class Renderer {
107
265
  * Order matches the style's `sources` declaration order.
108
266
  */
109
267
  boundSources(): string[];
268
+ /**
269
+ * Go back to the render cache's default size. Throws
270
+ * `FrameInProgress` while a `renderFrame` holds the renderer.
271
+ */
272
+ clearCacheBudget(): void;
273
+ /**
274
+ * Lift the cap `setGlyphBudget` put on the glyph bank, back to where a
275
+ * fresh renderer starts. It frees nothing: what is resident stays
276
+ * resident, and stops being trimmed. Throws `FrameInProgress` while a
277
+ * `renderFrame` holds the renderer.
278
+ */
279
+ clearGlyphBudget(): void;
110
280
  /**
111
281
  * Drop every pending source binding. Call between tile renders.
112
282
  */
113
283
  clearSources(): void;
284
+ /**
285
+ * Go back to rendering at the style's own `tile-size`, undoing
286
+ * `setTileSize`.
287
+ */
288
+ clearTileSize(): void;
289
+ /**
290
+ * Where a print frame sits on the tile grid: the zoom and tile size
291
+ * that meet `req`'s scale, and the tiles that cover it — the
292
+ * arithmetic `ezu frame` does before it renders anything, done by the
293
+ * same code, so a frame computed here is the one the CLI would render.
294
+ *
295
+ * `req` is `{ centerLon, centerLat, scale, dpi, width, height, zoom?,
296
+ * styleTileSize? }`: `scale` is the denominator (1000 for 1:1000),
297
+ * `width` and `height` the output size in pixels. `zoom` fixes the
298
+ * zoom, as the CLI's `--zoom` does; left out, the zoom chosen keeps
299
+ * the tile size nearest `styleTileSize`, which defaults to this
300
+ * renderer's style.
301
+ *
302
+ * The answer is `{ zoom, tileSize, scale, width, height, left, top,
303
+ * shift: [x, y], tilesX: [start, end], tilesY: [start, end] }`. Hand
304
+ * it to `renderFrame`, or render tiles `tilesX × tilesY` (end
305
+ * exclusive) at `zoom` and `tileSize` yourself: tile `(x, y)` lands
306
+ * with its top-left at `(x · tileSize − left, y · tileSize − top)`,
307
+ * cropped to `width × height`. `scale` is the denominator actually
308
+ * met, and `shift` how far rounding the frame onto whole pixels moved
309
+ * it.
310
+ *
311
+ * It changes nothing on the renderer. A request out of its domain (a
312
+ * non-positive scale, a latitude past the Mercator edge, a zero-sized
313
+ * output), a frame across the antimeridian, and a scale that needs a
314
+ * tile size outside 16..8192 px all throw `InvalidStyle`.
315
+ */
316
+ computeFrame(req: FrameRequest): Frame;
317
+ /**
318
+ * Start gathering what features nodes hold over `frame`'s page, for a
319
+ * host that renders the frame's tiles itself — with `tileSize` set to
320
+ * the frame's, say — rather than through `renderFrameWithFeatures`,
321
+ * which makes and drives one of its own. `request` is
322
+ * `renderFrameWithFeatures`'s `{ nodes: [{ node, key? }], coords? }`.
323
+ * Render each of the frame's tiles with the collector's `renderTile`,
324
+ * in any order, then `finish()`.
325
+ *
326
+ * It changes nothing about what the renderer draws, so it works while
327
+ * a `renderFrame` holds the renderer. Throws `InvalidStyle` for what
328
+ * `renderFrameWithFeatures` refuses, here, before anything renders.
329
+ */
330
+ frameFeatures(frame: Frame, request: FrameFeatures): FrameFeatureCollector;
114
331
  /**
115
332
  * The style's declared `legend`, or `undefined` when it declares
116
333
  * none. Pass a zoom to keep only the entries that apply there.
@@ -121,6 +338,26 @@ export class Renderer {
121
338
  * in a browser, render the named node.
122
339
  */
123
340
  legend(zoom?: number | null): any;
341
+ /**
342
+ * Decode a tile-scoped source's bytes — `mvt`, `pmtiles`, `dem`,
343
+ * `raster`, or a remote `geojson` document — once, into a
344
+ * `SourceData` that any number of `SourceSet`s can hold without
345
+ * decoding it again.
346
+ *
347
+ * A host rendering a block of tiles loads each tile it fetched once
348
+ * and binds it into the set of every tile it borders, rather than
349
+ * decoding it as the centre of one tile and again as a neighbour of
350
+ * each of the others. Nothing about what the renderer draws changes,
351
+ * so this works while a `renderFrame` holds the renderer, which is
352
+ * where a frame's callback loads its tiles.
353
+ *
354
+ * Throws `UnknownSource` if `name` is not declared, or is a kind bound
355
+ * into the renderer itself with `bindSource` (brush, image, sprite,
356
+ * font, glyphs), and the matching decode kind if the bytes do not
357
+ * parse. Unlike `bindSource`, a DEM or imagery tile is decoded here,
358
+ * so its decode error is thrown here and not from the render.
359
+ */
360
+ loadSource(name: string, bytes: Uint8Array): SourceData;
124
361
  /**
125
362
  * What this renderer is holding, in bytes, so a host can shed load
126
363
  * *before* an allocation fails rather than after.
@@ -172,6 +409,12 @@ export class Renderer {
172
409
  * over-approximation caveat.
173
410
  */
174
411
  neededCodepoints(): object;
412
+ /**
413
+ * `neededCodepoints` for the features in `set` rather than the ones
414
+ * bound to the renderer: what to bind into the glyphs sources before
415
+ * rendering from it.
416
+ */
417
+ neededCodepointsIn(set: SourceSet): object;
175
418
  /**
176
419
  * Glyph ranges the currently bound features can require, as
177
420
  * `{ [glyphsSourceName]: number[] }` where each number is a range
@@ -204,17 +447,104 @@ export class Renderer {
204
447
  * U+FB50‥U+FDFF and U+FE70‥U+FEFF.
205
448
  */
206
449
  neededGlyphRanges(): object;
450
+ /**
451
+ * `neededGlyphRanges` for the features in `set` rather than the ones
452
+ * bound to the renderer.
453
+ */
454
+ neededGlyphRangesIn(set: SourceSet): object;
207
455
  /**
208
456
  * Build a renderer from a style JSON document.
209
457
  */
210
458
  constructor(style_json: string);
459
+ /**
460
+ * Render every tile `frame` covers and copy each one's share into one
461
+ * frame-sized buffer, which is what `ezu frame` does: the same tiles,
462
+ * at the same tile size, cropped the same way. Resolves to straight
463
+ * (un-premultiplied) RGBA, `width × height × 4` bytes, as
464
+ * `format: "rgba"` is.
465
+ *
466
+ * The tile data stays yours to fetch, tile by tile, but it is handed
467
+ * over as a value rather than bound: before each tile
468
+ * `sources({ z, x, y }, binder)` is called with the tile about to
469
+ * render, and the tile renders from the `SourceSet` it returns, as
470
+ * `renderTileWith` does — the tile itself, the neighbours
471
+ * `requestedNeighborOffsets` names, the ancestor `sourceTile` answers
472
+ * past a source's max-zoom. A frame's tiles border each other, so keep
473
+ * the `SourceData` `loadSource` gives you and put each one into the set
474
+ * of every tile that reads it: each fetched tile is then decoded once,
475
+ * not once per tile around it. The frame reads the set and leaves it
476
+ * yours; returning one set for several tiles is fine.
477
+ *
478
+ * `sources` may return a promise, which is awaited, so it can fetch.
479
+ * One that throws or rejects stops the frame with that error. It may
480
+ * be `null` for a style that needs no tile data. The binder binds into
481
+ * the renderer what a set turns out to need — the glyphs
482
+ * `neededCodepointsIn` lists for it — with `binder.bindSource`, which
483
+ * takes what `bindSource` does but refuses a tile-scoped source with
484
+ * `UnknownSource`, since the frame never reads bound tile data.
485
+ * Persistent sources (fonts, sprites, brushes, images) can equally be
486
+ * bound once, before the call. After each tile the glyph banks are
487
+ * trimmed to `setGlyphBudget`'s budget, as `renderTile` does.
488
+ *
489
+ * Until the promise settles the renderer is the frame's: everything
490
+ * that would change what it draws — `bindSource`, `clearSources`,
491
+ * `renderTile`, `trimGlyphs`, another `renderFrame` or
492
+ * `renderFrameWithFeatures`, `setStyle`, `setTileSize`,
493
+ * `clearTileSize`, `setGlyphBudget`, `clearGlyphBudget`,
494
+ * `setCacheBudget`, `clearCacheBudget` — throws `FrameInProgress`, so a request running while `sources` awaits
495
+ * cannot change the frame's tiles under it. `loadSource`,
496
+ * `renderTileWith` and the queries that only read (`sourceTile`,
497
+ * `requestedNeighborOffsets`, `neededCodepointsIn`, `boundSources`, …)
498
+ * still work. A binder binds only for its own tile and only while that
499
+ * tile's `sources` runs; kept and used later, it throws `StaleBinder`.
500
+ * The renderer is given back however the frame ends, and the frame
501
+ * binds no tile data, so it leaves none bound.
502
+ *
503
+ * The tiles render at `frame.tileSize` per render, so the renderer's
504
+ * own tile size is left as it was. `opts` takes `renderTile`'s
505
+ * `pad` and `params`; its `format` and `tileSize` must be left out
506
+ * (or match), since the frame fixes both.
507
+ *
508
+ * Tiles render one after another, row by row from the top.
509
+ */
510
+ renderFrame(frame: Frame, sources: ((tile: { z: number; x: number; y: number }, binder: FrameBinder) => SourceSet | Promise<SourceSet>) | null | undefined, opts?: object | null): Promise<Uint8Array>;
511
+ /**
512
+ * `renderFrame`, also handing back what features nodes held over the
513
+ * whole page: resolves to `{ image, features }`, where `image` is the
514
+ * buffer `renderFrame` resolves to and `features` holds one
515
+ * `{ node, geojson }` per entry of `request.nodes`, in that order.
516
+ * `geojson` is a FeatureCollection as text, byte for byte the file
517
+ * `ezu frame --features` writes for the same style, data and frame.
518
+ *
519
+ * `request` is `{ nodes: [{ node, key? }], coords? }`. `key` names the
520
+ * properties that identify a feature across tiles — `["label-id",
521
+ * "part"]` for `label-boxes`: features whose key properties are all
522
+ * equal are written once, the first in reading order (rows top to
523
+ * bottom, then left to right), and the page is sorted by the key.
524
+ * Without one, every tile's features are written, so a feature several
525
+ * tiles see appears once per tile. `coords` is `"lonlat"` (the
526
+ * default), WGS84 to seven decimal places, or `"px"`, page pixels to
527
+ * two. Features wholly off the page are left out; one that reaches
528
+ * into it is written whole.
529
+ *
530
+ * The values are the ones each tile's render computed on its way to
531
+ * the pixels, so this costs no second evaluation. A name that is not
532
+ * a node of the style, or names one that produces something other
533
+ * than features, and a key that names no property, reject with
534
+ * `InvalidStyle` before anything renders.
535
+ */
536
+ renderFrameWithFeatures(frame: Frame, sources: ((tile: { z: number; x: number; y: number }, binder: FrameBinder) => SourceSet | Promise<SourceSet>) | null | undefined, request: FrameFeatures, opts?: object | null): Promise<FrameWithFeatures>;
211
537
  /**
212
538
  * Render a single tile using whatever sources are currently bound.
213
539
  *
214
540
  * `opts` (JS object, all fields optional):
215
541
  * - `format`: `"png"` (default) / `"webp"` / `"rgba"`
216
542
  * - `tileSize`, `pad`: override the style's canvas size for this
217
- * call (hi-DPI / preview)
543
+ * call, in style pixels (a larger tile draws finer)
544
+ * - `pixelRatio`: device pixels per style pixel, 1 to 4 (default 1).
545
+ * `2` renders a retina tile: twice the size, with every width, text
546
+ * size and blur doubled, the way `window.devicePixelRatio` scales
547
+ * a MapLibre map
218
548
  * - `params`: `{ name: number | boolean | string }` — render-time
219
549
  * overrides for the style's declared `params`, validated the same
220
550
  * way the CLI's `--param` is. Omitted names keep their declared
@@ -222,6 +552,47 @@ export class Renderer {
222
552
  * - `png`: `{ compression?: "fast" | "default" | "best" }`
223
553
  */
224
554
  renderTile(z: number, x: number, y: number, opts?: object | null): Uint8Array;
555
+ /**
556
+ * Render a single tile from the tile data in `set`, as `renderTile`
557
+ * does from what is bound. Nothing tile-scoped that `bindSource` bound
558
+ * is read; the fonts, sprites, brushes, images and glyphs bound into
559
+ * the renderer are. `opts` is `renderTile`'s.
560
+ *
561
+ * It changes nothing a later render depends on, so it needs no
562
+ * `clearSources` and works while a `renderFrame` holds the renderer.
563
+ * It does not bring the glyph banks back under a budget set with
564
+ * `setGlyphBudget`, as `renderTile` does after each render; call
565
+ * `trimGlyphs()` when a batch of renders is done.
566
+ */
567
+ renderTileWith(z: number, x: number, y: number, set: SourceSet, opts?: object | null): Uint8Array;
568
+ /**
569
+ * `renderTileWith`, also handing back what each of `nodes` — ids of
570
+ * nodes that produce features — held when the render finished, in the
571
+ * order given: `{ image, features }`, where `image` is the bytes
572
+ * `renderTileWith` returns and `features` holds one
573
+ * `{ node, extent, geojson }` per name, `geojson` being a GeoJSON
574
+ * FeatureCollection as text — the shape `renderFrameWithFeatures` and
575
+ * the Go package hand back too.
576
+ *
577
+ * Each entry carries the node's id as `node` and the tile's size
578
+ * in geometry units as `extent`: coordinates run `0..extent` across
579
+ * the tile, `x` right and `y` down from its top-left corner. A node the
580
+ * render never reached — a branch a `switch` did not take — has no
581
+ * `extent` and no features. The values are the ones the render
582
+ * computed on its way to the pixels, so this costs no second
583
+ * evaluation.
584
+ *
585
+ * `nodes` is an array of ids, or `{ nodes, coords }` to write the
586
+ * geometry in other coordinates: `coords` is `"tile"` (the default,
587
+ * tile units as above), `"lonlat"` (WGS84, seven decimals) or `"px"`
588
+ * (the rendered tile's pixels from its top-left corner, two decimals,
589
+ * at the tile size the render drew at).
590
+ *
591
+ * Throws `InvalidStyle` before anything renders when a name is not a
592
+ * node of the style, or names one that produces something other than
593
+ * features, and for a `coords` it does not know.
594
+ */
595
+ renderTileWithFeatures(z: number, x: number, y: number, set: SourceSet, nodes: string[] | TileFeatures, opts?: object | null): TileWithFeatures;
225
596
  /**
226
597
  * Neighbour tile offsets the active style actually asks for from
227
598
  * `source`, as an array of `[dx, dy]` pairs (never including the
@@ -250,6 +621,20 @@ export class Renderer {
250
621
  * Throws `UnknownSource` if `name` is not declared in the style.
251
622
  */
252
623
  requestedNeighborOffsets(name: string): Array<any>;
624
+ /**
625
+ * Let the render cache hold up to `bytes` of pixels instead of its
626
+ * default (8 MiB). The cache keeps intermediate results a later render
627
+ * can reuse — most of all what a world-anchored node computes, which
628
+ * every tile around it reads too — so a host rendering many
629
+ * neighbouring tiles with memory to spare renders them faster with
630
+ * more, and one in a memory-capped isolate can hold it to less.
631
+ * `memoryUsage().cacheBudget` reports it back.
632
+ *
633
+ * The cache starts empty at the new size, and keeps the size through
634
+ * `setStyle` and `setTileSize`. Throws `FrameInProgress` while a
635
+ * `renderFrame` holds the renderer.
636
+ */
637
+ setCacheBudget(bytes: number): void;
253
638
  /**
254
639
  * Cap the glyph bytes each bound fontstack keeps resident, in
255
640
  * bytes. Unset, a fontstack keeps every range ever bound to it for
@@ -274,8 +659,9 @@ export class Renderer {
274
659
  * names exactly what to bind, and a host that re-binds every tile
275
660
  * (rather than tracking what it sent) needs no other change.
276
661
  *
277
- * A budget of `0xFFFFFFFF` — the largest value this host can express,
278
- * since an address here is 32 bits — lifts the cap again, and is what
662
+ * `clearGlyphBudget()` lifts the cap again. So does a budget of
663
+ * `0xFFFFFFFF` — the largest value this host can express, since an
664
+ * address here is 32 bits — which is what
279
665
  * `memoryUsage().glyphBudget` reports as `Infinity`. A number that
280
666
  * big cannot be a real ceiling: it is every byte the module could
281
667
  * ever address.
@@ -283,9 +669,28 @@ export class Renderer {
283
669
  setGlyphBudget(bytes: number): void;
284
670
  /**
285
671
  * Replace the active style. Returns the new node count. Invalidates
286
- * the intermediate cache and drops any pending source bindings.
672
+ * the intermediate cache, drops any pending source bindings, and
673
+ * goes back to the new style's own tile size.
287
674
  */
288
675
  setStyle(style_json: string): number;
676
+ /**
677
+ * Render every tile at `size` px instead of the style's `tile-size`,
678
+ * without editing the style. `clearTileSize()` goes back to the
679
+ * style's, and so does `setStyle`.
680
+ *
681
+ * A print frame needs it: `computeFrame` meets the scale by choosing
682
+ * the tile size, and the frame's tiles must be drawn at exactly that
683
+ * size. It renders what the style with its `tile-size` edited would.
684
+ * Nothing you bind depends on it — `requestedNeighborOffsets` and
685
+ * `sourceTile` answer as before — and the intermediate cache, which is
686
+ * sized by the tile, is dropped when the size changes. `tileSize`
687
+ * keeps reporting the style's own, and a `tileSize` in one
688
+ * `renderTile`'s options still wins over this.
689
+ *
690
+ * Throws `InvalidStyle` for a size below 1 px: `0` is not "the
691
+ * style's", that is `clearTileSize`.
692
+ */
693
+ setTileSize(size: number): void;
289
694
  /**
290
695
  * The tile a host should actually fetch from `name` in order to draw
291
696
  * `z/x/y`, as `{ z, x, y }`.
@@ -335,6 +740,15 @@ export class Renderer {
335
740
  * `bindSource(name, atlasBytes, { index })`.
336
741
  */
337
742
  sources(): Array<any>;
743
+ /**
744
+ * Bring every bound fontstack back under the budget `setGlyphBudget`
745
+ * set; a no-op without one. `renderTile` does this after each render;
746
+ * after `renderTileWith`, call it yourself once a batch is done.
747
+ * Trimming can drop glyphs a frame bound for its next tile, so it
748
+ * throws `FrameInProgress` while a `renderFrame` holds the renderer,
749
+ * which trims after each of its tiles itself.
750
+ */
751
+ trimGlyphs(): void;
338
752
  /**
339
753
  * Effective attribution declared by the style (document +
340
754
  * sources), joined with ` | `. Upstream TileJSON / PMTiles
@@ -351,9 +765,89 @@ export class Renderer {
351
765
  */
352
766
  readonly paramsSchema: any;
353
767
  /**
354
- * `tile-size` declared by the current style.
768
+ * The tile size renders use: the one `setTileSize` set, or else the
769
+ * style's `tile-size`. A `tileSize` in one render's options still wins
770
+ * over it.
771
+ */
772
+ readonly renderTileSize: number;
773
+ /**
774
+ * `tile-size` declared by the current style, whatever `setTileSize`
775
+ * renders at.
355
776
  */
356
777
  readonly tileSize: number;
778
+ /**
779
+ * What building the current style's graph warned about: each names a
780
+ * node that works but relies on something the style does not say out
781
+ * loud. They are also logged when the style is built; this is for
782
+ * reporting or checking them on your own terms. Follows `setStyle`.
783
+ */
784
+ readonly warnings: string[];
785
+ }
786
+
787
+ /**
788
+ * One tile-scoped payload — a vector tile, a DEM or imagery tile, a
789
+ * GeoJSON document — decoded once by `Renderer.loadSource` and ready to
790
+ * sit in any number of `SourceSet`s.
791
+ *
792
+ * A set keeps what it holds alive, so `free()` once the sets that need it
793
+ * have it, or leave it to the garbage collector. It is not tied to the
794
+ * renderer that loaded it: renderers in one module share a heap, and a
795
+ * render checks that its style declares the source the way the data was
796
+ * loaded for.
797
+ */
798
+ export class SourceData {
799
+ private constructor();
800
+ free(): void;
801
+ [Symbol.dispose](): void;
802
+ /**
803
+ * The `sources.<name>` entry the data was loaded for.
804
+ */
805
+ readonly source: string;
806
+ }
807
+
808
+ /**
809
+ * Every tile-scoped payload one render reads, each at its place in the
810
+ * 3×3 neighbourhood: the binding table `bindSource` fills, as a value you
811
+ * build per tile and hand to `renderTileWith`.
812
+ *
813
+ * A set says nothing about the tile it is for — offsets are relative — so
814
+ * pairing each tile with its neighbourhood is yours to do. Fonts, sprites,
815
+ * brushes, images and glyphs are not here: they belong to the renderer,
816
+ * bound once with `bindSource` and read by every render.
817
+ */
818
+ export class SourceSet {
819
+ free(): void;
820
+ [Symbol.dispose](): void;
821
+ /**
822
+ * Put `data` at `opts.coord` for its source, replacing what was
823
+ * there. `opts` is `bindSource`'s `{ coord?: [dx, dy], sourceZoom? }`:
824
+ * `sourceZoom` says the data is an ancestor's, to be resampled or
825
+ * reprojected into the tile. The set shares the data rather than
826
+ * copying it.
827
+ *
828
+ * Throws `UnknownSource` when the source already holds data of
829
+ * another kind, and for the `coord` and `sourceZoom` `bindSource`
830
+ * refuses.
831
+ */
832
+ bind(data: SourceData, opts?: object | null): void;
833
+ /**
834
+ * A copy of the set. It holds the same data, which is shared rather
835
+ * than copied, so this costs a few references per entry.
836
+ */
837
+ clone(): SourceSet;
838
+ /**
839
+ * Whether anything is bound for `source`.
840
+ */
841
+ contains(source: string): boolean;
842
+ /**
843
+ * Whether nothing is bound at all.
844
+ */
845
+ isEmpty(): boolean;
846
+ /**
847
+ * An empty set: a render from it draws what the style draws with no
848
+ * tile data at all.
849
+ */
850
+ constructor();
357
851
  }
358
852
 
359
853
  /**
@@ -361,7 +855,8 @@ export class Renderer {
361
855
  *
362
856
  * This is the figure an isolate's memory cap applies to, and the one
363
857
  * to watch to shed load before an allocation fails — a refused
364
- * `memory.grow` throws [`OutOfMemory`](oom) and ends the instance.
858
+ * `memory.grow` throws `OutOfMemory` (see the `oom` module) and ends the
859
+ * instance.
365
860
  * It never falls: freed Rust values return to the allocator for reuse,
366
861
  * but wasm cannot hand pages back to the host. So a drop in demand
367
862
  * leaves the number where its peak left it, and only a fresh instance
@@ -372,6 +867,21 @@ export class Renderer {
372
867
  */
373
868
  export function heapBytes(): number;
374
869
 
870
+ /**
871
+ * The number of node ops registered in this module. It is the smoke test
872
+ * for the module's life-before-main constructors: zero means they never
873
+ * ran, and every style is about to fail with "unknown op". The Go
874
+ * package's `OpCount`; a Rust host reads the registry itself, through
875
+ * `ezu::paint::nodes::default_registry()`.
876
+ */
877
+ export function opCount(): number;
878
+
879
+ /**
880
+ * Every registered node op, by name: which ops this build has, not just
881
+ * how many. The Go package's `OpNames`.
882
+ */
883
+ export function opNames(): string[];
884
+
375
885
  /**
376
886
  * Whether the wasm binary was compiled with `+simd128`. Lets the demo
377
887
  * page label the renderer build accurately.
@@ -390,8 +900,15 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
390
900
 
391
901
  export interface InitOutput {
392
902
  readonly memory: WebAssembly.Memory;
903
+ readonly __wbg_framebinder_free: (a: number, b: number) => void;
904
+ readonly __wbg_framefeaturecollector_free: (a: number, b: number) => void;
393
905
  readonly __wbg_logsink_free: (a: number, b: number) => void;
394
906
  readonly __wbg_renderer_free: (a: number, b: number) => void;
907
+ readonly __wbg_sourcedata_free: (a: number, b: number) => void;
908
+ readonly __wbg_sourceset_free: (a: number, b: number) => void;
909
+ readonly framebinder_bindSource: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
910
+ readonly framefeaturecollector_finish: (a: number) => [number, number, number];
911
+ readonly framefeaturecollector_renderTile: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
395
912
  readonly heapBytes: () => number;
396
913
  readonly logsink_clear: (a: number) => void;
397
914
  readonly logsink_drain: (a: number) => any;
@@ -401,33 +918,61 @@ export interface InitOutput {
401
918
  readonly logsink_new: (a: number, b: number) => [number, number, number];
402
919
  readonly logsink_onEvent: (a: number, b: number) => void;
403
920
  readonly logsink_setCapacity: (a: number, b: number) => void;
921
+ readonly opCount: () => number;
922
+ readonly opNames: () => [number, number];
404
923
  readonly renderer_attribution: (a: number) => [number, number];
405
924
  readonly renderer_bindSource: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
406
925
  readonly renderer_boundSources: (a: number) => [number, number];
407
- readonly renderer_clearSources: (a: number) => void;
926
+ readonly renderer_clearCacheBudget: (a: number) => [number, number];
927
+ readonly renderer_clearGlyphBudget: (a: number) => [number, number];
928
+ readonly renderer_clearSources: (a: number) => [number, number];
929
+ readonly renderer_clearTileSize: (a: number) => [number, number];
930
+ readonly renderer_computeFrame: (a: number, b: any) => [number, number, number];
931
+ readonly renderer_frameFeatures: (a: number, b: any, c: any) => [number, number, number];
408
932
  readonly renderer_legend: (a: number, b: number) => [number, number, number];
933
+ readonly renderer_loadSource: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
409
934
  readonly renderer_memoryUsage: (a: number) => [number, number, number];
410
935
  readonly renderer_neededCodepoints: (a: number) => [number, number, number];
936
+ readonly renderer_neededCodepointsIn: (a: number, b: number) => [number, number, number];
411
937
  readonly renderer_neededGlyphRanges: (a: number) => [number, number, number];
938
+ readonly renderer_neededGlyphRangesIn: (a: number, b: number) => [number, number, number];
412
939
  readonly renderer_new: (a: number, b: number) => [number, number, number];
413
940
  readonly renderer_paramsSchema: (a: number) => [number, number, number];
941
+ readonly renderer_renderFrame: (a: number, b: any, c: number, d: number) => any;
942
+ readonly renderer_renderFrameWithFeatures: (a: number, b: any, c: number, d: any, e: number) => any;
414
943
  readonly renderer_renderTile: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
944
+ readonly renderer_renderTileSize: (a: number) => number;
945
+ readonly renderer_renderTileWith: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
946
+ readonly renderer_renderTileWithFeatures: (a: number, b: number, c: number, d: number, e: number, f: any, g: number) => [number, number, number];
415
947
  readonly renderer_requestedNeighborOffsets: (a: number, b: number, c: number) => [number, number, number];
416
- readonly renderer_setGlyphBudget: (a: number, b: number) => void;
948
+ readonly renderer_setCacheBudget: (a: number, b: number) => [number, number];
949
+ readonly renderer_setGlyphBudget: (a: number, b: number) => [number, number];
417
950
  readonly renderer_setStyle: (a: number, b: number, c: number) => [number, number, number];
951
+ readonly renderer_setTileSize: (a: number, b: number) => [number, number];
418
952
  readonly renderer_sourceTile: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
419
953
  readonly renderer_sources: (a: number) => [number, number, number];
420
954
  readonly renderer_tileSize: (a: number) => number;
955
+ readonly renderer_trimGlyphs: (a: number) => [number, number];
956
+ readonly renderer_warnings: (a: number) => [number, number];
421
957
  readonly simdEnabled: () => number;
958
+ readonly sourcedata_source: (a: number) => [number, number];
959
+ readonly sourceset_bind: (a: number, b: number, c: number) => [number, number];
960
+ readonly sourceset_clone: (a: number) => number;
961
+ readonly sourceset_contains: (a: number, b: number, c: number) => number;
962
+ readonly sourceset_isEmpty: (a: number) => number;
963
+ readonly sourceset_new: () => number;
422
964
  readonly threadsEnabled: () => number;
965
+ 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];
966
+ 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;
423
967
  readonly __wbindgen_malloc_command_export: (a: number, b: number) => number;
424
968
  readonly __wbindgen_realloc_command_export: (a: number, b: number, c: number, d: number) => number;
425
969
  readonly __wbindgen_exn_store_command_export: (a: number) => void;
426
970
  readonly __externref_table_alloc_command_export: () => number;
427
971
  readonly __wbindgen_externrefs: WebAssembly.Table;
428
972
  readonly __wbindgen_free_command_export: (a: number, b: number, c: number) => void;
429
- readonly __externref_drop_slice_command_export: (a: number, b: number) => void;
973
+ readonly __wbindgen_destroy_closure_command_export: (a: number, b: number) => void;
430
974
  readonly __externref_table_dealloc_command_export: (a: number) => void;
975
+ readonly __externref_drop_slice_command_export: (a: number, b: number) => void;
431
976
  readonly __wbindgen_start: () => void;
432
977
  }
433
978