@sakuzu/maplibre-gl-draw 1.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (541) hide show
  1. package/CHANGELOG.md +1109 -2
  2. package/README.ja.md +83 -50
  3. package/README.md +89 -53
  4. package/THIRD_PARTY_NOTICES.md +29 -0
  5. package/dist/api/datasets.d.ts +263 -0
  6. package/dist/api/document.d.ts +66 -0
  7. package/dist/api/draw.d.ts +137 -0
  8. package/dist/api/draw.js +20 -0
  9. package/dist/api/drawing.d.ts +87 -0
  10. package/dist/api/errors.d.ts +35 -0
  11. package/dist/api/errors.js +35 -0
  12. package/dist/api/events.d.ts +316 -0
  13. package/dist/api/extension/context.d.ts +247 -0
  14. package/dist/api/extension/feature-type.d.ts +129 -0
  15. package/dist/api/extension/mode.d.ts +123 -0
  16. package/dist/api/extension/plugin.d.ts +51 -0
  17. package/dist/api/extension/plugin.js +3 -0
  18. package/dist/api/extension/provider.d.ts +119 -0
  19. package/dist/api/extension/provider.js +3 -0
  20. package/dist/api/extension/render.d.ts +176 -0
  21. package/dist/api/extension/render.js +3 -0
  22. package/dist/api/extension/store.d.ts +190 -0
  23. package/dist/api/extension/store.js +3 -0
  24. package/dist/api/extensions.d.ts +306 -0
  25. package/dist/api/extensions.js +3 -0
  26. package/dist/api/features.d.ts +188 -0
  27. package/dist/api/features.js +3 -0
  28. package/dist/api/groups.d.ts +111 -0
  29. package/dist/api/groups.js +3 -0
  30. package/dist/api/hidden.d.ts +45 -0
  31. package/dist/api/hidden.js +3 -0
  32. package/dist/api/impl/adapters.js +463 -0
  33. package/dist/api/impl/contexts.js +466 -0
  34. package/dist/api/impl/create-draw.js +124 -0
  35. package/dist/api/impl/datasets.js +405 -0
  36. package/dist/api/impl/destroy-guard.js +74 -0
  37. package/dist/api/impl/document.js +280 -0
  38. package/dist/api/impl/drawing.js +180 -0
  39. package/dist/api/impl/engine-context.d.ts +7 -0
  40. package/dist/api/{context.js → impl/engine-context.js} +49 -38
  41. package/dist/{maplibre-gl-draw.js → api/impl/engine.js} +145 -177
  42. package/dist/api/impl/events.js +423 -0
  43. package/dist/api/impl/extension-host.js +364 -0
  44. package/dist/api/impl/extensions.js +229 -0
  45. package/dist/api/impl/features.js +445 -0
  46. package/dist/api/impl/geometry/apply.d.ts +32 -0
  47. package/dist/api/{geometry → impl/geometry}/apply.js +10 -27
  48. package/dist/api/{geometry → impl/geometry}/buffer.d.ts +4 -3
  49. package/dist/api/{geometry → impl/geometry}/buffer.js +12 -23
  50. package/dist/api/{geometry → impl/geometry}/split.d.ts +4 -3
  51. package/dist/api/{geometry → impl/geometry}/split.js +10 -21
  52. package/dist/api/{geometry → impl/geometry}/targets.d.ts +2 -20
  53. package/dist/api/{geometry → impl/geometry}/targets.js +8 -35
  54. package/dist/api/impl/geometry/types.js +3 -0
  55. package/dist/api/impl/groups.d.ts +3 -0
  56. package/dist/api/impl/groups.js +268 -0
  57. package/dist/api/impl/hidden.js +60 -0
  58. package/dist/api/impl/import-export/constants.d.ts +22 -0
  59. package/dist/api/impl/import-export/constants.js +24 -0
  60. package/dist/api/{import-export → impl/import-export}/embedded-file.js +2 -2
  61. package/dist/api/{import-export → impl/import-export}/format-detection.d.ts +1 -1
  62. package/dist/api/{import-export → impl/import-export}/format-detection.js +2 -1
  63. package/dist/api/impl/import-export/geojson-export.d.ts +19 -0
  64. package/dist/api/{import-export → impl/import-export}/geojson-export.js +71 -104
  65. package/dist/api/{import-export → impl/import-export}/geojson-import.d.ts +11 -7
  66. package/dist/api/{import-export → impl/import-export}/geojson-import.js +139 -97
  67. package/dist/api/{import-export → impl/import-export}/geometry-validation.d.ts +14 -0
  68. package/dist/api/{import-export → impl/import-export}/geometry-validation.js +45 -0
  69. package/dist/api/impl/import-export/image-import.d.ts +16 -0
  70. package/dist/api/impl/import-export/image-import.js +73 -0
  71. package/dist/api/impl/import-export/legacy-image-style.d.ts +16 -0
  72. package/dist/api/impl/import-export/legacy-image-style.js +49 -0
  73. package/dist/api/impl/import-export/native-format.d.ts +14 -0
  74. package/dist/api/{import-export → impl/import-export}/native-format.js +32 -22
  75. package/dist/api/impl/import-export/native-upgrade.d.ts +8 -0
  76. package/dist/api/impl/import-export/native-upgrade.js +139 -0
  77. package/dist/api/{import-export → impl/import-export}/native-validation.d.ts +1 -1
  78. package/dist/api/{import-export → impl/import-export}/native-validation.js +15 -14
  79. package/dist/api/impl/import-export/style-validation.d.ts +24 -0
  80. package/dist/api/impl/import-export/style-validation.js +86 -0
  81. package/dist/api/impl/import-export/types.d.ts +52 -0
  82. package/dist/api/impl/import-export/types.js +3 -0
  83. package/dist/api/impl/input.js +180 -0
  84. package/dist/api/impl/layers.js +307 -0
  85. package/dist/api/impl/metadata.d.ts +1 -0
  86. package/dist/api/impl/metadata.js +22 -0
  87. package/dist/api/impl/options.d.ts +1 -0
  88. package/dist/api/impl/options.js +851 -0
  89. package/dist/api/impl/placement.d.ts +1 -0
  90. package/dist/api/impl/placement.js +138 -0
  91. package/dist/api/impl/render-context.d.ts +13 -0
  92. package/dist/api/impl/render-context.js +272 -0
  93. package/dist/api/impl/rows.d.ts +1 -0
  94. package/dist/api/impl/rows.js +46 -0
  95. package/dist/api/impl/selection.d.ts +1 -0
  96. package/dist/api/impl/selection.js +186 -0
  97. package/dist/api/impl/shared.d.ts +64 -0
  98. package/dist/api/impl/shared.js +178 -0
  99. package/dist/api/impl/validate-extension.d.ts +1 -0
  100. package/dist/api/impl/validate-extension.js +159 -0
  101. package/dist/api/layers.d.ts +130 -0
  102. package/dist/api/layers.js +3 -0
  103. package/dist/api/metadata.d.ts +18 -0
  104. package/dist/api/metadata.js +3 -0
  105. package/dist/api/model.d.ts +487 -0
  106. package/dist/api/model.js +47 -0
  107. package/dist/api/options.d.ts +466 -0
  108. package/dist/api/options.js +3 -0
  109. package/dist/api/selection.d.ts +94 -0
  110. package/dist/api/selection.js +3 -0
  111. package/dist/api/state.d.ts +155 -0
  112. package/dist/api/state.js +12 -0
  113. package/dist/{display → dataset}/chunk.d.ts +1 -1
  114. package/dist/{display → dataset}/chunk.js +4 -3
  115. package/dist/{display → dataset}/dataset.js +21 -21
  116. package/dist/dataset/interaction.d.ts +1 -0
  117. package/dist/{display → dataset}/interaction.js +18 -6
  118. package/dist/dataset/manager.d.ts +1 -0
  119. package/dist/dataset/provider.d.ts +1 -0
  120. package/dist/{display → dataset}/retained.d.ts +1 -1
  121. package/dist/{display → dataset}/retained.js +8 -7
  122. package/dist/dataset/source.d.ts +1 -0
  123. package/dist/{display → dataset}/source.js +17 -4
  124. package/dist/dataset/spatial.d.ts +1 -0
  125. package/dist/{display → dataset}/spatial.js +1 -1
  126. package/dist/dataset/style.d.ts +1 -0
  127. package/dist/{display → dataset}/style.js +1 -1
  128. package/dist/dataset/table-source.d.ts +1 -0
  129. package/dist/{display/columnar/source.js → dataset/table-source.js} +53 -25
  130. package/dist/{display → dataset}/thinning.d.ts +0 -10
  131. package/dist/{display → dataset}/thinning.js +3 -2
  132. package/dist/dataset/triangulation.d.ts +1 -0
  133. package/dist/{display → dataset}/triangulation.js +0 -0
  134. package/dist/{display → dataset}/types.d.ts +84 -121
  135. package/dist/dataset/types.js +61 -0
  136. package/dist/dispatcher/hit-test/box-strategies.js +13 -13
  137. package/dist/dispatcher/hit-test/box-strategy.d.ts +2 -15
  138. package/dist/dispatcher/hit-test/globe-shape.js +5 -4
  139. package/dist/dispatcher/hit-test/service.d.ts +17 -0
  140. package/dist/dispatcher/hit-test/service.js +80 -16
  141. package/dist/dispatcher/hit-test/strategies/base.d.ts +13 -19
  142. package/dist/dispatcher/hit-test/strategies/circle.js +3 -2
  143. package/dist/dispatcher/hit-test/strategies/image.js +6 -18
  144. package/dist/dispatcher/hit-test/strategies/line.d.ts +0 -6
  145. package/dist/dispatcher/hit-test/strategies/line.js +9 -2
  146. package/dist/dispatcher/hit-test/strategies/multi.d.ts +0 -8
  147. package/dist/dispatcher/hit-test/strategies/multi.js +17 -8
  148. package/dist/dispatcher/hit-test/strategies/point.d.ts +9 -7
  149. package/dist/dispatcher/hit-test/strategies/point.js +8 -4
  150. package/dist/dispatcher/hit-test/strategies/polygon.d.ts +0 -7
  151. package/dist/dispatcher/hit-test/strategies/polygon.js +11 -3
  152. package/dist/dispatcher/hit-test/topmost.d.ts +1 -1
  153. package/dist/dispatcher/input-router.js +154 -70
  154. package/dist/dispatcher/normalizer.js +25 -4
  155. package/dist/dispatcher/types.d.ts +6 -1
  156. package/dist/extension/feature-handler.d.ts +1 -182
  157. package/dist/extension/index.d.ts +4 -7
  158. package/dist/extension/renderers.d.ts +1 -208
  159. package/dist/geometry/angle.d.ts +0 -8
  160. package/dist/geometry/angle.js +0 -8
  161. package/dist/geometry/bbox.d.ts +4 -12
  162. package/dist/geometry/bbox.js +4 -12
  163. package/dist/geometry/boolean.d.ts +0 -51
  164. package/dist/geometry/boolean.js +0 -51
  165. package/dist/geometry/buffer.d.ts +0 -26
  166. package/dist/geometry/buffer.js +0 -26
  167. package/dist/geometry/circle.d.ts +0 -9
  168. package/dist/geometry/circle.js +0 -9
  169. package/dist/geometry/coords.d.ts +0 -16
  170. package/dist/geometry/coords.js +0 -16
  171. package/dist/geometry/distance.d.ts +0 -24
  172. package/dist/geometry/distance.js +0 -24
  173. package/dist/geometry/errors.d.ts +21 -36
  174. package/dist/geometry/errors.js +49 -29
  175. package/dist/geometry/geojson.d.ts +85 -0
  176. package/dist/geometry/geojson.js +173 -0
  177. package/dist/geometry/index.d.ts +38 -23
  178. package/dist/geometry/index.js +43 -31
  179. package/dist/geometry/measure.d.ts +0 -27
  180. package/dist/geometry/measure.js +0 -27
  181. package/dist/geometry/predicates.d.ts +0 -9
  182. package/dist/geometry/predicates.js +0 -9
  183. package/dist/geometry/public-bounds.d.ts +26 -0
  184. package/dist/geometry/public-bounds.js +30 -0
  185. package/dist/geometry/public-combine.d.ts +78 -0
  186. package/dist/geometry/public-combine.js +82 -0
  187. package/dist/geometry/public-create.d.ts +54 -0
  188. package/dist/geometry/public-create.js +70 -0
  189. package/dist/geometry/public-measure.d.ts +170 -0
  190. package/dist/geometry/public-measure.js +283 -0
  191. package/dist/geometry/public-predicates.d.ts +54 -0
  192. package/dist/geometry/public-predicates.js +144 -0
  193. package/dist/geometry/public-repair.d.ts +75 -0
  194. package/dist/geometry/public-repair.js +77 -0
  195. package/dist/geometry/simplify.d.ts +0 -7
  196. package/dist/geometry/simplify.js +0 -7
  197. package/dist/geometry/split.d.ts +0 -20
  198. package/dist/geometry/split.js +0 -20
  199. package/dist/geometry/units.d.ts +20 -12
  200. package/dist/geometry/units.js +20 -12
  201. package/dist/index.d.ts +66 -66
  202. package/dist/index.js +6 -18
  203. package/dist/messages.d.ts +7 -7
  204. package/dist/modes/draw/circle.js +83 -207
  205. package/dist/modes/draw/commit-layer.d.ts +5 -16
  206. package/dist/modes/draw/commit-layer.js +2 -13
  207. package/dist/modes/draw/freehand.js +108 -246
  208. package/dist/modes/draw/image.js +4 -2
  209. package/dist/modes/draw/index.d.ts +5 -5
  210. package/dist/modes/draw/index.js +5 -5
  211. package/dist/modes/draw/line.js +18 -354
  212. package/dist/modes/draw/point.js +29 -78
  213. package/dist/modes/draw/polygon.js +23 -368
  214. package/dist/modes/draw/trace-support.d.ts +43 -36
  215. package/dist/modes/draw/trace-support.js +95 -98
  216. package/dist/modes/draw/vertex-drawing.d.ts +1 -0
  217. package/dist/modes/draw/vertex-drawing.js +176 -0
  218. package/dist/modes/handler.d.ts +1 -285
  219. package/dist/modes/manager.d.ts +2 -2
  220. package/dist/modes/manager.js +3 -0
  221. package/dist/modes/select/box-selection.d.ts +3 -3
  222. package/dist/modes/select/box-selection.js +2 -1
  223. package/dist/modes/select/click-handler.d.ts +5 -5
  224. package/dist/modes/select/click-handler.js +22 -20
  225. package/dist/modes/select/cursor-handler.d.ts +2 -2
  226. package/dist/modes/select/drag/intermediate-writes.js +1 -1
  227. package/dist/modes/select/drag/move.js +3 -3
  228. package/dist/modes/select/drag/operation.d.ts +3 -3
  229. package/dist/modes/select/drag/radius.js +5 -4
  230. package/dist/modes/select/drag/transform.d.ts +2 -2
  231. package/dist/modes/select/drag/transform.js +11 -5
  232. package/dist/modes/select/drag/vertex.d.ts +2 -2
  233. package/dist/modes/select/drag/vertex.js +13 -8
  234. package/dist/modes/select/drag-handler.js +44 -25
  235. package/dist/modes/select/mode.js +17 -17
  236. package/dist/modes/select/shortcut-handler.d.ts +8 -8
  237. package/dist/modes/select/shortcut-handler.js +9 -7
  238. package/dist/operations/layer-operations.js +29 -168
  239. package/dist/operations/resize.d.ts +2 -2
  240. package/dist/operations/resize.js +5 -5
  241. package/dist/operations/rotate.js +5 -5
  242. package/dist/operations/selection-operations.d.ts +16 -1
  243. package/dist/operations/selection-operations.js +28 -13
  244. package/dist/operations/shared-vertex.js +4 -2
  245. package/dist/operations/trace-graph.d.ts +0 -18
  246. package/dist/operations/trace-graph.js +0 -18
  247. package/dist/operations/vertex.js +36 -35
  248. package/dist/shared/color.d.ts +1 -0
  249. package/dist/shared/color.js +245 -0
  250. package/dist/shared/config/constants.d.ts +1 -54
  251. package/dist/shared/config/constants.js +1 -58
  252. package/dist/shared/config/feature-style.d.ts +16 -13
  253. package/dist/shared/config/feature-style.js +9 -0
  254. package/dist/shared/config/rendering.d.ts +3 -3
  255. package/dist/shared/config/selection-highlight.d.ts +0 -15
  256. package/dist/shared/config/selection-highlight.js +4 -7
  257. package/dist/shared/config/selection.d.ts +2 -32
  258. package/dist/shared/config/selection.js +0 -18
  259. package/dist/shared/config/topology.d.ts +2 -2
  260. package/dist/shared/config/trace.d.ts +4 -4
  261. package/dist/shared/math/angle.d.ts +1 -1
  262. package/dist/shared/math/angle.js +1 -1
  263. package/dist/shared/math/circle.d.ts +1 -1
  264. package/dist/shared/math/circle.js +1 -1
  265. package/dist/shared/math/distance.d.ts +2 -1
  266. package/dist/shared/math/distance.js +3 -2
  267. package/dist/shared/math/index.d.ts +1 -1
  268. package/dist/shared/math/index.js +1 -1
  269. package/dist/shared/math/transform.d.ts +23 -0
  270. package/dist/shared/math/transform.js +47 -28
  271. package/dist/shared/properties.d.ts +18 -0
  272. package/dist/shared/properties.js +129 -0
  273. package/dist/shared/types/events.d.ts +15 -7
  274. package/dist/shared/types/model.d.ts +109 -159
  275. package/dist/shared/types/style.d.ts +1 -1
  276. package/dist/shared/utils/color.d.ts +2 -36
  277. package/dist/shared/utils/color.js +13 -70
  278. package/dist/shared/utils/coordinates.d.ts +30 -4
  279. package/dist/shared/utils/coordinates.js +56 -10
  280. package/dist/shared/utils/event-emitter.d.ts +1 -262
  281. package/dist/shared/utils/event-emitter.js +4 -3
  282. package/dist/shared/utils/feature-bbox.js +8 -7
  283. package/dist/shared/utils/feature-segments.js +5 -4
  284. package/dist/shared/utils/image.d.ts +0 -4
  285. package/dist/shared/utils/image.js +0 -6
  286. package/dist/shared/utils/name-generator.d.ts +14 -20
  287. package/dist/shared/utils/name-generator.js +20 -3
  288. package/dist/shared/utils/pixel-ratio.d.ts +9 -3
  289. package/dist/shared/utils/pixel-ratio.js +13 -4
  290. package/dist/shared/utils/property.d.ts +7 -50
  291. package/dist/shared/utils/property.js +22 -87
  292. package/dist/snapping/custom-targets.js +21 -4
  293. package/dist/snapping/indicator.js +20 -11
  294. package/dist/snapping/providers/display.d.ts +6 -1
  295. package/dist/snapping/providers/display.js +2 -1
  296. package/dist/snapping/providers/guide.d.ts +3 -43
  297. package/dist/snapping/providers/guide.js +1 -44
  298. package/dist/snapping/providers/intersection.js +1 -1
  299. package/dist/snapping/providers/store.js +3 -3
  300. package/dist/snapping/service.js +18 -7
  301. package/dist/snapping/types.d.ts +9 -35
  302. package/dist/store/draw-store.js +233 -142
  303. package/dist/store/local-visibility.d.ts +11 -6
  304. package/dist/store/local-visibility.js +38 -7
  305. package/dist/store/lock.d.ts +0 -6
  306. package/dist/store/lock.js +0 -6
  307. package/dist/store/memory/change-bus.d.ts +3 -3
  308. package/dist/store/memory/change-bus.js +12 -0
  309. package/dist/store/memory/file-store.d.ts +2 -2
  310. package/dist/store/memory/ui-state.d.ts +1 -51
  311. package/dist/store/memory/ui-state.js +122 -134
  312. package/dist/store/memory.d.ts +1 -8
  313. package/dist/store/memory.js +249 -45
  314. package/dist/store/ordering.d.ts +9 -0
  315. package/dist/store/ordering.js +17 -0
  316. package/dist/store/spatial/spatial-index.d.ts +1 -1
  317. package/dist/store/spatial/spatial-index.js +1 -1
  318. package/dist/store/spatial/store-spatial-index.d.ts +3 -1
  319. package/dist/store/spatial/store-spatial-index.js +9 -3
  320. package/dist/store/store.d.ts +66 -107
  321. package/dist/store/types.d.ts +1 -1
  322. package/dist/store/writable-layer.d.ts +1 -1
  323. package/dist/store/writable-layer.js +2 -2
  324. package/dist/table/builder.d.ts +83 -0
  325. package/dist/table/builder.js +381 -0
  326. package/dist/table/index.d.ts +37 -0
  327. package/dist/table/index.js +5 -0
  328. package/dist/table/packed-rtree.d.ts +1 -0
  329. package/dist/{display → table}/packed-rtree.js +1 -1
  330. package/dist/table/partition.d.ts +1 -0
  331. package/dist/{display → table}/partition.js +3 -3
  332. package/dist/table/prepare.d.ts +44 -0
  333. package/dist/table/prepare.js +136 -0
  334. package/dist/table/table.d.ts +1 -0
  335. package/dist/{display/columnar → table}/table.js +29 -25
  336. package/dist/{display/columnar → table}/types.d.ts +68 -72
  337. package/dist/table/types.js +3 -0
  338. package/dist/view/coordinator.js +4 -3
  339. package/dist/view/feature-companion.d.ts +13 -7
  340. package/dist/view/feature-companion.js +11 -3
  341. package/dist/view/globe-subdivision.js +3 -3
  342. package/dist/view/layer/attach.d.ts +12 -6
  343. package/dist/view/layer/attach.js +86 -10
  344. package/dist/view/layer/custom-layer.js +40 -11
  345. package/dist/view/layer/display-list.js +2 -1
  346. package/dist/view/layer/drape-planner.d.ts +2 -2
  347. package/dist/view/layer/frame-render.d.ts +3 -3
  348. package/dist/view/layer/frame-render.js +7 -2
  349. package/dist/view/layer/frame-state.d.ts +6 -6
  350. package/dist/view/layer/index.d.ts +2 -2
  351. package/dist/view/layer/index.js +1 -1
  352. package/dist/view/layer/render.d.ts +4 -4
  353. package/dist/view/layer/render.js +3 -8
  354. package/dist/view/layer/renderers.d.ts +2 -2
  355. package/dist/view/layer/renderers.js +1 -1
  356. package/dist/view/layer/slot-manager.d.ts +2 -2
  357. package/dist/view/layer/slot-manager.js +4 -4
  358. package/dist/view/layer/slots.d.ts +2 -2
  359. package/dist/view/layer/slots.js +1 -1
  360. package/dist/view/layer/store-retained-bbox.js +3 -2
  361. package/dist/view/layer/store-retained-classify.d.ts +5 -7
  362. package/dist/view/layer/store-retained-classify.js +19 -7
  363. package/dist/view/layer/store-retained-collect.js +8 -7
  364. package/dist/view/layer/store-retained-coord-patch.d.ts +0 -8
  365. package/dist/view/layer/store-retained-coord-patch.js +13 -4
  366. package/dist/view/layer/store-retained-immediate.d.ts +3 -3
  367. package/dist/view/layer/store-retained-immediate.js +3 -8
  368. package/dist/view/layer/store-retained-invalidation.d.ts +2 -2
  369. package/dist/view/layer/store-retained.d.ts +2 -2
  370. package/dist/view/layer/store-retained.js +1 -1
  371. package/dist/view/renderers/batch-manager.js +8 -7
  372. package/dist/view/renderers/drawer.js +21 -15
  373. package/dist/view/renderers/image.js +13 -39
  374. package/dist/view/renderers/line/line-types.d.ts +3 -3
  375. package/dist/view/renderers/line/sdf-line.js +3 -1
  376. package/dist/view/renderers/point/billboard-depth.js +1 -1
  377. package/dist/view/renderers/point/point-instance.js +1 -1
  378. package/dist/view/renderers/point/point-shape.js +2 -2
  379. package/dist/view/renderers/point/point-style.js +48 -4
  380. package/dist/view/renderers/polygon/batch.js +1 -2
  381. package/dist/view/renderers/polygon/fill.js +3 -1
  382. package/dist/view/renderers/polygon/sdf-polygon.js +2 -3
  383. package/dist/view/renderers/polygon/triangulator.d.ts +1 -1
  384. package/dist/view/renderers/stroke.js +3 -1
  385. package/dist/view/shaders/helpers.d.ts +2 -42
  386. package/dist/view/shaders/helpers.js +0 -6
  387. package/dist/view/shaders/projection.d.ts +15 -7
  388. package/dist/view/shaders/projection.js +23 -6
  389. package/dist/view/shaders/quad.d.ts +16 -12
  390. package/dist/view/shaders/quad.js +34 -13
  391. package/dist/view/style-rule.d.ts +5 -42
  392. package/dist/view/style-rule.js +20 -44
  393. package/dist/view/terrain/binding.d.ts +1 -0
  394. package/dist/view/terrain/binding.js +29 -0
  395. package/dist/view/terrain/context.d.ts +3 -4
  396. package/dist/view/terrain/context.js +4 -5
  397. package/dist/view/terrain/drape/geometry.js +1 -1
  398. package/dist/view/terrain/drape/pass.d.ts +1 -1
  399. package/dist/view/terrain/drape/pass.js +8 -7
  400. package/dist/view/terrain/polygon.d.ts +9 -5
  401. package/dist/view/terrain/polygon.js +16 -2
  402. package/dist/view/terrain/state.d.ts +1 -1
  403. package/dist/view/terrain/state.js +1 -1
  404. package/dist/view/terrain/tessellation.d.ts +2 -2
  405. package/dist/view/terrain/tessellation.js +1 -1
  406. package/dist/view/ui/auxiliary-handles.d.ts +6 -29
  407. package/dist/view/ui/bounds.js +8 -12
  408. package/dist/view/ui/handle-test.js +2 -2
  409. package/dist/view/ui/handle-thinning.js +17 -17
  410. package/dist/view/ui/handles.js +21 -13
  411. package/dist/view/ui/helper.d.ts +1 -1
  412. package/dist/view/ui/helper.js +1 -1
  413. package/dist/view/ui/index.d.ts +1 -1
  414. package/dist/view/ui/selection-scope.js +4 -2
  415. package/dist/view/ui/selection-ui/bounding-box.js +6 -6
  416. package/dist/view/ui/selection-ui/extension-registry.d.ts +31 -20
  417. package/dist/view/ui/selection-ui/extension-registry.js +70 -7
  418. package/dist/view/ui/selection-ui/index.d.ts +2 -2
  419. package/dist/view/ui/selection-ui/index.js +1 -1
  420. package/dist/view/ui/selection-ui/renderer.js +15 -38
  421. package/dist/view/ui/selection-ui/types.d.ts +17 -2
  422. package/dist/view/ui/selection-ui-drawer.d.ts +8 -0
  423. package/dist/view/ui/selection-ui-drawer.js +63 -2
  424. package/dist/view/ui/tentative.js +1 -1
  425. package/dist/webgl/index.d.ts +65 -0
  426. package/dist/webgl/index.js +62 -0
  427. package/package.json +38 -15
  428. package/dist/api/api.d.ts +0 -1259
  429. package/dist/api/api.js +0 -86
  430. package/dist/api/context.d.ts +0 -173
  431. package/dist/api/display-api.js +0 -23
  432. package/dist/api/event-api.d.ts +0 -13
  433. package/dist/api/event-api.js +0 -17
  434. package/dist/api/extension-api.d.ts +0 -46
  435. package/dist/api/extension-api.js +0 -85
  436. package/dist/api/feature-api.d.ts +0 -11
  437. package/dist/api/feature-api.js +0 -101
  438. package/dist/api/geometry/apply.d.ts +0 -51
  439. package/dist/api/geometry/boolean.d.ts +0 -28
  440. package/dist/api/geometry/boolean.js +0 -65
  441. package/dist/api/geometry/types.d.ts +0 -31
  442. package/dist/api/geometry-operations.d.ts +0 -162
  443. package/dist/api/geometry-operations.js +0 -94
  444. package/dist/api/group-api.d.ts +0 -10
  445. package/dist/api/group-api.js +0 -78
  446. package/dist/api/import-export/constants.d.ts +0 -29
  447. package/dist/api/import-export/constants.js +0 -40
  448. package/dist/api/import-export/file-name.d.ts +0 -10
  449. package/dist/api/import-export/file-name.js +0 -20
  450. package/dist/api/import-export/geojson-export.d.ts +0 -19
  451. package/dist/api/import-export/image-import.d.ts +0 -12
  452. package/dist/api/import-export/image-import.js +0 -53
  453. package/dist/api/import-export/index.d.ts +0 -9
  454. package/dist/api/import-export/index.js +0 -107
  455. package/dist/api/import-export/native-format.d.ts +0 -15
  456. package/dist/api/import-export/style-validation.d.ts +0 -27
  457. package/dist/api/import-export/style-validation.js +0 -49
  458. package/dist/api/import-export/types.d.ts +0 -26
  459. package/dist/api/index.d.ts +0 -15
  460. package/dist/api/index.js +0 -3
  461. package/dist/api/input-api.d.ts +0 -158
  462. package/dist/api/input-api.js +0 -144
  463. package/dist/api/instance-api.d.ts +0 -38
  464. package/dist/api/instance-api.js +0 -136
  465. package/dist/api/layer-api.d.ts +0 -12
  466. package/dist/api/layer-api.js +0 -62
  467. package/dist/api/selection-api.d.ts +0 -7
  468. package/dist/api/selection-api.js +0 -78
  469. package/dist/api/snapping-api.d.ts +0 -125
  470. package/dist/api/snapping-api.js +0 -50
  471. package/dist/api/topology-api.d.ts +0 -30
  472. package/dist/api/topology-api.js +0 -16
  473. package/dist/api/tracing-api.d.ts +0 -31
  474. package/dist/api/tracing-api.js +0 -16
  475. package/dist/dispatcher/hit-test/index.d.ts +0 -14
  476. package/dist/dispatcher/hit-test/index.js +0 -9
  477. package/dist/dispatcher/index.d.ts +0 -15
  478. package/dist/dispatcher/index.js +0 -3
  479. package/dist/display/columnar/index.d.ts +0 -12
  480. package/dist/display/columnar/index.js +0 -13
  481. package/dist/display/columnar/prepare.d.ts +0 -42
  482. package/dist/display/columnar/prepare.js +0 -116
  483. package/dist/display/index.d.ts +0 -13
  484. package/dist/display/types.js +0 -43
  485. package/dist/maplibre-gl-draw.d.ts +0 -47
  486. package/dist/modes/cursor.js +0 -72
  487. package/dist/modes/index.d.ts +0 -7
  488. package/dist/operations/index.d.ts +0 -9
  489. package/dist/operations/index.js +0 -3
  490. package/dist/plugins/index.d.ts +0 -10
  491. package/dist/plugins/mutation-hooks.d.ts +0 -28
  492. package/dist/plugins/mutation-hooks.js +0 -84
  493. package/dist/plugins/plugin-context.js +0 -367
  494. package/dist/plugins/plugin-manager.d.ts +0 -103
  495. package/dist/plugins/plugin-manager.js +0 -316
  496. package/dist/plugins/plugin.d.ts +0 -529
  497. package/dist/shared/config/index.d.ts +0 -17
  498. package/dist/shared/config/index.js +0 -8
  499. package/dist/shared/utils/index.d.ts +0 -15
  500. package/dist/shared/utils/index.js +0 -24
  501. package/dist/snapping/index.d.ts +0 -14
  502. package/dist/snapping/index.js +0 -4
  503. package/dist/store/change-merger.js +0 -102
  504. package/dist/store/event-bridge.js +0 -161
  505. package/dist/store/index.d.ts +0 -12
  506. package/dist/store/index.js +0 -4
  507. package/dist/view/index.d.ts +0 -47
  508. package/dist/view/index.js +0 -20
  509. /package/dist/api/{geometry/types.js → datasets.js} +0 -0
  510. /package/dist/api/{import-export/types.js → document.js} +0 -0
  511. /package/dist/{display/columnar/types.js → api/drawing.js} +0 -0
  512. /package/dist/{display/index.js → api/events.js} +0 -0
  513. /package/dist/{modes/index.js → api/extension/context.js} +0 -0
  514. /package/dist/{plugins/index.js → api/extension/feature-type.js} +0 -0
  515. /package/dist/{plugins/plugin.js → api/extension/mode.js} +0 -0
  516. /package/dist/api/{display-api.d.ts → impl/adapters.d.ts} +0 -0
  517. /package/dist/{display/columnar/source.d.ts → api/impl/contexts.d.ts} +0 -0
  518. /package/dist/{display/columnar/table.d.ts → api/impl/create-draw.d.ts} +0 -0
  519. /package/dist/{display/interaction.d.ts → api/impl/datasets.d.ts} +0 -0
  520. /package/dist/{display/manager.d.ts → api/impl/destroy-guard.d.ts} +0 -0
  521. /package/dist/{display/packed-rtree.d.ts → api/impl/document.d.ts} +0 -0
  522. /package/dist/{display/partition.d.ts → api/impl/drawing.d.ts} +0 -0
  523. /package/dist/{display/provider.d.ts → api/impl/engine.d.ts} +0 -0
  524. /package/dist/{display/source.d.ts → api/impl/events.d.ts} +0 -0
  525. /package/dist/{display/spatial.d.ts → api/impl/extension-host.d.ts} +0 -0
  526. /package/dist/{display/style.d.ts → api/impl/extensions.d.ts} +0 -0
  527. /package/dist/{display/triangulation.d.ts → api/impl/features.d.ts} +0 -0
  528. /package/dist/{modes/cursor.d.ts → api/impl/geometry/types.d.ts} +0 -0
  529. /package/dist/{plugins/plugin-context.d.ts → api/impl/hidden.d.ts} +0 -0
  530. /package/dist/api/{import-export → impl/import-export}/embedded-file.d.ts +0 -0
  531. /package/dist/api/{import-export → impl/import-export}/own-property.d.ts +0 -0
  532. /package/dist/api/{import-export → impl/import-export}/own-property.js +0 -0
  533. /package/dist/{store/change-merger.d.ts → api/impl/input.d.ts} +0 -0
  534. /package/dist/{store/event-bridge.d.ts → api/impl/layers.d.ts} +0 -0
  535. /package/dist/{display → dataset}/chunk-set.d.ts +0 -0
  536. /package/dist/{display → dataset}/chunk-set.js +0 -0
  537. /package/dist/{display → dataset}/dataset.d.ts +0 -0
  538. /package/dist/{display → dataset}/manager.js +0 -0
  539. /package/dist/{display → dataset}/provider.js +0 -0
  540. /package/dist/{display → dataset}/selection.d.ts +0 -0
  541. /package/dist/{display → dataset}/selection.js +0 -0
@@ -0,0 +1,306 @@
1
+ /**
2
+ * `draw.extensions`: the collections of plugins, modes, feature types, overlays and providers
3
+ *
4
+ * Every kind of extension is added the same way: `add` registers it and returns the function
5
+ * that removes it, and `remove(name)` removes it by name.
6
+ */
7
+ import type { FeatureTypeDefinition } from './extension/feature-type.js';
8
+ import type { ModeFactory } from './extension/mode.js';
9
+ import type { Plugin } from './extension/plugin.js';
10
+ import type { CompanionProvider, HandleProvider, SnapProvider } from './extension/provider.js';
11
+ import type { OverlayRenderer } from './extension/render.js';
12
+ /** The plugins, in the order they were added. */
13
+ export interface PluginsCollection {
14
+ /**
15
+ * Gets a plugin by name.
16
+ *
17
+ * @returns The plugin, or `undefined` when there is none with this name
18
+ */
19
+ get(name: string): Plugin | undefined;
20
+ /** Lists the plugins in the order they were added. */
21
+ list(): Plugin[];
22
+ /** Counts the plugins. */
23
+ count(): number;
24
+ /** Whether a plugin with this name was added. */
25
+ has(name: string): boolean;
26
+ /**
27
+ * Adds a plugin.
28
+ *
29
+ * @returns The function that removes it again
30
+ * @throws `DrawError` with the code `already-exists` when a plugin with the same name was
31
+ * added
32
+ * or with `invalid-input` when the value does not have the shape of the contract
33
+ */
34
+ add(plugin: Plugin): () => void;
35
+ /**
36
+ * Adds several plugins in one transaction: all of them or none.
37
+ *
38
+ * @returns The function that removes them again
39
+ * @throws `DrawError` with the code `already-exists` when one of the names is taken, or
40
+ * `invalid-input` when a value does not have the shape of the contract; nothing is added
41
+ * then
42
+ */
43
+ addMany(plugins: readonly Plugin[]): () => void;
44
+ /**
45
+ * Removes a plugin, with everything it added.
46
+ *
47
+ * @returns True when it was removed
48
+ * @throws `DrawError` with the code `not-found` when there is no plugin with this name
49
+ */
50
+ remove(name: string): boolean;
51
+ /**
52
+ * Removes several plugins, with everything they added: all of them or none.
53
+ *
54
+ * @returns True when they were removed
55
+ * @throws `DrawError` with the code `not-found` when one of the names does not exist;
56
+ * nothing is removed then
57
+ */
58
+ removeMany(names: readonly string[]): boolean;
59
+ /**
60
+ * The API a plugin offers to others.
61
+ *
62
+ * @returns The API, or `undefined` when there is no plugin with this name or it offers none
63
+ */
64
+ getApi<T>(name: string): T | undefined;
65
+ }
66
+ /** The modes that were added, by name. */
67
+ export interface ModesCollection {
68
+ /**
69
+ * Gets the factory of a mode by name.
70
+ *
71
+ * @returns The factory, or `undefined` when there is no mode with this name
72
+ */
73
+ get(name: string): ModeFactory | undefined;
74
+ /** Lists the names of the modes. */
75
+ list(): string[];
76
+ /** Counts the modes. */
77
+ count(): number;
78
+ /** Whether a mode with this name was added. */
79
+ has(name: string): boolean;
80
+ /**
81
+ * Adds a mode under a name.
82
+ *
83
+ * @returns The function that removes it again
84
+ * @throws `DrawError` with the code `already-exists` when the name is taken
85
+ * or with `invalid-input` when the value does not have the shape of the contract
86
+ */
87
+ add(name: string, factory: ModeFactory): () => void;
88
+ /**
89
+ * Adds several modes in one transaction: all of them or none.
90
+ *
91
+ * @returns The function that removes them again
92
+ * @throws `DrawError` with the code `already-exists` when one of the names is taken, or
93
+ * `invalid-input` when a value does not have the shape of the contract; nothing is added
94
+ * then
95
+ */
96
+ addMany(entries: readonly {
97
+ name: string;
98
+ factory: ModeFactory;
99
+ }[]): () => void;
100
+ /**
101
+ * Removes a mode.
102
+ *
103
+ * @returns True when it was removed
104
+ * @throws `DrawError` with the code `not-found` when there is no mode with this name
105
+ */
106
+ remove(name: string): boolean;
107
+ /**
108
+ * Removes several modes: all of them or none.
109
+ *
110
+ * @returns True when they were removed
111
+ * @throws `DrawError` with the code `not-found` when one of the names does not exist;
112
+ * nothing is removed then
113
+ */
114
+ removeMany(names: readonly string[]): boolean;
115
+ }
116
+ /**
117
+ * The custom feature types, by type name, and the definitions that override a built-in type.
118
+ */
119
+ export interface FeatureTypesCollection {
120
+ /**
121
+ * Gets the definition of a feature type by name: a type that was added, or the definition
122
+ * that overrides a built-in type.
123
+ *
124
+ * @returns The definition, or `undefined` when there is none with this name
125
+ */
126
+ get(name: string): FeatureTypeDefinition | undefined;
127
+ /** Lists the names of the feature types that were added or overridden. */
128
+ list(): string[];
129
+ /** Counts the feature types that were added or overridden. */
130
+ count(): number;
131
+ /** Whether a feature type with this name was added or overridden. */
132
+ has(name: string): boolean;
133
+ /**
134
+ * Adds a custom feature type. The type takes every feature of its type: its `appliesTo`, if
135
+ * it has one, is ignored.
136
+ *
137
+ * @returns The function that removes it again
138
+ * @throws `DrawError` with the code `already-exists` when the type name is taken
139
+ * or with `invalid-input` when the value does not have the shape of the contract
140
+ */
141
+ add(definition: FeatureTypeDefinition): () => void;
142
+ /**
143
+ * Adds several custom feature types in one transaction: all of them or none.
144
+ *
145
+ * @returns The function that removes them again
146
+ * @throws `DrawError` with the code `already-exists` when one of the names is taken, or
147
+ * `invalid-input` when a value does not have the shape of the contract; nothing is added
148
+ * then
149
+ */
150
+ addMany(definitions: readonly FeatureTypeDefinition[]): () => void;
151
+ /**
152
+ * Overrides a built-in feature type (`Point`, `LineString`, `Polygon`, `Circle`,
153
+ * `Freehand` or `Image`) with a definition of the same `type` and the same kind of
154
+ * `geometry` as the built-in one (`Point` for a circle and an image, `LineString` for a
155
+ * freehand line). The features of the type are drawn by its renderer from then on. Its
156
+ * `hitTest`, `boxSelect`, `bounds`, `outline`, `bbox` and `snapCandidates` replace those of
157
+ * the built-in type when it has them, and the built-in ones stay for the members it leaves
158
+ * out. Its `handles` are shown with those of the built-in type. With `appliesTo`, it takes
159
+ * only the features for which that returns true, and the others keep the built-in type
160
+ * entirely.
161
+ *
162
+ * The built-in type comes back with the function it returns, with `remove(type)`, and, for
163
+ * a plugin that overrode it through its context, when the plugin is removed. `add` keeps
164
+ * refusing the names of the built-in types.
165
+ *
166
+ * @returns The function that puts the built-in type back
167
+ * @throws `DrawError` with the code `invalid-input` when the type is not one of the
168
+ * built-in types above, its `geometry` is not the one of the built-in type, or the value
169
+ * does not have the shape of the contract, and `already-exists` when the type is already
170
+ * overridden
171
+ */
172
+ override(definition: FeatureTypeDefinition): () => void;
173
+ /**
174
+ * Removes a custom feature type, or the definition that overrides a built-in type (the
175
+ * built-in type comes back).
176
+ *
177
+ * @returns True when it was removed
178
+ * @throws `DrawError` with the code `not-found` when there is no type with this name
179
+ */
180
+ remove(name: string): boolean;
181
+ /**
182
+ * Removes several custom feature types: all of them or none.
183
+ *
184
+ * @returns True when they were removed
185
+ * @throws `DrawError` with the code `not-found` when one of the names does not exist;
186
+ * nothing is removed then
187
+ */
188
+ removeMany(names: readonly string[]): boolean;
189
+ }
190
+ /** The renderers that draw above the features or between the layers, by name. */
191
+ export interface OverlaysCollection {
192
+ /**
193
+ * Gets an overlay renderer by name.
194
+ *
195
+ * @returns The renderer, or `undefined` when there is none with this name
196
+ */
197
+ get(name: string): OverlayRenderer | undefined;
198
+ /** Lists the names of the overlay renderers. */
199
+ list(): string[];
200
+ /** Counts the overlay renderers. */
201
+ count(): number;
202
+ /** Whether an overlay renderer with this name was added. */
203
+ has(name: string): boolean;
204
+ /**
205
+ * Adds an overlay renderer.
206
+ *
207
+ * @returns The function that removes it again
208
+ * @throws `DrawError` with the code `already-exists` when the name is taken
209
+ * or with `invalid-input` when the value does not have the shape of the contract
210
+ */
211
+ add(renderer: OverlayRenderer): () => void;
212
+ /**
213
+ * Adds several overlay renderers in one transaction: all of them or none.
214
+ *
215
+ * @returns The function that removes them again
216
+ * @throws `DrawError` with the code `already-exists` when one of the names is taken, or
217
+ * `invalid-input` when a value does not have the shape of the contract; nothing is added
218
+ * then
219
+ */
220
+ addMany(renderers: readonly OverlayRenderer[]): () => void;
221
+ /**
222
+ * Removes an overlay renderer.
223
+ *
224
+ * @returns True when it was removed
225
+ * @throws `DrawError` with the code `not-found` when there is none with this name
226
+ */
227
+ remove(name: string): boolean;
228
+ /**
229
+ * Removes several overlay renderers: all of them or none.
230
+ *
231
+ * @returns True when they were removed
232
+ * @throws `DrawError` with the code `not-found` when one of the names does not exist;
233
+ * nothing is removed then
234
+ */
235
+ removeMany(names: readonly string[]): boolean;
236
+ }
237
+ /**
238
+ * The providers of one kind, by name: snapping candidates, handles or companions.
239
+ *
240
+ * @typeParam T - The kind of provider
241
+ */
242
+ export interface ProvidersCollection<T> {
243
+ /**
244
+ * Gets a provider by name.
245
+ *
246
+ * @returns The provider, or `undefined` when there is none with this name
247
+ */
248
+ get(name: string): T | undefined;
249
+ /** Lists the names of the providers. */
250
+ list(): string[];
251
+ /** Counts the providers. */
252
+ count(): number;
253
+ /** Whether a provider with this name was added. */
254
+ has(name: string): boolean;
255
+ /**
256
+ * Adds a provider.
257
+ *
258
+ * @returns The function that removes it again
259
+ * @throws `DrawError` with the code `already-exists` when the name is taken
260
+ * or with `invalid-input` when the value does not have the shape of the contract
261
+ */
262
+ add(provider: T): () => void;
263
+ /**
264
+ * Adds several providers in one transaction: all of them or none.
265
+ *
266
+ * @returns The function that removes them again
267
+ * @throws `DrawError` with the code `already-exists` when one of the names is taken, or
268
+ * `invalid-input` when a value does not have the shape of the contract; nothing is added
269
+ * then
270
+ */
271
+ addMany(providers: readonly T[]): () => void;
272
+ /**
273
+ * Removes a provider.
274
+ *
275
+ * @returns True when it was removed
276
+ * @throws `DrawError` with the code `not-found` when there is no provider with this name
277
+ */
278
+ remove(name: string): boolean;
279
+ /**
280
+ * Removes several providers: all of them or none.
281
+ *
282
+ * @returns True when they were removed
283
+ * @throws `DrawError` with the code `not-found` when one of the names does not exist;
284
+ * nothing is removed then
285
+ */
286
+ removeMany(names: readonly string[]): boolean;
287
+ }
288
+ /**
289
+ * Every collection of extensions of a draw instance.
290
+ */
291
+ export interface ExtensionsCollections {
292
+ /** The plugins: bundles of other extensions and state */
293
+ readonly plugins: PluginsCollection;
294
+ /** The modes: ways of receiving input */
295
+ readonly modes: ModesCollection;
296
+ /** The custom feature types */
297
+ readonly featureTypes: FeatureTypesCollection;
298
+ /** The renderers that draw above the features or between the layers */
299
+ readonly overlays: OverlaysCollection;
300
+ /** The providers of snapping candidates */
301
+ readonly snapProviders: ProvidersCollection<SnapProvider>;
302
+ /** The providers of handles on the selected features */
303
+ readonly handleProviders: ProvidersCollection<HandleProvider>;
304
+ /** The providers of companions drawn one step below a feature */
305
+ readonly companionProviders: ProvidersCollection<CompanionProvider>;
306
+ }
@@ -0,0 +1,3 @@
1
+ // SPDX-FileCopyrightText: 2026 SAKAIDA Atsushi
2
+ // SPDX-License-Identifier: AGPL-3.0-only
3
+ export {};
@@ -0,0 +1,188 @@
1
+ /**
2
+ * `draw.features`: the features of the document
3
+ */
4
+ import type { Feature, FeatureFilter, FeatureInput, FeaturePatch, FeatureStyleResolved, MoveTarget } from './model.js';
5
+ /**
6
+ * The features of the document, with the standard methods of a collection and the verbs
7
+ * that move, combine and split them.
8
+ *
9
+ * A wrong argument (an ID that does not exist, an input of the wrong shape) throws a
10
+ * `DrawError` and changes nothing. A refusal because of the state (read-only, a lock) returns
11
+ * `null` or `false` and changes nothing. A method whose name ends in `Many` runs in one
12
+ * transaction: all of it happens or none of it does.
13
+ */
14
+ export interface FeaturesCollection {
15
+ /**
16
+ * Gets a feature by ID.
17
+ *
18
+ * @returns The feature, or `undefined` when there is none with this ID
19
+ */
20
+ get(id: string): Feature | undefined;
21
+ /**
22
+ * Gets features by ID, in the order of the IDs.
23
+ *
24
+ * @returns One entry per ID: the feature, or `undefined` when there is none with that ID
25
+ */
26
+ getMany(ids: readonly string[]): (Feature | undefined)[];
27
+ /**
28
+ * Lists the features in stacking order, from the back.
29
+ *
30
+ * @param filter - Keeps only the features that match every key given
31
+ */
32
+ list(filter?: FeatureFilter): Feature[];
33
+ /**
34
+ * Counts the features.
35
+ *
36
+ * @param filter - Counts only the features that match every key given
37
+ */
38
+ count(filter?: FeatureFilter): number;
39
+ /** Whether a feature with this ID exists. */
40
+ has(id: string): boolean;
41
+ /**
42
+ * Whether the feature can be edited now: the document is not read-only, and neither the
43
+ * feature nor its group nor its layer is locked. A refused edit returns `null` or `false`
44
+ * for the same reasons.
45
+ *
46
+ * @throws `DrawError` with the code `not-found` when there is no feature with this ID
47
+ */
48
+ isEditable(id: string): boolean;
49
+ /**
50
+ * Creates a feature and returns it as it was stored.
51
+ *
52
+ * @returns The new feature, or `null` when the document is read-only
53
+ * @throws `DrawError` with the code `invalid-input` when the input has the wrong shape,
54
+ * `already-exists` when its ID is taken, `not-found` when its layer or group does not
55
+ * exist, or `invalid-state` when the input names no layer and the document has no layer
56
+ * to put it in
57
+ */
58
+ create(input: FeatureInput): Feature | null;
59
+ /**
60
+ * Creates several features in one transaction: all of them or none.
61
+ *
62
+ * @returns The new features in the order of the inputs, or `null` when the document is
63
+ * read-only
64
+ * @throws `DrawError` as {@link FeaturesCollection.create} does, for any of the inputs;
65
+ * nothing is created then
66
+ */
67
+ createMany(inputs: readonly FeatureInput[]): Feature[] | null;
68
+ /**
69
+ * Changes the keys given in the patch and returns the feature after the change.
70
+ *
71
+ * `properties` and `style` are merged key by key, and a key given as `undefined` is
72
+ * removed.
73
+ *
74
+ * @returns The changed feature, or `null` when the change is refused (read-only, a lock)
75
+ * @throws `DrawError` with the code `not-found` when there is no feature with this ID, or
76
+ * `invalid-input` when the patch has the wrong shape
77
+ */
78
+ update(id: string, patch: FeaturePatch): Feature | null;
79
+ /**
80
+ * Changes several features in one transaction: all of them or none.
81
+ *
82
+ * @returns The changed features in the order of the patches, or `null` when the change is
83
+ * refused
84
+ * @throws `DrawError` as {@link FeaturesCollection.update} does, for any of the patches;
85
+ * nothing changes then
86
+ */
87
+ updateMany(patches: readonly {
88
+ id: string;
89
+ patch: FeaturePatch;
90
+ }[]): Feature[] | null;
91
+ /**
92
+ * Deletes a feature.
93
+ *
94
+ * @returns True when it was deleted, false when the deletion is refused (read-only, a lock)
95
+ * @throws `DrawError` with the code `not-found` when there is no feature with this ID
96
+ */
97
+ delete(id: string): boolean;
98
+ /**
99
+ * Deletes several features in one transaction: all of them or none.
100
+ *
101
+ * @returns True when they were deleted, false when the deletion is refused
102
+ * @throws `DrawError` with the code `not-found` when one of the IDs does not exist; nothing
103
+ * is deleted then
104
+ */
105
+ deleteMany(ids: readonly string[]): boolean;
106
+ /**
107
+ * Moves a feature to another layer, into a group or out of its group; `index` of the
108
+ * target sets its position there.
109
+ *
110
+ * @returns True when it moved, false when the move is refused (read-only, a lock)
111
+ * @throws `DrawError` with the code `not-found` when the feature or the target does not
112
+ * exist
113
+ */
114
+ move(id: string, to: MoveTarget): boolean;
115
+ /**
116
+ * Moves several features in one transaction, keeping their order: all of them or none.
117
+ *
118
+ * @returns True when they moved, false when the move is refused
119
+ * @throws `DrawError` with the code `not-found` when one of the features or the target does
120
+ * not exist; nothing moves then
121
+ */
122
+ moveMany(ids: readonly string[], to: MoveTarget): boolean;
123
+ /**
124
+ * The look a feature is drawn with: the default, the layer rule and the style of the
125
+ * feature put on top of each other.
126
+ *
127
+ * The colors of the `style` option and of the style of the feature are the strings they
128
+ * were given, alpha included; the color of a layer rule is `#rrggbb`, as
129
+ * {@link evaluateStyleRule} gives it, and a default is `#rrggbb`.
130
+ *
131
+ * @returns The look, or `undefined` when there is no feature with this ID
132
+ */
133
+ getAppliedStyle(id: string): FeatureStyleResolved | undefined;
134
+ /**
135
+ * Joins areas into one feature and returns it; the result replaces the features given.
136
+ *
137
+ * @returns The new feature, or `null` when the operation is refused (read-only, a lock)
138
+ * @throws `DrawError` with the code `not-found` when one of the IDs does not exist, or
139
+ * `invalid-input` when fewer than two areas are given or one of the features is not an
140
+ * area
141
+ */
142
+ union(ids: readonly string[]): Feature | null;
143
+ /**
144
+ * Subtracts other areas from an area and returns the result; the result replaces the area
145
+ * subtracted from, and the areas subtracted stay.
146
+ *
147
+ * @param id - The area to subtract from
148
+ * @param subtractIds - The areas to subtract
149
+ * @returns The resulting feature, or `null` when the operation is refused (read-only, a lock)
150
+ * @throws `DrawError` with the code `not-found` when one of the IDs does not exist, or
151
+ * `invalid-input` when one of the features is not an area
152
+ */
153
+ difference(id: string, subtractIds: readonly string[]): Feature | null;
154
+ /**
155
+ * Keeps the part where areas overlap and returns it; the result replaces the features given.
156
+ *
157
+ * @returns The resulting feature, or `null` when the operation is refused (read-only, a lock)
158
+ * @throws `DrawError` with the code `not-found` when one of the IDs does not exist, or
159
+ * `invalid-input` when fewer than two areas are given or one of the features is not an
160
+ * area
161
+ */
162
+ intersection(ids: readonly string[]): Feature | null;
163
+ /**
164
+ * Splits an area along a line and returns the features it made.
165
+ *
166
+ * @param id - The area to split
167
+ * @param lineId - The line to split along
168
+ * @returns The new features, or `null` when the operation is refused (read-only, a lock)
169
+ * @throws `DrawError` with the code `not-found` when one of the IDs does not exist, or
170
+ * `invalid-input` when the features are not an area and a line
171
+ */
172
+ split(id: string, lineId: string): Feature[] | null;
173
+ /**
174
+ * Creates the areas around features.
175
+ *
176
+ * @param ids - The features to surround
177
+ * @param options - `distanceMeters` is the distance of the outline from the features, and
178
+ * `segments` the number of segments of a full circle, as in the buffer of the geometry
179
+ * entry
180
+ * @returns The new features, or `null` when the operation is refused (read-only, a lock)
181
+ * @throws `DrawError` with the code `not-found` when one of the IDs does not exist, or
182
+ * `invalid-input` when the distance is not a finite number
183
+ */
184
+ buffer(ids: readonly string[], options: {
185
+ distanceMeters: number;
186
+ segments?: number;
187
+ }): Feature[] | null;
188
+ }
@@ -0,0 +1,3 @@
1
+ // SPDX-FileCopyrightText: 2026 SAKAIDA Atsushi
2
+ // SPDX-License-Identifier: AGPL-3.0-only
3
+ export {};
@@ -0,0 +1,111 @@
1
+ /**
2
+ * `draw.groups`: the groups of the document
3
+ */
4
+ import type { Group, GroupFilter, GroupInput, GroupPatch, MoveTarget } from './model.js';
5
+ /**
6
+ * The groups of the document, with the standard methods of a collection and the verbs that
7
+ * move them.
8
+ *
9
+ * A wrong argument (an ID that does not exist, an input of the wrong shape) throws a
10
+ * `DrawError` and changes nothing. A refusal because of the state (read-only, a lock) returns
11
+ * `null` or `false` and changes nothing. A method whose name ends in `Many` runs in one
12
+ * transaction: all of it happens or none of it does.
13
+ */
14
+ export interface GroupsCollection {
15
+ /**
16
+ * Gets a group by ID.
17
+ *
18
+ * @returns The group, or `undefined` when there is none with this ID
19
+ */
20
+ get(id: string): Group | undefined;
21
+ /**
22
+ * Gets groups by ID, in the order of the IDs.
23
+ *
24
+ * @returns One entry per ID: the group, or `undefined` when there is none with that ID
25
+ */
26
+ getMany(ids: readonly string[]): (Group | undefined)[];
27
+ /**
28
+ * Lists the groups in stacking order, from the back.
29
+ *
30
+ * @param filter - Keeps only the groups that match every key given
31
+ */
32
+ list(filter?: GroupFilter): Group[];
33
+ /**
34
+ * Counts the groups.
35
+ *
36
+ * @param filter - Counts only the groups that match every key given
37
+ */
38
+ count(filter?: GroupFilter): number;
39
+ /** Whether a group with this ID exists. */
40
+ has(id: string): boolean;
41
+ /**
42
+ * Creates a group of features and returns it as it was stored.
43
+ *
44
+ * @returns The new group, or `null` when the document is read-only
45
+ * @throws `DrawError` with the code `not-found` when one of the features does not exist,
46
+ * `invalid-input` when the features are not in the same layer, or `already-exists` when
47
+ * its ID is taken
48
+ */
49
+ create(input: GroupInput): Group | null;
50
+ /**
51
+ * Creates several groups in one transaction: all of them or none.
52
+ *
53
+ * @returns The new groups in the order of the inputs, or `null` when the document is
54
+ * read-only
55
+ * @throws `DrawError` as {@link GroupsCollection.create} does, for any of the inputs;
56
+ * nothing is created then
57
+ */
58
+ createMany(inputs: readonly GroupInput[]): Group[] | null;
59
+ /**
60
+ * Changes the keys given in the patch and returns the group after the change.
61
+ *
62
+ * @returns The changed group, or `null` when the change is refused (read-only, a lock)
63
+ * @throws `DrawError` with the code `not-found` when there is no group with this ID, or
64
+ * `invalid-input` when the patch has the wrong shape
65
+ */
66
+ update(id: string, patch: GroupPatch): Group | null;
67
+ /**
68
+ * Changes several groups in one transaction: all of them or none.
69
+ *
70
+ * @returns The changed groups in the order of the patches, or `null` when the change is
71
+ * refused
72
+ * @throws `DrawError` as {@link GroupsCollection.update} does, for any of the patches;
73
+ * nothing changes then
74
+ */
75
+ updateMany(patches: readonly {
76
+ id: string;
77
+ patch: GroupPatch;
78
+ }[]): Group[] | null;
79
+ /**
80
+ * Deletes a group; its features stay in the layer.
81
+ *
82
+ * @returns True when it was deleted, false when the deletion is refused (read-only, a lock)
83
+ * @throws `DrawError` with the code `not-found` when there is no group with this ID
84
+ */
85
+ delete(id: string): boolean;
86
+ /**
87
+ * Deletes several groups in one transaction: all of them or none. Their features stay in
88
+ * their layers.
89
+ *
90
+ * @returns True when they were deleted, false when the deletion is refused
91
+ * @throws `DrawError` with the code `not-found` when one of the IDs does not exist; nothing
92
+ * is deleted then
93
+ */
94
+ deleteMany(ids: readonly string[]): boolean;
95
+ /**
96
+ * Moves a group to another layer, or to another position in its layer.
97
+ *
98
+ * @returns True when it moved, false when the move is refused (read-only, a lock)
99
+ * @throws `DrawError` with the code `not-found` when the group or the target does not
100
+ * exist, or `invalid-input` when the target is a group
101
+ */
102
+ move(id: string, to: MoveTarget): boolean;
103
+ /**
104
+ * Moves several groups in one transaction: all of them or none.
105
+ *
106
+ * @returns True when they moved, false when the move is refused
107
+ * @throws `DrawError` as {@link GroupsCollection.move} does, for any of the groups; nothing
108
+ * moves then
109
+ */
110
+ moveMany(ids: readonly string[], to: MoveTarget): boolean;
111
+ }
@@ -0,0 +1,3 @@
1
+ // SPDX-FileCopyrightText: 2026 SAKAIDA Atsushi
2
+ // SPDX-License-Identifier: AGPL-3.0-only
3
+ export {};
@@ -0,0 +1,45 @@
1
+ /**
2
+ * `draw.hidden`: what this client hides without changing the document
3
+ */
4
+ /**
5
+ * The IDs of the features, groups and layers this client hides. Hiding changes only what this
6
+ * client draws; the document and its `visible` flags stay as they are.
7
+ */
8
+ export interface HiddenCollection {
9
+ /** Whether this client hides the item with this ID. */
10
+ get(id: string): boolean;
11
+ /** Lists the IDs this client hides. */
12
+ list(): readonly string[];
13
+ /** Counts the IDs this client hides. */
14
+ count(): number;
15
+ /** Whether this client hides the item with this ID; the same as {@link HiddenCollection.get}. */
16
+ has(id: string): boolean;
17
+ /**
18
+ * Hides a feature, a group or a layer in this client only; the document does not change.
19
+ *
20
+ * @throws `DrawError` with the code `not-found` when the ID is not a feature, a group or a
21
+ * layer of the document
22
+ */
23
+ add(id: string): void;
24
+ /**
25
+ * Hides several items in this client only, all of them or none.
26
+ *
27
+ * @throws `DrawError` with the code `not-found` when one of the IDs is not in the document;
28
+ * nothing is hidden then
29
+ */
30
+ addMany(ids: readonly string[]): void;
31
+ /**
32
+ * Shows an item this client hid.
33
+ *
34
+ * @returns False when this client did not hide it
35
+ */
36
+ remove(id: string): boolean;
37
+ /**
38
+ * Shows several items this client hid, all at once.
39
+ *
40
+ * @returns False when this client hid none of them
41
+ */
42
+ removeMany(ids: readonly string[]): boolean;
43
+ /** Shows every item this client hid. */
44
+ clear(): void;
45
+ }
@@ -0,0 +1,3 @@
1
+ // SPDX-FileCopyrightText: 2026 SAKAIDA Atsushi
2
+ // SPDX-License-Identifier: AGPL-3.0-only
3
+ export {};