@sakuzu/maplibre-gl-draw 1.0.0 → 2.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/CHANGELOG.md +1109 -2
- package/README.ja.md +83 -50
- package/README.md +89 -53
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/dist/api/datasets.d.ts +263 -0
- package/dist/api/document.d.ts +66 -0
- package/dist/api/draw.d.ts +137 -0
- package/dist/api/draw.js +20 -0
- package/dist/api/drawing.d.ts +87 -0
- package/dist/api/errors.d.ts +35 -0
- package/dist/api/errors.js +35 -0
- package/dist/api/events.d.ts +316 -0
- package/dist/api/extension/context.d.ts +247 -0
- package/dist/api/extension/feature-type.d.ts +129 -0
- package/dist/api/extension/mode.d.ts +123 -0
- package/dist/api/extension/plugin.d.ts +51 -0
- package/dist/api/extension/plugin.js +3 -0
- package/dist/api/extension/provider.d.ts +119 -0
- package/dist/api/extension/provider.js +3 -0
- package/dist/api/extension/render.d.ts +176 -0
- package/dist/api/extension/render.js +3 -0
- package/dist/api/extension/store.d.ts +190 -0
- package/dist/api/extension/store.js +3 -0
- package/dist/api/extensions.d.ts +306 -0
- package/dist/api/extensions.js +3 -0
- package/dist/api/features.d.ts +188 -0
- package/dist/api/features.js +3 -0
- package/dist/api/groups.d.ts +111 -0
- package/dist/api/groups.js +3 -0
- package/dist/api/hidden.d.ts +45 -0
- package/dist/api/hidden.js +3 -0
- package/dist/api/impl/adapters.js +463 -0
- package/dist/api/impl/contexts.js +466 -0
- package/dist/api/impl/create-draw.js +124 -0
- package/dist/api/impl/datasets.js +405 -0
- package/dist/api/impl/destroy-guard.js +74 -0
- package/dist/api/impl/document.js +280 -0
- package/dist/api/impl/drawing.js +180 -0
- package/dist/api/impl/engine-context.d.ts +7 -0
- package/dist/api/{context.js → impl/engine-context.js} +49 -38
- package/dist/{maplibre-gl-draw.js → api/impl/engine.js} +145 -177
- package/dist/api/impl/events.js +423 -0
- package/dist/api/impl/extension-host.js +364 -0
- package/dist/api/impl/extensions.js +229 -0
- package/dist/api/impl/features.js +445 -0
- package/dist/api/impl/geometry/apply.d.ts +32 -0
- package/dist/api/{geometry → impl/geometry}/apply.js +10 -27
- package/dist/api/{geometry → impl/geometry}/buffer.d.ts +4 -3
- package/dist/api/{geometry → impl/geometry}/buffer.js +12 -23
- package/dist/api/{geometry → impl/geometry}/split.d.ts +4 -3
- package/dist/api/{geometry → impl/geometry}/split.js +10 -21
- package/dist/api/{geometry → impl/geometry}/targets.d.ts +2 -20
- package/dist/api/{geometry → impl/geometry}/targets.js +8 -35
- package/dist/api/impl/geometry/types.js +3 -0
- package/dist/api/impl/groups.d.ts +3 -0
- package/dist/api/impl/groups.js +268 -0
- package/dist/api/impl/hidden.js +60 -0
- package/dist/api/impl/import-export/constants.d.ts +22 -0
- package/dist/api/impl/import-export/constants.js +24 -0
- package/dist/api/{import-export → impl/import-export}/embedded-file.js +2 -2
- package/dist/api/{import-export → impl/import-export}/format-detection.d.ts +1 -1
- package/dist/api/{import-export → impl/import-export}/format-detection.js +2 -1
- package/dist/api/impl/import-export/geojson-export.d.ts +19 -0
- package/dist/api/{import-export → impl/import-export}/geojson-export.js +71 -104
- package/dist/api/{import-export → impl/import-export}/geojson-import.d.ts +11 -7
- package/dist/api/{import-export → impl/import-export}/geojson-import.js +139 -97
- package/dist/api/{import-export → impl/import-export}/geometry-validation.d.ts +14 -0
- package/dist/api/{import-export → impl/import-export}/geometry-validation.js +45 -0
- package/dist/api/impl/import-export/image-import.d.ts +16 -0
- package/dist/api/impl/import-export/image-import.js +73 -0
- package/dist/api/impl/import-export/legacy-image-style.d.ts +16 -0
- package/dist/api/impl/import-export/legacy-image-style.js +49 -0
- package/dist/api/impl/import-export/native-format.d.ts +14 -0
- package/dist/api/{import-export → impl/import-export}/native-format.js +32 -22
- package/dist/api/impl/import-export/native-upgrade.d.ts +8 -0
- package/dist/api/impl/import-export/native-upgrade.js +139 -0
- package/dist/api/{import-export → impl/import-export}/native-validation.d.ts +1 -1
- package/dist/api/{import-export → impl/import-export}/native-validation.js +15 -14
- package/dist/api/impl/import-export/style-validation.d.ts +24 -0
- package/dist/api/impl/import-export/style-validation.js +86 -0
- package/dist/api/impl/import-export/types.d.ts +52 -0
- package/dist/api/impl/import-export/types.js +3 -0
- package/dist/api/impl/input.js +180 -0
- package/dist/api/impl/layers.js +307 -0
- package/dist/api/impl/metadata.d.ts +1 -0
- package/dist/api/impl/metadata.js +22 -0
- package/dist/api/impl/options.d.ts +1 -0
- package/dist/api/impl/options.js +851 -0
- package/dist/api/impl/placement.d.ts +1 -0
- package/dist/api/impl/placement.js +138 -0
- package/dist/api/impl/render-context.d.ts +13 -0
- package/dist/api/impl/render-context.js +272 -0
- package/dist/api/impl/rows.d.ts +1 -0
- package/dist/api/impl/rows.js +46 -0
- package/dist/api/impl/selection.d.ts +1 -0
- package/dist/api/impl/selection.js +186 -0
- package/dist/api/impl/shared.d.ts +64 -0
- package/dist/api/impl/shared.js +178 -0
- package/dist/api/impl/validate-extension.d.ts +1 -0
- package/dist/api/impl/validate-extension.js +159 -0
- package/dist/api/layers.d.ts +130 -0
- package/dist/api/layers.js +3 -0
- package/dist/api/metadata.d.ts +18 -0
- package/dist/api/metadata.js +3 -0
- package/dist/api/model.d.ts +487 -0
- package/dist/api/model.js +47 -0
- package/dist/api/options.d.ts +466 -0
- package/dist/api/options.js +3 -0
- package/dist/api/selection.d.ts +94 -0
- package/dist/api/selection.js +3 -0
- package/dist/api/state.d.ts +155 -0
- package/dist/api/state.js +12 -0
- package/dist/{display → dataset}/chunk.d.ts +1 -1
- package/dist/{display → dataset}/chunk.js +4 -3
- package/dist/{display → dataset}/dataset.js +21 -21
- package/dist/dataset/interaction.d.ts +1 -0
- package/dist/{display → dataset}/interaction.js +18 -6
- package/dist/dataset/manager.d.ts +1 -0
- package/dist/dataset/provider.d.ts +1 -0
- package/dist/{display → dataset}/retained.d.ts +1 -1
- package/dist/{display → dataset}/retained.js +8 -7
- package/dist/dataset/source.d.ts +1 -0
- package/dist/{display → dataset}/source.js +17 -4
- package/dist/dataset/spatial.d.ts +1 -0
- package/dist/{display → dataset}/spatial.js +1 -1
- package/dist/dataset/style.d.ts +1 -0
- package/dist/{display → dataset}/style.js +1 -1
- package/dist/dataset/table-source.d.ts +1 -0
- package/dist/{display/columnar/source.js → dataset/table-source.js} +53 -25
- package/dist/{display → dataset}/thinning.d.ts +0 -10
- package/dist/{display → dataset}/thinning.js +3 -2
- package/dist/dataset/triangulation.d.ts +1 -0
- package/dist/{display → dataset}/triangulation.js +0 -0
- package/dist/{display → dataset}/types.d.ts +84 -121
- package/dist/dataset/types.js +61 -0
- package/dist/dispatcher/hit-test/box-strategies.js +13 -13
- package/dist/dispatcher/hit-test/box-strategy.d.ts +2 -15
- package/dist/dispatcher/hit-test/globe-shape.js +5 -4
- package/dist/dispatcher/hit-test/service.d.ts +17 -0
- package/dist/dispatcher/hit-test/service.js +80 -16
- package/dist/dispatcher/hit-test/strategies/base.d.ts +13 -19
- package/dist/dispatcher/hit-test/strategies/circle.js +3 -2
- package/dist/dispatcher/hit-test/strategies/image.js +6 -18
- package/dist/dispatcher/hit-test/strategies/line.d.ts +0 -6
- package/dist/dispatcher/hit-test/strategies/line.js +9 -2
- package/dist/dispatcher/hit-test/strategies/multi.d.ts +0 -8
- package/dist/dispatcher/hit-test/strategies/multi.js +17 -8
- package/dist/dispatcher/hit-test/strategies/point.d.ts +9 -7
- package/dist/dispatcher/hit-test/strategies/point.js +8 -4
- package/dist/dispatcher/hit-test/strategies/polygon.d.ts +0 -7
- package/dist/dispatcher/hit-test/strategies/polygon.js +11 -3
- package/dist/dispatcher/hit-test/topmost.d.ts +1 -1
- package/dist/dispatcher/input-router.js +154 -70
- package/dist/dispatcher/normalizer.js +25 -4
- package/dist/dispatcher/types.d.ts +6 -1
- package/dist/extension/feature-handler.d.ts +1 -182
- package/dist/extension/index.d.ts +4 -7
- package/dist/extension/renderers.d.ts +1 -208
- package/dist/geometry/angle.d.ts +0 -8
- package/dist/geometry/angle.js +0 -8
- package/dist/geometry/bbox.d.ts +4 -12
- package/dist/geometry/bbox.js +4 -12
- package/dist/geometry/boolean.d.ts +0 -51
- package/dist/geometry/boolean.js +0 -51
- package/dist/geometry/buffer.d.ts +0 -26
- package/dist/geometry/buffer.js +0 -26
- package/dist/geometry/circle.d.ts +0 -9
- package/dist/geometry/circle.js +0 -9
- package/dist/geometry/coords.d.ts +0 -16
- package/dist/geometry/coords.js +0 -16
- package/dist/geometry/distance.d.ts +0 -24
- package/dist/geometry/distance.js +0 -24
- package/dist/geometry/errors.d.ts +21 -36
- package/dist/geometry/errors.js +49 -29
- package/dist/geometry/geojson.d.ts +85 -0
- package/dist/geometry/geojson.js +173 -0
- package/dist/geometry/index.d.ts +38 -23
- package/dist/geometry/index.js +43 -31
- package/dist/geometry/measure.d.ts +0 -27
- package/dist/geometry/measure.js +0 -27
- package/dist/geometry/predicates.d.ts +0 -9
- package/dist/geometry/predicates.js +0 -9
- package/dist/geometry/public-bounds.d.ts +26 -0
- package/dist/geometry/public-bounds.js +30 -0
- package/dist/geometry/public-combine.d.ts +78 -0
- package/dist/geometry/public-combine.js +82 -0
- package/dist/geometry/public-create.d.ts +54 -0
- package/dist/geometry/public-create.js +70 -0
- package/dist/geometry/public-measure.d.ts +170 -0
- package/dist/geometry/public-measure.js +283 -0
- package/dist/geometry/public-predicates.d.ts +54 -0
- package/dist/geometry/public-predicates.js +144 -0
- package/dist/geometry/public-repair.d.ts +75 -0
- package/dist/geometry/public-repair.js +77 -0
- package/dist/geometry/simplify.d.ts +0 -7
- package/dist/geometry/simplify.js +0 -7
- package/dist/geometry/split.d.ts +0 -20
- package/dist/geometry/split.js +0 -20
- package/dist/geometry/units.d.ts +20 -12
- package/dist/geometry/units.js +20 -12
- package/dist/index.d.ts +66 -66
- package/dist/index.js +6 -18
- package/dist/messages.d.ts +7 -7
- package/dist/modes/draw/circle.js +83 -207
- package/dist/modes/draw/commit-layer.d.ts +5 -16
- package/dist/modes/draw/commit-layer.js +2 -13
- package/dist/modes/draw/freehand.js +108 -246
- package/dist/modes/draw/image.js +4 -2
- package/dist/modes/draw/index.d.ts +5 -5
- package/dist/modes/draw/index.js +5 -5
- package/dist/modes/draw/line.js +18 -354
- package/dist/modes/draw/point.js +29 -78
- package/dist/modes/draw/polygon.js +23 -368
- package/dist/modes/draw/trace-support.d.ts +43 -36
- package/dist/modes/draw/trace-support.js +95 -98
- package/dist/modes/draw/vertex-drawing.d.ts +1 -0
- package/dist/modes/draw/vertex-drawing.js +176 -0
- package/dist/modes/handler.d.ts +1 -285
- package/dist/modes/manager.d.ts +2 -2
- package/dist/modes/manager.js +3 -0
- package/dist/modes/select/box-selection.d.ts +3 -3
- package/dist/modes/select/box-selection.js +2 -1
- package/dist/modes/select/click-handler.d.ts +5 -5
- package/dist/modes/select/click-handler.js +22 -20
- package/dist/modes/select/cursor-handler.d.ts +2 -2
- package/dist/modes/select/drag/intermediate-writes.js +1 -1
- package/dist/modes/select/drag/move.js +3 -3
- package/dist/modes/select/drag/operation.d.ts +3 -3
- package/dist/modes/select/drag/radius.js +5 -4
- package/dist/modes/select/drag/transform.d.ts +2 -2
- package/dist/modes/select/drag/transform.js +11 -5
- package/dist/modes/select/drag/vertex.d.ts +2 -2
- package/dist/modes/select/drag/vertex.js +13 -8
- package/dist/modes/select/drag-handler.js +44 -25
- package/dist/modes/select/mode.js +17 -17
- package/dist/modes/select/shortcut-handler.d.ts +8 -8
- package/dist/modes/select/shortcut-handler.js +9 -7
- package/dist/operations/layer-operations.js +29 -168
- package/dist/operations/resize.d.ts +2 -2
- package/dist/operations/resize.js +5 -5
- package/dist/operations/rotate.js +5 -5
- package/dist/operations/selection-operations.d.ts +16 -1
- package/dist/operations/selection-operations.js +28 -13
- package/dist/operations/shared-vertex.js +4 -2
- package/dist/operations/trace-graph.d.ts +0 -18
- package/dist/operations/trace-graph.js +0 -18
- package/dist/operations/vertex.js +36 -35
- package/dist/shared/color.d.ts +1 -0
- package/dist/shared/color.js +245 -0
- package/dist/shared/config/constants.d.ts +1 -54
- package/dist/shared/config/constants.js +1 -58
- package/dist/shared/config/feature-style.d.ts +16 -13
- package/dist/shared/config/feature-style.js +9 -0
- package/dist/shared/config/rendering.d.ts +3 -3
- package/dist/shared/config/selection-highlight.d.ts +0 -15
- package/dist/shared/config/selection-highlight.js +4 -7
- package/dist/shared/config/selection.d.ts +2 -32
- package/dist/shared/config/selection.js +0 -18
- package/dist/shared/config/topology.d.ts +2 -2
- package/dist/shared/config/trace.d.ts +4 -4
- package/dist/shared/math/angle.d.ts +1 -1
- package/dist/shared/math/angle.js +1 -1
- package/dist/shared/math/circle.d.ts +1 -1
- package/dist/shared/math/circle.js +1 -1
- package/dist/shared/math/distance.d.ts +2 -1
- package/dist/shared/math/distance.js +3 -2
- package/dist/shared/math/index.d.ts +1 -1
- package/dist/shared/math/index.js +1 -1
- package/dist/shared/math/transform.d.ts +23 -0
- package/dist/shared/math/transform.js +47 -28
- package/dist/shared/properties.d.ts +18 -0
- package/dist/shared/properties.js +129 -0
- package/dist/shared/types/events.d.ts +15 -7
- package/dist/shared/types/model.d.ts +109 -159
- package/dist/shared/types/style.d.ts +1 -1
- package/dist/shared/utils/color.d.ts +2 -36
- package/dist/shared/utils/color.js +13 -70
- package/dist/shared/utils/coordinates.d.ts +30 -4
- package/dist/shared/utils/coordinates.js +56 -10
- package/dist/shared/utils/event-emitter.d.ts +1 -262
- package/dist/shared/utils/event-emitter.js +4 -3
- package/dist/shared/utils/feature-bbox.js +8 -7
- package/dist/shared/utils/feature-segments.js +5 -4
- package/dist/shared/utils/image.d.ts +0 -4
- package/dist/shared/utils/image.js +0 -6
- package/dist/shared/utils/name-generator.d.ts +14 -20
- package/dist/shared/utils/name-generator.js +20 -3
- package/dist/shared/utils/pixel-ratio.d.ts +9 -3
- package/dist/shared/utils/pixel-ratio.js +13 -4
- package/dist/shared/utils/property.d.ts +7 -50
- package/dist/shared/utils/property.js +22 -87
- package/dist/snapping/custom-targets.js +21 -4
- package/dist/snapping/indicator.js +20 -11
- package/dist/snapping/providers/display.d.ts +6 -1
- package/dist/snapping/providers/display.js +2 -1
- package/dist/snapping/providers/guide.d.ts +3 -43
- package/dist/snapping/providers/guide.js +1 -44
- package/dist/snapping/providers/intersection.js +1 -1
- package/dist/snapping/providers/store.js +3 -3
- package/dist/snapping/service.js +18 -7
- package/dist/snapping/types.d.ts +9 -35
- package/dist/store/draw-store.js +233 -142
- package/dist/store/local-visibility.d.ts +11 -6
- package/dist/store/local-visibility.js +38 -7
- package/dist/store/lock.d.ts +0 -6
- package/dist/store/lock.js +0 -6
- package/dist/store/memory/change-bus.d.ts +3 -3
- package/dist/store/memory/change-bus.js +12 -0
- package/dist/store/memory/file-store.d.ts +2 -2
- package/dist/store/memory/ui-state.d.ts +1 -51
- package/dist/store/memory/ui-state.js +122 -134
- package/dist/store/memory.d.ts +1 -8
- package/dist/store/memory.js +249 -45
- package/dist/store/ordering.d.ts +9 -0
- package/dist/store/ordering.js +17 -0
- package/dist/store/spatial/spatial-index.d.ts +1 -1
- package/dist/store/spatial/spatial-index.js +1 -1
- package/dist/store/spatial/store-spatial-index.d.ts +3 -1
- package/dist/store/spatial/store-spatial-index.js +9 -3
- package/dist/store/store.d.ts +66 -107
- package/dist/store/types.d.ts +1 -1
- package/dist/store/writable-layer.d.ts +1 -1
- package/dist/store/writable-layer.js +2 -2
- package/dist/table/builder.d.ts +83 -0
- package/dist/table/builder.js +381 -0
- package/dist/table/index.d.ts +37 -0
- package/dist/table/index.js +5 -0
- package/dist/table/packed-rtree.d.ts +1 -0
- package/dist/{display → table}/packed-rtree.js +1 -1
- package/dist/table/partition.d.ts +1 -0
- package/dist/{display → table}/partition.js +3 -3
- package/dist/table/prepare.d.ts +44 -0
- package/dist/table/prepare.js +136 -0
- package/dist/table/table.d.ts +1 -0
- package/dist/{display/columnar → table}/table.js +29 -25
- package/dist/{display/columnar → table}/types.d.ts +68 -72
- package/dist/table/types.js +3 -0
- package/dist/view/coordinator.js +4 -3
- package/dist/view/feature-companion.d.ts +13 -7
- package/dist/view/feature-companion.js +11 -3
- package/dist/view/globe-subdivision.js +3 -3
- package/dist/view/layer/attach.d.ts +12 -6
- package/dist/view/layer/attach.js +86 -10
- package/dist/view/layer/custom-layer.js +40 -11
- package/dist/view/layer/display-list.js +2 -1
- package/dist/view/layer/drape-planner.d.ts +2 -2
- package/dist/view/layer/frame-render.d.ts +3 -3
- package/dist/view/layer/frame-render.js +7 -2
- package/dist/view/layer/frame-state.d.ts +6 -6
- package/dist/view/layer/index.d.ts +2 -2
- package/dist/view/layer/index.js +1 -1
- package/dist/view/layer/render.d.ts +4 -4
- package/dist/view/layer/render.js +3 -8
- package/dist/view/layer/renderers.d.ts +2 -2
- package/dist/view/layer/renderers.js +1 -1
- package/dist/view/layer/slot-manager.d.ts +2 -2
- package/dist/view/layer/slot-manager.js +4 -4
- package/dist/view/layer/slots.d.ts +2 -2
- package/dist/view/layer/slots.js +1 -1
- package/dist/view/layer/store-retained-bbox.js +3 -2
- package/dist/view/layer/store-retained-classify.d.ts +5 -7
- package/dist/view/layer/store-retained-classify.js +19 -7
- package/dist/view/layer/store-retained-collect.js +8 -7
- package/dist/view/layer/store-retained-coord-patch.d.ts +0 -8
- package/dist/view/layer/store-retained-coord-patch.js +13 -4
- package/dist/view/layer/store-retained-immediate.d.ts +3 -3
- package/dist/view/layer/store-retained-immediate.js +3 -8
- package/dist/view/layer/store-retained-invalidation.d.ts +2 -2
- package/dist/view/layer/store-retained.d.ts +2 -2
- package/dist/view/layer/store-retained.js +1 -1
- package/dist/view/renderers/batch-manager.js +8 -7
- package/dist/view/renderers/drawer.js +21 -15
- package/dist/view/renderers/image.js +13 -39
- package/dist/view/renderers/line/line-types.d.ts +3 -3
- package/dist/view/renderers/line/sdf-line.js +3 -1
- package/dist/view/renderers/point/billboard-depth.js +1 -1
- package/dist/view/renderers/point/point-instance.js +1 -1
- package/dist/view/renderers/point/point-shape.js +2 -2
- package/dist/view/renderers/point/point-style.js +48 -4
- package/dist/view/renderers/polygon/batch.js +1 -2
- package/dist/view/renderers/polygon/fill.js +3 -1
- package/dist/view/renderers/polygon/sdf-polygon.js +2 -3
- package/dist/view/renderers/polygon/triangulator.d.ts +1 -1
- package/dist/view/renderers/stroke.js +3 -1
- package/dist/view/shaders/helpers.d.ts +2 -42
- package/dist/view/shaders/helpers.js +0 -6
- package/dist/view/shaders/projection.d.ts +15 -7
- package/dist/view/shaders/projection.js +23 -6
- package/dist/view/shaders/quad.d.ts +16 -12
- package/dist/view/shaders/quad.js +34 -13
- package/dist/view/style-rule.d.ts +5 -42
- package/dist/view/style-rule.js +20 -44
- package/dist/view/terrain/binding.d.ts +1 -0
- package/dist/view/terrain/binding.js +29 -0
- package/dist/view/terrain/context.d.ts +3 -4
- package/dist/view/terrain/context.js +4 -5
- package/dist/view/terrain/drape/geometry.js +1 -1
- package/dist/view/terrain/drape/pass.d.ts +1 -1
- package/dist/view/terrain/drape/pass.js +8 -7
- package/dist/view/terrain/polygon.d.ts +9 -5
- package/dist/view/terrain/polygon.js +16 -2
- package/dist/view/terrain/state.d.ts +1 -1
- package/dist/view/terrain/state.js +1 -1
- package/dist/view/terrain/tessellation.d.ts +2 -2
- package/dist/view/terrain/tessellation.js +1 -1
- package/dist/view/ui/auxiliary-handles.d.ts +6 -29
- package/dist/view/ui/bounds.js +8 -12
- package/dist/view/ui/handle-test.js +2 -2
- package/dist/view/ui/handle-thinning.js +17 -17
- package/dist/view/ui/handles.js +21 -13
- package/dist/view/ui/helper.d.ts +1 -1
- package/dist/view/ui/helper.js +1 -1
- package/dist/view/ui/index.d.ts +1 -1
- package/dist/view/ui/selection-scope.js +4 -2
- package/dist/view/ui/selection-ui/bounding-box.js +6 -6
- package/dist/view/ui/selection-ui/extension-registry.d.ts +31 -20
- package/dist/view/ui/selection-ui/extension-registry.js +70 -7
- package/dist/view/ui/selection-ui/index.d.ts +2 -2
- package/dist/view/ui/selection-ui/index.js +1 -1
- package/dist/view/ui/selection-ui/renderer.js +15 -38
- package/dist/view/ui/selection-ui/types.d.ts +17 -2
- package/dist/view/ui/selection-ui-drawer.d.ts +8 -0
- package/dist/view/ui/selection-ui-drawer.js +63 -2
- package/dist/view/ui/tentative.js +1 -1
- package/dist/webgl/index.d.ts +65 -0
- package/dist/webgl/index.js +62 -0
- package/package.json +38 -15
- package/dist/api/api.d.ts +0 -1259
- package/dist/api/api.js +0 -86
- package/dist/api/context.d.ts +0 -173
- package/dist/api/display-api.js +0 -23
- package/dist/api/event-api.d.ts +0 -13
- package/dist/api/event-api.js +0 -17
- package/dist/api/extension-api.d.ts +0 -46
- package/dist/api/extension-api.js +0 -85
- package/dist/api/feature-api.d.ts +0 -11
- package/dist/api/feature-api.js +0 -101
- package/dist/api/geometry/apply.d.ts +0 -51
- package/dist/api/geometry/boolean.d.ts +0 -28
- package/dist/api/geometry/boolean.js +0 -65
- package/dist/api/geometry/types.d.ts +0 -31
- package/dist/api/geometry-operations.d.ts +0 -162
- package/dist/api/geometry-operations.js +0 -94
- package/dist/api/group-api.d.ts +0 -10
- package/dist/api/group-api.js +0 -78
- package/dist/api/import-export/constants.d.ts +0 -29
- package/dist/api/import-export/constants.js +0 -40
- package/dist/api/import-export/file-name.d.ts +0 -10
- package/dist/api/import-export/file-name.js +0 -20
- package/dist/api/import-export/geojson-export.d.ts +0 -19
- package/dist/api/import-export/image-import.d.ts +0 -12
- package/dist/api/import-export/image-import.js +0 -53
- package/dist/api/import-export/index.d.ts +0 -9
- package/dist/api/import-export/index.js +0 -107
- package/dist/api/import-export/native-format.d.ts +0 -15
- package/dist/api/import-export/style-validation.d.ts +0 -27
- package/dist/api/import-export/style-validation.js +0 -49
- package/dist/api/import-export/types.d.ts +0 -26
- package/dist/api/index.d.ts +0 -15
- package/dist/api/index.js +0 -3
- package/dist/api/input-api.d.ts +0 -158
- package/dist/api/input-api.js +0 -144
- package/dist/api/instance-api.d.ts +0 -38
- package/dist/api/instance-api.js +0 -136
- package/dist/api/layer-api.d.ts +0 -12
- package/dist/api/layer-api.js +0 -62
- package/dist/api/selection-api.d.ts +0 -7
- package/dist/api/selection-api.js +0 -78
- package/dist/api/snapping-api.d.ts +0 -125
- package/dist/api/snapping-api.js +0 -50
- package/dist/api/topology-api.d.ts +0 -30
- package/dist/api/topology-api.js +0 -16
- package/dist/api/tracing-api.d.ts +0 -31
- package/dist/api/tracing-api.js +0 -16
- package/dist/dispatcher/hit-test/index.d.ts +0 -14
- package/dist/dispatcher/hit-test/index.js +0 -9
- package/dist/dispatcher/index.d.ts +0 -15
- package/dist/dispatcher/index.js +0 -3
- package/dist/display/columnar/index.d.ts +0 -12
- package/dist/display/columnar/index.js +0 -13
- package/dist/display/columnar/prepare.d.ts +0 -42
- package/dist/display/columnar/prepare.js +0 -116
- package/dist/display/index.d.ts +0 -13
- package/dist/display/types.js +0 -43
- package/dist/maplibre-gl-draw.d.ts +0 -47
- package/dist/modes/cursor.js +0 -72
- package/dist/modes/index.d.ts +0 -7
- package/dist/operations/index.d.ts +0 -9
- package/dist/operations/index.js +0 -3
- package/dist/plugins/index.d.ts +0 -10
- package/dist/plugins/mutation-hooks.d.ts +0 -28
- package/dist/plugins/mutation-hooks.js +0 -84
- package/dist/plugins/plugin-context.js +0 -367
- package/dist/plugins/plugin-manager.d.ts +0 -103
- package/dist/plugins/plugin-manager.js +0 -316
- package/dist/plugins/plugin.d.ts +0 -529
- package/dist/shared/config/index.d.ts +0 -17
- package/dist/shared/config/index.js +0 -8
- package/dist/shared/utils/index.d.ts +0 -15
- package/dist/shared/utils/index.js +0 -24
- package/dist/snapping/index.d.ts +0 -14
- package/dist/snapping/index.js +0 -4
- package/dist/store/change-merger.js +0 -102
- package/dist/store/event-bridge.js +0 -161
- package/dist/store/index.d.ts +0 -12
- package/dist/store/index.js +0 -4
- package/dist/view/index.d.ts +0 -47
- package/dist/view/index.js +0 -20
- /package/dist/api/{geometry/types.js → datasets.js} +0 -0
- /package/dist/api/{import-export/types.js → document.js} +0 -0
- /package/dist/{display/columnar/types.js → api/drawing.js} +0 -0
- /package/dist/{display/index.js → api/events.js} +0 -0
- /package/dist/{modes/index.js → api/extension/context.js} +0 -0
- /package/dist/{plugins/index.js → api/extension/feature-type.js} +0 -0
- /package/dist/{plugins/plugin.js → api/extension/mode.js} +0 -0
- /package/dist/api/{display-api.d.ts → impl/adapters.d.ts} +0 -0
- /package/dist/{display/columnar/source.d.ts → api/impl/contexts.d.ts} +0 -0
- /package/dist/{display/columnar/table.d.ts → api/impl/create-draw.d.ts} +0 -0
- /package/dist/{display/interaction.d.ts → api/impl/datasets.d.ts} +0 -0
- /package/dist/{display/manager.d.ts → api/impl/destroy-guard.d.ts} +0 -0
- /package/dist/{display/packed-rtree.d.ts → api/impl/document.d.ts} +0 -0
- /package/dist/{display/partition.d.ts → api/impl/drawing.d.ts} +0 -0
- /package/dist/{display/provider.d.ts → api/impl/engine.d.ts} +0 -0
- /package/dist/{display/source.d.ts → api/impl/events.d.ts} +0 -0
- /package/dist/{display/spatial.d.ts → api/impl/extension-host.d.ts} +0 -0
- /package/dist/{display/style.d.ts → api/impl/extensions.d.ts} +0 -0
- /package/dist/{display/triangulation.d.ts → api/impl/features.d.ts} +0 -0
- /package/dist/{modes/cursor.d.ts → api/impl/geometry/types.d.ts} +0 -0
- /package/dist/{plugins/plugin-context.d.ts → api/impl/hidden.d.ts} +0 -0
- /package/dist/api/{import-export → impl/import-export}/embedded-file.d.ts +0 -0
- /package/dist/api/{import-export → impl/import-export}/own-property.d.ts +0 -0
- /package/dist/api/{import-export → impl/import-export}/own-property.js +0 -0
- /package/dist/{store/change-merger.d.ts → api/impl/input.d.ts} +0 -0
- /package/dist/{store/event-bridge.d.ts → api/impl/layers.d.ts} +0 -0
- /package/dist/{display → dataset}/chunk-set.d.ts +0 -0
- /package/dist/{display → dataset}/chunk-set.js +0 -0
- /package/dist/{display → dataset}/dataset.d.ts +0 -0
- /package/dist/{display → dataset}/manager.js +0 -0
- /package/dist/{display → dataset}/provider.js +0 -0
- /package/dist/{display → dataset}/selection.d.ts +0 -0
- /package/dist/{display → dataset}/selection.js +0 -0
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `draw.extensions`: the collections of plugins, modes, feature types, overlays and providers
|
|
3
|
+
*
|
|
4
|
+
* Every kind of extension is added the same way: `add` registers it and returns the function
|
|
5
|
+
* that removes it, and `remove(name)` removes it by name.
|
|
6
|
+
*/
|
|
7
|
+
import type { FeatureTypeDefinition } from './extension/feature-type.js';
|
|
8
|
+
import type { ModeFactory } from './extension/mode.js';
|
|
9
|
+
import type { Plugin } from './extension/plugin.js';
|
|
10
|
+
import type { CompanionProvider, HandleProvider, SnapProvider } from './extension/provider.js';
|
|
11
|
+
import type { OverlayRenderer } from './extension/render.js';
|
|
12
|
+
/** The plugins, in the order they were added. */
|
|
13
|
+
export interface PluginsCollection {
|
|
14
|
+
/**
|
|
15
|
+
* Gets a plugin by name.
|
|
16
|
+
*
|
|
17
|
+
* @returns The plugin, or `undefined` when there is none with this name
|
|
18
|
+
*/
|
|
19
|
+
get(name: string): Plugin | undefined;
|
|
20
|
+
/** Lists the plugins in the order they were added. */
|
|
21
|
+
list(): Plugin[];
|
|
22
|
+
/** Counts the plugins. */
|
|
23
|
+
count(): number;
|
|
24
|
+
/** Whether a plugin with this name was added. */
|
|
25
|
+
has(name: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Adds a plugin.
|
|
28
|
+
*
|
|
29
|
+
* @returns The function that removes it again
|
|
30
|
+
* @throws `DrawError` with the code `already-exists` when a plugin with the same name was
|
|
31
|
+
* added
|
|
32
|
+
* or with `invalid-input` when the value does not have the shape of the contract
|
|
33
|
+
*/
|
|
34
|
+
add(plugin: Plugin): () => void;
|
|
35
|
+
/**
|
|
36
|
+
* Adds several plugins in one transaction: all of them or none.
|
|
37
|
+
*
|
|
38
|
+
* @returns The function that removes them again
|
|
39
|
+
* @throws `DrawError` with the code `already-exists` when one of the names is taken, or
|
|
40
|
+
* `invalid-input` when a value does not have the shape of the contract; nothing is added
|
|
41
|
+
* then
|
|
42
|
+
*/
|
|
43
|
+
addMany(plugins: readonly Plugin[]): () => void;
|
|
44
|
+
/**
|
|
45
|
+
* Removes a plugin, with everything it added.
|
|
46
|
+
*
|
|
47
|
+
* @returns True when it was removed
|
|
48
|
+
* @throws `DrawError` with the code `not-found` when there is no plugin with this name
|
|
49
|
+
*/
|
|
50
|
+
remove(name: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Removes several plugins, with everything they added: all of them or none.
|
|
53
|
+
*
|
|
54
|
+
* @returns True when they were removed
|
|
55
|
+
* @throws `DrawError` with the code `not-found` when one of the names does not exist;
|
|
56
|
+
* nothing is removed then
|
|
57
|
+
*/
|
|
58
|
+
removeMany(names: readonly string[]): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* The API a plugin offers to others.
|
|
61
|
+
*
|
|
62
|
+
* @returns The API, or `undefined` when there is no plugin with this name or it offers none
|
|
63
|
+
*/
|
|
64
|
+
getApi<T>(name: string): T | undefined;
|
|
65
|
+
}
|
|
66
|
+
/** The modes that were added, by name. */
|
|
67
|
+
export interface ModesCollection {
|
|
68
|
+
/**
|
|
69
|
+
* Gets the factory of a mode by name.
|
|
70
|
+
*
|
|
71
|
+
* @returns The factory, or `undefined` when there is no mode with this name
|
|
72
|
+
*/
|
|
73
|
+
get(name: string): ModeFactory | undefined;
|
|
74
|
+
/** Lists the names of the modes. */
|
|
75
|
+
list(): string[];
|
|
76
|
+
/** Counts the modes. */
|
|
77
|
+
count(): number;
|
|
78
|
+
/** Whether a mode with this name was added. */
|
|
79
|
+
has(name: string): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Adds a mode under a name.
|
|
82
|
+
*
|
|
83
|
+
* @returns The function that removes it again
|
|
84
|
+
* @throws `DrawError` with the code `already-exists` when the name is taken
|
|
85
|
+
* or with `invalid-input` when the value does not have the shape of the contract
|
|
86
|
+
*/
|
|
87
|
+
add(name: string, factory: ModeFactory): () => void;
|
|
88
|
+
/**
|
|
89
|
+
* Adds several modes in one transaction: all of them or none.
|
|
90
|
+
*
|
|
91
|
+
* @returns The function that removes them again
|
|
92
|
+
* @throws `DrawError` with the code `already-exists` when one of the names is taken, or
|
|
93
|
+
* `invalid-input` when a value does not have the shape of the contract; nothing is added
|
|
94
|
+
* then
|
|
95
|
+
*/
|
|
96
|
+
addMany(entries: readonly {
|
|
97
|
+
name: string;
|
|
98
|
+
factory: ModeFactory;
|
|
99
|
+
}[]): () => void;
|
|
100
|
+
/**
|
|
101
|
+
* Removes a mode.
|
|
102
|
+
*
|
|
103
|
+
* @returns True when it was removed
|
|
104
|
+
* @throws `DrawError` with the code `not-found` when there is no mode with this name
|
|
105
|
+
*/
|
|
106
|
+
remove(name: string): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Removes several modes: all of them or none.
|
|
109
|
+
*
|
|
110
|
+
* @returns True when they were removed
|
|
111
|
+
* @throws `DrawError` with the code `not-found` when one of the names does not exist;
|
|
112
|
+
* nothing is removed then
|
|
113
|
+
*/
|
|
114
|
+
removeMany(names: readonly string[]): boolean;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The custom feature types, by type name, and the definitions that override a built-in type.
|
|
118
|
+
*/
|
|
119
|
+
export interface FeatureTypesCollection {
|
|
120
|
+
/**
|
|
121
|
+
* Gets the definition of a feature type by name: a type that was added, or the definition
|
|
122
|
+
* that overrides a built-in type.
|
|
123
|
+
*
|
|
124
|
+
* @returns The definition, or `undefined` when there is none with this name
|
|
125
|
+
*/
|
|
126
|
+
get(name: string): FeatureTypeDefinition | undefined;
|
|
127
|
+
/** Lists the names of the feature types that were added or overridden. */
|
|
128
|
+
list(): string[];
|
|
129
|
+
/** Counts the feature types that were added or overridden. */
|
|
130
|
+
count(): number;
|
|
131
|
+
/** Whether a feature type with this name was added or overridden. */
|
|
132
|
+
has(name: string): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Adds a custom feature type. The type takes every feature of its type: its `appliesTo`, if
|
|
135
|
+
* it has one, is ignored.
|
|
136
|
+
*
|
|
137
|
+
* @returns The function that removes it again
|
|
138
|
+
* @throws `DrawError` with the code `already-exists` when the type name is taken
|
|
139
|
+
* or with `invalid-input` when the value does not have the shape of the contract
|
|
140
|
+
*/
|
|
141
|
+
add(definition: FeatureTypeDefinition): () => void;
|
|
142
|
+
/**
|
|
143
|
+
* Adds several custom feature types in one transaction: all of them or none.
|
|
144
|
+
*
|
|
145
|
+
* @returns The function that removes them again
|
|
146
|
+
* @throws `DrawError` with the code `already-exists` when one of the names is taken, or
|
|
147
|
+
* `invalid-input` when a value does not have the shape of the contract; nothing is added
|
|
148
|
+
* then
|
|
149
|
+
*/
|
|
150
|
+
addMany(definitions: readonly FeatureTypeDefinition[]): () => void;
|
|
151
|
+
/**
|
|
152
|
+
* Overrides a built-in feature type (`Point`, `LineString`, `Polygon`, `Circle`,
|
|
153
|
+
* `Freehand` or `Image`) with a definition of the same `type` and the same kind of
|
|
154
|
+
* `geometry` as the built-in one (`Point` for a circle and an image, `LineString` for a
|
|
155
|
+
* freehand line). The features of the type are drawn by its renderer from then on. Its
|
|
156
|
+
* `hitTest`, `boxSelect`, `bounds`, `outline`, `bbox` and `snapCandidates` replace those of
|
|
157
|
+
* the built-in type when it has them, and the built-in ones stay for the members it leaves
|
|
158
|
+
* out. Its `handles` are shown with those of the built-in type. With `appliesTo`, it takes
|
|
159
|
+
* only the features for which that returns true, and the others keep the built-in type
|
|
160
|
+
* entirely.
|
|
161
|
+
*
|
|
162
|
+
* The built-in type comes back with the function it returns, with `remove(type)`, and, for
|
|
163
|
+
* a plugin that overrode it through its context, when the plugin is removed. `add` keeps
|
|
164
|
+
* refusing the names of the built-in types.
|
|
165
|
+
*
|
|
166
|
+
* @returns The function that puts the built-in type back
|
|
167
|
+
* @throws `DrawError` with the code `invalid-input` when the type is not one of the
|
|
168
|
+
* built-in types above, its `geometry` is not the one of the built-in type, or the value
|
|
169
|
+
* does not have the shape of the contract, and `already-exists` when the type is already
|
|
170
|
+
* overridden
|
|
171
|
+
*/
|
|
172
|
+
override(definition: FeatureTypeDefinition): () => void;
|
|
173
|
+
/**
|
|
174
|
+
* Removes a custom feature type, or the definition that overrides a built-in type (the
|
|
175
|
+
* built-in type comes back).
|
|
176
|
+
*
|
|
177
|
+
* @returns True when it was removed
|
|
178
|
+
* @throws `DrawError` with the code `not-found` when there is no type with this name
|
|
179
|
+
*/
|
|
180
|
+
remove(name: string): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Removes several custom feature types: all of them or none.
|
|
183
|
+
*
|
|
184
|
+
* @returns True when they were removed
|
|
185
|
+
* @throws `DrawError` with the code `not-found` when one of the names does not exist;
|
|
186
|
+
* nothing is removed then
|
|
187
|
+
*/
|
|
188
|
+
removeMany(names: readonly string[]): boolean;
|
|
189
|
+
}
|
|
190
|
+
/** The renderers that draw above the features or between the layers, by name. */
|
|
191
|
+
export interface OverlaysCollection {
|
|
192
|
+
/**
|
|
193
|
+
* Gets an overlay renderer by name.
|
|
194
|
+
*
|
|
195
|
+
* @returns The renderer, or `undefined` when there is none with this name
|
|
196
|
+
*/
|
|
197
|
+
get(name: string): OverlayRenderer | undefined;
|
|
198
|
+
/** Lists the names of the overlay renderers. */
|
|
199
|
+
list(): string[];
|
|
200
|
+
/** Counts the overlay renderers. */
|
|
201
|
+
count(): number;
|
|
202
|
+
/** Whether an overlay renderer with this name was added. */
|
|
203
|
+
has(name: string): boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Adds an overlay renderer.
|
|
206
|
+
*
|
|
207
|
+
* @returns The function that removes it again
|
|
208
|
+
* @throws `DrawError` with the code `already-exists` when the name is taken
|
|
209
|
+
* or with `invalid-input` when the value does not have the shape of the contract
|
|
210
|
+
*/
|
|
211
|
+
add(renderer: OverlayRenderer): () => void;
|
|
212
|
+
/**
|
|
213
|
+
* Adds several overlay renderers in one transaction: all of them or none.
|
|
214
|
+
*
|
|
215
|
+
* @returns The function that removes them again
|
|
216
|
+
* @throws `DrawError` with the code `already-exists` when one of the names is taken, or
|
|
217
|
+
* `invalid-input` when a value does not have the shape of the contract; nothing is added
|
|
218
|
+
* then
|
|
219
|
+
*/
|
|
220
|
+
addMany(renderers: readonly OverlayRenderer[]): () => void;
|
|
221
|
+
/**
|
|
222
|
+
* Removes an overlay renderer.
|
|
223
|
+
*
|
|
224
|
+
* @returns True when it was removed
|
|
225
|
+
* @throws `DrawError` with the code `not-found` when there is none with this name
|
|
226
|
+
*/
|
|
227
|
+
remove(name: string): boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Removes several overlay renderers: all of them or none.
|
|
230
|
+
*
|
|
231
|
+
* @returns True when they were removed
|
|
232
|
+
* @throws `DrawError` with the code `not-found` when one of the names does not exist;
|
|
233
|
+
* nothing is removed then
|
|
234
|
+
*/
|
|
235
|
+
removeMany(names: readonly string[]): boolean;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* The providers of one kind, by name: snapping candidates, handles or companions.
|
|
239
|
+
*
|
|
240
|
+
* @typeParam T - The kind of provider
|
|
241
|
+
*/
|
|
242
|
+
export interface ProvidersCollection<T> {
|
|
243
|
+
/**
|
|
244
|
+
* Gets a provider by name.
|
|
245
|
+
*
|
|
246
|
+
* @returns The provider, or `undefined` when there is none with this name
|
|
247
|
+
*/
|
|
248
|
+
get(name: string): T | undefined;
|
|
249
|
+
/** Lists the names of the providers. */
|
|
250
|
+
list(): string[];
|
|
251
|
+
/** Counts the providers. */
|
|
252
|
+
count(): number;
|
|
253
|
+
/** Whether a provider with this name was added. */
|
|
254
|
+
has(name: string): boolean;
|
|
255
|
+
/**
|
|
256
|
+
* Adds a provider.
|
|
257
|
+
*
|
|
258
|
+
* @returns The function that removes it again
|
|
259
|
+
* @throws `DrawError` with the code `already-exists` when the name is taken
|
|
260
|
+
* or with `invalid-input` when the value does not have the shape of the contract
|
|
261
|
+
*/
|
|
262
|
+
add(provider: T): () => void;
|
|
263
|
+
/**
|
|
264
|
+
* Adds several providers in one transaction: all of them or none.
|
|
265
|
+
*
|
|
266
|
+
* @returns The function that removes them again
|
|
267
|
+
* @throws `DrawError` with the code `already-exists` when one of the names is taken, or
|
|
268
|
+
* `invalid-input` when a value does not have the shape of the contract; nothing is added
|
|
269
|
+
* then
|
|
270
|
+
*/
|
|
271
|
+
addMany(providers: readonly T[]): () => void;
|
|
272
|
+
/**
|
|
273
|
+
* Removes a provider.
|
|
274
|
+
*
|
|
275
|
+
* @returns True when it was removed
|
|
276
|
+
* @throws `DrawError` with the code `not-found` when there is no provider with this name
|
|
277
|
+
*/
|
|
278
|
+
remove(name: string): boolean;
|
|
279
|
+
/**
|
|
280
|
+
* Removes several providers: all of them or none.
|
|
281
|
+
*
|
|
282
|
+
* @returns True when they were removed
|
|
283
|
+
* @throws `DrawError` with the code `not-found` when one of the names does not exist;
|
|
284
|
+
* nothing is removed then
|
|
285
|
+
*/
|
|
286
|
+
removeMany(names: readonly string[]): boolean;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Every collection of extensions of a draw instance.
|
|
290
|
+
*/
|
|
291
|
+
export interface ExtensionsCollections {
|
|
292
|
+
/** The plugins: bundles of other extensions and state */
|
|
293
|
+
readonly plugins: PluginsCollection;
|
|
294
|
+
/** The modes: ways of receiving input */
|
|
295
|
+
readonly modes: ModesCollection;
|
|
296
|
+
/** The custom feature types */
|
|
297
|
+
readonly featureTypes: FeatureTypesCollection;
|
|
298
|
+
/** The renderers that draw above the features or between the layers */
|
|
299
|
+
readonly overlays: OverlaysCollection;
|
|
300
|
+
/** The providers of snapping candidates */
|
|
301
|
+
readonly snapProviders: ProvidersCollection<SnapProvider>;
|
|
302
|
+
/** The providers of handles on the selected features */
|
|
303
|
+
readonly handleProviders: ProvidersCollection<HandleProvider>;
|
|
304
|
+
/** The providers of companions drawn one step below a feature */
|
|
305
|
+
readonly companionProviders: ProvidersCollection<CompanionProvider>;
|
|
306
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `draw.features`: the features of the document
|
|
3
|
+
*/
|
|
4
|
+
import type { Feature, FeatureFilter, FeatureInput, FeaturePatch, FeatureStyleResolved, MoveTarget } from './model.js';
|
|
5
|
+
/**
|
|
6
|
+
* The features of the document, with the standard methods of a collection and the verbs
|
|
7
|
+
* that move, combine and split them.
|
|
8
|
+
*
|
|
9
|
+
* A wrong argument (an ID that does not exist, an input of the wrong shape) throws a
|
|
10
|
+
* `DrawError` and changes nothing. A refusal because of the state (read-only, a lock) returns
|
|
11
|
+
* `null` or `false` and changes nothing. A method whose name ends in `Many` runs in one
|
|
12
|
+
* transaction: all of it happens or none of it does.
|
|
13
|
+
*/
|
|
14
|
+
export interface FeaturesCollection {
|
|
15
|
+
/**
|
|
16
|
+
* Gets a feature by ID.
|
|
17
|
+
*
|
|
18
|
+
* @returns The feature, or `undefined` when there is none with this ID
|
|
19
|
+
*/
|
|
20
|
+
get(id: string): Feature | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Gets features by ID, in the order of the IDs.
|
|
23
|
+
*
|
|
24
|
+
* @returns One entry per ID: the feature, or `undefined` when there is none with that ID
|
|
25
|
+
*/
|
|
26
|
+
getMany(ids: readonly string[]): (Feature | undefined)[];
|
|
27
|
+
/**
|
|
28
|
+
* Lists the features in stacking order, from the back.
|
|
29
|
+
*
|
|
30
|
+
* @param filter - Keeps only the features that match every key given
|
|
31
|
+
*/
|
|
32
|
+
list(filter?: FeatureFilter): Feature[];
|
|
33
|
+
/**
|
|
34
|
+
* Counts the features.
|
|
35
|
+
*
|
|
36
|
+
* @param filter - Counts only the features that match every key given
|
|
37
|
+
*/
|
|
38
|
+
count(filter?: FeatureFilter): number;
|
|
39
|
+
/** Whether a feature with this ID exists. */
|
|
40
|
+
has(id: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the feature can be edited now: the document is not read-only, and neither the
|
|
43
|
+
* feature nor its group nor its layer is locked. A refused edit returns `null` or `false`
|
|
44
|
+
* for the same reasons.
|
|
45
|
+
*
|
|
46
|
+
* @throws `DrawError` with the code `not-found` when there is no feature with this ID
|
|
47
|
+
*/
|
|
48
|
+
isEditable(id: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a feature and returns it as it was stored.
|
|
51
|
+
*
|
|
52
|
+
* @returns The new feature, or `null` when the document is read-only
|
|
53
|
+
* @throws `DrawError` with the code `invalid-input` when the input has the wrong shape,
|
|
54
|
+
* `already-exists` when its ID is taken, `not-found` when its layer or group does not
|
|
55
|
+
* exist, or `invalid-state` when the input names no layer and the document has no layer
|
|
56
|
+
* to put it in
|
|
57
|
+
*/
|
|
58
|
+
create(input: FeatureInput): Feature | null;
|
|
59
|
+
/**
|
|
60
|
+
* Creates several features in one transaction: all of them or none.
|
|
61
|
+
*
|
|
62
|
+
* @returns The new features in the order of the inputs, or `null` when the document is
|
|
63
|
+
* read-only
|
|
64
|
+
* @throws `DrawError` as {@link FeaturesCollection.create} does, for any of the inputs;
|
|
65
|
+
* nothing is created then
|
|
66
|
+
*/
|
|
67
|
+
createMany(inputs: readonly FeatureInput[]): Feature[] | null;
|
|
68
|
+
/**
|
|
69
|
+
* Changes the keys given in the patch and returns the feature after the change.
|
|
70
|
+
*
|
|
71
|
+
* `properties` and `style` are merged key by key, and a key given as `undefined` is
|
|
72
|
+
* removed.
|
|
73
|
+
*
|
|
74
|
+
* @returns The changed feature, or `null` when the change is refused (read-only, a lock)
|
|
75
|
+
* @throws `DrawError` with the code `not-found` when there is no feature with this ID, or
|
|
76
|
+
* `invalid-input` when the patch has the wrong shape
|
|
77
|
+
*/
|
|
78
|
+
update(id: string, patch: FeaturePatch): Feature | null;
|
|
79
|
+
/**
|
|
80
|
+
* Changes several features in one transaction: all of them or none.
|
|
81
|
+
*
|
|
82
|
+
* @returns The changed features in the order of the patches, or `null` when the change is
|
|
83
|
+
* refused
|
|
84
|
+
* @throws `DrawError` as {@link FeaturesCollection.update} does, for any of the patches;
|
|
85
|
+
* nothing changes then
|
|
86
|
+
*/
|
|
87
|
+
updateMany(patches: readonly {
|
|
88
|
+
id: string;
|
|
89
|
+
patch: FeaturePatch;
|
|
90
|
+
}[]): Feature[] | null;
|
|
91
|
+
/**
|
|
92
|
+
* Deletes a feature.
|
|
93
|
+
*
|
|
94
|
+
* @returns True when it was deleted, false when the deletion is refused (read-only, a lock)
|
|
95
|
+
* @throws `DrawError` with the code `not-found` when there is no feature with this ID
|
|
96
|
+
*/
|
|
97
|
+
delete(id: string): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Deletes several features in one transaction: all of them or none.
|
|
100
|
+
*
|
|
101
|
+
* @returns True when they were deleted, false when the deletion is refused
|
|
102
|
+
* @throws `DrawError` with the code `not-found` when one of the IDs does not exist; nothing
|
|
103
|
+
* is deleted then
|
|
104
|
+
*/
|
|
105
|
+
deleteMany(ids: readonly string[]): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Moves a feature to another layer, into a group or out of its group; `index` of the
|
|
108
|
+
* target sets its position there.
|
|
109
|
+
*
|
|
110
|
+
* @returns True when it moved, false when the move is refused (read-only, a lock)
|
|
111
|
+
* @throws `DrawError` with the code `not-found` when the feature or the target does not
|
|
112
|
+
* exist
|
|
113
|
+
*/
|
|
114
|
+
move(id: string, to: MoveTarget): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Moves several features in one transaction, keeping their order: all of them or none.
|
|
117
|
+
*
|
|
118
|
+
* @returns True when they moved, false when the move is refused
|
|
119
|
+
* @throws `DrawError` with the code `not-found` when one of the features or the target does
|
|
120
|
+
* not exist; nothing moves then
|
|
121
|
+
*/
|
|
122
|
+
moveMany(ids: readonly string[], to: MoveTarget): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* The look a feature is drawn with: the default, the layer rule and the style of the
|
|
125
|
+
* feature put on top of each other.
|
|
126
|
+
*
|
|
127
|
+
* The colors of the `style` option and of the style of the feature are the strings they
|
|
128
|
+
* were given, alpha included; the color of a layer rule is `#rrggbb`, as
|
|
129
|
+
* {@link evaluateStyleRule} gives it, and a default is `#rrggbb`.
|
|
130
|
+
*
|
|
131
|
+
* @returns The look, or `undefined` when there is no feature with this ID
|
|
132
|
+
*/
|
|
133
|
+
getAppliedStyle(id: string): FeatureStyleResolved | undefined;
|
|
134
|
+
/**
|
|
135
|
+
* Joins areas into one feature and returns it; the result replaces the features given.
|
|
136
|
+
*
|
|
137
|
+
* @returns The new feature, or `null` when the operation is refused (read-only, a lock)
|
|
138
|
+
* @throws `DrawError` with the code `not-found` when one of the IDs does not exist, or
|
|
139
|
+
* `invalid-input` when fewer than two areas are given or one of the features is not an
|
|
140
|
+
* area
|
|
141
|
+
*/
|
|
142
|
+
union(ids: readonly string[]): Feature | null;
|
|
143
|
+
/**
|
|
144
|
+
* Subtracts other areas from an area and returns the result; the result replaces the area
|
|
145
|
+
* subtracted from, and the areas subtracted stay.
|
|
146
|
+
*
|
|
147
|
+
* @param id - The area to subtract from
|
|
148
|
+
* @param subtractIds - The areas to subtract
|
|
149
|
+
* @returns The resulting feature, or `null` when the operation is refused (read-only, a lock)
|
|
150
|
+
* @throws `DrawError` with the code `not-found` when one of the IDs does not exist, or
|
|
151
|
+
* `invalid-input` when one of the features is not an area
|
|
152
|
+
*/
|
|
153
|
+
difference(id: string, subtractIds: readonly string[]): Feature | null;
|
|
154
|
+
/**
|
|
155
|
+
* Keeps the part where areas overlap and returns it; the result replaces the features given.
|
|
156
|
+
*
|
|
157
|
+
* @returns The resulting feature, or `null` when the operation is refused (read-only, a lock)
|
|
158
|
+
* @throws `DrawError` with the code `not-found` when one of the IDs does not exist, or
|
|
159
|
+
* `invalid-input` when fewer than two areas are given or one of the features is not an
|
|
160
|
+
* area
|
|
161
|
+
*/
|
|
162
|
+
intersection(ids: readonly string[]): Feature | null;
|
|
163
|
+
/**
|
|
164
|
+
* Splits an area along a line and returns the features it made.
|
|
165
|
+
*
|
|
166
|
+
* @param id - The area to split
|
|
167
|
+
* @param lineId - The line to split along
|
|
168
|
+
* @returns The new features, or `null` when the operation is refused (read-only, a lock)
|
|
169
|
+
* @throws `DrawError` with the code `not-found` when one of the IDs does not exist, or
|
|
170
|
+
* `invalid-input` when the features are not an area and a line
|
|
171
|
+
*/
|
|
172
|
+
split(id: string, lineId: string): Feature[] | null;
|
|
173
|
+
/**
|
|
174
|
+
* Creates the areas around features.
|
|
175
|
+
*
|
|
176
|
+
* @param ids - The features to surround
|
|
177
|
+
* @param options - `distanceMeters` is the distance of the outline from the features, and
|
|
178
|
+
* `segments` the number of segments of a full circle, as in the buffer of the geometry
|
|
179
|
+
* entry
|
|
180
|
+
* @returns The new features, or `null` when the operation is refused (read-only, a lock)
|
|
181
|
+
* @throws `DrawError` with the code `not-found` when one of the IDs does not exist, or
|
|
182
|
+
* `invalid-input` when the distance is not a finite number
|
|
183
|
+
*/
|
|
184
|
+
buffer(ids: readonly string[], options: {
|
|
185
|
+
distanceMeters: number;
|
|
186
|
+
segments?: number;
|
|
187
|
+
}): Feature[] | null;
|
|
188
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `draw.groups`: the groups of the document
|
|
3
|
+
*/
|
|
4
|
+
import type { Group, GroupFilter, GroupInput, GroupPatch, MoveTarget } from './model.js';
|
|
5
|
+
/**
|
|
6
|
+
* The groups of the document, with the standard methods of a collection and the verbs that
|
|
7
|
+
* move them.
|
|
8
|
+
*
|
|
9
|
+
* A wrong argument (an ID that does not exist, an input of the wrong shape) throws a
|
|
10
|
+
* `DrawError` and changes nothing. A refusal because of the state (read-only, a lock) returns
|
|
11
|
+
* `null` or `false` and changes nothing. A method whose name ends in `Many` runs in one
|
|
12
|
+
* transaction: all of it happens or none of it does.
|
|
13
|
+
*/
|
|
14
|
+
export interface GroupsCollection {
|
|
15
|
+
/**
|
|
16
|
+
* Gets a group by ID.
|
|
17
|
+
*
|
|
18
|
+
* @returns The group, or `undefined` when there is none with this ID
|
|
19
|
+
*/
|
|
20
|
+
get(id: string): Group | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Gets groups by ID, in the order of the IDs.
|
|
23
|
+
*
|
|
24
|
+
* @returns One entry per ID: the group, or `undefined` when there is none with that ID
|
|
25
|
+
*/
|
|
26
|
+
getMany(ids: readonly string[]): (Group | undefined)[];
|
|
27
|
+
/**
|
|
28
|
+
* Lists the groups in stacking order, from the back.
|
|
29
|
+
*
|
|
30
|
+
* @param filter - Keeps only the groups that match every key given
|
|
31
|
+
*/
|
|
32
|
+
list(filter?: GroupFilter): Group[];
|
|
33
|
+
/**
|
|
34
|
+
* Counts the groups.
|
|
35
|
+
*
|
|
36
|
+
* @param filter - Counts only the groups that match every key given
|
|
37
|
+
*/
|
|
38
|
+
count(filter?: GroupFilter): number;
|
|
39
|
+
/** Whether a group with this ID exists. */
|
|
40
|
+
has(id: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a group of features and returns it as it was stored.
|
|
43
|
+
*
|
|
44
|
+
* @returns The new group, or `null` when the document is read-only
|
|
45
|
+
* @throws `DrawError` with the code `not-found` when one of the features does not exist,
|
|
46
|
+
* `invalid-input` when the features are not in the same layer, or `already-exists` when
|
|
47
|
+
* its ID is taken
|
|
48
|
+
*/
|
|
49
|
+
create(input: GroupInput): Group | null;
|
|
50
|
+
/**
|
|
51
|
+
* Creates several groups in one transaction: all of them or none.
|
|
52
|
+
*
|
|
53
|
+
* @returns The new groups in the order of the inputs, or `null` when the document is
|
|
54
|
+
* read-only
|
|
55
|
+
* @throws `DrawError` as {@link GroupsCollection.create} does, for any of the inputs;
|
|
56
|
+
* nothing is created then
|
|
57
|
+
*/
|
|
58
|
+
createMany(inputs: readonly GroupInput[]): Group[] | null;
|
|
59
|
+
/**
|
|
60
|
+
* Changes the keys given in the patch and returns the group after the change.
|
|
61
|
+
*
|
|
62
|
+
* @returns The changed group, or `null` when the change is refused (read-only, a lock)
|
|
63
|
+
* @throws `DrawError` with the code `not-found` when there is no group with this ID, or
|
|
64
|
+
* `invalid-input` when the patch has the wrong shape
|
|
65
|
+
*/
|
|
66
|
+
update(id: string, patch: GroupPatch): Group | null;
|
|
67
|
+
/**
|
|
68
|
+
* Changes several groups in one transaction: all of them or none.
|
|
69
|
+
*
|
|
70
|
+
* @returns The changed groups in the order of the patches, or `null` when the change is
|
|
71
|
+
* refused
|
|
72
|
+
* @throws `DrawError` as {@link GroupsCollection.update} does, for any of the patches;
|
|
73
|
+
* nothing changes then
|
|
74
|
+
*/
|
|
75
|
+
updateMany(patches: readonly {
|
|
76
|
+
id: string;
|
|
77
|
+
patch: GroupPatch;
|
|
78
|
+
}[]): Group[] | null;
|
|
79
|
+
/**
|
|
80
|
+
* Deletes a group; its features stay in the layer.
|
|
81
|
+
*
|
|
82
|
+
* @returns True when it was deleted, false when the deletion is refused (read-only, a lock)
|
|
83
|
+
* @throws `DrawError` with the code `not-found` when there is no group with this ID
|
|
84
|
+
*/
|
|
85
|
+
delete(id: string): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Deletes several groups in one transaction: all of them or none. Their features stay in
|
|
88
|
+
* their layers.
|
|
89
|
+
*
|
|
90
|
+
* @returns True when they were deleted, false when the deletion is refused
|
|
91
|
+
* @throws `DrawError` with the code `not-found` when one of the IDs does not exist; nothing
|
|
92
|
+
* is deleted then
|
|
93
|
+
*/
|
|
94
|
+
deleteMany(ids: readonly string[]): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Moves a group to another layer, or to another position in its layer.
|
|
97
|
+
*
|
|
98
|
+
* @returns True when it moved, false when the move is refused (read-only, a lock)
|
|
99
|
+
* @throws `DrawError` with the code `not-found` when the group or the target does not
|
|
100
|
+
* exist, or `invalid-input` when the target is a group
|
|
101
|
+
*/
|
|
102
|
+
move(id: string, to: MoveTarget): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Moves several groups in one transaction: all of them or none.
|
|
105
|
+
*
|
|
106
|
+
* @returns True when they moved, false when the move is refused
|
|
107
|
+
* @throws `DrawError` as {@link GroupsCollection.move} does, for any of the groups; nothing
|
|
108
|
+
* moves then
|
|
109
|
+
*/
|
|
110
|
+
moveMany(ids: readonly string[], to: MoveTarget): boolean;
|
|
111
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `draw.hidden`: what this client hides without changing the document
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The IDs of the features, groups and layers this client hides. Hiding changes only what this
|
|
6
|
+
* client draws; the document and its `visible` flags stay as they are.
|
|
7
|
+
*/
|
|
8
|
+
export interface HiddenCollection {
|
|
9
|
+
/** Whether this client hides the item with this ID. */
|
|
10
|
+
get(id: string): boolean;
|
|
11
|
+
/** Lists the IDs this client hides. */
|
|
12
|
+
list(): readonly string[];
|
|
13
|
+
/** Counts the IDs this client hides. */
|
|
14
|
+
count(): number;
|
|
15
|
+
/** Whether this client hides the item with this ID; the same as {@link HiddenCollection.get}. */
|
|
16
|
+
has(id: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Hides a feature, a group or a layer in this client only; the document does not change.
|
|
19
|
+
*
|
|
20
|
+
* @throws `DrawError` with the code `not-found` when the ID is not a feature, a group or a
|
|
21
|
+
* layer of the document
|
|
22
|
+
*/
|
|
23
|
+
add(id: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Hides several items in this client only, all of them or none.
|
|
26
|
+
*
|
|
27
|
+
* @throws `DrawError` with the code `not-found` when one of the IDs is not in the document;
|
|
28
|
+
* nothing is hidden then
|
|
29
|
+
*/
|
|
30
|
+
addMany(ids: readonly string[]): void;
|
|
31
|
+
/**
|
|
32
|
+
* Shows an item this client hid.
|
|
33
|
+
*
|
|
34
|
+
* @returns False when this client did not hide it
|
|
35
|
+
*/
|
|
36
|
+
remove(id: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Shows several items this client hid, all at once.
|
|
39
|
+
*
|
|
40
|
+
* @returns False when this client hid none of them
|
|
41
|
+
*/
|
|
42
|
+
removeMany(ids: readonly string[]): boolean;
|
|
43
|
+
/** Shows every item this client hid. */
|
|
44
|
+
clear(): void;
|
|
45
|
+
}
|