@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,353 @@
|
|
|
1
|
+
import { MountayaElementsError } from "@mountaya/elements/errors";
|
|
2
|
+
import type { BoundingBox } from "@mountaya/elements/map-client";
|
|
3
|
+
|
|
4
|
+
import { notifyListeners, surfaceFault } from "../../rules/listeners.js";
|
|
5
|
+
import { type Clock, MAX_TIMER_MS } from "../../seams/rules/clock.js";
|
|
6
|
+
import type { ReadyMessage } from "../rules/bridgeMessages.js";
|
|
7
|
+
import {
|
|
8
|
+
buildReadyPayload,
|
|
9
|
+
EMBED_COVER_MAX_MS,
|
|
10
|
+
resolveFramedError,
|
|
11
|
+
} from "../rules/readyProtocol.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* EmbedReadyConfig is what an embed's ready events are assembled from, all of it replaceable
|
|
15
|
+
* mid-life through {@link EmbedReadyEngine.configure} and read when an event is posted.
|
|
16
|
+
*/
|
|
17
|
+
export interface EmbedReadyConfig {
|
|
18
|
+
/** The itinerary the store has active, or null while none is, reported as the settled content. */
|
|
19
|
+
readonly activeItineraryId: string | null;
|
|
20
|
+
/** The store's terrain slug, empty until the display seed has landed. */
|
|
21
|
+
readonly activeTerrain: string;
|
|
22
|
+
/** The embed config's terrain slug, reported while the store's terrain is still empty. */
|
|
23
|
+
readonly configTerrain: string;
|
|
24
|
+
/** The itinerary the embed config asks for, or null for an embed of the base map alone. */
|
|
25
|
+
readonly configuredItineraryId: string | null;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the configured itinerary's detail failed to load, which a settle reports as
|
|
28
|
+
* `"not_found"`: the host asked for content that never resolved.
|
|
29
|
+
*/
|
|
30
|
+
readonly itineraryFailed: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Receives each ready event, everything but the `type` the host bridge stamps on: an embed in an
|
|
33
|
+
* iframe posts it to the parent page. Omitted where nobody listens (a share page), and the cover
|
|
34
|
+
* still lifts. One that throws stops nothing: the cover has lifted by then, and its fault
|
|
35
|
+
* reaches the program as an uncaught error on a microtask.
|
|
36
|
+
*/
|
|
37
|
+
readonly onReady?: ((payload: Omit<ReadyMessage, "type">) => void) | undefined;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* EmbedReadyEngineOptions is the {@link EmbedReadyConfig} an engine starts with, plus the settings
|
|
42
|
+
* fixed for its life.
|
|
43
|
+
*/
|
|
44
|
+
export interface EmbedReadyEngineOptions extends EmbedReadyConfig {
|
|
45
|
+
/**
|
|
46
|
+
* Where the deadline's time comes from. The deadline is a duration the product chose rather than
|
|
47
|
+
* a rate, so it waits on the studio's `Clock` seam, and a host that renders an embed frame by
|
|
48
|
+
* frame, or tests one, moves it by hand.
|
|
49
|
+
*/
|
|
50
|
+
readonly clock: Clock;
|
|
51
|
+
/**
|
|
52
|
+
* How long the cover waits for the initial view to settle before it lifts anyway, in
|
|
53
|
+
* milliseconds, counted from the first subscriber. When it passes with no settle, the host is
|
|
54
|
+
* told `"timeout"`. A whole or fractional number from 0 to 2,147,483,647, the longest delay a
|
|
55
|
+
* timer honours.
|
|
56
|
+
*
|
|
57
|
+
* @default 8000
|
|
58
|
+
*/
|
|
59
|
+
readonly timeoutMs?: number | undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** EmbedReadySnapshot is what an {@link EmbedReadyEngine} answers: whether the cover still shows. */
|
|
63
|
+
export interface EmbedReadySnapshot {
|
|
64
|
+
/**
|
|
65
|
+
* Whether the loading cover is up: true from the start until the first settle or the deadline,
|
|
66
|
+
* and false for good after either.
|
|
67
|
+
*/
|
|
68
|
+
readonly covered: boolean;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Deadline is one armed deadline: the record the engine compares when the clock runs it, and the
|
|
73
|
+
* cancel the clock handed back for it.
|
|
74
|
+
*/
|
|
75
|
+
interface Deadline {
|
|
76
|
+
cancel: () => void;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** coveredSnapshot is the answer while the cover is up: one object, so its identity is stable. */
|
|
80
|
+
const coveredSnapshot: EmbedReadySnapshot = { covered: true };
|
|
81
|
+
|
|
82
|
+
/** revealedSnapshot is the answer once the cover has lifted, for good. */
|
|
83
|
+
const revealedSnapshot: EmbedReadySnapshot = { covered: false };
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* timeoutFrom reads the deadline an engine is constructed with, refusing a value no timer can keep.
|
|
87
|
+
*
|
|
88
|
+
* @throws {MountayaElementsError} When `timeoutMs` is not a finite number from 0 to
|
|
89
|
+
* {@link MAX_TIMER_MS}. A `NaN` or a negative delay fires at once, and so does an `Infinity` or an
|
|
90
|
+
* oversized one, so each would be a deadline that lifts the cover before the view has had any time
|
|
91
|
+
* to settle while reading as a setting.
|
|
92
|
+
*/
|
|
93
|
+
const timeoutFrom = (timeoutMs: number | undefined): number => {
|
|
94
|
+
if (timeoutMs === undefined) {
|
|
95
|
+
return EMBED_COVER_MAX_MS;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs < 0 || timeoutMs > MAX_TIMER_MS) {
|
|
99
|
+
throw new MountayaElementsError(
|
|
100
|
+
`EmbedReadyEngine: timeoutMs is ${String(timeoutMs)}; pass a number of milliseconds ` +
|
|
101
|
+
`from 0 to ${MAX_TIMER_MS}, or omit it for ${EMBED_COVER_MAX_MS}.`,
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return timeoutMs;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* EmbedReadyEngine is the machine behind an embed's cold-load cover and its ready handshake with
|
|
110
|
+
* the page that hosts it.
|
|
111
|
+
*
|
|
112
|
+
* The cover is up from the start, so a visitor never sees the map's default, off-route centre
|
|
113
|
+
* before the embed frames its content. It lifts on the first of two things:
|
|
114
|
+
*
|
|
115
|
+
* - **A settle.** {@link EmbedReadyEngine.settle} reports that the initial view has painted,
|
|
116
|
+
* framed on the given bounds (see `EmbedFramingEngine`). The cover lifts and a ready event is
|
|
117
|
+
* posted through `onReady`, assembled by `buildReadyPayload` with the error `resolveFramedError`
|
|
118
|
+
* answers. Every settle posts one, the cold load's and each content switch's alike, so a host
|
|
119
|
+
* learns what settled after every switch.
|
|
120
|
+
* - **The deadline.** `timeoutMs` after the first subscriber with nothing settled, the cover lifts
|
|
121
|
+
* whatever the framing reports, so a stalled tile fetch or a failure the framing cannot observe
|
|
122
|
+
* never leaves a visitor facing an opaque plate, and a ready event with the error `"timeout"` is
|
|
123
|
+
* posted, so a host waiting on the event is never left hanging. A settle drops the deadline, so
|
|
124
|
+
* it never contradicts an event already sent.
|
|
125
|
+
*
|
|
126
|
+
* Once lifted the cover stays down: a content switch reframes under the reader's eyes rather than
|
|
127
|
+
* behind a plate.
|
|
128
|
+
*
|
|
129
|
+
* The configuration is read when an event is posted, so a settle reports the itinerary and the
|
|
130
|
+
* terrain as they stand then. Replacing it never moves the deadline, which is counted from the
|
|
131
|
+
* first subscriber however often the surface re-renders.
|
|
132
|
+
*
|
|
133
|
+
* Time follows the engines' rule: the deadline is a duration the product chose, so it waits on
|
|
134
|
+
* the `clock` option, the studio's `Clock` seam, and never on the runtime's own timer.
|
|
135
|
+
*
|
|
136
|
+
* A host's `onReady` that throws, and a listener that throws, stop neither the engine nor the
|
|
137
|
+
* listeners after it. Each is called from a settle the framing engine reports at the end of a
|
|
138
|
+
* paint's promise, or from the clock's own timer at the deadline, where a throw left to travel
|
|
139
|
+
* would read as that caller's own failure. The fault leaves through `surfaceFault` and
|
|
140
|
+
* `notifyListeners`: an uncaught error on a microtask, for the program that handed the callback
|
|
141
|
+
* over.
|
|
142
|
+
*
|
|
143
|
+
* The lifecycle is the listeners. Constructing one arms nothing; the first subscriber arms the
|
|
144
|
+
* deadline while the cover is up; the last unsubscribe parks: the deadline is dropped, and a
|
|
145
|
+
* settle reported while parked lifts nothing and posts nothing. The next subscriber arms a fresh
|
|
146
|
+
* deadline. React's StrictMode mounts, unmounts and mounts again in one pass, which parks and
|
|
147
|
+
* resumes and leaves one deadline armed. {@link EmbedReadyEngine.dispose} is the latch, for an
|
|
148
|
+
* owner that is not a component.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
* declare function notifyHostPage(payload: Omit<ReadyMessage, "type">): void;
|
|
153
|
+
* declare const cover: { toggle(covered: boolean): void };
|
|
154
|
+
*
|
|
155
|
+
* const ready = new EmbedReadyEngine({
|
|
156
|
+
* activeItineraryId: null,
|
|
157
|
+
* activeTerrain: "",
|
|
158
|
+
* clock: systemClock(),
|
|
159
|
+
* configTerrain: "topo",
|
|
160
|
+
* configuredItineraryId: "itin-1",
|
|
161
|
+
* itineraryFailed: false,
|
|
162
|
+
* onReady: (payload) => notifyHostPage(payload),
|
|
163
|
+
* });
|
|
164
|
+
* const release = ready.subscribe(() => cover.toggle(ready.getSnapshot().covered));
|
|
165
|
+
*
|
|
166
|
+
* ready.settle([6.8, 45.8, 7.1, 46]);
|
|
167
|
+
* release();
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
export class EmbedReadyEngine {
|
|
171
|
+
private config: EmbedReadyConfig;
|
|
172
|
+
private readonly clock: Clock;
|
|
173
|
+
private readonly timeoutMs: number;
|
|
174
|
+
|
|
175
|
+
private snapshot: EmbedReadySnapshot = coveredSnapshot;
|
|
176
|
+
private readonly listeners = new Set<() => void>();
|
|
177
|
+
|
|
178
|
+
/** The deadline waiting on the clock, or null while none is. */
|
|
179
|
+
private deadline: Deadline | null = null;
|
|
180
|
+
|
|
181
|
+
/** Whether nobody is watching. A parked engine arms nothing and posts nothing. */
|
|
182
|
+
private parked = true;
|
|
183
|
+
private disposed = false;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Constructing one holds the options and does nothing else: no deadline is armed and nothing is
|
|
187
|
+
* posted. A React binding constructs during a render React is free to throw away, and a
|
|
188
|
+
* constructor with a side effect would leave the discarded copy waiting.
|
|
189
|
+
*
|
|
190
|
+
* @throws {MountayaElementsError} When `timeoutMs` is not a finite number from 0 to
|
|
191
|
+
* 2,147,483,647.
|
|
192
|
+
*/
|
|
193
|
+
constructor(options: EmbedReadyEngineOptions) {
|
|
194
|
+
const { clock, timeoutMs, ...config } = options;
|
|
195
|
+
this.clock = clock;
|
|
196
|
+
this.timeoutMs = timeoutFrom(timeoutMs);
|
|
197
|
+
this.config = config;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** getSnapshot returns the current answer, by reference and stable between changes. */
|
|
201
|
+
getSnapshot(): EmbedReadySnapshot {
|
|
202
|
+
return this.snapshot;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* subscribe registers a listener for every change of the snapshot, and returns its own
|
|
207
|
+
* unsubscribe, which is idempotent.
|
|
208
|
+
*
|
|
209
|
+
* The first listener resumes the engine and the last one leaving parks it, which is the whole
|
|
210
|
+
* lifecycle a component can express correctly: React tears an effect down and sets it up again
|
|
211
|
+
* with the same object under StrictMode, so a latch here would leave a live surface bound to a
|
|
212
|
+
* dead engine. A binding hands its framework a STABLE `subscribe`; a fresh closure per render
|
|
213
|
+
* parks and resumes on every render.
|
|
214
|
+
*/
|
|
215
|
+
subscribe(listener: () => void): () => void {
|
|
216
|
+
if (this.disposed) {
|
|
217
|
+
return () => undefined;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const subscription = (): void => listener();
|
|
221
|
+
this.listeners.add(subscription);
|
|
222
|
+
|
|
223
|
+
if (this.parked) {
|
|
224
|
+
this.parked = false;
|
|
225
|
+
this.arm();
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return () => {
|
|
229
|
+
if (!this.listeners.delete(subscription) || this.listeners.size > 0 || this.parked) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
this.parked = true;
|
|
234
|
+
this.disarm();
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* configure replaces the configuration the next ready event is assembled from. It moves nothing:
|
|
240
|
+
* the deadline stays where it is and a posted event stays posted, so a binding calls it after
|
|
241
|
+
* every render at the cost of an assignment.
|
|
242
|
+
*/
|
|
243
|
+
configure(config: EmbedReadyConfig): void {
|
|
244
|
+
if (!this.disposed) {
|
|
245
|
+
this.config = config;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* settle reports that the initial view has painted, framed on `bounds` (`[west, south, east,
|
|
251
|
+
* north]`, the itinerary's or the collection's, or null when neither frames it): the cover lifts
|
|
252
|
+
* and a ready event is posted.
|
|
253
|
+
* Called on the cold load and again after every content switch, and each call posts. A call
|
|
254
|
+
* while parked, or after {@link EmbedReadyEngine.dispose}, does nothing.
|
|
255
|
+
*/
|
|
256
|
+
settle(bounds: BoundingBox | null): void {
|
|
257
|
+
if (this.parked || this.disposed) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const { configuredItineraryId, itineraryFailed } = this.config;
|
|
262
|
+
this.disarm();
|
|
263
|
+
this.reveal();
|
|
264
|
+
this.post(bounds, resolveFramedError(configuredItineraryId, itineraryFailed));
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* dispose drops the deadline and every listener, for good.
|
|
269
|
+
*
|
|
270
|
+
* Idempotent, and every call after it is a no-op rather than an error: an owner torn down
|
|
271
|
+
* mid-load should not have to guard the calls it already queued.
|
|
272
|
+
*/
|
|
273
|
+
dispose(): void {
|
|
274
|
+
if (this.disposed) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
this.disposed = true;
|
|
279
|
+
this.parked = true;
|
|
280
|
+
this.disarm();
|
|
281
|
+
this.listeners.clear();
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** arm waits out the deadline while the cover is up. */
|
|
285
|
+
private arm(): void {
|
|
286
|
+
if (!this.snapshot.covered || this.deadline !== null) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// The deadline this call arms, compared when it fires, so a clock that still runs a cancelled
|
|
291
|
+
// callback cannot lift a cover for a deadline the engine has since dropped. It is held before
|
|
292
|
+
// the clock is asked: a clock that runs a zero delay at once fires inside `after`, before
|
|
293
|
+
// there is a cancel to keep.
|
|
294
|
+
const deadline: Deadline = { cancel: () => undefined };
|
|
295
|
+
this.deadline = deadline;
|
|
296
|
+
deadline.cancel = this.clock.after(this.timeoutMs, () => {
|
|
297
|
+
if (this.deadline !== deadline) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
this.deadline = null;
|
|
302
|
+
this.expire();
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/** disarm drops the deadline, if one is armed. */
|
|
307
|
+
private disarm(): void {
|
|
308
|
+
const deadline = this.deadline;
|
|
309
|
+
this.deadline = null;
|
|
310
|
+
deadline?.cancel();
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* expire lifts the cover at the deadline and says `"timeout"`. It runs only for the deadline the
|
|
315
|
+
* engine still holds, so the engine is watched and nothing has settled: a settle, a park and a
|
|
316
|
+
* dispose each drop the deadline, and a lifted cover arms no other.
|
|
317
|
+
*/
|
|
318
|
+
private expire(): void {
|
|
319
|
+
this.reveal();
|
|
320
|
+
this.post(null, "timeout");
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/** post hands one ready event to the host, assembled from the configuration as it stands. */
|
|
324
|
+
private post(bounds: BoundingBox | null, error: ReadyMessage["error"]): void {
|
|
325
|
+
const { activeItineraryId, activeTerrain, configTerrain, onReady } = this.config;
|
|
326
|
+
const payload = buildReadyPayload({
|
|
327
|
+
activeItineraryId,
|
|
328
|
+
activeTerrain,
|
|
329
|
+
bounds,
|
|
330
|
+
configTerrain,
|
|
331
|
+
error,
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
try {
|
|
335
|
+
onReady?.(payload);
|
|
336
|
+
} catch (fault) {
|
|
337
|
+
// The cover has lifted and every listener has heard by now, so there is nothing to undo,
|
|
338
|
+
// and the callers are a settle at the end of a paint's promise and the clock's timer:
|
|
339
|
+
// neither can catch it. The host's own program hears of its defect.
|
|
340
|
+
surfaceFault(fault);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** reveal lifts the cover, and tells every listener when that is news. */
|
|
345
|
+
private reveal(): void {
|
|
346
|
+
if (this.snapshot === revealedSnapshot) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
this.snapshot = revealedSnapshot;
|
|
351
|
+
notifyListeners(this.listeners);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hosted embed's session token, asked of the page that frames it.
|
|
3
|
+
*
|
|
4
|
+
* An organization that sets `require_session_token` has every read of its hosted embed carry a
|
|
5
|
+
* session token, the map's tiles included, and a token lives minutes. The embed cannot mint
|
|
6
|
+
* one: minting takes the organization's secret key, which only the integrator's server holds. So
|
|
7
|
+
* the embed asks the page that frames it, and that page asks the server: the snippet's script
|
|
8
|
+
* answers each request from the integrator's own endpoint.
|
|
9
|
+
*
|
|
10
|
+
* {@link askFramingPageForSession} is one such ask, shaped as the `mint` a `SessionTokenEngine`
|
|
11
|
+
* of `@mountaya/client` takes, so the engine schedules the next one a minute before the answer's
|
|
12
|
+
* `expires_at` and retries a page that did not answer:
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { SessionTokenEngine } from "@mountaya/client";
|
|
16
|
+
* import { askFramingPageForSession } from "@mountaya/studio/engines";
|
|
17
|
+
* import { systemClock } from "@mountaya/studio/seams";
|
|
18
|
+
*
|
|
19
|
+
* const session = new SessionTokenEngine({
|
|
20
|
+
* mint: () => askFramingPageForSession({ clock: systemClock(), embed: window }),
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import type { RestSchema } from "@mountaya/client";
|
|
26
|
+
import { MountayaElementsError } from "@mountaya/elements/errors";
|
|
27
|
+
|
|
28
|
+
import { type Clock, MAX_TIMER_MS } from "../../seams/rules/clock.js";
|
|
29
|
+
import {
|
|
30
|
+
REQUEST_SESSION_TOKEN_MESSAGE,
|
|
31
|
+
setSessionTokenMessageSchema,
|
|
32
|
+
} from "../rules/bridgeMessages.js";
|
|
33
|
+
|
|
34
|
+
/** FRAMING_PAGE_SESSION_TIMEOUT_MS is how long an ask waits for the framing page by default. */
|
|
35
|
+
export const FRAMING_PAGE_SESSION_TIMEOUT_MS = 10_000;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* FramingPageMessage is the part of a window `message` event an ask reads: the payload, and the
|
|
39
|
+
* window that posted it.
|
|
40
|
+
*/
|
|
41
|
+
export interface FramingPageMessage {
|
|
42
|
+
readonly data: unknown;
|
|
43
|
+
readonly source: unknown;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* FramingPageWindow is the part of the embed's own window an ask uses: its parent, the page that
|
|
48
|
+
* frames it, and the `message` listener the answer arrives through. A browser `Window` is one.
|
|
49
|
+
*/
|
|
50
|
+
export interface FramingPageWindow {
|
|
51
|
+
readonly addEventListener: (
|
|
52
|
+
type: "message",
|
|
53
|
+
listener: (event: FramingPageMessage) => void,
|
|
54
|
+
) => void;
|
|
55
|
+
readonly parent: {
|
|
56
|
+
readonly postMessage: (message: unknown, targetOrigin: string) => void;
|
|
57
|
+
};
|
|
58
|
+
readonly removeEventListener: (
|
|
59
|
+
type: "message",
|
|
60
|
+
listener: (event: FramingPageMessage) => void,
|
|
61
|
+
) => void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** AskFramingPageForSessionOptions is what {@link askFramingPageForSession} takes. */
|
|
65
|
+
export interface AskFramingPageForSessionOptions {
|
|
66
|
+
/**
|
|
67
|
+
* Where the wait's time comes from: `systemClock()` of `@mountaya/studio/seams` in a page, which
|
|
68
|
+
* the host chooses as it chooses every seam.
|
|
69
|
+
*/
|
|
70
|
+
readonly clock: Clock;
|
|
71
|
+
/**
|
|
72
|
+
* How long to wait for the framing page's answer, in milliseconds, before the ask rejects. A
|
|
73
|
+
* whole or fractional number from 1 to 2,147,483,647, the longest delay a timer honours.
|
|
74
|
+
*
|
|
75
|
+
* @default 10000
|
|
76
|
+
*/
|
|
77
|
+
readonly timeoutMs?: number | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* The embed's own window, whose parent is the page that frames it. Handed in rather than read
|
|
80
|
+
* off the global, so a host decides which window asks, and a suite hands it a stand-in.
|
|
81
|
+
*/
|
|
82
|
+
readonly embed: FramingPageWindow;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* timeoutFrom reads the wait an ask is given, refusing one no timer honours: a `NaN`, an infinity,
|
|
87
|
+
* zero or less, or one past the longest delay a timer keeps.
|
|
88
|
+
*/
|
|
89
|
+
const timeoutFrom = (timeoutMs: number | undefined): number => {
|
|
90
|
+
if (timeoutMs === undefined) {
|
|
91
|
+
return FRAMING_PAGE_SESSION_TIMEOUT_MS;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0 || timeoutMs > MAX_TIMER_MS) {
|
|
95
|
+
throw new MountayaElementsError(
|
|
96
|
+
`askFramingPageForSession: timeoutMs is ${String(timeoutMs)}; pass a number of ` +
|
|
97
|
+
`milliseconds from 1 to ${MAX_TIMER_MS}, or omit it for ${FRAMING_PAGE_SESSION_TIMEOUT_MS}.`,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return timeoutMs;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* askFramingPageForSession asks the page that frames the embed for a session token, and resolves
|
|
106
|
+
* with the first valid `mountaya:setSessionToken` that page posts back.
|
|
107
|
+
*
|
|
108
|
+
* Only the framing page is heard: a message from any other window (a frame beside the embed, a
|
|
109
|
+
* popup, a frame inside it) is ignored, as is one that does not parse, so a script the framing
|
|
110
|
+
* page did not run itself never hands the embed a token. The answer resolves as a `Session` whose
|
|
111
|
+
* `user_id` is null: the hosted embed reads what is published and acts as no member.
|
|
112
|
+
*
|
|
113
|
+
* @param options - The embed's own window, and how long to wait.
|
|
114
|
+
* @returns The session, as `POST /v1/sessions` answers one.
|
|
115
|
+
* @throws {MountayaElementsError} Where `timeoutMs` is no delay a timer honours. The promise
|
|
116
|
+
* rejects with one where the embed is not framed, since there is no page to ask, and where the
|
|
117
|
+
* framing page has not answered within `timeoutMs`; the listener is removed either way, so an
|
|
118
|
+
* unanswered ask holds nothing.
|
|
119
|
+
*/
|
|
120
|
+
export const askFramingPageForSession = (
|
|
121
|
+
options: AskFramingPageForSessionOptions,
|
|
122
|
+
): Promise<RestSchema.Session> => {
|
|
123
|
+
const timeoutMs = timeoutFrom(options.timeoutMs);
|
|
124
|
+
const { clock, embed } = options;
|
|
125
|
+
|
|
126
|
+
return new Promise((resolve, reject) => {
|
|
127
|
+
// A window that is its own parent is a top-level page: the request would reach only itself.
|
|
128
|
+
if (Object.is(embed.parent, embed)) {
|
|
129
|
+
reject(
|
|
130
|
+
new MountayaElementsError(
|
|
131
|
+
"askFramingPageForSession: the embed is not framed, so no page can hand it a session token.",
|
|
132
|
+
),
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
let cancel = (): void => {};
|
|
139
|
+
const listener = (event: FramingPageMessage): void => {
|
|
140
|
+
if (event.source !== embed.parent) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const parsed = setSessionTokenMessageSchema.safeParse(event.data);
|
|
145
|
+
if (!parsed.success) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
cancel();
|
|
150
|
+
embed.removeEventListener("message", listener);
|
|
151
|
+
resolve({
|
|
152
|
+
expires_at: new Date(parsed.data.expiresAt),
|
|
153
|
+
token: parsed.data.token,
|
|
154
|
+
user_id: null,
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
embed.addEventListener("message", listener);
|
|
159
|
+
cancel = clock.after(timeoutMs, () => {
|
|
160
|
+
embed.removeEventListener("message", listener);
|
|
161
|
+
reject(
|
|
162
|
+
new MountayaElementsError(
|
|
163
|
+
`askFramingPageForSession: the framing page answered no session token within ${timeoutMs} ms.`,
|
|
164
|
+
),
|
|
165
|
+
);
|
|
166
|
+
});
|
|
167
|
+
embed.parent.postMessage({ type: REQUEST_SESSION_TOKEN_MESSAGE }, "*");
|
|
168
|
+
});
|
|
169
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { ToolFailure } from "../../bus/rules/types.js";
|
|
2
|
+
import { requirePublishEntitlement } from "../../itinerary/handlers/publicationScope.js";
|
|
3
|
+
import { isKnownPersonalTarget } from "../../share/handlers/shareScope.js";
|
|
4
|
+
import type { StudioToolContext, StudioToolDefinition } from "../../viewer/rules/context.js";
|
|
5
|
+
import { entitlementWithheld } from "../../viewer/rules/viewer.js";
|
|
6
|
+
import { type SwitchOverrides, switchOverridesSchema } from "../rules/bridgeMessages.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* requireEmbed refuses a viewer without the `embed` entitlement, else answers null. Embedding an
|
|
10
|
+
* itinerary in a third-party site issues a publishable key scoped to an organization, so the
|
|
11
|
+
* open and close verbs run this gate first, and refuse with {@link entitlementWithheld}.
|
|
12
|
+
*
|
|
13
|
+
* The gate asks the viewer seam for the entitlement, the same answer the menu entry reads, so
|
|
14
|
+
* who may embed is the host's table to keep.
|
|
15
|
+
*/
|
|
16
|
+
const requireEmbed = (ctx: StudioToolContext): ToolFailure | null =>
|
|
17
|
+
ctx.viewer.hasEntitlement("embed") ? null : entitlementWithheld("embed");
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* open opens the embed wizard for an itinerary or a collection: it seeds the embed slot with that
|
|
21
|
+
* one pointer, which is all the store holds. The wizard authors its display config in its own
|
|
22
|
+
* form and reads the organization's default props and publishable key from server state.
|
|
23
|
+
*
|
|
24
|
+
* Its gates stand before it. A viewer without the `embed` entitlement, or without `publish`, is
|
|
25
|
+
* refused with `upgrade-required` ({@link requireEmbed}, then {@link requirePublishEntitlement}):
|
|
26
|
+
* an embed serves what Map Publishing publishes, so a studio offers no way into one where the
|
|
27
|
+
* organization's agreement does not include it. A target the session knows to be PERSONAL is
|
|
28
|
+
* refused with `forbidden`, since an embed's publishable key belongs to an organization: the same
|
|
29
|
+
* reading the share sheet's gate makes ({@link isKnownPersonalTarget}), and the same refusal the
|
|
30
|
+
* menu states by offering no embed entry. A target whose organization the session does not know
|
|
31
|
+
* opens, and the server is the boundary. Every gate holds for the co-pilot, which dispatches
|
|
32
|
+
* through this bus.
|
|
33
|
+
*/
|
|
34
|
+
export const open: StudioToolDefinition<"studio.embed.open"> = {
|
|
35
|
+
handler: (ctx, input) => {
|
|
36
|
+
const gate = requireEmbed(ctx) ?? requirePublishEntitlement(ctx);
|
|
37
|
+
if (gate) {
|
|
38
|
+
return gate;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (isKnownPersonalTarget(ctx, input)) {
|
|
42
|
+
const resources = input.kind === "collection" ? "collections" : "itineraries";
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
code: "forbidden",
|
|
46
|
+
error: `this ${input.kind} is personal: only an organization's ${resources} can be embedded`,
|
|
47
|
+
ok: false,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
ctx.ui.getState().setEmbed({ id: input.id, kind: input.kind });
|
|
52
|
+
|
|
53
|
+
return { ok: true, summary: `Opened the embed wizard for ${input.kind} ${input.id}.` };
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* close closes the embed wizard by clearing the embed slot. Gated on `embed` as open is (a viewer
|
|
59
|
+
* without it has no wizard to close).
|
|
60
|
+
*/
|
|
61
|
+
export const close: StudioToolDefinition<"studio.embed.close"> = {
|
|
62
|
+
handler: (ctx) => {
|
|
63
|
+
const gate = requireEmbed(ctx);
|
|
64
|
+
if (gate) {
|
|
65
|
+
return gate;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
ctx.ui.getState().setEmbed(null);
|
|
69
|
+
|
|
70
|
+
return { ok: true, summary: "Closed the embed wizard." };
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* providedOverrides keeps the members of `overrides` a host stated: a member whose value is
|
|
76
|
+
* undefined, and a list stated as null, is not provided.
|
|
77
|
+
*
|
|
78
|
+
* The parser keeps a key that is present with the value undefined, and so does the structured
|
|
79
|
+
* clone a `postMessage` makes, so a host that builds its message from optional variables sends
|
|
80
|
+
* such keys. Read through the schema again so the answer is typed by it and holds no such key.
|
|
81
|
+
*/
|
|
82
|
+
const providedOverrides = (overrides: SwitchOverrides): SwitchOverrides =>
|
|
83
|
+
switchOverridesSchema.parse(
|
|
84
|
+
Object.fromEntries(
|
|
85
|
+
Object.entries(overrides).filter(([, value]) => value !== undefined && value !== null),
|
|
86
|
+
),
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* mergeOverrides accumulates the display overrides a host newly provided onto the ones it sent
|
|
91
|
+
* before, so a field that is not provided leaves the current value unchanged (the documented
|
|
92
|
+
* `setItinerary` contract). Not provided is an omitted field, a field stated as undefined and a
|
|
93
|
+
* list stated as null ({@link providedOverrides}): none of them clears what the host set.
|
|
94
|
+
*/
|
|
95
|
+
const mergeOverrides = (
|
|
96
|
+
previous: SwitchOverrides | undefined,
|
|
97
|
+
incoming: SwitchOverrides,
|
|
98
|
+
): SwitchOverrides => ({ ...previous, ...providedOverrides(incoming) });
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* setContent sets the embedded studio's live content from a host `mountaya:setItinerary`
|
|
102
|
+
* postMessage: it switches to the itinerary by id and accumulates the command's display
|
|
103
|
+
* overrides into the embed-content store slot the surface reads. It is a read-only
|
|
104
|
+
* DISPLAY verb: it only writes the UI store. The surface folds the slot over the resolved
|
|
105
|
+
* config and clamps it again to the organization's safety rules, so this tool records intent
|
|
106
|
+
* only and can never lift a capability past the organization's boundary. ctx is the first
|
|
107
|
+
* positional parameter.
|
|
108
|
+
*
|
|
109
|
+
* A null id is a content too: the slot records it with the overrides the host set, and the
|
|
110
|
+
* surface then shows the base map alone and releases the lock an itinerary's extent held, or,
|
|
111
|
+
* on an embed of a collection, frames the collection again. The slot is never cleared here,
|
|
112
|
+
* since an empty one stands for a host that has sent nothing.
|
|
113
|
+
*/
|
|
114
|
+
export const setContent: StudioToolDefinition<"studio.embed.setContent"> = {
|
|
115
|
+
agentHidden: true,
|
|
116
|
+
handler: (ctx, input) => {
|
|
117
|
+
const { itineraryId, ...incoming } = input;
|
|
118
|
+
const previous = ctx.ui.getState().embedContent;
|
|
119
|
+
const overrides = mergeOverrides(previous?.overrides, incoming);
|
|
120
|
+
ctx.ui.getState().setEmbedContent({ itineraryId, overrides });
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
ok: true,
|
|
124
|
+
summary:
|
|
125
|
+
itineraryId === null
|
|
126
|
+
? "Set the embedded studio to the base map alone, with no itinerary."
|
|
127
|
+
: `Set the embedded studio to itinerary ${itineraryId}.`,
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
};
|