@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,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ChainSegment is the minimal shape these helpers read off one entry of an ordered segment chain: a
|
|
3
|
+
* stable id. Structural rather than the full `ItinerarySegment` so a persisted segment, an
|
|
4
|
+
* import-draft segment, and a hand-built fixture all satisfy it: the chain rules depend on order
|
|
5
|
+
* and identity alone, never on geometry.
|
|
6
|
+
*/
|
|
7
|
+
export interface ChainSegment {
|
|
8
|
+
id: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* ChainRunBounds are the inclusive chain indices a contiguous selection spans: `first` the index of
|
|
13
|
+
* its head, `last` the index of its tail. A single-segment run has `first === last`. It is what a
|
|
14
|
+
* range control reads to place its extend/shrink affordances at the two ends of the run.
|
|
15
|
+
*/
|
|
16
|
+
export interface ChainRunBounds {
|
|
17
|
+
first: number;
|
|
18
|
+
last: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* indexById maps each chain entry's id onto its position in the chain, so the run helpers resolve
|
|
23
|
+
* an arbitrary id set in one pass instead of scanning the chain per id. The caller passes the chain
|
|
24
|
+
* in order, and that order IS the position ordering the API assigns: every entry carries its own
|
|
25
|
+
* `position`, assigned by the API, and the chain is read back ordered by it.
|
|
26
|
+
*/
|
|
27
|
+
const indexById = (segments: readonly ChainSegment[]): Map<string, number> => {
|
|
28
|
+
const indices = new Map<string, number>();
|
|
29
|
+
for (const [index, segment] of segments.entries()) {
|
|
30
|
+
indices.set(segment.id, index);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return indices;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* runBoundsFrom resolves an id selection against a prebuilt index map and returns the
|
|
38
|
+
* inclusive chain span it covers, or null when the selection is empty, carries an id the
|
|
39
|
+
* chain does not hold, names an id twice, or leaves a hole. The ids need not be in chain
|
|
40
|
+
* order.
|
|
41
|
+
*
|
|
42
|
+
* The contiguity rule is the span matching the count: `last - first + 1 === size`.
|
|
43
|
+
* That single predicate is what both the group range and the duplication selection
|
|
44
|
+
* are held to, and it is the same rule the API enforces. Trimming from the ends IS
|
|
45
|
+
* contiguity, so it cannot be sidestepped by dropping interior entries one at a time
|
|
46
|
+
* the way an "only an end may be dropped" rule can. A repeat is refused rather than
|
|
47
|
+
* collapsed because the API refuses it too: both selections are `uniqueItems` on the wire.
|
|
48
|
+
*/
|
|
49
|
+
const runBoundsFrom = (
|
|
50
|
+
indices: ReadonlyMap<string, number>,
|
|
51
|
+
ids: Iterable<string>,
|
|
52
|
+
): ChainRunBounds | null => {
|
|
53
|
+
const seen = new Set<string>();
|
|
54
|
+
let first = Number.POSITIVE_INFINITY;
|
|
55
|
+
let last = Number.NEGATIVE_INFINITY;
|
|
56
|
+
|
|
57
|
+
for (const id of ids) {
|
|
58
|
+
const index = indices.get(id);
|
|
59
|
+
// An id the chain does not carry leaves the run undefined rather than silently
|
|
60
|
+
// narrowing it: a stale id must fail the check, not pass it. A repeated one is a
|
|
61
|
+
// selection the write refuses, so it fails the check for the same reason.
|
|
62
|
+
if (index === undefined || seen.has(id)) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
seen.add(id);
|
|
67
|
+
first = Math.min(first, index);
|
|
68
|
+
last = Math.max(last, index);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (seen.size === 0) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return last - first + 1 === seen.size ? { first, last } : null;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* contiguousRunBounds returns the inclusive chain span the given ids cover when they
|
|
80
|
+
* form one unbroken run, whatever their order, and null otherwise: an empty set, an id
|
|
81
|
+
* absent from the chain, a repeated id, or a selection with a hole in it.
|
|
82
|
+
*
|
|
83
|
+
* It is the shared source of both the predicate and the geometry of a run: a
|
|
84
|
+
* validator reads only whether it is null (see {@link isContiguousRun}), while a
|
|
85
|
+
* range control reads `first`/`last` to anchor the controls that extend or shrink
|
|
86
|
+
* the run by one entry at each end.
|
|
87
|
+
*/
|
|
88
|
+
export const contiguousRunBounds = (
|
|
89
|
+
segments: readonly ChainSegment[],
|
|
90
|
+
ids: Iterable<string>,
|
|
91
|
+
): ChainRunBounds | null => runBoundsFrom(indexById(segments), ids);
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* isContiguousRun reports whether the given ids form one unbroken run of the chain.
|
|
95
|
+
* An empty selection is not a run, and an id the chain lacks, or one named twice,
|
|
96
|
+
* fails the check rather than being ignored.
|
|
97
|
+
*
|
|
98
|
+
* This is the client-side twin of the rule the API enforces on a group's members and
|
|
99
|
+
* on a duplication's segment selection, so a surface can disable an impossible choice
|
|
100
|
+
* instead of letting the write fail.
|
|
101
|
+
*/
|
|
102
|
+
export const isContiguousRun = (
|
|
103
|
+
segments: readonly ChainSegment[],
|
|
104
|
+
ids: Iterable<string>,
|
|
105
|
+
): boolean => contiguousRunBounds(segments, ids) !== null;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* toggleableSegmentIds returns every chain id whose toggle (dropping it when it is kept, adding it
|
|
109
|
+
* when it is not) leaves the kept set a NON-EMPTY contiguous run. It is the one rule behind both a
|
|
110
|
+
* duplication dialog's checkboxes and a group range control's extend/shrink affordances, so neither
|
|
111
|
+
* surface re-derives it.
|
|
112
|
+
*
|
|
113
|
+
* Three consequences fall out of the single predicate, and they are the whole point: only the two
|
|
114
|
+
* ends of a run may be dropped (dropping an interior entry would leave a hole); only the entries
|
|
115
|
+
* immediately outside the run may be added back (adding a detached one would leave a hole); and the
|
|
116
|
+
* last remaining entry may not be dropped, because an empty selection is not a run.
|
|
117
|
+
*
|
|
118
|
+
* The kept set is expected to already be contiguous (every surface driving it can only reach
|
|
119
|
+
* contiguous states), and when it IS, those three consequences ARE the answer: run the head and the
|
|
120
|
+
* tail, plus the entry either side of the run. That is resolved directly from
|
|
121
|
+
* {@link contiguousRunBounds}, in one pass over the ids rather than one simulated toggle per chain
|
|
122
|
+
* entry, because the surfaces that drive this re-run it on every checkbox tick and every
|
|
123
|
+
* extend/shrink click.
|
|
124
|
+
*
|
|
125
|
+
* The function stays total for any input all the same. An empty selection offers the whole chain
|
|
126
|
+
* (every toggle from nothing yields a one-entry run), and a kept set that is NOT a run (a hole in
|
|
127
|
+
* it, or an id the chain does not carry) falls back to simulating each toggle against the same
|
|
128
|
+
* predicate rather than assuming a shape. Both the fast path and the fallback answer with the same
|
|
129
|
+
* set; the fallback is what makes that provable for inputs no surface can produce.
|
|
130
|
+
*
|
|
131
|
+
* The kept ids are read as given, by the rule {@link contiguousRunBounds} holds a run to: an id
|
|
132
|
+
* named twice is never collapsed, so a selection that repeats one is no run. Dropping an id drops
|
|
133
|
+
* every mention of it, which makes dropping the repeated id the one toggle that can leave a run.
|
|
134
|
+
*/
|
|
135
|
+
export const toggleableSegmentIds = (
|
|
136
|
+
segments: readonly ChainSegment[],
|
|
137
|
+
keptIds: Iterable<string>,
|
|
138
|
+
): Set<string> => {
|
|
139
|
+
const indices = indexById(segments);
|
|
140
|
+
const keptList = [...keptIds];
|
|
141
|
+
const kept = new Set(keptList);
|
|
142
|
+
const toggleable = new Set<string>();
|
|
143
|
+
|
|
144
|
+
// Nothing kept: each toggle seeds a one-entry run, which is contiguous, so a surface
|
|
145
|
+
// starting from an empty selection can begin anywhere.
|
|
146
|
+
if (kept.size === 0) {
|
|
147
|
+
for (const segment of segments) {
|
|
148
|
+
toggleable.add(segment.id);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return toggleable;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// The ids as given and not the set of them, so a repeat reads as it does to the run rule.
|
|
155
|
+
const bounds = runBoundsFrom(indices, keptList);
|
|
156
|
+
if (bounds !== null) {
|
|
157
|
+
const head = segments[bounds.first];
|
|
158
|
+
const tail = segments[bounds.last];
|
|
159
|
+
|
|
160
|
+
// Dropping an end leaves a shorter run, unless the run is a single entry, whose removal empties
|
|
161
|
+
// the selection, and an empty selection is not a run.
|
|
162
|
+
if (head && tail && bounds.last > bounds.first) {
|
|
163
|
+
toggleable.add(head.id);
|
|
164
|
+
toggleable.add(tail.id);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Adding the entry immediately outside either end extends the run by one; anything
|
|
168
|
+
// beyond them would leave a hole. An index off either end of the chain reads as
|
|
169
|
+
// undefined, which is the whole bound check.
|
|
170
|
+
const above = bounds.first > 0 ? segments[bounds.first - 1] : undefined;
|
|
171
|
+
const below = segments[bounds.last + 1];
|
|
172
|
+
if (above) {
|
|
173
|
+
toggleable.add(above.id);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (below) {
|
|
177
|
+
toggleable.add(below.id);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return toggleable;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// The kept set is not a run. No end and no neighbour is defined, so the answer is whatever the
|
|
184
|
+
// predicate itself says, simulated toggle by toggle.
|
|
185
|
+
for (const segment of segments) {
|
|
186
|
+
const candidate = kept.has(segment.id)
|
|
187
|
+
? keptList.filter((id) => id !== segment.id)
|
|
188
|
+
: [...keptList, segment.id];
|
|
189
|
+
|
|
190
|
+
if (runBoundsFrom(indices, candidate) !== null) {
|
|
191
|
+
toggleable.add(segment.id);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return toggleable;
|
|
196
|
+
};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import type { ItinerarySegment } from "@mountaya/elements/data";
|
|
2
|
+
import { SEGMENT_GROUP_MIN_MEMBERS } from "@mountaya/elements/data";
|
|
3
|
+
|
|
4
|
+
import type { ItinerarySegmentGroup } from "../../rules/types.js";
|
|
5
|
+
import { exceedsMergeViaCeiling } from "./merge.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The chain a segment list renders, folded once into the models its rows and gutters read.
|
|
9
|
+
*
|
|
10
|
+
* Every one of these is derived from the COMMITTED chain rather than from whatever a list happens
|
|
11
|
+
* to be showing, and that is the rule the whole module keeps: a list also renders the segment
|
|
12
|
+
* currently being drawn and the one being inserted into a gap, neither of which the API knows
|
|
13
|
+
* about. Answering "which row is the tail" positionally over the rendered list is what lets a real
|
|
14
|
+
* tail offer a merge it has no successor for and lose its own Delete.
|
|
15
|
+
*
|
|
16
|
+
* They are folds rather than per-row lookups for a second reason, and it is a performance one that
|
|
17
|
+
* shows up as correctness: a list re-renders on every peer-lock frame and on every throttled tick
|
|
18
|
+
* of an open edit, and a per-row derivation would rescan the chain once per row. Each of these
|
|
19
|
+
* walks it once and hands back objects a memoised row can compare by reference.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* SegmentMergeRefusal names why two adjacent segments cannot be fused: they are drawn by different
|
|
24
|
+
* engines, they sit on either side of a group boundary, the fused itinerary would ask the router
|
|
25
|
+
* for more waypoints than it accepts, or a collaborator holds one of them.
|
|
26
|
+
*
|
|
27
|
+
* Each is a condition the merge tool refuses on, which is the point: surfacing one turns a round
|
|
28
|
+
* trip into an explanation the user reads before reaching for the verb.
|
|
29
|
+
*
|
|
30
|
+
* The order below is the order they are evaluated in: the structural reasons first, because none of
|
|
31
|
+
* them resolves on its own and each names a fix (change the engine, leave the group, simplify one
|
|
32
|
+
* of the two), then the lock, which clears when the peer moves on.
|
|
33
|
+
*
|
|
34
|
+
* One refusal of the API has no reason here: a freehand pair whose joined line holds more drawn
|
|
35
|
+
* vertices than a segment stores (`segments.merge_positions_max`). The API counts them after its
|
|
36
|
+
* own cleaning pass over the joined line, which drops the vertices that sit within a few meters of
|
|
37
|
+
* the line through their neighbours, and the studio holds no copy of that pass. A count taken
|
|
38
|
+
* before it would grey out merges the API makes. So the merge stays offered, and a refused one
|
|
39
|
+
* answers with the API's own sentence, which the verb's failure carries as its `detail`.
|
|
40
|
+
*/
|
|
41
|
+
export type SegmentMergeRefusal = "engine" | "group" | "waypointsMax" | "locked";
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* SegmentChainMerge is one fusion the chain offers: the segment folded into its successor, the
|
|
45
|
+
* successor it folds into, and why the verb is inert when it is. A null reason is a live merge.
|
|
46
|
+
*
|
|
47
|
+
* `intoSegmentId` rides alongside the id the verb acts on because a surface previews its own
|
|
48
|
+
* operands (reaching for the control lights BOTH segments), so the pair is resolved with the model
|
|
49
|
+
* rather than read back out of the list at pointer time.
|
|
50
|
+
*/
|
|
51
|
+
export interface SegmentChainMerge {
|
|
52
|
+
readonly disabledReason: SegmentMergeRefusal | null;
|
|
53
|
+
readonly intoSegmentId: string;
|
|
54
|
+
readonly segmentId: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* SegmentChainMerges is the same merge objects indexed twice: by the segment that FOLDS DOWN and by
|
|
59
|
+
* the one that ABSORBS it.
|
|
60
|
+
*
|
|
61
|
+
* A row's two menu items ask opposite questions about one pair ("can I fold into the row below" and
|
|
62
|
+
* "can the row above fold into me"), and a gutter asks the first of them about the row above it.
|
|
63
|
+
* Deriving both indexes in the single walk that already builds the merges is what makes those three
|
|
64
|
+
* readings unable to disagree.
|
|
65
|
+
*
|
|
66
|
+
* A MISSING entry is itself an answer, and the two ends are asymmetric: no `byFolded` entry means
|
|
67
|
+
* there is nothing below to fold into (the tail), and no `byAbsorber` entry means there is nothing
|
|
68
|
+
* above to be folded into it (the head).
|
|
69
|
+
*/
|
|
70
|
+
export interface SegmentChainMerges {
|
|
71
|
+
readonly byAbsorber: ReadonlyMap<string, SegmentChainMerge>;
|
|
72
|
+
readonly byFolded: ReadonlyMap<string, SegmentChainMerge>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* buildSegmentChainMerges resolves every adjacent pair of the committed chain into the merge it
|
|
77
|
+
* offers, or into the reason it does not.
|
|
78
|
+
*
|
|
79
|
+
* `lockedSegmentIds` is the set a collaborator currently holds. It arrives resolved rather than
|
|
80
|
+
* as a lock map because who holds what is a session concern and the shape of that session is the
|
|
81
|
+
* host's; what this needs to know is only whether either side of a pair is spoken for.
|
|
82
|
+
*/
|
|
83
|
+
export const buildSegmentChainMerges = (
|
|
84
|
+
segments: readonly ItinerarySegment[],
|
|
85
|
+
lockedSegmentIds: ReadonlySet<string> = new Set(),
|
|
86
|
+
): SegmentChainMerges => {
|
|
87
|
+
const byAbsorber = new Map<string, SegmentChainMerge>();
|
|
88
|
+
const byFolded = new Map<string, SegmentChainMerge>();
|
|
89
|
+
|
|
90
|
+
for (let index = 1; index < segments.length; index += 1) {
|
|
91
|
+
const previous = segments[index - 1];
|
|
92
|
+
const segment = segments[index];
|
|
93
|
+
if (!previous || !segment) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
let disabledReason: SegmentMergeRefusal | null = null;
|
|
98
|
+
if (previous.mode !== segment.mode) {
|
|
99
|
+
disabledReason = "engine";
|
|
100
|
+
} else if (previous.group_id !== segment.group_id) {
|
|
101
|
+
// Comparing the ids covers the one-grouped-one-not case too, since an ungrouped segment
|
|
102
|
+
// carries a null group.
|
|
103
|
+
disabledReason = "group";
|
|
104
|
+
} else if (exceedsMergeViaCeiling(previous, segment)) {
|
|
105
|
+
// The router's waypoint ceiling, checked here rather than left to the round trip: the API
|
|
106
|
+
// joins the two via lists exactly as mergedViaCount does, so the count is the API's own. The
|
|
107
|
+
// freehand position ceiling is the one refusal left to the API (see SegmentMergeRefusal).
|
|
108
|
+
disabledReason = "waypointsMax";
|
|
109
|
+
} else if (lockedSegmentIds.has(previous.id) || lockedSegmentIds.has(segment.id)) {
|
|
110
|
+
disabledReason = "locked";
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const merge: SegmentChainMerge = {
|
|
114
|
+
disabledReason,
|
|
115
|
+
intoSegmentId: segment.id,
|
|
116
|
+
segmentId: previous.id,
|
|
117
|
+
};
|
|
118
|
+
byFolded.set(previous.id, merge);
|
|
119
|
+
byAbsorber.set(segment.id, merge);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return { byAbsorber, byFolded };
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* SegmentChainEnds is which rows the API knows about, and which two of them are the real ends of
|
|
127
|
+
* the chain: the facts every chain verb is gated on.
|
|
128
|
+
*/
|
|
129
|
+
export interface SegmentChainEnds {
|
|
130
|
+
readonly committedIds: ReadonlySet<string>;
|
|
131
|
+
readonly firstCommittedId: string | null;
|
|
132
|
+
readonly lastCommittedId: string | null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** segmentChainEnds folds the committed chain into {@link SegmentChainEnds}. */
|
|
136
|
+
export const segmentChainEnds = (segments: readonly ItinerarySegment[]): SegmentChainEnds => ({
|
|
137
|
+
committedIds: new Set(segments.map((segment) => segment.id)),
|
|
138
|
+
firstCommittedId: segments[0]?.id ?? null,
|
|
139
|
+
lastCommittedId: segments.at(-1)?.id ?? null,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* SegmentGroupRun is one row's place in the chain's grouping.
|
|
144
|
+
*
|
|
145
|
+
* `group` is the group it belongs to, or null. `isFirst` / `isLast` are the ends of the RUN,
|
|
146
|
+
* which is what lets only those two leave without splitting it. `memberCount` is the run's size,
|
|
147
|
+
* so a surface can say that leaving a two-member group dissolves it rather than offering the
|
|
148
|
+
* same wording for an act that also destroys the group's name and colour. `hasFreeNeighbour`
|
|
149
|
+
* answers the other direction: grouping needs an ungrouped segment beside this one, and with
|
|
150
|
+
* none the verb is shown refused rather than hidden, so the absence explains itself.
|
|
151
|
+
*/
|
|
152
|
+
export interface SegmentGroupRun {
|
|
153
|
+
readonly group: ItinerarySegmentGroup | null;
|
|
154
|
+
readonly hasFreeNeighbour: boolean;
|
|
155
|
+
readonly isFirst: boolean;
|
|
156
|
+
readonly isLast: boolean;
|
|
157
|
+
readonly memberCount: number;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* buildSegmentGroupRuns folds the chain's grouping into a per-segment model, keyed by segment id.
|
|
162
|
+
*
|
|
163
|
+
* The membership counts come from ONE pass over the chain rather than from asking it per row: doing
|
|
164
|
+
* that inside the per-row walk rescans it once per member, which is quadratic on exactly the
|
|
165
|
+
* itineraries grouping exists for: a long chain where most rows belong to a run.
|
|
166
|
+
*
|
|
167
|
+
* A segment whose `group_id` names no group in `groups` reads as ungrouped, which is the honest
|
|
168
|
+
* answer while a group delete and the chain that referenced it are landing a frame apart. It reads
|
|
169
|
+
* so to its neighbours too: it is a free neighbour to the rows either side of it.
|
|
170
|
+
*/
|
|
171
|
+
export const buildSegmentGroupRuns = (
|
|
172
|
+
segments: readonly ItinerarySegment[],
|
|
173
|
+
groups: readonly ItinerarySegmentGroup[],
|
|
174
|
+
): ReadonlyMap<string, SegmentGroupRun> => {
|
|
175
|
+
const byId = new Map(groups.map((group) => [group.id, group]));
|
|
176
|
+
const memberCounts = new Map<string, number>();
|
|
177
|
+
for (const segment of segments) {
|
|
178
|
+
if (segment.group_id !== null) {
|
|
179
|
+
memberCounts.set(segment.group_id, (memberCounts.get(segment.group_id) ?? 0) + 1);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// One reading of a group id for the segment that carries it and for the rows beside it: an id
|
|
184
|
+
// that names no group in `groups` is no group.
|
|
185
|
+
const groupOf = (segment: ItinerarySegment): ItinerarySegmentGroup | null =>
|
|
186
|
+
segment.group_id === null ? null : (byId.get(segment.group_id) ?? null);
|
|
187
|
+
|
|
188
|
+
const runs = new Map<string, SegmentGroupRun>();
|
|
189
|
+
segments.forEach((segment, index) => {
|
|
190
|
+
const group = groupOf(segment);
|
|
191
|
+
const previous = segments[index - 1];
|
|
192
|
+
const next = segments[index + 1];
|
|
193
|
+
|
|
194
|
+
runs.set(segment.id, {
|
|
195
|
+
group,
|
|
196
|
+
hasFreeNeighbour:
|
|
197
|
+
(previous !== undefined && groupOf(previous) === null) ||
|
|
198
|
+
(next !== undefined && groupOf(next) === null),
|
|
199
|
+
isFirst: group === null ? false : previous?.group_id !== group.id,
|
|
200
|
+
isLast: group === null ? false : next?.group_id !== group.id,
|
|
201
|
+
memberCount: group === null ? 0 : (memberCounts.get(group.id) ?? 0),
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
return runs;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* segmentGroupDissolvesOnLeave says whether one member leaving takes the whole group with it.
|
|
210
|
+
*
|
|
211
|
+
* Leaving is a range change, not a delete, unless it would leave a single member behind, which is
|
|
212
|
+
* not a group at all. Both are the same user intent expressed against the floor the rule imposes,
|
|
213
|
+
* and stating the test once here is what keeps the menu's wording and the verb's behaviour from
|
|
214
|
+
* answering it differently.
|
|
215
|
+
*/
|
|
216
|
+
export const segmentGroupDissolvesOnLeave = (memberCount: number): boolean =>
|
|
217
|
+
memberCount - 1 < SEGMENT_GROUP_MIN_MEMBERS;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* hexColorSchema validates a 3- or 6-digit hex color string (`#abc` or `#aabbcc`), matching the
|
|
5
|
+
* color pattern the API persists, so a caller-supplied color is rejected at the mutation boundary
|
|
6
|
+
* before a write sees it. The palette it validates against lives one level down in
|
|
7
|
+
* `@mountaya/elements/style` (the lively colors are all 6-digit hexes that satisfy it), and the
|
|
8
|
+
* schema is the studio's because validating a write is a studio concern: the rendering family
|
|
9
|
+
* states the vocabulary, the studio validates a write against it.
|
|
10
|
+
*/
|
|
11
|
+
export const hexColorSchema = z.string().regex(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { SegmentEditMode } from "@mountaya/elements/data";
|
|
2
|
+
|
|
3
|
+
import type { StudioToolInputs } from "../../bus/contracts/studioTools.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* SegmentEditCommitInput is the `studio.itinerary.segment.editCommit` input both
|
|
7
|
+
* the on-map Save cluster and the editing keyboard build: a from-scratch CREATE
|
|
8
|
+
* (a `name` + `color`, no `segmentId`) or an existing-segment UPDATE (a
|
|
9
|
+
* `segmentId`, no name). The discriminated `mode` carries the mode-correct
|
|
10
|
+
* geometry: directions `vias` or freehand `line`. `itineraryId` may be null or
|
|
11
|
+
* left out, and the commit then saves to the itinerary open in the editor or to the
|
|
12
|
+
* staged draft that shows. It is the contract's own input type, so the builder and
|
|
13
|
+
* the verb cannot drift, and it is the single shape both commit paths produce so a
|
|
14
|
+
* key press and a click cannot drift either.
|
|
15
|
+
*/
|
|
16
|
+
export type SegmentEditCommitInput = StudioToolInputs["studio.itinerary.segment.editCommit"];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* BuildSegmentEditCommitParams is the active edit session's commit-relevant slice: the authoring
|
|
20
|
+
* `mode`, the draft `coordinates` read off the map, the `itineraryId` scope (null while only an
|
|
21
|
+
* import draft is open), the session's `segmentId`, and the `draftName` + `draftColor`. The draft
|
|
22
|
+
* name + color are set ONLY for a from-scratch segment (the create form and the add-segment control
|
|
23
|
+
* seed them); an existing-segment edit leaves them null.
|
|
24
|
+
*/
|
|
25
|
+
export interface BuildSegmentEditCommitParams {
|
|
26
|
+
coordinates: [number, number][];
|
|
27
|
+
draftColor: string | null;
|
|
28
|
+
draftName: string | null;
|
|
29
|
+
itineraryId: string | null;
|
|
30
|
+
mode: SegmentEditMode;
|
|
31
|
+
segmentId: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* buildSegmentEditCommitInput shapes the segment editCommit input from the active session. A
|
|
36
|
+
* from-scratch segment is identified by a non-null `draftName` (the "Segment #N" label the create +
|
|
37
|
+
* add-segment flows seed, present only until a persisted entry exists): it commits as a CREATE,
|
|
38
|
+
* where the name + color ride and the client `segmentId` is OMITTED, so the mutation sink POSTs a
|
|
39
|
+
* new segment. An existing-segment edit (no draftName) commits as an UPDATE keyed on the
|
|
40
|
+
* `segmentId`, so the sink PUTs the new geometry (or rewrites the import-draft entry). Both the
|
|
41
|
+
* Save button and the Enter key build the input here so the two paths cannot diverge.
|
|
42
|
+
*/
|
|
43
|
+
export const buildSegmentEditCommitInput = ({
|
|
44
|
+
coordinates,
|
|
45
|
+
draftColor,
|
|
46
|
+
draftName,
|
|
47
|
+
itineraryId,
|
|
48
|
+
mode,
|
|
49
|
+
segmentId,
|
|
50
|
+
}: BuildSegmentEditCommitParams): SegmentEditCommitInput => {
|
|
51
|
+
// A from-scratch segment carries the "Segment #N" draft name; commit it as a create so the sink
|
|
52
|
+
// POSTs (the client segmentId is never sent: the API assigns it). The color rides so the new
|
|
53
|
+
// segment persists its lively hue.
|
|
54
|
+
if (draftName !== null) {
|
|
55
|
+
return mode === "directions"
|
|
56
|
+
? {
|
|
57
|
+
color: draftColor ?? undefined,
|
|
58
|
+
itineraryId,
|
|
59
|
+
mode: "directions",
|
|
60
|
+
name: draftName,
|
|
61
|
+
vias: coordinates,
|
|
62
|
+
}
|
|
63
|
+
: {
|
|
64
|
+
color: draftColor ?? undefined,
|
|
65
|
+
itineraryId,
|
|
66
|
+
line: coordinates,
|
|
67
|
+
mode: "linestring",
|
|
68
|
+
name: draftName,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// An existing-segment edit commits as an update keyed on the segmentId.
|
|
73
|
+
return mode === "directions"
|
|
74
|
+
? { itineraryId, mode: "directions", segmentId, vias: coordinates }
|
|
75
|
+
: { itineraryId, line: coordinates, mode: "linestring", segmentId };
|
|
76
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { Geometry, Position } from "geojson";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* draftPositionCount reads how many handle coordinates a stored segment draft carries. The store
|
|
5
|
+
* edit session holds the draft as a single-leaf GeometryCollection (a MultiPoint of vias in
|
|
6
|
+
* directions mode, a LineString in linestring mode, both exposing `coordinates: Position[]`), so
|
|
7
|
+
* the count is that leaf's coordinate length.
|
|
8
|
+
*
|
|
9
|
+
* It is the render-time signal a Save reads to disable a commit below {@link SEGMENT_MIN_VIAS}. It
|
|
10
|
+
* lives here rather than beside whatever builds the draft because a footer has to read it without
|
|
11
|
+
* pulling in a renderer.
|
|
12
|
+
*
|
|
13
|
+
* Anything unexpected (a non-collection geometry, an empty collection, or a leaf that is neither a
|
|
14
|
+
* MultiPoint nor a LineString) yields 0 so the Save stays disabled rather than committing an
|
|
15
|
+
* unroutable draft.
|
|
16
|
+
*/
|
|
17
|
+
export const draftPositionCount = (geometry: Geometry): number => {
|
|
18
|
+
const leaf = geometry.type === "GeometryCollection" ? geometry.geometries[0] : geometry;
|
|
19
|
+
if (leaf && (leaf.type === "MultiPoint" || leaf.type === "LineString")) {
|
|
20
|
+
return leaf.coordinates.length;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return 0;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* draftCoordinates extracts the editable handle coordinates from a stored draft geometry: the vias
|
|
28
|
+
* of a directions draft's MultiPoint or the vertices of a linestring draft's LineString, flattening
|
|
29
|
+
* the GeometryCollection. A null or empty draft yields an empty list (the handles clear). It is the
|
|
30
|
+
* inverse of the wrap that builds a draft, reading the leaf a draft restore must apply again.
|
|
31
|
+
*/
|
|
32
|
+
export const draftCoordinates = (draft: Geometry | null): Position[] => {
|
|
33
|
+
if (!draft) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const leaves = draft.type === "GeometryCollection" ? draft.geometries : [draft];
|
|
38
|
+
for (const leaf of leaves) {
|
|
39
|
+
if (leaf.type === "MultiPoint" || leaf.type === "LineString") {
|
|
40
|
+
return leaf.coordinates;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return [];
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* segmentDraftHandles answers the handles a segment session shows: its draft's, or the seed it
|
|
49
|
+
* opened with while it holds no draft, which is every moment before the first change and after
|
|
50
|
+
* an undo back to the start.
|
|
51
|
+
*/
|
|
52
|
+
export const segmentDraftHandles = (
|
|
53
|
+
draft: Geometry | null,
|
|
54
|
+
seedVias: readonly (readonly number[])[],
|
|
55
|
+
): readonly (readonly number[])[] => (draft === null ? seedVias : draftCoordinates(draft));
|
|
56
|
+
|
|
57
|
+
/** sameHandles is whether two handle lists name the same points, in the same order. */
|
|
58
|
+
export const sameHandles = (
|
|
59
|
+
a: readonly (readonly number[])[],
|
|
60
|
+
b: readonly (readonly number[])[],
|
|
61
|
+
): boolean =>
|
|
62
|
+
a.length === b.length &&
|
|
63
|
+
a.every((handle, index) => {
|
|
64
|
+
const other = b[index];
|
|
65
|
+
|
|
66
|
+
return other !== undefined && handle[0] === other[0] && handle[1] === other[1];
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* SegmentDraftBaseline is what a segment session's change is measured against: the handles it
|
|
71
|
+
* shows, read off its draft and its seed, and the handles leaving would not lose.
|
|
72
|
+
*/
|
|
73
|
+
interface SegmentDraftBaseline {
|
|
74
|
+
readonly draft: Geometry | null;
|
|
75
|
+
readonly savedVias: readonly (readonly number[])[];
|
|
76
|
+
readonly seedVias: readonly (readonly number[])[];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* isSegmentDraftDirty is whether a segment session holds a change leaving would lose: the handles
|
|
81
|
+
* it shows differ from the ones saved.
|
|
82
|
+
*
|
|
83
|
+
* A session nobody touched holds no draft and shows its seed, which is what it saved, so it reads
|
|
84
|
+
* clean. So does one whose handle was dragged away and back, and one undone back to its start,
|
|
85
|
+
* since handles are compared by the points they name. A co-pilot's proposal is saved as nothing,
|
|
86
|
+
* so it reads as a change until it is saved or dropped. No session holds no change.
|
|
87
|
+
*/
|
|
88
|
+
export const isSegmentDraftDirty = (session: SegmentDraftBaseline | null): boolean =>
|
|
89
|
+
session !== null &&
|
|
90
|
+
!sameHandles(segmentDraftHandles(session.draft, session.seedVias), session.savedVias);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DraftChangeDisposition is what an editing surface does with one change its map reports to a
|
|
3
|
+
* draft (a segment's vias, a zone's shape, a waypoint's placement).
|
|
4
|
+
*
|
|
5
|
+
* - `drop`: nothing is recorded, previewed or sent to a collaborator.
|
|
6
|
+
* - `preview`: the change is shown (a live profile, a collaborator's ghost) and never recorded.
|
|
7
|
+
* - `record`: the change is recorded, by its phase where the family has one, and shown.
|
|
8
|
+
*/
|
|
9
|
+
export type DraftChangeDisposition = "drop" | "preview" | "record";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* draftChangeDisposition decides what an editing surface does with one change its map reports,
|
|
13
|
+
* from whether the co-pilot is driving and whether the change is programmatic.
|
|
14
|
+
*
|
|
15
|
+
* | `agentDriving` | `programmatic` | disposition |
|
|
16
|
+
* | --- | --- | --- |
|
|
17
|
+
* | false | false | `record` |
|
|
18
|
+
* | false | true | `preview` |
|
|
19
|
+
* | true | false | `drop` |
|
|
20
|
+
* | true | true | `preview` |
|
|
21
|
+
*
|
|
22
|
+
* A programmatic change is the echo of a write the store already holds (an undo, a redo, an
|
|
23
|
+
* applied draft, the agent's own proposal), so recording it would loop it back into the history.
|
|
24
|
+
* A person's change while the co-pilot drives would move the agent's in-flight edit. A family whose
|
|
25
|
+
* map reports no origin passes `programmatic: false`.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* draftChangeDisposition({ agentDriving: true, programmatic: false }); // "drop"
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export const draftChangeDisposition = (change: {
|
|
33
|
+
/** Whether the co-pilot is running a turn that drives the studio. */
|
|
34
|
+
readonly agentDriving: boolean;
|
|
35
|
+
/** Whether the change is the echo of a programmatic write rather than a person's gesture. */
|
|
36
|
+
readonly programmatic: boolean;
|
|
37
|
+
}): DraftChangeDisposition => {
|
|
38
|
+
if (change.programmatic) {
|
|
39
|
+
return "preview";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return change.agentDriving ? "drop" : "record";
|
|
43
|
+
};
|