@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,129 @@
|
|
|
1
|
+
import type { SegmentEditMode } from "@mountaya/elements/data";
|
|
2
|
+
import { DIRECTIONS_VIA_MAX, extractVias, segmentLineCoordinates } from "@mountaya/elements/geo";
|
|
3
|
+
import { DEFAULT_SEGMENT_COLOR } from "@mountaya/elements/style";
|
|
4
|
+
|
|
5
|
+
import type { StudioToolInputs } from "../../bus/contracts/studioTools.js";
|
|
6
|
+
import type { ToolResult } from "../../bus/rules/types.js";
|
|
7
|
+
import type { ItineraryDraftSegment } from "../../itinerary/rules/import.js";
|
|
8
|
+
import { hexColorSchema } from "./colors.js";
|
|
9
|
+
import { clampSeedPoint, type SegmentEditSeed, seedFromCoordinates } from "./engine.js";
|
|
10
|
+
import { simplifyToVias } from "./viaSimplify.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* DraftSegmentEditAnchor is what a draft row knows about its segment's place in the draft chain,
|
|
14
|
+
* which is everything a begin-edit reads from the rest of the chain.
|
|
15
|
+
*/
|
|
16
|
+
export interface DraftSegmentEditAnchor {
|
|
17
|
+
/** Whether the segment is the chain's first entry, which has nothing before it to anchor to. */
|
|
18
|
+
isFirst: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The previous entry's chosen-geometry end as `[lng, lat]`, or null when it has none. Every
|
|
21
|
+
* entry after the first pins its start here, so the draft stays continuous for the confirm snap.
|
|
22
|
+
*/
|
|
23
|
+
previousEnd: [number, number] | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* draftSeed derives the begin-edit coordinates from a draft segment's candidate in its current
|
|
28
|
+
* mode, or null when that candidate carries no usable geometry.
|
|
29
|
+
*
|
|
30
|
+
* A snapped segment seeds from its directions candidate's vias, the MultiPoint leaf, since the
|
|
31
|
+
* canonical directions geometry is the routed LineString plus that MultiPoint; with no MultiPoint
|
|
32
|
+
* it falls back to the routed line, reduced by {@link simplifyToVias} to the vias the router
|
|
33
|
+
* takes, since every coordinate of a seed is a point the route is made to pass through. A snapped
|
|
34
|
+
* segment with no directions candidate has nothing to seed a directions edit from. An exact
|
|
35
|
+
* segment seeds from its linestring candidate's coordinates. A candidate drawn as several lines
|
|
36
|
+
* is read whole, its lines end to end.
|
|
37
|
+
*/
|
|
38
|
+
const draftSeed = (segment: ItineraryDraftSegment): SegmentEditSeed | null => {
|
|
39
|
+
if (segment.mode === "directions") {
|
|
40
|
+
if (!segment.directions) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const vias = extractVias(segment.directions.geojson);
|
|
45
|
+
const rawSeed =
|
|
46
|
+
vias.length > 0
|
|
47
|
+
? vias
|
|
48
|
+
: simplifyToVias(segmentLineCoordinates(segment.directions.geojson), DIRECTIONS_VIA_MAX);
|
|
49
|
+
|
|
50
|
+
return rawSeed.length > 0 ? seedFromCoordinates(rawSeed) : null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const line = segmentLineCoordinates(segment.linestring.geojson);
|
|
54
|
+
|
|
55
|
+
return line.length > 0 ? seedFromCoordinates(line) : null;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* beginDraftSegmentEdit arms the geometry editor for one segment of an import or suggest draft,
|
|
60
|
+
* through the bus's `studio.itinerary.segment.editBegin` tool.
|
|
61
|
+
*
|
|
62
|
+
* A draft chain lives in the draft slice rather than in the open itinerary, so the begin payload
|
|
63
|
+
* is assembled from what the row knows: the chosen candidate's geometry seeds the edit, the
|
|
64
|
+
* previous entry's chosen end pins this one's start, and the draft activity's slug routes a
|
|
65
|
+
* snapped edit. A draft's colour is any string, and the begin takes a hex colour alone: a segment
|
|
66
|
+
* whose colour is no hex colour, the empty one a source with no colour leaves included, draws in
|
|
67
|
+
* {@link DEFAULT_SEGMENT_COLOR}.
|
|
68
|
+
*
|
|
69
|
+
* `dispatch` is the one bus call this makes, with the tool's own input. A bus bound to its
|
|
70
|
+
* context fits (`(name, input) => bus.dispatch(ctx, name, input)`), and so does a binding's own
|
|
71
|
+
* dispatch that is checked against every tool.
|
|
72
|
+
*
|
|
73
|
+
* Resolves to null, dispatching nothing, when the chosen candidate carries no usable geometry or
|
|
74
|
+
* a snapped segment carries no directions candidate at all: there is nothing to open, and a
|
|
75
|
+
* caller that reports a refusal has nothing to report. Otherwise it resolves to the tool's
|
|
76
|
+
* result, which is a refusal for a snapped edit with no `activitySlug` to route for.
|
|
77
|
+
*
|
|
78
|
+
* A persisted segment reopens through a binding's own begin-edit, which assembles the same payload
|
|
79
|
+
* from the open itinerary's stored chain and seeds it with {@link seedFromPersistedSegment}. The
|
|
80
|
+
* two differ in where the chain is read from, which is why they are separate rather than one
|
|
81
|
+
* function with a mode flag.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* declare const draft: ItineraryDraft;
|
|
86
|
+
*
|
|
87
|
+
* const segment = draft.segments[1];
|
|
88
|
+
* if (segment) {
|
|
89
|
+
* await beginDraftSegmentEdit(
|
|
90
|
+
* (name, input) => bus.dispatch(ctx, name, input),
|
|
91
|
+
* segment,
|
|
92
|
+
* { isFirst: false, previousEnd: [6.87, 45.92] },
|
|
93
|
+
* "hiking",
|
|
94
|
+
* );
|
|
95
|
+
* }
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export const beginDraftSegmentEdit = (
|
|
99
|
+
dispatch: (
|
|
100
|
+
name: "studio.itinerary.segment.editBegin",
|
|
101
|
+
input: StudioToolInputs["studio.itinerary.segment.editBegin"],
|
|
102
|
+
) => Promise<ToolResult>,
|
|
103
|
+
segment: ItineraryDraftSegment,
|
|
104
|
+
anchor: DraftSegmentEditAnchor,
|
|
105
|
+
activitySlug: string | null,
|
|
106
|
+
): Promise<ToolResult | null> => {
|
|
107
|
+
const mode: SegmentEditMode = segment.mode;
|
|
108
|
+
const seed = draftSeed(segment);
|
|
109
|
+
if (!seed) {
|
|
110
|
+
return Promise.resolve(null);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// The first draft segment has no previous end to anchor to, so its start is left unpinned and
|
|
114
|
+
// freely editable. The previous end is read straight off stored geometry (it does not flow
|
|
115
|
+
// through seedFromCoordinates), so it is clamped to the precision the seed vias carry: the
|
|
116
|
+
// freehand head-lock guard compares the pin against the first via exactly, and an unclamped
|
|
117
|
+
// pin past nine decimals would never equal the clamped head.
|
|
118
|
+
const previousPin = anchor.previousEnd ? clampSeedPoint(anchor.previousEnd) : null;
|
|
119
|
+
const pinnedStart = anchor.isFirst ? undefined : (previousPin ?? seed.pinnedStart);
|
|
120
|
+
|
|
121
|
+
return dispatch("studio.itinerary.segment.editBegin", {
|
|
122
|
+
activitySlug: activitySlug ?? undefined,
|
|
123
|
+
color: hexColorSchema.safeParse(segment.color).success ? segment.color : DEFAULT_SEGMENT_COLOR,
|
|
124
|
+
mode,
|
|
125
|
+
pinnedStart,
|
|
126
|
+
seedVias: seed.seedVias,
|
|
127
|
+
segmentId: segment.id,
|
|
128
|
+
});
|
|
129
|
+
};
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import type { ItinerarySegment, SegmentEditMode } from "@mountaya/elements/data";
|
|
2
|
+
import { DIRECTIONS_VIA_MAX, extractVias, segmentLineCoordinates } from "@mountaya/elements/geo";
|
|
3
|
+
|
|
4
|
+
import type { Activity, ActivityCapabilities, CategoryActivities } from "../../rules/types.js";
|
|
5
|
+
import { simplifyToVias } from "./viaSimplify.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* activityForId finds the activity with the given id across the grouped catalog (each category
|
|
9
|
+
* holds its activities as children), so a caller holding only an itinerary's immutable activity_id
|
|
10
|
+
* can read the activity's slug + capabilities. Returns null when the catalog has not loaded or the
|
|
11
|
+
* id is absent from it. It lives here so every surface that resolves an authoring engine from an
|
|
12
|
+
* activity (the editor's segment list, the add control, the agent-facing propose tools) shares one
|
|
13
|
+
* lookup rather than walking the catalog in parallel.
|
|
14
|
+
*/
|
|
15
|
+
export const activityForId = (
|
|
16
|
+
categories: readonly CategoryActivities[],
|
|
17
|
+
activityId: string,
|
|
18
|
+
): Activity | null => {
|
|
19
|
+
for (const category of categories) {
|
|
20
|
+
const activity = category.children.find((child) => child.id === activityId);
|
|
21
|
+
if (activity) {
|
|
22
|
+
return activity;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return null;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* firstActivityId returns the id of the first activity in the grouped catalog (the first category's
|
|
31
|
+
* first child), or null when the catalog has not resolved or carries no activities. The create form
|
|
32
|
+
* and the import shell both seed a fresh itinerary's activity from this one rule (the first
|
|
33
|
+
* activity in the list) rather than from parallel reaches into `categories[0].children[0]`.
|
|
34
|
+
*/
|
|
35
|
+
export const firstActivityId = (categories: readonly CategoryActivities[]): string | null =>
|
|
36
|
+
categories[0]?.children[0]?.id ?? null;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* defaultEngineForActivity picks the authoring engine a new segment of an activity opens in:
|
|
40
|
+
* `directions` when the catalog says the activity can be routed, and `linestring` otherwise.
|
|
41
|
+
*
|
|
42
|
+
* It answers for every input, so it is not the question of whether the activity may be drawn at
|
|
43
|
+
* all: {@link availableEnginesForActivity} answers that, and its list is empty for an activity
|
|
44
|
+
* the catalog gives neither engine. For every other activity this is the first engine of that
|
|
45
|
+
* list. `analysis` is no authoring engine and never enters the choice.
|
|
46
|
+
*
|
|
47
|
+
* @param capabilities The activity's capabilities as the catalog serves them, or `null` or
|
|
48
|
+
* `undefined` while the catalog has not resolved, which answers `linestring` so a person can
|
|
49
|
+
* still draw.
|
|
50
|
+
*/
|
|
51
|
+
export const defaultEngineForActivity = (
|
|
52
|
+
capabilities: ActivityCapabilities | null | undefined,
|
|
53
|
+
): SegmentEditMode => (capabilities?.directions === true ? "directions" : "linestring");
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* availableEnginesForActivity lists the authoring engines a new segment of an activity may open
|
|
57
|
+
* in, in the order an add control offers them: `directions` where the catalog says the activity
|
|
58
|
+
* can be routed, then `linestring` where it says a line may be drawn by hand.
|
|
59
|
+
*
|
|
60
|
+
* Directions come first, so the first entry is what {@link defaultEngineForActivity} answers and
|
|
61
|
+
* a picker's default for an activity that offers both. A surface shows a picker only for a list
|
|
62
|
+
* of two.
|
|
63
|
+
*
|
|
64
|
+
* @param capabilities The activity's capabilities as the catalog serves them, or `null` or
|
|
65
|
+
* `undefined` while the catalog has not resolved.
|
|
66
|
+
* @returns The engines offered. Empty for an activity the catalog gives neither engine: nothing
|
|
67
|
+
* can be drawn for it, and a surface offers no add control. A catalog that has not resolved
|
|
68
|
+
* answers `["linestring"]`, so a person can still draw before it lands.
|
|
69
|
+
*/
|
|
70
|
+
export const availableEnginesForActivity = (
|
|
71
|
+
capabilities: ActivityCapabilities | null | undefined,
|
|
72
|
+
): SegmentEditMode[] => {
|
|
73
|
+
if (capabilities === null || capabilities === undefined) {
|
|
74
|
+
return ["linestring"];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const engines: SegmentEditMode[] = [];
|
|
78
|
+
if (capabilities.directions === true) {
|
|
79
|
+
engines.push("directions");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (capabilities.linestring === true) {
|
|
83
|
+
engines.push("linestring");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return engines;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* defaultSpeedForActivity reads the activity's default travel speed (km/h) the speed control seeds
|
|
91
|
+
* a segment with when the segment carries no own speed. The figure is the activity's
|
|
92
|
+
* routing-profile default, which the catalog answers on the capabilities so it is stated in one
|
|
93
|
+
* place, the API's, rather than mirrored here. Returns null when the capability set has not
|
|
94
|
+
* resolved yet (the catalog is still loading), so the caller seeds empty until it lands.
|
|
95
|
+
*/
|
|
96
|
+
export const defaultSpeedForActivity = (
|
|
97
|
+
capabilities: ActivityCapabilities | null | undefined,
|
|
98
|
+
): number | null => capabilities?.default_speed ?? null;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* SegmentEditSeed is the begin-edit seed a directions/linestring engine arms from:
|
|
102
|
+
* the editable [lng, lat] vias the SDK draws draggable handles for, and the boundary
|
|
103
|
+
* vertices pinned to the neighbouring segments. pinnedStart locks vertex 0 to the
|
|
104
|
+
* PREVIOUS segment's end and pinnedEnd locks the last vertex to the NEXT segment's
|
|
105
|
+
* start, so an edit that lands inside the chain meets both neighbours exactly and
|
|
106
|
+
* leaves their geometry untouched. Each is undefined when there is no neighbour on
|
|
107
|
+
* that side: an append has no successor, a head insert has no predecessor, and a
|
|
108
|
+
* from-scratch first segment has neither.
|
|
109
|
+
*/
|
|
110
|
+
export interface SegmentEditSeed {
|
|
111
|
+
pinnedEnd: [number, number] | undefined;
|
|
112
|
+
pinnedStart: [number, number] | undefined;
|
|
113
|
+
seedVias: [number, number][];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* SEED_COORDINATE_PRECISION bounds a seed ordinate to nine decimal places (~0.1mm at the equator),
|
|
118
|
+
* the coordinate precision the freehand edit engine accepts. A stored segment carries its DEM
|
|
119
|
+
* elevations zipped into a 3D LineString, and reading that geometry back through float64 leaves a
|
|
120
|
+
* flattened [lng, lat] ordinate with more decimal places than that: 6.170024872 arrives as
|
|
121
|
+
* 6.170024872000001. The engine validates a seeded line against this same bound and drops a
|
|
122
|
+
* coordinate that exceeds it, so an unclamped seed never arms the saved line for reshape; clamping
|
|
123
|
+
* every ordinate to the bound keeps the arm honest without moving the vertex a visible amount.
|
|
124
|
+
*/
|
|
125
|
+
const SEED_COORDINATE_PRECISION = 9;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* clampSeedOrdinate rounds one ordinate to {@link SEED_COORDINATE_PRECISION}
|
|
129
|
+
* decimal places, the way the edit engine limits an interactively-drawn
|
|
130
|
+
* coordinate, so a seed derived from stored geometry meets the same precision
|
|
131
|
+
* bound the engine holds its own vertices to.
|
|
132
|
+
*/
|
|
133
|
+
const clampSeedOrdinate = (ordinate: number): number => {
|
|
134
|
+
const factor = 10 ** SEED_COORDINATE_PRECISION;
|
|
135
|
+
|
|
136
|
+
return Math.round(ordinate * factor) / factor;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* clampSeedPoint narrows one GeoJSON position to the [lng, lat] tuple a segment edit seeds from,
|
|
141
|
+
* clamping each ordinate to {@link SEED_COORDINATE_PRECISION} decimal places. It is the single
|
|
142
|
+
* place a geometry-derived coordinate becomes an editor seed coordinate:
|
|
143
|
+
* {@link seedFromCoordinates} maps it over a via list, and the chain's previous-segment-end pin
|
|
144
|
+
* (read straight off a stored segment's tail, so it does NOT flow through seedFromCoordinates) runs
|
|
145
|
+
* one coordinate through it. Routing both through this one clamp means a pin and a seed via built
|
|
146
|
+
* from the same stored coordinate land byte-identical. The freehand head-lock guard compares the
|
|
147
|
+
* pin against the first via exactly, so any coordinate handed to a begin-edit must pass through
|
|
148
|
+
* this clamp or a stored line's float64 round-trip (which zips DEM elevations into a 3D LineString
|
|
149
|
+
* and reads back >9 decimal places) leaves the pin unequal to the head and the reshape never arms.
|
|
150
|
+
*/
|
|
151
|
+
export const clampSeedPoint = (position: readonly number[]): [number, number] => [
|
|
152
|
+
clampSeedOrdinate(position[0] ?? 0),
|
|
153
|
+
clampSeedOrdinate(position[1] ?? 0),
|
|
154
|
+
];
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* seedFromCoordinates narrows a GeoJSON Position list (each [lng, lat, …]) to the [lng, lat] tuple
|
|
158
|
+
* seed a segment geometry edit arms from, pinning the start to the head. It is the one shaper the
|
|
159
|
+
* begin-edit seed flows through, so a persisted segment's saved vias, an import draft segment's
|
|
160
|
+
* chosen-candidate geometry, and a suggested itinerary's simplified vias all arm the
|
|
161
|
+
* directions/linestring engines from an identical shape: the seam the editor sidenav and the
|
|
162
|
+
* suggest auto-arm share rather than re-deriving the tuple narrowing in parallel. Each ordinate is
|
|
163
|
+
* clamped through {@link clampSeedPoint} to the precision the edit engine accepts so a stored
|
|
164
|
+
* line's float64 round-trip cannot leave a seed the engine rejects, and the pinned start is read
|
|
165
|
+
* off the clamped head so it stays byte-identical to the first via (the head-lock guard compares
|
|
166
|
+
* the two). An empty list yields an undefined pinned start and no vias.
|
|
167
|
+
*
|
|
168
|
+
* A reshape leaves its end free: the tail is the user's to drag, and the API re-seats the
|
|
169
|
+
* successor's start against wherever it lands. Only an INSERT pins both boundaries, and it builds
|
|
170
|
+
* its seed from the two neighbours rather than from an existing line, so it does not flow through
|
|
171
|
+
* here.
|
|
172
|
+
*/
|
|
173
|
+
export const seedFromCoordinates = (
|
|
174
|
+
coordinates: readonly (readonly number[])[],
|
|
175
|
+
): SegmentEditSeed => {
|
|
176
|
+
const seedVias: [number, number][] = coordinates.map((via) => clampSeedPoint(via));
|
|
177
|
+
const head = seedVias[0];
|
|
178
|
+
const pinnedStart: [number, number] | undefined = head ? [head[0], head[1]] : undefined;
|
|
179
|
+
|
|
180
|
+
return { pinnedEnd: undefined, pinnedStart, seedVias };
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* seedFromPersistedSegment derives the begin-edit coordinates from a persisted segment and the
|
|
185
|
+
* engine it is being reopened in: the router vias when the segment is routed (the saved
|
|
186
|
+
* MultiPoint), the drawn vias when it is freehand.
|
|
187
|
+
*
|
|
188
|
+
* A freehand segment stores the sparse vias the user drew as a MultiPoint alongside the densified
|
|
189
|
+
* profile LineString (the same MultiPoint-plus-LineString shape a directions segment carries), so
|
|
190
|
+
* the freehand branch prefers those vias too, keeping the reshape handles at the drawn vertices
|
|
191
|
+
* rather than at the hundreds of densified samples. An older freehand segment (or a dense import)
|
|
192
|
+
* carries no MultiPoint, so it falls back to the coordinates of its line, and of every line end to
|
|
193
|
+
* end for a segment drawn as several. The start vertex is pinned to the seed's head, as
|
|
194
|
+
* {@link seedFromCoordinates} does for every reshape.
|
|
195
|
+
*
|
|
196
|
+
* A routed segment stored with no MultiPoint (a segment written by another client, or a routed line
|
|
197
|
+
* imported whole) seeds from its routed line, every line end to end, reduced by
|
|
198
|
+
* {@link simplifyToVias} to at most `DIRECTIONS_VIA_MAX` vias. Every coordinate of a directions
|
|
199
|
+
* seed is a point the route is made to pass through, so the line is never handed over whole, and a
|
|
200
|
+
* seed of no via would reopen the segment with no handle to drag. Saved vias are used as they are
|
|
201
|
+
* stored and never reduced.
|
|
202
|
+
*
|
|
203
|
+
* This is the half of "reopen a segment for editing" that is a RULE rather than a lifecycle, which
|
|
204
|
+
* is why it is here rather than in whatever hook arms the engine: reading the wrong geometry leaf
|
|
205
|
+
* for the mode is silent. The edit opens, and the user's handles are in the wrong places.
|
|
206
|
+
*/
|
|
207
|
+
export const seedFromPersistedSegment = (
|
|
208
|
+
segment: Pick<ItinerarySegment, "geojson">,
|
|
209
|
+
mode: SegmentEditMode,
|
|
210
|
+
): SegmentEditSeed => {
|
|
211
|
+
const vias = extractVias(segment.geojson);
|
|
212
|
+
if (vias.length > 0) {
|
|
213
|
+
return seedFromCoordinates(vias);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Every line the segment holds, end to end: a segment drawn as several tracks reopens whole.
|
|
217
|
+
const line = segmentLineCoordinates(segment.geojson);
|
|
218
|
+
|
|
219
|
+
return seedFromCoordinates(
|
|
220
|
+
mode === "directions" ? simplifyToVias(line, DIRECTIONS_VIA_MAX) : line,
|
|
221
|
+
);
|
|
222
|
+
};
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a save of one segment group sends, in which order, and when its form counts as changed.
|
|
3
|
+
*
|
|
4
|
+
* A group is created through one verb, and an existing one is saved through two: its membership
|
|
5
|
+
* through `studio.itinerary.group.setRange` and its display fields (name, colour, speed) through
|
|
6
|
+
* `studio.itinerary.group.update`. A group form holds all of it until Save, so the rules that turn
|
|
7
|
+
* one form into an ordered run of dispatches are the studio's: which field withholds the save,
|
|
8
|
+
* which verbs go out with which members, in which order, and whether anything moved at all. A
|
|
9
|
+
* surface opens an existing group's form through {@link segmentGroupForm}, binds its inputs to a
|
|
10
|
+
* {@link SegmentGroupForm}, asks {@link segmentGroupSavePlan} at every change, and dispatches the
|
|
11
|
+
* plan's steps when the reader saves.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
type ItinerarySegment,
|
|
16
|
+
type ItinerarySegmentGroup,
|
|
17
|
+
SEGMENT_GROUP_MIN_MEMBERS,
|
|
18
|
+
} from "@mountaya/elements/data";
|
|
19
|
+
|
|
20
|
+
import type { StudioToolInputs } from "../../bus/contracts/studioTools.js";
|
|
21
|
+
import { displayNameSchema } from "../../edit/rules/draftMetadata.js";
|
|
22
|
+
import type { StudioStrings } from "../../strings/rules/en.js";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* SegmentGroupOpened is what the display fields of an existing group held as its form opened, and
|
|
26
|
+
* the group's id.
|
|
27
|
+
*/
|
|
28
|
+
export interface SegmentGroupOpened {
|
|
29
|
+
/** The colour the group was painted in, as `#rrggbb`. */
|
|
30
|
+
readonly color: string;
|
|
31
|
+
/** The id of the group the form edits. */
|
|
32
|
+
readonly groupId: string;
|
|
33
|
+
/** The group's name. */
|
|
34
|
+
readonly name: string;
|
|
35
|
+
/** The group's speed override in km/h, or null for none. */
|
|
36
|
+
readonly speed: number | null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* SegmentGroupForm is everything a group form holds while it is open: the group's display fields
|
|
41
|
+
* as typed, the run it covers, and what an existing group opened on.
|
|
42
|
+
*
|
|
43
|
+
* It is a form's state and not the wire's: the name is the text typed, white space and all.
|
|
44
|
+
*/
|
|
45
|
+
export interface SegmentGroupForm {
|
|
46
|
+
/** The colour the group paints, as `#rrggbb`. */
|
|
47
|
+
readonly color: string;
|
|
48
|
+
/** The typed name. */
|
|
49
|
+
readonly name: string;
|
|
50
|
+
/**
|
|
51
|
+
* The display fields of the group the form edits as it opened, or null for a form that creates
|
|
52
|
+
* a group. A save compares the form with them, so a field the reader left as it opened is sent
|
|
53
|
+
* by no verb and a collaborator's change made since stands.
|
|
54
|
+
*/
|
|
55
|
+
readonly opened: SegmentGroupOpened | null;
|
|
56
|
+
/** The ids of the segments the run holds, in chain order. */
|
|
57
|
+
readonly segmentIds: readonly string[];
|
|
58
|
+
/** The speed override in km/h, or null for none, so each member keeps its own pace. */
|
|
59
|
+
readonly speed: number | null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* SegmentGroupRefusal names the field that withholds a save, by the key of the sentence the
|
|
64
|
+
* studio's copy holds for it under `segmentGroup`.
|
|
65
|
+
*
|
|
66
|
+
* A key and no sentence, so a surface words it in the reader's language:
|
|
67
|
+
* `strings.segmentGroup[refusal]`. The compiler holds each member to a key of the bundle.
|
|
68
|
+
*/
|
|
69
|
+
export type SegmentGroupRefusal = Extract<
|
|
70
|
+
keyof StudioStrings["segmentGroup"],
|
|
71
|
+
"minMembers" | "nameError"
|
|
72
|
+
>;
|
|
73
|
+
|
|
74
|
+
/** The verbs a save of one group dispatches, in the order a plan sends them. */
|
|
75
|
+
type SegmentGroupSaveVerb =
|
|
76
|
+
| "studio.itinerary.group.create"
|
|
77
|
+
| "studio.itinerary.group.setRange"
|
|
78
|
+
| "studio.itinerary.group.update";
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* SegmentGroupSaveStep is one dispatch of a save: a verb's name and the input it is sent with,
|
|
82
|
+
* typed by that verb's contract.
|
|
83
|
+
*/
|
|
84
|
+
export type SegmentGroupSaveStep = {
|
|
85
|
+
[Verb in SegmentGroupSaveVerb]: {
|
|
86
|
+
readonly input: StudioToolInputs[Verb];
|
|
87
|
+
readonly name: Verb;
|
|
88
|
+
};
|
|
89
|
+
}[SegmentGroupSaveVerb];
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* SegmentGroupSavePlan is what {@link segmentGroupSavePlan} answers for one form over one chain.
|
|
93
|
+
*/
|
|
94
|
+
export interface SegmentGroupSavePlan {
|
|
95
|
+
/**
|
|
96
|
+
* Whether a save would write anything, so a surface offers Save as its live action. A create
|
|
97
|
+
* always writes. A save of an existing group writes where its run differs from the one the
|
|
98
|
+
* chain holds or a display field moved since the form opened.
|
|
99
|
+
*/
|
|
100
|
+
readonly changed: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* The first field that withholds the save, the run before the name, or null. It reads the form
|
|
103
|
+
* alone, so a surface that shows it can ask over any chain.
|
|
104
|
+
*/
|
|
105
|
+
readonly refusal: SegmentGroupRefusal | null;
|
|
106
|
+
/**
|
|
107
|
+
* The dispatches of a save, in the order they are sent. A caller sends each once the one
|
|
108
|
+
* before it has answered `ok`, and stops at the first refusal. Empty while a field refuses.
|
|
109
|
+
*/
|
|
110
|
+
readonly steps: readonly SegmentGroupSaveStep[];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* heldRun reads the run `segments` holds for one group: the ids of its members, in chain order.
|
|
115
|
+
*/
|
|
116
|
+
const heldRun = (
|
|
117
|
+
segments: readonly Pick<ItinerarySegment, "group_id" | "id">[],
|
|
118
|
+
groupId: string,
|
|
119
|
+
): string[] =>
|
|
120
|
+
segments.filter((segment) => segment.group_id === groupId).map((segment) => segment.id);
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* segmentGroupForm reads a saved group and the chain it stands in into the form a group editor
|
|
124
|
+
* opens on: the group's display fields, the run the chain holds for it, and `opened` set to what
|
|
125
|
+
* the display fields hold now.
|
|
126
|
+
*
|
|
127
|
+
* A form that creates a group has no record to read, so its surface writes the run it proposes
|
|
128
|
+
* and `opened: null` itself.
|
|
129
|
+
*
|
|
130
|
+
* @param group The saved group, as the itinerary holds it.
|
|
131
|
+
* @param segments The itinerary's chain, read for the run the group holds.
|
|
132
|
+
*/
|
|
133
|
+
export const segmentGroupForm = (
|
|
134
|
+
group: Pick<ItinerarySegmentGroup, "color" | "id" | "name" | "speed">,
|
|
135
|
+
segments: readonly Pick<ItinerarySegment, "group_id" | "id">[],
|
|
136
|
+
): SegmentGroupForm => ({
|
|
137
|
+
color: group.color,
|
|
138
|
+
name: group.name,
|
|
139
|
+
opened: { color: group.color, groupId: group.id, name: group.name, speed: group.speed },
|
|
140
|
+
segmentIds: heldRun(segments, group.id),
|
|
141
|
+
speed: group.speed,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* formRefusal names the first field of a form that withholds its save: a run below the floor a
|
|
146
|
+
* group holds, then a name the bus refuses. The run comes first, since a group of one cannot
|
|
147
|
+
* exist at all while a name is one keystroke from valid.
|
|
148
|
+
*/
|
|
149
|
+
const formRefusal = (form: SegmentGroupForm): SegmentGroupRefusal | null => {
|
|
150
|
+
if (form.segmentIds.length < SEGMENT_GROUP_MIN_MEMBERS) {
|
|
151
|
+
return "minMembers";
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return displayNameSchema.safeParse(form.name).success ? null : "nameError";
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/** Whether two runs name the same segments in the same order. */
|
|
158
|
+
const sameRun = (left: readonly string[], right: readonly string[]): boolean =>
|
|
159
|
+
left.length === right.length && left.every((id, index) => id === right[index]);
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* segmentGroupSavePlan reads what a save of `form` sends, whether anything would be written, and
|
|
163
|
+
* which field withholds the save.
|
|
164
|
+
*
|
|
165
|
+
* **A create is one verb.** `studio.itinerary.group.create` with every field, the name trimmed.
|
|
166
|
+
*
|
|
167
|
+
* **A save of an existing group sends its membership first, then the display fields that
|
|
168
|
+
* moved.** Two verbs cannot be made atomic, so the one with a routine refusal goes first:
|
|
169
|
+
* `studio.itinerary.group.setRange` is refused whenever a collaborator grouped one of the
|
|
170
|
+
* segments first, and sent first it stops the save before anything is written. It is sent only
|
|
171
|
+
* where the run differs from the one `segments` holds for the group, in order. Then
|
|
172
|
+
* `studio.itinerary.group.update` carries the name, the colour and the speed that differ from what
|
|
173
|
+
* the form opened on and no other, so a field a collaborator wrote while the form was open is
|
|
174
|
+
* never put back by a save that did not touch it. A form where nothing moved sends nothing.
|
|
175
|
+
*
|
|
176
|
+
* **A field that refuses withholds everything**, so while `refusal` names one `steps` is empty.
|
|
177
|
+
*
|
|
178
|
+
* @param itineraryId The itinerary the group stands in.
|
|
179
|
+
* @param segments The itinerary's chain as it stands at the save, read for the run the group
|
|
180
|
+
* holds now: a collaborator's edit can land while the form is open.
|
|
181
|
+
* @param form The form as it stands.
|
|
182
|
+
*/
|
|
183
|
+
export const segmentGroupSavePlan = (
|
|
184
|
+
itineraryId: string,
|
|
185
|
+
segments: readonly Pick<ItinerarySegment, "group_id" | "id">[],
|
|
186
|
+
form: SegmentGroupForm,
|
|
187
|
+
): SegmentGroupSavePlan => {
|
|
188
|
+
const name = form.name.trim();
|
|
189
|
+
const refusal = formRefusal(form);
|
|
190
|
+
const { opened } = form;
|
|
191
|
+
|
|
192
|
+
if (opened === null) {
|
|
193
|
+
const create: SegmentGroupSaveStep = {
|
|
194
|
+
input: {
|
|
195
|
+
color: form.color,
|
|
196
|
+
itineraryId,
|
|
197
|
+
name,
|
|
198
|
+
segmentIds: [...form.segmentIds],
|
|
199
|
+
speed: form.speed,
|
|
200
|
+
},
|
|
201
|
+
name: "studio.itinerary.group.create",
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
return { changed: true, refusal, steps: refusal === null ? [create] : [] };
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const subject = { groupId: opened.groupId, itineraryId };
|
|
208
|
+
const runMoved = !sameRun(heldRun(segments, opened.groupId), form.segmentIds);
|
|
209
|
+
const display = {
|
|
210
|
+
...(form.color === opened.color ? {} : { color: form.color }),
|
|
211
|
+
...(name === opened.name.trim() ? {} : { name }),
|
|
212
|
+
...(form.speed === opened.speed ? {} : { speed: form.speed }),
|
|
213
|
+
};
|
|
214
|
+
const displayMoved = Object.keys(display).length > 0;
|
|
215
|
+
const changed = runMoved || displayMoved;
|
|
216
|
+
|
|
217
|
+
if (refusal !== null) {
|
|
218
|
+
return { changed, refusal, steps: [] };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const steps: SegmentGroupSaveStep[] = [];
|
|
222
|
+
if (runMoved) {
|
|
223
|
+
steps.push({
|
|
224
|
+
input: { ...subject, segmentIds: [...form.segmentIds] },
|
|
225
|
+
name: "studio.itinerary.group.setRange",
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (displayMoved) {
|
|
230
|
+
steps.push({ input: { ...display, ...subject }, name: "studio.itinerary.group.update" });
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return { changed, refusal, steps };
|
|
234
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { RouteAdvisory } from "../../itinerary/rules/routing.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Asking the user about a route's hazards ONCE, however many routing round-trips are in flight.
|
|
5
|
+
*
|
|
6
|
+
* The confirmation gate a host supplies QUEUES requests rather than de-duplicating them, which is
|
|
7
|
+
* right for its own job, since two destructive tools from two chats are two decisions. It is wrong
|
|
8
|
+
* here. The directions engine awaits its routing function BEFORE it can tell whether its own
|
|
9
|
+
* resolution has been superseded, so a fast sequence of placements raises a prompt per round-trip
|
|
10
|
+
* and the gate stacks them: the user answers the same question about the same way three times, once
|
|
11
|
+
* per point they placed while the first dialog was open.
|
|
12
|
+
*
|
|
13
|
+
* So the de-duplication belongs on this side of the gate, keyed by what the question IS.
|
|
14
|
+
*
|
|
15
|
+
* Deciding whether a hazard has already been answered for this edit is the studio's rule (a routed
|
|
16
|
+
* line that a person declined once must not re-prompt on the next via drag), and it is the same
|
|
17
|
+
* rule whatever raises the prompt. What stays with a binding is the asking.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* promptKey identifies the question a hazard set asks, independent of the order the advisories
|
|
22
|
+
* arrived in: `["tollway", "private"]` and `["private", "tollway"]` are one
|
|
23
|
+
* question, and keying on the raw order would open two dialogs for it.
|
|
24
|
+
*/
|
|
25
|
+
const promptKey = (hazards: readonly RouteAdvisory[]): string => [...hazards].sort().join("|");
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* HazardPromptGate asks the user to approve a hazard set, collapsing concurrent asks about the
|
|
29
|
+
* same set onto a single answer.
|
|
30
|
+
*/
|
|
31
|
+
export type HazardPromptGate = (hazards: RouteAdvisory[]) => Promise<boolean>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* createHazardPromptGate wraps `ask` so that while an answer for a given hazard set is still
|
|
35
|
+
* pending, every further ask about that SAME set resolves to the same answer rather than raising a
|
|
36
|
+
* second dialog. A set whose answer has already settled asks again: that is the caller's decision
|
|
37
|
+
* to make (the routing memo is what stops a settled question returning), and a gate that remembered
|
|
38
|
+
* answers here would silently outlive the edit it was built for.
|
|
39
|
+
*
|
|
40
|
+
* The in-flight entry is cleared on settle whether the answer was yes, no, or a throw, so a failed
|
|
41
|
+
* dialog cannot wedge the key permanently.
|
|
42
|
+
*/
|
|
43
|
+
export const createHazardPromptGate = (ask: HazardPromptGate): HazardPromptGate => {
|
|
44
|
+
const pending = new Map<string, Promise<boolean>>();
|
|
45
|
+
|
|
46
|
+
return (hazards) => {
|
|
47
|
+
const key = promptKey(hazards);
|
|
48
|
+
const asking = pending.get(key);
|
|
49
|
+
if (asking) {
|
|
50
|
+
return asking;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const answer = ask(hazards).finally(() => {
|
|
54
|
+
pending.delete(key);
|
|
55
|
+
});
|
|
56
|
+
pending.set(key, answer);
|
|
57
|
+
|
|
58
|
+
return answer;
|
|
59
|
+
};
|
|
60
|
+
};
|