@planet/maps 10.3.0-dev.1734966802191 → 10.3.0-dev.1735324946128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Map.js +2 -1
- package/internal/config.js +1 -0
- package/internal/render.js +103 -20
- package/internal/update.js +1 -0
- package/package.json +9 -8
package/Map.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import OLMap from 'ol/Map.js';
|
|
17
17
|
import propTypes from 'prop-types';
|
|
18
18
|
import {Component, createElement, createRef, forwardRef} from 'react';
|
|
19
|
+
import {MAP} from './internal/config.js';
|
|
19
20
|
import {render, updateInstanceFromProps} from './internal/render.js';
|
|
20
21
|
|
|
21
22
|
const defaultDivStyle = {
|
|
@@ -38,7 +39,7 @@ class Map extends Component {
|
|
|
38
39
|
innerRef.current = this.map;
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
|
-
updateInstanceFromProps(this.map, mapProps);
|
|
42
|
+
updateInstanceFromProps(this.map, MAP, {}, mapProps);
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
componentDidMount() {
|
package/internal/config.js
CHANGED
package/internal/render.js
CHANGED
|
@@ -10,6 +10,7 @@ import {CONTROL, INTERACTION, LAYER, OVERLAY, SOURCE, VIEW} from './config.js';
|
|
|
10
10
|
import {
|
|
11
11
|
ConcurrentRoot,
|
|
12
12
|
DefaultEventPriority,
|
|
13
|
+
NoEventPriority,
|
|
13
14
|
} from 'react-reconciler/constants.js';
|
|
14
15
|
import {
|
|
15
16
|
prepareControlUpdate,
|
|
@@ -41,20 +42,52 @@ const knownTypes = {
|
|
|
41
42
|
[SOURCE]: true,
|
|
42
43
|
};
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
/**
|
|
46
|
+
* @param {Array} a1 An array.
|
|
47
|
+
* @param {Array} a2 An array.
|
|
48
|
+
* @return {boolean} All elements in the array are the same;
|
|
49
|
+
*/
|
|
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
|
+
export function updateInstanceFromProps(instance, type, oldProps, newProps) {
|
|
70
|
+
for (const key in newProps) {
|
|
46
71
|
if (reservedProps[key]) {
|
|
47
72
|
continue;
|
|
48
73
|
}
|
|
74
|
+
const newValue = newProps[key];
|
|
75
|
+
const oldValue = oldProps[key];
|
|
76
|
+
if (oldValue === newValue) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
|
|
49
80
|
if (listenerRegex.test(key)) {
|
|
50
|
-
const listener =
|
|
51
|
-
const
|
|
81
|
+
const listener = newProps[key];
|
|
82
|
+
const eventType = key
|
|
52
83
|
.replace(listenerColonRegex, 'onChange:')
|
|
53
84
|
.replace(listenerRegex, '$1')
|
|
54
85
|
.toLowerCase();
|
|
55
|
-
instance.on(
|
|
56
|
-
|
|
57
|
-
|
|
86
|
+
instance.on(eventType, listener);
|
|
87
|
+
|
|
88
|
+
const oldListener = oldProps[key];
|
|
89
|
+
if (oldListener) {
|
|
90
|
+
instance.un(eventType, oldListener);
|
|
58
91
|
if (instance.changed) {
|
|
59
92
|
instance.changed();
|
|
60
93
|
}
|
|
@@ -62,16 +95,20 @@ export function updateInstanceFromProps(instance, props, oldProps = {}) {
|
|
|
62
95
|
continue;
|
|
63
96
|
}
|
|
64
97
|
|
|
98
|
+
if (key === 'center' && arrayEquals(newValue, oldValue)) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
|
|
65
102
|
const setter = setterName(key);
|
|
66
103
|
if (typeof instance[setter] === 'function') {
|
|
67
|
-
instance[setter](
|
|
104
|
+
instance[setter](newValue);
|
|
68
105
|
continue;
|
|
69
106
|
}
|
|
70
107
|
|
|
71
108
|
if (key === 'features' && typeof instance.addFeatures === 'function') {
|
|
72
109
|
// TODO: there is likely a smarter way to diff features
|
|
73
110
|
instance.clear(true);
|
|
74
|
-
instance.addFeatures(
|
|
111
|
+
instance.addFeatures(newValue);
|
|
75
112
|
continue;
|
|
76
113
|
}
|
|
77
114
|
|
|
@@ -80,12 +117,12 @@ export function updateInstanceFromProps(instance, props, oldProps = {}) {
|
|
|
80
117
|
typeof instance.addInteraction === 'function'
|
|
81
118
|
) {
|
|
82
119
|
instance.getInteractions().clear();
|
|
83
|
-
|
|
120
|
+
newValue.forEach(interaction => instance.addInteraction(interaction));
|
|
84
121
|
continue;
|
|
85
122
|
}
|
|
86
123
|
if (key === 'controls' && typeof instance.addControl === 'function') {
|
|
87
124
|
instance.getControls().clear();
|
|
88
|
-
|
|
125
|
+
newValue.forEach(control => instance.addControl(control));
|
|
89
126
|
continue;
|
|
90
127
|
}
|
|
91
128
|
|
|
@@ -102,7 +139,7 @@ function createInstance(type, {cls: Constructor, ...props}) {
|
|
|
102
139
|
}
|
|
103
140
|
|
|
104
141
|
const instance = new Constructor(props.options || {});
|
|
105
|
-
updateInstanceFromProps(instance, props);
|
|
142
|
+
updateInstanceFromProps(instance, type, {}, props);
|
|
106
143
|
return instance;
|
|
107
144
|
}
|
|
108
145
|
|
|
@@ -167,8 +204,8 @@ function prepareUpdate(instance, type, oldProps, newProps) {
|
|
|
167
204
|
return updater(instance, type, oldProps, newProps);
|
|
168
205
|
}
|
|
169
206
|
|
|
170
|
-
function commitUpdate(instance,
|
|
171
|
-
updateInstanceFromProps(instance,
|
|
207
|
+
function commitUpdate(instance, type, oldProps, newProps) {
|
|
208
|
+
updateInstanceFromProps(instance, type, oldProps, newProps);
|
|
172
209
|
}
|
|
173
210
|
|
|
174
211
|
function removeChildFromContainer(map, child) {
|
|
@@ -247,6 +284,9 @@ function insertBefore(parent, child, beforeChild) {
|
|
|
247
284
|
throw new Error(`Cannot insert child ${child} into parent ${parent}`);
|
|
248
285
|
}
|
|
249
286
|
|
|
287
|
+
const noContext = {};
|
|
288
|
+
let currentUpdatePriority = NoEventPriority;
|
|
289
|
+
|
|
250
290
|
const reconciler = ReactReconciler({
|
|
251
291
|
supportsMutation: true,
|
|
252
292
|
isPrimaryRenderer: false,
|
|
@@ -260,21 +300,66 @@ const reconciler = ReactReconciler({
|
|
|
260
300
|
clearContainer,
|
|
261
301
|
removeChildFromContainer,
|
|
262
302
|
removeChild,
|
|
263
|
-
|
|
264
303
|
insertInContainerBefore,
|
|
265
304
|
insertBefore,
|
|
305
|
+
noTimeout: -1,
|
|
306
|
+
|
|
307
|
+
getInstanceFromNode() {
|
|
308
|
+
return null;
|
|
309
|
+
},
|
|
310
|
+
|
|
311
|
+
shouldAttemptEagerTransition() {
|
|
312
|
+
return false;
|
|
313
|
+
},
|
|
314
|
+
|
|
315
|
+
requestPostPaintCallback() {},
|
|
316
|
+
|
|
317
|
+
maySuspendCommit() {
|
|
318
|
+
return false;
|
|
319
|
+
},
|
|
320
|
+
|
|
321
|
+
preloadInstance() {
|
|
322
|
+
return true;
|
|
323
|
+
},
|
|
324
|
+
|
|
325
|
+
startSuspendingCommit() {},
|
|
326
|
+
|
|
327
|
+
suspendInstance() {},
|
|
328
|
+
|
|
329
|
+
waitForCommitToBeReady() {
|
|
330
|
+
return null;
|
|
331
|
+
},
|
|
332
|
+
|
|
333
|
+
setCurrentUpdatePriority(newPriority) {
|
|
334
|
+
currentUpdatePriority = newPriority;
|
|
335
|
+
},
|
|
336
|
+
|
|
337
|
+
getCurrentUpdatePriority() {
|
|
338
|
+
return currentUpdatePriority;
|
|
339
|
+
},
|
|
340
|
+
|
|
341
|
+
resolveUpdatePriority() {
|
|
342
|
+
if (currentUpdatePriority) {
|
|
343
|
+
return currentUpdatePriority;
|
|
344
|
+
}
|
|
345
|
+
return DefaultEventPriority;
|
|
346
|
+
},
|
|
266
347
|
|
|
267
348
|
finalizeInitialChildren() {
|
|
268
349
|
return false;
|
|
269
350
|
},
|
|
270
351
|
|
|
271
|
-
getChildHostContext() {
|
|
352
|
+
getChildHostContext() {
|
|
353
|
+
return noContext;
|
|
354
|
+
},
|
|
272
355
|
|
|
273
356
|
getPublicInstance(instance) {
|
|
274
357
|
return instance;
|
|
275
358
|
},
|
|
276
359
|
|
|
277
|
-
getRootHostContext() {
|
|
360
|
+
getRootHostContext() {
|
|
361
|
+
return noContext;
|
|
362
|
+
},
|
|
278
363
|
|
|
279
364
|
getCurrentEventPriority() {
|
|
280
365
|
return DefaultEventPriority;
|
|
@@ -299,9 +384,7 @@ export function render(element, container) {
|
|
|
299
384
|
let root = roots.get(container);
|
|
300
385
|
if (!root) {
|
|
301
386
|
const logRecoverableError =
|
|
302
|
-
typeof reportError === 'function'
|
|
303
|
-
? reportError // eslint-disable-line no-undef
|
|
304
|
-
: console.error; // eslint-disable-line no-console
|
|
387
|
+
typeof reportError === 'function' ? reportError : console.error; // eslint-disable-line no-console
|
|
305
388
|
|
|
306
389
|
root = reconciler.createContainer(
|
|
307
390
|
container,
|
package/internal/update.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planet/maps",
|
|
3
|
-
"version": "10.3.0-dev.
|
|
3
|
+
"version": "10.3.0-dev.1735324946128",
|
|
4
4
|
"description": "Declarative mapping components for React",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"react-reconciler": "^0.
|
|
25
|
+
"react-reconciler": "^0.31.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"ol": "*",
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"react": "*"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@astrojs/mdx": "^
|
|
33
|
+
"@astrojs/mdx": "^4.0.3",
|
|
34
34
|
"@astrojs/react": "^4.0.0",
|
|
35
35
|
"@octokit/rest": "^21.0.0",
|
|
36
36
|
"@playwright/test": "^1.25.2",
|
|
37
37
|
"@testing-library/react": "^16.0.0",
|
|
38
|
-
"@types/react": "^
|
|
39
|
-
"@types/react-dom": "^
|
|
38
|
+
"@types/react": "^19.0.2",
|
|
39
|
+
"@types/react-dom": "^19.0.2",
|
|
40
40
|
"@vitest/browser": "^2.0.3",
|
|
41
|
-
"astro": "^
|
|
41
|
+
"astro": "^5.1.1",
|
|
42
42
|
"es-main": "^1.2.0",
|
|
43
43
|
"eslint": "^8.57.0",
|
|
44
44
|
"eslint-config-planet": "^22.1.0",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"ol": "^10.3.0",
|
|
52
52
|
"ol-mapbox-style": "^12.3.5",
|
|
53
53
|
"prop-types": "^15.8.1",
|
|
54
|
-
"react": "^
|
|
55
|
-
"react-dom": "^
|
|
54
|
+
"react": "^19.0.0",
|
|
55
|
+
"react-dom": "^19.0.0",
|
|
56
56
|
"remark-html": "^16.0.1",
|
|
57
57
|
"remark-parse": "^11.0.0",
|
|
58
58
|
"semapro": "^1.1.0",
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
{
|
|
80
80
|
"ignore": [
|
|
81
81
|
"astro:content",
|
|
82
|
+
"astro/config",
|
|
82
83
|
"@astrojs/*",
|
|
83
84
|
"@octokit/rest"
|
|
84
85
|
]
|