@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.
Files changed (540) hide show
  1. package/CHANGELOG.md +1016 -2
  2. package/README.ja.md +39 -19
  3. package/README.md +41 -21
  4. package/dist/api/datasets.d.ts +258 -0
  5. package/dist/api/document.d.ts +66 -0
  6. package/dist/api/draw.d.ts +135 -0
  7. package/dist/api/draw.js +18 -0
  8. package/dist/api/drawing.d.ts +87 -0
  9. package/dist/api/errors.d.ts +35 -0
  10. package/dist/api/errors.js +35 -0
  11. package/dist/api/events.d.ts +306 -0
  12. package/dist/api/extension/context.d.ts +247 -0
  13. package/dist/api/extension/feature-type.d.ts +129 -0
  14. package/dist/api/extension/mode.d.ts +123 -0
  15. package/dist/api/extension/plugin.d.ts +51 -0
  16. package/dist/api/extension/plugin.js +3 -0
  17. package/dist/api/extension/provider.d.ts +119 -0
  18. package/dist/api/extension/provider.js +3 -0
  19. package/dist/api/extension/render.d.ts +176 -0
  20. package/dist/api/extension/render.js +3 -0
  21. package/dist/api/extension/store.d.ts +190 -0
  22. package/dist/api/extension/store.js +3 -0
  23. package/dist/api/extensions.d.ts +306 -0
  24. package/dist/api/extensions.js +3 -0
  25. package/dist/api/features.d.ts +188 -0
  26. package/dist/api/features.js +3 -0
  27. package/dist/api/groups.d.ts +111 -0
  28. package/dist/api/groups.js +3 -0
  29. package/dist/api/hidden.d.ts +45 -0
  30. package/dist/api/hidden.js +3 -0
  31. package/dist/api/impl/adapters.js +463 -0
  32. package/dist/api/impl/contexts.js +466 -0
  33. package/dist/api/impl/create-draw.js +124 -0
  34. package/dist/api/impl/datasets.js +404 -0
  35. package/dist/api/impl/destroy-guard.js +74 -0
  36. package/dist/api/impl/document.js +280 -0
  37. package/dist/api/impl/drawing.js +180 -0
  38. package/dist/api/impl/engine-context.d.ts +7 -0
  39. package/dist/api/{context.js → impl/engine-context.js} +49 -38
  40. package/dist/{maplibre-gl-draw.js → api/impl/engine.js} +145 -177
  41. package/dist/api/impl/events.js +422 -0
  42. package/dist/api/impl/extension-host.js +361 -0
  43. package/dist/api/impl/extensions.js +229 -0
  44. package/dist/api/impl/features.js +445 -0
  45. package/dist/api/impl/geometry/apply.d.ts +32 -0
  46. package/dist/api/{geometry → impl/geometry}/apply.js +10 -27
  47. package/dist/api/{geometry → impl/geometry}/buffer.d.ts +4 -3
  48. package/dist/api/{geometry → impl/geometry}/buffer.js +12 -23
  49. package/dist/api/{geometry → impl/geometry}/split.d.ts +4 -3
  50. package/dist/api/{geometry → impl/geometry}/split.js +10 -21
  51. package/dist/api/{geometry → impl/geometry}/targets.d.ts +2 -20
  52. package/dist/api/{geometry → impl/geometry}/targets.js +8 -35
  53. package/dist/api/impl/geometry/types.js +3 -0
  54. package/dist/api/impl/groups.d.ts +3 -0
  55. package/dist/api/impl/groups.js +268 -0
  56. package/dist/api/impl/hidden.js +60 -0
  57. package/dist/api/impl/import-export/constants.d.ts +22 -0
  58. package/dist/api/impl/import-export/constants.js +24 -0
  59. package/dist/api/{import-export → impl/import-export}/embedded-file.js +2 -2
  60. package/dist/api/{import-export → impl/import-export}/format-detection.d.ts +1 -1
  61. package/dist/api/{import-export → impl/import-export}/format-detection.js +2 -1
  62. package/dist/api/impl/import-export/geojson-export.d.ts +19 -0
  63. package/dist/api/{import-export → impl/import-export}/geojson-export.js +71 -104
  64. package/dist/api/{import-export → impl/import-export}/geojson-import.d.ts +11 -7
  65. package/dist/api/{import-export → impl/import-export}/geojson-import.js +139 -97
  66. package/dist/api/{import-export → impl/import-export}/geometry-validation.d.ts +14 -0
  67. package/dist/api/{import-export → impl/import-export}/geometry-validation.js +45 -0
  68. package/dist/api/impl/import-export/image-import.d.ts +16 -0
  69. package/dist/api/impl/import-export/image-import.js +73 -0
  70. package/dist/api/impl/import-export/legacy-image-style.d.ts +16 -0
  71. package/dist/api/impl/import-export/legacy-image-style.js +49 -0
  72. package/dist/api/impl/import-export/native-format.d.ts +14 -0
  73. package/dist/api/{import-export → impl/import-export}/native-format.js +32 -22
  74. package/dist/api/impl/import-export/native-upgrade.d.ts +8 -0
  75. package/dist/api/impl/import-export/native-upgrade.js +139 -0
  76. package/dist/api/{import-export → impl/import-export}/native-validation.d.ts +1 -1
  77. package/dist/api/{import-export → impl/import-export}/native-validation.js +15 -14
  78. package/dist/api/impl/import-export/style-validation.d.ts +24 -0
  79. package/dist/api/impl/import-export/style-validation.js +86 -0
  80. package/dist/api/impl/import-export/types.d.ts +52 -0
  81. package/dist/api/impl/import-export/types.js +3 -0
  82. package/dist/api/impl/input.js +180 -0
  83. package/dist/api/impl/layers.js +307 -0
  84. package/dist/api/impl/metadata.d.ts +1 -0
  85. package/dist/api/impl/metadata.js +22 -0
  86. package/dist/api/impl/options.d.ts +1 -0
  87. package/dist/api/impl/options.js +822 -0
  88. package/dist/api/impl/placement.d.ts +1 -0
  89. package/dist/api/impl/placement.js +138 -0
  90. package/dist/api/impl/render-context.d.ts +13 -0
  91. package/dist/api/impl/render-context.js +272 -0
  92. package/dist/api/impl/rows.d.ts +1 -0
  93. package/dist/api/impl/rows.js +46 -0
  94. package/dist/api/impl/selection.d.ts +1 -0
  95. package/dist/api/impl/selection.js +186 -0
  96. package/dist/api/impl/shared.d.ts +64 -0
  97. package/dist/api/impl/shared.js +178 -0
  98. package/dist/api/impl/validate-extension.d.ts +1 -0
  99. package/dist/api/impl/validate-extension.js +159 -0
  100. package/dist/api/layers.d.ts +130 -0
  101. package/dist/api/layers.js +3 -0
  102. package/dist/api/metadata.d.ts +18 -0
  103. package/dist/api/metadata.js +3 -0
  104. package/dist/api/model.d.ts +487 -0
  105. package/dist/api/model.js +47 -0
  106. package/dist/api/options.d.ts +466 -0
  107. package/dist/api/options.js +3 -0
  108. package/dist/api/selection.d.ts +94 -0
  109. package/dist/api/selection.js +3 -0
  110. package/dist/api/state.d.ts +155 -0
  111. package/dist/api/state.js +12 -0
  112. package/dist/{display → dataset}/chunk.d.ts +1 -1
  113. package/dist/{display → dataset}/chunk.js +4 -3
  114. package/dist/{display → dataset}/dataset.js +18 -21
  115. package/dist/dataset/interaction.d.ts +1 -0
  116. package/dist/{display → dataset}/interaction.js +18 -6
  117. package/dist/dataset/manager.d.ts +1 -0
  118. package/dist/dataset/provider.d.ts +1 -0
  119. package/dist/{display → dataset}/retained.d.ts +1 -1
  120. package/dist/{display → dataset}/retained.js +8 -7
  121. package/dist/dataset/source.d.ts +1 -0
  122. package/dist/{display → dataset}/source.js +17 -4
  123. package/dist/dataset/spatial.d.ts +1 -0
  124. package/dist/{display → dataset}/spatial.js +1 -1
  125. package/dist/dataset/style.d.ts +1 -0
  126. package/dist/{display → dataset}/style.js +1 -1
  127. package/dist/dataset/table-source.d.ts +1 -0
  128. package/dist/{display/columnar/source.js → dataset/table-source.js} +53 -25
  129. package/dist/{display → dataset}/thinning.d.ts +0 -10
  130. package/dist/{display → dataset}/thinning.js +3 -2
  131. package/dist/dataset/triangulation.d.ts +1 -0
  132. package/dist/{display → dataset}/triangulation.js +0 -0
  133. package/dist/{display → dataset}/types.d.ts +82 -121
  134. package/dist/dataset/types.js +61 -0
  135. package/dist/dispatcher/hit-test/box-strategies.js +13 -13
  136. package/dist/dispatcher/hit-test/box-strategy.d.ts +2 -15
  137. package/dist/dispatcher/hit-test/globe-shape.js +5 -4
  138. package/dist/dispatcher/hit-test/service.d.ts +17 -0
  139. package/dist/dispatcher/hit-test/service.js +80 -16
  140. package/dist/dispatcher/hit-test/strategies/base.d.ts +13 -19
  141. package/dist/dispatcher/hit-test/strategies/circle.js +3 -2
  142. package/dist/dispatcher/hit-test/strategies/image.js +6 -18
  143. package/dist/dispatcher/hit-test/strategies/line.d.ts +0 -6
  144. package/dist/dispatcher/hit-test/strategies/line.js +9 -2
  145. package/dist/dispatcher/hit-test/strategies/multi.d.ts +0 -8
  146. package/dist/dispatcher/hit-test/strategies/multi.js +17 -8
  147. package/dist/dispatcher/hit-test/strategies/point.d.ts +9 -7
  148. package/dist/dispatcher/hit-test/strategies/point.js +8 -4
  149. package/dist/dispatcher/hit-test/strategies/polygon.d.ts +0 -7
  150. package/dist/dispatcher/hit-test/strategies/polygon.js +11 -3
  151. package/dist/dispatcher/hit-test/topmost.d.ts +1 -1
  152. package/dist/dispatcher/input-router.js +152 -69
  153. package/dist/dispatcher/normalizer.js +6 -2
  154. package/dist/dispatcher/types.d.ts +6 -1
  155. package/dist/extension/feature-handler.d.ts +1 -182
  156. package/dist/extension/index.d.ts +4 -7
  157. package/dist/extension/renderers.d.ts +1 -208
  158. package/dist/geometry/angle.d.ts +0 -8
  159. package/dist/geometry/angle.js +0 -8
  160. package/dist/geometry/bbox.d.ts +4 -12
  161. package/dist/geometry/bbox.js +4 -12
  162. package/dist/geometry/boolean.d.ts +0 -51
  163. package/dist/geometry/boolean.js +0 -51
  164. package/dist/geometry/buffer.d.ts +0 -26
  165. package/dist/geometry/buffer.js +0 -26
  166. package/dist/geometry/circle.d.ts +0 -9
  167. package/dist/geometry/circle.js +0 -9
  168. package/dist/geometry/coords.d.ts +0 -16
  169. package/dist/geometry/coords.js +0 -16
  170. package/dist/geometry/distance.d.ts +0 -24
  171. package/dist/geometry/distance.js +0 -24
  172. package/dist/geometry/errors.d.ts +21 -36
  173. package/dist/geometry/errors.js +49 -29
  174. package/dist/geometry/geojson.d.ts +81 -0
  175. package/dist/geometry/geojson.js +164 -0
  176. package/dist/geometry/index.d.ts +38 -23
  177. package/dist/geometry/index.js +43 -31
  178. package/dist/geometry/measure.d.ts +0 -27
  179. package/dist/geometry/measure.js +0 -27
  180. package/dist/geometry/predicates.d.ts +0 -9
  181. package/dist/geometry/predicates.js +0 -9
  182. package/dist/geometry/public-bounds.d.ts +26 -0
  183. package/dist/geometry/public-bounds.js +30 -0
  184. package/dist/geometry/public-combine.d.ts +78 -0
  185. package/dist/geometry/public-combine.js +82 -0
  186. package/dist/geometry/public-create.d.ts +54 -0
  187. package/dist/geometry/public-create.js +70 -0
  188. package/dist/geometry/public-measure.d.ts +170 -0
  189. package/dist/geometry/public-measure.js +283 -0
  190. package/dist/geometry/public-predicates.d.ts +54 -0
  191. package/dist/geometry/public-predicates.js +144 -0
  192. package/dist/geometry/public-repair.d.ts +75 -0
  193. package/dist/geometry/public-repair.js +77 -0
  194. package/dist/geometry/simplify.d.ts +0 -7
  195. package/dist/geometry/simplify.js +0 -7
  196. package/dist/geometry/split.d.ts +0 -20
  197. package/dist/geometry/split.js +0 -20
  198. package/dist/geometry/units.d.ts +20 -12
  199. package/dist/geometry/units.js +20 -12
  200. package/dist/index.d.ts +52 -66
  201. package/dist/index.js +6 -18
  202. package/dist/messages.d.ts +7 -7
  203. package/dist/modes/draw/circle.js +83 -207
  204. package/dist/modes/draw/commit-layer.d.ts +5 -16
  205. package/dist/modes/draw/commit-layer.js +2 -13
  206. package/dist/modes/draw/freehand.js +108 -246
  207. package/dist/modes/draw/image.js +4 -2
  208. package/dist/modes/draw/index.d.ts +5 -5
  209. package/dist/modes/draw/index.js +5 -5
  210. package/dist/modes/draw/line.js +18 -354
  211. package/dist/modes/draw/point.js +29 -78
  212. package/dist/modes/draw/polygon.js +23 -368
  213. package/dist/modes/draw/trace-support.d.ts +43 -36
  214. package/dist/modes/draw/trace-support.js +95 -98
  215. package/dist/modes/draw/vertex-drawing.d.ts +1 -0
  216. package/dist/modes/draw/vertex-drawing.js +176 -0
  217. package/dist/modes/handler.d.ts +1 -285
  218. package/dist/modes/manager.d.ts +2 -2
  219. package/dist/modes/manager.js +3 -0
  220. package/dist/modes/select/box-selection.d.ts +3 -3
  221. package/dist/modes/select/box-selection.js +2 -1
  222. package/dist/modes/select/click-handler.d.ts +5 -5
  223. package/dist/modes/select/click-handler.js +22 -20
  224. package/dist/modes/select/cursor-handler.d.ts +2 -2
  225. package/dist/modes/select/drag/intermediate-writes.js +1 -1
  226. package/dist/modes/select/drag/move.js +3 -3
  227. package/dist/modes/select/drag/operation.d.ts +3 -3
  228. package/dist/modes/select/drag/radius.js +5 -4
  229. package/dist/modes/select/drag/transform.d.ts +2 -2
  230. package/dist/modes/select/drag/transform.js +11 -5
  231. package/dist/modes/select/drag/vertex.d.ts +2 -2
  232. package/dist/modes/select/drag/vertex.js +13 -8
  233. package/dist/modes/select/drag-handler.js +44 -25
  234. package/dist/modes/select/mode.js +17 -17
  235. package/dist/modes/select/shortcut-handler.d.ts +8 -8
  236. package/dist/modes/select/shortcut-handler.js +9 -7
  237. package/dist/operations/layer-operations.js +29 -168
  238. package/dist/operations/resize.d.ts +2 -2
  239. package/dist/operations/resize.js +5 -5
  240. package/dist/operations/rotate.js +5 -5
  241. package/dist/operations/selection-operations.d.ts +16 -1
  242. package/dist/operations/selection-operations.js +28 -13
  243. package/dist/operations/shared-vertex.js +4 -2
  244. package/dist/operations/trace-graph.d.ts +0 -18
  245. package/dist/operations/trace-graph.js +0 -18
  246. package/dist/operations/vertex.js +36 -35
  247. package/dist/shared/color.d.ts +1 -0
  248. package/dist/shared/color.js +245 -0
  249. package/dist/shared/config/constants.d.ts +1 -54
  250. package/dist/shared/config/constants.js +1 -58
  251. package/dist/shared/config/feature-style.d.ts +16 -13
  252. package/dist/shared/config/feature-style.js +9 -0
  253. package/dist/shared/config/rendering.d.ts +3 -3
  254. package/dist/shared/config/selection-highlight.d.ts +0 -15
  255. package/dist/shared/config/selection-highlight.js +4 -7
  256. package/dist/shared/config/selection.d.ts +2 -32
  257. package/dist/shared/config/selection.js +0 -18
  258. package/dist/shared/config/topology.d.ts +2 -2
  259. package/dist/shared/config/trace.d.ts +4 -4
  260. package/dist/shared/math/angle.d.ts +1 -1
  261. package/dist/shared/math/angle.js +1 -1
  262. package/dist/shared/math/circle.d.ts +1 -1
  263. package/dist/shared/math/circle.js +1 -1
  264. package/dist/shared/math/distance.d.ts +2 -1
  265. package/dist/shared/math/distance.js +3 -2
  266. package/dist/shared/math/index.d.ts +1 -1
  267. package/dist/shared/math/index.js +1 -1
  268. package/dist/shared/math/transform.d.ts +23 -0
  269. package/dist/shared/math/transform.js +47 -28
  270. package/dist/shared/properties.d.ts +18 -0
  271. package/dist/shared/properties.js +129 -0
  272. package/dist/shared/types/events.d.ts +15 -7
  273. package/dist/shared/types/model.d.ts +109 -159
  274. package/dist/shared/types/style.d.ts +1 -1
  275. package/dist/shared/utils/color.d.ts +2 -36
  276. package/dist/shared/utils/color.js +13 -70
  277. package/dist/shared/utils/coordinates.d.ts +30 -4
  278. package/dist/shared/utils/coordinates.js +56 -10
  279. package/dist/shared/utils/event-emitter.d.ts +1 -262
  280. package/dist/shared/utils/event-emitter.js +4 -3
  281. package/dist/shared/utils/feature-bbox.js +8 -7
  282. package/dist/shared/utils/feature-segments.js +5 -4
  283. package/dist/shared/utils/image.d.ts +0 -4
  284. package/dist/shared/utils/image.js +0 -6
  285. package/dist/shared/utils/name-generator.d.ts +14 -20
  286. package/dist/shared/utils/name-generator.js +20 -3
  287. package/dist/shared/utils/pixel-ratio.d.ts +9 -3
  288. package/dist/shared/utils/pixel-ratio.js +13 -4
  289. package/dist/shared/utils/property.d.ts +7 -50
  290. package/dist/shared/utils/property.js +22 -87
  291. package/dist/snapping/custom-targets.js +21 -4
  292. package/dist/snapping/indicator.js +20 -11
  293. package/dist/snapping/providers/display.d.ts +6 -1
  294. package/dist/snapping/providers/display.js +2 -1
  295. package/dist/snapping/providers/guide.d.ts +3 -43
  296. package/dist/snapping/providers/guide.js +1 -44
  297. package/dist/snapping/providers/intersection.js +1 -1
  298. package/dist/snapping/providers/store.js +3 -3
  299. package/dist/snapping/service.js +18 -7
  300. package/dist/snapping/types.d.ts +9 -35
  301. package/dist/store/draw-store.js +233 -142
  302. package/dist/store/local-visibility.d.ts +11 -6
  303. package/dist/store/local-visibility.js +38 -7
  304. package/dist/store/lock.d.ts +0 -6
  305. package/dist/store/lock.js +0 -6
  306. package/dist/store/memory/change-bus.d.ts +3 -3
  307. package/dist/store/memory/change-bus.js +12 -0
  308. package/dist/store/memory/file-store.d.ts +2 -2
  309. package/dist/store/memory/ui-state.d.ts +1 -51
  310. package/dist/store/memory/ui-state.js +122 -134
  311. package/dist/store/memory.d.ts +1 -8
  312. package/dist/store/memory.js +249 -45
  313. package/dist/store/ordering.d.ts +9 -0
  314. package/dist/store/ordering.js +17 -0
  315. package/dist/store/spatial/spatial-index.d.ts +1 -1
  316. package/dist/store/spatial/spatial-index.js +1 -1
  317. package/dist/store/spatial/store-spatial-index.d.ts +3 -1
  318. package/dist/store/spatial/store-spatial-index.js +9 -3
  319. package/dist/store/store.d.ts +66 -107
  320. package/dist/store/types.d.ts +1 -1
  321. package/dist/store/writable-layer.d.ts +1 -1
  322. package/dist/store/writable-layer.js +2 -2
  323. package/dist/table/builder.d.ts +83 -0
  324. package/dist/table/builder.js +381 -0
  325. package/dist/table/index.d.ts +37 -0
  326. package/dist/table/index.js +5 -0
  327. package/dist/table/packed-rtree.d.ts +1 -0
  328. package/dist/{display → table}/packed-rtree.js +1 -1
  329. package/dist/table/partition.d.ts +1 -0
  330. package/dist/{display → table}/partition.js +3 -3
  331. package/dist/table/prepare.d.ts +44 -0
  332. package/dist/table/prepare.js +136 -0
  333. package/dist/table/table.d.ts +1 -0
  334. package/dist/{display/columnar → table}/table.js +29 -25
  335. package/dist/{display/columnar → table}/types.d.ts +68 -72
  336. package/dist/table/types.js +3 -0
  337. package/dist/view/coordinator.js +4 -3
  338. package/dist/view/feature-companion.d.ts +13 -7
  339. package/dist/view/feature-companion.js +11 -3
  340. package/dist/view/globe-subdivision.js +3 -3
  341. package/dist/view/layer/attach.d.ts +1 -1
  342. package/dist/view/layer/attach.js +1 -1
  343. package/dist/view/layer/custom-layer.js +40 -11
  344. package/dist/view/layer/display-list.js +2 -1
  345. package/dist/view/layer/drape-planner.d.ts +2 -2
  346. package/dist/view/layer/frame-render.d.ts +3 -3
  347. package/dist/view/layer/frame-render.js +7 -2
  348. package/dist/view/layer/frame-state.d.ts +6 -6
  349. package/dist/view/layer/index.d.ts +2 -2
  350. package/dist/view/layer/index.js +1 -1
  351. package/dist/view/layer/render.d.ts +4 -4
  352. package/dist/view/layer/render.js +3 -8
  353. package/dist/view/layer/renderers.d.ts +2 -2
  354. package/dist/view/layer/renderers.js +1 -1
  355. package/dist/view/layer/slot-manager.d.ts +2 -2
  356. package/dist/view/layer/slot-manager.js +4 -4
  357. package/dist/view/layer/slots.d.ts +2 -2
  358. package/dist/view/layer/slots.js +1 -1
  359. package/dist/view/layer/store-retained-bbox.js +3 -2
  360. package/dist/view/layer/store-retained-classify.d.ts +5 -7
  361. package/dist/view/layer/store-retained-classify.js +19 -7
  362. package/dist/view/layer/store-retained-collect.js +8 -7
  363. package/dist/view/layer/store-retained-coord-patch.d.ts +0 -8
  364. package/dist/view/layer/store-retained-coord-patch.js +13 -4
  365. package/dist/view/layer/store-retained-immediate.d.ts +3 -3
  366. package/dist/view/layer/store-retained-immediate.js +3 -8
  367. package/dist/view/layer/store-retained-invalidation.d.ts +2 -2
  368. package/dist/view/layer/store-retained.d.ts +2 -2
  369. package/dist/view/layer/store-retained.js +1 -1
  370. package/dist/view/renderers/batch-manager.js +8 -7
  371. package/dist/view/renderers/drawer.js +21 -15
  372. package/dist/view/renderers/image.js +13 -39
  373. package/dist/view/renderers/line/line-types.d.ts +3 -3
  374. package/dist/view/renderers/line/sdf-line.js +3 -1
  375. package/dist/view/renderers/point/billboard-depth.js +1 -1
  376. package/dist/view/renderers/point/point-instance.js +1 -1
  377. package/dist/view/renderers/point/point-shape.js +2 -2
  378. package/dist/view/renderers/point/point-style.js +48 -4
  379. package/dist/view/renderers/polygon/batch.js +1 -2
  380. package/dist/view/renderers/polygon/fill.js +3 -1
  381. package/dist/view/renderers/polygon/sdf-polygon.js +2 -3
  382. package/dist/view/renderers/polygon/triangulator.d.ts +1 -1
  383. package/dist/view/renderers/stroke.js +3 -1
  384. package/dist/view/shaders/helpers.d.ts +2 -42
  385. package/dist/view/shaders/helpers.js +0 -6
  386. package/dist/view/shaders/projection.d.ts +15 -7
  387. package/dist/view/shaders/projection.js +23 -6
  388. package/dist/view/shaders/quad.d.ts +16 -12
  389. package/dist/view/shaders/quad.js +34 -13
  390. package/dist/view/style-rule.d.ts +5 -42
  391. package/dist/view/style-rule.js +20 -44
  392. package/dist/view/terrain/binding.d.ts +1 -0
  393. package/dist/view/terrain/binding.js +29 -0
  394. package/dist/view/terrain/context.d.ts +3 -4
  395. package/dist/view/terrain/context.js +4 -5
  396. package/dist/view/terrain/drape/geometry.js +1 -1
  397. package/dist/view/terrain/drape/pass.d.ts +1 -1
  398. package/dist/view/terrain/drape/pass.js +8 -7
  399. package/dist/view/terrain/polygon.d.ts +9 -5
  400. package/dist/view/terrain/polygon.js +16 -2
  401. package/dist/view/terrain/state.d.ts +1 -1
  402. package/dist/view/terrain/state.js +1 -1
  403. package/dist/view/terrain/tessellation.d.ts +2 -2
  404. package/dist/view/terrain/tessellation.js +1 -1
  405. package/dist/view/ui/auxiliary-handles.d.ts +6 -29
  406. package/dist/view/ui/bounds.js +8 -12
  407. package/dist/view/ui/handle-test.js +2 -2
  408. package/dist/view/ui/handle-thinning.js +17 -17
  409. package/dist/view/ui/handles.js +21 -13
  410. package/dist/view/ui/helper.d.ts +1 -1
  411. package/dist/view/ui/helper.js +1 -1
  412. package/dist/view/ui/index.d.ts +1 -1
  413. package/dist/view/ui/selection-scope.js +4 -2
  414. package/dist/view/ui/selection-ui/bounding-box.js +6 -6
  415. package/dist/view/ui/selection-ui/extension-registry.d.ts +31 -20
  416. package/dist/view/ui/selection-ui/extension-registry.js +70 -7
  417. package/dist/view/ui/selection-ui/index.d.ts +2 -2
  418. package/dist/view/ui/selection-ui/index.js +1 -1
  419. package/dist/view/ui/selection-ui/renderer.js +15 -38
  420. package/dist/view/ui/selection-ui/types.d.ts +17 -2
  421. package/dist/view/ui/selection-ui-drawer.d.ts +8 -0
  422. package/dist/view/ui/selection-ui-drawer.js +63 -2
  423. package/dist/view/ui/tentative.js +1 -1
  424. package/dist/webgl/index.d.ts +65 -0
  425. package/dist/webgl/index.js +62 -0
  426. package/package.json +20 -9
  427. package/dist/api/api.d.ts +0 -1259
  428. package/dist/api/api.js +0 -86
  429. package/dist/api/context.d.ts +0 -173
  430. package/dist/api/display-api.js +0 -23
  431. package/dist/api/event-api.d.ts +0 -13
  432. package/dist/api/event-api.js +0 -17
  433. package/dist/api/extension-api.d.ts +0 -46
  434. package/dist/api/extension-api.js +0 -85
  435. package/dist/api/feature-api.d.ts +0 -11
  436. package/dist/api/feature-api.js +0 -101
  437. package/dist/api/geometry/apply.d.ts +0 -51
  438. package/dist/api/geometry/boolean.d.ts +0 -28
  439. package/dist/api/geometry/boolean.js +0 -65
  440. package/dist/api/geometry/types.d.ts +0 -31
  441. package/dist/api/geometry-operations.d.ts +0 -162
  442. package/dist/api/geometry-operations.js +0 -94
  443. package/dist/api/group-api.d.ts +0 -10
  444. package/dist/api/group-api.js +0 -78
  445. package/dist/api/import-export/constants.d.ts +0 -29
  446. package/dist/api/import-export/constants.js +0 -40
  447. package/dist/api/import-export/file-name.d.ts +0 -10
  448. package/dist/api/import-export/file-name.js +0 -20
  449. package/dist/api/import-export/geojson-export.d.ts +0 -19
  450. package/dist/api/import-export/image-import.d.ts +0 -12
  451. package/dist/api/import-export/image-import.js +0 -53
  452. package/dist/api/import-export/index.d.ts +0 -9
  453. package/dist/api/import-export/index.js +0 -107
  454. package/dist/api/import-export/native-format.d.ts +0 -15
  455. package/dist/api/import-export/style-validation.d.ts +0 -27
  456. package/dist/api/import-export/style-validation.js +0 -49
  457. package/dist/api/import-export/types.d.ts +0 -26
  458. package/dist/api/index.d.ts +0 -15
  459. package/dist/api/index.js +0 -3
  460. package/dist/api/input-api.d.ts +0 -158
  461. package/dist/api/input-api.js +0 -144
  462. package/dist/api/instance-api.d.ts +0 -38
  463. package/dist/api/instance-api.js +0 -136
  464. package/dist/api/layer-api.d.ts +0 -12
  465. package/dist/api/layer-api.js +0 -62
  466. package/dist/api/selection-api.d.ts +0 -7
  467. package/dist/api/selection-api.js +0 -78
  468. package/dist/api/snapping-api.d.ts +0 -125
  469. package/dist/api/snapping-api.js +0 -50
  470. package/dist/api/topology-api.d.ts +0 -30
  471. package/dist/api/topology-api.js +0 -16
  472. package/dist/api/tracing-api.d.ts +0 -31
  473. package/dist/api/tracing-api.js +0 -16
  474. package/dist/dispatcher/hit-test/index.d.ts +0 -14
  475. package/dist/dispatcher/hit-test/index.js +0 -9
  476. package/dist/dispatcher/index.d.ts +0 -15
  477. package/dist/dispatcher/index.js +0 -3
  478. package/dist/display/columnar/index.d.ts +0 -12
  479. package/dist/display/columnar/index.js +0 -13
  480. package/dist/display/columnar/prepare.d.ts +0 -42
  481. package/dist/display/columnar/prepare.js +0 -116
  482. package/dist/display/index.d.ts +0 -13
  483. package/dist/display/types.js +0 -43
  484. package/dist/maplibre-gl-draw.d.ts +0 -47
  485. package/dist/modes/cursor.js +0 -72
  486. package/dist/modes/index.d.ts +0 -7
  487. package/dist/operations/index.d.ts +0 -9
  488. package/dist/operations/index.js +0 -3
  489. package/dist/plugins/index.d.ts +0 -10
  490. package/dist/plugins/mutation-hooks.d.ts +0 -28
  491. package/dist/plugins/mutation-hooks.js +0 -84
  492. package/dist/plugins/plugin-context.js +0 -367
  493. package/dist/plugins/plugin-manager.d.ts +0 -103
  494. package/dist/plugins/plugin-manager.js +0 -316
  495. package/dist/plugins/plugin.d.ts +0 -529
  496. package/dist/shared/config/index.d.ts +0 -17
  497. package/dist/shared/config/index.js +0 -8
  498. package/dist/shared/utils/index.d.ts +0 -15
  499. package/dist/shared/utils/index.js +0 -24
  500. package/dist/snapping/index.d.ts +0 -14
  501. package/dist/snapping/index.js +0 -4
  502. package/dist/store/change-merger.js +0 -102
  503. package/dist/store/event-bridge.js +0 -161
  504. package/dist/store/index.d.ts +0 -12
  505. package/dist/store/index.js +0 -4
  506. package/dist/view/index.d.ts +0 -47
  507. package/dist/view/index.js +0 -20
  508. /package/dist/api/{geometry/types.js → datasets.js} +0 -0
  509. /package/dist/api/{import-export/types.js → document.js} +0 -0
  510. /package/dist/{display/columnar/types.js → api/drawing.js} +0 -0
  511. /package/dist/{display/index.js → api/events.js} +0 -0
  512. /package/dist/{modes/index.js → api/extension/context.js} +0 -0
  513. /package/dist/{plugins/index.js → api/extension/feature-type.js} +0 -0
  514. /package/dist/{plugins/plugin.js → api/extension/mode.js} +0 -0
  515. /package/dist/api/{display-api.d.ts → impl/adapters.d.ts} +0 -0
  516. /package/dist/{display/columnar/source.d.ts → api/impl/contexts.d.ts} +0 -0
  517. /package/dist/{display/columnar/table.d.ts → api/impl/create-draw.d.ts} +0 -0
  518. /package/dist/{display/interaction.d.ts → api/impl/datasets.d.ts} +0 -0
  519. /package/dist/{display/manager.d.ts → api/impl/destroy-guard.d.ts} +0 -0
  520. /package/dist/{display/packed-rtree.d.ts → api/impl/document.d.ts} +0 -0
  521. /package/dist/{display/partition.d.ts → api/impl/drawing.d.ts} +0 -0
  522. /package/dist/{display/provider.d.ts → api/impl/engine.d.ts} +0 -0
  523. /package/dist/{display/source.d.ts → api/impl/events.d.ts} +0 -0
  524. /package/dist/{display/spatial.d.ts → api/impl/extension-host.d.ts} +0 -0
  525. /package/dist/{display/style.d.ts → api/impl/extensions.d.ts} +0 -0
  526. /package/dist/{display/triangulation.d.ts → api/impl/features.d.ts} +0 -0
  527. /package/dist/{modes/cursor.d.ts → api/impl/geometry/types.d.ts} +0 -0
  528. /package/dist/{plugins/plugin-context.d.ts → api/impl/hidden.d.ts} +0 -0
  529. /package/dist/api/{import-export → impl/import-export}/embedded-file.d.ts +0 -0
  530. /package/dist/api/{import-export → impl/import-export}/own-property.d.ts +0 -0
  531. /package/dist/api/{import-export → impl/import-export}/own-property.js +0 -0
  532. /package/dist/{store/change-merger.d.ts → api/impl/input.d.ts} +0 -0
  533. /package/dist/{store/event-bridge.d.ts → api/impl/layers.d.ts} +0 -0
  534. /package/dist/{display → dataset}/chunk-set.d.ts +0 -0
  535. /package/dist/{display → dataset}/chunk-set.js +0 -0
  536. /package/dist/{display → dataset}/dataset.d.ts +0 -0
  537. /package/dist/{display → dataset}/manager.js +0 -0
  538. /package/dist/{display → dataset}/provider.js +0 -0
  539. /package/dist/{display → dataset}/selection.d.ts +0 -0
  540. /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 feature, nested as deep as its type needs
13
+ * The coordinates of a GeoJSON geometry, nested as deep as its kind needs
13
14
  *
14
- * The nesting depth of the array expresses the structure of the geometry. It follows the
15
- * `coordinates` of the GeoJSON geometry of the same name.
16
- *
17
- * - `Coordinate`: Point, Image (the anchor of the image) and Circle (the center; the radius
18
- * is `properties.radiusMeters`)
19
- * - `Coordinate[]`: LineString, Freehand and MultiPoint (a sequence of coordinates)
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 = Coordinate | Coordinate[] | Coordinate[][] | Coordinate[][][];
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 shape of
32
- * `Feature.coordinates` ({@link FeatureCoordinates}). Any other string names a custom type,
33
- * which an extension adds with `registerFeatureHandler` ({@link CustomFeatureHandler}).
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
- vertexIndices: VertexRef[];
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 `#rgb` or `#rrggbb`.
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 and the keys of {@link ImageStyle} |
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 (the marker keeps its white outline)
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 an image, from 0 to 1 (it takes precedence over {@link ImageStyle.opacity})
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
- imageOpacity?: number;
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 height in pixels at the created zoom
211
+ * The color of the outline of the marker of a point
233
212
  *
234
- * @defaultValue the height of the image (`properties.imageHeight`)
213
+ * @defaultValue `'#ffffff'`
235
214
  */
236
- height?: number;
215
+ pointStrokeColor?: string;
237
216
  /**
238
- * A rotation in degrees, added to `properties.rotation`
217
+ * The width of the outline of the marker of a point, in CSS pixels (0 for none)
239
218
  *
240
- * @defaultValue `0`
219
+ * @defaultValue `2`
241
220
  */
242
- rotation?: number;
221
+ pointStrokeWidth?: number;
243
222
  /**
244
- * The opacity from 0 to 1, used when {@link FeatureStyle.imageOpacity} is unset
223
+ * The opacity of an image, from 0 to 1
245
224
  *
246
225
  * @defaultValue `1`
247
226
  */
248
- opacity?: number;
227
+ imageOpacity?: number;
249
228
  }
250
229
  /**
251
- * The properties core keeps in `Feature.properties` of an Image feature
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. The image data itself is a
254
- * {@link FileData} of the Store, which `imageFileId` names, so that several features can share
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 of the image in pixels */
239
+ /** The width in pixels the image is drawn at, at the created zoom */
261
240
  imageWidth: number;
262
- /** The height of the image in pixels */
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 (`properties.imageFileId` of an Image), and the native format
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 attributes
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 `getFeature`, `getAllFeatures` and the events, and
290
- * creates them from a {@link FeatureInput}. What the instance returns is read-only: change a
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.order`, or in `Group.featureIds` when it belongs to a group.
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 shape of `coordinates` */
277
+ /** The type of the feature, which decides the kind of `geometry` */
300
278
  type: FeatureType;
301
- /** The geometry, nested as {@link FeatureCoordinates} describes for each type */
302
- coordinates: FeatureCoordinates;
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.order`.
292
+ * A feature in a group is listed in `Group.featureIds` instead of `Layer.items`.
312
293
  */
313
- groupId?: string;
294
+ groupId: string | undefined;
314
295
  /**
315
- * The attributes of the feature
296
+ * The GeoJSON properties: the attributes of the user and the values of the library
316
297
  *
317
- * They are free-form, and GeoJSON export writes them as the GeoJSON properties. Core also
318
- * reads and writes a few keys of its own here: `name` and `description`, `createdZoom`,
319
- * `rotation` and `scale` (see {@link getCreatedZoom}, {@link getRotation} and
320
- * {@link getScale}), `radiusMeters` and `radiusHandleAngle` of a Circle, and the keys of
321
- * {@link ImageProperties} of an Image.
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 style rule apply when omitted);
326
- * an Image takes an {@link ImageStyle}
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?: FeatureStyle | ImageStyle;
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 with `addFeature`: a {@link Feature} whose other fields
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 `coordinates` are required; the other fields take the defaults written on
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
- /** Coordinates */
358
- coordinates: FeatureCoordinates;
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 | ImageStyle;
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 `order`. New
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 `CustomRendererDrawContext.opacity`). It is applied at draw time, so changing it is
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
- order: string[];
441
+ items: readonly string[];
475
442
  /** Free-form data of the host, saved and exported with the layer */
476
- metadata?: Record<string, unknown>;
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?: 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.order` of its layer like a feature, and its members are listed
489
- * in `featureIds` (each member has `groupId` set). The layer of a group is the layer whose
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 StateChanges.tentative}).
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: loading a native file, which replaces
566
- * the whole document, and clearing the selection when a mode starts
567
- * - batch: loading a GeoJSON file, a bulk change recorded as one step (it is one transaction,
568
- * which is what makes it one notification)
569
- * - remote: a change that came from outside the instance. A replaced {@link DocumentStore}
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 StateChanges.features.updated. An external store can look at this
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
- * {@link DocumentStore} notifies; the others are local state of this client.
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 StateChanges {
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 'batch', and a replaced store writes 'remote' for the changes it applies
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.order array.
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 StateChanges, but they are notified in order
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 (`'2.0.0'` for this release) */
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 {@link DocumentStore.setLayerOrder}) at their
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 (#RRGGBB or #RGB)
25
- * @param to - Color of the end point (#RRGGBB or #RGB)
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;