@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.
@@ -397,21 +397,70 @@ var __publicField = (obj, key, value) => {
397
397
  const selectAccessToken = (state) => state.authReducer.accessToken;
398
398
  const selectIsLoggedIn = (state) => state.authReducer.isLoggedIn;
399
399
  const authReducer = authSlice.reducer;
400
- const createPointGeometry = (position) => {
400
+ const coordinatesToLiteral = (coordinates) => {
401
+ return { lng: coordinates[0], lat: coordinates[1] };
402
+ };
403
+ const literalToCoordinates = (literal) => {
404
+ return [literal.lng, literal.lat];
405
+ };
406
+ const flipCoordinates = (coordinates) => {
407
+ return [coordinates[1], coordinates[0]];
408
+ };
409
+ const flipBounds = (bounds) => {
410
+ return [flipCoordinates(bounds[0]), flipCoordinates(bounds[1])];
411
+ };
412
+ function offsetPositionByMeters(originalPosition, latMeters, lngMeters) {
413
+ const { lat, lng } = originalPosition;
414
+ const earthRadius = 6378137;
415
+ const metersPerDegree = 2 * Math.PI * earthRadius / 360;
416
+ const newLng = lng + lngMeters / metersPerDegree / Math.cos(lat * Math.PI / 180);
417
+ const newLat = lat - latMeters / metersPerDegree;
418
+ return { lat: newLat, lng: newLng };
419
+ }
420
+ const createPointGeometry = (coordinates) => {
401
421
  return {
402
422
  type: "Point",
403
- coordinates: position
423
+ coordinates
404
424
  };
405
425
  };
426
+ const coordinatesAreEqual = (a, b) => {
427
+ return a[0] === b[0] && a[1] === b[1];
428
+ };
429
+ const coordinatesToText = (coordinates, decimalPlaces) => {
430
+ if (!coordinates)
431
+ return "(No Location)";
432
+ const { lat, lng } = coordinatesToLiteral(coordinates);
433
+ if (decimalPlaces)
434
+ return `${lat.toFixed(decimalPlaces)}, ${lng.toFixed(decimalPlaces)}`;
435
+ return `${lat}, ${lng}`;
436
+ };
437
+ const coordinatesToUrlText = (coordinates) => {
438
+ const { lat, lng } = coordinatesToLiteral(coordinates);
439
+ return `${lat}%2C${lng}`;
440
+ };
441
+ const openCoordsInGoogleMaps = (coordinates) => {
442
+ const url = `https://www.google.com/maps/search/?api=1&query=${coordinatesToUrlText(coordinates)}`;
443
+ window.open(url);
444
+ };
445
+ const openDirectionsInGoogleMaps = (startingPoint, destination) => {
446
+ const startingPointUrl = coordinatesToUrlText(startingPoint);
447
+ const destinationUrl = coordinatesToUrlText(destination);
448
+ const url = `https://www.google.com/maps/dir/?api=1&origin=${startingPointUrl}&destination=${destinationUrl}`;
449
+ window.open(url);
450
+ };
451
+ const worldBounds = {
452
+ type: "MultiPoint",
453
+ coordinates: [
454
+ [90, -180],
455
+ [-90, 180]
456
+ ]
457
+ };
406
458
  const createMultiPointGeometry = (coordinates) => {
407
459
  return {
408
460
  type: "MultiPoint",
409
461
  coordinates
410
462
  };
411
463
  };
412
- const coordinatesAreEqual = (a, b) => {
413
- return a[0] === b[0] && a[1] === b[1];
414
- };
415
464
  function classNames(...args) {
416
465
  const classes = [];
417
466
  for (const arg of args) {
@@ -589,11 +638,14 @@ var __publicField = (obj, key, value) => {
589
638
  return v.file_sha1 === value.file_sha1;
590
639
  }) === index;
591
640
  }
641
+ function boundsContainPoint(bounds, coordinates) {
642
+ return bounds[0][0] > coordinates[0] && bounds[1][0] < coordinates[0] && bounds[0][1] > coordinates[1] && bounds[1][1] < coordinates[1];
643
+ }
592
644
  const emailRegex = /^.+@.+\..+$/;
593
645
  const fullAssetMarkerSize = 45;
594
646
  const DEFAULT_ISSUE_STATUS = IssueStatus.BACKLOG;
595
647
  const DEFAULT_ISSUE_PRIORITY = IssuePriority.MEDIUM;
596
- const OUTBOX_RETRY_DELAY = 5e3;
648
+ const OUTBOX_RETRY_DELAY = 6e4;
597
649
  const EMPTY_ARRAY = Object.freeze([]);
598
650
  let debug = false;
599
651
  const REACT_APP_DEBUG_MEMOIZATION = {}.REACT_APP_DEBUG_MEMOIZATION || "";
@@ -3360,62 +3412,11 @@ var __publicField = (obj, key, value) => {
3360
3412
  };
3361
3413
  const overmapReducer = toolkit.combineReducers(overmapReducers);
3362
3414
  const resetStore = "RESET";
3363
- function handleWorkspaceRemoval(draft, action) {
3364
- const workspaceId = action.payload;
3365
- const issuesVisibleInWorkspace = Object.values(draft.issueReducer.instances).filter(
3366
- (issue) => issue.visible_in_workspaces.includes(workspaceId)
3367
- );
3368
- const mainWorkspace = selectMainWorkspace(draft);
3369
- if (!mainWorkspace) {
3370
- throw new Error("Main workspace not found");
3371
- }
3372
- if (action.payload === mainWorkspace.offline_id) {
3373
- throw new Error("Tried to delete main workspace");
3374
- }
3375
- const categoriesInThisWorkspace = new Set(
3376
- selectCategoriesOfWorkspace(workspaceId)(draft).map((category) => category.offline_id)
3377
- );
3378
- for (const issue of issuesVisibleInWorkspace) {
3379
- if (issue.category && categoriesInThisWorkspace.has(issue.category)) {
3380
- issue.category = null;
3381
- }
3382
- }
3383
- const issuesWithThisWorkspaceIndex = issuesVisibleInWorkspace.filter(
3384
- (issue) => issue.index_workspace === action.payload
3385
- );
3386
- for (const issue of issuesWithThisWorkspaceIndex) {
3387
- issue.index_workspace = mainWorkspace.offline_id;
3388
- if (!issue.visible_in_workspaces.includes(mainWorkspace.offline_id)) {
3389
- issue.visible_in_workspaces.push(mainWorkspace.offline_id);
3390
- }
3391
- }
3392
- for (const issue of issuesVisibleInWorkspace) {
3393
- const indexOfWorkspace = issue.visible_in_workspaces.indexOf(workspaceId);
3394
- if (indexOfWorkspace === -1) {
3395
- throw new Error("Workspace not found in issue's visible_in_workspaces");
3396
- }
3397
- issue.visible_in_workspaces.splice(indexOfWorkspace, 1);
3398
- }
3399
- for (const issue of issuesVisibleInWorkspace) {
3400
- if (issue.visible_in_workspaces.length === 0) {
3401
- throw new Error(`Unexpected error: Issue ${issue.offline_id} has no visible_in_workspaces`);
3402
- }
3403
- if (issue.index_workspace === action.payload || !issue.index_workspace) {
3404
- throw new Error(`Failed to update index_workspace of issue ${issue.offline_id} to main workspace`);
3405
- }
3406
- }
3407
- }
3408
3415
  const overmapRootReducer = (state, action) => {
3409
3416
  if (action.type === "auth/setLoggedIn" && !action.payload) {
3410
3417
  return overmapReducer(void 0, action);
3411
3418
  }
3412
- let mutatedState = state;
3413
- if (state && action.type === "workspace/removeWorkspace") {
3414
- mutatedState = toolkit.createNextState(state, (draft) => {
3415
- handleWorkspaceRemoval(draft, action);
3416
- });
3417
- }
3418
- return overmapReducer(mutatedState, action);
3419
+ return overmapReducer(state, action);
3419
3420
  };
3420
3421
  let __OUTBOX_COORDINATOR = null;
3421
3422
  function getOutboxCoordinator() {
@@ -4919,11 +4920,7 @@ var __publicField = (obj, key, value) => {
4919
4920
  ...issueType ? { issue_type: issueType } : {}
4920
4921
  },
4921
4922
  payload: issuePayload,
4922
- blockers: [
4923
- "add-issue",
4924
- ...issuePayload.index_workspace ? [issuePayload.index_workspace] : [],
4925
- ...issuePayload.visible_in_workspaces
4926
- ],
4923
+ blockers: ["add-issue", ...issuePayload.index_workspace ? [issuePayload.index_workspace] : []],
4927
4924
  blocks: [issuePayload.offline_id]
4928
4925
  });
4929
4926
  void promise.then((result) => {
@@ -7624,6 +7621,7 @@ var __publicField = (obj, key, value) => {
7624
7621
  exports2.authReducer = authReducer;
7625
7622
  exports2.authSlice = authSlice;
7626
7623
  exports2.blobToBase64 = blobToBase64;
7624
+ exports2.boundsContainPoint = boundsContainPoint;
7627
7625
  exports2.categoryReducer = categoryReducer;
7628
7626
  exports2.categorySlice = categorySlice;
7629
7627
  exports2.classNames = classNames;
@@ -7631,6 +7629,9 @@ var __publicField = (obj, key, value) => {
7631
7629
  exports2.clearTokens = clearTokens;
7632
7630
  exports2.constructUploadedFilePayloads = constructUploadedFilePayloads;
7633
7631
  exports2.coordinatesAreEqual = coordinatesAreEqual;
7632
+ exports2.coordinatesToLiteral = coordinatesToLiteral;
7633
+ exports2.coordinatesToText = coordinatesToText;
7634
+ exports2.coordinatesToUrlText = coordinatesToUrlText;
7634
7635
  exports2.createMultiPointGeometry = createMultiPointGeometry;
7635
7636
  exports2.createOfflineAction = createOfflineAction;
7636
7637
  exports2.createPointGeometry = createPointGeometry;
@@ -7693,6 +7694,8 @@ var __publicField = (obj, key, value) => {
7693
7694
  exports2.fileReducer = fileReducer;
7694
7695
  exports2.fileSlice = fileSlice;
7695
7696
  exports2.fileToBlob = fileToBlob;
7697
+ exports2.flipBounds = flipBounds;
7698
+ exports2.flipCoordinates = flipCoordinates;
7696
7699
  exports2.formReducer = formReducer;
7697
7700
  exports2.formRevisionAttachmentReducer = formRevisionAttachmentReducer;
7698
7701
  exports2.formRevisionAttachmentSlice = formRevisionAttachmentSlice;
@@ -7759,14 +7762,18 @@ var __publicField = (obj, key, value) => {
7759
7762
  exports2.issueUpdateSlice = issueUpdateSlice;
7760
7763
  exports2.licenseReducer = licenseReducer;
7761
7764
  exports2.licenseSlice = licenseSlice;
7765
+ exports2.literalToCoordinates = literalToCoordinates;
7762
7766
  exports2.logOnlyOnce = logOnlyOnce;
7763
7767
  exports2.markAsDeleted = markAsDeleted;
7764
7768
  exports2.markForDeletion = markForDeletion;
7765
7769
  exports2.memoize = memoize;
7766
7770
  exports2.moveDocument = moveDocument;
7767
7771
  exports2.offline = offline;
7772
+ exports2.offsetPositionByMeters = offsetPositionByMeters;
7768
7773
  exports2.onlyUniqueHashes = onlyUniqueHashes;
7769
7774
  exports2.onlyUniqueOfflineIds = onlyUniqueOfflineIds;
7775
+ exports2.openCoordsInGoogleMaps = openCoordsInGoogleMaps;
7776
+ exports2.openDirectionsInGoogleMaps = openDirectionsInGoogleMaps;
7770
7777
  exports2.organizationAccessReducer = organizationAccessReducer;
7771
7778
  exports2.organizationAccessSlice = organizationAccessSlice;
7772
7779
  exports2.organizationReducer = organizationReducer;
@@ -8082,6 +8089,7 @@ var __publicField = (obj, key, value) => {
8082
8089
  exports2.warningColor = warningColor;
8083
8090
  exports2.workspaceReducer = workspaceReducer;
8084
8091
  exports2.workspaceSlice = workspaceSlice;
8092
+ exports2.worldBounds = worldBounds;
8085
8093
  Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
8086
8094
  });
8087
8095
  //# sourceMappingURL=overmap-core.umd.cjs.map