@mountaya/studio 0.0.0-stage → 0.2.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/CHANGELOG.md +69 -0
- package/LICENCE.fr.txt +280 -0
- package/LICENSE.txt +262 -0
- package/README.md +917 -2
- package/dist/agent/index.cjs +2600 -0
- package/dist/agent/index.cjs.map +1 -0
- package/dist/agent/index.d.cts +1237 -0
- package/dist/agent/index.d.ts +1237 -0
- package/dist/agent/index.js +2581 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/chunk-3Oi_Zrtm.js +9 -0
- package/dist/chunk-3Oi_Zrtm.js.map +1 -0
- package/dist/chunk-B18OPIu_.js +6 -0
- package/dist/chunk-B18OPIu_.js.map +1 -0
- package/dist/chunk-B5Uz3Qct.cjs +15 -0
- package/dist/chunk-B5Uz3Qct.cjs.map +1 -0
- package/dist/chunk-BBEJwkd3.d.cts +839 -0
- package/dist/chunk-BIEc_SkR.cjs +29 -0
- package/dist/chunk-BIEc_SkR.cjs.map +1 -0
- package/dist/chunk-BKMFOe-N.js +171 -0
- package/dist/chunk-BKMFOe-N.js.map +1 -0
- package/dist/chunk-BP4uy7E1.d.ts +11583 -0
- package/dist/chunk-BSHTsFiB.js +1403 -0
- package/dist/chunk-BSHTsFiB.js.map +1 -0
- package/dist/chunk-BTUUABGI.js +17 -0
- package/dist/chunk-BTUUABGI.js.map +1 -0
- package/dist/chunk-BaPiaz5X.cjs +115 -0
- package/dist/chunk-BaPiaz5X.cjs.map +1 -0
- package/dist/chunk-BeCVpkYr.cjs +542 -0
- package/dist/chunk-BeCVpkYr.cjs.map +1 -0
- package/dist/chunk-BgngsvK8.cjs +6202 -0
- package/dist/chunk-BgngsvK8.cjs.map +1 -0
- package/dist/chunk-BhInd7CJ.d.cts +253 -0
- package/dist/chunk-Bn6ZbxkS.cjs +27 -0
- package/dist/chunk-By9ZnkVI.js +60 -0
- package/dist/chunk-By9ZnkVI.js.map +1 -0
- package/dist/chunk-BzqPhxsz.cjs +367 -0
- package/dist/chunk-BzqPhxsz.cjs.map +1 -0
- package/dist/chunk-C2mMX81q.d.ts +443 -0
- package/dist/chunk-C2rr9Q0V.cjs +1402 -0
- package/dist/chunk-C2rr9Q0V.cjs.map +1 -0
- package/dist/chunk-CDJCbwIQ.d.cts +78 -0
- package/dist/chunk-CLGvBOVH.d.cts +1654 -0
- package/dist/chunk-COdw1dc6.d.ts +525 -0
- package/dist/chunk-CQCJnT2i.d.ts +511 -0
- package/dist/chunk-CSyHY67q.cjs +353 -0
- package/dist/chunk-CSyHY67q.cjs.map +1 -0
- package/dist/chunk-CiK1Iqrv.js +950 -0
- package/dist/chunk-CiK1Iqrv.js.map +1 -0
- package/dist/chunk-CmJBgSwZ.cjs +24 -0
- package/dist/chunk-CmJBgSwZ.cjs.map +1 -0
- package/dist/chunk-CnrsRK2u.cjs +83 -0
- package/dist/chunk-CnrsRK2u.cjs.map +1 -0
- package/dist/chunk-Co782_9r.js +326 -0
- package/dist/chunk-Co782_9r.js.map +1 -0
- package/dist/chunk-Csr3KDpZ.cjs +32 -0
- package/dist/chunk-Csr3KDpZ.cjs.map +1 -0
- package/dist/chunk-CwkmccXv.js +89 -0
- package/dist/chunk-CwkmccXv.js.map +1 -0
- package/dist/chunk-D0Q4iL9B.cjs +255 -0
- package/dist/chunk-D0Q4iL9B.cjs.map +1 -0
- package/dist/chunk-DFwiSzUS.cjs +72 -0
- package/dist/chunk-DFwiSzUS.cjs.map +1 -0
- package/dist/chunk-DIFayl2P.d.cts +443 -0
- package/dist/chunk-DIGF58ux.d.cts +525 -0
- package/dist/chunk-DKuuuld5.js +101 -0
- package/dist/chunk-DKuuuld5.js.map +1 -0
- package/dist/chunk-DMePkFEo.js +5054 -0
- package/dist/chunk-DMePkFEo.js.map +1 -0
- package/dist/chunk-DO5SIBgu.js +305 -0
- package/dist/chunk-DO5SIBgu.js.map +1 -0
- package/dist/chunk-DOQ_7eE5.d.ts +6662 -0
- package/dist/chunk-DThaaNeb.d.cts +15 -0
- package/dist/chunk-DThaaNeb.d.ts +15 -0
- package/dist/chunk-DUQzjUJy.d.ts +78 -0
- package/dist/chunk-DX37IPhV.cjs +1903 -0
- package/dist/chunk-DX37IPhV.cjs.map +1 -0
- package/dist/chunk-Damps5Tk.cjs +155 -0
- package/dist/chunk-Damps5Tk.cjs.map +1 -0
- package/dist/chunk-DbK5PhpJ.d.ts +1654 -0
- package/dist/chunk-De0vAASv.d.ts +253 -0
- package/dist/chunk-DhSZ7YZt.d.cts +6662 -0
- package/dist/chunk-DjEvqvPA.cjs +43 -0
- package/dist/chunk-DjEvqvPA.cjs.map +1 -0
- package/dist/chunk-DkwDzwvu.d.cts +121 -0
- package/dist/chunk-DkwDzwvu.d.ts +121 -0
- package/dist/chunk-Dmszv9If.js +71 -0
- package/dist/chunk-Dmszv9If.js.map +1 -0
- package/dist/chunk-Dp_ftNWY.d.cts +511 -0
- package/dist/chunk-DsHQySz0.js +31 -0
- package/dist/chunk-DsHQySz0.js.map +1 -0
- package/dist/chunk-DwoUyHHh.js +281 -0
- package/dist/chunk-DwoUyHHh.js.map +1 -0
- package/dist/chunk-IaIDQflj.d.cts +2315 -0
- package/dist/chunk-IaIDQflj.d.ts +2315 -0
- package/dist/chunk-cVXLsZfL.d.ts +839 -0
- package/dist/chunk-mIaCX9EJ.d.cts +11583 -0
- package/dist/chunk-nJQxbOwQ.cjs +8962 -0
- package/dist/chunk-nJQxbOwQ.cjs.map +1 -0
- package/dist/chunk-o9jaxhCO.js +8852 -0
- package/dist/chunk-o9jaxhCO.js.map +1 -0
- package/dist/chunk-p-Tt_Lwz.js +14 -0
- package/dist/chunk-p-Tt_Lwz.js.map +1 -0
- package/dist/engines/index.cjs +2091 -0
- package/dist/engines/index.cjs.map +1 -0
- package/dist/engines/index.d.cts +2176 -0
- package/dist/engines/index.d.ts +2176 -0
- package/dist/engines/index.js +2075 -0
- package/dist/engines/index.js.map +1 -0
- package/dist/handlers/index.cjs +53 -0
- package/dist/handlers/index.cjs.map +1 -0
- package/dist/handlers/index.d.cts +403 -0
- package/dist/handlers/index.d.ts +403 -0
- package/dist/handlers/index.js +33 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/index.cjs +3511 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +3033 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/index.cjs +510 -0
- package/dist/plugins/index.cjs.map +1 -0
- package/dist/plugins/index.d.cts +296 -0
- package/dist/plugins/index.d.ts +296 -0
- package/dist/plugins/index.js +489 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/seams/index.cjs +89 -0
- package/dist/seams/index.cjs.map +1 -0
- package/dist/seams/index.d.cts +452 -0
- package/dist/seams/index.d.ts +452 -0
- package/dist/seams/index.js +49 -0
- package/dist/seams/index.js.map +1 -0
- package/dist/strings/fr/index.cjs +2135 -0
- package/dist/strings/fr/index.cjs.map +1 -0
- package/dist/strings/fr/index.d.cts +17 -0
- package/dist/strings/fr/index.d.ts +17 -0
- package/dist/strings/fr/index.js +2130 -0
- package/dist/strings/fr/index.js.map +1 -0
- package/dist/strings/index.cjs +2384 -0
- package/dist/strings/index.cjs.map +1 -0
- package/dist/strings/index.d.cts +3 -0
- package/dist/strings/index.d.ts +3 -0
- package/dist/strings/index.js +2353 -0
- package/dist/strings/index.js.map +1 -0
- package/dist/testing/index.cjs +230 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +246 -0
- package/dist/testing/index.d.ts +246 -0
- package/dist/testing/index.js +219 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/time/index.cjs +28 -0
- package/dist/time/index.cjs.map +1 -0
- package/dist/time/index.d.cts +41 -0
- package/dist/time/index.d.ts +41 -0
- package/dist/time/index.js +23 -0
- package/dist/time/index.js.map +1 -0
- package/package.json +224 -4
- package/src/agent/engines/agentThreads.ts +1601 -0
- package/src/agent/engines/directorChat.ts +500 -0
- package/src/agent/index.ts +67 -0
- package/src/agent/rules/agentEditLock.ts +115 -0
- package/src/agent/rules/agentErrorCopy.ts +44 -0
- package/src/agent/rules/copilotOrganization.ts +36 -0
- package/src/agent/rules/playbook.gen.ts +444 -0
- package/src/agent/rules/router.ts +518 -0
- package/src/agent/rules/stateDelta.ts +29 -0
- package/src/agent/rules/studioRouter.ts +123 -0
- package/src/agent/rules/surfaces.gen.ts +633 -0
- package/src/agent/rules/threadsUrl.ts +48 -0
- package/src/agent/rules/transcriptObserver.ts +90 -0
- package/src/agent/stores/agentThreads.ts +451 -0
- package/src/bus/contracts/noData.ts +18 -0
- package/src/bus/contracts/shared.ts +172 -0
- package/src/bus/contracts/studioTools.ts +224 -0
- package/src/bus/rules/bus.ts +857 -0
- package/src/bus/rules/confirmation.ts +22 -0
- package/src/bus/rules/defineRegistry.ts +24 -0
- package/src/bus/rules/errors.ts +401 -0
- package/src/bus/rules/handlerErrors.ts +103 -0
- package/src/bus/rules/handlerRegistry.ts +627 -0
- package/src/bus/rules/inputSchema.ts +232 -0
- package/src/bus/rules/invalidInput.ts +441 -0
- package/src/bus/rules/lateBoundTools.ts +100 -0
- package/src/bus/rules/studioRegistry.ts +324 -0
- package/src/bus/rules/studioToolBus.ts +73 -0
- package/src/bus/rules/types.ts +804 -0
- package/src/chrome/contracts/alert.ts +42 -0
- package/src/chrome/contracts/itinerary.ts +26 -0
- package/src/chrome/contracts/map.ts +23 -0
- package/src/chrome/contracts/overlay.ts +46 -0
- package/src/chrome/contracts/panel.ts +29 -0
- package/src/chrome/contracts/question.ts +52 -0
- package/src/chrome/contracts/selection.ts +26 -0
- package/src/chrome/contracts/sidenav.ts +23 -0
- package/src/chrome/contracts/snapshot.ts +319 -0
- package/src/chrome/contracts/state.ts +22 -0
- package/src/chrome/contracts/tabs.ts +56 -0
- package/src/chrome/handlers/alert.ts +91 -0
- package/src/chrome/handlers/introspection.ts +180 -0
- package/src/chrome/handlers/panels.ts +42 -0
- package/src/chrome/handlers/question.ts +24 -0
- package/src/chrome/handlers/sidenav.ts +116 -0
- package/src/chrome/handlers/snapshot.ts +451 -0
- package/src/chrome/handlers/stateDelta.ts +125 -0
- package/src/chrome/handlers/tabs.ts +143 -0
- package/src/chrome/handlers/timestamp.ts +19 -0
- package/src/chrome/rules/agentSelectors.ts +210 -0
- package/src/chrome/rules/mapAlert.ts +13 -0
- package/src/chrome/rules/question.ts +25 -0
- package/src/chrome/rules/tabs.ts +13 -0
- package/src/chrome/stores/activeDraftSession.ts +134 -0
- package/src/chrome/stores/chrome.ts +527 -0
- package/src/chrome/stores/uiStore.ts +575 -0
- package/src/collab/contracts/collab.ts +261 -0
- package/src/collab/handlers/collab.ts +468 -0
- package/src/collab/rules/toolNames.ts +33 -0
- package/src/collab/stores/collab.ts +899 -0
- package/src/collections/contracts/collection.ts +182 -0
- package/src/collections/handlers/collectionAttach.ts +141 -0
- package/src/collections/handlers/collections.ts +499 -0
- package/src/collections/handlers/heldCollection.ts +42 -0
- package/src/collections/handlers/restCollections.ts +386 -0
- package/src/collections/rules/collections.ts +138 -0
- package/src/collections/rules/entityCollections.ts +53 -0
- package/src/collections/stores/collections.ts +133 -0
- package/src/data/contracts/data.ts +233 -0
- package/src/data/contracts/itinerary.ts +71 -0
- package/src/data/handlers/activityResolve.ts +76 -0
- package/src/data/handlers/data.ts +200 -0
- package/src/data/handlers/graphql.ts +26 -0
- package/src/data/handlers/mutationSink.ts +1577 -0
- package/src/data/handlers/profile.ts +83 -0
- package/src/data/handlers/writeThrough.ts +417 -0
- package/src/data/rules/cache.ts +181 -0
- package/src/data/rules/dataTypes.ts +40 -0
- package/src/data/rules/keys.ts +106 -0
- package/src/data/rules/persistence.ts +1058 -0
- package/src/data/rules/requestBody.ts +43 -0
- package/src/data/rules/restErrors.ts +354 -0
- package/src/data/rules/sessionSurface.ts +156 -0
- package/src/data/rules/toolResultData.ts +73 -0
- package/src/data/rules/uuid.ts +24 -0
- package/src/edit/contracts/edit.ts +37 -0
- package/src/edit/contracts/itinerary.ts +57 -0
- package/src/edit/handlers/draftCommit.ts +257 -0
- package/src/edit/handlers/editDiscard.ts +34 -0
- package/src/edit/handlers/editLock.ts +949 -0
- package/src/edit/handlers/editor.ts +203 -0
- package/src/edit/handlers/formUnsaved.ts +24 -0
- package/src/edit/rules/draftMetadata.ts +117 -0
- package/src/edit/rules/editKeyboard.ts +222 -0
- package/src/edit/rules/editShortcuts.ts +102 -0
- package/src/edit/rules/editTooltip.ts +174 -0
- package/src/edit/rules/editorTaken.ts +49 -0
- package/src/edit/rules/history.ts +26 -0
- package/src/edit/rules/unsavedWork.ts +60 -0
- package/src/edit/stores/editorReservation.ts +70 -0
- package/src/edit/stores/formsUnsaved.ts +54 -0
- package/src/embed/contracts/embed.ts +48 -0
- package/src/embed/engines/embedFraming.ts +1329 -0
- package/src/embed/engines/embedReady.ts +353 -0
- package/src/embed/engines/framingPageSession.ts +169 -0
- package/src/embed/handlers/embed.ts +130 -0
- package/src/embed/rules/allowedDomains.ts +71 -0
- package/src/embed/rules/bridgeMessages.ts +224 -0
- package/src/embed/rules/defaults.ts +173 -0
- package/src/embed/rules/displaySeed.ts +115 -0
- package/src/embed/rules/embedAllowlist.ts +146 -0
- package/src/embed/rules/embedConstraints.ts +215 -0
- package/src/embed/rules/embedElements.ts +277 -0
- package/src/embed/rules/embedSectionFields.ts +126 -0
- package/src/embed/rules/embedSecurity.ts +116 -0
- package/src/embed/rules/fieldDependencies.ts +89 -0
- package/src/embed/rules/fieldOptions.ts +138 -0
- package/src/embed/rules/layerOptions.ts +161 -0
- package/src/embed/rules/readyProtocol.ts +66 -0
- package/src/embed/rules/safetyRules.ts +215 -0
- package/src/embed/rules/snippet.ts +531 -0
- package/src/embed/rules/tableCode.ts +270 -0
- package/src/embed/stores/embed.ts +60 -0
- package/src/embed/stores/embedContent.ts +77 -0
- package/src/engines/index.ts +81 -0
- package/src/handlers/index.ts +66 -0
- package/src/index.ts +1065 -0
- package/src/itinerary/contracts/itinerary.ts +705 -0
- package/src/itinerary/engines/itineraryPace.ts +612 -0
- package/src/itinerary/engines/profileMarker.ts +238 -0
- package/src/itinerary/handlers/importStaging.ts +352 -0
- package/src/itinerary/handlers/itinerary.ts +572 -0
- package/src/itinerary/handlers/itineraryDuplicate.ts +177 -0
- package/src/itinerary/handlers/itineraryExport.ts +117 -0
- package/src/itinerary/handlers/itineraryImport.ts +783 -0
- package/src/itinerary/handlers/itineraryPublish.ts +118 -0
- package/src/itinerary/handlers/itinerarySelection.ts +354 -0
- package/src/itinerary/handlers/itinerarySuggest.ts +1186 -0
- package/src/itinerary/handlers/itineraryUnpublish.ts +101 -0
- package/src/itinerary/handlers/publicationScope.ts +118 -0
- package/src/itinerary/handlers/restItineraries.ts +752 -0
- package/src/itinerary/handlers/restItineraryExport.ts +70 -0
- package/src/itinerary/handlers/restItineraryImport.ts +311 -0
- package/src/itinerary/handlers/restItineraryPace.ts +87 -0
- package/src/itinerary/handlers/restItineraryRecord.ts +36 -0
- package/src/itinerary/handlers/suggestParams.ts +379 -0
- package/src/itinerary/handlers/suggestStaging.ts +363 -0
- package/src/itinerary/handlers/surfaceOpen.ts +389 -0
- package/src/itinerary/rules/activity.ts +139 -0
- package/src/itinerary/rules/analysis.ts +42 -0
- package/src/itinerary/rules/ceiling.ts +49 -0
- package/src/itinerary/rules/createFlow.ts +107 -0
- package/src/itinerary/rules/densify.ts +440 -0
- package/src/itinerary/rules/draftSurface.ts +219 -0
- package/src/itinerary/rules/editorView.ts +83 -0
- package/src/itinerary/rules/export.ts +159 -0
- package/src/itinerary/rules/friendlyName.ts +77 -0
- package/src/itinerary/rules/import.ts +1050 -0
- package/src/itinerary/rules/importFiles.ts +140 -0
- package/src/itinerary/rules/importTotals.ts +77 -0
- package/src/itinerary/rules/liveSegment.ts +712 -0
- package/src/itinerary/rules/lngLat.ts +17 -0
- package/src/itinerary/rules/mapSync.ts +100 -0
- package/src/itinerary/rules/previewRender.ts +416 -0
- package/src/itinerary/rules/profileReadout.ts +216 -0
- package/src/itinerary/rules/routing.ts +707 -0
- package/src/itinerary/rules/suggest.ts +522 -0
- package/src/itinerary/rules/suggestionPreview.ts +119 -0
- package/src/itinerary/rules/view.ts +61 -0
- package/src/itinerary/stores/importSession.ts +319 -0
- package/src/itinerary/stores/itinerary.ts +331 -0
- package/src/itinerary/stores/itineraryDuplicate.ts +76 -0
- package/src/itinerary/stores/sessionIdentity.ts +43 -0
- package/src/itinerary/stores/suggestSession.ts +418 -0
- package/src/layers/contracts/itinerary.ts +46 -0
- package/src/layers/contracts/overlay.ts +132 -0
- package/src/layers/handlers/enrichment.ts +36 -0
- package/src/layers/handlers/overlay.ts +406 -0
- package/src/layers/handlers/restLayers.ts +94 -0
- package/src/layers/handlers/tiles.ts +25 -0
- package/src/layers/rules/layers.ts +212 -0
- package/src/layers/rules/overlayInstant.ts +12 -0
- package/src/layers/rules/reachabilityIcon.ts +18 -0
- package/src/layers/rules/readout.ts +102 -0
- package/src/layers/stores/layers.ts +262 -0
- package/src/map/contracts/contextmenu.ts +33 -0
- package/src/map/contracts/geolocate.ts +37 -0
- package/src/map/contracts/map.ts +146 -0
- package/src/map/contracts/streetview.ts +53 -0
- package/src/map/contracts/terrain.ts +152 -0
- package/src/map/handlers/contextMenu.ts +135 -0
- package/src/map/handlers/geolocate.ts +52 -0
- package/src/map/handlers/map.ts +391 -0
- package/src/map/handlers/streetview.ts +94 -0
- package/src/map/handlers/terrain.ts +663 -0
- package/src/map/rules/baseTerrain.ts +75 -0
- package/src/map/rules/clickTargets.ts +464 -0
- package/src/map/rules/constraints.ts +32 -0
- package/src/map/rules/contextMenuReadout.ts +67 -0
- package/src/map/rules/coordinates.ts +71 -0
- package/src/map/rules/itineraryFit.ts +8 -0
- package/src/map/rules/mapEvents.ts +64 -0
- package/src/map/rules/mapProjection.ts +476 -0
- package/src/map/rules/terrainReading.ts +62 -0
- package/src/plugins/contracts/ids.ts +66 -0
- package/src/plugins/contracts/plugin.ts +202 -0
- package/src/plugins/contracts/slots.ts +137 -0
- package/src/plugins/engines/studioPlugin.ts +1365 -0
- package/src/plugins/index.ts +111 -0
- package/src/plugins/rules/contributions.ts +152 -0
- package/src/plugins/rules/errors.ts +60 -0
- package/src/plugins/rules/ids.ts +42 -0
- package/src/plugins/rules/validation.ts +249 -0
- package/src/rules/listeners.ts +57 -0
- package/src/rules/origin.ts +13 -0
- package/src/rules/storeWrite.ts +37 -0
- package/src/rules/types.ts +136 -0
- package/src/seams/index.ts +79 -0
- package/src/seams/rules/clock.ts +28 -0
- package/src/seams/rules/formatters.ts +211 -0
- package/src/seams/rules/ids.ts +102 -0
- package/src/seams/rules/links.ts +66 -0
- package/src/seams/rules/navigation.ts +222 -0
- package/src/seams/rules/notify.ts +49 -0
- package/src/seams/rules/persistenceDrawer.ts +220 -0
- package/src/seams/rules/saveFile.ts +101 -0
- package/src/seams/rules/seams.ts +156 -0
- package/src/seams/rules/storage.ts +116 -0
- package/src/search/contracts/overlay.ts +74 -0
- package/src/search/contracts/search.ts +197 -0
- package/src/search/handlers/pois.ts +57 -0
- package/src/search/handlers/search.ts +280 -0
- package/src/search/rules/params.ts +925 -0
- package/src/search/rules/poiGroups.ts +138 -0
- package/src/search/rules/searchFetch.ts +139 -0
- package/src/search/rules/timeWindow.ts +30 -0
- package/src/search/stores/search.ts +51 -0
- package/src/segments/contracts/itinerary.ts +433 -0
- package/src/segments/contracts/segment.ts +35 -0
- package/src/segments/engines/segmentDraft.ts +926 -0
- package/src/segments/handlers/chainGuards.ts +67 -0
- package/src/segments/handlers/directions.ts +44 -0
- package/src/segments/handlers/itineraryEcho.ts +45 -0
- package/src/segments/handlers/roadAccessDialog.ts +34 -0
- package/src/segments/handlers/segment.ts +111 -0
- package/src/segments/handlers/segmentEdit.ts +1341 -0
- package/src/segments/handlers/segmentGroups.ts +347 -0
- package/src/segments/handlers/segmentStructure.ts +1144 -0
- package/src/segments/rules/chain.ts +196 -0
- package/src/segments/rules/chainModel.ts +217 -0
- package/src/segments/rules/colors.ts +11 -0
- package/src/segments/rules/commit.ts +76 -0
- package/src/segments/rules/draft.ts +90 -0
- package/src/segments/rules/draftDisposition.ts +43 -0
- package/src/segments/rules/draftSegmentEdit.ts +129 -0
- package/src/segments/rules/engine.ts +222 -0
- package/src/segments/rules/groupSave.ts +234 -0
- package/src/segments/rules/hazardPrompt.ts +60 -0
- package/src/segments/rules/itineraryEcho.ts +40 -0
- package/src/segments/rules/liveSegmentProjection.ts +55 -0
- package/src/segments/rules/merge.ts +51 -0
- package/src/segments/rules/metrics.ts +456 -0
- package/src/segments/rules/naming.ts +168 -0
- package/src/segments/rules/segmentArming.ts +144 -0
- package/src/segments/rules/splitPick.ts +84 -0
- package/src/segments/rules/viaSimplify.ts +230 -0
- package/src/segments/stores/directions.ts +77 -0
- package/src/segments/stores/roadAccessDialog.ts +58 -0
- package/src/segments/stores/segmentEdit.ts +922 -0
- package/src/segments/stores/segmentGroupEdit.ts +84 -0
- package/src/segments/stores/segmentSplit.ts +77 -0
- package/src/share/contracts/share.ts +39 -0
- package/src/share/contracts/shareLink.ts +63 -0
- package/src/share/engines/shareLink.ts +1053 -0
- package/src/share/handlers/share.ts +47 -0
- package/src/share/handlers/shareLink.ts +231 -0
- package/src/share/handlers/shareScope.ts +54 -0
- package/src/share/rules/link.ts +89 -0
- package/src/share/rules/shareLink.ts +218 -0
- package/src/share/rules/targets.ts +92 -0
- package/src/share/rules/viewConfig.ts +95 -0
- package/src/share/stores/share.ts +58 -0
- package/src/strings/fr/index.ts +18 -0
- package/src/strings/fr/rules/fr.ts +2368 -0
- package/src/strings/index.ts +98 -0
- package/src/strings/rules/confirmCopy.ts +156 -0
- package/src/strings/rules/draftToolNames.ts +94 -0
- package/src/strings/rules/en.ts +2519 -0
- package/src/strings/rules/failureAlert.ts +115 -0
- package/src/strings/rules/formError.ts +400 -0
- package/src/strings/rules/maneuvers.ts +107 -0
- package/src/strings/rules/outputOptions.ts +126 -0
- package/src/strings/rules/publicationState.ts +100 -0
- package/src/strings/rules/routeHazardCopy.ts +62 -0
- package/src/strings/rules/searchLabels.ts +50 -0
- package/src/strings/rules/segmentChainVerbs.ts +62 -0
- package/src/strings/rules/studioCopy.ts +130 -0
- package/src/strings/rules/unitOptions.ts +119 -0
- package/src/testing/checkedBus.ts +226 -0
- package/src/testing/index.ts +30 -0
- package/src/testing/plugins.ts +106 -0
- package/src/testing/studio.ts +267 -0
- package/src/testing/urlSeam.ts +153 -0
- package/src/time/index.ts +12 -0
- package/src/time/rules/sun.ts +78 -0
- package/src/video/contracts/cameraSchemas.ts +266 -0
- package/src/video/contracts/profileSchemas.ts +37 -0
- package/src/video/contracts/video.ts +601 -0
- package/src/video/handlers/video.ts +1638 -0
- package/src/video/handlers/videoDirector.ts +114 -0
- package/src/video/rules/previewRefresh.ts +76 -0
- package/src/video/rules/profileSource.ts +51 -0
- package/src/video/rules/routeSpans.ts +79 -0
- package/src/video/rules/shotDefaults.ts +28 -0
- package/src/video/rules/stepOrder.ts +17 -0
- package/src/video/rules/videoSnapshot.ts +136 -0
- package/src/video/stores/directorThreads.ts +167 -0
- package/src/video/stores/videoExport.ts +290 -0
- package/src/viewer/contracts/preferences.ts +40 -0
- package/src/viewer/handlers/preferences.ts +91 -0
- package/src/viewer/rules/capabilities.ts +42 -0
- package/src/viewer/rules/config.ts +266 -0
- package/src/viewer/rules/context.ts +375 -0
- package/src/viewer/rules/ownership.ts +134 -0
- package/src/viewer/rules/platformViewer.ts +199 -0
- package/src/viewer/rules/scope.ts +197 -0
- package/src/viewer/rules/url.ts +145 -0
- package/src/viewer/rules/viewer.ts +307 -0
- package/src/viewer/rules/viewerSeam.ts +49 -0
- package/src/viewer/rules/viewerUnits.ts +34 -0
- package/src/waypoints/contracts/itinerary.ts +417 -0
- package/src/waypoints/handlers/poiWaypointStyle.ts +32 -0
- package/src/waypoints/handlers/waypointDetailsDialog.ts +38 -0
- package/src/waypoints/handlers/waypointEdit.ts +1073 -0
- package/src/waypoints/rules/amenities.ts +30 -0
- package/src/waypoints/rules/defaults.ts +31 -0
- package/src/waypoints/rules/details.ts +213 -0
- package/src/waypoints/rules/detailsDraft.ts +312 -0
- package/src/waypoints/rules/detailsPreview.ts +76 -0
- package/src/waypoints/rules/detailsSave.ts +356 -0
- package/src/waypoints/rules/draftDirty.ts +45 -0
- package/src/waypoints/rules/icons.ts +32 -0
- package/src/waypoints/rules/liveWaypoint.ts +63 -0
- package/src/waypoints/rules/naming.ts +185 -0
- package/src/waypoints/rules/sections.ts +77 -0
- package/src/waypoints/rules/waypointDraft.ts +62 -0
- package/src/waypoints/stores/waypointDetails.ts +62 -0
- package/src/waypoints/stores/waypointEdit.ts +566 -0
- package/src/zones/contracts/collection.ts +37 -0
- package/src/zones/contracts/zone.ts +528 -0
- package/src/zones/engines/zoneForm.ts +1773 -0
- package/src/zones/handlers/restZones.ts +287 -0
- package/src/zones/handlers/zonePublish.ts +206 -0
- package/src/zones/handlers/zoneUnpublish.ts +56 -0
- package/src/zones/handlers/zones.ts +2254 -0
- package/src/zones/rules/geometry.ts +946 -0
- package/src/zones/rules/zoneDefaults.ts +34 -0
- package/src/zones/rules/zoneDraft.ts +54 -0
- package/src/zones/rules/zoneForm.ts +563 -0
- package/src/zones/rules/zoneMetadata.ts +29 -0
- package/src/zones/rules/zoneSource.ts +87 -0
- package/src/zones/rules/zoneSourceRefusal.ts +104 -0
- package/src/zones/stores/zoneEdit.ts +998 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The coordinates a caller names, and the bounds they are held to.
|
|
3
|
+
*
|
|
4
|
+
* A tool takes a coordinate from one of two places, and the two are bounded differently. A pair
|
|
5
|
+
* that arrives from a projection the caller already trusts (a via, a dragged handle) takes the
|
|
6
|
+
* bus's shared, unbounded `lngLatSchema`. A pair a caller NAMES (a point to read, a place to
|
|
7
|
+
* frame, a right-click to open a menu at) is held to the world here, because a named pair
|
|
8
|
+
* outside it is a typo: `[45.9, 106.8]` is a pair written latitude first, and a renderer handed
|
|
9
|
+
* it throws where a boundary would have said which member is wrong.
|
|
10
|
+
*
|
|
11
|
+
* The world's two limits are the ones `@mountaya/elements/geo` publishes (`LONGITUDE_LIMIT`,
|
|
12
|
+
* the antimeridian, and `LATITUDE_LIMIT`, a pole), and this package declares neither. The
|
|
13
|
+
* schemas over them are declared once, in this module, and every map, terrain and overlay
|
|
14
|
+
* contract reads them from here. It sits under `rules/` and not beside those contracts: a
|
|
15
|
+
* `contracts/` directory holds one tool-contract table per namespace module, and these are
|
|
16
|
+
* schemas the tables are built from.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import * as z from "zod";
|
|
20
|
+
|
|
21
|
+
import { LATITUDE_LIMIT, LONGITUDE_LIMIT } from "@mountaya/elements/geo";
|
|
22
|
+
|
|
23
|
+
/** A latitude inside the world, the poles included. */
|
|
24
|
+
const worldLatitudeSchema = z.number().min(-LATITUDE_LIMIT).max(LATITUDE_LIMIT);
|
|
25
|
+
|
|
26
|
+
/** A longitude inside one copy of the world, the antimeridian included. */
|
|
27
|
+
const worldLongitudeSchema = z.number().min(-LONGITUDE_LIMIT).max(LONGITUDE_LIMIT);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* worldLngLatSchema is a `[longitude, latitude]` inside one copy of the world.
|
|
31
|
+
*
|
|
32
|
+
* For a point a caller names to READ something at (a terrain sample, an overlay sample), where
|
|
33
|
+
* a longitude past the antimeridian is as much a typo as a latitude past a pole, and is worth
|
|
34
|
+
* refusing at the boundary over answering that nothing is loaded there.
|
|
35
|
+
*/
|
|
36
|
+
export const worldLngLatSchema = z.tuple([worldLongitudeSchema, worldLatitudeSchema]);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* worldBoundingBoxSchema is a `[west, south, east, north]` box inside one copy of the world.
|
|
40
|
+
* Whether its corners are in order is the contract's own question, asked where the box is used.
|
|
41
|
+
*/
|
|
42
|
+
export const worldBoundingBoxSchema = z.tuple([
|
|
43
|
+
worldLongitudeSchema,
|
|
44
|
+
worldLatitudeSchema,
|
|
45
|
+
worldLongitudeSchema,
|
|
46
|
+
worldLatitudeSchema,
|
|
47
|
+
]);
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* namedLngLatSchema is a `[longitude, latitude]` a caller names for the camera or the pointer:
|
|
51
|
+
* its latitude is inside the world and its longitude is any finite number.
|
|
52
|
+
*
|
|
53
|
+
* The longitude is left unbounded on purpose. A map shows the world more than once, and a
|
|
54
|
+
* right-click on a copy past the antimeridian names a longitude past 180, which a renderer
|
|
55
|
+
* wraps. No latitude wraps, so one past a pole is refused.
|
|
56
|
+
*/
|
|
57
|
+
export const namedLngLatSchema = z.tuple([z.number(), worldLatitudeSchema]);
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* namedBoundingBoxSchema is a `[west, south, east, north]` box a caller names for the camera:
|
|
61
|
+
* its latitudes are inside the world and its longitudes are any finite numbers.
|
|
62
|
+
*
|
|
63
|
+
* A box whose west is east of its east is taken: it is the canonical form of a box across the
|
|
64
|
+
* antimeridian, and the map client reads it by its corners.
|
|
65
|
+
*/
|
|
66
|
+
export const namedBoundingBoxSchema = z.tuple([
|
|
67
|
+
z.number(),
|
|
68
|
+
worldLatitudeSchema,
|
|
69
|
+
z.number(),
|
|
70
|
+
worldLatitudeSchema,
|
|
71
|
+
]);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ITINERARY_FIT_MAX_ZOOM caps how far framing a single itinerary may zoom in.
|
|
3
|
+
*
|
|
4
|
+
* A short route fit to its bare bounds would reach street level, hiding the surrounding
|
|
5
|
+
* terrain that gives an outdoor route its context. One ceiling, shared by every caller that
|
|
6
|
+
* frames an itinerary, so none of them restates it.
|
|
7
|
+
*/
|
|
8
|
+
export const ITINERARY_FIT_MAX_ZOOM = 13;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
|
|
3
|
+
import type { FeatureHit, OverlayFeature, PoiInfo } from "@mountaya/elements/map-client";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* What the MAP hands the tool layer, validated.
|
|
7
|
+
*
|
|
8
|
+
* Every shape here crosses one boundary, from a map to a tool, a store and a surface, and it
|
|
9
|
+
* is the only place these values are untrusted: a renderer implementation produces them.
|
|
10
|
+
* `studio.contextmenu.open` validates the points of interest and the overlay features it stores
|
|
11
|
+
* with {@link poiInfoSchema} and {@link overlayFeatureSchema}, so every reader of the menu slot
|
|
12
|
+
* reads a parsed value. {@link featureHitSchema} is parsed by no studio module: a click or a
|
|
13
|
+
* hover reaches the click-target rules from a binding, typed, and the schema is published for
|
|
14
|
+
* a host whose own renderer answers the hits and that wants them checked at its boundary.
|
|
15
|
+
*
|
|
16
|
+
* The shapes themselves are declared by `@mountaya/elements`, beside the client that produces
|
|
17
|
+
* them, because they describe what a MAP resolved under a cursor: a point of interest, an overlay
|
|
18
|
+
* feature's properties, a tile feature's id. They are named here from `./map-client`, the entry
|
|
19
|
+
* that publishes them with no renderer in its declarations. A consumer driving `MapLibreClient`
|
|
20
|
+
* directly reads those types without taking a schema library; only the crossing needs one, so
|
|
21
|
+
* no consumer of the imperative map surface resolves a validation runtime to name a POI.
|
|
22
|
+
*
|
|
23
|
+
* It sits under `map/rules/` rather than `map/contracts/`, because a `contracts/` directory holds
|
|
24
|
+
* a tool-contract table per namespace. These are schemas the contracts are built from, not a
|
|
25
|
+
* contract table.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* poiInfoSchema validates one point of interest resolved under a right-click: the feature's
|
|
30
|
+
* display `name` (null when the tile carries none), its `category` (the OpenMapTiles `class` or
|
|
31
|
+
* `subclass` naming what the feature is) and the `id` the tile gives the feature (null when it
|
|
32
|
+
* gives none).
|
|
33
|
+
*
|
|
34
|
+
* It carries no icon or color: the Tile API's POI overlay owns how a tile POI is styled, so the
|
|
35
|
+
* popup shows the name and category as text rather than inventing a parallel marker style.
|
|
36
|
+
*/
|
|
37
|
+
export const poiInfoSchema = z.object({
|
|
38
|
+
category: z.string(),
|
|
39
|
+
id: z.string().nullable(),
|
|
40
|
+
name: z.string().nullable(),
|
|
41
|
+
}) satisfies z.ZodType<PoiInfo>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* overlayFeatureSchema validates one active-overlay vector feature's display properties.
|
|
45
|
+
*
|
|
46
|
+
* The value carries the raw properties so a formatter interprets them by key:
|
|
47
|
+
* {@link overlayReadoutFor} formats a reading in the reader's units.
|
|
48
|
+
*/
|
|
49
|
+
export const overlayFeatureSchema = z.record(
|
|
50
|
+
z.string(),
|
|
51
|
+
z.union([z.string(), z.number(), z.boolean(), z.null()]),
|
|
52
|
+
) satisfies z.ZodType<OverlayFeature>;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* featureHitSchema validates one tile feature resolved under a layer-scoped click or hover.
|
|
56
|
+
*
|
|
57
|
+
* The raw renderer feature stays inside the map package and never leaks through `MapClient`; the
|
|
58
|
+
* application reads the id and properties to decide which tool to dispatch (select a segment
|
|
59
|
+
* or a waypoint).
|
|
60
|
+
*/
|
|
61
|
+
export const featureHitSchema = z.object({
|
|
62
|
+
id: z.union([z.string(), z.number()]).nullable(),
|
|
63
|
+
properties: z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()])),
|
|
64
|
+
}) satisfies z.ZodType<FeatureHit>;
|
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a studio's state puts on its map.
|
|
3
|
+
*
|
|
4
|
+
* A studio keeps its state in a store and draws it on a map client, and between the two sits a
|
|
5
|
+
* set of decisions: which source owns the one preview overlay, which collaborators' drafts are
|
|
6
|
+
* ghosts, which enrichments a viewer may draw, which points-of-interest layers show, which
|
|
7
|
+
* tiles are fetched again for an instant, what "now" is to a zone's time window, and which
|
|
8
|
+
* lines a dropped waypoint snaps to. Each is a function here, of the store's values and the
|
|
9
|
+
* layers manifest, answering what the map should hold. None of them touches a map.
|
|
10
|
+
*
|
|
11
|
+
* A binding is what is left: read the store, call the rule, hand its answer to the client, and
|
|
12
|
+
* write only what changed. `@mountaya/studio-react/map` does that in one effect per rule, and a
|
|
13
|
+
* binding in another framework calls the same functions and writes its own effects. Deriving
|
|
14
|
+
* one of these in a binding is how two studios come to disagree about the same state.
|
|
15
|
+
*
|
|
16
|
+
* The map client's shapes are named from `@mountaya/elements/map-client`, which declares them
|
|
17
|
+
* with no renderer behind them, so nothing here resolves one at runtime or at type-check.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { LineString, Polygon, Position } from "geojson";
|
|
21
|
+
|
|
22
|
+
import type { ItineraryWithDetails, RestSchema } from "@mountaya/client";
|
|
23
|
+
import { type PeerNameResolver, peerDraftInitials } from "@mountaya/elements/collab";
|
|
24
|
+
import { extractLines } from "@mountaya/elements/geo";
|
|
25
|
+
import { findOverlay } from "@mountaya/elements/layers";
|
|
26
|
+
import type {
|
|
27
|
+
ItineraryExclusions,
|
|
28
|
+
ItineraryPreviewRender,
|
|
29
|
+
PeerDraftEntity,
|
|
30
|
+
} from "@mountaya/elements/map-client";
|
|
31
|
+
import { convertDuration } from "@mountaya/elements/units";
|
|
32
|
+
|
|
33
|
+
import { type CollabPeerDraft, collabPeerColor } from "../../collab/stores/collab.js";
|
|
34
|
+
import type { ItineraryDraft } from "../../itinerary/rules/import.js";
|
|
35
|
+
import {
|
|
36
|
+
draftToPreviewRender,
|
|
37
|
+
itineraryExclusions,
|
|
38
|
+
itineraryToPreviewRender,
|
|
39
|
+
type PreviewGlyphs,
|
|
40
|
+
zoneBandsToPreviewRender,
|
|
41
|
+
} from "../../itinerary/rules/previewRender.js";
|
|
42
|
+
import {
|
|
43
|
+
type SuggestionPreviewInputs,
|
|
44
|
+
suggestionPreviewRender,
|
|
45
|
+
} from "../../itinerary/rules/suggestionPreview.js";
|
|
46
|
+
import { POIS_OVERLAY_SLUG } from "../../layers/rules/layers.js";
|
|
47
|
+
import { POI_GROUPS } from "../../search/rules/poiGroups.js";
|
|
48
|
+
import type { ZonePreview } from "../../zones/stores/zoneEdit.js";
|
|
49
|
+
|
|
50
|
+
type Layers = RestSchema.Layers;
|
|
51
|
+
type Overlay = RestSchema.Overlay;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* PreviewProjectionInput is the studio state {@link previewProjection} decides the preview
|
|
55
|
+
* overlay from: every source that can own it, and the entities an edit engine is drawing.
|
|
56
|
+
*/
|
|
57
|
+
export interface PreviewProjectionInput {
|
|
58
|
+
/** The itinerary the editor has open, read only when `tiled` is false. */
|
|
59
|
+
readonly activeItinerary: ItineraryWithDetails | null;
|
|
60
|
+
/** The active draft, an import's or a suggestion's, or null with none. */
|
|
61
|
+
readonly draft: ItineraryDraft | null;
|
|
62
|
+
/** The segment under a live geometry edit, which the edit engine draws, or null. */
|
|
63
|
+
readonly editSegmentId: string | null;
|
|
64
|
+
/** The waypoint under a live edit, which the edit engine draws, or null. */
|
|
65
|
+
readonly editWaypointId: string | null;
|
|
66
|
+
/** The open suggest session's candidates and endpoints, or null with no session open. */
|
|
67
|
+
readonly suggestion: SuggestionPreviewInputs | null;
|
|
68
|
+
/**
|
|
69
|
+
* Whether this studio's writes reach the tile server, the persistence seam's own `tiled`
|
|
70
|
+
* answer. A studio that persists nothing has no local write to paint, and passes true.
|
|
71
|
+
*/
|
|
72
|
+
readonly tiled: boolean;
|
|
73
|
+
/** The zone panel's reachability preview, or null with none computed. */
|
|
74
|
+
readonly zonePreview: ZonePreview | null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* PreviewProjection is what the map's one preview overlay holds for a studio state, as
|
|
79
|
+
* {@link previewProjection} answers it.
|
|
80
|
+
*/
|
|
81
|
+
export interface PreviewProjection {
|
|
82
|
+
/**
|
|
83
|
+
* The draft the overlay paints, or null when it paints none. A caller frames each draft
|
|
84
|
+
* once, on the first projection that names it, and forgets the last one framed on a null.
|
|
85
|
+
*/
|
|
86
|
+
readonly draft: ItineraryDraft | null;
|
|
87
|
+
/**
|
|
88
|
+
* The tile copies to suppress while the overlay stands in for them, or null when the tiles
|
|
89
|
+
* draw the itinerary. A caller that set them clears them when the projection moves on.
|
|
90
|
+
*/
|
|
91
|
+
readonly exclusions: ItineraryExclusions | null;
|
|
92
|
+
/** What the overlay paints, or null to clear it. */
|
|
93
|
+
readonly render: ItineraryPreviewRender | null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* previewProjection answers what the map's one preview overlay holds, from every source that
|
|
98
|
+
* can own it.
|
|
99
|
+
*
|
|
100
|
+
* A persisted itinerary is drawn by its tiles. Anything else has none, so a studio paints it as
|
|
101
|
+
* a read-only overlay, and the client has one such overlay. The first source below that has
|
|
102
|
+
* something to show owns it, so two of them never contend for it:
|
|
103
|
+
*
|
|
104
|
+
* 1. the zone panel's reachability bands, while at least one band is computed;
|
|
105
|
+
* 2. the active draft, an import's or a suggestion's, while it holds a segment or a waypoint.
|
|
106
|
+
* The entity under a live edit is left to the edit engine, and a draft whose only entity is
|
|
107
|
+
* under one still owns the overlay, so no later source paints beneath the edit;
|
|
108
|
+
* 3. the open suggest session's selected candidate and endpoint pins, while it paints at least
|
|
109
|
+
* one of them. A session with no endpoint placed and no candidate picked holds nothing;
|
|
110
|
+
* 4. the open itinerary, when `tiled` is false. A write that never reaches the tile server is
|
|
111
|
+
* never in a tile, so the store's copy is painted and the tile copy, which still shows the
|
|
112
|
+
* server's version, is suppressed whole through `exclusions`.
|
|
113
|
+
*
|
|
114
|
+
* With none of them the overlay is cleared. A source that is open and holds nothing never owns
|
|
115
|
+
* the overlay: an open suggest panel beside an untiled itinerary would otherwise take that
|
|
116
|
+
* itinerary off the map until the reader placed a start.
|
|
117
|
+
*
|
|
118
|
+
* Only a draft is framed (`draft` is null for every other source). Bands and candidates are
|
|
119
|
+
* computed around a point the reader just placed and are in view already, so framing them would
|
|
120
|
+
* move the camera under a reader who is still choosing.
|
|
121
|
+
*
|
|
122
|
+
* The answer is recomputed whole from its inputs, so applying it again is safe, and one source's
|
|
123
|
+
* change never clears another's paint.
|
|
124
|
+
*/
|
|
125
|
+
export const previewProjection = (
|
|
126
|
+
glyphs: PreviewGlyphs,
|
|
127
|
+
input: PreviewProjectionInput,
|
|
128
|
+
): PreviewProjection => {
|
|
129
|
+
const { activeItinerary, draft, suggestion, tiled, zonePreview } = input;
|
|
130
|
+
const editing = { segmentId: input.editSegmentId, waypointId: input.editWaypointId };
|
|
131
|
+
|
|
132
|
+
if (zonePreview && zonePreview.bands.length > 0) {
|
|
133
|
+
return {
|
|
134
|
+
draft: null,
|
|
135
|
+
exclusions: null,
|
|
136
|
+
render: zoneBandsToPreviewRender(glyphs, zonePreview),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (draft && (draft.segments.length > 0 || draft.waypoints.length > 0)) {
|
|
141
|
+
return { draft, exclusions: null, render: draftToPreviewRender(glyphs, draft, editing) };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (suggestion) {
|
|
145
|
+
const render = suggestionPreviewRender(suggestion);
|
|
146
|
+
if (render.lines.length > 0 || render.waypoints.length > 0) {
|
|
147
|
+
return { draft: null, exclusions: null, render };
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (!tiled && activeItinerary) {
|
|
152
|
+
return {
|
|
153
|
+
draft: null,
|
|
154
|
+
exclusions: itineraryExclusions(activeItinerary),
|
|
155
|
+
render: itineraryToPreviewRender(glyphs, activeItinerary, editing),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return { draft: null, exclusions: null, render: null };
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
/** PeerDraftGhostsInput is the collaboration state {@link peerDraftGhosts} reads. */
|
|
163
|
+
export interface PeerDraftGhostsInput {
|
|
164
|
+
/**
|
|
165
|
+
* Every open resource's peer drafts, keyed `segment/{id}` or `zone/{id}`. Entity ids are
|
|
166
|
+
* unique across resources, so the maps of two open resources merge without a collision.
|
|
167
|
+
*/
|
|
168
|
+
readonly drafts: Readonly<Record<string, CollabPeerDraft>>;
|
|
169
|
+
/** The segment the local user is editing, or null. */
|
|
170
|
+
readonly localSegmentEditId: string | null;
|
|
171
|
+
/** The zone the local user is reshaping, or null. */
|
|
172
|
+
readonly localZoneEditId: string | null;
|
|
173
|
+
/** The user ids present in the open resources' rosters. */
|
|
174
|
+
readonly presentPeerIds: readonly string[];
|
|
175
|
+
/**
|
|
176
|
+
* Resolves a peer's display name. Absent, or answering null for a peer, the ghost is labeled
|
|
177
|
+
* with the peer's initials.
|
|
178
|
+
*/
|
|
179
|
+
readonly resolveName?: PeerNameResolver | undefined;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** PeerDraftGhost is one collaborator's in-flight edit, as the local map paints it. */
|
|
183
|
+
export interface PeerDraftGhost {
|
|
184
|
+
/**
|
|
185
|
+
* The paint value of the peer's color, `collabPeerColor`'s answer for the author: a
|
|
186
|
+
* `#rrggbb` string any renderer reads, with no theme to resolve it against.
|
|
187
|
+
*/
|
|
188
|
+
readonly color: string;
|
|
189
|
+
/** The entity the ghost is keyed on, which is what a client paints and clears it by. */
|
|
190
|
+
readonly entity: PeerDraftEntity;
|
|
191
|
+
/** A segment's routed line, or a zone's drawn polygon. */
|
|
192
|
+
readonly geometry: LineString | Polygon;
|
|
193
|
+
/** The draft's key, stable while the draft lives, for telling one reconcile from the next. */
|
|
194
|
+
readonly key: string;
|
|
195
|
+
/** The author's display name, or their initials while none resolves. */
|
|
196
|
+
readonly label: string;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* peerDraftGhosts answers the ghosts the local map paints for its collaborators' in-flight
|
|
201
|
+
* edits, in the order the drafts are held.
|
|
202
|
+
*
|
|
203
|
+
* A segment draft is a ghost of the first line it can draw: the first line of its geometry
|
|
204
|
+
* that holds two points or more (`extractLines`, so each track of a segment drawn as a
|
|
205
|
+
* `MultiLineString` counts, and a track of one point is passed over for the one after it). A
|
|
206
|
+
* zone draft is a ghost of its polygon. A client's ghost is one line or one polygon, which is
|
|
207
|
+
* why a segment's other lines are not in it. These drafts have no ghost:
|
|
208
|
+
*
|
|
209
|
+
* - one whose author is not in `presentPeerIds`, since a draft frame can arrive before its
|
|
210
|
+
* author's presence does;
|
|
211
|
+
* - one for the entity the local user is editing, where the local edit owns the map and a
|
|
212
|
+
* ghost under it would fight the handles;
|
|
213
|
+
* - a segment draft with no line of two points or more, which is what an edit carries before
|
|
214
|
+
* its first route lands.
|
|
215
|
+
*
|
|
216
|
+
* A ghost's color and label follow from its author's id, never from the peer's cursor or
|
|
217
|
+
* selection, so a caller that keys on the drafts and the present ids repaints nothing while a
|
|
218
|
+
* peer only moves a cursor. A caller clears the ghost of every key a previous answer held and
|
|
219
|
+
* this one does not.
|
|
220
|
+
*/
|
|
221
|
+
export const peerDraftGhosts = (input: PeerDraftGhostsInput): PeerDraftGhost[] => {
|
|
222
|
+
const present = new Set(input.presentPeerIds);
|
|
223
|
+
const ghosts: PeerDraftGhost[] = [];
|
|
224
|
+
|
|
225
|
+
for (const [key, draft] of Object.entries(input.drafts)) {
|
|
226
|
+
if (!present.has(draft.userId)) {
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const color = collabPeerColor(draft.userId);
|
|
231
|
+
const label = input.resolveName?.(draft.userId) ?? peerDraftInitials(draft.userId);
|
|
232
|
+
|
|
233
|
+
if (draft.kind === "segment") {
|
|
234
|
+
if (draft.segment.id === input.localSegmentEditId) {
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const line = extractLines(draft.segment.geojson).find(
|
|
239
|
+
(candidate) => candidate.coordinates.length >= 2,
|
|
240
|
+
);
|
|
241
|
+
if (!line) {
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
ghosts.push({
|
|
246
|
+
color,
|
|
247
|
+
entity: { id: draft.segment.id, kind: "segment" },
|
|
248
|
+
geometry: line,
|
|
249
|
+
key,
|
|
250
|
+
label,
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// A zone draft carries its polygon and no id: the id is the part of the key after `zone/`.
|
|
257
|
+
const zoneId = key.slice(key.indexOf("/") + 1);
|
|
258
|
+
if (zoneId === input.localZoneEditId) {
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
ghosts.push({
|
|
263
|
+
color,
|
|
264
|
+
entity: { id: zoneId, kind: "zone" },
|
|
265
|
+
geometry: draft.zone,
|
|
266
|
+
key,
|
|
267
|
+
label,
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return ghosts;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* permittedEnrichmentOverlays answers the enrichment overlays a map draws: each active slug
|
|
276
|
+
* the manifest holds, once, in the order the slugs are active, the points of interest only for a
|
|
277
|
+
* viewer who holds the `map-pois` entitlement and every other one only for a viewer who holds
|
|
278
|
+
* `map-overlays`.
|
|
279
|
+
*
|
|
280
|
+
* Each entitlement is the scope in view's answer, which follows the organization's agreement
|
|
281
|
+
* and, under a publishable key, its safety rules (the overlay allowlist), and this is the gate a
|
|
282
|
+
* map draws by: the same answer a layers picker offers by
|
|
283
|
+
* (`filterOverlayCategories`, `filterEnrichmentOverlays`) and the sample tools refuse by. It is
|
|
284
|
+
* applied before anything is mounted: a slug can arrive from a link or a tool call without
|
|
285
|
+
* passing a picker, and an overlay the viewer may not see then costs no tile request the API
|
|
286
|
+
* would refuse.
|
|
287
|
+
*
|
|
288
|
+
* A slug the manifest does not hold is dropped. A slug active twice is answered once, where it
|
|
289
|
+
* first stands: a map mounts an overlay's sources under their ids, and a second mount of one id
|
|
290
|
+
* is refused by a renderer. The slug is looked up across every category of the manifest, the one
|
|
291
|
+
* named for enrichments or another.
|
|
292
|
+
*
|
|
293
|
+
* @param overlaysEntitled Whether the viewer holds `map-overlays`.
|
|
294
|
+
* @param poisEntitled Whether the viewer holds `map-pois`.
|
|
295
|
+
*/
|
|
296
|
+
export const permittedEnrichmentOverlays = (
|
|
297
|
+
layers: Layers,
|
|
298
|
+
activeEnrichments: readonly string[],
|
|
299
|
+
overlaysEntitled: boolean,
|
|
300
|
+
poisEntitled: boolean,
|
|
301
|
+
): Overlay[] =>
|
|
302
|
+
[...new Set(activeEnrichments)].flatMap((slug) => {
|
|
303
|
+
if (!(slug === POIS_OVERLAY_SLUG ? poisEntitled : overlaysEntitled)) {
|
|
304
|
+
return [];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const overlay = findOverlay({ overlays: layers.overlays ?? [] }, slug);
|
|
308
|
+
|
|
309
|
+
return overlay === null ? [] : [overlay];
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* permittedClassicOverlay answers the classic overlay a map draws: the overlay the active slug
|
|
314
|
+
* names in the manifest, or null with no active slug, with a slug the manifest does not hold, and
|
|
315
|
+
* for a viewer who does not hold the `map-overlays` entitlement.
|
|
316
|
+
*
|
|
317
|
+
* It is {@link permittedEnrichmentOverlays}' twin for the one overlay that replaces the others,
|
|
318
|
+
* under the same gate: a slug the store holds for a viewer the scope in view does not answer
|
|
319
|
+
* `map-overlays` for is drawn for nobody, whether the organization's agreement or, under a
|
|
320
|
+
* publishable key, its safety rules withhold it.
|
|
321
|
+
*
|
|
322
|
+
* @param activeOverlay The slug the studio's state holds active, or null.
|
|
323
|
+
* @param overlaysEntitled Whether the viewer holds `map-overlays`.
|
|
324
|
+
*/
|
|
325
|
+
export const permittedClassicOverlay = (
|
|
326
|
+
layers: Layers,
|
|
327
|
+
activeOverlay: string | null,
|
|
328
|
+
overlaysEntitled: boolean,
|
|
329
|
+
): Overlay | null =>
|
|
330
|
+
overlaysEntitled && activeOverlay !== null
|
|
331
|
+
? findOverlay({ overlays: layers.overlays ?? [] }, activeOverlay)
|
|
332
|
+
: null;
|
|
333
|
+
|
|
334
|
+
/** The group that owns each points-of-interest layer key. */
|
|
335
|
+
const poiGroupByLayerKey: ReadonlyMap<string, string> = new Map(
|
|
336
|
+
POI_GROUPS.flatMap((group) => group.layerKeys.map((key) => [key, group.id] as const)),
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
/** PoiLayerVisibility is one points-of-interest render layer, and whether it shows. */
|
|
340
|
+
export interface PoiLayerVisibility {
|
|
341
|
+
/** The render layer's id in the manifest, which is the id a map client toggles it by. */
|
|
342
|
+
readonly layerId: string;
|
|
343
|
+
/** Whether the layer shows. */
|
|
344
|
+
readonly visible: boolean;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* poiLayerVisibility answers whether each render layer of the points-of-interest overlay
|
|
349
|
+
* shows, for the active groups, in manifest order.
|
|
350
|
+
*
|
|
351
|
+
* A layer shows when the group that owns its key is among `activePoiGroups` (`POI_GROUPS`
|
|
352
|
+
* says which keys a group gathers: lodging is refuges, hotels, campsites and caravan sites
|
|
353
|
+
* under one switch). A layer whose key no group owns shows always, so a layer the manifest
|
|
354
|
+
* gains before its menu entry exists is never hidden with no switch to bring it back.
|
|
355
|
+
*
|
|
356
|
+
* Empty when the manifest holds no such overlay. Whether the overlay itself is on the map is
|
|
357
|
+
* not answered here: it is an enrichment, and {@link permittedEnrichmentOverlays} decides that.
|
|
358
|
+
*/
|
|
359
|
+
export const poiLayerVisibility = (
|
|
360
|
+
layers: Layers,
|
|
361
|
+
activePoiGroups: readonly string[],
|
|
362
|
+
): PoiLayerVisibility[] => {
|
|
363
|
+
const overlay = findOverlay({ overlays: layers.overlays ?? [] }, POIS_OVERLAY_SLUG);
|
|
364
|
+
if (!overlay) {
|
|
365
|
+
return [];
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
const active = new Set(activePoiGroups);
|
|
369
|
+
|
|
370
|
+
return overlay.sources.flatMap((source) =>
|
|
371
|
+
source.layers.map((layer) => {
|
|
372
|
+
const group = poiGroupByLayerKey.get(layer.key);
|
|
373
|
+
|
|
374
|
+
return { layerId: layer.id, visible: group === undefined || active.has(group) };
|
|
375
|
+
}),
|
|
376
|
+
);
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
// The tile sources fetched again for an instant are the elements' `timestampedSources`: the
|
|
380
|
+
// classic overlay's, where the server stamps it, and never the zones', which take a timestamp and
|
|
381
|
+
// would then answer only the zones active at that instant, hiding the ended and upcoming zones a
|
|
382
|
+
// studio draws with their own treatment. A zone is styled by time on the client instead, against
|
|
383
|
+
// `zoneTimeReferenceSeconds`. A binding gates it on `permittedClassicOverlay`, as the map draws by.
|
|
384
|
+
export { type TimestampedSource, timestampedSources } from "@mountaya/elements/layers";
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* ZONE_TIME_REFERENCE_INTERVAL_MS is how often the zone layers' live time reference moves, in
|
|
388
|
+
* milliseconds: one minute.
|
|
389
|
+
*
|
|
390
|
+
* It is the one statement of that minute. {@link zoneTimeReferenceSeconds} floors the clock to
|
|
391
|
+
* it, and a binding that re-reads the reference on a timer arms that timer for the next
|
|
392
|
+
* multiple of it, so the timer fires when the reference moves and at no other time. A second
|
|
393
|
+
* statement of the interval in a binding is how the two drift apart.
|
|
394
|
+
*/
|
|
395
|
+
export const ZONE_TIME_REFERENCE_INTERVAL_MS = /*#__PURE__*/ convertDuration(
|
|
396
|
+
1,
|
|
397
|
+
"minute",
|
|
398
|
+
"millisecond",
|
|
399
|
+
);
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* zoneTimeReferenceSeconds answers the instant, in whole epoch seconds, that the zone layers
|
|
403
|
+
* evaluate each zone's time window against.
|
|
404
|
+
*
|
|
405
|
+
* A pinned `overlayTimestamp` (an ISO 8601 instant, the layers panel's slider) is its own
|
|
406
|
+
* second, floored, and does not move with the clock. With none pinned the reference is the
|
|
407
|
+
* start of the {@link ZONE_TIME_REFERENCE_INTERVAL_MS} interval `nowMs` falls in, the minute,
|
|
408
|
+
* so it moves when the minute does and at no other time.
|
|
409
|
+
*
|
|
410
|
+
* None is pinned for null, for an empty string, and for a string that names no instant
|
|
411
|
+
* ("tomorrow"). The verb that writes the pin refuses such a string, and a pin restored from a
|
|
412
|
+
* link or a past session can still hold one: it is read as no pin and never as `NaN`, which a
|
|
413
|
+
* client would write into the zone layers' filters.
|
|
414
|
+
*
|
|
415
|
+
* The minute is the rule and not a rounding convenience. A map client writes the reference
|
|
416
|
+
* into the zone layers' filters, and each write restyles the zones, so a reference that moved
|
|
417
|
+
* every second would rewrite them once a second for as long as a camera moved. On the minute, a
|
|
418
|
+
* zone reads as active, and as ended, within a minute of its window opening and closing.
|
|
419
|
+
*
|
|
420
|
+
* A caller asks again whenever the clock or the camera moves and writes the answer only when
|
|
421
|
+
* it differs from the last one written.
|
|
422
|
+
*
|
|
423
|
+
* @param overlayTimestamp The pinned instant, or null with none pinned.
|
|
424
|
+
* @param nowMs The current instant in epoch milliseconds, read off the clock seam.
|
|
425
|
+
*/
|
|
426
|
+
export const zoneTimeReferenceSeconds = (
|
|
427
|
+
overlayTimestamp: string | null,
|
|
428
|
+
nowMs: number,
|
|
429
|
+
): number => {
|
|
430
|
+
const pinnedMs = overlayTimestamp ? new Date(overlayTimestamp).getTime() : Number.NaN;
|
|
431
|
+
if (!Number.isNaN(pinnedMs)) {
|
|
432
|
+
return Math.floor(convertDuration(pinnedMs, "millisecond", "second"));
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
const intervalStartMs =
|
|
436
|
+
Math.floor(nowMs / ZONE_TIME_REFERENCE_INTERVAL_MS) * ZONE_TIME_REFERENCE_INTERVAL_MS;
|
|
437
|
+
|
|
438
|
+
return convertDuration(intervalStartMs, "millisecond", "second");
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* activeSegmentLines answers the lines a waypoint being placed snaps onto: every line of the
|
|
443
|
+
* open itinerary's segments, in chain order and then in the order a segment writes them, each
|
|
444
|
+
* as its coordinates.
|
|
445
|
+
*
|
|
446
|
+
* A segment's geometry is read through `extractLines`: each `LineString` and each line of a
|
|
447
|
+
* `MultiLineString`, the shape a segment drawn as tracks has. Only its lines are read: a routed
|
|
448
|
+
* segment also carries its via points, which are not on the course. Empty with no itinerary
|
|
449
|
+
* open, and for a segment that carries no geometry yet, which leaves a client nothing to snap
|
|
450
|
+
* to.
|
|
451
|
+
*/
|
|
452
|
+
export const activeSegmentLines = (
|
|
453
|
+
itinerary: Pick<ItineraryWithDetails, "segments"> | null,
|
|
454
|
+
): Position[][] =>
|
|
455
|
+
(itinerary?.segments ?? []).flatMap((segment) =>
|
|
456
|
+
extractLines(segment.geojson).map((line) => line.coordinates),
|
|
457
|
+
);
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* resolveDemUrl answers which elevation raster a map bakes its relief from, or undefined for
|
|
461
|
+
* none.
|
|
462
|
+
*
|
|
463
|
+
* The sources, in this order. A host that names one has the final say: it pays for that
|
|
464
|
+
* account, and it may serve heights Mountaya does not publish. Otherwise the layers manifest's
|
|
465
|
+
* own `elevation`, which every credential can read, so a consumer that wires nothing still gets
|
|
466
|
+
* a map in relief. An empty host address names none, as a host forwarding an unset environment
|
|
467
|
+
* value passes one, and the manifest's elevation answers for it.
|
|
468
|
+
*
|
|
469
|
+
* Undefined when neither answers, which leaves the map flat. An address assembled from nothing
|
|
470
|
+
* is still a well-formed one, and a renderer handed it requests it per tile, per pan, for as
|
|
471
|
+
* long as the map lives.
|
|
472
|
+
*/
|
|
473
|
+
export const resolveDemUrl = (
|
|
474
|
+
layers: Layers | null | undefined,
|
|
475
|
+
demUrl: string | undefined,
|
|
476
|
+
): string | undefined => demUrl || layers?.elevation?.url || undefined;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
|
|
3
|
+
import type { OverlayFeature } from "@mountaya/elements/map-client";
|
|
4
|
+
|
|
5
|
+
/** terrainChannelsSchema holds the channels a terrain reading states as numbers. */
|
|
6
|
+
const terrainChannelsSchema = z.object({
|
|
7
|
+
aspect: z.number().optional(),
|
|
8
|
+
elevation: z.number().optional(),
|
|
9
|
+
slope: z.number().optional(),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* overlaySampleResultSchema is the per-cursor terrain readout a DEM sample
|
|
14
|
+
* resolves to: elevation in meters, slope in degrees, aspect as a 0..360°
|
|
15
|
+
* compass bearing, and a steepness band label. Every field is
|
|
16
|
+
* optional because a reader drops keys whose value is undefined before forwarding (the
|
|
17
|
+
* right-click popup, the agent terrain tools).
|
|
18
|
+
*
|
|
19
|
+
* It lives in this package rather than beside the DEM sampler that produces it, which is
|
|
20
|
+
* renderer-bound: a terrain tool importing the schema as a value from there would pull MapLibre
|
|
21
|
+
* into a handler that renders nothing. Both the web sampler and the bus's terrain tools
|
|
22
|
+
* validate against this one schema.
|
|
23
|
+
*/
|
|
24
|
+
export const overlaySampleResultSchema = terrainChannelsSchema.extend({
|
|
25
|
+
steepness_class: z.string().optional(),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* OverlaySampleResult is one cursor terrain readout, derived from
|
|
30
|
+
* overlaySampleResultSchema.
|
|
31
|
+
*/
|
|
32
|
+
export type OverlaySampleResult = z.infer<typeof overlaySampleResultSchema>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* terrainChannelsOf reads the terrain reading a map client answered under a point, channel by
|
|
36
|
+
* channel, through {@link overlaySampleResultSchema}: the elevation, the slope and the aspect.
|
|
37
|
+
*
|
|
38
|
+
* A channel is kept when its member of the schema parses it to a number, which a finite number
|
|
39
|
+
* does, and dropped otherwise. A map client's reading is a record whose values may be null, so
|
|
40
|
+
* a host's own client can answer one channel and not another: the reading keeps what it holds.
|
|
41
|
+
* Nothing here throws. It is the one read of `sampleOverlayAt` the terrain samplers and the
|
|
42
|
+
* context menu share, so a tool and the right-click readout keep the same channels of one
|
|
43
|
+
* reading.
|
|
44
|
+
*
|
|
45
|
+
* @param reading What the map client's `sampleOverlayAt` answered, or null for no reading.
|
|
46
|
+
* @returns The channels kept, or null for no reading and for one that holds no channel.
|
|
47
|
+
*/
|
|
48
|
+
export const terrainChannelsOf = (reading: OverlayFeature | null): OverlaySampleResult | null => {
|
|
49
|
+
if (!reading) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const sample: OverlaySampleResult = {};
|
|
54
|
+
for (const channel of terrainChannelsSchema.keyof().options) {
|
|
55
|
+
const parsed = terrainChannelsSchema.shape[channel].safeParse(reading[channel]);
|
|
56
|
+
if (parsed.success && parsed.data !== undefined) {
|
|
57
|
+
sample[channel] = parsed.data;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return Object.keys(sample).length === 0 ? null : sample;
|
|
62
|
+
};
|