mobility-toolbox-js 3.0.0-beta.9 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/api/HttpAPI.d.ts +5 -16
- package/api/HttpAPI.js +1 -14
- package/api/RealtimeAPI.d.ts +188 -143
- package/api/RealtimeAPI.js +265 -206
- package/api/RoutingAPI.d.ts +21 -11
- package/api/RoutingAPI.js +17 -7
- package/api/StopsAPI.d.ts +20 -14
- package/api/StopsAPI.js +17 -11
- package/api/WebSocketAPI.d.ts +60 -66
- package/api/WebSocketAPI.js +164 -165
- package/api/index.js +1 -1
- package/api/typedefs.d.ts +0 -102
- package/api/typedefs.js +27 -42
- package/common/controls/StopFinderControlCommon.d.ts +13 -13
- package/common/controls/StopFinderControlCommon.js +32 -32
- package/common/index.d.ts +1 -1
- package/common/index.js +1 -1
- package/common/styles/realtimeDefaultStyle.js +6 -11
- package/common/styles/realtimeHeadingStyle.js +5 -10
- package/common/styles/realtimeSimpleStyle.d.ts +0 -1
- package/common/styles/realtimeSimpleStyle.js +0 -1
- package/common/typedefs.d.ts +11 -121
- package/common/typedefs.js +6 -31
- package/common/utils/RealtimeEngine.d.ts +214 -0
- package/common/utils/RealtimeEngine.js +554 -0
- package/common/utils/compareDepartures.d.ts +2 -2
- package/common/utils/compareDepartures.js +2 -2
- package/common/utils/debounceWebsocketMessages.d.ts +1 -1
- package/common/utils/getLayersAsFlatArray.d.ts +0 -1
- package/common/utils/getLayersAsFlatArray.js +0 -1
- package/common/utils/getMapGlCopyrights.d.ts +1 -1
- package/common/utils/getMapGlCopyrights.js +3 -3
- package/common/utils/getRealtimeModeSuffix.d.ts +1 -0
- package/common/utils/getRealtimeModeSuffix.js +1 -0
- package/common/utils/getVehiclePosition.d.ts +5 -4
- package/common/utils/getVehiclePosition.js +6 -3
- package/common/utils/realtimeConfig.d.ts +1 -1
- package/common/utils/realtimeConfig.js +0 -1
- package/common/utils/renderTrajectories.d.ts +2 -1
- package/common/utils/renderTrajectories.js +7 -6
- package/common/utils/sortAndFilterDepartures.d.ts +2 -1
- package/common/utils/sortAndFilterDepartures.js +2 -1
- package/common/utils/sortByDelay.d.ts +2 -2
- package/common/utils/sortByDelay.js +5 -1
- package/maplibre/controls/CopyrightControl.d.ts +9 -6
- package/maplibre/controls/CopyrightControl.js +11 -8
- package/maplibre/layers/Layer.d.ts +8 -7
- package/maplibre/layers/Layer.js +2 -3
- package/maplibre/layers/RealtimeLayer.d.ts +82 -118
- package/maplibre/layers/RealtimeLayer.js +154 -118
- package/maplibre/utils/getSourceCoordinates.d.ts +1 -0
- package/maplibre/utils/getSourceCoordinates.js +6 -5
- package/mbt.js +14611 -14591
- package/mbt.js.map +4 -4
- package/mbt.min.js +75 -75
- package/mbt.min.js.map +4 -4
- package/ol/controls/CopyrightControl.d.ts +13 -5
- package/ol/controls/CopyrightControl.js +13 -5
- package/ol/controls/RoutingControl.d.ts +105 -101
- package/ol/controls/RoutingControl.js +250 -264
- package/ol/controls/StopFinderControl.d.ts +24 -5
- package/ol/controls/StopFinderControl.js +24 -5
- package/ol/layers/Layer.d.ts +26 -0
- package/ol/layers/Layer.js +39 -0
- package/ol/layers/MaplibreLayer.d.ts +56 -28
- package/ol/layers/MaplibreLayer.js +154 -31
- package/ol/layers/MaplibreStyleLayer.d.ts +71 -149
- package/ol/layers/MaplibreStyleLayer.js +281 -210
- package/ol/layers/RealtimeLayer.d.ts +95 -230
- package/ol/layers/RealtimeLayer.js +209 -211
- package/ol/layers/VectorLayer.d.ts +17 -0
- package/ol/layers/VectorLayer.js +33 -0
- package/ol/layers/index.d.ts +2 -0
- package/ol/layers/index.js +3 -0
- package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -20
- package/ol/renderers/MaplibreLayerRenderer.js +142 -114
- package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +6 -6
- package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
- package/ol/renderers/RealtimeLayerRenderer.d.ts +7 -7
- package/ol/renderers/RealtimeLayerRenderer.js +46 -66
- package/ol/styles/fullTrajectoryDelayStyle.js +5 -7
- package/ol/styles/fullTrajectoryStyle.d.ts +1 -2
- package/ol/styles/fullTrajectoryStyle.js +5 -7
- package/ol/styles/routingStyle.d.ts +0 -1
- package/ol/styles/routingStyle.js +13 -10
- package/ol/utils/defineDeprecatedProperties.d.ts +10 -0
- package/ol/utils/defineDeprecatedProperties.js +180 -0
- package/ol/utils/getFeatureInfoAtCoordinate.d.ts +1 -1
- package/ol/utils/getFeatureInfoAtCoordinate.js +11 -17
- package/package.json +44 -44
- package/setupTests.js +17 -4
- package/types/common.d.ts +53 -69
- package/types/index.d.ts +1 -1
- package/types/realtime.d.ts +98 -95
- package/types/routing.d.ts +60 -60
- package/types/stops.d.ts +62 -62
- package/common/mixins/RealtimeLayerMixin.d.ts +0 -273
- package/common/mixins/RealtimeLayerMixin.js +0 -743
- package/ol/layers/MapGlLayer.d.ts +0 -144
- package/ol/layers/MapGlLayer.js +0 -144
- package/ol/mixins/MobilityLayerMixin.d.ts +0 -98
- package/ol/mixins/MobilityLayerMixin.js +0 -6
- package/ol/mixins/PropertiesLayerMixin.d.ts +0 -127
- package/ol/mixins/PropertiesLayerMixin.js +0 -143
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import { Circle, Fill, Stroke } from 'ol/style';
|
|
2
2
|
import Style from 'ol/style/Style';
|
|
3
|
-
/** @private */
|
|
4
3
|
const circleStyle = new Circle({
|
|
5
|
-
radius: 6,
|
|
6
4
|
fill: new Fill({
|
|
7
5
|
color: [255, 0, 0, 1],
|
|
8
6
|
}),
|
|
7
|
+
radius: 6,
|
|
9
8
|
stroke: new Stroke({
|
|
10
9
|
color: [0, 0, 0, 1],
|
|
11
10
|
width: 1,
|
|
12
11
|
}),
|
|
13
12
|
});
|
|
14
|
-
/** @private */
|
|
15
13
|
const blackBorder = new Style({
|
|
16
14
|
stroke: new Stroke({
|
|
17
15
|
color: [0, 0, 0, 1],
|
|
18
16
|
width: 5,
|
|
19
17
|
}),
|
|
20
18
|
});
|
|
21
|
-
/** @private */
|
|
22
19
|
const redLine = new Style({
|
|
23
20
|
image: circleStyle,
|
|
24
21
|
stroke: new Stroke({
|
|
@@ -26,27 +23,33 @@ const redLine = new Style({
|
|
|
26
23
|
width: 3,
|
|
27
24
|
}),
|
|
28
25
|
});
|
|
29
|
-
/** @private */
|
|
30
26
|
const dashedRedLine = new Style({
|
|
31
27
|
image: circleStyle,
|
|
32
28
|
stroke: new Stroke({
|
|
33
29
|
color: [255, 0, 0, 1],
|
|
34
|
-
width: 3,
|
|
35
30
|
lineDash: [1, 10],
|
|
31
|
+
width: 3,
|
|
36
32
|
}),
|
|
37
33
|
});
|
|
38
|
-
/** @private */
|
|
39
34
|
const routingStyle = (feature, resolution) => {
|
|
35
|
+
var _a;
|
|
40
36
|
const minResolution = feature.get('minResolution');
|
|
41
37
|
const maxResolution = feature.get('maxResolution');
|
|
42
38
|
const inRange = resolution <= minResolution && resolution > maxResolution;
|
|
43
39
|
if (minResolution && maxResolution && !inRange) {
|
|
44
40
|
return [];
|
|
45
41
|
}
|
|
42
|
+
const zIndex = ((_a = feature === null || feature === void 0 ? void 0 : feature.getGeometry()) === null || _a === void 0 ? void 0 : _a.getType()) === 'Point' ? 100 : 0;
|
|
43
|
+
let styles = [blackBorder, redLine];
|
|
46
44
|
const mot = feature.get('mot');
|
|
47
|
-
if (mot
|
|
48
|
-
|
|
45
|
+
if (mot === 'foot') {
|
|
46
|
+
styles = [dashedRedLine];
|
|
49
47
|
}
|
|
50
|
-
|
|
48
|
+
styles = styles.map((style) => {
|
|
49
|
+
const tmp = style.clone();
|
|
50
|
+
tmp.setZIndex(zIndex);
|
|
51
|
+
return tmp;
|
|
52
|
+
});
|
|
53
|
+
return styles;
|
|
51
54
|
};
|
|
52
55
|
export default routingStyle;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Layer } from 'ol/layer';
|
|
2
|
+
import { MobilityLayerOptions } from '../layers/Layer';
|
|
3
|
+
/**
|
|
4
|
+
* obj function defines properties taht were used in mbt v2.
|
|
5
|
+
* They are all marked als deprecated.
|
|
6
|
+
* @param obj
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
declare const defineDeprecatedProperties: (obj: Layer, options: MobilityLayerOptions) => void;
|
|
10
|
+
export default defineDeprecatedProperties;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import debounce from 'lodash.debounce';
|
|
2
|
+
let deprecated = () => { };
|
|
3
|
+
if (typeof window !== 'undefined' &&
|
|
4
|
+
new URLSearchParams(window.location.search).get('deprecated')) {
|
|
5
|
+
deprecated = debounce((message) => {
|
|
6
|
+
// eslint-disable-next-line no-console
|
|
7
|
+
console.warn(message);
|
|
8
|
+
}, 1000);
|
|
9
|
+
}
|
|
10
|
+
const onChildrenChange = (layer, oldValue) => {
|
|
11
|
+
// Set the parent property
|
|
12
|
+
(oldValue || []).forEach((child) => {
|
|
13
|
+
child.set('parent', undefined);
|
|
14
|
+
});
|
|
15
|
+
(layer.get('children') || []).forEach((child) => {
|
|
16
|
+
child.set('parent', this);
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* obj function defines properties taht were used in mbt v2.
|
|
21
|
+
* They are all marked als deprecated.
|
|
22
|
+
* @param obj
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
const defineDeprecatedProperties = (obj, options) => {
|
|
26
|
+
if (options.properties) {
|
|
27
|
+
deprecated("Deprecated. Don't use properties options. Pass the values directly in options object.");
|
|
28
|
+
obj.setProperties(options.properties);
|
|
29
|
+
}
|
|
30
|
+
// Update parent property
|
|
31
|
+
obj.on('propertychange', (evt) => {
|
|
32
|
+
if (evt.key === 'children') {
|
|
33
|
+
onChildrenChange(evt.target, evt.oldValue);
|
|
34
|
+
}
|
|
35
|
+
if (evt.key === 'map') {
|
|
36
|
+
const map = evt.target.get(evt.key);
|
|
37
|
+
if (map) {
|
|
38
|
+
(evt.target.get('children') || []).forEach((child) => {
|
|
39
|
+
map.addLayer(child);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else if (evt.oldValue) {
|
|
43
|
+
(evt.target.get('children') || []).forEach((child) => {
|
|
44
|
+
evt.oldValue.removeLayer(child);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
// Save options for cloning
|
|
50
|
+
obj.set('options', options);
|
|
51
|
+
obj.set('children', options.children || []); // Trigger the on children change event
|
|
52
|
+
Object.defineProperties(obj, {
|
|
53
|
+
children: {
|
|
54
|
+
/** @deprecated */
|
|
55
|
+
get: () => {
|
|
56
|
+
deprecated("Layer.children is deprecated. Use the Layer.get('children') method instead.");
|
|
57
|
+
return obj.get('children') || [];
|
|
58
|
+
},
|
|
59
|
+
/** @deprecated */
|
|
60
|
+
set: (newValue) => {
|
|
61
|
+
deprecated("Layer.children is deprecated. Use the Layer.set('children', children) method instead.");
|
|
62
|
+
obj.set('children', newValue || []);
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
copyrights: {
|
|
66
|
+
/** @deprecated */
|
|
67
|
+
get: () => {
|
|
68
|
+
deprecated('Layer.copyrights is deprecated. Get the attributions from the source object');
|
|
69
|
+
return obj.get('copyrights');
|
|
70
|
+
},
|
|
71
|
+
/** @deprecated */
|
|
72
|
+
set: (newCopyrights) => {
|
|
73
|
+
deprecated('Layer.copyrights is deprecated. Set the attributions to the source object.');
|
|
74
|
+
const arrValue = newCopyrights && !Array.isArray(newCopyrights)
|
|
75
|
+
? [newCopyrights]
|
|
76
|
+
: newCopyrights;
|
|
77
|
+
obj.set('copyrights', arrValue || []);
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
disabled: {
|
|
81
|
+
/** @deprecated */
|
|
82
|
+
get() {
|
|
83
|
+
deprecated("Layer.disabled is deprecated. Use the Layer.get('disabled') method instead.");
|
|
84
|
+
return obj.get('disabled');
|
|
85
|
+
},
|
|
86
|
+
/** @deprecated */
|
|
87
|
+
set(newValue) {
|
|
88
|
+
deprecated("Layer.disabled is deprecated. Use the Layer.set('disabled', newValue) method instead.");
|
|
89
|
+
obj.set('disabled', newValue);
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
group: {
|
|
93
|
+
/** @deprecated */
|
|
94
|
+
get() {
|
|
95
|
+
deprecated("Layer.group is deprecated. Use the Layer.get('group') method instead.");
|
|
96
|
+
return obj.get('group');
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
hitTolerance: {
|
|
100
|
+
/** @deprecated */
|
|
101
|
+
get() {
|
|
102
|
+
deprecated('Layer.hitTolerance is deprecated. Pass the hitTolerance when you request the features.');
|
|
103
|
+
return obj.get('hitTolerance') || 5;
|
|
104
|
+
},
|
|
105
|
+
/** @deprecated */
|
|
106
|
+
set(newValue) {
|
|
107
|
+
deprecated('Layer.hitTolerance is deprecated. Pass the hitTolerance when you request the features.');
|
|
108
|
+
obj.set('hitTolerance', newValue);
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
key: {
|
|
112
|
+
/** @deprecated */
|
|
113
|
+
get() {
|
|
114
|
+
deprecated('Layer.key is deprecated. Use the Layer.get("key") method instead.');
|
|
115
|
+
return obj.get('key') || obj.get('name');
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
map: {
|
|
119
|
+
/** @deprecated */
|
|
120
|
+
get() {
|
|
121
|
+
deprecated('Layer.map is deprecated. Use the Layer.get("map") method instead.');
|
|
122
|
+
return obj.getMapInternal();
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
name: {
|
|
126
|
+
/** @deprecated */
|
|
127
|
+
get() {
|
|
128
|
+
deprecated("Layer.name is deprecated. Use the Layer.get('name') method instead.");
|
|
129
|
+
return obj.get('name');
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
olLayer: {
|
|
133
|
+
/** @deprecated */
|
|
134
|
+
get() {
|
|
135
|
+
deprecated("Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. obj getter is only a redirect to the current 'this' object.");
|
|
136
|
+
return obj;
|
|
137
|
+
},
|
|
138
|
+
/** @deprecated */
|
|
139
|
+
set() {
|
|
140
|
+
deprecated('Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. obj setter has no effect.');
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
options: {
|
|
144
|
+
/** @deprecated */
|
|
145
|
+
get() {
|
|
146
|
+
deprecated('Layer.options is deprecated. Use the Layer.get("options") method instead.');
|
|
147
|
+
return obj.get('options');
|
|
148
|
+
},
|
|
149
|
+
set(newValue) {
|
|
150
|
+
deprecated('Layer.options is deprecated. Use the Layer.set("options", newValue) method instead.');
|
|
151
|
+
return obj.set('options', newValue);
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
parent: {
|
|
155
|
+
/** @deprecated */
|
|
156
|
+
get() {
|
|
157
|
+
deprecated("Layer.parent is deprecated. Use the Layer.get('parent') method instead.");
|
|
158
|
+
return obj.get('parent');
|
|
159
|
+
},
|
|
160
|
+
/** @deprecated */
|
|
161
|
+
set(newValue) {
|
|
162
|
+
deprecated("Layer.parent is deprecated. Use the Layer.set('parent', parent) method instead.");
|
|
163
|
+
obj.set('parent', newValue);
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
visible: {
|
|
167
|
+
/** @deprecated */
|
|
168
|
+
get() {
|
|
169
|
+
deprecated('Layer.visible is deprecated. Use the Layer.getVisible() method instead.');
|
|
170
|
+
return obj.getVisible();
|
|
171
|
+
},
|
|
172
|
+
/** @deprecated */
|
|
173
|
+
set(newValue) {
|
|
174
|
+
deprecated('Layer.visible is deprecated. Use the Layer.setVisible(newValue) method instead.');
|
|
175
|
+
obj.setVisible(newValue);
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
export default defineDeprecatedProperties;
|
|
@@ -19,11 +19,11 @@ const format = new GeoJSON();
|
|
|
19
19
|
*/
|
|
20
20
|
const getFeaturesFromWMS = (source, options, abortController) => {
|
|
21
21
|
let url;
|
|
22
|
-
const { coordinate,
|
|
22
|
+
const { coordinate, params, projection, resolution } = options;
|
|
23
23
|
if (source && resolution && projection) {
|
|
24
24
|
url = source.getFeatureInfoUrl(coordinate, resolution, projection, Object.assign({ info_format: 'application/json', query_layers: source.getParams().layers }, params));
|
|
25
25
|
}
|
|
26
|
-
// @ts-
|
|
26
|
+
// @ts-expect-error
|
|
27
27
|
return fetch(url, { signal: abortController.signal })
|
|
28
28
|
.then((resp) => resp.json())
|
|
29
29
|
.then((featureCollection) => format.readFeatures(featureCollection))
|
|
@@ -36,7 +36,7 @@ let abortControllers = {};
|
|
|
36
36
|
/**
|
|
37
37
|
* @private
|
|
38
38
|
*/
|
|
39
|
-
const getFeatureInfoAtCoordinate = (
|
|
39
|
+
const getFeatureInfoAtCoordinate = (coordinate_1, layers_1, ...args_1) => __awaiter(void 0, [coordinate_1, layers_1, ...args_1], void 0, function* (coordinate, layers, hitTolerance = 5) {
|
|
40
40
|
// Kill all previous requests
|
|
41
41
|
Object.values(abortControllers).forEach((abortController) => {
|
|
42
42
|
abortController === null || abortController === void 0 ? void 0 : abortController.abort();
|
|
@@ -47,21 +47,17 @@ const getFeatureInfoAtCoordinate = (coordinate, layers, hitTolerance = 5) => __a
|
|
|
47
47
|
var _a, _b, _c, _d;
|
|
48
48
|
const map = layer.getMapInternal();
|
|
49
49
|
const projection = (_b = (_a = map === null || map === void 0 ? void 0 : map.getView()) === null || _a === void 0 ? void 0 : _a.getProjection()) === null || _b === void 0 ? void 0 : _b.getCode();
|
|
50
|
-
const emptyResponse = { features: [], layer
|
|
50
|
+
const emptyResponse = { coordinate, features: [], layer };
|
|
51
51
|
if (!projection) {
|
|
52
52
|
return Promise.resolve(emptyResponse);
|
|
53
53
|
}
|
|
54
54
|
// For backward compatibility
|
|
55
|
-
// @ts-ignore
|
|
56
55
|
if (layer.getFeatureInfoAtCoordinate) {
|
|
57
|
-
return (
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
.getFeatureInfoAtCoordinate(coordinate));
|
|
56
|
+
return layer.getFeatureInfoAtCoordinate(coordinate);
|
|
60
57
|
}
|
|
61
58
|
// WMS sources
|
|
62
59
|
// Here we don't use instanceof, to be able to use this function if a layer comes from 2 different ol versions.
|
|
63
60
|
const source = layer === null || layer === void 0 ? void 0 : layer.getSource();
|
|
64
|
-
// @ts-ignore
|
|
65
61
|
if (source === null || source === void 0 ? void 0 : source.getFeatureInfoUrl) {
|
|
66
62
|
const id = getUid(layer);
|
|
67
63
|
// Abort and recreates one controller per layer
|
|
@@ -70,25 +66,25 @@ const getFeatureInfoAtCoordinate = (coordinate, layers, hitTolerance = 5) => __a
|
|
|
70
66
|
const resolution = (_d = map === null || map === void 0 ? void 0 : map.getView()) === null || _d === void 0 ? void 0 : _d.getResolution();
|
|
71
67
|
return getFeaturesFromWMS(source, {
|
|
72
68
|
coordinate,
|
|
73
|
-
resolution,
|
|
74
|
-
projection,
|
|
75
69
|
params: {
|
|
76
70
|
info_format: 'application/json',
|
|
77
71
|
query_layers: source.getParams().layers,
|
|
78
72
|
},
|
|
73
|
+
projection,
|
|
74
|
+
resolution,
|
|
79
75
|
}, abortControllers[id])
|
|
80
76
|
.then((features) => {
|
|
81
77
|
return {
|
|
78
|
+
coordinate,
|
|
82
79
|
features,
|
|
83
80
|
layer,
|
|
84
|
-
coordinate,
|
|
85
81
|
};
|
|
86
82
|
})
|
|
87
83
|
.catch(() => {
|
|
88
84
|
return {
|
|
85
|
+
coordinate,
|
|
89
86
|
features: [],
|
|
90
87
|
layer,
|
|
91
|
-
coordinate,
|
|
92
88
|
};
|
|
93
89
|
});
|
|
94
90
|
}
|
|
@@ -99,15 +95,13 @@ const getFeatureInfoAtCoordinate = (coordinate, layers, hitTolerance = 5) => __a
|
|
|
99
95
|
return Promise.resolve(emptyResponse);
|
|
100
96
|
}
|
|
101
97
|
const features = map === null || map === void 0 ? void 0 : map.getFeaturesAtPixel(pixel, {
|
|
98
|
+
hitTolerance: layer.get('hitTolerance') || hitTolerance || 5,
|
|
102
99
|
layerFilter: (l) => l === layer,
|
|
103
|
-
hitTolerance:
|
|
104
|
-
// @ts-ignore
|
|
105
|
-
layer.get('hitTolerance') || hitTolerance || 5,
|
|
106
100
|
});
|
|
107
101
|
return Promise.resolve({
|
|
102
|
+
coordinate,
|
|
108
103
|
features,
|
|
109
104
|
layer,
|
|
110
|
-
coordinate,
|
|
111
105
|
});
|
|
112
106
|
});
|
|
113
107
|
return Promise.all(promises);
|
package/package.json
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
"name": "mobility-toolbox-js",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"description": "Toolbox for JavaScript applications in the domains of mobility and logistics.",
|
|
5
|
-
"version": "3.0.0
|
|
5
|
+
"version": "3.0.0",
|
|
6
6
|
"homepage": "https://mobility-toolbox-js.geops.io/",
|
|
7
|
-
"module": "index.js",
|
|
8
7
|
"exports": {
|
|
9
8
|
".": "./index.js",
|
|
10
9
|
"./api": "./api/index.js",
|
|
@@ -13,32 +12,35 @@
|
|
|
13
12
|
"./types": "./types/index.d.ts"
|
|
14
13
|
},
|
|
15
14
|
"dependencies": {
|
|
16
|
-
"@
|
|
17
|
-
"@turf/
|
|
15
|
+
"@geoblocks/ol-maplibre-layer": "^1.0.2",
|
|
16
|
+
"@turf/helpers": "7.1.0",
|
|
17
|
+
"@turf/transform-rotate": "7.1.0",
|
|
18
18
|
"lodash.debounce": "4.0.8",
|
|
19
19
|
"lodash.throttle": "4.1.1",
|
|
20
|
-
"uuid": "
|
|
20
|
+
"uuid": "11.0.3"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"maplibre-gl": ">=
|
|
24
|
-
"ol": ">=
|
|
23
|
+
"maplibre-gl": ">=4",
|
|
24
|
+
"ol": ">=9"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@babel/preset-env": "^7.
|
|
28
|
-
"@babel/preset-typescript": "^7.
|
|
29
|
-
"@commitlint/cli": "19.0
|
|
30
|
-
"@commitlint/config-conventional": "19.0
|
|
27
|
+
"@babel/preset-env": "^7.26.0",
|
|
28
|
+
"@babel/preset-typescript": "^7.26.0",
|
|
29
|
+
"@commitlint/cli": "19.6.0",
|
|
30
|
+
"@commitlint/config-conventional": "19.6.0",
|
|
31
|
+
"@geops/eslint-config-react": "^1.3.2",
|
|
31
32
|
"@types/geojson": "7946.0.14",
|
|
33
|
+
"@types/lodash": "^4.17.13",
|
|
32
34
|
"@types/lodash.debounce": "4.0.9",
|
|
33
35
|
"@types/lodash.throttle": "4.1.9",
|
|
34
|
-
"@types/mapbox-gl": "3.1
|
|
36
|
+
"@types/mapbox-gl": "3.4.1",
|
|
35
37
|
"@types/offscreencanvas": "2019.7.3",
|
|
36
38
|
"@types/topojson": "3.2.6",
|
|
37
|
-
"@types/uuid": "
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "
|
|
39
|
-
"@typescript-eslint/parser": "
|
|
40
|
-
"cypress": "13.
|
|
41
|
-
"esbuild": "0.
|
|
39
|
+
"@types/uuid": "10.0.0",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "8.17.0",
|
|
41
|
+
"@typescript-eslint/parser": "8.17.0",
|
|
42
|
+
"cypress": "13.16.1",
|
|
43
|
+
"esbuild": "0.24.0",
|
|
42
44
|
"esdoc": "1.1.0",
|
|
43
45
|
"esdoc-ecmascript-proposal-plugin": "1.0.0",
|
|
44
46
|
"esdoc-publish-html-plugin": "1.1.2",
|
|
@@ -46,15 +48,15 @@
|
|
|
46
48
|
"esdoc-typescript-plugin": "1.0.1",
|
|
47
49
|
"eslint": "8.57.0",
|
|
48
50
|
"eslint-config-airbnb": "19.0.4",
|
|
49
|
-
"eslint-config-airbnb-typescript": "
|
|
51
|
+
"eslint-config-airbnb-typescript": "18.0.0",
|
|
50
52
|
"eslint-config-prettier": "9.1.0",
|
|
51
|
-
"eslint-plugin-cypress": "
|
|
52
|
-
"eslint-plugin-import": "2.
|
|
53
|
-
"eslint-plugin-jsx-a11y": "6.
|
|
54
|
-
"eslint-plugin-prettier": "5.1
|
|
55
|
-
"eslint-plugin-react": "7.
|
|
53
|
+
"eslint-plugin-cypress": "3.5.0",
|
|
54
|
+
"eslint-plugin-import": "2.31.0",
|
|
55
|
+
"eslint-plugin-jsx-a11y": "6.10.2",
|
|
56
|
+
"eslint-plugin-prettier": "5.2.1",
|
|
57
|
+
"eslint-plugin-react": "7.37.2",
|
|
56
58
|
"fixpack": "4.0.0",
|
|
57
|
-
"husky": "9.
|
|
59
|
+
"husky": "9.1.7",
|
|
58
60
|
"is-ci": "3.0.1",
|
|
59
61
|
"jest": "29.7.0",
|
|
60
62
|
"jest-canvas-mock": "2.5.2",
|
|
@@ -63,24 +65,25 @@
|
|
|
63
65
|
"jest-serializer-html": "7.1.0",
|
|
64
66
|
"jest-transformer-svg": "2.0.2",
|
|
65
67
|
"jest-websocket-mock": "2.5.0",
|
|
66
|
-
"lint-staged": "15.2.
|
|
67
|
-
"maplibre-gl": "4.
|
|
68
|
+
"lint-staged": "15.2.10",
|
|
69
|
+
"maplibre-gl": "4.7.1",
|
|
68
70
|
"mock-socket": "9.3.1",
|
|
69
|
-
"next": "
|
|
71
|
+
"next": "15.0.3",
|
|
70
72
|
"next-transpile-modules": "10.0.1",
|
|
71
|
-
"ol": "
|
|
72
|
-
"openapi-typescript": "6.7.
|
|
73
|
-
"prettier": "3.2
|
|
73
|
+
"ol": "10.3.1",
|
|
74
|
+
"openapi-typescript": "6.7.5",
|
|
75
|
+
"prettier": "3.4.2",
|
|
74
76
|
"raw-loader": "4.0.2",
|
|
75
77
|
"sort-json": "2.0.1",
|
|
76
78
|
"standard-version": "9.5.0",
|
|
77
|
-
"start-server-and-test": "2.0.
|
|
78
|
-
"stylelint": "16.
|
|
79
|
-
"stylelint-config-recommended-scss": "14.
|
|
80
|
-
"stylelint-config-standard": "36.0.
|
|
81
|
-
"stylelint-scss": "6.
|
|
82
|
-
"
|
|
83
|
-
"typescript": "5.
|
|
79
|
+
"start-server-and-test": "2.0.8",
|
|
80
|
+
"stylelint": "16.11.0",
|
|
81
|
+
"stylelint-config-recommended-scss": "14.1.0",
|
|
82
|
+
"stylelint-config-standard": "36.0.1",
|
|
83
|
+
"stylelint-scss": "6.10.0",
|
|
84
|
+
"ts-jest": "^29.2.5",
|
|
85
|
+
"typescript": "5.7.2",
|
|
86
|
+
"vite": "^6.0.2"
|
|
84
87
|
},
|
|
85
88
|
"scripts": {
|
|
86
89
|
"apidoc": "esdoc && cp apidoc/index.json doc/src/components/Esdoc",
|
|
@@ -93,21 +96,18 @@
|
|
|
93
96
|
"cy:test:chrome": "yarn build && start-server-and-test start http://localhost:3000 'cypress run --browser chrome'",
|
|
94
97
|
"cy:test:edge": "yarn build && start-server-and-test start http://localhost:3000 'cypress run --browser edge'",
|
|
95
98
|
"cy:test:firefox": "yarn build && start-server-and-test start http://localhost:3000 'cypress run --browser firefox'",
|
|
96
|
-
"dev": "
|
|
97
|
-
"dev:examples": "yarn clean && yarn build && cd doc && rm -rf node_modules/mobility-toolbox-js && yarn install --force && yarn dev",
|
|
99
|
+
"dev": "vite",
|
|
98
100
|
"doc": "yarn build && yarn apidoc && cd doc && rm -rf node_modules/mobility-toolbox-js && yarn install --force && yarn build",
|
|
101
|
+
"doc:dev": "yarn clean && yarn build && yarn apidoc && yarn doc:dev:examples",
|
|
102
|
+
"doc:dev:examples": "yarn clean && yarn build && cd doc && rm -rf node_modules/mobility-toolbox-js && yarn install --force && yarn dev",
|
|
99
103
|
"esbuild": "yarn esbuild:all && yarn esbuild:iife",
|
|
100
104
|
"esbuild:all": "esbuild src/index.js src/**/*.js src/**/*.ts src/**/**/*.js src/**/**/*.ts --target=chrome100 --outdir=build/ --loader:.js=jsx",
|
|
101
105
|
"esbuild:iife": "yarn esbuild:iife:unminify && yarn esbuild:iife:minify",
|
|
102
106
|
"esbuild:iife:base": "esbuild src/iife.js --bundle --sourcemap --target=chrome100",
|
|
103
107
|
"esbuild:iife:minify": "yarn esbuild:iife:base --minify --outfile=build/mbt.min.js",
|
|
104
108
|
"esbuild:iife:unminify": "yarn esbuild:iife:base --outfile=build/mbt.js",
|
|
105
|
-
"format": "prettier --write 'src/**/*.js' && eslint
|
|
106
|
-
"lib": "REACT_APP_LIB_MODE=1 webpack --mode production",
|
|
107
|
-
"lib:dev": "REACT_APP_LIB_MODE=1 webpack --mode development",
|
|
108
|
-
"link2": "cmdToAdd=$(node ./scripts/read-pkg-json.js add) && $cmdToAdd && yarn build && cmdToRemove=$(node ./scripts/read-pkg-json.js remove) && $cmdToRemove && cd build && yarn link",
|
|
109
|
+
"format": "prettier --write 'src/**/*.js' 'src/**/*.test.js' && eslint src/**/*.js src/**/*.test.js src/**/*.ts --fix && stylelint 'src/**/*.css' 'src/**/*.scss' --fix --allow-empty-input",
|
|
109
110
|
"lint": "eslint src/**/*.js src/**/*.ts && stylelint src/**/*.css src/**/*.scss --allow-empty-input",
|
|
110
|
-
"prepare": "is-ci || husky",
|
|
111
111
|
"publish:beta": "HUSKY=0 yarn release -- --prerelease beta --skip.changelog && yarn run build && cd build && HUSKY=0 yarn publish --tag beta && git push origin HEAD && git push --tags ",
|
|
112
112
|
"publish:beta:dryrun": "yarn release -- --prerelease beta --dry-run --skip.changelog",
|
|
113
113
|
"publish:public": "yarn release && yarn run build && cd build && HUSKY=0 yarn publish && git push origin HEAD && git push --tags ",
|
package/setupTests.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import 'jest-canvas-mock';
|
|
3
|
-
import fetchTrajectoryByIdResponse from '../data/fetchTrajectoryById.json';
|
|
1
|
+
import fetchRouteResponse from '../data/fetchRoute.json';
|
|
4
2
|
import fetchTrajectoriesResponse from '../data/fetchTrajectories.json';
|
|
3
|
+
import fetchTrajectoryByIdResponse from '../data/fetchTrajectoryById.json';
|
|
5
4
|
import fetchTrajectoryStationsResponse from '../data/fetchTrajectoryStations.json';
|
|
6
5
|
import stopsSearchResponse from '../data/stopsSearch.json';
|
|
7
|
-
import
|
|
6
|
+
import 'jest-canvas-mock';
|
|
8
7
|
global.fetchTrajectoryByIdResponse = fetchTrajectoryByIdResponse;
|
|
9
8
|
global.fetchTrajectoriesResponse = fetchTrajectoriesResponse;
|
|
10
9
|
global.fetchTrajectoryStationsResponse = fetchTrajectoryStationsResponse;
|
|
@@ -24,3 +23,17 @@ class ResizeObserver {
|
|
|
24
23
|
disconnect() { }
|
|
25
24
|
}
|
|
26
25
|
window.ResizeObserver = ResizeObserver;
|
|
26
|
+
window.noop = () => { };
|
|
27
|
+
class Worker {
|
|
28
|
+
constructor(stringUrl) {
|
|
29
|
+
this.url = stringUrl;
|
|
30
|
+
this.onmessage = noop;
|
|
31
|
+
}
|
|
32
|
+
postMessage(msg) {
|
|
33
|
+
this.onmessage(msg);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
Object.defineProperty(window, 'Worker', {
|
|
37
|
+
writable: true,
|
|
38
|
+
value: Worker,
|
|
39
|
+
});
|