@reearth/ezu 0.4.0 → 0.4.2

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.
@@ -0,0 +1,34 @@
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 logsink_clear: (a: number) => void;
7
+ export const logsink_drain: (a: number) => any;
8
+ export const logsink_drainLines: (a: number) => [number, number];
9
+ export const logsink_isEmpty: (a: number) => number;
10
+ export const logsink_len: (a: number) => number;
11
+ export const logsink_new: (a: number, b: number) => [number, number, number];
12
+ export const logsink_onEvent: (a: number, b: number) => void;
13
+ export const logsink_setCapacity: (a: number, b: number) => void;
14
+ export const renderer_attribution: (a: number) => [number, number];
15
+ export const renderer_bindSource: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
16
+ export const renderer_boundSources: (a: number) => [number, number];
17
+ export const renderer_clearSources: (a: number) => void;
18
+ export const renderer_neededGlyphRanges: (a: number) => [number, number, number];
19
+ export const renderer_new: (a: number, b: number) => [number, number, number];
20
+ export const renderer_renderTile: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
21
+ export const renderer_requestedNeighborOffsets: (a: number, b: number, c: number) => [number, number, number];
22
+ export const renderer_setStyle: (a: number, b: number, c: number) => [number, number, number];
23
+ export const renderer_tileSize: (a: number) => number;
24
+ export const simdEnabled: () => number;
25
+ export const threadsEnabled: () => number;
26
+ export const __wbindgen_malloc_command_export: (a: number, b: number) => number;
27
+ export const __wbindgen_realloc_command_export: (a: number, b: number, c: number, d: number) => number;
28
+ export const __wbindgen_exn_store_command_export: (a: number) => void;
29
+ export const __externref_table_alloc_command_export: () => number;
30
+ export const __wbindgen_externrefs: WebAssembly.Table;
31
+ export const __wbindgen_free_command_export: (a: number, b: number, c: number) => void;
32
+ export const __externref_drop_slice_command_export: (a: number, b: number) => void;
33
+ export const __externref_table_dealloc_command_export: (a: number) => void;
34
+ export const __wbindgen_start: () => void;
@@ -0,0 +1,3 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export * from "../bundler/ezu.js";
@@ -0,0 +1,13 @@
1
+ /* @ts-self-types="./ezu.d.ts" */
2
+ import * as glue from "../bundler/ezu_bg.js";
3
+ import wasmModule from "../bundler/ezu_bg.wasm";
4
+
5
+ // Synchronous instantiation is allowed at module scope on workerd; it
6
+ // would be rejected inside a request handler.
7
+ const instance = new WebAssembly.Instance(wasmModule, { "./ezu_bg.js": glue });
8
+ glue.__wbg_set_wasm(instance.exports);
9
+ instance.exports.__wbindgen_start();
10
+
11
+ export {
12
+ LogSink, Renderer, simdEnabled, threadsEnabled
13
+ } from "../bundler/ezu_bg.js";
package/web/ezu.d.ts CHANGED
@@ -92,6 +92,28 @@ export class Renderer {
92
92
  * Drop every pending source binding. Call between tile renders.
93
93
  */
94
94
  clearSources(): void;
95
+ /**
96
+ * Glyph ranges the currently bound features can require, as
97
+ * `{ [glyphsSourceName]: number[] }` where each number is a range
98
+ * start (`0`, `256`, `512`, …) — i.e. the `{range}` in a
99
+ * `…/{fontstack}/{range}.pbf` URL is `<start>-<start + 255>`.
100
+ *
101
+ * This host cannot fetch glyph ranges lazily, so every range a
102
+ * tile's labels touch must be bound before `renderTile`. Rather than
103
+ * scraping every string in the MVT, call this after binding the
104
+ * vector sources and bind exactly the listed ranges.
105
+ *
106
+ * It is an over-approximation, deliberately: a range is listed if
107
+ * *any* feature in a text layer carries the codepoint in a property
108
+ * the layer's `text` expression reads, without evaluating filters,
109
+ * zoom ranges, or the expression itself, and it is listed for every
110
+ * fontstack in that layer's fallback chain. So it never omits a
111
+ * range a label needs, and it may name a few that go unused. Text
112
+ * layers that build their string from something other than a `get`
113
+ * of a feature property (a literal, a `concat` of formatted values)
114
+ * contribute their literal text where it is a plain string.
115
+ */
116
+ neededGlyphRanges(): object;
95
117
  /**
96
118
  * Build a renderer from a style JSON document.
97
119
  */
@@ -106,6 +128,22 @@ export class Renderer {
106
128
  * - `png`: `{ compression?: "fast" | "default" | "best" }`
107
129
  */
108
130
  renderTile(z: number, x: number, y: number, opts?: object | null): Uint8Array;
131
+ /**
132
+ * Neighbour tile offsets the active style actually asks for from
133
+ * `source`, as an array of `[dx, dy]` pairs (never including the
134
+ * centre `[0, 0]`).
135
+ *
136
+ * Cross-tile label collision and edge-continuous DEM shading are the
137
+ * only things that read neighbours, and only for the sources they
138
+ * name. A host that fetches the full 3×3 window unconditionally
139
+ * therefore pays for up to eight tiles it will not look at; passing
140
+ * each offset from this list to `bindSource(name, bytes, { coord })`
141
+ * fetches exactly what the recipe needs. An empty array means the
142
+ * centre tile is enough.
143
+ *
144
+ * Throws `UnknownSource` if `name` is not declared in the style.
145
+ */
146
+ requestedNeighborOffsets(name: string): Array<any>;
109
147
  /**
110
148
  * Replace the active style. Returns the new node count. Invalidates
111
149
  * the intermediate cache and drops any pending source bindings.
@@ -155,8 +193,10 @@ export interface InitOutput {
155
193
  readonly renderer_bindSource: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
156
194
  readonly renderer_boundSources: (a: number) => [number, number];
157
195
  readonly renderer_clearSources: (a: number) => void;
196
+ readonly renderer_neededGlyphRanges: (a: number) => [number, number, number];
158
197
  readonly renderer_new: (a: number, b: number) => [number, number, number];
159
198
  readonly renderer_renderTile: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
199
+ readonly renderer_requestedNeighborOffsets: (a: number, b: number, c: number) => [number, number, number];
160
200
  readonly renderer_setStyle: (a: number, b: number, c: number) => [number, number, number];
161
201
  readonly renderer_tileSize: (a: number) => number;
162
202
  readonly simdEnabled: () => number;
package/web/ezu.js CHANGED
@@ -180,6 +180,35 @@ export class Renderer {
180
180
  clearSources() {
181
181
  wasm.renderer_clearSources(this.__wbg_ptr);
182
182
  }
183
+ /**
184
+ * Glyph ranges the currently bound features can require, as
185
+ * `{ [glyphsSourceName]: number[] }` where each number is a range
186
+ * start (`0`, `256`, `512`, …) — i.e. the `{range}` in a
187
+ * `…/{fontstack}/{range}.pbf` URL is `<start>-<start + 255>`.
188
+ *
189
+ * This host cannot fetch glyph ranges lazily, so every range a
190
+ * tile's labels touch must be bound before `renderTile`. Rather than
191
+ * scraping every string in the MVT, call this after binding the
192
+ * vector sources and bind exactly the listed ranges.
193
+ *
194
+ * It is an over-approximation, deliberately: a range is listed if
195
+ * *any* feature in a text layer carries the codepoint in a property
196
+ * the layer's `text` expression reads, without evaluating filters,
197
+ * zoom ranges, or the expression itself, and it is listed for every
198
+ * fontstack in that layer's fallback chain. So it never omits a
199
+ * range a label needs, and it may name a few that go unused. Text
200
+ * layers that build their string from something other than a `get`
201
+ * of a feature property (a literal, a `concat` of formatted values)
202
+ * contribute their literal text where it is a plain string.
203
+ * @returns {object}
204
+ */
205
+ neededGlyphRanges() {
206
+ const ret = wasm.renderer_neededGlyphRanges(this.__wbg_ptr);
207
+ if (ret[2]) {
208
+ throw takeFromExternrefTable0(ret[1]);
209
+ }
210
+ return takeFromExternrefTable0(ret[0]);
211
+ }
183
212
  /**
184
213
  * Build a renderer from a style JSON document.
185
214
  * @param {string} style_json
@@ -218,6 +247,32 @@ export class Renderer {
218
247
  wasm.__wbindgen_free_command_export(ret[0], ret[1] * 1, 1);
219
248
  return v1;
220
249
  }
250
+ /**
251
+ * Neighbour tile offsets the active style actually asks for from
252
+ * `source`, as an array of `[dx, dy]` pairs (never including the
253
+ * centre `[0, 0]`).
254
+ *
255
+ * Cross-tile label collision and edge-continuous DEM shading are the
256
+ * only things that read neighbours, and only for the sources they
257
+ * name. A host that fetches the full 3×3 window unconditionally
258
+ * therefore pays for up to eight tiles it will not look at; passing
259
+ * each offset from this list to `bindSource(name, bytes, { coord })`
260
+ * fetches exactly what the recipe needs. An empty array means the
261
+ * centre tile is enough.
262
+ *
263
+ * Throws `UnknownSource` if `name` is not declared in the style.
264
+ * @param {string} name
265
+ * @returns {Array<any>}
266
+ */
267
+ requestedNeighborOffsets(name) {
268
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
269
+ const len0 = WASM_VECTOR_LEN;
270
+ const ret = wasm.renderer_requestedNeighborOffsets(this.__wbg_ptr, ptr0, len0);
271
+ if (ret[2]) {
272
+ throw takeFromExternrefTable0(ret[1]);
273
+ }
274
+ return takeFromExternrefTable0(ret[0]);
275
+ }
221
276
  /**
222
277
  * Replace the active style. Returns the new node count. Invalidates
223
278
  * the intermediate cache and drops any pending source bindings.
@@ -287,6 +342,9 @@ function __wbg_get_imports() {
287
342
  getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
288
343
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
289
344
  },
345
+ __wbg___wbindgen_rethrow_2b7cc655458909c2: function(arg0) {
346
+ throw arg0;
347
+ },
290
348
  __wbg___wbindgen_string_get_d109740c0d18f4d7: function(arg0, arg1) {
291
349
  const obj = arg1;
292
350
  const ret = typeof(obj) === 'string' ? obj : undefined;
package/web/ezu_bg.wasm CHANGED
Binary file
@@ -15,8 +15,10 @@ export const renderer_attribution: (a: number) => [number, number];
15
15
  export const renderer_bindSource: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
16
16
  export const renderer_boundSources: (a: number) => [number, number];
17
17
  export const renderer_clearSources: (a: number) => void;
18
+ export const renderer_neededGlyphRanges: (a: number) => [number, number, number];
18
19
  export const renderer_new: (a: number, b: number) => [number, number, number];
19
20
  export const renderer_renderTile: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
21
+ export const renderer_requestedNeighborOffsets: (a: number, b: number, c: number) => [number, number, number];
20
22
  export const renderer_setStyle: (a: number, b: number, c: number) => [number, number, number];
21
23
  export const renderer_tileSize: (a: number) => number;
22
24
  export const simdEnabled: () => number;
@@ -0,0 +1,3 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export * from "../bundler/ezu.js";
package/workerd/ezu.js ADDED
@@ -0,0 +1,13 @@
1
+ /* @ts-self-types="./ezu.d.ts" */
2
+ import * as glue from "../bundler/ezu_bg.js";
3
+ import wasmModule from "../bundler/ezu_bg.wasm";
4
+
5
+ // Synchronous instantiation is allowed at module scope on workerd; it
6
+ // would be rejected inside a request handler.
7
+ const instance = new WebAssembly.Instance(wasmModule, { "./ezu_bg.js": glue });
8
+ glue.__wbg_set_wasm(instance.exports);
9
+ instance.exports.__wbindgen_start();
10
+
11
+ export {
12
+ LogSink, Renderer, simdEnabled, threadsEnabled
13
+ } from "../bundler/ezu_bg.js";