@overmap-ai/core 1.0.65-mapbox.0 → 1.0.65-strip-workspace-access.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/dist/constants/offline.d.ts +1 -1
- package/dist/overmap-core.js +73 -65
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +71 -63
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/typings/models/geo.d.ts +3 -3
- package/dist/typings/models/issues.d.ts +0 -1
- package/dist/utils/coordinates.d.ts +18 -4
- package/dist/utils/utils.d.ts +7 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const OUTBOX_RETRY_DELAY =
|
|
1
|
+
export declare const OUTBOX_RETRY_DELAY = 60000;
|
package/dist/overmap-core.js
CHANGED
|
@@ -11,7 +11,7 @@ import { offline as offline$1 } from "@redux-offline/redux-offline";
|
|
|
11
11
|
import offlineConfig from "@redux-offline/redux-offline/lib/defaults";
|
|
12
12
|
import localforage from "localforage";
|
|
13
13
|
import createMigration from "redux-persist-migrate";
|
|
14
|
-
import { createSlice, createSelector, combineReducers
|
|
14
|
+
import { createSlice, createSelector, combineReducers } from "@reduxjs/toolkit";
|
|
15
15
|
import request from "superagent";
|
|
16
16
|
import { saveAs } from "file-saver";
|
|
17
17
|
import React, { useRef, useEffect } from "react";
|
|
@@ -409,21 +409,70 @@ const { setTokens, clearTokens, setLoggedIn } = authSlice.actions;
|
|
|
409
409
|
const selectAccessToken = (state) => state.authReducer.accessToken;
|
|
410
410
|
const selectIsLoggedIn = (state) => state.authReducer.isLoggedIn;
|
|
411
411
|
const authReducer = authSlice.reducer;
|
|
412
|
-
const
|
|
412
|
+
const coordinatesToLiteral = (coordinates) => {
|
|
413
|
+
return { lng: coordinates[0], lat: coordinates[1] };
|
|
414
|
+
};
|
|
415
|
+
const literalToCoordinates = (literal) => {
|
|
416
|
+
return [literal.lng, literal.lat];
|
|
417
|
+
};
|
|
418
|
+
const flipCoordinates = (coordinates) => {
|
|
419
|
+
return [coordinates[1], coordinates[0]];
|
|
420
|
+
};
|
|
421
|
+
const flipBounds = (bounds) => {
|
|
422
|
+
return [flipCoordinates(bounds[0]), flipCoordinates(bounds[1])];
|
|
423
|
+
};
|
|
424
|
+
function offsetPositionByMeters(originalPosition, latMeters, lngMeters) {
|
|
425
|
+
const { lat, lng } = originalPosition;
|
|
426
|
+
const earthRadius = 6378137;
|
|
427
|
+
const metersPerDegree = 2 * Math.PI * earthRadius / 360;
|
|
428
|
+
const newLng = lng + lngMeters / metersPerDegree / Math.cos(lat * Math.PI / 180);
|
|
429
|
+
const newLat = lat - latMeters / metersPerDegree;
|
|
430
|
+
return { lat: newLat, lng: newLng };
|
|
431
|
+
}
|
|
432
|
+
const createPointGeometry = (coordinates) => {
|
|
413
433
|
return {
|
|
414
434
|
type: "Point",
|
|
415
|
-
coordinates
|
|
435
|
+
coordinates
|
|
416
436
|
};
|
|
417
437
|
};
|
|
438
|
+
const coordinatesAreEqual = (a, b) => {
|
|
439
|
+
return a[0] === b[0] && a[1] === b[1];
|
|
440
|
+
};
|
|
441
|
+
const coordinatesToText = (coordinates, decimalPlaces) => {
|
|
442
|
+
if (!coordinates)
|
|
443
|
+
return "(No Location)";
|
|
444
|
+
const { lat, lng } = coordinatesToLiteral(coordinates);
|
|
445
|
+
if (decimalPlaces)
|
|
446
|
+
return `${lat.toFixed(decimalPlaces)}, ${lng.toFixed(decimalPlaces)}`;
|
|
447
|
+
return `${lat}, ${lng}`;
|
|
448
|
+
};
|
|
449
|
+
const coordinatesToUrlText = (coordinates) => {
|
|
450
|
+
const { lat, lng } = coordinatesToLiteral(coordinates);
|
|
451
|
+
return `${lat}%2C${lng}`;
|
|
452
|
+
};
|
|
453
|
+
const openCoordsInGoogleMaps = (coordinates) => {
|
|
454
|
+
const url = `https://www.google.com/maps/search/?api=1&query=${coordinatesToUrlText(coordinates)}`;
|
|
455
|
+
window.open(url);
|
|
456
|
+
};
|
|
457
|
+
const openDirectionsInGoogleMaps = (startingPoint, destination) => {
|
|
458
|
+
const startingPointUrl = coordinatesToUrlText(startingPoint);
|
|
459
|
+
const destinationUrl = coordinatesToUrlText(destination);
|
|
460
|
+
const url = `https://www.google.com/maps/dir/?api=1&origin=${startingPointUrl}&destination=${destinationUrl}`;
|
|
461
|
+
window.open(url);
|
|
462
|
+
};
|
|
463
|
+
const worldBounds = {
|
|
464
|
+
type: "MultiPoint",
|
|
465
|
+
coordinates: [
|
|
466
|
+
[90, -180],
|
|
467
|
+
[-90, 180]
|
|
468
|
+
]
|
|
469
|
+
};
|
|
418
470
|
const createMultiPointGeometry = (coordinates) => {
|
|
419
471
|
return {
|
|
420
472
|
type: "MultiPoint",
|
|
421
473
|
coordinates
|
|
422
474
|
};
|
|
423
475
|
};
|
|
424
|
-
const coordinatesAreEqual = (a, b) => {
|
|
425
|
-
return a[0] === b[0] && a[1] === b[1];
|
|
426
|
-
};
|
|
427
476
|
function classNames(...args) {
|
|
428
477
|
const classes = [];
|
|
429
478
|
for (const arg of args) {
|
|
@@ -601,11 +650,14 @@ function onlyUniqueHashes(value, index, self) {
|
|
|
601
650
|
return v.file_sha1 === value.file_sha1;
|
|
602
651
|
}) === index;
|
|
603
652
|
}
|
|
653
|
+
function boundsContainPoint(bounds, coordinates) {
|
|
654
|
+
return bounds[0][0] > coordinates[0] && bounds[1][0] < coordinates[0] && bounds[0][1] > coordinates[1] && bounds[1][1] < coordinates[1];
|
|
655
|
+
}
|
|
604
656
|
const emailRegex = /^.+@.+\..+$/;
|
|
605
657
|
const fullAssetMarkerSize = 45;
|
|
606
658
|
const DEFAULT_ISSUE_STATUS = IssueStatus.BACKLOG;
|
|
607
659
|
const DEFAULT_ISSUE_PRIORITY = IssuePriority.MEDIUM;
|
|
608
|
-
const OUTBOX_RETRY_DELAY =
|
|
660
|
+
const OUTBOX_RETRY_DELAY = 6e4;
|
|
609
661
|
const EMPTY_ARRAY = Object.freeze([]);
|
|
610
662
|
let debug = false;
|
|
611
663
|
const REACT_APP_DEBUG_MEMOIZATION = {}.REACT_APP_DEBUG_MEMOIZATION || "";
|
|
@@ -3372,62 +3424,11 @@ const overmapReducers = {
|
|
|
3372
3424
|
};
|
|
3373
3425
|
const overmapReducer = combineReducers(overmapReducers);
|
|
3374
3426
|
const resetStore = "RESET";
|
|
3375
|
-
function handleWorkspaceRemoval(draft, action) {
|
|
3376
|
-
const workspaceId = action.payload;
|
|
3377
|
-
const issuesVisibleInWorkspace = Object.values(draft.issueReducer.instances).filter(
|
|
3378
|
-
(issue) => issue.visible_in_workspaces.includes(workspaceId)
|
|
3379
|
-
);
|
|
3380
|
-
const mainWorkspace = selectMainWorkspace(draft);
|
|
3381
|
-
if (!mainWorkspace) {
|
|
3382
|
-
throw new Error("Main workspace not found");
|
|
3383
|
-
}
|
|
3384
|
-
if (action.payload === mainWorkspace.offline_id) {
|
|
3385
|
-
throw new Error("Tried to delete main workspace");
|
|
3386
|
-
}
|
|
3387
|
-
const categoriesInThisWorkspace = new Set(
|
|
3388
|
-
selectCategoriesOfWorkspace(workspaceId)(draft).map((category) => category.offline_id)
|
|
3389
|
-
);
|
|
3390
|
-
for (const issue of issuesVisibleInWorkspace) {
|
|
3391
|
-
if (issue.category && categoriesInThisWorkspace.has(issue.category)) {
|
|
3392
|
-
issue.category = null;
|
|
3393
|
-
}
|
|
3394
|
-
}
|
|
3395
|
-
const issuesWithThisWorkspaceIndex = issuesVisibleInWorkspace.filter(
|
|
3396
|
-
(issue) => issue.index_workspace === action.payload
|
|
3397
|
-
);
|
|
3398
|
-
for (const issue of issuesWithThisWorkspaceIndex) {
|
|
3399
|
-
issue.index_workspace = mainWorkspace.offline_id;
|
|
3400
|
-
if (!issue.visible_in_workspaces.includes(mainWorkspace.offline_id)) {
|
|
3401
|
-
issue.visible_in_workspaces.push(mainWorkspace.offline_id);
|
|
3402
|
-
}
|
|
3403
|
-
}
|
|
3404
|
-
for (const issue of issuesVisibleInWorkspace) {
|
|
3405
|
-
const indexOfWorkspace = issue.visible_in_workspaces.indexOf(workspaceId);
|
|
3406
|
-
if (indexOfWorkspace === -1) {
|
|
3407
|
-
throw new Error("Workspace not found in issue's visible_in_workspaces");
|
|
3408
|
-
}
|
|
3409
|
-
issue.visible_in_workspaces.splice(indexOfWorkspace, 1);
|
|
3410
|
-
}
|
|
3411
|
-
for (const issue of issuesVisibleInWorkspace) {
|
|
3412
|
-
if (issue.visible_in_workspaces.length === 0) {
|
|
3413
|
-
throw new Error(`Unexpected error: Issue ${issue.offline_id} has no visible_in_workspaces`);
|
|
3414
|
-
}
|
|
3415
|
-
if (issue.index_workspace === action.payload || !issue.index_workspace) {
|
|
3416
|
-
throw new Error(`Failed to update index_workspace of issue ${issue.offline_id} to main workspace`);
|
|
3417
|
-
}
|
|
3418
|
-
}
|
|
3419
|
-
}
|
|
3420
3427
|
const overmapRootReducer = (state, action) => {
|
|
3421
3428
|
if (action.type === "auth/setLoggedIn" && !action.payload) {
|
|
3422
3429
|
return overmapReducer(void 0, action);
|
|
3423
3430
|
}
|
|
3424
|
-
|
|
3425
|
-
if (state && action.type === "workspace/removeWorkspace") {
|
|
3426
|
-
mutatedState = createNextState(state, (draft) => {
|
|
3427
|
-
handleWorkspaceRemoval(draft, action);
|
|
3428
|
-
});
|
|
3429
|
-
}
|
|
3430
|
-
return overmapReducer(mutatedState, action);
|
|
3431
|
+
return overmapReducer(state, action);
|
|
3431
3432
|
};
|
|
3432
3433
|
let __OUTBOX_COORDINATOR = null;
|
|
3433
3434
|
function getOutboxCoordinator() {
|
|
@@ -4931,11 +4932,7 @@ class IssueService extends BaseApiService {
|
|
|
4931
4932
|
...issueType ? { issue_type: issueType } : {}
|
|
4932
4933
|
},
|
|
4933
4934
|
payload: issuePayload,
|
|
4934
|
-
blockers: [
|
|
4935
|
-
"add-issue",
|
|
4936
|
-
...issuePayload.index_workspace ? [issuePayload.index_workspace] : [],
|
|
4937
|
-
...issuePayload.visible_in_workspaces
|
|
4938
|
-
],
|
|
4935
|
+
blockers: ["add-issue", ...issuePayload.index_workspace ? [issuePayload.index_workspace] : []],
|
|
4939
4936
|
blocks: [issuePayload.offline_id]
|
|
4940
4937
|
});
|
|
4941
4938
|
void promise.then((result) => {
|
|
@@ -7637,6 +7634,7 @@ export {
|
|
|
7637
7634
|
authReducer,
|
|
7638
7635
|
authSlice,
|
|
7639
7636
|
blobToBase64,
|
|
7637
|
+
boundsContainPoint,
|
|
7640
7638
|
categoryReducer,
|
|
7641
7639
|
categorySlice,
|
|
7642
7640
|
classNames,
|
|
@@ -7644,6 +7642,9 @@ export {
|
|
|
7644
7642
|
clearTokens,
|
|
7645
7643
|
constructUploadedFilePayloads,
|
|
7646
7644
|
coordinatesAreEqual,
|
|
7645
|
+
coordinatesToLiteral,
|
|
7646
|
+
coordinatesToText,
|
|
7647
|
+
coordinatesToUrlText,
|
|
7647
7648
|
createMultiPointGeometry,
|
|
7648
7649
|
createOfflineAction,
|
|
7649
7650
|
createPointGeometry,
|
|
@@ -7706,6 +7707,8 @@ export {
|
|
|
7706
7707
|
fileReducer,
|
|
7707
7708
|
fileSlice,
|
|
7708
7709
|
fileToBlob,
|
|
7710
|
+
flipBounds,
|
|
7711
|
+
flipCoordinates,
|
|
7709
7712
|
formReducer,
|
|
7710
7713
|
formRevisionAttachmentReducer,
|
|
7711
7714
|
formRevisionAttachmentSlice,
|
|
@@ -7772,14 +7775,18 @@ export {
|
|
|
7772
7775
|
issueUpdateSlice,
|
|
7773
7776
|
licenseReducer,
|
|
7774
7777
|
licenseSlice,
|
|
7778
|
+
literalToCoordinates,
|
|
7775
7779
|
logOnlyOnce,
|
|
7776
7780
|
markAsDeleted,
|
|
7777
7781
|
markForDeletion,
|
|
7778
7782
|
memoize,
|
|
7779
7783
|
moveDocument,
|
|
7780
7784
|
offline,
|
|
7785
|
+
offsetPositionByMeters,
|
|
7781
7786
|
onlyUniqueHashes,
|
|
7782
7787
|
onlyUniqueOfflineIds,
|
|
7788
|
+
openCoordsInGoogleMaps,
|
|
7789
|
+
openDirectionsInGoogleMaps,
|
|
7783
7790
|
organizationAccessReducer,
|
|
7784
7791
|
organizationAccessSlice,
|
|
7785
7792
|
organizationReducer,
|
|
@@ -8094,6 +8101,7 @@ export {
|
|
|
8094
8101
|
versioningSlice,
|
|
8095
8102
|
warningColor,
|
|
8096
8103
|
workspaceReducer,
|
|
8097
|
-
workspaceSlice
|
|
8104
|
+
workspaceSlice,
|
|
8105
|
+
worldBounds
|
|
8098
8106
|
};
|
|
8099
8107
|
//# sourceMappingURL=overmap-core.js.map
|