@planet/maps 11.0.0 → 11.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 (275) hide show
  1. package/Map.d.ts +48 -0
  2. package/Map.d.ts.map +1 -0
  3. package/Map.js +16 -16
  4. package/Overlay.d.ts +26 -0
  5. package/Overlay.d.ts.map +1 -0
  6. package/Overlay.js +8 -0
  7. package/View.d.ts +26 -0
  8. package/View.d.ts.map +1 -0
  9. package/View.js +8 -0
  10. package/control/Attribution.d.ts +24 -0
  11. package/control/Attribution.d.ts.map +1 -0
  12. package/control/Attribution.js +8 -0
  13. package/control/Control.d.ts +24 -0
  14. package/control/Control.d.ts.map +1 -0
  15. package/control/Control.js +8 -0
  16. package/control/FullScreen.d.ts +24 -0
  17. package/control/FullScreen.d.ts.map +1 -0
  18. package/control/FullScreen.js +8 -0
  19. package/control/MousePosition.d.ts +24 -0
  20. package/control/MousePosition.d.ts.map +1 -0
  21. package/control/MousePosition.js +8 -0
  22. package/control/OverviewMap.d.ts +24 -0
  23. package/control/OverviewMap.d.ts.map +1 -0
  24. package/control/OverviewMap.js +8 -0
  25. package/control/Rotate.d.ts +24 -0
  26. package/control/Rotate.d.ts.map +1 -0
  27. package/control/Rotate.js +8 -0
  28. package/control/ScaleLine.d.ts +24 -0
  29. package/control/ScaleLine.d.ts.map +1 -0
  30. package/control/ScaleLine.js +8 -0
  31. package/control/Zoom.d.ts +24 -0
  32. package/control/Zoom.d.ts.map +1 -0
  33. package/control/Zoom.js +8 -0
  34. package/control/ZoomSlider.d.ts +24 -0
  35. package/control/ZoomSlider.d.ts.map +1 -0
  36. package/control/ZoomSlider.js +8 -0
  37. package/control/ZoomToExtent.d.ts +24 -0
  38. package/control/ZoomToExtent.d.ts.map +1 -0
  39. package/control/ZoomToExtent.js +8 -0
  40. package/interaction/DblClickDragZoom.d.ts +24 -0
  41. package/interaction/DblClickDragZoom.d.ts.map +1 -0
  42. package/interaction/DblClickDragZoom.js +8 -0
  43. package/interaction/DoubleClickZoom.d.ts +24 -0
  44. package/interaction/DoubleClickZoom.d.ts.map +1 -0
  45. package/interaction/DoubleClickZoom.js +8 -0
  46. package/interaction/DragAndDrop.d.ts +24 -0
  47. package/interaction/DragAndDrop.d.ts.map +1 -0
  48. package/interaction/DragAndDrop.js +8 -0
  49. package/interaction/DragBox.d.ts +24 -0
  50. package/interaction/DragBox.d.ts.map +1 -0
  51. package/interaction/DragBox.js +8 -0
  52. package/interaction/DragPan.d.ts +24 -0
  53. package/interaction/DragPan.d.ts.map +1 -0
  54. package/interaction/DragPan.js +8 -0
  55. package/interaction/DragRotate.d.ts +24 -0
  56. package/interaction/DragRotate.d.ts.map +1 -0
  57. package/interaction/DragRotate.js +8 -0
  58. package/interaction/DragRotateAndZoom.d.ts +24 -0
  59. package/interaction/DragRotateAndZoom.d.ts.map +1 -0
  60. package/interaction/DragRotateAndZoom.js +8 -0
  61. package/interaction/DragZoom.d.ts +24 -0
  62. package/interaction/DragZoom.d.ts.map +1 -0
  63. package/interaction/DragZoom.js +8 -0
  64. package/interaction/Draw.d.ts +24 -0
  65. package/interaction/Draw.d.ts.map +1 -0
  66. package/interaction/Draw.js +8 -0
  67. package/interaction/Extent.d.ts +24 -0
  68. package/interaction/Extent.d.ts.map +1 -0
  69. package/interaction/Extent.js +8 -0
  70. package/interaction/Interaction.d.ts +24 -0
  71. package/interaction/Interaction.d.ts.map +1 -0
  72. package/interaction/Interaction.js +8 -0
  73. package/interaction/KeyboardPan.d.ts +24 -0
  74. package/interaction/KeyboardPan.d.ts.map +1 -0
  75. package/interaction/KeyboardPan.js +8 -0
  76. package/interaction/KeyboardZoom.d.ts +24 -0
  77. package/interaction/KeyboardZoom.d.ts.map +1 -0
  78. package/interaction/KeyboardZoom.js +8 -0
  79. package/interaction/Link.d.ts +24 -0
  80. package/interaction/Link.d.ts.map +1 -0
  81. package/interaction/Link.js +8 -0
  82. package/interaction/Modify.d.ts +24 -0
  83. package/interaction/Modify.d.ts.map +1 -0
  84. package/interaction/Modify.js +8 -0
  85. package/interaction/MouseWheelZoom.d.ts +24 -0
  86. package/interaction/MouseWheelZoom.d.ts.map +1 -0
  87. package/interaction/MouseWheelZoom.js +8 -0
  88. package/interaction/PinchRotate.d.ts +24 -0
  89. package/interaction/PinchRotate.d.ts.map +1 -0
  90. package/interaction/PinchRotate.js +8 -0
  91. package/interaction/PinchZoom.d.ts +24 -0
  92. package/interaction/PinchZoom.d.ts.map +1 -0
  93. package/interaction/PinchZoom.js +8 -0
  94. package/interaction/Pointer.d.ts +24 -0
  95. package/interaction/Pointer.d.ts.map +1 -0
  96. package/interaction/Pointer.js +8 -0
  97. package/interaction/Select.d.ts +24 -0
  98. package/interaction/Select.d.ts.map +1 -0
  99. package/interaction/Select.js +8 -0
  100. package/interaction/Snap.d.ts +24 -0
  101. package/interaction/Snap.d.ts.map +1 -0
  102. package/interaction/Snap.js +8 -0
  103. package/interaction/Translate.d.ts +24 -0
  104. package/interaction/Translate.d.ts.map +1 -0
  105. package/interaction/Translate.js +8 -0
  106. package/internal/config.d.ts +18 -0
  107. package/internal/config.d.ts.map +1 -0
  108. package/internal/config.js +1 -0
  109. package/internal/render.d.ts +21 -0
  110. package/internal/render.d.ts.map +1 -0
  111. package/internal/render.js +129 -42
  112. package/internal/update.d.ts +40 -0
  113. package/internal/update.d.ts.map +1 -0
  114. package/internal/update.js +37 -4
  115. package/layer/Base.d.ts +29 -0
  116. package/layer/Base.d.ts.map +1 -0
  117. package/layer/Base.js +9 -5
  118. package/layer/BaseImage.d.ts +29 -0
  119. package/layer/BaseImage.d.ts.map +1 -0
  120. package/layer/BaseImage.js +9 -5
  121. package/layer/BaseTile.d.ts +29 -0
  122. package/layer/BaseTile.d.ts.map +1 -0
  123. package/layer/BaseTile.js +9 -5
  124. package/layer/BaseVector.d.ts +29 -0
  125. package/layer/BaseVector.d.ts.map +1 -0
  126. package/layer/BaseVector.js +9 -5
  127. package/layer/Flow.d.ts +29 -0
  128. package/layer/Flow.d.ts.map +1 -0
  129. package/layer/Flow.js +9 -5
  130. package/layer/Graticule.d.ts +29 -0
  131. package/layer/Graticule.d.ts.map +1 -0
  132. package/layer/Graticule.js +9 -5
  133. package/layer/Group.d.ts +29 -0
  134. package/layer/Group.d.ts.map +1 -0
  135. package/layer/Group.js +9 -5
  136. package/layer/Heatmap.d.ts +29 -0
  137. package/layer/Heatmap.d.ts.map +1 -0
  138. package/layer/Heatmap.js +9 -5
  139. package/layer/Image.d.ts +29 -0
  140. package/layer/Image.d.ts.map +1 -0
  141. package/layer/Image.js +9 -5
  142. package/layer/Layer.d.ts +29 -0
  143. package/layer/Layer.d.ts.map +1 -0
  144. package/layer/Layer.js +9 -5
  145. package/layer/MapboxVector.d.ts +20 -0
  146. package/layer/MapboxVector.d.ts.map +1 -0
  147. package/layer/MapboxVector.js +8 -5
  148. package/layer/Tile.d.ts +29 -0
  149. package/layer/Tile.d.ts.map +1 -0
  150. package/layer/Tile.js +9 -5
  151. package/layer/Vector.d.ts +29 -0
  152. package/layer/Vector.d.ts.map +1 -0
  153. package/layer/Vector.js +9 -5
  154. package/layer/VectorImage.d.ts +29 -0
  155. package/layer/VectorImage.d.ts.map +1 -0
  156. package/layer/VectorImage.js +9 -5
  157. package/layer/VectorTile.d.ts +29 -0
  158. package/layer/VectorTile.d.ts.map +1 -0
  159. package/layer/VectorTile.js +9 -5
  160. package/layer/WebGLPoints.d.ts +29 -0
  161. package/layer/WebGLPoints.d.ts.map +1 -0
  162. package/layer/WebGLPoints.js +9 -5
  163. package/layer/WebGLTile.d.ts +29 -0
  164. package/layer/WebGLTile.d.ts.map +1 -0
  165. package/layer/WebGLTile.js +9 -5
  166. package/layer/WebGLVector.d.ts +29 -0
  167. package/layer/WebGLVector.d.ts.map +1 -0
  168. package/layer/WebGLVector.js +9 -5
  169. package/layer/WebGLVectorTile.d.ts +29 -0
  170. package/layer/WebGLVectorTile.d.ts.map +1 -0
  171. package/layer/WebGLVectorTile.js +9 -5
  172. package/package.json +24 -15
  173. package/source/BingMaps.d.ts +24 -0
  174. package/source/BingMaps.d.ts.map +1 -0
  175. package/source/BingMaps.js +8 -0
  176. package/source/CartoDB.d.ts +24 -0
  177. package/source/CartoDB.d.ts.map +1 -0
  178. package/source/CartoDB.js +8 -0
  179. package/source/Cluster.d.ts +24 -0
  180. package/source/Cluster.d.ts.map +1 -0
  181. package/source/Cluster.js +8 -0
  182. package/source/DataTile.d.ts +24 -0
  183. package/source/DataTile.d.ts.map +1 -0
  184. package/source/DataTile.js +8 -0
  185. package/source/GeoTIFF.d.ts +24 -0
  186. package/source/GeoTIFF.d.ts.map +1 -0
  187. package/source/GeoTIFF.js +8 -0
  188. package/source/Google.d.ts +24 -0
  189. package/source/Google.d.ts.map +1 -0
  190. package/source/Google.js +8 -0
  191. package/source/IIIF.d.ts +24 -0
  192. package/source/IIIF.d.ts.map +1 -0
  193. package/source/IIIF.js +8 -0
  194. package/source/Image.d.ts +24 -0
  195. package/source/Image.d.ts.map +1 -0
  196. package/source/Image.js +8 -0
  197. package/source/ImageArcGISRest.d.ts +24 -0
  198. package/source/ImageArcGISRest.d.ts.map +1 -0
  199. package/source/ImageArcGISRest.js +8 -0
  200. package/source/ImageCanvas.d.ts +24 -0
  201. package/source/ImageCanvas.d.ts.map +1 -0
  202. package/source/ImageCanvas.js +8 -0
  203. package/source/ImageMapGuide.d.ts +24 -0
  204. package/source/ImageMapGuide.d.ts.map +1 -0
  205. package/source/ImageMapGuide.js +8 -0
  206. package/source/ImageStatic.d.ts +24 -0
  207. package/source/ImageStatic.d.ts.map +1 -0
  208. package/source/ImageStatic.js +8 -0
  209. package/source/ImageTile.d.ts +24 -0
  210. package/source/ImageTile.d.ts.map +1 -0
  211. package/source/ImageTile.js +8 -0
  212. package/source/ImageWMS.d.ts +24 -0
  213. package/source/ImageWMS.d.ts.map +1 -0
  214. package/source/ImageWMS.js +8 -0
  215. package/source/OGCMapTile.d.ts +24 -0
  216. package/source/OGCMapTile.d.ts.map +1 -0
  217. package/source/OGCMapTile.js +8 -0
  218. package/source/OGCVectorTile.d.ts +24 -0
  219. package/source/OGCVectorTile.d.ts.map +1 -0
  220. package/source/OGCVectorTile.js +8 -0
  221. package/source/OSM.d.ts +24 -0
  222. package/source/OSM.d.ts.map +1 -0
  223. package/source/OSM.js +8 -0
  224. package/source/Raster.d.ts +24 -0
  225. package/source/Raster.d.ts.map +1 -0
  226. package/source/Raster.js +8 -0
  227. package/source/SentinelHub.d.ts +24 -0
  228. package/source/SentinelHub.d.ts.map +1 -0
  229. package/source/SentinelHub.js +8 -0
  230. package/source/Source.d.ts +24 -0
  231. package/source/Source.d.ts.map +1 -0
  232. package/source/Source.js +8 -0
  233. package/source/StadiaMaps.d.ts +24 -0
  234. package/source/StadiaMaps.d.ts.map +1 -0
  235. package/source/StadiaMaps.js +8 -0
  236. package/source/Tile.d.ts +24 -0
  237. package/source/Tile.d.ts.map +1 -0
  238. package/source/Tile.js +8 -0
  239. package/source/TileArcGISRest.d.ts +24 -0
  240. package/source/TileArcGISRest.d.ts.map +1 -0
  241. package/source/TileArcGISRest.js +8 -0
  242. package/source/TileDebug.d.ts +24 -0
  243. package/source/TileDebug.d.ts.map +1 -0
  244. package/source/TileDebug.js +8 -0
  245. package/source/TileImage.d.ts +24 -0
  246. package/source/TileImage.d.ts.map +1 -0
  247. package/source/TileImage.js +8 -0
  248. package/source/TileJSON.d.ts +24 -0
  249. package/source/TileJSON.d.ts.map +1 -0
  250. package/source/TileJSON.js +8 -0
  251. package/source/TileWMS.d.ts +24 -0
  252. package/source/TileWMS.d.ts.map +1 -0
  253. package/source/TileWMS.js +8 -0
  254. package/source/UTFGrid.d.ts +24 -0
  255. package/source/UTFGrid.d.ts.map +1 -0
  256. package/source/UTFGrid.js +8 -0
  257. package/source/UrlTile.d.ts +24 -0
  258. package/source/UrlTile.d.ts.map +1 -0
  259. package/source/UrlTile.js +8 -0
  260. package/source/Vector.d.ts +24 -0
  261. package/source/Vector.d.ts.map +1 -0
  262. package/source/Vector.js +8 -0
  263. package/source/VectorTile.d.ts +24 -0
  264. package/source/VectorTile.d.ts.map +1 -0
  265. package/source/VectorTile.js +8 -0
  266. package/source/WMTS.d.ts +24 -0
  267. package/source/WMTS.d.ts.map +1 -0
  268. package/source/WMTS.js +8 -0
  269. package/source/XYZ.d.ts +24 -0
  270. package/source/XYZ.d.ts.map +1 -0
  271. package/source/XYZ.js +8 -0
  272. package/source/Zoomify.d.ts +24 -0
  273. package/source/Zoomify.d.ts.map +1 -0
  274. package/source/Zoomify.js +8 -0
  275. package/interaction/Property.js +0 -22
@@ -1,18 +1,24 @@
1
+ import OLMap from 'ol/Map.js';
2
+ import {unByKey} from 'ol/Observable.js';
1
3
  import Overlay from 'ol/Overlay.js';
2
4
  import View from 'ol/View.js';
3
5
  import Control from 'ol/control/Control.js';
4
6
  import Interaction from 'ol/interaction/Interaction.js';
5
7
  import BaseLayer from 'ol/layer/Base.js';
6
8
  import GroupLayer from 'ol/layer/Group.js';
9
+ import Layer from 'ol/layer/Layer.js';
7
10
  import Source from 'ol/source/Source.js';
11
+ import Vector from 'ol/source/Vector.js';
8
12
  import ReactReconciler from 'react-reconciler';
9
13
  import {
10
14
  ConcurrentRoot,
11
15
  DefaultEventPriority,
16
+ //@ts-ignore (TODO: remove after https://github.com/DefinitelyTyped/DefinitelyTyped/pull/72046 is released)
12
17
  NoEventPriority,
13
18
  } from 'react-reconciler/constants.js';
14
19
  import {CONTROL, INTERACTION, LAYER, OVERLAY, SOURCE, VIEW} from './config.js';
15
20
  import {
21
+ arrayEquals,
16
22
  prepareControlUpdate,
17
23
  prepareInteractionUpdate,
18
24
  prepareLayerUpdate,
@@ -25,14 +31,23 @@ import {
25
31
  const listenerRegex = /^on([A-Z].*)/;
26
32
  const listenerColonRegex = /^onChange-/;
27
33
 
34
+ /**
35
+ * @param {string} str A string.
36
+ */
28
37
  function upperFirst(str) {
29
38
  return str[0].toUpperCase() + str.slice(1);
30
39
  }
31
40
 
41
+ /**
42
+ * @param {string} str A string.
43
+ */
32
44
  function setterName(str) {
33
45
  return 'set' + upperFirst(str);
34
46
  }
35
47
 
48
+ /**
49
+ * @type {Object<string, boolean>}
50
+ */
36
51
  const knownTypes = {
37
52
  [VIEW]: true,
38
53
  [OVERLAY]: true,
@@ -42,30 +57,11 @@ const knownTypes = {
42
57
  [SOURCE]: true,
43
58
  };
44
59
 
60
+ const customViewChangeEventType = 'custom-change';
61
+
45
62
  /**
46
- * @param {Array} a1 An array.
47
- * @param {Array} a2 An array.
48
- * @return {boolean} All elements in the array are the same;
63
+ * @type {import('./update.js').Updater}
49
64
  */
50
- function arrayEquals(a1, a2) {
51
- if (!a1 || !a2) {
52
- return false;
53
- }
54
- const len1 = a1.length;
55
- const len2 = a2.length;
56
- if (len1 !== len2) {
57
- return false;
58
- }
59
- for (let i = 0; i < len1; i += 1) {
60
- const v1 = a1[i];
61
- const v2 = a2[i];
62
- if (v1 !== v2) {
63
- return false;
64
- }
65
- }
66
- return true;
67
- }
68
-
69
65
  export function updateInstanceFromProps(instance, type, oldProps, newProps) {
70
66
  for (const key in newProps) {
71
67
  if (reservedProps[key]) {
@@ -79,10 +75,15 @@ export function updateInstanceFromProps(instance, type, oldProps, newProps) {
79
75
 
80
76
  if (listenerRegex.test(key)) {
81
77
  const listener = newProps[key];
82
- const eventType = key
78
+ let eventType = key
83
79
  .replace(listenerColonRegex, 'onChange:')
84
80
  .replace(listenerRegex, '$1')
85
81
  .toLowerCase();
82
+
83
+ // special handling for view change
84
+ if (instance instanceof View && eventType === 'change') {
85
+ eventType = customViewChangeEventType;
86
+ }
86
87
  instance.on(eventType, listener);
87
88
 
88
89
  const oldListener = oldProps[key];
@@ -105,31 +106,46 @@ export function updateInstanceFromProps(instance, type, oldProps, newProps) {
105
106
  continue;
106
107
  }
107
108
 
108
- if (key === 'features' && typeof instance.addFeatures === 'function') {
109
- // TODO: there is likely a smarter way to diff features
110
- instance.clear(true);
111
- instance.addFeatures(newValue);
112
- continue;
109
+ if (instance instanceof Vector) {
110
+ if (key === 'features') {
111
+ // TODO: there is likely a smarter way to diff features
112
+ instance.clear(true);
113
+ instance.addFeatures(newValue);
114
+ continue;
115
+ }
113
116
  }
114
117
 
115
- if (
116
- key === 'interactions' &&
117
- typeof instance.addInteraction === 'function'
118
- ) {
119
- instance.getInteractions().clear();
120
- newValue.forEach(interaction => instance.addInteraction(interaction));
121
- continue;
122
- }
123
- if (key === 'controls' && typeof instance.addControl === 'function') {
124
- instance.getControls().clear();
125
- newValue.forEach(control => instance.addControl(control));
126
- continue;
118
+ if (instance instanceof OLMap) {
119
+ if (key === 'interactions') {
120
+ const interactions = /** @type {Array<Interaction>} */ (newValue);
121
+ instance.getInteractions().clear();
122
+ interactions.forEach(interaction =>
123
+ instance.addInteraction(interaction),
124
+ );
125
+ continue;
126
+ }
127
+ if (key === 'controls') {
128
+ const controls = /** @type {Array<Control>} */ (newValue);
129
+ instance.getControls().clear();
130
+ controls.forEach(control => instance.addControl(control));
131
+ continue;
132
+ }
127
133
  }
128
134
 
129
135
  throw new Error(`Cannot update '${key}' property`);
130
136
  }
131
137
  }
132
138
 
139
+ /**
140
+ * @typedef {Object} InstanceProps
141
+ * @property {new(options: any) => any} cls A class.
142
+ * @property {any} [options] The options.
143
+ */
144
+
145
+ /**
146
+ * @param {string} type The string type.
147
+ * @param {InstanceProps} The instance props.
148
+ */
133
149
  function createInstance(type, {cls: Constructor, ...props}) {
134
150
  if (!knownTypes[type]) {
135
151
  throw new Error(`Unsupported element type: ${type}`);
@@ -147,9 +163,19 @@ function createTextInstance() {
147
163
  throw new Error('Cannot add text to the map');
148
164
  }
149
165
 
166
+ /**
167
+ * @param {OLMap} map The map.
168
+ * @param {any} child The child.
169
+ */
150
170
  function appendChildToContainer(map, child) {
151
171
  if (child instanceof View) {
172
+ const key = map.on('moveend', () => {
173
+ child.dispatchEvent(customViewChangeEventType);
174
+ });
152
175
  map.setView(child);
176
+ map.on('change:view', () => {
177
+ unByKey(key);
178
+ });
153
179
  return;
154
180
  }
155
181
  if (child instanceof Overlay) {
@@ -171,9 +197,13 @@ function appendChildToContainer(map, child) {
171
197
  throw new Error(`Cannot add child to the map: ${child}`);
172
198
  }
173
199
 
200
+ /**
201
+ * @param {any} parent The parent.
202
+ * @param {any} child The child.
203
+ */
174
204
  function appendChild(parent, child) {
175
205
  if (child instanceof Source) {
176
- if (!(parent instanceof BaseLayer)) {
206
+ if (!(parent instanceof Layer)) {
177
207
  throw new Error(`Cannot add source to ${parent}`);
178
208
  }
179
209
  parent.setSource(child);
@@ -187,6 +217,9 @@ function appendChild(parent, child) {
187
217
  throw new Error(`Cannot add ${child} to ${parent}`);
188
218
  }
189
219
 
220
+ /**
221
+ * @type {Object<string, import('./update.js').Updater>}
222
+ */
190
223
  const updaters = {
191
224
  [VIEW]: prepareViewUpdate,
192
225
  [OVERLAY]: prepareOverlayUpdate,
@@ -196,6 +229,12 @@ const updaters = {
196
229
  [SOURCE]: prepareSourceUpdate,
197
230
  };
198
231
 
232
+ /**
233
+ * @param {any} instance The instance to update.
234
+ * @param {string} type The string type.
235
+ * @param {Object<string, any>} oldProps The old props.
236
+ * @param {Object<string, any>} newProps The new props.
237
+ */
199
238
  function prepareUpdate(instance, type, oldProps, newProps) {
200
239
  const updater = updaters[type];
201
240
  if (!updater) {
@@ -204,13 +243,21 @@ function prepareUpdate(instance, type, oldProps, newProps) {
204
243
  return updater(instance, type, oldProps, newProps);
205
244
  }
206
245
 
246
+ /**
247
+ * @type {import('./update.js').Updater}
248
+ */
207
249
  function commitUpdate(instance, type, oldProps, newProps) {
208
250
  updateInstanceFromProps(instance, type, oldProps, newProps);
209
251
  }
210
252
 
253
+ /**
254
+ * @param {OLMap} map The map.
255
+ * @param {any} child The object to remove from the map.
256
+ */
211
257
  function removeChildFromContainer(map, child) {
212
258
  if (child instanceof View) {
213
- map.setView(child);
259
+ // @ts-ignore (remove when https://github.com/openlayers/openlayers/pull/16691 is released)
260
+ map.setView(null);
214
261
  return;
215
262
  }
216
263
  if (child instanceof Overlay) {
@@ -232,6 +279,10 @@ function removeChildFromContainer(map, child) {
232
279
  throw new Error(`Cannot remove child from the map: ${child}`);
233
280
  }
234
281
 
282
+ /**
283
+ * @param {any} parent The parent object.
284
+ * @param {any} child The child object.
285
+ */
235
286
  function removeChild(parent, child) {
236
287
  // this happens with group layers
237
288
  if (child instanceof BaseLayer && parent.getLayers) {
@@ -241,12 +292,21 @@ function removeChild(parent, child) {
241
292
  throw new Error(`TODO: implement removeChild for ${parent} and ${child}`);
242
293
  }
243
294
 
295
+ /**
296
+ * @param {OLMap} map The map.
297
+ */
244
298
  function clearContainer(map) {
245
299
  map.getLayers().clear();
246
300
  // Need to leave the default controls and interactions.
247
301
  // TODO: determine when this gets called.
248
302
  }
249
303
 
304
+ /**
305
+ * @template {any} T
306
+ * @param {import("ol/Collection.js").default<T>} collection A collection.
307
+ * @param {T} child The child to insert.
308
+ * @param {T} beforeChild The insertion point.
309
+ */
250
310
  function insertInCollection(collection, child, beforeChild) {
251
311
  const index = collection.getArray().indexOf(beforeChild);
252
312
  if (index < 0) {
@@ -256,9 +316,20 @@ function insertInCollection(collection, child, beforeChild) {
256
316
  }
257
317
  }
258
318
 
319
+ /**
320
+ * @param {OLMap} map The map.
321
+ * @param {any} child The child to insert.
322
+ * @param {any} beforeChild The insertion point.
323
+ */
259
324
  function insertInContainerBefore(map, child, beforeChild) {
260
325
  if (child instanceof View) {
326
+ const key = map.on('moveend', () => {
327
+ child.dispatchEvent(customViewChangeEventType);
328
+ });
261
329
  map.setView(child);
330
+ map.on('change:view', () => {
331
+ unByKey(key);
332
+ });
262
333
  return;
263
334
  }
264
335
  let collection;
@@ -276,6 +347,11 @@ function insertInContainerBefore(map, child, beforeChild) {
276
347
  }
277
348
  }
278
349
 
350
+ /**
351
+ * @param {any} parent The parent.
352
+ * @param {any} child The child to insert.
353
+ * @param {any} beforeChild The insertion point.
354
+ */
279
355
  function insertBefore(parent, child, beforeChild) {
280
356
  if (child instanceof BaseLayer && parent instanceof GroupLayer) {
281
357
  insertInCollection(parent.getLayers(), child, beforeChild);
@@ -308,6 +384,7 @@ const reconciler = ReactReconciler({
308
384
  return null;
309
385
  },
310
386
 
387
+ //@ts-ignore
311
388
  shouldAttemptEagerTransition() {
312
389
  return false;
313
390
  },
@@ -330,6 +407,9 @@ const reconciler = ReactReconciler({
330
407
  return null;
331
408
  },
332
409
 
410
+ /**
411
+ * @param {number} newPriority The new priority.
412
+ */
333
413
  setCurrentUpdatePriority(newPriority) {
334
414
  currentUpdatePriority = newPriority;
335
415
  },
@@ -378,8 +458,15 @@ const reconciler = ReactReconciler({
378
458
  detachDeletedInstance() {},
379
459
  });
380
460
 
461
+ /**
462
+ * @type {Map<any, ReactReconciler.OpaqueRoot>}
463
+ */
381
464
  const roots = new Map();
382
465
 
466
+ /**
467
+ * @param {React.ReactNode} element The element to render.
468
+ * @param {any} container The container.
469
+ */
383
470
  export function render(element, container) {
384
471
  let root = roots.get(container);
385
472
  if (!root) {
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @typedef {function(any, string, Object<string, any>, Object<string, any>): any} Updater
3
+ */
4
+ /**
5
+ * @param {Array<any>} [a1] An array.
6
+ * @param {Array<any>} [a2] An array.
7
+ * @return {boolean} All elements in the array are the same;
8
+ */
9
+ export function arrayEquals(a1?: Array<any>, a2?: Array<any>): boolean;
10
+ /**
11
+ * @param {import("ol/View.js").default} view The view.
12
+ * @param {string} type The string type.
13
+ * @param {Object<string, any>} oldProps The old props.
14
+ * @param {Object<string, any>} newProps The new props.
15
+ */
16
+ export function prepareViewUpdate(view: import("ol/View.js").default, type: string, oldProps: {
17
+ [x: string]: any;
18
+ }, newProps: {
19
+ [x: string]: any;
20
+ }): {
21
+ [x: string]: any;
22
+ } | null;
23
+ /**
24
+ * @type {Object<string, boolean>}
25
+ */
26
+ export const reservedProps: {
27
+ [x: string]: boolean;
28
+ };
29
+ export type Updater = (arg0: any, arg1: string, arg2: {
30
+ [x: string]: any;
31
+ }, arg3: {
32
+ [x: string]: any;
33
+ }) => any;
34
+ declare function prepareGenericUpdate(arg0: any, arg1: string, arg2: {
35
+ [x: string]: any;
36
+ }, arg3: {
37
+ [x: string]: any;
38
+ }): any;
39
+ export { prepareGenericUpdate as prepareControlUpdate, prepareGenericUpdate as prepareInteractionUpdate, prepareGenericUpdate as prepareLayerUpdate, prepareGenericUpdate as prepareOverlayUpdate, prepareGenericUpdate as prepareSourceUpdate };
40
+ //# sourceMappingURL=update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["update.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,iCAJW,KAAK,CAAC,GAAG,CAAC,OACV,KAAK,CAAC,GAAG,CAAC,GACT,OAAO,CAkBlB;AAYD;;;;;GAKG;AACH,wCALW,OAAO,YAAY,EAAE,OAAO,QAC5B,MAAM;;;;;;SA2DhB;AAvED;;GAEG;AACH;;EAKE;sBAlCW,CAAS,IAAG,EAAH,GAAG,EAAE,IAAM,EAAN,MAAM,EAAE,IAAmB,EAAnB;QAAO,MAAM,GAAE,GAAG;CAAC,EAAE,IAAmB,EAAnB;QAAO,MAAM,GAAE,GAAG;CAAC,KAAG,GAAG;AAApE,4CAAS,GAAG,QAAE,MAAM;;;;IAA6C,GAAG,CAAA"}
@@ -1,15 +1,33 @@
1
- function arrayEquals(a, b) {
2
- if (a.length !== b.length) {
1
+ /**
2
+ * @typedef {function(any, string, Object<string, any>, Object<string, any>): any} Updater
3
+ */
4
+
5
+ /**
6
+ * @param {Array<any>} [a1] An array.
7
+ * @param {Array<any>} [a2] An array.
8
+ * @return {boolean} All elements in the array are the same;
9
+ */
10
+ export function arrayEquals(a1, a2) {
11
+ if (!a1 || !a2) {
12
+ return false;
13
+ }
14
+ const len = a1.length;
15
+ if (len !== a2.length) {
3
16
  return false;
4
17
  }
5
- for (let i = 0; i < a.length; i++) {
6
- if (a[i] !== b[i]) {
18
+ for (let i = 0; i < len; i += 1) {
19
+ const v1 = a1[i];
20
+ const v2 = a2[i];
21
+ if (v1 !== v2) {
7
22
  return false;
8
23
  }
9
24
  }
10
25
  return true;
11
26
  }
12
27
 
28
+ /**
29
+ * @type {Object<string, boolean>}
30
+ */
13
31
  export const reservedProps = {
14
32
  children: true,
15
33
  cls: true,
@@ -17,10 +35,19 @@ export const reservedProps = {
17
35
  ref: true, // TODO: deal with changing ref
18
36
  };
19
37
 
38
+ /**
39
+ * @param {import("ol/View.js").default} view The view.
40
+ * @param {string} type The string type.
41
+ * @param {Object<string, any>} oldProps The old props.
42
+ * @param {Object<string, any>} newProps The new props.
43
+ */
20
44
  export function prepareViewUpdate(view, type, oldProps, newProps) {
21
45
  if (view.getAnimating()) {
22
46
  return null;
23
47
  }
48
+ /**
49
+ * @type {Object<string, any>}
50
+ */
24
51
  const payload = {};
25
52
  let needsUpdate = false;
26
53
  for (const key in newProps) {
@@ -71,7 +98,13 @@ export function prepareViewUpdate(view, type, oldProps, newProps) {
71
98
  return payload;
72
99
  }
73
100
 
101
+ /**
102
+ * @type {Updater}
103
+ */
74
104
  function prepareGenericUpdate(instance, type, oldProps, newProps) {
105
+ /**
106
+ * @type {Object<string, any>}
107
+ */
75
108
  const payload = {};
76
109
  let needsUpdate = false;
77
110
  for (const key in newProps) {
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @typedef {Object} BaseProps
3
+ * @property {ConstructorParameters<typeof OLBase>[0]} [options] The layer options.
4
+ * @property {React.ReactNode} children The layer source.
5
+ */
6
+ /**
7
+ * @param {BaseProps | Object<string, any>} props The layer props.
8
+ */
9
+ export default function Base({ children, ...props }: BaseProps | {
10
+ [x: string]: any;
11
+ }): import("react").ReactElement<{
12
+ /**
13
+ * The layer options.
14
+ */
15
+ options?: import("ol/layer/Base.js").Options | undefined;
16
+ cls: typeof OLBase;
17
+ }, string | import("react").JSXElementConstructor<any>>;
18
+ export type BaseProps = {
19
+ /**
20
+ * The layer options.
21
+ */
22
+ options?: import("ol/layer/Base.js").Options | undefined;
23
+ /**
24
+ * The layer source.
25
+ */
26
+ children: React.ReactNode;
27
+ };
28
+ import OLBase from 'ol/layer/Base.js';
29
+ //# sourceMappingURL=Base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Base.d.ts","sourceRoot":"","sources":["Base.js"],"names":[],"mappings":"AAmBA;;;;GAIG;AAEH;;GAEG;AACH,qDAFW,SAAS,GAAG;QAAO,MAAM,GAAE,GAAG;CAAC;;;;;;wDAIzC;;;;;;;;;cARa,KAAK,CAAC,SAAS;;mBANV,kBAAkB"}
package/layer/Base.js CHANGED
@@ -15,13 +15,17 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import OLBase from 'ol/layer/Base.js';
18
- import propTypes from 'prop-types';
19
18
  import {createElement} from 'react';
20
19
 
20
+ /**
21
+ * @typedef {Object} BaseProps
22
+ * @property {ConstructorParameters<typeof OLBase>[0]} [options] The layer options.
23
+ * @property {React.ReactNode} children The layer source.
24
+ */
25
+
26
+ /**
27
+ * @param {BaseProps | Object<string, any>} props The layer props.
28
+ */
21
29
  export default function Base({children, ...props}) {
22
30
  return createElement('layer', {cls: OLBase, ...props}, children);
23
31
  }
24
-
25
- Base.propTypes = {
26
- children: propTypes.node,
27
- };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @typedef {Object} BaseImageProps
3
+ * @property {ConstructorParameters<typeof OLBaseImage>[0]} [options] The layer options.
4
+ * @property {React.ReactNode} children The layer source.
5
+ */
6
+ /**
7
+ * @param {BaseImageProps | Object<string, any>} props The layer props.
8
+ */
9
+ export default function BaseImage({ children, ...props }: BaseImageProps | {
10
+ [x: string]: any;
11
+ }): import("react").ReactElement<{
12
+ /**
13
+ * The layer options.
14
+ */
15
+ options?: ConstructorParameters<typeof OLBaseImage>[0];
16
+ cls: typeof OLBaseImage;
17
+ }, string | import("react").JSXElementConstructor<any>>;
18
+ export type BaseImageProps = {
19
+ /**
20
+ * The layer options.
21
+ */
22
+ options?: ConstructorParameters<typeof OLBaseImage>[0];
23
+ /**
24
+ * The layer source.
25
+ */
26
+ children: React.ReactNode;
27
+ };
28
+ import OLBaseImage from 'ol/layer/BaseImage.js';
29
+ //# sourceMappingURL=BaseImage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseImage.d.ts","sourceRoot":"","sources":["BaseImage.js"],"names":[],"mappings":"AAmBA;;;;GAIG;AAEH;;GAEG;AACH,0DAFW,cAAc,GAAG;QAAO,MAAM,GAAE,GAAG;CAAC;;;;cALjC,qBAAqB,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC;;wDASzD;;;;;cATa,qBAAqB,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC;;;;cAC5C,KAAK,CAAC,SAAS;;wBANL,uBAAuB"}
@@ -15,13 +15,17 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import OLBaseImage from 'ol/layer/BaseImage.js';
18
- import propTypes from 'prop-types';
19
18
  import {createElement} from 'react';
20
19
 
20
+ /**
21
+ * @typedef {Object} BaseImageProps
22
+ * @property {ConstructorParameters<typeof OLBaseImage>[0]} [options] The layer options.
23
+ * @property {React.ReactNode} children The layer source.
24
+ */
25
+
26
+ /**
27
+ * @param {BaseImageProps | Object<string, any>} props The layer props.
28
+ */
21
29
  export default function BaseImage({children, ...props}) {
22
30
  return createElement('layer', {cls: OLBaseImage, ...props}, children);
23
31
  }
24
-
25
- BaseImage.propTypes = {
26
- children: propTypes.node,
27
- };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @typedef {Object} BaseTileProps
3
+ * @property {ConstructorParameters<typeof OLBaseTile>[0]} [options] The layer options.
4
+ * @property {React.ReactNode} children The layer source.
5
+ */
6
+ /**
7
+ * @param {BaseTileProps | Object<string, any>} props The layer props.
8
+ */
9
+ export default function BaseTile({ children, ...props }: BaseTileProps | {
10
+ [x: string]: any;
11
+ }): import("react").ReactElement<{
12
+ /**
13
+ * The layer options.
14
+ */
15
+ options?: ConstructorParameters<typeof OLBaseTile>[0];
16
+ cls: typeof OLBaseTile;
17
+ }, string | import("react").JSXElementConstructor<any>>;
18
+ export type BaseTileProps = {
19
+ /**
20
+ * The layer options.
21
+ */
22
+ options?: ConstructorParameters<typeof OLBaseTile>[0];
23
+ /**
24
+ * The layer source.
25
+ */
26
+ children: React.ReactNode;
27
+ };
28
+ import OLBaseTile from 'ol/layer/BaseTile.js';
29
+ //# sourceMappingURL=BaseTile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseTile.d.ts","sourceRoot":"","sources":["BaseTile.js"],"names":[],"mappings":"AAmBA;;;;GAIG;AAEH;;GAEG;AACH,yDAFW,aAAa,GAAG;QAAO,MAAM,GAAE,GAAG;CAAC;;;;cALhC,qBAAqB,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;;wDASxD;;;;;cATa,qBAAqB,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;;;;cAC3C,KAAK,CAAC,SAAS;;uBANN,sBAAsB"}
package/layer/BaseTile.js CHANGED
@@ -15,13 +15,17 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import OLBaseTile from 'ol/layer/BaseTile.js';
18
- import propTypes from 'prop-types';
19
18
  import {createElement} from 'react';
20
19
 
20
+ /**
21
+ * @typedef {Object} BaseTileProps
22
+ * @property {ConstructorParameters<typeof OLBaseTile>[0]} [options] The layer options.
23
+ * @property {React.ReactNode} children The layer source.
24
+ */
25
+
26
+ /**
27
+ * @param {BaseTileProps | Object<string, any>} props The layer props.
28
+ */
21
29
  export default function BaseTile({children, ...props}) {
22
30
  return createElement('layer', {cls: OLBaseTile, ...props}, children);
23
31
  }
24
-
25
- BaseTile.propTypes = {
26
- children: propTypes.node,
27
- };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @typedef {Object} BaseVectorProps
3
+ * @property {ConstructorParameters<typeof OLBaseVector>[0]} [options] The layer options.
4
+ * @property {React.ReactNode} children The layer source.
5
+ */
6
+ /**
7
+ * @param {BaseVectorProps | Object<string, any>} props The layer props.
8
+ */
9
+ export default function BaseVector({ children, ...props }: BaseVectorProps | {
10
+ [x: string]: any;
11
+ }): import("react").ReactElement<{
12
+ /**
13
+ * The layer options.
14
+ */
15
+ options?: ConstructorParameters<typeof OLBaseVector>[0];
16
+ cls: typeof OLBaseVector;
17
+ }, string | import("react").JSXElementConstructor<any>>;
18
+ export type BaseVectorProps = {
19
+ /**
20
+ * The layer options.
21
+ */
22
+ options?: ConstructorParameters<typeof OLBaseVector>[0];
23
+ /**
24
+ * The layer source.
25
+ */
26
+ children: React.ReactNode;
27
+ };
28
+ import OLBaseVector from 'ol/layer/BaseVector.js';
29
+ //# sourceMappingURL=BaseVector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseVector.d.ts","sourceRoot":"","sources":["BaseVector.js"],"names":[],"mappings":"AAmBA;;;;GAIG;AAEH;;GAEG;AACH,2DAFW,eAAe,GAAG;QAAO,MAAM,GAAE,GAAG;CAAC;;;;cALlC,qBAAqB,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC;;wDAS1D;;;;;cATa,qBAAqB,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC;;;;cAC7C,KAAK,CAAC,SAAS;;yBANJ,wBAAwB"}
@@ -15,13 +15,17 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import OLBaseVector from 'ol/layer/BaseVector.js';
18
- import propTypes from 'prop-types';
19
18
  import {createElement} from 'react';
20
19
 
20
+ /**
21
+ * @typedef {Object} BaseVectorProps
22
+ * @property {ConstructorParameters<typeof OLBaseVector>[0]} [options] The layer options.
23
+ * @property {React.ReactNode} children The layer source.
24
+ */
25
+
26
+ /**
27
+ * @param {BaseVectorProps | Object<string, any>} props The layer props.
28
+ */
21
29
  export default function BaseVector({children, ...props}) {
22
30
  return createElement('layer', {cls: OLBaseVector, ...props}, children);
23
31
  }
24
-
25
- BaseVector.propTypes = {
26
- children: propTypes.node,
27
- };