@opengeoweb/store 9.24.0 → 9.25.2

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/index.esm.js CHANGED
@@ -10,7 +10,7 @@ import { useSelector, useDispatch, Provider } from 'react-redux';
10
10
  import { useCallback, useEffect } from 'react';
11
11
  import { createStore as createStore$1 } from '@redux-eggs/redux-toolkit';
12
12
  import { getSagaExtension } from '@redux-eggs/saga-extension';
13
- import { takeLatest, takeEvery, select, put, all, call as call$e, delay } from 'redux-saga/effects';
13
+ import { takeEvery, call as call$e, put, select, delay, all, takeLatest } from 'redux-saga/effects';
14
14
  import { metronome } from '@opengeoweb/metronome';
15
15
  import { jsx } from 'react/jsx-runtime';
16
16
 
@@ -1999,7 +1999,7 @@ var LayerActionOrigin;
1999
1999
  LayerActionOrigin["layerManager"] = "layerManager";
2000
2000
  LayerActionOrigin["wmsLoader"] = "WMSLayerTreeConnect";
2001
2001
  LayerActionOrigin["ReactMapViewParseLayer"] = "ReactMapViewParseLayer";
2002
- LayerActionOrigin["setLayerDimensionSaga"] = "setLayerDimensionSaga";
2002
+ LayerActionOrigin["updateLayerInformationListener"] = "updateLayerInformationListener";
2003
2003
  LayerActionOrigin["toggleAutoUpdateListener"] = "toggleAutoUpdateListener";
2004
2004
  LayerActionOrigin["unregisterMapSaga"] = "unregisterMapSaga";
2005
2005
  })(LayerActionOrigin || (LayerActionOrigin = {}));
@@ -7631,104 +7631,6 @@ const isAnimationEndTimeValid = animationEndTime => {
7631
7631
  const parsedDate = dateUtils.parseISO(animationEndTime);
7632
7632
  return dateUtils.isValid(parsedDate);
7633
7633
  };
7634
- function* deleteLayerSaga({
7635
- payload
7636
- }) {
7637
- const {
7638
- mapId
7639
- } = payload;
7640
- const layers = yield select(getMapLayersWithoutDimensionCurrentValue, mapId);
7641
- if (!layers.length) {
7642
- yield put(mapActions.mapStopAnimation({
7643
- mapId
7644
- }));
7645
- }
7646
- }
7647
- function* updateAnimation$1(mapId, maxValue) {
7648
- const shouldEndtimeOverride$1 = yield select(shouldEndtimeOverride, mapId);
7649
- if (shouldEndtimeOverride$1 === true) {
7650
- return;
7651
- }
7652
- const animationStart = yield select(getAnimationStartTime, mapId);
7653
- // Calculate how much time the animation start need to move forwards
7654
- const animationEnd = yield select(getAnimationEndTime, mapId);
7655
- const animationEndUnix = dateUtils.unix(dateUtils.utc(animationEnd));
7656
- const maxTimeAsUnix = dateUtils.unix(dateUtils.utc(maxValue));
7657
- const timeInSecondToShiftAnimationForwards = maxTimeAsUnix - animationEndUnix;
7658
- const animationStartUnix = dateUtils.unix(dateUtils.utc(animationStart));
7659
- const newAnimationStartTime = dateUtils.dateToString(dateUtils.fromUnix(animationStartUnix + timeInSecondToShiftAnimationForwards), dateFormat);
7660
- const newAnimationEndTime = dateUtils.dateToString(dateUtils.fromUnix(animationEndUnix + timeInSecondToShiftAnimationForwards), dateFormat);
7661
- if (!newAnimationStartTime || !newAnimationEndTime) {
7662
- return;
7663
- }
7664
- yield put(mapActions.setAnimationEndTime({
7665
- mapId,
7666
- animationEndTime: newAnimationEndTime
7667
- }));
7668
- yield put(mapActions.setAnimationStartTime({
7669
- mapId,
7670
- animationStartTime: newAnimationStartTime
7671
- }));
7672
- }
7673
- function* setLayerDimensionsSaga({
7674
- payload
7675
- }) {
7676
- try {
7677
- const {
7678
- layerDimensions
7679
- } = payload;
7680
- if (!layerDimensions) {
7681
- return;
7682
- }
7683
- const {
7684
- dimensions,
7685
- layerId
7686
- } = layerDimensions;
7687
- const layer = yield select(getLayerById, layerId);
7688
- if (!layer) {
7689
- return;
7690
- }
7691
- const newTimeDimension = dimensions.find(dimension => dimension.name === 'time');
7692
- const {
7693
- mapId
7694
- } = layer;
7695
- const autoUpdateLayerId = yield select(getAutoUpdateLayerId, mapId);
7696
- const shouldAutoUpdate = yield select(isAutoUpdating, mapId);
7697
- const prevTimeDimension = yield select(getLayerTimeDimension, layerId);
7698
- const isAutoUpdateLayer = layerId === autoUpdateLayerId;
7699
- const incomingMaxTime = newTimeDimension === null || newTimeDimension === void 0 ? void 0 : newTimeDimension.maxValue;
7700
- const isIncomingMaxTimeLaterThanCurrentLayerTime = incomingMaxTime && (prevTimeDimension === null || prevTimeDimension === void 0 ? void 0 : prevTimeDimension.currentValue) && prevTimeDimension.currentValue !== incomingMaxTime;
7701
- if (isAutoUpdateLayer &&
7702
- // only update the active layer
7703
- shouldAutoUpdate && isIncomingMaxTimeLaterThanCurrentLayerTime) {
7704
- const isMapAnimating = yield select(isAnimating, mapId);
7705
- if (!isMapAnimating) {
7706
- yield put(layerActions.layerChangeDimension({
7707
- layerId,
7708
- origin: LayerActionOrigin.setLayerDimensionSaga,
7709
- dimension: {
7710
- name: 'time',
7711
- currentValue: incomingMaxTime
7712
- }
7713
- }));
7714
- // Each time a layer updates, set the new time for all synced timesliders
7715
- const syncedMapIds = yield select(getSyncedMapIdsForTimeslider);
7716
- if (syncedMapIds) {
7717
- // Change time value for all other timesliders
7718
- yield all(syncedMapIds.map(syncedMapId => put(setTime({
7719
- origin: 'mapStore saga',
7720
- sourceId: syncedMapId,
7721
- value: incomingMaxTime
7722
- }))));
7723
- }
7724
- }
7725
- yield call$e(updateAnimation$1, mapId, incomingMaxTime);
7726
- }
7727
- } catch (error) {
7728
- // eslint-disable-next-line no-console
7729
- console.warn(error);
7730
- }
7731
- }
7732
7634
  function* handleBaseLayersSaga(mapId, baseLayers) {
7733
7635
  const baseLayer = baseLayers.find(layer => layer.layerType === 'baseLayer');
7734
7636
  const currentAvailableBaseLayers = yield select(getAvailableBaseLayersForMap, mapId);
@@ -8058,8 +7960,6 @@ function* setStepBackwardOrForwardSaga({
8058
7960
  }
8059
7961
  function* rootSaga$2() {
8060
7962
  // resets IWMJSMap state
8061
- yield takeLatest(layerActions.layerDelete.type, deleteLayerSaga);
8062
- yield takeLatest(layerActions.onUpdateLayerInformation.type, setLayerDimensionsSaga);
8063
7963
  yield takeEvery(mapActions.setMapPreset.type, setMapPresetSaga);
8064
7964
  yield takeEvery(mapActions.unregisterMap.type, unregisterMapSaga);
8065
7965
  yield takeEvery(mapActions.setStepBackwardOrForward.type, setStepBackwardOrForwardSaga);
@@ -8367,6 +8267,85 @@ mapUiListener.startListening({
8367
8267
  });
8368
8268
 
8369
8269
  const mapListener = createListenerMiddleware();
8270
+ mapListener.startListening({
8271
+ actionCreator: layerActions.layerDelete,
8272
+ effect: ({
8273
+ payload
8274
+ }, listenerApi) => {
8275
+ const {
8276
+ mapId
8277
+ } = payload;
8278
+ const layers = getMapLayersWithoutDimensionCurrentValue(listenerApi.getState(), mapId);
8279
+ if (!layers.length) {
8280
+ listenerApi.dispatch(mapActions.mapStopAnimation({
8281
+ mapId
8282
+ }));
8283
+ }
8284
+ }
8285
+ });
8286
+ // update layer, synced maps and animation on latest max time if autoupdating
8287
+ mapListener.startListening({
8288
+ actionCreator: layerActions.onUpdateLayerInformation,
8289
+ effect: ({
8290
+ payload
8291
+ }, listenerApi) => {
8292
+ try {
8293
+ const {
8294
+ layerDimensions
8295
+ } = payload;
8296
+ if (!layerDimensions) {
8297
+ return;
8298
+ }
8299
+ const {
8300
+ dimensions,
8301
+ layerId
8302
+ } = layerDimensions;
8303
+ const layer = getLayerById(listenerApi.getState(), layerId);
8304
+ if (!layer) {
8305
+ return;
8306
+ }
8307
+ const newTimeDimension = dimensions.find(dimension => dimension.name === 'time');
8308
+ const {
8309
+ mapId
8310
+ } = layer;
8311
+ const autoUpdateLayerId = getAutoUpdateLayerId(listenerApi.getState(), mapId);
8312
+ const shouldAutoUpdate = isAutoUpdating(listenerApi.getState(), mapId);
8313
+ const prevTimeDimension = getLayerTimeDimension(listenerApi.getState(), layerId);
8314
+ const isAutoUpdateLayer = layerId === autoUpdateLayerId;
8315
+ const incomingMaxTime = newTimeDimension === null || newTimeDimension === void 0 ? void 0 : newTimeDimension.maxValue;
8316
+ const isIncomingMaxTimeLaterThanCurrentLayerTime = incomingMaxTime && (prevTimeDimension === null || prevTimeDimension === void 0 ? void 0 : prevTimeDimension.currentValue) && prevTimeDimension.currentValue !== incomingMaxTime;
8317
+ if (isAutoUpdateLayer &&
8318
+ // only update the active layer
8319
+ shouldAutoUpdate && isIncomingMaxTimeLaterThanCurrentLayerTime) {
8320
+ const isMapAnimating = isAnimating(listenerApi.getState(), mapId);
8321
+ if (!isMapAnimating) {
8322
+ listenerApi.dispatch(layerActions.layerChangeDimension({
8323
+ layerId,
8324
+ origin: LayerActionOrigin.updateLayerInformationListener,
8325
+ dimension: {
8326
+ name: 'time',
8327
+ currentValue: incomingMaxTime
8328
+ }
8329
+ }));
8330
+ // Each time a layer updates, set the new time for all synced timesliders
8331
+ const syncedMapIds = getSyncedMapIdsForTimeslider(listenerApi.getState());
8332
+ if (syncedMapIds) {
8333
+ // Change time value for all other timesliders
8334
+ syncedMapIds.map(syncedMapId => listenerApi.dispatch(setTime({
8335
+ origin: LayerActionOrigin.updateLayerInformationListener,
8336
+ sourceId: syncedMapId,
8337
+ value: incomingMaxTime
8338
+ })));
8339
+ }
8340
+ }
8341
+ updateAnimation(mapId, incomingMaxTime, listenerApi);
8342
+ }
8343
+ } catch (error) {
8344
+ // eslint-disable-next-line no-console
8345
+ console.warn(error);
8346
+ }
8347
+ }
8348
+ });
8370
8349
  const updateAnimation = (mapId, maxValue, listenerApi) => {
8371
8350
  const shouldEndtimeOverride$1 = shouldEndtimeOverride(listenerApi.getState(), mapId);
8372
8351
  if (shouldEndtimeOverride$1 === true) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/store",
3
- "version": "9.24.0",
3
+ "version": "9.25.2",
4
4
  "description": "GeoWeb Store library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -13,7 +13,7 @@ export declare enum LayerActionOrigin {
13
13
  layerManager = "layerManager",
14
14
  wmsLoader = "WMSLayerTreeConnect",
15
15
  ReactMapViewParseLayer = "ReactMapViewParseLayer",
16
- setLayerDimensionSaga = "setLayerDimensionSaga",
16
+ updateLayerInformationListener = "updateLayerInformationListener",
17
17
  toggleAutoUpdateListener = "toggleAutoUpdateListener",
18
18
  unregisterMapSaga = "unregisterMapSaga"
19
19
  }
@@ -1,12 +1,9 @@
1
1
  import { SagaIterator } from 'redux-saga';
2
2
  import { mapActions } from '.';
3
- import { layerActions } from '../layers';
4
3
  import { Layer } from '../layers/types';
5
4
  export declare const getAnimationEndTime: (animationEndTime: string) => string;
6
5
  export declare const isAnimationEndTimeValid: (animationEndTime: string) => boolean;
7
- export declare function deleteLayerSaga({ payload, }: ReturnType<typeof layerActions.layerDelete>): SagaIterator;
8
6
  export declare function updateAnimation(mapId: string, maxValue: string): SagaIterator;
9
- export declare function setLayerDimensionsSaga({ payload, }: ReturnType<typeof layerActions.onUpdateLayerInformation>): SagaIterator;
10
7
  export declare function handleBaseLayersSaga(mapId: string, baseLayers: Layer[]): SagaIterator;
11
8
  export declare function setMapPresetSaga({ payload, }: ReturnType<typeof mapActions.setMapPreset>): SagaIterator;
12
9
  export declare function unregisterMapSaga({ payload, }: ReturnType<typeof mapActions.unregisterMap>): Generator;