@zwishing/emap 0.1.0 → 0.1.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.
- package/CHANGELOG.md +33 -2
- package/README.md +68 -8
- package/dist/emap.js +2 -2
- package/dist/emap.mjs +1 -5
- package/dist/index.d.ts +2 -2
- package/dist/map/types.d.ts +5 -0
- package/dist/mapshaper-vendor.mjs +1 -0
- package/dist/source/topology-source.d.ts +14 -0
- package/dist/ui/basemap-control.d.ts +2 -1
- package/package.json +17 -8
- package/style.css.d.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.2] - 2026-05-16
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- `import "@zwishing/emap"` is now self-contained in any browser bundler.
|
|
15
|
+
mapshaper is no longer routed through CommonJS in the ESM build (which could
|
|
16
|
+
emit a dead `require("adm-zip")` and a runtime-throwing `iconv-lite` helper);
|
|
17
|
+
it ships as a sibling ES module `dist/mapshaper-vendor.mjs` that `dist/emap.mjs`
|
|
18
|
+
imports by relative path. This **supersedes the 0.1.1 inlining approach** —
|
|
19
|
+
consumers can remove any `mapshaper`->browser alias, `Buffer` polyfill, or
|
|
20
|
+
band-aid tests.
|
|
21
|
+
|
|
22
|
+
## [0.1.1] - 2026-05-16
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- Exported `MapOptions` from the package root for typed constructor options.
|
|
27
|
+
- Added `TopologySource.fromBytes(...)` for in-memory file and upload flows.
|
|
28
|
+
- Documented bundler, stylesheet, and worker asset integration for
|
|
29
|
+
`@zwishing/emap`.
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
|
|
33
|
+
- Bundled mapshaper into the browser ESM entry so Vite/esbuild consumers no
|
|
34
|
+
longer need an app-level `Buffer` polyfill for local file parsing. _(Interim
|
|
35
|
+
approach — superseded in 0.1.2 by an externalized sibling ESM vendor.)_
|
|
36
|
+
- Changed `BasemapControl` to load MapLibre on demand instead of pulling it
|
|
37
|
+
into the root entry at import time.
|
|
38
|
+
- Corrected README package names and worker option examples.
|
|
39
|
+
|
|
10
40
|
## [0.1.0] - 2026-05-16
|
|
11
41
|
|
|
12
42
|
Initial public release.
|
|
@@ -32,7 +62,8 @@ Initial public release.
|
|
|
32
62
|
- Built-in UI controls: navigation, status, basemap, vertex edit, feature
|
|
33
63
|
draw, history, box / lasso selection, simplify.
|
|
34
64
|
- Distributed control stylesheet as `dist/emap.css` (importable via
|
|
35
|
-
|
|
65
|
+
`@zwishing/emap/style.css`).
|
|
36
66
|
|
|
37
|
-
[Unreleased]: https://github.com/zwishing/emap/compare/v0.1.
|
|
67
|
+
[Unreleased]: https://github.com/zwishing/emap/compare/v0.1.1...HEAD
|
|
68
|
+
[0.1.1]: https://github.com/zwishing/emap/compare/v0.1.0...v0.1.1
|
|
38
69
|
[0.1.0]: https://github.com/zwishing/emap/releases/tag/v0.1.0
|
package/README.md
CHANGED
|
@@ -18,9 +18,9 @@ A topology-oriented geographic map rendering and editing engine built around [Ma
|
|
|
18
18
|
## Install
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
pnpm add emap
|
|
21
|
+
pnpm add @zwishing/emap
|
|
22
22
|
# or
|
|
23
|
-
npm install emap
|
|
23
|
+
npm install @zwishing/emap
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
## Hello map
|
|
@@ -29,13 +29,13 @@ npm install emap
|
|
|
29
29
|
<!DOCTYPE html>
|
|
30
30
|
<html>
|
|
31
31
|
<head>
|
|
32
|
-
<link rel="stylesheet" href="node_modules/emap/dist/emap.css" />
|
|
32
|
+
<link rel="stylesheet" href="node_modules/@zwishing/emap/dist/emap.css" />
|
|
33
33
|
<style>#map { width: 100vw; height: 100vh; margin: 0; }</style>
|
|
34
34
|
</head>
|
|
35
35
|
<body>
|
|
36
36
|
<div id="map"></div>
|
|
37
|
-
<script src="node_modules/emap/dist/mapshaper-vendor.js"></script>
|
|
38
|
-
<script src="node_modules/emap/dist/emap.js"></script>
|
|
37
|
+
<script src="node_modules/@zwishing/emap/dist/mapshaper-vendor.js"></script>
|
|
38
|
+
<script src="node_modules/@zwishing/emap/dist/emap.js"></script>
|
|
39
39
|
<script>
|
|
40
40
|
const { Emap, TopologySource, NavigationControl, EditToolbar } = emap;
|
|
41
41
|
|
|
@@ -56,8 +56,45 @@ npm install emap
|
|
|
56
56
|
</html>
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
+
### Bundlers
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { Emap, TopologySource, type MapOptions } from '@zwishing/emap';
|
|
63
|
+
import '@zwishing/emap/style.css';
|
|
64
|
+
|
|
65
|
+
const options: MapOptions = { container: 'map' };
|
|
66
|
+
const map = new Emap(options);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The ESM build is browser-ready and bundles the mapshaper runtime it needs, so
|
|
70
|
+
Vite/Webpack/Bun consumers should not need to add a `Buffer` polyfill.
|
|
71
|
+
|
|
72
|
+
`BasemapControl` loads MapLibre only when a basemap is first enabled. If you use
|
|
73
|
+
that control, also include MapLibre's stylesheet in your app:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import 'maplibre-gl/dist/maplibre-gl.css';
|
|
77
|
+
```
|
|
78
|
+
|
|
59
79
|
Live demos in `test/examples/*.html` cover every feature area below.
|
|
60
80
|
|
|
81
|
+
## Browser bundlers (Vite / webpack / esbuild / Bun)
|
|
82
|
+
|
|
83
|
+
`import "@zwishing/emap"` works out of the box — no `resolve.alias`, no
|
|
84
|
+
`Buffer` polyfill, no bundler config. mapshaper is shipped as a sibling ES
|
|
85
|
+
module (`dist/mapshaper-vendor.mjs`) that `dist/emap.mjs` imports by relative
|
|
86
|
+
path; your bundler resolves it automatically from
|
|
87
|
+
`node_modules/@zwishing/emap/dist/`.
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { Emap, TopologySource } from "@zwishing/emap";
|
|
91
|
+
import "@zwishing/emap/style.css";
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The Web Worker is only needed if you opt into off-thread ops via `workerUrl`;
|
|
95
|
+
deploy `dist/emap-worker.js` and `dist/mapshaper-vendor.js` as same-directory
|
|
96
|
+
static assets then.
|
|
97
|
+
|
|
61
98
|
## API tour
|
|
62
99
|
|
|
63
100
|
### Core map
|
|
@@ -77,7 +114,9 @@ map.on('click', (e) => { /* … */ });
|
|
|
77
114
|
|
|
78
115
|
```ts
|
|
79
116
|
const source = await TopologySource.fromUrl('id', url); // GeoJSON / TopoJSON / ZIP
|
|
80
|
-
const source2 = await TopologySource.fromBytes('id', buf
|
|
117
|
+
const source2 = await TopologySource.fromBytes('id', buf, {
|
|
118
|
+
filename: 'local.geojson',
|
|
119
|
+
}); // ArrayBuffer / Uint8Array
|
|
81
120
|
source.getExtent();
|
|
82
121
|
source.getLayers();
|
|
83
122
|
```
|
|
@@ -154,7 +193,7 @@ Vertex drags / feature translates within a session merge into one undo step. Dat
|
|
|
154
193
|
Register validators that run after every committed edit. Failures fire `validationfailed` — the engine doesn't auto-undo, the app decides.
|
|
155
194
|
|
|
156
195
|
```ts
|
|
157
|
-
import { topologyValidator } from 'emap';
|
|
196
|
+
import { topologyValidator } from '@zwishing/emap';
|
|
158
197
|
|
|
159
198
|
const unregister = map.validators.register(topologyValidator({
|
|
160
199
|
sources: ['china'],
|
|
@@ -205,7 +244,7 @@ Attribute-only ops (each / join / rename-fields / sort) preserve the selection a
|
|
|
205
244
|
const map = new Emap({
|
|
206
245
|
container: 'map',
|
|
207
246
|
workerUrl: '/emap-worker.js', // built alongside dist/emap.js
|
|
208
|
-
|
|
247
|
+
useWorker: 'auto', // 'auto' | true | false
|
|
209
248
|
workerThreshold: 200_000, // vertex count
|
|
210
249
|
workerPoolSize: 2, // multiple workers (PR-22a)
|
|
211
250
|
});
|
|
@@ -215,6 +254,27 @@ map.on('workerjobend', (e) => console.log('end', e.durationMs));
|
|
|
215
254
|
```
|
|
216
255
|
|
|
217
256
|
The router classifies each op as cheap / expensive and overrides the threshold accordingly. Override the decision globally with `MapOptions.workerRouting?: (info) => boolean`.
|
|
257
|
+
`workerMode` is also accepted as a compatibility alias for `useWorker`; prefer `useWorker` in new code.
|
|
258
|
+
|
|
259
|
+
When worker offloading is enabled, serve both `emap-worker.js` and
|
|
260
|
+
`mapshaper-vendor.js` from the same directory. The worker loads the vendor file
|
|
261
|
+
with `importScripts('mapshaper-vendor.js')`.
|
|
262
|
+
|
|
263
|
+
```ts
|
|
264
|
+
const map = new Emap({
|
|
265
|
+
container: 'map',
|
|
266
|
+
useWorker: 'auto',
|
|
267
|
+
workerUrl: '/vendor/emap/emap-worker.js',
|
|
268
|
+
});
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
For bundler projects, copy these package files to that served directory during
|
|
272
|
+
your app build:
|
|
273
|
+
|
|
274
|
+
```text
|
|
275
|
+
node_modules/@zwishing/emap/dist/emap-worker.js
|
|
276
|
+
node_modules/@zwishing/emap/dist/mapshaper-vendor.js
|
|
277
|
+
```
|
|
218
278
|
|
|
219
279
|
### Snapshots
|
|
220
280
|
|