@zwishing/emap 0.1.3 → 0.2.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/CHANGELOG.md CHANGED
@@ -7,6 +7,43 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.2.0] - 2026-05-17
11
+
12
+ ### Changed
13
+
14
+ - **BREAKING:** `TopologySource.setData()` now returns
15
+ `Promise<TopologySource>` instead of `this`. It resolves once the import
16
+ completes and rejects if it fails, so `await source.setData(...)` is now the
17
+ canonical way to wait for the dataset (previously `await` resolved on the
18
+ next microtask, before the data existed — a silent footgun that left the
19
+ map blank). The `data` / `error` events still fire unchanged for
20
+ event-driven consumers, and last-write-wins semantics are preserved (a
21
+ superseded call's promise resolves early so awaiting it never hangs).
22
+ Fluent chaining off the return value (`source.setData(x).getLayers()`) no
23
+ longer works — `await` first. `fromUrl` / `fromBytes` now delegate to the
24
+ awaitable `setData` internally.
25
+ - `TopologySource.getLayers()` is now typed `MapshaperLayer[]` instead of
26
+ `any[]`, so `name` / `geometry_type` are reachable without an `any` cast at
27
+ every consumer. Runtime behavior is unchanged (additive type only).
28
+
29
+ ### Fixed
30
+
31
+ - Corrected `test/examples/*.html` (`box-select`, `draw-snap-edge`,
32
+ `lasso-select`, `polygon-fill`) that passed the camelCase `sourceLayer` key
33
+ to `addLayer` specs. The `LayerSpecification` only reads the canonical
34
+ MapLibre-style `'source-layer'`, so the camelCase key was silently ignored
35
+ and resolution fell back to the first layer — a real bug in `polygon-fill`,
36
+ which targets a specific layer. Examples now use `'source-layer'`.
37
+ - `npm run dev-build` was broken: the `prefer-browser-mapshaper-modules`
38
+ Rollup plugin only matched the terser-minified ternary form of mapshaper's
39
+ module loader, so it patched the production vendor but threw `Unable to
40
+ patch mapshaper module loader` on the unminified dev vendor (terser does
41
+ not run in dev). `dist/emap-dev.js` — referenced by every
42
+ `test/examples/*.html` — could not be built at all. Added a second pattern
43
+ matching the unminified `if / else-if / else` loader block and reordering
44
+ it to prefer `window.modules` over `require` (same intent as the minified
45
+ path). Dev and prod builds now both patch the vendor correctly.
46
+
10
47
  ## [0.1.3] - 2026-05-17
11
48
 
12
49
  ### Fixed
@@ -75,7 +112,8 @@ Initial public release.
75
112
  - Distributed control stylesheet as `dist/emap.css` (importable via
76
113
  `@zwishing/emap/style.css`).
77
114
 
78
- [Unreleased]: https://github.com/zwishing/emap/compare/v0.1.3...HEAD
115
+ [Unreleased]: https://github.com/zwishing/emap/compare/v0.2.0...HEAD
116
+ [0.2.0]: https://github.com/zwishing/emap/compare/v0.1.3...v0.2.0
79
117
  [0.1.3]: https://github.com/zwishing/emap/compare/v0.1.2...v0.1.3
80
118
  [0.1.2]: https://github.com/zwishing/emap/compare/v0.1.1...v0.1.2
81
119
  [0.1.1]: https://github.com/zwishing/emap/compare/v0.1.0...v0.1.1
package/README.md CHANGED
@@ -117,6 +117,11 @@ const source = await TopologySource.fromUrl('id', url); // GeoJSON / TopoJSO
117
117
  const source2 = await TopologySource.fromBytes('id', buf, {
118
118
  filename: 'local.geojson',
119
119
  }); // ArrayBuffer / Uint8Array
120
+
121
+ // Re-importing an existing source: setData is awaitable — it resolves
122
+ // once the dataset is ready, so getLayers()/getExtent() are safe after it.
123
+ // The `data` / `error` events still fire for event-driven consumers.
124
+ await source.setData({ filename: 'next.geojson', content: bytes });
120
125
  source.getExtent();
121
126
  source.getLayers();
122
127
  ```