@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 +39 -1
- package/README.md +5 -0
- package/dist/emap.js +1 -1
- package/dist/emap.mjs +1 -1
- package/dist/source/topology-source.d.ts +28 -4
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { EventDispatcher } from '../core/events';
|
|
|
2
2
|
import { TopologySource as ITopologySource } from './source';
|
|
3
3
|
import { Bounds } from '../geo/bounds';
|
|
4
4
|
import { DisplayArcs } from './display-arcs';
|
|
5
|
-
import type { MapshaperDataset } from '../types/mapshaper-types';
|
|
5
|
+
import type { MapshaperDataset, MapshaperLayer } from '../types/mapshaper-types';
|
|
6
6
|
import type { ExportOptions } from './source';
|
|
7
7
|
import { type MapshaperRunner } from './mapshaper-runner';
|
|
8
8
|
export type TopologySourceData = string | {
|
|
@@ -63,6 +63,13 @@ export declare class TopologySource extends EventDispatcher implements ITopology
|
|
|
63
63
|
private _data;
|
|
64
64
|
private _loadVersion;
|
|
65
65
|
private _abortController;
|
|
66
|
+
/**
|
|
67
|
+
* Deferred backing the {@link setData} promise. Settled by the matching
|
|
68
|
+
* `_loadVersion`'s `_updateData` run (resolve on `data`, reject on `error`).
|
|
69
|
+
* A superseding `setData` resolves it early — last-write-wins, the newer
|
|
70
|
+
* call owns the next outcome.
|
|
71
|
+
*/
|
|
72
|
+
private _pending;
|
|
66
73
|
/**
|
|
67
74
|
* Sticky simplification floor. mapshaper's `-simplify` writes a
|
|
68
75
|
* `retainedInterval` into the resulting `ArcCollection`; we cache that
|
|
@@ -95,12 +102,24 @@ export declare class TopologySource extends EventDispatcher implements ITopology
|
|
|
95
102
|
* layer in one dataset — same behaviour as mapshaper's
|
|
96
103
|
* `-i FILE1 FILE2 ...` CLI invocation).
|
|
97
104
|
*
|
|
105
|
+
* Returns a promise that resolves with the source once the import
|
|
106
|
+
* completes and rejects if it fails — `await source.setData(...)` is the
|
|
107
|
+
* canonical way to wait for the dataset. The `data` / `error` events still
|
|
108
|
+
* fire for event-driven consumers.
|
|
109
|
+
*
|
|
98
110
|
* Last-write-wins: rapid back-to-back calls supersede each other. Only the
|
|
99
111
|
* latest call's outcome fires `data` / `error`; in-flight URL fetches from
|
|
100
|
-
* superseded calls are aborted.
|
|
112
|
+
* superseded calls are aborted. A superseded call's promise resolves early
|
|
113
|
+
* (the newer call owns the next outcome) so awaiting it never hangs.
|
|
101
114
|
*/
|
|
102
|
-
setData(data: TopologySourceInput):
|
|
115
|
+
setData(data: TopologySourceInput): Promise<TopologySource>;
|
|
103
116
|
private _updateData;
|
|
117
|
+
/**
|
|
118
|
+
* Settle the {@link setData} deferred for the given load version. Ignored
|
|
119
|
+
* if a newer call has already replaced it (the superseding `setData`
|
|
120
|
+
* resolved the old deferred early).
|
|
121
|
+
*/
|
|
122
|
+
private _settlePending;
|
|
104
123
|
private _hasSupportedExtension;
|
|
105
124
|
private _filenameFromContentType;
|
|
106
125
|
getDataset(): MapshaperDataset | undefined;
|
|
@@ -150,7 +169,12 @@ export declare class TopologySource extends EventDispatcher implements ITopology
|
|
|
150
169
|
* Single-file formats use the first entry directly; shapefile is zipped.
|
|
151
170
|
*/
|
|
152
171
|
private _filesToBlob;
|
|
153
|
-
|
|
172
|
+
/**
|
|
173
|
+
* The dataset's layers, or `[]` before the first successful import.
|
|
174
|
+
* Each entry is a {@link MapshaperLayer} (`name`, optional `geometry_type`
|
|
175
|
+
* — `'polygon' | 'polyline' | 'point'`, absent for data-only layers).
|
|
176
|
+
*/
|
|
177
|
+
getLayers(): MapshaperLayer[];
|
|
154
178
|
private _isZipFile;
|
|
155
179
|
private _extractZip;
|
|
156
180
|
private _isTextFile;
|