@reearth/ezu 0.4.1 → 0.5.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/README.md +39 -0
- package/bundler/ezu.d.ts +97 -0
- package/bundler/ezu.js +1 -1
- package/bundler/ezu_bg.js +143 -25
- package/bundler/ezu_bg.wasm +0 -0
- package/bundler/ezu_bg.wasm.d.ts +4 -0
- package/nodejs/ezu.d.ts +97 -0
- package/nodejs/ezu.js +144 -25
- package/nodejs/ezu_bg.wasm +0 -0
- package/nodejs/ezu_bg.wasm.d.ts +4 -0
- package/package.json +45 -2
- package/simd/bundler/ezu.d.ts +273 -0
- package/simd/bundler/ezu.js +9 -0
- package/simd/bundler/ezu_bg.js +715 -0
- package/simd/bundler/ezu_bg.wasm +0 -0
- package/simd/bundler/ezu_bg.wasm.d.ts +38 -0
- package/simd/nodejs/ezu.d.ts +273 -0
- package/simd/nodejs/ezu.js +725 -0
- package/simd/nodejs/ezu_bg.wasm +0 -0
- package/simd/nodejs/ezu_bg.wasm.d.ts +38 -0
- package/simd/nodejs/package.json +1 -0
- package/simd/web/ezu.d.ts +336 -0
- package/simd/web/ezu.js +815 -0
- package/simd/web/ezu_bg.wasm +0 -0
- package/simd/web/ezu_bg.wasm.d.ts +38 -0
- package/simd/workerd/ezu.d.ts +3 -0
- package/simd/workerd/ezu.js +13 -0
- package/web/ezu.d.ts +101 -0
- package/web/ezu.js +143 -25
- package/web/ezu_bg.wasm +0 -0
- package/web/ezu_bg.wasm.d.ts +4 -0
- package/workerd/ezu.js +1 -1
|
Binary file
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_logsink_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_renderer_free: (a: number, b: number) => void;
|
|
6
|
+
export const heapBytes: () => number;
|
|
7
|
+
export const logsink_clear: (a: number) => void;
|
|
8
|
+
export const logsink_drain: (a: number) => any;
|
|
9
|
+
export const logsink_drainLines: (a: number) => [number, number];
|
|
10
|
+
export const logsink_isEmpty: (a: number) => number;
|
|
11
|
+
export const logsink_len: (a: number) => number;
|
|
12
|
+
export const logsink_new: (a: number, b: number) => [number, number, number];
|
|
13
|
+
export const logsink_onEvent: (a: number, b: number) => void;
|
|
14
|
+
export const logsink_setCapacity: (a: number, b: number) => void;
|
|
15
|
+
export const renderer_attribution: (a: number) => [number, number];
|
|
16
|
+
export const renderer_bindSource: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
17
|
+
export const renderer_boundSources: (a: number) => [number, number];
|
|
18
|
+
export const renderer_clearSources: (a: number) => void;
|
|
19
|
+
export const renderer_memoryUsage: (a: number) => [number, number, number];
|
|
20
|
+
export const renderer_neededCodepoints: (a: number) => [number, number, number];
|
|
21
|
+
export const renderer_neededGlyphRanges: (a: number) => [number, number, number];
|
|
22
|
+
export const renderer_new: (a: number, b: number) => [number, number, number];
|
|
23
|
+
export const renderer_renderTile: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
24
|
+
export const renderer_requestedNeighborOffsets: (a: number, b: number, c: number) => [number, number, number];
|
|
25
|
+
export const renderer_setGlyphBudget: (a: number, b: number) => void;
|
|
26
|
+
export const renderer_setStyle: (a: number, b: number, c: number) => [number, number, number];
|
|
27
|
+
export const renderer_tileSize: (a: number) => number;
|
|
28
|
+
export const simdEnabled: () => number;
|
|
29
|
+
export const threadsEnabled: () => number;
|
|
30
|
+
export const __wbindgen_malloc_command_export: (a: number, b: number) => number;
|
|
31
|
+
export const __wbindgen_realloc_command_export: (a: number, b: number, c: number, d: number) => number;
|
|
32
|
+
export const __wbindgen_exn_store_command_export: (a: number) => void;
|
|
33
|
+
export const __externref_table_alloc_command_export: () => number;
|
|
34
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
35
|
+
export const __wbindgen_free_command_export: (a: number, b: number, c: number) => void;
|
|
36
|
+
export const __externref_drop_slice_command_export: (a: number, b: number) => void;
|
|
37
|
+
export const __externref_table_dealloc_command_export: (a: number) => void;
|
|
38
|
+
export const __wbindgen_start: () => void;
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Buffered log sink that captures `tracing` events from the renderer.
|
|
6
|
+
*
|
|
7
|
+
* Construct once near the top of your bootstrap, then either set a
|
|
8
|
+
* callback for live forwarding (`onEvent(e => console.log(e))`) or
|
|
9
|
+
* `drainLines()` periodically to flush into a UI panel.
|
|
10
|
+
*/
|
|
11
|
+
export class LogSink {
|
|
12
|
+
free(): void;
|
|
13
|
+
[Symbol.dispose](): void;
|
|
14
|
+
/**
|
|
15
|
+
* Drop all buffered records without returning them.
|
|
16
|
+
*/
|
|
17
|
+
clear(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Drain every buffered record. Returns a JS array of structured
|
|
20
|
+
* objects `{ level, target, message, fields, timestampMs }`.
|
|
21
|
+
*/
|
|
22
|
+
drain(): Array<any>;
|
|
23
|
+
/**
|
|
24
|
+
* Drain buffered records and return pre-formatted strings — the
|
|
25
|
+
* same shape the CLI prints. Convenient for `console.log(lines.join('\n'))`.
|
|
26
|
+
*/
|
|
27
|
+
drainLines(): string[];
|
|
28
|
+
/**
|
|
29
|
+
* `true` if no records are buffered.
|
|
30
|
+
*/
|
|
31
|
+
isEmpty(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Install (idempotently) the global tracing subscriber. `level` is
|
|
34
|
+
* an `EnvFilter` string — e.g. `"info"`, `"debug"`,
|
|
35
|
+
* `"info,ezu_graph::eval=debug"`. Honoured on first call only.
|
|
36
|
+
*/
|
|
37
|
+
constructor(level: string);
|
|
38
|
+
/**
|
|
39
|
+
* Set (or clear with `null` / `undefined`) the per-event JS
|
|
40
|
+
* callback. The callback receives a structured record object.
|
|
41
|
+
*
|
|
42
|
+
* No-op in multithreaded (`threads`) builds — events can originate
|
|
43
|
+
* on rayon worker threads, so live forwarding to a main-thread JS
|
|
44
|
+
* callback isn't available. Use `drain` / `drainLines` instead.
|
|
45
|
+
*/
|
|
46
|
+
onEvent(callback?: Function | null): void;
|
|
47
|
+
/**
|
|
48
|
+
* Resize the ring-buffer cap. Older entries are evicted FIFO once
|
|
49
|
+
* the buffer reaches the new cap. Default is 4096.
|
|
50
|
+
*/
|
|
51
|
+
setCapacity(cap: number): void;
|
|
52
|
+
/**
|
|
53
|
+
* Number of records currently buffered.
|
|
54
|
+
*/
|
|
55
|
+
readonly len: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Stateful WASM renderer.
|
|
60
|
+
*/
|
|
61
|
+
export class Renderer {
|
|
62
|
+
free(): void;
|
|
63
|
+
[Symbol.dispose](): void;
|
|
64
|
+
/**
|
|
65
|
+
* Bind raw tile bytes under a `sources.<name>` entry from the style.
|
|
66
|
+
* The renderer dispatches on the source's declared `type`:
|
|
67
|
+
*
|
|
68
|
+
* - `mvt` / `pmtiles` → store raw MVT bytes per `(dx, dy)` neighbour
|
|
69
|
+
* offset (centre `coord: [0, 0]`, the default). Layers are bound as
|
|
70
|
+
* `<source>.<layer>` (centre) or `<source>.<layer>@dx,dy`
|
|
71
|
+
* (neighbours) when [`render_tile`] runs. Binding only the centre
|
|
72
|
+
* degrades cross-tile label collision to centre-only at borders.
|
|
73
|
+
* - `dem` / `raster` → store the raw bytes per `(dx, dy)` neighbour
|
|
74
|
+
* offset. The centre tile is `coord: [0, 0]` (default). Decoding
|
|
75
|
+
* and 3×3 stitching happen at render time once the tile id is known.
|
|
76
|
+
* - `geojson` (remote) → store raw bytes per `(dx, dy)` offset;
|
|
77
|
+
* projected per tile (and neighbour) at render time.
|
|
78
|
+
*
|
|
79
|
+
* `opts` is a JS object: `{ coord?: [dx, dy] }`. Throws
|
|
80
|
+
* `UnknownSource` if `name` doesn't match any entry in the style's
|
|
81
|
+
* `sources` block, `MvtDecode` if MVT bytes don't parse, and
|
|
82
|
+
* `DemDecode` for non-image DEM bytes (the decode itself runs at
|
|
83
|
+
* render time, but obvious cases are caught here).
|
|
84
|
+
*/
|
|
85
|
+
bindSource(name: string, bytes: Uint8Array, opts?: object | null): void;
|
|
86
|
+
/**
|
|
87
|
+
* Names of every source with at least one pending binding.
|
|
88
|
+
* Order matches the style's `sources` declaration order.
|
|
89
|
+
*/
|
|
90
|
+
boundSources(): string[];
|
|
91
|
+
/**
|
|
92
|
+
* Drop every pending source binding. Call between tile renders.
|
|
93
|
+
*/
|
|
94
|
+
clearSources(): void;
|
|
95
|
+
/**
|
|
96
|
+
* What this renderer is holding, in bytes, so a host can shed load
|
|
97
|
+
* *before* an allocation fails rather than after.
|
|
98
|
+
*
|
|
99
|
+
* Returns a JS object:
|
|
100
|
+
* - `heapBytes` — wasm linear memory committed to the **module**,
|
|
101
|
+
* shared by every `Renderer` in this instance. This is the number
|
|
102
|
+
* that meets an isolate's memory cap. It is a high-water mark:
|
|
103
|
+
* freeing Rust values returns them to the allocator, never to the
|
|
104
|
+
* host, so it only ever grows.
|
|
105
|
+
* - `glyphBytes` / `glyphRanges` — SDF bitmaps resident in the
|
|
106
|
+
* glyph bank, and how many 256-codepoint blocks they span. Glyphs
|
|
107
|
+
* accumulate for the life of the renderer and survive
|
|
108
|
+
* `clearSources`, so on a long-lived instance this is usually
|
|
109
|
+
* what grew. `glyphBudget` is the per-fontstack ceiling
|
|
110
|
+
* `setGlyphBudget` put on them, or `Infinity` if none — note
|
|
111
|
+
* `glyphBytes` totals *every* fontstack, so it can exceed the
|
|
112
|
+
* budget legitimately.
|
|
113
|
+
* - `fontBytes` — outline font files held in the font bank.
|
|
114
|
+
* - `imageBytes` — decoded pixels of bound images and sprite
|
|
115
|
+
* atlases.
|
|
116
|
+
* - `cacheBytes` / `cacheBudget` — the render cache's pixel
|
|
117
|
+
* payload against its own eviction budget; it bounds itself, so
|
|
118
|
+
* `cacheBytes` near `cacheBudget` is steady state, not a leak.
|
|
119
|
+
*
|
|
120
|
+
* These are payload sizes, not an accounting of the heap: they omit
|
|
121
|
+
* allocator overhead, decoded features, per-font glyph-path caches,
|
|
122
|
+
* and the buffers a render is using right now. Expect the parts to
|
|
123
|
+
* sum to less than `heapBytes`.
|
|
124
|
+
*/
|
|
125
|
+
memoryUsage(): object;
|
|
126
|
+
/**
|
|
127
|
+
* Codepoints the currently bound features can require, as
|
|
128
|
+
* `{ [glyphsSourceName]: number[] }` sorted ascending.
|
|
129
|
+
*
|
|
130
|
+
* This is the precise form of
|
|
131
|
+
* [`neededGlyphRanges`](Self::needed_glyph_ranges): a host that
|
|
132
|
+
* can build its own glyph PBF — one message holding just these
|
|
133
|
+
* codepoints — transfers only the glyphs the tile draws instead
|
|
134
|
+
* of the whole 256-codepoint block around each of them. On CJK
|
|
135
|
+
* labels that is the difference between a few thousand glyphs and
|
|
136
|
+
* a few tens of megabytes. `bindSource` files each glyph by its
|
|
137
|
+
* own id, so such a subset may span any number of blocks and
|
|
138
|
+
* needs no particular `range` string.
|
|
139
|
+
*
|
|
140
|
+
* Hosts that can only fetch whole `{range}.pbf` files off a
|
|
141
|
+
* MapLibre glyphs endpoint want `neededGlyphRanges` instead. Both
|
|
142
|
+
* calls see the same set of codepoints and carry the same
|
|
143
|
+
* over-approximation caveat.
|
|
144
|
+
*/
|
|
145
|
+
neededCodepoints(): object;
|
|
146
|
+
/**
|
|
147
|
+
* Glyph ranges the currently bound features can require, as
|
|
148
|
+
* `{ [glyphsSourceName]: number[] }` where each number is a range
|
|
149
|
+
* start (`0`, `256`, `512`, …) — i.e. the `{range}` in a
|
|
150
|
+
* `…/{fontstack}/{range}.pbf` URL is `<start>-<start + 255>`.
|
|
151
|
+
*
|
|
152
|
+
* This host cannot fetch glyph ranges lazily, so every range a
|
|
153
|
+
* tile's labels touch must be bound before `renderTile`. Rather than
|
|
154
|
+
* scraping every string in the MVT, call this after binding the
|
|
155
|
+
* vector sources and bind exactly the listed ranges.
|
|
156
|
+
*
|
|
157
|
+
* A range holds 256 codepoints and a tile typically draws a
|
|
158
|
+
* handful of them, so this is a coarse unit to fetch in. Hosts
|
|
159
|
+
* that can assemble their own subset PBF should call
|
|
160
|
+
* [`neededCodepoints`](Self::needed_codepoints) instead.
|
|
161
|
+
*
|
|
162
|
+
* It is an over-approximation, deliberately: a range is listed if
|
|
163
|
+
* *any* feature in a text layer carries the codepoint in a property
|
|
164
|
+
* the layer's `text` expression reads, without evaluating filters,
|
|
165
|
+
* zoom ranges, or the expression itself, and it is listed for every
|
|
166
|
+
* fontstack in that layer's fallback chain. So it never omits a
|
|
167
|
+
* range a label needs, and it may name a few that go unused. Text
|
|
168
|
+
* layers that build their string from something other than a `get`
|
|
169
|
+
* of a feature property (a literal, a `concat` of formatted values)
|
|
170
|
+
* contribute their literal text where it is a plain string.
|
|
171
|
+
*/
|
|
172
|
+
neededGlyphRanges(): object;
|
|
173
|
+
/**
|
|
174
|
+
* Build a renderer from a style JSON document.
|
|
175
|
+
*/
|
|
176
|
+
constructor(style_json: string);
|
|
177
|
+
/**
|
|
178
|
+
* Render a single tile using whatever sources are currently bound.
|
|
179
|
+
*
|
|
180
|
+
* `opts` (JS object, all fields optional):
|
|
181
|
+
* - `format`: `"png"` (default) / `"webp"` / `"rgba"`
|
|
182
|
+
* - `tileSize`, `pad`: override the style's canvas size for this
|
|
183
|
+
* call (hi-DPI / preview)
|
|
184
|
+
* - `png`: `{ compression?: "fast" | "default" | "best" }`
|
|
185
|
+
*/
|
|
186
|
+
renderTile(z: number, x: number, y: number, opts?: object | null): Uint8Array;
|
|
187
|
+
/**
|
|
188
|
+
* Neighbour tile offsets the active style actually asks for from
|
|
189
|
+
* `source`, as an array of `[dx, dy]` pairs (never including the
|
|
190
|
+
* centre `[0, 0]`).
|
|
191
|
+
*
|
|
192
|
+
* Cross-tile label collision and edge-continuous DEM shading are the
|
|
193
|
+
* only things that read neighbours, and only for the sources they
|
|
194
|
+
* name. A host that fetches the full 3×3 window unconditionally
|
|
195
|
+
* therefore pays for up to eight tiles it will not look at; passing
|
|
196
|
+
* each offset from this list to `bindSource(name, bytes, { coord })`
|
|
197
|
+
* fetches exactly what the recipe needs. An empty array means the
|
|
198
|
+
* centre tile is enough.
|
|
199
|
+
*
|
|
200
|
+
* Throws `UnknownSource` if `name` is not declared in the style.
|
|
201
|
+
*/
|
|
202
|
+
requestedNeighborOffsets(name: string): Array<any>;
|
|
203
|
+
/**
|
|
204
|
+
* Cap the glyph bytes each bound fontstack keeps resident, in
|
|
205
|
+
* bytes. Unset, a fontstack keeps every range ever bound to it for
|
|
206
|
+
* the life of the renderer — `clearSources` does not touch glyphs,
|
|
207
|
+
* and on a long-lived instance rendering across a basemap that is
|
|
208
|
+
* usually what grew.
|
|
209
|
+
*
|
|
210
|
+
* Trimming happens **after** each `renderTile`, not while binding,
|
|
211
|
+
* so a render never loses glyphs that were bound for it. The tile
|
|
212
|
+
* that just drew is therefore the most recently used, and a budget
|
|
213
|
+
* large enough for one tile's glyphs always keeps that tile's; what
|
|
214
|
+
* goes is what earlier tiles needed and this one did not. Set it
|
|
215
|
+
* below one tile's worth and the ceiling still holds — the stack
|
|
216
|
+
* empties after every render and nothing carries over, which
|
|
217
|
+
* renders correctly but buys no reuse.
|
|
218
|
+
*
|
|
219
|
+
* It is a per-fontstack ceiling: a style with a regular, a medium
|
|
220
|
+
* and an italic stack can hold three times what is set here.
|
|
221
|
+
*
|
|
222
|
+
* This host cannot refetch, so anything trimmed must be bound again
|
|
223
|
+
* before the next tile that needs it. `neededCodepoints()` already
|
|
224
|
+
* names exactly what to bind, and a host that re-binds every tile
|
|
225
|
+
* (rather than tracking what it sent) needs no other change.
|
|
226
|
+
*/
|
|
227
|
+
setGlyphBudget(bytes: number): void;
|
|
228
|
+
/**
|
|
229
|
+
* Replace the active style. Returns the new node count. Invalidates
|
|
230
|
+
* the intermediate cache and drops any pending source bindings.
|
|
231
|
+
*/
|
|
232
|
+
setStyle(style_json: string): number;
|
|
233
|
+
/**
|
|
234
|
+
* Effective attribution declared by the style (document +
|
|
235
|
+
* sources), joined with ` | `. Upstream TileJSON / PMTiles
|
|
236
|
+
* metadata is the JS host's concern — merge it on that side.
|
|
237
|
+
*/
|
|
238
|
+
readonly attribution: string | undefined;
|
|
239
|
+
/**
|
|
240
|
+
* `tile-size` declared by the current style.
|
|
241
|
+
*/
|
|
242
|
+
readonly tileSize: number;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Wasm linear memory currently committed to this module, in bytes.
|
|
247
|
+
*
|
|
248
|
+
* This is the figure an isolate's memory cap applies to, and the one
|
|
249
|
+
* to watch to shed load before an allocation fails — a refused
|
|
250
|
+
* `memory.grow` throws [`OutOfMemory`](oom) and ends the instance.
|
|
251
|
+
* It never falls: freed Rust values return to the allocator for reuse,
|
|
252
|
+
* but wasm cannot hand pages back to the host. So a drop in demand
|
|
253
|
+
* leaves the number where its peak left it, and only a fresh instance
|
|
254
|
+
* resets it.
|
|
255
|
+
*
|
|
256
|
+
* Module-wide, not per-`Renderer`. For what a given renderer is
|
|
257
|
+
* holding, and which bank to evict, call `memoryUsage()`.
|
|
258
|
+
*/
|
|
259
|
+
export function heapBytes(): number;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Whether the wasm binary was compiled with `+simd128`. Lets the demo
|
|
263
|
+
* page label the renderer build accurately.
|
|
264
|
+
*/
|
|
265
|
+
export function simdEnabled(): boolean;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Whether this build supports multithreaded rendering (compiled with
|
|
269
|
+
* the `threads` feature). When `false`, `initThreadPool` is absent and
|
|
270
|
+
* `renderTile`'s `parallel` option is a no-op. Mirrors `simdEnabled` so
|
|
271
|
+
* the host can label the build.
|
|
272
|
+
*/
|
|
273
|
+
export function threadsEnabled(): boolean;
|