@zwishing/emap 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.
Files changed (114) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/LICENSE +373 -0
  3. package/README.md +294 -0
  4. package/SECURITY.md +56 -0
  5. package/dist/adapter/mapshaper-adapter.d.ts +282 -0
  6. package/dist/core/drag-pan-handler.d.ts +28 -0
  7. package/dist/core/events.d.ts +16 -0
  8. package/dist/core/interactions.d.ts +20 -0
  9. package/dist/core/mapshaper-worker-pool.d.ts +151 -0
  10. package/dist/core/tween.d.ts +26 -0
  11. package/dist/edit/commands/composite.d.ts +16 -0
  12. package/dist/edit/commands/dataset-replace.d.ts +43 -0
  13. package/dist/edit/commands/feature-affine.d.ts +72 -0
  14. package/dist/edit/commands/feature-create.d.ts +47 -0
  15. package/dist/edit/commands/feature-delete.d.ts +72 -0
  16. package/dist/edit/commands/feature-property-change.d.ts +34 -0
  17. package/dist/edit/commands/feature-translate.d.ts +55 -0
  18. package/dist/edit/commands/field-add.d.ts +24 -0
  19. package/dist/edit/commands/field-remove.d.ts +20 -0
  20. package/dist/edit/commands/field-rename.d.ts +19 -0
  21. package/dist/edit/commands/split-shared-arcs.d.ts +71 -0
  22. package/dist/edit/commands/vertex-delete.d.ts +26 -0
  23. package/dist/edit/commands/vertex-insert.d.ts +26 -0
  24. package/dist/edit/commands/vertex-move.d.ts +45 -0
  25. package/dist/edit/edit-command.d.ts +72 -0
  26. package/dist/edit/edit-history.d.ts +130 -0
  27. package/dist/edit/transaction.d.ts +59 -0
  28. package/dist/emap-worker.js +1 -0
  29. package/dist/emap.css +157 -0
  30. package/dist/emap.js +5 -0
  31. package/dist/emap.mjs +5 -0
  32. package/dist/geo/bounds.d.ts +18 -0
  33. package/dist/geo/crs-resolver.d.ts +35 -0
  34. package/dist/geo/projection.d.ts +28 -0
  35. package/dist/geo/transform.d.ts +19 -0
  36. package/dist/geo/viewport.d.ts +52 -0
  37. package/dist/index.d.ts +86 -0
  38. package/dist/map/attribute-ops.d.ts +61 -0
  39. package/dist/map/command-args.d.ts +28 -0
  40. package/dist/map/edit-sessions.d.ts +97 -0
  41. package/dist/map/edit-state-store.d.ts +41 -0
  42. package/dist/map/emap-host.d.ts +79 -0
  43. package/dist/map/feature-accessor.d.ts +43 -0
  44. package/dist/map/feature-query.d.ts +58 -0
  45. package/dist/map/highlight-manager.d.ts +17 -0
  46. package/dist/map/layer-registry.d.ts +33 -0
  47. package/dist/map/layer.d.ts +29 -0
  48. package/dist/map/map.d.ts +386 -0
  49. package/dist/map/mapshaper-ops.d.ts +56 -0
  50. package/dist/map/op-result.d.ts +46 -0
  51. package/dist/map/ops/_context.d.ts +41 -0
  52. package/dist/map/ops/_runner.d.ts +55 -0
  53. package/dist/map/ops/affine.d.ts +4 -0
  54. package/dist/map/ops/buffer.d.ts +4 -0
  55. package/dist/map/ops/check-geometry.d.ts +4 -0
  56. package/dist/map/ops/clean.d.ts +4 -0
  57. package/dist/map/ops/clip-erase.d.ts +5 -0
  58. package/dist/map/ops/data-fill.d.ts +4 -0
  59. package/dist/map/ops/dissolve.d.ts +20 -0
  60. package/dist/map/ops/divide.d.ts +4 -0
  61. package/dist/map/ops/drop-layer.d.ts +4 -0
  62. package/dist/map/ops/each-filter.d.ts +5 -0
  63. package/dist/map/ops/explode.d.ts +4 -0
  64. package/dist/map/ops/filter-fields.d.ts +4 -0
  65. package/dist/map/ops/filter-geom.d.ts +4 -0
  66. package/dist/map/ops/filter-islands.d.ts +4 -0
  67. package/dist/map/ops/filter-slivers.d.ts +4 -0
  68. package/dist/map/ops/innerlines.d.ts +4 -0
  69. package/dist/map/ops/intersection-points.d.ts +4 -0
  70. package/dist/map/ops/join-table.d.ts +4 -0
  71. package/dist/map/ops/lines.d.ts +4 -0
  72. package/dist/map/ops/merge-layers.d.ts +4 -0
  73. package/dist/map/ops/mosaic.d.ts +4 -0
  74. package/dist/map/ops/points.d.ts +4 -0
  75. package/dist/map/ops/polygons.d.ts +4 -0
  76. package/dist/map/ops/project.d.ts +4 -0
  77. package/dist/map/ops/rebuild-topology.d.ts +4 -0
  78. package/dist/map/ops/rename-fields.d.ts +4 -0
  79. package/dist/map/ops/rename-layer.d.ts +4 -0
  80. package/dist/map/ops/simplify.d.ts +4 -0
  81. package/dist/map/ops/snap.d.ts +4 -0
  82. package/dist/map/ops/sort-features.d.ts +4 -0
  83. package/dist/map/ops/split-layer.d.ts +4 -0
  84. package/dist/map/ops/union.d.ts +4 -0
  85. package/dist/map/ops/unique-features.d.ts +4 -0
  86. package/dist/map/selection.d.ts +73 -0
  87. package/dist/map/types.d.ts +1072 -0
  88. package/dist/map/worker-routing.d.ts +40 -0
  89. package/dist/mapshaper-vendor.js +1 -0
  90. package/dist/renderer/canvas-painter.d.ts +50 -0
  91. package/dist/renderer/edit-overlay-renderer.d.ts +22 -0
  92. package/dist/renderer/painter.d.ts +52 -0
  93. package/dist/shim.d.ts +1 -0
  94. package/dist/source/display-arcs.d.ts +49 -0
  95. package/dist/source/layer-utils.d.ts +12 -0
  96. package/dist/source/mapshaper-runner.d.ts +22 -0
  97. package/dist/source/source.d.ts +80 -0
  98. package/dist/source/topology-source.d.ts +145 -0
  99. package/dist/types/mapshaper-types.d.ts +182 -0
  100. package/dist/ui/basemap-control.d.ts +35 -0
  101. package/dist/ui/box-select-control.d.ts +67 -0
  102. package/dist/ui/control.d.ts +6 -0
  103. package/dist/ui/draw-feature-control.d.ts +82 -0
  104. package/dist/ui/edit-toolbar.d.ts +27 -0
  105. package/dist/ui/history-control.d.ts +29 -0
  106. package/dist/ui/lasso-select-control.d.ts +96 -0
  107. package/dist/ui/navigation-control.d.ts +16 -0
  108. package/dist/ui/simplify-control.d.ts +40 -0
  109. package/dist/ui/status-control.d.ts +23 -0
  110. package/dist/ui/vertex-edit-control.d.ts +111 -0
  111. package/dist/validation/builtin/topology.d.ts +19 -0
  112. package/dist/validation/registry.d.ts +23 -0
  113. package/dist/validation/validator.d.ts +47 -0
  114. package/package.json +90 -0
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { AffineLayerOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function affineLayer(ctx: OpContext, opts: AffineLayerOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { BufferOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function bufferLayer(ctx: OpContext, opts: BufferOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { CheckGeometryOptions, GeometryCheckReport } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function checkGeometry(ctx: OpContext, opts: CheckGeometryOptions): Promise<OpResult<GeometryCheckReport>>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { CleanOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function cleanLayer(ctx: OpContext, opts: CleanOptions): Promise<OpResult>;
@@ -0,0 +1,5 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { ClipEraseOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function clipLayer(ctx: OpContext, opts: ClipEraseOptions): Promise<OpResult>;
5
+ export declare function eraseLayer(ctx: OpContext, opts: ClipEraseOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { DataFillOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function dataFill(ctx: OpContext, opts: DataFillOptions): Promise<OpResult>;
@@ -0,0 +1,20 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { DissolveOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function dissolveLayer(ctx: OpContext, opts: DissolveOptions): Promise<OpResult>;
5
+ /**
6
+ * Merge the currently-selected features (when they all share the same
7
+ * source/layer) into one feature via the same `-dissolve` pipeline.
8
+ *
9
+ * Recipe:
10
+ * 1. Stamp a discriminator field directly onto records — selected rows
11
+ * get `'M'`, unselected rows get a unique `'k_<id>'` so they pass
12
+ * through dissolve unchanged.
13
+ * 2. Run `-dissolve __emap_merge copy-fields=<all original>`.
14
+ * 3. Drop the discriminator with `-filter-fields __emap_merge invert`.
15
+ *
16
+ * Direct record mutation (instead of an `-each EXPR` pre-pass that
17
+ * embedded `JSON.stringify(selectedIds)` to test membership) keeps the
18
+ * command string size O(1) regardless of selection cardinality.
19
+ */
20
+ export declare function mergeSelected(ctx: OpContext): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { DivideOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function divideLayer(ctx: OpContext, opts: DivideOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { DropLayerOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function dropLayer(ctx: OpContext, opts: DropLayerOptions): Promise<OpResult>;
@@ -0,0 +1,5 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { ApplyExpressionOptions, FilterOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function applyExpression(ctx: OpContext, opts: ApplyExpressionOptions): Promise<OpResult>;
5
+ export declare function filterFeatures(ctx: OpContext, opts: FilterOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { ExplodeOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function explodeLayer(ctx: OpContext, opts: ExplodeOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { FilterFieldsOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function filterFields(ctx: OpContext, opts: FilterFieldsOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { FilterGeomOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function filterGeom(ctx: OpContext, opts: FilterGeomOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { FilterIslandsOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function filterIslands(ctx: OpContext, opts: FilterIslandsOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { FilterSliversOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function filterSlivers(ctx: OpContext, opts: FilterSliversOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { InnerlinesOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function innerlinesLayer(ctx: OpContext, opts: InnerlinesOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { IntersectionPointsLayerOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function intersectionPointsLayer(ctx: OpContext, opts: IntersectionPointsLayerOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { JoinTableOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function joinTable(ctx: OpContext, opts: JoinTableOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { LinesOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function linesLayer(ctx: OpContext, opts: LinesOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { MergeLayersOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function mergeLayers(ctx: OpContext, opts: MergeLayersOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { MosaicOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function mosaicLayer(ctx: OpContext, opts: MosaicOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { PointsOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function pointsLayer(ctx: OpContext, opts: PointsOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { PolygonsOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function polygonsLayer(ctx: OpContext, opts: PolygonsOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { ProjectOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function projectLayer(ctx: OpContext, opts: ProjectOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { RebuildTopologyOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function rebuildTopology(ctx: OpContext, opts: RebuildTopologyOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { RenameFieldsOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function renameFields(ctx: OpContext, opts: RenameFieldsOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { RenameLayerOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function renameLayer(ctx: OpContext, opts: RenameLayerOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { SimplifyOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function simplifyLayer(ctx: OpContext, opts: SimplifyOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { SnapOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function snapLayer(ctx: OpContext, opts: SnapOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { SortFeaturesOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function sortFeatures(ctx: OpContext, opts: SortFeaturesOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { SplitLayerOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function splitLayer(ctx: OpContext, opts: SplitLayerOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { UnionOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function unionLayers(ctx: OpContext, opts: UnionOptions): Promise<OpResult>;
@@ -0,0 +1,4 @@
1
+ import { type OpResult } from '../op-result';
2
+ import type { UniqueFeaturesOptions } from '../types';
3
+ import type { OpContext } from './_context';
4
+ export declare function uniqueFeatures(ctx: OpContext, opts: UniqueFeaturesOptions): Promise<OpResult>;
@@ -0,0 +1,73 @@
1
+ import type { FeatureRef } from './map';
2
+ /** Mutation modes for {@link Selection.apply}. */
3
+ export type SelectMode = 'replace' | 'add' | 'toggle';
4
+ /** Diff produced by every selection mutation. */
5
+ export interface SelectionDiff {
6
+ /** Refs newly present after the mutation */
7
+ added: FeatureRef[];
8
+ /** Refs newly absent after the mutation */
9
+ removed: FeatureRef[];
10
+ /** True when at least one of `added` / `removed` is non-empty */
11
+ changed: boolean;
12
+ }
13
+ /**
14
+ * Opaque snapshot returned by {@link Selection.snapshot} and consumed by
15
+ * {@link Selection.restore}. Implementation detail — do not depend on
16
+ * the concrete shape.
17
+ */
18
+ export type SelectionSnapshot = ReadonlySet<string>;
19
+ /**
20
+ * Persistent multi-source / multi-layer feature selection.
21
+ *
22
+ * Storage shape mirrors `HighlightManager`: `Map<source, Map<layer, Set<id>>>`.
23
+ * That gives O(1) `has` checks, O(1) iteration per layer for downstream
24
+ * operations, and free deduplication.
25
+ *
26
+ * Distinct from highlight on purpose: selection is persistent state ("what
27
+ * the next operation will act on"), highlight is transient render state
28
+ * ("what to draw extra strokes on right now").
29
+ */
30
+ export declare class Selection {
31
+ private _byKey;
32
+ private _size;
33
+ /** Number of distinct selected features across all source/layer pairs. */
34
+ get size(): number;
35
+ /** Returns `true` when the given feature is currently in the selection. */
36
+ has(ref: FeatureRef): boolean;
37
+ /** Flat list of every selected ref, in insertion order within each layer. */
38
+ getAll(): FeatureRef[];
39
+ /** Numeric ids selected within a single source/layer, in insertion order. */
40
+ getByLayer(source: string, layer: string): number[];
41
+ /** Remove every entry. Returns the diff of refs that were actually cleared. */
42
+ clear(): SelectionDiff;
43
+ /**
44
+ * Mutate the set according to `mode`:
45
+ * - `replace`: result is exactly `refs` (clears prior state)
46
+ * - `add`: union of current state and `refs`
47
+ * - `toggle`: each ref is flipped (present → removed, absent → added)
48
+ *
49
+ * Returns a diff so the caller can fire events with `{ added, removed }`.
50
+ */
51
+ apply(refs: ReadonlyArray<FeatureRef>, mode: SelectMode): SelectionDiff;
52
+ /** Remove the listed refs. Refs not present in the selection are skipped silently. */
53
+ remove(refs: ReadonlyArray<FeatureRef>): SelectionDiff;
54
+ /**
55
+ * Capture the current selection as an opaque snapshot. The returned
56
+ * value is meant to be handed back to {@link restore} later — its
57
+ * shape (currently `Set<string>` of encoded refs) is an implementation
58
+ * detail and may change.
59
+ *
60
+ * Used by `Transaction` for rollback so a transaction-internal
61
+ * operation that clears the selection can be reverted.
62
+ */
63
+ snapshot(): SelectionSnapshot;
64
+ /**
65
+ * Replace the current selection with the contents of a previously
66
+ * captured snapshot. Returns the diff between the old state and the
67
+ * restored state so callers can fire a single `selectionchange` event.
68
+ */
69
+ restore(snap: SelectionSnapshot): SelectionDiff;
70
+ private _addOne;
71
+ private _removeOne;
72
+ private _refSetSnapshot;
73
+ }