@maplibre/mlt-wasm 0.1.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 ADDED
@@ -0,0 +1,54 @@
1
+ # mlt-wasm
2
+
3
+ WebAssembly bindings for the [MapLibre Tile (MLT)](https://github.com/maplibre/maplibre-tile-spec) decoder.
4
+
5
+ Compiles `mlt-core` to WASM via [wasm-bindgen](https://github.com/rustwasm/wasm-bindgen) and ships a TypeScript wrapper exposing a `VectorTileLike` API.
6
+
7
+ ## Layout
8
+
9
+ ```
10
+ mlt-wasm/
11
+ ├── src/lib.rs # wasm-bindgen bindings
12
+ ├── js/
13
+ │ ├── index.ts # package entry point
14
+ │ └── vectorTile.ts # VectorTileLike wrapper
15
+ ├── pkg/ # wasm-pack output (gitignored)
16
+ ├── dist/ # tsc output (gitignored)
17
+ ├── Cargo.toml
18
+ ├── package.json
19
+ └── tsconfig.json
20
+ ```
21
+
22
+ ## Build
23
+
24
+ Requires [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/) and Node.js.
25
+
26
+ ```sh
27
+ npm run build
28
+ ```
29
+
30
+ This runs `wasm-pack build --target bundler --out-dir pkg` followed by `tsc`. Both steps are also available individually:
31
+
32
+ ```sh
33
+ npm run build:wasm
34
+ npm run build:ts
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ ```ts
40
+ import { decodeTile } from '@maplibre/mlt-wasm';
41
+
42
+ const data = new Uint8Array(await fetch(tileUrl).then(r => r.arrayBuffer()));
43
+ const tile = decodeTile(data);
44
+
45
+ for (const [name, layer] of Object.entries(tile.layers)) {
46
+ for (let i = 0; i < layer.length; i++) {
47
+ const feature = layer.feature(i);
48
+ console.log(feature.type); // 1 | 2 | 3
49
+ console.log(feature.id); // number | undefined
50
+ console.log(feature.properties); // fetched lazily from WASM
51
+ console.log(feature.loadGeometry()); // Point[][]
52
+ }
53
+ }
54
+ ```
@@ -0,0 +1,3 @@
1
+ export type { VectorTileFeatureLike, VectorTileLayerLike, VectorTileLike, } from "@maplibre/vt-pbf";
2
+ export { decodeTile } from "./vectorTile";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../js/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { decodeTile } from "./vectorTile";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../js/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { VectorTileLike } from "@maplibre/vt-pbf";
2
+ export declare function decodeTile(data: Uint8Array): VectorTileLike;
3
+ //# sourceMappingURL=vectorTile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vectorTile.d.ts","sourceRoot":"","sources":["../js/vectorTile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,cAAc,EACf,MAAM,kBAAkB,CAAC;AAwV1B,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,cAAc,CAQ3D"}
@@ -0,0 +1,246 @@
1
+ import Point from "@mapbox/point-geometry";
2
+ import { decode_tile as wasmDecodeTile } from "../pkg/mlt_wasm.js";
3
+ // ---------------------------------------------------------------------------
4
+ // Geometry constants (mirror Rust GeometryType → MVT mapping)
5
+ // ---------------------------------------------------------------------------
6
+ const POINT = 1;
7
+ const LINESTRING = 2;
8
+ const POLYGON = 3;
9
+ // ---------------------------------------------------------------------------
10
+ // loadGeometry — pure JS, zero WASM calls
11
+ //
12
+ // Faithfully replicates DecodedGeometry::to_mvt_rings from geotype.rs.
13
+ //
14
+ // Offset arrays are cumulative vertex-count arrays (not byte offsets).
15
+ // Vertex n lives at vertices[n*2], vertices[n*2+1].
16
+ // All returned rings are open (no repeated closing vertex).
17
+ // ---------------------------------------------------------------------------
18
+ /**
19
+ * Decodes the geometry for feature `featureIdx` from the pre-fetched bulk
20
+ * arrays. This is the JS equivalent of `DecodedGeometry::to_mvt_rings`.
21
+ *
22
+ * The MVT type byte (1/2/3) from `layer_types` does not distinguish
23
+ * single-part from multi-part geometry — that distinction is implicit in
24
+ * whether `geomOffsets` is present and in the offset ranges. We therefore
25
+ * dispatch on both the type byte and the presence of offset arrays.
26
+ */
27
+ function loadGeometry(mvtType, featureIdx, geomOffsets, partOffsets, ringOffsets, verts) {
28
+ const hasGeomOffsets = geomOffsets.length > 0;
29
+ const hasPartOffsets = partOffsets.length > 0;
30
+ const hasRingOffsets = ringOffsets.length > 0;
31
+ const openRing = (start, end) => {
32
+ const ring = new Array(end - start);
33
+ for (let i = start; i < end; i++) {
34
+ ring[i - start] = new Point(verts[i * 2], verts[i * 2 + 1]);
35
+ }
36
+ return ring;
37
+ };
38
+ if (mvtType === POINT) {
39
+ if (!hasGeomOffsets) {
40
+ // Plain Point: no geometry_offsets means direct vertex indexing.
41
+ // May have part/ring indirection if this is a mixed-type layer.
42
+ let idx = featureIdx;
43
+ if (hasPartOffsets)
44
+ idx = partOffsets[idx];
45
+ if (hasRingOffsets)
46
+ idx = ringOffsets[idx];
47
+ return [[new Point(verts[idx * 2], verts[idx * 2 + 1])]];
48
+ }
49
+ else {
50
+ // MultiPoint: geometry_offsets[i..i+1] gives a range of point indices.
51
+ // Each point may be further indirected through part/ring offsets.
52
+ const gStart = geomOffsets[featureIdx];
53
+ const gEnd = geomOffsets[featureIdx + 1];
54
+ const rings = new Array(gEnd - gStart);
55
+ for (let g = gStart; g < gEnd; g++) {
56
+ let idx = g;
57
+ if (hasPartOffsets)
58
+ idx = partOffsets[idx];
59
+ if (hasRingOffsets)
60
+ idx = ringOffsets[idx];
61
+ rings[g - gStart] = [new Point(verts[idx * 2], verts[idx * 2 + 1])];
62
+ }
63
+ return rings;
64
+ }
65
+ }
66
+ if (mvtType === LINESTRING) {
67
+ if (!hasGeomOffsets) {
68
+ // Single LineString.
69
+ let start;
70
+ let end;
71
+ if (hasRingOffsets) {
72
+ const partIdx = partOffsets[featureIdx];
73
+ start = ringOffsets[partIdx];
74
+ end = ringOffsets[partIdx + 1];
75
+ }
76
+ else {
77
+ start = partOffsets[featureIdx];
78
+ end = partOffsets[featureIdx + 1];
79
+ }
80
+ return [openRing(start, end)];
81
+ }
82
+ else {
83
+ // MultiLineString: geometry_offsets[i..i+1] is a range of part indices.
84
+ const gStart = geomOffsets[featureIdx];
85
+ const gEnd = geomOffsets[featureIdx + 1];
86
+ const result = new Array(gEnd - gStart);
87
+ for (let g = gStart; g < gEnd; g++) {
88
+ let start;
89
+ let end;
90
+ if (hasRingOffsets) {
91
+ const partIdx = partOffsets[g];
92
+ start = ringOffsets[partIdx];
93
+ end = ringOffsets[partIdx + 1];
94
+ }
95
+ else {
96
+ start = partOffsets[g];
97
+ end = partOffsets[g + 1];
98
+ }
99
+ result[g - gStart] = openRing(start, end);
100
+ }
101
+ return result;
102
+ }
103
+ }
104
+ if (mvtType === POLYGON) {
105
+ if (!hasGeomOffsets) {
106
+ // Single Polygon: part_offsets[i..i+1] iterates its ring indices.
107
+ const partStart = partOffsets[featureIdx];
108
+ const partEnd = partOffsets[featureIdx + 1];
109
+ const rings = new Array(partEnd - partStart);
110
+ for (let r = partStart; r < partEnd; r++) {
111
+ rings[r - partStart] = openRing(ringOffsets[r], ringOffsets[r + 1]);
112
+ }
113
+ return rings;
114
+ }
115
+ else {
116
+ // MultiPolygon: geometry_offsets[i..i+1] iterates polygon indices;
117
+ // each polygon's part_offsets range iterates its ring indices.
118
+ // All rings are returned flat, matching to_mvt_rings behaviour.
119
+ const gStart = geomOffsets[featureIdx];
120
+ const gEnd = geomOffsets[featureIdx + 1];
121
+ const result = [];
122
+ for (let g = gStart; g < gEnd; g++) {
123
+ const partStart = partOffsets[g];
124
+ const partEnd = partOffsets[g + 1];
125
+ for (let r = partStart; r < partEnd; r++) {
126
+ result.push(openRing(ringOffsets[r], ringOffsets[r + 1]));
127
+ }
128
+ }
129
+ return result;
130
+ }
131
+ }
132
+ return [];
133
+ }
134
+ // ---------------------------------------------------------------------------
135
+ // MltFeature
136
+ // ---------------------------------------------------------------------------
137
+ class MltFeature {
138
+ _featureIdx;
139
+ _types;
140
+ _ids;
141
+ _geomOffsets;
142
+ _partOffsets;
143
+ _ringOffsets;
144
+ _verts;
145
+ _propKeys;
146
+ _propCols;
147
+ extent;
148
+ // Lazily populated from the bulk arrays owned by MltLayer.
149
+ // _type: undefined = not yet read.
150
+ // _id: null = sentinel "not yet read"; undefined = feature has no id.
151
+ _type;
152
+ _id;
153
+ constructor(_featureIdx, extent, _types, _ids, _geomOffsets, _partOffsets, _ringOffsets, _verts, _propKeys, _propCols) {
154
+ this._featureIdx = _featureIdx;
155
+ this._types = _types;
156
+ this._ids = _ids;
157
+ this._geomOffsets = _geomOffsets;
158
+ this._partOffsets = _partOffsets;
159
+ this._ringOffsets = _ringOffsets;
160
+ this._verts = _verts;
161
+ this._propKeys = _propKeys;
162
+ this._propCols = _propCols;
163
+ this.extent = extent;
164
+ this._id = null;
165
+ }
166
+ get type() {
167
+ if (this._type === undefined) {
168
+ this._type = this._types[this._featureIdx];
169
+ }
170
+ return this._type;
171
+ }
172
+ get id() {
173
+ if (this._id === null) {
174
+ const raw = this._ids[this._featureIdx];
175
+ this._id = Number.isNaN(raw) ? undefined : raw;
176
+ }
177
+ return this._id;
178
+ }
179
+ get properties() {
180
+ const result = {};
181
+ for (let k = 0; k < this._propKeys.length; k++) {
182
+ const col = this._propCols[k];
183
+ const val = col[this._featureIdx];
184
+ // Float columns encode absent as NaN; bool/string columns use undefined.
185
+ // Integer columns cannot encode absent (0 is used as placeholder) so
186
+ // those are always included — acceptable for the rendering fast path.
187
+ if (val !== undefined &&
188
+ !(typeof val === "number" && Number.isNaN(val))) {
189
+ result[this._propKeys[k]] = val;
190
+ }
191
+ }
192
+ return result;
193
+ }
194
+ loadGeometry() {
195
+ return loadGeometry(this.type, this._featureIdx, this._geomOffsets, this._partOffsets, this._ringOffsets, this._verts);
196
+ }
197
+ }
198
+ // ---------------------------------------------------------------------------
199
+ // MltLayer
200
+ // ---------------------------------------------------------------------------
201
+ class MltLayer {
202
+ _tile;
203
+ _layerIdx;
204
+ version = 1;
205
+ name;
206
+ extent;
207
+ length;
208
+ // All fetched once per layer — O(1) WASM calls regardless of feature count.
209
+ _types;
210
+ _ids;
211
+ _geomOffsets;
212
+ _partOffsets;
213
+ _ringOffsets;
214
+ _verts;
215
+ _propKeys;
216
+ _propCols;
217
+ constructor(_tile, _layerIdx, name) {
218
+ this._tile = _tile;
219
+ this._layerIdx = _layerIdx;
220
+ this.name = name;
221
+ this.extent = _tile.layer_extent(_layerIdx);
222
+ this.length = _tile.feature_count(_layerIdx);
223
+ this._types = _tile.layer_types(_layerIdx);
224
+ this._ids = _tile.layer_ids(_layerIdx);
225
+ const geom = _tile.layer_geometry(_layerIdx);
226
+ this._geomOffsets = geom.geometry_offsets();
227
+ this._partOffsets = geom.part_offsets();
228
+ this._ringOffsets = geom.ring_offsets();
229
+ this._verts = geom.vertices();
230
+ this._propKeys = _tile.layer_property_keys(_layerIdx);
231
+ this._propCols = _tile.layer_properties(_layerIdx);
232
+ }
233
+ feature(i) {
234
+ return new MltFeature(i, this.extent, this._types, this._ids, this._geomOffsets, this._partOffsets, this._ringOffsets, this._verts, this._propKeys, this._propCols);
235
+ }
236
+ }
237
+ export function decodeTile(data) {
238
+ const tile = wasmDecodeTile(data);
239
+ const layers = {};
240
+ for (let i = 0; i < tile.layer_count(); i++) {
241
+ const name = tile.layer_name(i);
242
+ layers[name] = new MltLayer(tile, i, name);
243
+ }
244
+ return { layers };
245
+ }
246
+ //# sourceMappingURL=vectorTile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vect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CAAC,YAAY,EACjB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,SAAS,CACf,CAAC;IACJ,CAAC;CACF;AAED,MAAM,UAAU,UAAU,CAAC,IAAgB;IACzC,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,CAAgB,CAAC;IACjD,MAAM,MAAM,GAAwC,EAAE,CAAC;IACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5C,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@maplibre/mlt-wasm",
3
+ "version": "0.1.0",
4
+ "description": "WebAssembly-backed MapLibre Tile (MLT) decoder",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "/dist",
10
+ "/pkg"
11
+ ],
12
+ "license": "(MIT OR Apache-2.0)",
13
+ "homepage": "https://github.com/maplibre/maplibre-tile-spec/#readme",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/maplibre/maplibre-tile-spec"
17
+ },
18
+ "bugs": {
19
+ "url": "https://github.com/maplibre/maplibre-tile-spec/issues"
20
+ },
21
+ "keywords": [
22
+ "maplibre",
23
+ "mlt",
24
+ "vector-tile",
25
+ "wasm",
26
+ "webassembly",
27
+ "gis"
28
+ ],
29
+ "scripts": {
30
+ "build:wasm": "RUSTFLAGS=\"-Zunstable-options -Cpanic=immediate-abort -Ctarget-feature=+simd128\" CARGO_UNSTABLE_BUILD_STD=std,panic_abort RUSTUP_TOOLCHAIN=nightly wasm-pack build --target bundler --weak-refs --out-dir pkg",
31
+ "build:wasm-gz": "gzip --best --no-name pkg/mlt_wasm_bg.wasm --keep --force && du -sh pkg/*.wasm*",
32
+ "build:ts": "tsc",
33
+ "build": "npm run build:wasm && npm run build:ts && npm run build:wasm-gz",
34
+ "test": "vitest --coverage --coverage.reportOnFailure --run",
35
+ "test:watch": "vitest --coverage --coverage.reportOnFailure --ui",
36
+ "bench": "vitest bench"
37
+ },
38
+ "dependencies": {
39
+ "@mapbox/point-geometry": "^1.1.0",
40
+ "@maplibre/vt-pbf": "4.3.0"
41
+ },
42
+ "devDependencies": {
43
+ "@types/node": "^24.10.2",
44
+ "@vitest/coverage-v8": "^4.0.1",
45
+ "@vitest/ui": "^4.0.18",
46
+ "typescript": "^5.9.3",
47
+ "vite-plugin-top-level-await": "^1.6.0",
48
+ "vite-plugin-wasm": "^3.5.0",
49
+ "vitest": "^4.0.1"
50
+ }
51
+ }