@sakuzu/maplibre-gl-draw 1.0.0 → 2.0.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 +1016 -2
- package/README.ja.md +39 -19
- package/README.md +41 -21
- package/dist/api/datasets.d.ts +258 -0
- package/dist/api/document.d.ts +66 -0
- package/dist/api/draw.d.ts +135 -0
- package/dist/api/draw.js +18 -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 +306 -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 +404 -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 +422 -0
- package/dist/api/impl/extension-host.js +361 -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 +822 -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 +18 -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 +82 -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 +152 -69
- package/dist/dispatcher/normalizer.js +6 -2
- 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 +81 -0
- package/dist/geometry/geojson.js +164 -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 +52 -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 +1 -1
- package/dist/view/layer/attach.js +1 -1
- 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 +20 -9
- 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
|
@@ -4,33 +4,32 @@
|
|
|
4
4
|
* Types only. They sit in shared/ so that every layer can use them (store/types.ts
|
|
5
5
|
* re-exports them).
|
|
6
6
|
*/
|
|
7
|
+
import type { Geometry, Position } from 'geojson';
|
|
7
8
|
/**
|
|
8
9
|
* A position as `[longitude, latitude]` in degrees (WGS 84), in the same order as GeoJSON
|
|
9
10
|
*/
|
|
10
11
|
export type Coordinate = [number, number];
|
|
11
12
|
/**
|
|
12
|
-
* The coordinates of a
|
|
13
|
+
* The coordinates of a GeoJSON geometry, nested as deep as its kind needs
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* - `
|
|
18
|
-
*
|
|
19
|
-
* - `
|
|
20
|
-
* - `Coordinate[][]`: Polygon (an array of rings: ring 0 is the outer ring, the rest are
|
|
21
|
-
* holes) and MultiLineString (an array of lines)
|
|
22
|
-
* - `Coordinate[][][]`: MultiPolygon (an array of polygons, each an array of rings)
|
|
15
|
+
* - `Position`: Point (the geometry of a Point, the anchor of an Image and the center of a
|
|
16
|
+
* Circle)
|
|
17
|
+
* - `Position[]`: LineString (also of a Freehand) and MultiPoint
|
|
18
|
+
* - `Position[][]`: Polygon (an array of rings: ring 0 is the outer ring, the rest are holes)
|
|
19
|
+
* and MultiLineString (an array of lines)
|
|
20
|
+
* - `Position[][][]`: MultiPolygon (an array of polygons, each an array of rings)
|
|
23
21
|
*
|
|
24
22
|
* A ring of a Polygon is closed: its last coordinate repeats its first.
|
|
25
23
|
*/
|
|
26
|
-
export type FeatureCoordinates =
|
|
24
|
+
export type FeatureCoordinates = Position | Position[] | Position[][] | Position[][][];
|
|
27
25
|
/**
|
|
28
26
|
* The type of a feature: one of the nine built-in types, or the name of a custom type
|
|
29
27
|
*
|
|
30
28
|
* The built-in types are Point, LineString, Polygon, MultiPoint, MultiLineString,
|
|
31
|
-
* MultiPolygon, Image, Circle and Freehand. The type decides the
|
|
32
|
-
*
|
|
33
|
-
* which an extension adds
|
|
29
|
+
* MultiPolygon, Image, Circle and Freehand. The type decides the kind of `Feature.geometry`:
|
|
30
|
+
* a Circle and an Image hold the Point of their center and their anchor, and a Freehand holds
|
|
31
|
+
* a LineString. Any other string names a custom type, which an extension adds through
|
|
32
|
+
* `draw.extensions.featureTypes` (the engine reads it as a {@link FeatureTypeHandler}).
|
|
34
33
|
*
|
|
35
34
|
* The Multi types come from imports and from the results of geometry operations; no drawing
|
|
36
35
|
* mode creates them.
|
|
@@ -57,7 +56,7 @@ export interface Selection {
|
|
|
57
56
|
/** Selection type (null means nothing is selected) */
|
|
58
57
|
type: SelectionType | null;
|
|
59
58
|
/** IDs of the selected items */
|
|
60
|
-
ids: string[];
|
|
59
|
+
ids: readonly string[];
|
|
61
60
|
}
|
|
62
61
|
/**
|
|
63
62
|
* Vertex reference
|
|
@@ -95,7 +94,7 @@ export interface VertexSelection {
|
|
|
95
94
|
/** The ID of the feature whose vertices are selected */
|
|
96
95
|
featureId: string;
|
|
97
96
|
/** The selected vertices */
|
|
98
|
-
|
|
97
|
+
vertices: readonly VertexRef[];
|
|
99
98
|
}
|
|
100
99
|
/**
|
|
101
100
|
* The style a feature carries in `Feature.style`, overriding the defaults key by key
|
|
@@ -103,16 +102,16 @@ export interface VertexSelection {
|
|
|
103
102
|
* Every key is optional. A color key left unset takes the color of the layer's style rule
|
|
104
103
|
* ({@link StyleRule}) when the layer has one, and any other key left unset takes the default
|
|
105
104
|
* of the `style` option ({@link FeatureStyleConfig}). The precedence is "the feature's own key
|
|
106
|
-
* > the layer's style rule > the default". Colors are
|
|
105
|
+
* > the layer's style rule > the default". Colors are CSS colors.
|
|
107
106
|
*
|
|
108
107
|
* Each feature type reads its own keys:
|
|
109
108
|
*
|
|
110
109
|
* | Feature types | Keys |
|
|
111
110
|
* | --- | --- |
|
|
112
|
-
* | Point, MultiPoint | pointColor, pointRadius, pointShape |
|
|
111
|
+
* | Point, MultiPoint | pointColor, pointRadius, pointShape, pointOpacity, pointStrokeColor, pointStrokeWidth |
|
|
113
112
|
* | LineString, MultiLineString, Freehand | strokeColor, strokeOpacity, strokeWidth, lineStyle |
|
|
114
113
|
* | Polygon, MultiPolygon, Circle | the stroke keys, fillColor, fillOpacity |
|
|
115
|
-
* | Image | imageOpacity
|
|
114
|
+
* | Image | imageOpacity |
|
|
116
115
|
*
|
|
117
116
|
* On import each key is validated and a key that fails is dropped.
|
|
118
117
|
*
|
|
@@ -122,13 +121,6 @@ export interface VertexSelection {
|
|
|
122
121
|
* declaration merging and checks their values where it reads them, since a value can also
|
|
123
122
|
* arrive through `updateFeature` or a replaced store without an import.
|
|
124
123
|
*
|
|
125
|
-
* @example
|
|
126
|
-
* ```ts
|
|
127
|
-
* draw.updateFeature(id, {
|
|
128
|
-
* style: { strokeColor: '#0055ff', strokeWidth: 4, lineStyle: 'dashed' },
|
|
129
|
-
* });
|
|
130
|
-
* ```
|
|
131
|
-
*
|
|
132
124
|
* @example A style key of an extension
|
|
133
125
|
* ```ts
|
|
134
126
|
* declare module '@sakuzu/maplibre-gl-draw' {
|
|
@@ -193,7 +185,7 @@ export interface FeatureStyle {
|
|
|
193
185
|
*/
|
|
194
186
|
pointRadius?: number;
|
|
195
187
|
/**
|
|
196
|
-
* The fill color of the marker of a point (
|
|
188
|
+
* The fill color of the marker of a point (its outline is `pointStrokeColor`)
|
|
197
189
|
*
|
|
198
190
|
* @defaultValue `'#FF6633'`
|
|
199
191
|
*/
|
|
@@ -209,57 +201,44 @@ export interface FeatureStyle {
|
|
|
209
201
|
*/
|
|
210
202
|
pointShape?: 'circle' | 'square' | 'triangle' | 'star';
|
|
211
203
|
/**
|
|
212
|
-
* The opacity of
|
|
204
|
+
* The opacity of the marker of a point, from 0 to 1, multiplied into the opacity of its
|
|
205
|
+
* fill and of its outline
|
|
213
206
|
*
|
|
214
207
|
* @defaultValue `1`
|
|
215
208
|
*/
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* The style of an Image feature: {@link FeatureStyle} plus its size, rotation and opacity
|
|
220
|
-
*
|
|
221
|
-
* The image is drawn at its size at the zoom it was created at (`properties.createdZoom`)
|
|
222
|
-
* and scales with the map from there, like a picture laid on the ground.
|
|
223
|
-
*/
|
|
224
|
-
export interface ImageStyle extends FeatureStyle {
|
|
225
|
-
/**
|
|
226
|
-
* The width in pixels at the created zoom
|
|
227
|
-
*
|
|
228
|
-
* @defaultValue the width of the image (`properties.imageWidth`)
|
|
229
|
-
*/
|
|
230
|
-
width?: number;
|
|
209
|
+
pointOpacity?: number;
|
|
231
210
|
/**
|
|
232
|
-
* The
|
|
211
|
+
* The color of the outline of the marker of a point
|
|
233
212
|
*
|
|
234
|
-
* @defaultValue
|
|
213
|
+
* @defaultValue `'#ffffff'`
|
|
235
214
|
*/
|
|
236
|
-
|
|
215
|
+
pointStrokeColor?: string;
|
|
237
216
|
/**
|
|
238
|
-
*
|
|
217
|
+
* The width of the outline of the marker of a point, in CSS pixels (0 for none)
|
|
239
218
|
*
|
|
240
|
-
* @defaultValue `
|
|
219
|
+
* @defaultValue `2`
|
|
241
220
|
*/
|
|
242
|
-
|
|
221
|
+
pointStrokeWidth?: number;
|
|
243
222
|
/**
|
|
244
|
-
* The opacity from 0 to 1
|
|
223
|
+
* The opacity of an image, from 0 to 1
|
|
245
224
|
*
|
|
246
225
|
* @defaultValue `1`
|
|
247
226
|
*/
|
|
248
|
-
|
|
227
|
+
imageOpacity?: number;
|
|
249
228
|
}
|
|
250
229
|
/**
|
|
251
|
-
* The
|
|
230
|
+
* The values core keeps in `Feature.properties` of an Image feature, read into one object
|
|
252
231
|
*
|
|
253
|
-
* The image mode and `load()` of an image file write them
|
|
254
|
-
* {@link FileData} of the Store, which
|
|
255
|
-
* one image.
|
|
232
|
+
* The image mode and `load()` of an image file write them, under the keys that start with
|
|
233
|
+
* `maplibre-gl-draw:`. The image data itself is a {@link FileData} of the Store, which
|
|
234
|
+
* `imageFileId` names, so that several features can share one image.
|
|
256
235
|
*/
|
|
257
236
|
export interface ImageProperties {
|
|
258
237
|
/** The ID of the {@link FileData} that holds the image */
|
|
259
238
|
imageFileId: string;
|
|
260
|
-
/** The width
|
|
239
|
+
/** The width in pixels the image is drawn at, at the created zoom */
|
|
261
240
|
imageWidth: number;
|
|
262
|
-
/** The height
|
|
241
|
+
/** The height in pixels the image is drawn at, at the created zoom */
|
|
263
242
|
imageHeight: number;
|
|
264
243
|
/** The zoom the image was placed at; at this zoom it is drawn at its size in pixels */
|
|
265
244
|
createdZoom: number;
|
|
@@ -271,8 +250,8 @@ export interface ImageProperties {
|
|
|
271
250
|
/**
|
|
272
251
|
* An embedded file of the document, such as the data of an image
|
|
273
252
|
*
|
|
274
|
-
* Features refer to it by ID (`
|
|
275
|
-
* exports the files the exported features use.
|
|
253
|
+
* Features refer to it by ID (`maplibre-gl-draw:imageFileId` in `properties` of an Image),
|
|
254
|
+
* and the native format exports the files the exported features use.
|
|
276
255
|
*/
|
|
277
256
|
export interface FileData {
|
|
278
257
|
/** The ID of the file, unique within the document */
|
|
@@ -283,23 +262,25 @@ export interface FileData {
|
|
|
283
262
|
dataURL: string;
|
|
284
263
|
}
|
|
285
264
|
/**
|
|
286
|
-
* A feature of the document: its geometry, the layer and group it belongs to, its
|
|
287
|
-
* and its style
|
|
265
|
+
* A feature of the document: its GeoJSON geometry, the layer and group it belongs to, its
|
|
266
|
+
* attributes and its style
|
|
288
267
|
*
|
|
289
|
-
* The draw instance returns features from `
|
|
290
|
-
*
|
|
291
|
-
* feature with `updateFeature`, which stores a new object.
|
|
268
|
+
* The draw instance returns features from `draw.features` and the events, and creates them
|
|
269
|
+
* from an input. What the instance returns is read-only: a change stores a new object.
|
|
292
270
|
*
|
|
293
271
|
* The stacking order of the features is not a property of the feature: it is the position of
|
|
294
|
-
* its ID in `Layer.
|
|
272
|
+
* its ID in `Layer.items`, or in `Group.featureIds` when it belongs to a group.
|
|
295
273
|
*/
|
|
296
274
|
export interface Feature {
|
|
297
275
|
/** The ID of the feature, unique within the document (a ULID when core generates it) */
|
|
298
276
|
id: string;
|
|
299
|
-
/** The type of the feature, which decides the
|
|
277
|
+
/** The type of the feature, which decides the kind of `geometry` */
|
|
300
278
|
type: FeatureType;
|
|
301
|
-
/**
|
|
302
|
-
|
|
279
|
+
/**
|
|
280
|
+
* The GeoJSON geometry (a Circle and an Image hold the Point of their center and their
|
|
281
|
+
* anchor, and a Freehand holds a LineString)
|
|
282
|
+
*/
|
|
283
|
+
geometry: Geometry;
|
|
303
284
|
/**
|
|
304
285
|
* The ID of the layer the feature belongs to (for a feature in a group, the layer of the
|
|
305
286
|
* group)
|
|
@@ -308,24 +289,24 @@ export interface Feature {
|
|
|
308
289
|
/**
|
|
309
290
|
* The ID of the group the feature belongs to, when it belongs to one
|
|
310
291
|
*
|
|
311
|
-
* A feature in a group is listed in `Group.featureIds` instead of `Layer.
|
|
292
|
+
* A feature in a group is listed in `Group.featureIds` instead of `Layer.items`.
|
|
312
293
|
*/
|
|
313
|
-
groupId
|
|
294
|
+
groupId: string | undefined;
|
|
314
295
|
/**
|
|
315
|
-
* The attributes of the
|
|
296
|
+
* The GeoJSON properties: the attributes of the user and the values of the library
|
|
316
297
|
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
298
|
+
* A key that starts with `maplibre-gl-draw:` holds a value of the library: the created zoom,
|
|
299
|
+
* the rotation and the scale (see {@link getCreatedZoom}, {@link getRotation} and
|
|
300
|
+
* {@link getScale}), the radius of a Circle and the values of {@link ImageProperties} of an
|
|
301
|
+
* Image. Every other key is an attribute of the user, free-form; `name` and `description`
|
|
302
|
+
* are read as the name and the description. Exports write them as they are.
|
|
322
303
|
*/
|
|
323
304
|
properties: Record<string, unknown>;
|
|
324
305
|
/**
|
|
325
|
-
* The style of this feature (the defaults and the layer's
|
|
326
|
-
*
|
|
306
|
+
* The style of this feature, `{}` when it has none of its own (the defaults and the layer's
|
|
307
|
+
* style rule apply to the keys it leaves out)
|
|
327
308
|
*/
|
|
328
|
-
style
|
|
309
|
+
style: FeatureStyle;
|
|
329
310
|
/**
|
|
330
311
|
* Whether the feature is locked
|
|
331
312
|
*
|
|
@@ -343,10 +324,10 @@ export interface Feature {
|
|
|
343
324
|
visible: boolean;
|
|
344
325
|
}
|
|
345
326
|
/**
|
|
346
|
-
* The input for adding a feature
|
|
327
|
+
* The input for adding a feature to the Store: a {@link Feature} whose other fields
|
|
347
328
|
* may be omitted
|
|
348
329
|
*
|
|
349
|
-
* Only `type` and `
|
|
330
|
+
* Only `type` and `geometry` are required; the other fields take the defaults written on
|
|
350
331
|
* them.
|
|
351
332
|
*/
|
|
352
333
|
export interface FeatureInput {
|
|
@@ -354,14 +335,14 @@ export interface FeatureInput {
|
|
|
354
335
|
id?: string;
|
|
355
336
|
/** Feature type */
|
|
356
337
|
type: FeatureType;
|
|
357
|
-
/**
|
|
358
|
-
|
|
338
|
+
/** The GeoJSON geometry, of the kind the type holds */
|
|
339
|
+
geometry: Geometry;
|
|
359
340
|
/** Layer ID (the active layer when omitted) */
|
|
360
341
|
layerId?: string;
|
|
361
342
|
/** Properties (an empty object when omitted) */
|
|
362
343
|
properties?: Record<string, unknown>;
|
|
363
344
|
/** Style */
|
|
364
|
-
style?: FeatureStyle
|
|
345
|
+
style?: FeatureStyle;
|
|
365
346
|
/** Locked state (false when omitted) */
|
|
366
347
|
locked?: boolean;
|
|
367
348
|
/** Visible state (true when omitted) */
|
|
@@ -391,20 +372,6 @@ export interface FeatureInput {
|
|
|
391
372
|
* for `graduated`, say), takes `other` rather than the default color, so a rule that does not
|
|
392
373
|
* apply can be told apart from a missing value. {@link evaluateStyleRule} evaluates a rule and
|
|
393
374
|
* {@link deriveLegend} lists its legend entries; the library does not draw the legend.
|
|
394
|
-
*
|
|
395
|
-
* @example
|
|
396
|
-
* ```ts
|
|
397
|
-
* draw.updateLayer(layerId, {
|
|
398
|
-
* styleRule: {
|
|
399
|
-
* kind: 'graduated',
|
|
400
|
-
* property: 'population',
|
|
401
|
-
* breaks: [1000, 10000],
|
|
402
|
-
* colors: ['#fee8c8', '#fdbb84', '#e34a33'],
|
|
403
|
-
* other: '#cccccc',
|
|
404
|
-
* },
|
|
405
|
-
* });
|
|
406
|
-
* // population 500 -> #fee8c8, 5000 -> #fdbb84, 20000 -> #e34a33, missing -> #cccccc
|
|
407
|
-
* ```
|
|
408
375
|
*/
|
|
409
376
|
export type StyleRule = {
|
|
410
377
|
kind: 'single';
|
|
@@ -433,7 +400,7 @@ export type StyleRule = {
|
|
|
433
400
|
* lock and style rule
|
|
434
401
|
*
|
|
435
402
|
* Every feature belongs to one layer. The layers are stacked in the order of
|
|
436
|
-
* `getLayerOrder()`, and within a layer the items are stacked in the order of `
|
|
403
|
+
* `getLayerOrder()`, and within a layer the items are stacked in the order of `items`. New
|
|
437
404
|
* features are drawn into the active layer.
|
|
438
405
|
*/
|
|
439
406
|
export interface Layer {
|
|
@@ -460,7 +427,7 @@ export interface Layer {
|
|
|
460
427
|
*
|
|
461
428
|
* It is multiplied into the alpha of everything drawn for the layer (fills, lines, points,
|
|
462
429
|
* images, and what the renderers of custom types and feature companions draw, which receive
|
|
463
|
-
* it as `
|
|
430
|
+
* it as `FrameDrawContext.opacity`). It is applied at draw time, so changing it is
|
|
464
431
|
* cheap: nothing is rebuilt. It is only a look: hit testing ignores it, and a feature in a
|
|
465
432
|
* layer at opacity 0 can still be selected.
|
|
466
433
|
*/
|
|
@@ -471,31 +438,37 @@ export interface Layer {
|
|
|
471
438
|
*
|
|
472
439
|
* A feature in a group is listed in `Group.featureIds` instead.
|
|
473
440
|
*/
|
|
474
|
-
|
|
441
|
+
items: readonly string[];
|
|
475
442
|
/** Free-form data of the host, saved and exported with the layer */
|
|
476
|
-
metadata
|
|
443
|
+
metadata: Record<string, unknown> | undefined;
|
|
477
444
|
/**
|
|
478
445
|
* Style rule (no rule when omitted)
|
|
479
446
|
*
|
|
480
447
|
* Because it is an ordinary field it is subject to saving, subscription and undo, and
|
|
481
448
|
* it is updated with `updateLayer(id, { styleRule })`.
|
|
482
449
|
*/
|
|
483
|
-
styleRule
|
|
450
|
+
styleRule: StyleRule | undefined;
|
|
484
451
|
}
|
|
485
452
|
/**
|
|
486
453
|
* A group of features within one layer, selected, moved and stacked as a unit
|
|
487
454
|
*
|
|
488
|
-
* A group is listed in `Layer.
|
|
489
|
-
* in `featureIds` (each member has `groupId` set).
|
|
490
|
-
* order lists it, so a group has no `layerId`.
|
|
455
|
+
* A group is listed in `Layer.items` of its layer like a feature, and its members are listed
|
|
456
|
+
* in `featureIds` (each member has `groupId` set).
|
|
491
457
|
*/
|
|
492
458
|
export interface Group {
|
|
493
459
|
/** The ID of the group, unique within the document */
|
|
494
460
|
id: string;
|
|
461
|
+
/**
|
|
462
|
+
* The ID of the layer the group is in: the layer whose `items` list it
|
|
463
|
+
*
|
|
464
|
+
* The Store keeps it: a group takes the layer that lists it when it is created, and a write
|
|
465
|
+
* that lists it in the items of another layer moves it to that layer.
|
|
466
|
+
*/
|
|
467
|
+
layerId: string;
|
|
495
468
|
/** The display name */
|
|
496
469
|
name: string;
|
|
497
470
|
/** The IDs of the members, back to front (the last is the frontmost) */
|
|
498
|
-
featureIds: string[];
|
|
471
|
+
featureIds: readonly string[];
|
|
499
472
|
/**
|
|
500
473
|
* Whether the group is locked (every member is then locked, see {@link isFeatureLocked})
|
|
501
474
|
*/
|
|
@@ -509,7 +482,7 @@ export interface Group {
|
|
|
509
482
|
* A drawing mode keeps it in the Store while the user draws, and it is cleared when the
|
|
510
483
|
* feature is committed or the drawing is cancelled. It is local state of this instance; a
|
|
511
484
|
* subscriber that wants the drawing in progress reads it from the notifications of the Store
|
|
512
|
-
* ({@link
|
|
485
|
+
* ({@link StoreChange.tentative}).
|
|
513
486
|
*/
|
|
514
487
|
export interface TentativeState {
|
|
515
488
|
/** The type of the feature being drawn */
|
|
@@ -562,11 +535,14 @@ export interface TentativeState {
|
|
|
562
535
|
* features.change carries the source of its flush.
|
|
563
536
|
*
|
|
564
537
|
* - local: an operation of the user or a call of the API (the default)
|
|
565
|
-
* - silent: a change that a subscriber recording changes leaves out
|
|
566
|
-
*
|
|
567
|
-
* -
|
|
568
|
-
* which is what makes it one
|
|
569
|
-
*
|
|
538
|
+
* - silent: a change that a subscriber recording changes leaves out, such as clearing the
|
|
539
|
+
* selection when a mode starts
|
|
540
|
+
* - load: a load of any format (or of several sources at once), with the replacement it
|
|
541
|
+
* makes, recorded as one step (it is one transaction, which is what makes it one
|
|
542
|
+
* notification)
|
|
543
|
+
* - batch: a bulk change of a host or an extension recorded as one step; core does not write
|
|
544
|
+
* it
|
|
545
|
+
* - remote: a change that came from outside the instance. A replaced Store (see StoreContract)
|
|
570
546
|
* writes it for the changes it applies from elsewhere, so that subscribers can tell them from
|
|
571
547
|
* local edits and core keeps the local editing state (a vertex selection) consistent with them
|
|
572
548
|
* - import: for a host or an extension that loads data by its own means; core does not write
|
|
@@ -574,7 +550,7 @@ export interface TentativeState {
|
|
|
574
550
|
*
|
|
575
551
|
* Any other string can be used by a plugin or a store for the changes it applies itself.
|
|
576
552
|
*/
|
|
577
|
-
export type UpdateSource = 'local' | 'silent' | 'batch' | 'remote' | 'import' | (string & Record<never, never>);
|
|
553
|
+
export type UpdateSource = 'local' | 'silent' | 'load' | 'batch' | 'remote' | 'import' | (string & Record<never, never>);
|
|
578
554
|
/**
|
|
579
555
|
* Options of `updateFeature` on the Store, for the updates of an edit in progress
|
|
580
556
|
*/
|
|
@@ -586,7 +562,7 @@ export interface UpdateFeatureOptions {
|
|
|
586
562
|
* An intermediate state is always overwritten by the committing update that follows
|
|
587
563
|
* (the one without options).
|
|
588
564
|
* MemoryStore ignores it and applies the update as usual, and passes it through to
|
|
589
|
-
* isIntermediate of
|
|
565
|
+
* isIntermediate of StoreChange.features.updated. An external store can look at this
|
|
590
566
|
* flag to decide whether to keep the update or to hold it apart until the commit.
|
|
591
567
|
*/
|
|
592
568
|
isIntermediate?: boolean;
|
|
@@ -596,23 +572,15 @@ export interface UpdateFeatureOptions {
|
|
|
596
572
|
*
|
|
597
573
|
* `subscribe` of the Store delivers one per outermost transaction (or per write outside
|
|
598
574
|
* one). Each category is present only when the transaction changed it. The document
|
|
599
|
-
* categories (features, layers, groups, layerReorder, groupReorder, metadata) are what a
|
|
600
|
-
*
|
|
601
|
-
*
|
|
602
|
-
* @example
|
|
603
|
-
* ```ts
|
|
604
|
-
* draw.getStore().subscribe((changes) => {
|
|
605
|
-
* if (changes.source === 'remote') return;
|
|
606
|
-
* for (const feature of changes.features?.created ?? []) console.log('created', feature.id);
|
|
607
|
-
* });
|
|
608
|
-
* ```
|
|
575
|
+
* categories (features, layers, groups, layerReorder, groupReorder, metadata, files) are what a
|
|
576
|
+
* DocumentStore notifies; the others are local state of this client.
|
|
609
577
|
*/
|
|
610
|
-
export interface
|
|
578
|
+
export interface StoreChange {
|
|
611
579
|
/**
|
|
612
580
|
* The source of the operation
|
|
613
581
|
*
|
|
614
582
|
* Used by subscribers to identify the source of the operation. Core writes 'local',
|
|
615
|
-
* 'silent' and '
|
|
583
|
+
* 'silent' and 'load', and a replaced store writes 'remote' for the changes it applies
|
|
616
584
|
* from outside (see {@link UpdateSource}); plugins and external store implementations can
|
|
617
585
|
* use their own values.
|
|
618
586
|
*/
|
|
@@ -666,7 +634,7 @@ export interface StateChanges {
|
|
|
666
634
|
/**
|
|
667
635
|
* Reordering of items within a layer
|
|
668
636
|
*
|
|
669
|
-
* The reordering of items (features or groups) within the layer.
|
|
637
|
+
* The reordering of items (features or groups) within the layer.items array.
|
|
670
638
|
* It is emitted separately from layers.updated, and is recorded as a dedicated command
|
|
671
639
|
* by history management.
|
|
672
640
|
*/
|
|
@@ -711,7 +679,7 @@ export interface StateChanges {
|
|
|
711
679
|
};
|
|
712
680
|
/**
|
|
713
681
|
* A flag indicating that the UI state (dragState, boxSelection) has changed
|
|
714
|
-
* These are not included in the details of
|
|
682
|
+
* These are not included in the details of StoreChange, but they are notified in order
|
|
715
683
|
* to trigger a redraw
|
|
716
684
|
*/
|
|
717
685
|
uiStateChanged?: boolean;
|
|
@@ -720,6 +688,16 @@ export interface StateChanges {
|
|
|
720
688
|
metadata: Metadata;
|
|
721
689
|
previous: Metadata;
|
|
722
690
|
};
|
|
691
|
+
/** The embedded files created and deleted */
|
|
692
|
+
files?: {
|
|
693
|
+
created?: FileData[];
|
|
694
|
+
deleted?: FileData[];
|
|
695
|
+
};
|
|
696
|
+
/**
|
|
697
|
+
* True when the notification replaces the whole document at once (a Store that takes a
|
|
698
|
+
* document from elsewhere sets it); it survives the folding of a transaction
|
|
699
|
+
*/
|
|
700
|
+
reset?: boolean;
|
|
723
701
|
}
|
|
724
702
|
/**
|
|
725
703
|
* An axis-aligned bounding box in longitude (X) and latitude (Y), in degrees
|
|
@@ -742,17 +720,6 @@ export interface BoundingBox {
|
|
|
742
720
|
* It declares a title and a description. An application keeps settings of its own here (the
|
|
743
721
|
* basemap it shows, a default view) by adding keys to this interface with declaration
|
|
744
722
|
* merging; the keys are stored and exported like the declared ones.
|
|
745
|
-
*
|
|
746
|
-
* @example
|
|
747
|
-
* ```ts
|
|
748
|
-
* declare module '@sakuzu/maplibre-gl-draw' {
|
|
749
|
-
* interface Metadata {
|
|
750
|
-
* basemap?: string;
|
|
751
|
-
* }
|
|
752
|
-
* }
|
|
753
|
-
*
|
|
754
|
-
* draw.setMetadata({ basemap: 'https://example.com/style.json' });
|
|
755
|
-
* ```
|
|
756
723
|
*/
|
|
757
724
|
export interface Metadata {
|
|
758
725
|
/** The title of the document */
|
|
@@ -768,7 +735,7 @@ export interface Metadata {
|
|
|
768
735
|
* first problem. The format is described in the data format reference.
|
|
769
736
|
*/
|
|
770
737
|
export interface Data {
|
|
771
|
-
/** The version of the native format (`'
|
|
738
|
+
/** The version of the native format (`'3.0.0'` for this release) */
|
|
772
739
|
version: string;
|
|
773
740
|
/** When the data was written (an ISO 8601 timestamp) */
|
|
774
741
|
created?: string;
|
|
@@ -780,7 +747,7 @@ export interface Data {
|
|
|
780
747
|
layers?: Layer[];
|
|
781
748
|
/**
|
|
782
749
|
* The stacking order, from the back: every layer of `layers` once, and the entries of the
|
|
783
|
-
* application that are not layers (see
|
|
750
|
+
* application that are not layers (see the stacking order of StoreContract) at their
|
|
784
751
|
* positions
|
|
785
752
|
*/
|
|
786
753
|
layerOrder: string[];
|
|
@@ -841,10 +808,6 @@ export interface SkippedFeature {
|
|
|
841
808
|
/** Why it was skipped (English, for logs and diagnostics) */
|
|
842
809
|
reason: string;
|
|
843
810
|
}
|
|
844
|
-
/**
|
|
845
|
-
* The format `export()` writes: the native format ({@link Data}) or GeoJSON
|
|
846
|
-
*/
|
|
847
|
-
export type ExportFormat = 'native' | 'geojson';
|
|
848
811
|
/**
|
|
849
812
|
* Options of `export()`: the file name, and which features or layers to export
|
|
850
813
|
*/
|
|
@@ -856,19 +819,6 @@ export interface ExportOptions {
|
|
|
856
819
|
/** Export only certain layers */
|
|
857
820
|
layerIds?: string[];
|
|
858
821
|
}
|
|
859
|
-
/**
|
|
860
|
-
* What `export()` returns: the data as a string, with its MIME type and a file name
|
|
861
|
-
*/
|
|
862
|
-
export interface ExportResult {
|
|
863
|
-
/** The export format */
|
|
864
|
-
format: ExportFormat;
|
|
865
|
-
/** The exported data */
|
|
866
|
-
data: string;
|
|
867
|
-
/** The MIME type */
|
|
868
|
-
mimeType: string;
|
|
869
|
-
/** The recommended file name */
|
|
870
|
-
fileName: string;
|
|
871
|
-
}
|
|
872
822
|
/**
|
|
873
823
|
* The box selection in progress (a Shift-drag in the select mode), local state of this client
|
|
874
824
|
*/
|
|
@@ -46,7 +46,7 @@ export interface PointStyle {
|
|
|
46
46
|
/** The identifier of the icon, for the `'icon'` shape */
|
|
47
47
|
iconId?: string;
|
|
48
48
|
}
|
|
49
|
-
/** The dash pattern of a line: solid, dashed or dotted */
|
|
49
|
+
/** The dash pattern of a line: solid, dashed or dotted. */
|
|
50
50
|
export type LineStyle = 'solid' | 'dashed' | 'dotted';
|
|
51
51
|
/**
|
|
52
52
|
* How a line or an outline is drawn: its width, color, opacity and dash pattern
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Color conversion utilities
|
|
3
|
-
*
|
|
4
|
-
* Functions that convert between HEX color strings and RGBA arrays.
|
|
5
|
-
*/
|
|
6
|
-
import type { Color } from '../types/style.js';
|
|
7
|
-
/**
|
|
8
|
-
* Converts a HEX color string into an RGBA array
|
|
9
|
-
*
|
|
10
|
-
* @param hex - A color string in #RRGGBB or #RGB form
|
|
11
|
-
* @param opacity - Opacity (0-1)
|
|
12
|
-
* @returns An array in the form [r, g, b, a] (each value in 0-1)
|
|
13
|
-
*/
|
|
14
|
-
export declare function hexToColor(hex: string, opacity?: number): Color;
|
|
15
1
|
/**
|
|
16
2
|
* Linearly interpolates two colors in the OKLab space
|
|
17
3
|
*
|
|
@@ -21,29 +7,9 @@ export declare function hexToColor(hex: string, opacity?: number): Color;
|
|
|
21
7
|
* component by component.
|
|
22
8
|
* The interpolation position is clamped to 0-1.
|
|
23
9
|
*
|
|
24
|
-
* @param from - Color of the start point (
|
|
25
|
-
* @param to - Color of the end point (
|
|
10
|
+
* @param from - Color of the start point (a CSS color)
|
|
11
|
+
* @param to - Color of the end point (a CSS color)
|
|
26
12
|
* @param t - Interpolation position (0-1)
|
|
27
13
|
* @returns A color string in #RRGGBB form
|
|
28
14
|
*/
|
|
29
15
|
export declare function interpolateHexColor(from: string, to: string, t: number): string;
|
|
30
|
-
/**
|
|
31
|
-
* Computes the relative luminance
|
|
32
|
-
*
|
|
33
|
-
* Based on the relative luminance formula of WCAG 2.0.
|
|
34
|
-
* https://www.w3.org/TR/WCAG20/#relativeluminancedef
|
|
35
|
-
*
|
|
36
|
-
* @param hex - A color string in #RRGGBB or #RGB form
|
|
37
|
-
* @returns Relative luminance (0-1)
|
|
38
|
-
*/
|
|
39
|
-
export declare function getLuminance(hex: string): number;
|
|
40
|
-
/**
|
|
41
|
-
* Gets a contrasting color
|
|
42
|
-
*
|
|
43
|
-
* Returns a highly visible contrasting color based on the luminance of the given color.
|
|
44
|
-
* Returns black for a light color and white for a dark color.
|
|
45
|
-
*
|
|
46
|
-
* @param hex - A color string in #RRGGBB or #RGB form
|
|
47
|
-
* @returns The contrasting color (#000000 or #FFFFFF)
|
|
48
|
-
*/
|
|
49
|
-
export declare function getContrastColor(hex: string): string;
|