@mountaya/studio 0.0.0-stage → 0.1.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 +39 -0
- package/LICENCE.fr.txt +280 -0
- package/LICENSE.txt +262 -0
- package/README.md +917 -2
- package/dist/agent/index.cjs +2854 -0
- package/dist/agent/index.cjs.map +1 -0
- package/dist/agent/index.d.cts +1257 -0
- package/dist/agent/index.d.ts +1257 -0
- package/dist/agent/index.js +2818 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/bus-BwiNiXdH.d.ts +514 -0
- package/dist/bus-DzmhPwdK.d.cts +514 -0
- package/dist/chainModel-B23pEP_1.d.cts +127 -0
- package/dist/chainModel-B23pEP_1.d.ts +127 -0
- package/dist/chunk-2HFY7ETU.js +5721 -0
- package/dist/chunk-2HFY7ETU.js.map +1 -0
- package/dist/chunk-355TOXSB.js +72 -0
- package/dist/chunk-355TOXSB.js.map +1 -0
- package/dist/chunk-4ZCUZVSV.js +10275 -0
- package/dist/chunk-4ZCUZVSV.js.map +1 -0
- package/dist/chunk-6HEKY3NF.js +95 -0
- package/dist/chunk-6HEKY3NF.js.map +1 -0
- package/dist/chunk-7GFLGGBX.cjs +8 -0
- package/dist/chunk-7GFLGGBX.cjs.map +1 -0
- package/dist/chunk-7NBRCENN.cjs +19 -0
- package/dist/chunk-7NBRCENN.cjs.map +1 -0
- package/dist/chunk-AF5GCXE3.js +8 -0
- package/dist/chunk-AF5GCXE3.js.map +1 -0
- package/dist/chunk-CJDIFRGZ.cjs +2005 -0
- package/dist/chunk-CJDIFRGZ.cjs.map +1 -0
- package/dist/chunk-CNPZY7N3.js +349 -0
- package/dist/chunk-CNPZY7N3.js.map +1 -0
- package/dist/chunk-DZJHTWSF.cjs +45 -0
- package/dist/chunk-DZJHTWSF.cjs.map +1 -0
- package/dist/chunk-EABIHHWA.js +42 -0
- package/dist/chunk-EABIHHWA.js.map +1 -0
- package/dist/chunk-EKZWV6RS.cjs +415 -0
- package/dist/chunk-EKZWV6RS.cjs.map +1 -0
- package/dist/chunk-EOKRXXAC.cjs +24 -0
- package/dist/chunk-EOKRXXAC.cjs.map +1 -0
- package/dist/chunk-F73W2ZTJ.js +1126 -0
- package/dist/chunk-F73W2ZTJ.js.map +1 -0
- package/dist/chunk-H4DVOZ5O.js +1897 -0
- package/dist/chunk-H4DVOZ5O.js.map +1 -0
- package/dist/chunk-HI52PBFT.cjs +10314 -0
- package/dist/chunk-HI52PBFT.cjs.map +1 -0
- package/dist/chunk-IDBXFBLG.cjs +1225 -0
- package/dist/chunk-IDBXFBLG.cjs.map +1 -0
- package/dist/chunk-LBWTJZUJ.js +297 -0
- package/dist/chunk-LBWTJZUJ.js.map +1 -0
- package/dist/chunk-NCLA6DKD.cjs +310 -0
- package/dist/chunk-NCLA6DKD.cjs.map +1 -0
- package/dist/chunk-O4MC5DPD.js +19 -0
- package/dist/chunk-O4MC5DPD.js.map +1 -0
- package/dist/chunk-OP37FKW6.cjs +98 -0
- package/dist/chunk-OP37FKW6.cjs.map +1 -0
- package/dist/chunk-OQSYFH3Z.cjs +5945 -0
- package/dist/chunk-OQSYFH3Z.cjs.map +1 -0
- package/dist/chunk-PACIO4NS.cjs +26 -0
- package/dist/chunk-PACIO4NS.cjs.map +1 -0
- package/dist/chunk-PSZ2R3TC.cjs +75 -0
- package/dist/chunk-PSZ2R3TC.cjs.map +1 -0
- package/dist/chunk-QFO5CZG2.cjs +136 -0
- package/dist/chunk-QFO5CZG2.cjs.map +1 -0
- package/dist/chunk-QL63MUEW.cjs +140 -0
- package/dist/chunk-QL63MUEW.cjs.map +1 -0
- package/dist/chunk-RFUPPVZO.js +17 -0
- package/dist/chunk-RFUPPVZO.js.map +1 -0
- package/dist/chunk-RPG2LWMP.js +23 -0
- package/dist/chunk-RPG2LWMP.js.map +1 -0
- package/dist/chunk-TIBXK6B7.cjs +12 -0
- package/dist/chunk-TIBXK6B7.cjs.map +1 -0
- package/dist/chunk-UU65VNEV.js +381 -0
- package/dist/chunk-UU65VNEV.js.map +1 -0
- package/dist/chunk-VGX6TR2I.js +209 -0
- package/dist/chunk-VGX6TR2I.js.map +1 -0
- package/dist/chunk-WUTDDBVP.js +130 -0
- package/dist/chunk-WUTDDBVP.js.map +1 -0
- package/dist/chunk-WVQQLKCI.cjs +224 -0
- package/dist/chunk-WVQQLKCI.cjs.map +1 -0
- package/dist/chunk-WZYXG3SE.js +111 -0
- package/dist/chunk-WZYXG3SE.js.map +1 -0
- package/dist/chunk-XDI2X3KE.js +6 -0
- package/dist/chunk-XDI2X3KE.js.map +1 -0
- package/dist/chunk-XKHLRIC7.cjs +381 -0
- package/dist/chunk-XKHLRIC7.cjs.map +1 -0
- package/dist/context-DNtd2WUv.d.cts +11666 -0
- package/dist/context-DgB72Bur.d.ts +11666 -0
- package/dist/directorThreads-CqmvsV8b.d.cts +80 -0
- package/dist/directorThreads-CqmvsV8b.d.ts +80 -0
- package/dist/en-Bu4Ti9Ev.d.cts +2315 -0
- package/dist/en-Bu4Ti9Ev.d.ts +2315 -0
- package/dist/engines/index.cjs +3446 -0
- package/dist/engines/index.cjs.map +1 -0
- package/dist/engines/index.d.cts +2216 -0
- package/dist/engines/index.d.ts +2216 -0
- package/dist/engines/index.js +3416 -0
- package/dist/engines/index.js.map +1 -0
- package/dist/handlers/index.cjs +99 -0
- package/dist/handlers/index.cjs.map +1 -0
- package/dist/handlers/index.d.cts +445 -0
- package/dist/handlers/index.d.ts +445 -0
- package/dist/handlers/index.js +42 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/index.cjs +4562 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +7297 -0
- package/dist/index.d.ts +7297 -0
- package/dist/index.js +3223 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/index.cjs +977 -0
- package/dist/plugins/index.cjs.map +1 -0
- package/dist/plugins/index.d.cts +313 -0
- package/dist/plugins/index.d.ts +313 -0
- package/dist/plugins/index.js +933 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/saveFile-j-1kkApx.d.cts +123 -0
- package/dist/saveFile-j-1kkApx.d.ts +123 -0
- package/dist/seams/index.cjs +152 -0
- package/dist/seams/index.cjs.map +1 -0
- package/dist/seams/index.d.cts +485 -0
- package/dist/seams/index.d.ts +485 -0
- package/dist/seams/index.js +79 -0
- package/dist/seams/index.js.map +1 -0
- package/dist/shareLink-B6hlt942.d.ts +144 -0
- package/dist/shareLink-C7rIMb7x.d.ts +527 -0
- package/dist/shareLink-CnTxxXjp.d.cts +144 -0
- package/dist/shareLink-DyZVYH2V.d.cts +527 -0
- package/dist/strings/fr/index.cjs +2121 -0
- package/dist/strings/fr/index.cjs.map +1 -0
- package/dist/strings/fr/index.d.cts +19 -0
- package/dist/strings/fr/index.d.ts +19 -0
- package/dist/strings/fr/index.js +2119 -0
- package/dist/strings/fr/index.js.map +1 -0
- package/dist/strings/index.cjs +2678 -0
- package/dist/strings/index.cjs.map +1 -0
- package/dist/strings/index.d.cts +731 -0
- package/dist/strings/index.d.ts +731 -0
- package/dist/strings/index.js +2644 -0
- package/dist/strings/index.js.map +1 -0
- package/dist/studioPlugin-C3C7VjMy.d.ts +847 -0
- package/dist/studioPlugin-Cf3OBNUv.d.cts +847 -0
- package/dist/tabs-B2nRO4p_.d.cts +15 -0
- package/dist/tabs-B2nRO4p_.d.ts +15 -0
- package/dist/testing/index.cjs +292 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +306 -0
- package/dist/testing/index.d.ts +306 -0
- package/dist/testing/index.js +284 -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 +43 -0
- package/dist/time/index.d.ts +43 -0
- package/dist/time/index.js +26 -0
- package/dist/time/index.js.map +1 -0
- package/dist/types-BzJRV6UI.d.cts +845 -0
- package/dist/types-BzJRV6UI.d.ts +845 -0
- package/dist/zoneForm-CdYNtnnA.d.cts +320 -0
- package/dist/zoneForm-mG85yt5e.d.ts +320 -0
- package/package.json +225 -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 +28 -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 +454 -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 +858 -0
- package/src/bus/rules/confirmation.ts +22 -0
- package/src/bus/rules/defineRegistry.ts +26 -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 +805 -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 +573 -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 +87 -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 +213 -0
- package/src/embed/rules/snippet.ts +531 -0
- package/src/embed/rules/tableCode.ts +269 -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 +1086 -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 +1052 -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 +200 -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 +209 -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 +34 -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 +198 -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,977 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkTIBXK6B7_cjs = require('../chunk-TIBXK6B7.cjs');
|
|
4
|
+
var chunkPACIO4NS_cjs = require('../chunk-PACIO4NS.cjs');
|
|
5
|
+
var z = require('zod');
|
|
6
|
+
var errors = require('@mountaya/elements/errors');
|
|
7
|
+
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var z__namespace = /*#__PURE__*/_interopNamespace(z);
|
|
27
|
+
|
|
28
|
+
var studioPluginSlotSchema = z__namespace.enum([
|
|
29
|
+
"itinerary.menu",
|
|
30
|
+
"map.contextMenu",
|
|
31
|
+
"map.controls",
|
|
32
|
+
"profile.header",
|
|
33
|
+
"profile.plot",
|
|
34
|
+
"segment.menu",
|
|
35
|
+
"waypoint.menu",
|
|
36
|
+
"zone.menu"
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
// src/plugins/rules/contributions.ts
|
|
40
|
+
var isStudioContributionAvailable = (contribution, ctx) => {
|
|
41
|
+
const gate = contribution.gate;
|
|
42
|
+
if (gate === void 0) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
for (const capability of gate.capabilities ?? []) {
|
|
47
|
+
if (!ctx.capabilities.has(capability)) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
for (const entitlement of gate.entitlements ?? []) {
|
|
52
|
+
if (!ctx.viewer.hasEntitlement(entitlement)) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return gate.when === void 0 || gate.when(ctx) === true;
|
|
57
|
+
} catch (fault) {
|
|
58
|
+
const faulted = typeof gate === "object" && gate !== null ? gate : contribution;
|
|
59
|
+
if (!faultedGates.has(faulted)) {
|
|
60
|
+
faultedGates.add(faulted);
|
|
61
|
+
chunkPACIO4NS_cjs.surfaceFault(fault);
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var faultedGates = /* @__PURE__ */ new WeakSet();
|
|
67
|
+
var availableStudioContributions = (contributions, ctx) => {
|
|
68
|
+
if (contributions.every((contribution) => isStudioContributionAvailable(contribution, ctx))) {
|
|
69
|
+
return contributions;
|
|
70
|
+
}
|
|
71
|
+
return contributions.filter((contribution) => isStudioContributionAvailable(contribution, ctx));
|
|
72
|
+
};
|
|
73
|
+
var orderOf = ({ order }) => order !== void 0 && Number.isFinite(order) ? order : 0;
|
|
74
|
+
var sortStudioContributions = (contributions) => [...contributions].sort(
|
|
75
|
+
(left, right) => orderOf(left) - orderOf(right) || (left.sequence ?? 0) - (right.sequence ?? 0)
|
|
76
|
+
);
|
|
77
|
+
var STUDIO_PLUGIN_ERROR_NAME = "StudioPluginError";
|
|
78
|
+
var StudioPluginError = class extends errors.MountayaElementsError {
|
|
79
|
+
name = STUDIO_PLUGIN_ERROR_NAME;
|
|
80
|
+
defects;
|
|
81
|
+
constructor(defects, options) {
|
|
82
|
+
super(
|
|
83
|
+
`plugin install refused: ${defects.map((defect) => `${defect.pluginId} ${defect.code}${defect.subject === void 0 ? "" : ` (${defect.subject})`}`).join(", ")}`,
|
|
84
|
+
options
|
|
85
|
+
);
|
|
86
|
+
this.defects = defects;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
var isStudioPluginError = (error) => typeof error === "object" && error !== null && error.name === STUDIO_PLUGIN_ERROR_NAME && Array.isArray(error.defects);
|
|
90
|
+
|
|
91
|
+
// src/plugins/rules/ids.ts
|
|
92
|
+
var studioPluginToolPrefix = (pluginId) => `${pluginId}.`;
|
|
93
|
+
var isStudioPluginToolName = (pluginId, name) => name.startsWith(studioPluginToolPrefix(pluginId));
|
|
94
|
+
var qualifyStudioContributionId = (pluginId, contributionId) => `${pluginId}:${contributionId}`;
|
|
95
|
+
var studioPluginDefectCodeSchema = z__namespace.enum([
|
|
96
|
+
"contribution_empty",
|
|
97
|
+
"contribution_id_duplicate",
|
|
98
|
+
"contribution_id_invalid",
|
|
99
|
+
"plugin_id_invalid",
|
|
100
|
+
"plugin_id_reserved",
|
|
101
|
+
"plugin_id_taken",
|
|
102
|
+
"slot_unknown",
|
|
103
|
+
"tool_key_mismatch",
|
|
104
|
+
"tool_name_empty",
|
|
105
|
+
"tool_name_not_namespaced",
|
|
106
|
+
"tool_name_taken"
|
|
107
|
+
]);
|
|
108
|
+
var isRecord = (value) => typeof value === "object" && value !== null;
|
|
109
|
+
var printed = (value) => {
|
|
110
|
+
if (typeof value === "string") {
|
|
111
|
+
return value;
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
return String(value);
|
|
115
|
+
} catch {
|
|
116
|
+
return typeof value;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
var validateStudioPlugin = (plugin, scope) => {
|
|
120
|
+
const declaration = plugin;
|
|
121
|
+
const members = isRecord(declaration) ? declaration : {};
|
|
122
|
+
const defects = [];
|
|
123
|
+
const pluginId = typeof members.id === "string" ? members.id : "";
|
|
124
|
+
const defect = (code, subject) => {
|
|
125
|
+
defects.push(subject === void 0 ? { code, pluginId } : { code, pluginId, subject });
|
|
126
|
+
};
|
|
127
|
+
if (!chunkTIBXK6B7_cjs.studioPluginIdPattern.test(pluginId)) {
|
|
128
|
+
defect("plugin_id_invalid");
|
|
129
|
+
}
|
|
130
|
+
const vendor = pluginId.split(".")[0];
|
|
131
|
+
if (chunkTIBXK6B7_cjs.RESERVED_PLUGIN_NAMESPACES.some((reserved) => reserved === vendor)) {
|
|
132
|
+
defect("plugin_id_reserved");
|
|
133
|
+
}
|
|
134
|
+
if (scope.installed.has(pluginId)) {
|
|
135
|
+
defect("plugin_id_taken");
|
|
136
|
+
}
|
|
137
|
+
const seen = /* @__PURE__ */ new Set();
|
|
138
|
+
const declared = members.contributions ?? [];
|
|
139
|
+
const contributions = Array.isArray(declared) ? declared : [declared];
|
|
140
|
+
for (const entry of contributions) {
|
|
141
|
+
const contribution = isRecord(entry) ? entry : {};
|
|
142
|
+
const subject = printed(contribution.id);
|
|
143
|
+
if (!studioPluginSlotSchema.safeParse(contribution.slot).success) {
|
|
144
|
+
defect("slot_unknown", printed(contribution.slot));
|
|
145
|
+
}
|
|
146
|
+
if (typeof contribution.id !== "string" || !chunkTIBXK6B7_cjs.studioContributionIdPattern.test(contribution.id)) {
|
|
147
|
+
defect("contribution_id_invalid", subject);
|
|
148
|
+
} else if (seen.has(contribution.id)) {
|
|
149
|
+
defect("contribution_id_duplicate", subject);
|
|
150
|
+
}
|
|
151
|
+
if (typeof contribution.id === "string") {
|
|
152
|
+
seen.add(contribution.id);
|
|
153
|
+
}
|
|
154
|
+
const hasView = contribution.view !== void 0 && contribution.view !== null;
|
|
155
|
+
const hasAction = typeof contribution.label === "string" && contribution.label.trim() !== "" && typeof contribution.run === "function";
|
|
156
|
+
if (!hasView && !hasAction) {
|
|
157
|
+
defect("contribution_empty", subject);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (members.tools !== void 0 && members.tools !== null && !isRecord(members.tools)) {
|
|
161
|
+
defect("tool_key_mismatch", printed(members.tools));
|
|
162
|
+
}
|
|
163
|
+
for (const [key, tool] of Object.entries(isRecord(members.tools) ? members.tools : {})) {
|
|
164
|
+
const name = isRecord(tool) ? tool.name : void 0;
|
|
165
|
+
if (typeof name !== "string") {
|
|
166
|
+
defect("tool_key_mismatch", key);
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (key !== name) {
|
|
170
|
+
defect("tool_key_mismatch", key);
|
|
171
|
+
}
|
|
172
|
+
if (!isStudioPluginToolName(pluginId, name)) {
|
|
173
|
+
defect("tool_name_not_namespaced", name);
|
|
174
|
+
} else if (name === studioPluginToolPrefix(pluginId)) {
|
|
175
|
+
defect("tool_name_empty", name);
|
|
176
|
+
}
|
|
177
|
+
if (scope.tools.has(name)) {
|
|
178
|
+
defect("tool_name_taken", name);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return defects;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// src/plugins/engines/studioPlugin.ts
|
|
185
|
+
var NO_CONTRIBUTIONS = Object.freeze([]);
|
|
186
|
+
var emptyIndex = () => ({
|
|
187
|
+
"itinerary.menu": NO_CONTRIBUTIONS,
|
|
188
|
+
"map.contextMenu": NO_CONTRIBUTIONS,
|
|
189
|
+
"map.controls": NO_CONTRIBUTIONS,
|
|
190
|
+
"profile.header": NO_CONTRIBUTIONS,
|
|
191
|
+
"profile.plot": NO_CONTRIBUTIONS,
|
|
192
|
+
"segment.menu": NO_CONTRIBUTIONS,
|
|
193
|
+
"waypoint.menu": NO_CONTRIBUTIONS,
|
|
194
|
+
"zone.menu": NO_CONTRIBUTIONS
|
|
195
|
+
});
|
|
196
|
+
var refusalsFor = (onRefused) => {
|
|
197
|
+
if (onRefused !== void 0) {
|
|
198
|
+
return { reporter: onRefused, settle: () => void 0 };
|
|
199
|
+
}
|
|
200
|
+
let first;
|
|
201
|
+
return {
|
|
202
|
+
reporter: (error) => {
|
|
203
|
+
first ??= { error };
|
|
204
|
+
},
|
|
205
|
+
settle: () => {
|
|
206
|
+
if (first !== void 0) {
|
|
207
|
+
throw first.error;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
var declaredId = (plugin) => typeof plugin === "object" && plugin !== null && "id" in plugin && typeof plugin.id === "string" ? plugin.id : void 0;
|
|
213
|
+
var noRefusalsTold = () => ({ byId: /* @__PURE__ */ new Map(), unnamed: /* @__PURE__ */ new Map() });
|
|
214
|
+
var unnamedSubject = (member) => {
|
|
215
|
+
if (typeof member === "function") {
|
|
216
|
+
return Function;
|
|
217
|
+
}
|
|
218
|
+
return typeof member === "object" && member !== null ? Object : member;
|
|
219
|
+
};
|
|
220
|
+
var refusalWords = (error) => {
|
|
221
|
+
if (error instanceof Error) {
|
|
222
|
+
return `${error.name}: ${error.message}`;
|
|
223
|
+
}
|
|
224
|
+
try {
|
|
225
|
+
return String(error);
|
|
226
|
+
} catch {
|
|
227
|
+
return "";
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
var noteRefusal = (told, before, member, error) => {
|
|
231
|
+
const id = declaredId(member);
|
|
232
|
+
const words = refusalWords(error);
|
|
233
|
+
if (id === void 0) {
|
|
234
|
+
const subject = unnamedSubject(member);
|
|
235
|
+
const stated = told.unnamed.get(subject) ?? /* @__PURE__ */ new Set();
|
|
236
|
+
told.unnamed.set(subject, stated.add(words));
|
|
237
|
+
return before.unnamed.get(subject)?.has(words) === true;
|
|
238
|
+
}
|
|
239
|
+
const held = before.byId.get(id);
|
|
240
|
+
told.byId.set(id, words);
|
|
241
|
+
return held === words || held === null;
|
|
242
|
+
};
|
|
243
|
+
var declaredListReporter = (onRefused, told, before, surface) => (error, plugin) => {
|
|
244
|
+
const member = plugin;
|
|
245
|
+
if (typeof member !== "object" || member === null) {
|
|
246
|
+
if (surface !== void 0 && !noteRefusal(told, before, member, error)) {
|
|
247
|
+
surface(error);
|
|
248
|
+
}
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
if (!noteRefusal(told, before, member, error)) {
|
|
252
|
+
onRefused(error, plugin);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
var isStillKept = (held, listed) => listed !== void 0 && (!held.listedAsGiven || listed === held.tool);
|
|
256
|
+
var StudioPluginEngine = class {
|
|
257
|
+
listeners = /* @__PURE__ */ new Set();
|
|
258
|
+
observers = /* @__PURE__ */ new Set();
|
|
259
|
+
/** The installed declarations, by id, in install order. */
|
|
260
|
+
plugins = /* @__PURE__ */ new Map();
|
|
261
|
+
/** Each plugin's resolved entries, by id, in declaration order. */
|
|
262
|
+
entries = /* @__PURE__ */ new Map();
|
|
263
|
+
/**
|
|
264
|
+
* Every tool name THIS registry owns, mapped to the plugin that brought it.
|
|
265
|
+
*
|
|
266
|
+
* Ownership rather than registration state, which is the difference that matters while there is
|
|
267
|
+
* no sink: {@link attachTools} is allowed to arrive late, and the names a plugin claimed have to
|
|
268
|
+
* be known before then, both to re-register them when a sink appears and to refuse a second
|
|
269
|
+
* plugin claiming the same one in the meantime.
|
|
270
|
+
*/
|
|
271
|
+
toolNames = /* @__PURE__ */ new Map();
|
|
272
|
+
/**
|
|
273
|
+
* The tools this registry put on the attached sink, by name: the ones it registered there and
|
|
274
|
+
* the ones it adopted where the sink had kept them.
|
|
275
|
+
*
|
|
276
|
+
* It is what {@link withdraw} reads before it asks the sink for a name back. A name that is
|
|
277
|
+
* not here was never this registry's on that sink, whoever holds it there, and is never asked
|
|
278
|
+
* for. Empty while no sink is attached.
|
|
279
|
+
*/
|
|
280
|
+
placed = /* @__PURE__ */ new Map();
|
|
281
|
+
/**
|
|
282
|
+
* The names each sink would not release, by sink: each with the plugin that brought it and
|
|
283
|
+
* the tool that plugin declared.
|
|
284
|
+
*
|
|
285
|
+
* A sink answers `unregister` with false for a name it keeps. The tool is then on the sink
|
|
286
|
+
* with no installed plugin behind it, and this map is what lets the plugin's own declaration
|
|
287
|
+
* meet that sink again, by a new install or by a new attach: the name reads as the plugin's
|
|
288
|
+
* and the held tool is adopted where it stands. An entry is a fact about its sink and stands
|
|
289
|
+
* while another sink is attached, so a registry that returns to a sink it left finds its
|
|
290
|
+
* tools there. Keyed weakly, so a sink that is gone keeps nothing alive.
|
|
291
|
+
*
|
|
292
|
+
* An entry is what the registry remembers, and the sink decides: its owner may take a kept
|
|
293
|
+
* name off it at any time. So a kept name is met again only while the sink still lists it,
|
|
294
|
+
* which {@link register} reads before it adopts, and an entry the sink no longer lists is
|
|
295
|
+
* forgotten there.
|
|
296
|
+
*/
|
|
297
|
+
unreleased = /* @__PURE__ */ new WeakMap();
|
|
298
|
+
/**
|
|
299
|
+
* The ids a DECLARED list owns, which is the only thing {@link sync} may take back.
|
|
300
|
+
*
|
|
301
|
+
* The two install paths compose rather than competing, and this set is what makes that true. A
|
|
302
|
+
* host's `install` array is one authority and a settings screen calling `install()` is another;
|
|
303
|
+
* a reconciliation that dropped every id absent from its own list would silently uninstall the
|
|
304
|
+
* other's the moment the array's identity changed. Seeded by the constructor's `install`,
|
|
305
|
+
* because that is the same declared list the host then syncs.
|
|
306
|
+
*/
|
|
307
|
+
declared = /* @__PURE__ */ new Set();
|
|
308
|
+
/**
|
|
309
|
+
* What the declared list read last was told of, which holds each refusal to one report while
|
|
310
|
+
* the list goes on stating it. See {@link declaredListReporter}.
|
|
311
|
+
*/
|
|
312
|
+
told = noRefusalsTold();
|
|
313
|
+
index = emptyIndex();
|
|
314
|
+
sequence = 0;
|
|
315
|
+
revision = 0;
|
|
316
|
+
/** The installed declarations as {@link installed} hands them back, or null when stale. */
|
|
317
|
+
snapshot = null;
|
|
318
|
+
sink;
|
|
319
|
+
constructor(options = {}) {
|
|
320
|
+
this.sink = options.tools;
|
|
321
|
+
const told = noRefusalsTold();
|
|
322
|
+
const onRefused = options.onRefused === void 0 ? void 0 : declaredListReporter(options.onRefused, told, this.told, void 0);
|
|
323
|
+
try {
|
|
324
|
+
for (const plugin of options.install ?? []) {
|
|
325
|
+
if (this.take(plugin, onRefused)) {
|
|
326
|
+
this.declared.add(plugin.id);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
this.told = told;
|
|
330
|
+
} catch (error) {
|
|
331
|
+
this.dispose();
|
|
332
|
+
throw error;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* at returns the installed contributions for one slot, sorted, UNGATED.
|
|
337
|
+
*
|
|
338
|
+
* The same array between mutations, as the class docblock states. Cast-free, which is why the
|
|
339
|
+
* index is a mapped-type record rather than a `Map`: the one member every render touches is the
|
|
340
|
+
* one that should not need a cast.
|
|
341
|
+
*/
|
|
342
|
+
at(slot) {
|
|
343
|
+
return this.index[slot];
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* installed returns the declarations currently installed, in install order.
|
|
347
|
+
*
|
|
348
|
+
* Materialised once per change and handed back by reference until the next one, for the reason
|
|
349
|
+
* this file's opening comment gives about `at`: a getter shaped like a snapshot will be read as
|
|
350
|
+
* one (`useSyncExternalStore(engine.subscribe, engine.installed)` is the obvious thing for
|
|
351
|
+
* a consumer holding the engine to write), and a fresh array per call is an infinite render
|
|
352
|
+
* loop. An arrow PROPERTY for the same reason {@link subscribe} is one: it is passed detached.
|
|
353
|
+
*/
|
|
354
|
+
installed = () => {
|
|
355
|
+
this.snapshot ??= Object.freeze([...this.plugins.values()]);
|
|
356
|
+
return this.snapshot;
|
|
357
|
+
};
|
|
358
|
+
/**
|
|
359
|
+
* version is a counter that changes whenever any slot does.
|
|
360
|
+
*
|
|
361
|
+
* The scalar a `useSyncExternalStore` reads, so the binding subscribes once for the whole
|
|
362
|
+
* engine rather than once per slot, and the per-slot arrays stay plain reads inside the
|
|
363
|
+
* memo that filters them. An arrow PROPERTY for the same reason {@link subscribe} is one.
|
|
364
|
+
*/
|
|
365
|
+
version = () => this.revision;
|
|
366
|
+
/**
|
|
367
|
+
* subscribe registers a listener called after any change, and returns the detach.
|
|
368
|
+
*
|
|
369
|
+
* An arrow PROPERTY rather than a method, and this is not style: `useSyncExternalStore` calls
|
|
370
|
+
* it detached from the object (`useSyncExternalStore(engine.subscribe, …)`), so a method
|
|
371
|
+
* would arrive with `this` unbound and throw on the first render that reads it.
|
|
372
|
+
*/
|
|
373
|
+
subscribe = (listener) => {
|
|
374
|
+
this.listeners.add(listener);
|
|
375
|
+
return () => {
|
|
376
|
+
this.listeners.delete(listener);
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
/** observe registers a per-`run` telemetry observer and returns the detach. */
|
|
380
|
+
observe(observer) {
|
|
381
|
+
this.observers.add(observer);
|
|
382
|
+
return () => {
|
|
383
|
+
this.observers.delete(observer);
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* attachTools points the engine at a tool sink, moving every installed plugin's tools onto it.
|
|
388
|
+
*
|
|
389
|
+
* The sink is a LIFETIME rather than a construction fact, and this is the member that says so. An
|
|
390
|
+
* engine outlives the bus a binding built for it (a React host rebuilds the bus whenever its
|
|
391
|
+
* handlers, its grants or its confirm gate move), and an engine holding the one it was
|
|
392
|
+
* constructed with would keep registering a plugin's verbs onto a bus nothing dispatches
|
|
393
|
+
* through. It is also the only way an engine a CONSUMER constructed, and handed to the studio,
|
|
394
|
+
* ever reaches a bus at all.
|
|
395
|
+
*
|
|
396
|
+
* It is total in both directions: the outgoing sink gives every name back, the incoming one
|
|
397
|
+
* receives every installed plugin's tools, and `null` detaches. A sink that REFUSES a plugin's
|
|
398
|
+
* tools (a name it already holds) costs that plugin its install, reported through the refusal
|
|
399
|
+
* reporter, because a plugin whose contributions are on the menu and whose verbs are on no bus
|
|
400
|
+
* is half-installed in the one way nothing downstream can see.
|
|
401
|
+
*
|
|
402
|
+
* A detach moves tools and no ownership. The names stay their plugins' while no sink is
|
|
403
|
+
* attached, so a second plugin claiming one is refused when it is installed, and the tools go
|
|
404
|
+
* onto the sink that arrives next.
|
|
405
|
+
*
|
|
406
|
+
* With no reporter the first refusal is thrown, and only once every other plugin's tools are
|
|
407
|
+
* on the incoming sink and the subscribers have heard: a throw never leaves a later plugin on
|
|
408
|
+
* the menu with its verbs on no sink.
|
|
409
|
+
*
|
|
410
|
+
* With a reporter, a refused plugin a declared list states is told of here once: the
|
|
411
|
+
* reconciliation after this attach reports its refusal to nobody, in whatever words it reads
|
|
412
|
+
* there. See {@link StudioPluginRefusalReporter}.
|
|
413
|
+
*
|
|
414
|
+
* It does not notify on its own: moving tools between buses changes no slot. A refusal does
|
|
415
|
+
* change one, and that notifies.
|
|
416
|
+
*
|
|
417
|
+
* `onRefused` is a parameter here rather than a construction option, as it is on {@link sync},
|
|
418
|
+
* and deliberately: a reporter held as a FIELD would put `TView` in an input position on this
|
|
419
|
+
* class, which is what keeps `StudioPluginEngine<never>` (the engine a bare
|
|
420
|
+
* `new StudioPluginEngine()` builds) assignable to the bound one a React host takes.
|
|
421
|
+
*/
|
|
422
|
+
attachTools(sink, onRefused) {
|
|
423
|
+
const outgoing = this.sink;
|
|
424
|
+
if (outgoing !== void 0) {
|
|
425
|
+
for (const [name, owner] of [...this.toolNames]) {
|
|
426
|
+
this.withdraw(name, owner, outgoing);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
this.sink = sink ?? void 0;
|
|
430
|
+
if (sink === null) {
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
const refusals = refusalsFor(onRefused);
|
|
434
|
+
let dropped = false;
|
|
435
|
+
for (const plugin of [...this.plugins.values()]) {
|
|
436
|
+
try {
|
|
437
|
+
this.register(plugin, sink);
|
|
438
|
+
} catch (error) {
|
|
439
|
+
const stated = this.declared.has(plugin.id);
|
|
440
|
+
this.drop(plugin.id);
|
|
441
|
+
dropped = true;
|
|
442
|
+
this.report(error, plugin, refusals.reporter);
|
|
443
|
+
if (onRefused !== void 0 && stated) {
|
|
444
|
+
this.told.byId.set(plugin.id, null);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
if (dropped) {
|
|
449
|
+
this.notify();
|
|
450
|
+
}
|
|
451
|
+
refusals.settle();
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* install validates a plugin, registers its tools and indexes its contributions, or refuses
|
|
455
|
+
* the whole thing.
|
|
456
|
+
*
|
|
457
|
+
* It throws a {@link StudioPluginError} carrying EVERY defect, because an install a host asked
|
|
458
|
+
* for and did not get has to be loud: a plugin that silently failed to install is a menu item
|
|
459
|
+
* that is missing, which reads as the studio being broken rather than as the plugin being
|
|
460
|
+
* malformed. A sink that refuses one of the plugin's tools throws ITS OWN error through here
|
|
461
|
+
* unchanged, after the rollback, so a caller catching this catches both kinds.
|
|
462
|
+
*
|
|
463
|
+
* A value that is no declaration at all, `null` off a manifest for one, is refused the same
|
|
464
|
+
* way: a {@link StudioPluginError} whose defect says it states no id.
|
|
465
|
+
*
|
|
466
|
+
* What it installs is never reconciled away: {@link sync} owns the ids a DECLARED list brought,
|
|
467
|
+
* and this is the other path. A settings screen installing on demand and a host declaring an
|
|
468
|
+
* array compose rather than competing, until the same id appears in the declared list, which
|
|
469
|
+
* takes ownership of it.
|
|
470
|
+
*
|
|
471
|
+
* @throws StudioPluginError carrying every defect of a declaration the validation refuses.
|
|
472
|
+
* @throws whatever the tool sink throws for a tool it refuses, after the rollback.
|
|
473
|
+
*/
|
|
474
|
+
install(plugin) {
|
|
475
|
+
this.adopt(plugin);
|
|
476
|
+
this.notify();
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* uninstall removes a plugin and everything it brought, reporting whether it was there.
|
|
480
|
+
*
|
|
481
|
+
* It takes back only the tool names THIS engine registered for THIS plugin (tracked as they
|
|
482
|
+
* are registered rather than recomputed from the declaration), which is what guarantees an
|
|
483
|
+
* uninstall can never take a `studio.*` verb, or another plugin's, down with it.
|
|
484
|
+
*/
|
|
485
|
+
uninstall(pluginId) {
|
|
486
|
+
if (!this.drop(pluginId)) {
|
|
487
|
+
return false;
|
|
488
|
+
}
|
|
489
|
+
this.notify();
|
|
490
|
+
return true;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* sync reconciles the installed set against a declared list, and notifies at most once.
|
|
494
|
+
*
|
|
495
|
+
* It reconciles by ID for install and uninstall, and ADDITIONALLY replaces a stored
|
|
496
|
+
* declaration when the plugin's object reference changed: rebuilding the touched slots, and
|
|
497
|
+
* re-registering bus tools only when the tool-name list actually differs.
|
|
498
|
+
*
|
|
499
|
+
* Replacing on reference is the one place this departs from a pure by-id reconciliation, and
|
|
500
|
+
* the reason is a real trap: a host that changes language and passes new labels under the same
|
|
501
|
+
* ids would otherwise see nothing change. It is safe HERE because the notification flows
|
|
502
|
+
* strictly DOWN (every subscriber is a menu below the host, and a menu re-rendering never
|
|
503
|
+
* re-renders the host), so there is no cycle to fall into.
|
|
504
|
+
*
|
|
505
|
+
* What it costs is a host who writes the array inline: the menus beneath them re-render
|
|
506
|
+
* whenever the host does. Hoist the declarations to module scope, which is the natural way to
|
|
507
|
+
* write them, and nothing churns.
|
|
508
|
+
*
|
|
509
|
+
* **It removes only what a DECLARED list installed.** An id that arrived through
|
|
510
|
+
* {@link install} (a settings screen, a marketplace loading one on demand) is another
|
|
511
|
+
* authority's, and a reconciliation that dropped it would make the two paths compete for the
|
|
512
|
+
* engine rather than compose in it. A declaration naming that id takes ownership of it from
|
|
513
|
+
* then on.
|
|
514
|
+
*
|
|
515
|
+
* `onRefused` decides what a malformed declaration costs. Supplied, it is reported and skipped
|
|
516
|
+
* and every other declaration still lands; omitted, the first refusal is thrown once every
|
|
517
|
+
* declaration that could be applied has been and the subscribers have heard. A binding
|
|
518
|
+
* reconciling inside a render tree passes one: see {@link StudioPluginRefusalReporter}.
|
|
519
|
+
*
|
|
520
|
+
* A member of the list that is no object is one more malformed declaration: refused where it
|
|
521
|
+
* stands, with the defect of a declaration that states no id. With no reporter it is thrown as
|
|
522
|
+
* any refusal is. With one it is handed to nobody, since a reporter is handed a declaration:
|
|
523
|
+
* its refusal is surfaced on a microtask. Subscribers hear of what the list applied whatever
|
|
524
|
+
* leaves this call.
|
|
525
|
+
*
|
|
526
|
+
* A refusal is reported, or surfaced, once while the list goes on stating it, the seed's list
|
|
527
|
+
* included and a list written inline as well: see {@link StudioPluginRefusalReporter}. With no
|
|
528
|
+
* reporter every call throws its first refusal, since each call is one its caller asked for.
|
|
529
|
+
*/
|
|
530
|
+
sync(plugins, onRefused) {
|
|
531
|
+
const next = /* @__PURE__ */ new Map();
|
|
532
|
+
for (const plugin of plugins) {
|
|
533
|
+
next.set(declaredId(plugin) ?? {}, plugin);
|
|
534
|
+
}
|
|
535
|
+
const told = noRefusalsTold();
|
|
536
|
+
const refusals = refusalsFor(
|
|
537
|
+
onRefused === void 0 ? void 0 : declaredListReporter(onRefused, told, this.told, chunkPACIO4NS_cjs.surfaceFault)
|
|
538
|
+
);
|
|
539
|
+
let changed = false;
|
|
540
|
+
try {
|
|
541
|
+
for (const id of [...this.declared]) {
|
|
542
|
+
if (!next.has(id)) {
|
|
543
|
+
this.drop(id);
|
|
544
|
+
changed = true;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
for (const [id, plugin] of next) {
|
|
548
|
+
if (typeof id !== "string") {
|
|
549
|
+
this.take(plugin, refusals.reporter);
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
552
|
+
if (this.reconcile(id, plugin, refusals.reporter)) {
|
|
553
|
+
changed = true;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
} finally {
|
|
557
|
+
this.told = told;
|
|
558
|
+
if (changed) {
|
|
559
|
+
this.notify();
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
refusals.settle();
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* reconcile brings one declaration of a declared list in under its id: installed where the id
|
|
566
|
+
* is new, replaced where its reference changed, and left where it is the one installed.
|
|
567
|
+
*
|
|
568
|
+
* @returns Whether a slot may have changed: a plugin was installed, replaced, or lost to a
|
|
569
|
+
* sink that refused its replacement.
|
|
570
|
+
*/
|
|
571
|
+
reconcile(id, plugin, onRefused) {
|
|
572
|
+
const current = this.plugins.get(id);
|
|
573
|
+
if (current === plugin) {
|
|
574
|
+
this.declared.add(id);
|
|
575
|
+
return false;
|
|
576
|
+
}
|
|
577
|
+
if (current === void 0) {
|
|
578
|
+
if (!this.take(plugin, onRefused)) {
|
|
579
|
+
return false;
|
|
580
|
+
}
|
|
581
|
+
this.declared.add(id);
|
|
582
|
+
return true;
|
|
583
|
+
}
|
|
584
|
+
let defects;
|
|
585
|
+
try {
|
|
586
|
+
defects = validateStudioPlugin(plugin, this.scope(id, true));
|
|
587
|
+
} catch (error) {
|
|
588
|
+
this.report(error, plugin, onRefused);
|
|
589
|
+
return false;
|
|
590
|
+
}
|
|
591
|
+
if (defects.length > 0) {
|
|
592
|
+
this.report(new StudioPluginError(defects), plugin, onRefused);
|
|
593
|
+
return false;
|
|
594
|
+
}
|
|
595
|
+
this.drop(id);
|
|
596
|
+
if (this.take(plugin, onRefused)) {
|
|
597
|
+
this.declared.add(id);
|
|
598
|
+
}
|
|
599
|
+
return true;
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* run invokes a contribution's verb and reports how it ended. It ALWAYS resolves.
|
|
603
|
+
*
|
|
604
|
+
* It re-checks two things the caller cannot, because a menu can outlive both: that the entry is
|
|
605
|
+
* still installed (a plugin uninstalled, or its declaration replaced, while the dropdown was
|
|
606
|
+
* open) and that its gate still passes (an entitlement that lapsed mid-session). Neither is a
|
|
607
|
+
* throw: a stale click is a no-op with a reason, not a crash.
|
|
608
|
+
*
|
|
609
|
+
* `onError` is how the thrown value reaches a caller that has to report it. The outcome alone
|
|
610
|
+
* cannot carry one, and an observer is registered per ENGINE rather than per call, so a
|
|
611
|
+
* binding wanting to hand the failure to a host seam beside the contribution it came from
|
|
612
|
+
* passes this. It is called at most once, before the promise resolves. An `onError` that itself
|
|
613
|
+
* throws leaves the outcome `threw`, and its fault is surfaced on a microtask.
|
|
614
|
+
*/
|
|
615
|
+
async run(entry, ctx, target, onError) {
|
|
616
|
+
const start = performance.now();
|
|
617
|
+
const report = (outcome, error) => {
|
|
618
|
+
this.emit({
|
|
619
|
+
...error === void 0 ? {} : { error },
|
|
620
|
+
latencyMs: performance.now() - start,
|
|
621
|
+
outcome,
|
|
622
|
+
pluginId: entry.pluginId,
|
|
623
|
+
qualifiedId: entry.qualifiedId,
|
|
624
|
+
slot: entry.slot
|
|
625
|
+
});
|
|
626
|
+
return outcome;
|
|
627
|
+
};
|
|
628
|
+
if (!this.index[entry.slot].some((live) => live === entry)) {
|
|
629
|
+
return report("unknown");
|
|
630
|
+
}
|
|
631
|
+
if (!isStudioContributionAvailable(entry, ctx)) {
|
|
632
|
+
return report("gated");
|
|
633
|
+
}
|
|
634
|
+
const verb = entry.run;
|
|
635
|
+
if (verb === void 0) {
|
|
636
|
+
return report("inert");
|
|
637
|
+
}
|
|
638
|
+
try {
|
|
639
|
+
await verb(ctx, target);
|
|
640
|
+
} catch (error) {
|
|
641
|
+
try {
|
|
642
|
+
onError?.(error);
|
|
643
|
+
} catch (fault) {
|
|
644
|
+
chunkPACIO4NS_cjs.surfaceFault(fault);
|
|
645
|
+
}
|
|
646
|
+
return report("threw", error);
|
|
647
|
+
}
|
|
648
|
+
return report("ran");
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* dispose uninstalls everything and drops every listener and observer.
|
|
652
|
+
*
|
|
653
|
+
* It leaves an EMPTY engine rather than a poisoned one (installing into it afterwards works),
|
|
654
|
+
* because the alternative breaks React's StrictMode, where an effect's cleanup runs between
|
|
655
|
+
* two runs of the effect itself.
|
|
656
|
+
*
|
|
657
|
+
* An empty engine was told of nothing: a list declared after it is told of its refusals as a
|
|
658
|
+
* list stated for the first time is.
|
|
659
|
+
*/
|
|
660
|
+
dispose() {
|
|
661
|
+
const had = this.plugins.size > 0;
|
|
662
|
+
for (const id of [...this.plugins.keys()]) {
|
|
663
|
+
this.drop(id);
|
|
664
|
+
}
|
|
665
|
+
this.told = noRefusalsTold();
|
|
666
|
+
if (had) {
|
|
667
|
+
this.notify();
|
|
668
|
+
}
|
|
669
|
+
this.listeners.clear();
|
|
670
|
+
this.observers.clear();
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* adopt is install without the notification: validate, register with rollback, then index.
|
|
674
|
+
*
|
|
675
|
+
* The order is the atomicity. Validation reads and changes nothing; tool registration is the
|
|
676
|
+
* only step that can fail, and it unwinds its own partial work; indexing is pure mutation of
|
|
677
|
+
* state this object owns and cannot throw. So a refused install leaves the bus and every slot
|
|
678
|
+
* exactly as they were.
|
|
679
|
+
*
|
|
680
|
+
* A sink that keeps a name it is asked for is the one exception, and {@link register} states
|
|
681
|
+
* what becomes of that name.
|
|
682
|
+
*/
|
|
683
|
+
adopt(plugin) {
|
|
684
|
+
const defects = validateStudioPlugin(plugin, this.scope(declaredId(plugin) ?? "", false));
|
|
685
|
+
if (defects.length > 0) {
|
|
686
|
+
throw new StudioPluginError(defects);
|
|
687
|
+
}
|
|
688
|
+
const sink = this.sink;
|
|
689
|
+
const declaredTools = Object.values(plugin.tools ?? {}).map((tool) => tool.name);
|
|
690
|
+
const registered = sink === void 0 ? declaredTools : this.register(plugin, sink);
|
|
691
|
+
for (const name of registered) {
|
|
692
|
+
this.toolNames.set(name, plugin.id);
|
|
693
|
+
}
|
|
694
|
+
this.plugins.set(plugin.id, plugin);
|
|
695
|
+
this.snapshot = null;
|
|
696
|
+
const touched = /* @__PURE__ */ new Set();
|
|
697
|
+
const resolved = (plugin.contributions ?? []).map((contribution) => {
|
|
698
|
+
touched.add(contribution.slot);
|
|
699
|
+
return {
|
|
700
|
+
...contribution,
|
|
701
|
+
pluginId: plugin.id,
|
|
702
|
+
qualifiedId: qualifyStudioContributionId(plugin.id, contribution.id),
|
|
703
|
+
sequence: this.sequence++
|
|
704
|
+
};
|
|
705
|
+
});
|
|
706
|
+
this.entries.set(plugin.id, resolved);
|
|
707
|
+
this.rebuild(touched);
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* register puts one plugin's tools on a sink, unwinding its own partial work if one is refused.
|
|
711
|
+
*
|
|
712
|
+
* The only step of an adoption that can fail, which is why it is the only one with a rollback
|
|
713
|
+
* (see {@link install}'s note on atomicity). `instanceof Error` here is the narrow question "is
|
|
714
|
+
* this already a throwable with a message", not the class-identity check `isStudioPluginError`
|
|
715
|
+
* exists to avoid: the value is the sink's, and wrapping one that is already an error would
|
|
716
|
+
* bury the bus's own message one `cause` deeper.
|
|
717
|
+
*
|
|
718
|
+
* The rollback asks the sink for each name back through {@link withdraw}, as an uninstall
|
|
719
|
+
* does. A name the sink keeps is remembered as the plugin's own, so the declaration put right
|
|
720
|
+
* meets its tool where the refusal left it.
|
|
721
|
+
*
|
|
722
|
+
* A name the sink kept from the plugin's earlier install ({@link unreleased}) is adopted
|
|
723
|
+
* where it stands, and only while the sink still lists it: the sink is read once, when the
|
|
724
|
+
* first such name is met. A kept name the sink does not list then is forgotten and its tool is
|
|
725
|
+
* registered as any other. So is a kept name under which the sink lists another tool, where
|
|
726
|
+
* the sink lists what it is given ({@link isStillKept}): its owner registered that tool since,
|
|
727
|
+
* the sink is offered the plugin's and answers for the name itself. A sink that throws from
|
|
728
|
+
* that read refuses the plugin, as one that throws from `register` does.
|
|
729
|
+
*/
|
|
730
|
+
register(plugin, sink) {
|
|
731
|
+
const kept = this.unreleased.get(sink);
|
|
732
|
+
const registered = [];
|
|
733
|
+
const adopted = [];
|
|
734
|
+
let listed;
|
|
735
|
+
try {
|
|
736
|
+
for (const tool of Object.values(plugin.tools ?? {})) {
|
|
737
|
+
const held = kept?.get(tool.name);
|
|
738
|
+
if (held?.pluginId === plugin.id) {
|
|
739
|
+
listed ??= new Map(sink.registered().map((entry) => [entry.name, entry]));
|
|
740
|
+
if (isStillKept(held, listed.get(tool.name))) {
|
|
741
|
+
if (held.tool !== tool) {
|
|
742
|
+
throw new errors.MountayaElementsError(
|
|
743
|
+
`plugin ${plugin.id} cannot register ${tool.name}: the tool sink kept that name from an earlier install and would not release it. Install the declaration that registered it, or stop reserving the plugin's vendor segment on the sink.`
|
|
744
|
+
);
|
|
745
|
+
}
|
|
746
|
+
adopted.push(held);
|
|
747
|
+
continue;
|
|
748
|
+
}
|
|
749
|
+
kept?.delete(tool.name);
|
|
750
|
+
}
|
|
751
|
+
sink.register(tool);
|
|
752
|
+
this.placed.set(tool.name, tool);
|
|
753
|
+
registered.push(tool.name);
|
|
754
|
+
}
|
|
755
|
+
} catch (error) {
|
|
756
|
+
for (const name of registered) {
|
|
757
|
+
this.withdraw(name, plugin.id, sink);
|
|
758
|
+
}
|
|
759
|
+
throw error instanceof Error ? error : new errors.MountayaElementsError(`plugin ${plugin.id} failed to register a tool`, {
|
|
760
|
+
cause: error
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
for (const { tool } of adopted) {
|
|
764
|
+
this.placed.set(tool.name, tool);
|
|
765
|
+
kept?.delete(tool.name);
|
|
766
|
+
}
|
|
767
|
+
return [...adopted.map(({ tool }) => tool.name), ...registered];
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* take is {@link adopt} with the refusal routed rather than thrown. Reports whether it landed.
|
|
771
|
+
*
|
|
772
|
+
* The one place the two postures meet: with a reporter a refusal is one plugin's problem, and
|
|
773
|
+
* without one it is the caller's. Everything above that wants "apply what you can" goes through
|
|
774
|
+
* here, and the atomicity `adopt` guarantees is untouched either way.
|
|
775
|
+
*/
|
|
776
|
+
take(plugin, onRefused) {
|
|
777
|
+
try {
|
|
778
|
+
this.adopt(plugin);
|
|
779
|
+
} catch (error) {
|
|
780
|
+
this.report(error, plugin, onRefused);
|
|
781
|
+
return false;
|
|
782
|
+
}
|
|
783
|
+
return true;
|
|
784
|
+
}
|
|
785
|
+
/** report hands a refusal to the reporter, or rethrows it when there is none. */
|
|
786
|
+
report(error, plugin, onRefused) {
|
|
787
|
+
if (onRefused === void 0) {
|
|
788
|
+
throw error;
|
|
789
|
+
}
|
|
790
|
+
try {
|
|
791
|
+
onRefused(error, plugin);
|
|
792
|
+
} catch (fault) {
|
|
793
|
+
chunkPACIO4NS_cjs.surfaceFault(fault);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
/** drop is uninstall without the notification. Reports whether the plugin was there. */
|
|
797
|
+
drop(pluginId) {
|
|
798
|
+
this.declared.delete(pluginId);
|
|
799
|
+
if (!this.plugins.has(pluginId)) {
|
|
800
|
+
return false;
|
|
801
|
+
}
|
|
802
|
+
const touched = new Set(
|
|
803
|
+
(this.entries.get(pluginId) ?? []).map((entry) => entry.slot)
|
|
804
|
+
);
|
|
805
|
+
this.plugins.delete(pluginId);
|
|
806
|
+
this.entries.delete(pluginId);
|
|
807
|
+
this.snapshot = null;
|
|
808
|
+
this.rebuild(touched);
|
|
809
|
+
for (const [name, owner] of [...this.toolNames]) {
|
|
810
|
+
if (owner === pluginId) {
|
|
811
|
+
this.toolNames.delete(name);
|
|
812
|
+
if (this.sink !== void 0) {
|
|
813
|
+
this.withdraw(name, pluginId, this.sink);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
return true;
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* withdraw asks a sink for one name back, and remembers a name the sink would not give up.
|
|
821
|
+
*
|
|
822
|
+
* Only a name this registry put there ({@link placed}) is asked for: a name the sink holds
|
|
823
|
+
* for somebody else was never this registry's to take back.
|
|
824
|
+
*
|
|
825
|
+
* `unregister` answers false for a name the sink never held and for one it refuses to release,
|
|
826
|
+
* so the sink is asked whether it still lists the name. A tool left there stays in service
|
|
827
|
+
* with no installed plugin behind it, and is remembered with the tool this registry handed
|
|
828
|
+
* over: see {@link unreleased}. The sink is read by name, since it may hand back another object
|
|
829
|
+
* than it was given.
|
|
830
|
+
*
|
|
831
|
+
* A fault the sink throws here is surfaced on a microtask and leaves through no caller: an
|
|
832
|
+
* uninstall, a reconciliation and a move between sinks each finish what they were doing.
|
|
833
|
+
*/
|
|
834
|
+
withdraw(name, pluginId, sink) {
|
|
835
|
+
const tool = this.placed.get(name);
|
|
836
|
+
if (tool === void 0) {
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
this.placed.delete(name);
|
|
840
|
+
let listed;
|
|
841
|
+
try {
|
|
842
|
+
if (sink.unregister(name)) {
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
listed = sink.registered().find((held) => held.name === name);
|
|
846
|
+
} catch (fault) {
|
|
847
|
+
chunkPACIO4NS_cjs.surfaceFault(fault);
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
if (listed === void 0) {
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
const kept = this.unreleased.get(sink) ?? /* @__PURE__ */ new Map();
|
|
854
|
+
kept.set(name, { listedAsGiven: listed === tool, pluginId, tool });
|
|
855
|
+
this.unreleased.set(sink, kept);
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* rebuild re-materialises exactly the slots named, and nothing else.
|
|
859
|
+
*
|
|
860
|
+
* Only the touched ones, which is what makes "installing a `segment.menu` plugin leaves
|
|
861
|
+
* `at('map.controls')` referentially identical" true: the property a memo keyed on a slot's
|
|
862
|
+
* array depends on.
|
|
863
|
+
*/
|
|
864
|
+
rebuild(slots) {
|
|
865
|
+
for (const slot of slots) {
|
|
866
|
+
const found = [];
|
|
867
|
+
for (const entries of this.entries.values()) {
|
|
868
|
+
for (const entry of entries) {
|
|
869
|
+
if (entry.slot === slot) {
|
|
870
|
+
found.push(entry);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
this.setSlot(
|
|
875
|
+
slot,
|
|
876
|
+
found.length === 0 ? NO_CONTRIBUTIONS : Object.freeze(sortStudioContributions(found))
|
|
877
|
+
);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* setSlot writes one slot of the index.
|
|
882
|
+
*
|
|
883
|
+
* The second localized cast, and it is the mapped type's: writing through a key whose type is
|
|
884
|
+
* the whole union makes TypeScript demand a value assignable to EVERY member's value type at
|
|
885
|
+
* once, which nothing is. Moving the index to a `Map` would trade this cast for one in `at`,
|
|
886
|
+
* the wrong side of the trade, since `at` is the member every render touches.
|
|
887
|
+
*/
|
|
888
|
+
setSlot(slot, entries) {
|
|
889
|
+
this.index[slot] = entries;
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* The collision scope a declaration of `pluginId` is validated against: the ids installed, and
|
|
893
|
+
* every tool name already taken.
|
|
894
|
+
*
|
|
895
|
+
* `replacing` takes the installed plugin of that id back out of it: its id and the names it
|
|
896
|
+
* brought, including the ones the sink is holding for it. That is what lets a replacement be
|
|
897
|
+
* validated while its incumbent is still installed. Without it every re-declaration under an
|
|
898
|
+
* unchanged id would read as `plugin_id_taken` plus one `tool_name_taken` per verb.
|
|
899
|
+
*
|
|
900
|
+
* A name the sink kept from an earlier install of the same id is the plugin's own either way,
|
|
901
|
+
* and taken for every other plugin: see {@link unreleased}. It is the plugin's own only while
|
|
902
|
+
* what the sink lists under it is still the tool it kept ({@link isStillKept}): a name its
|
|
903
|
+
* owner gave another tool since is taken, for this plugin as for any other.
|
|
904
|
+
*/
|
|
905
|
+
scope(pluginId, replacing) {
|
|
906
|
+
const own = /* @__PURE__ */ new Set();
|
|
907
|
+
const tools = /* @__PURE__ */ new Set();
|
|
908
|
+
const kept = this.sink === void 0 ? void 0 : this.unreleased.get(this.sink);
|
|
909
|
+
const listed = this.sink?.registered() ?? [];
|
|
910
|
+
const listedByName = new Map(listed.map((tool) => [tool.name, tool]));
|
|
911
|
+
for (const [name, held] of kept ?? []) {
|
|
912
|
+
if (held.pluginId === pluginId && isStillKept(held, listedByName.get(name))) {
|
|
913
|
+
own.add(name);
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
for (const [name, owner] of this.toolNames) {
|
|
917
|
+
if (replacing && owner === pluginId) {
|
|
918
|
+
own.add(name);
|
|
919
|
+
} else {
|
|
920
|
+
tools.add(name);
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
for (const tool of listed) {
|
|
924
|
+
if (!own.has(tool.name)) {
|
|
925
|
+
tools.add(tool.name);
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
const installed = new Set(this.plugins.keys());
|
|
929
|
+
if (replacing) {
|
|
930
|
+
installed.delete(pluginId);
|
|
931
|
+
}
|
|
932
|
+
return { installed, tools };
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* notify advances the version FIRST, so a listener reading `at` already sees the new list.
|
|
936
|
+
*
|
|
937
|
+
* Every listener is told, by the one rule the package's engines share (`notifyListeners`). A
|
|
938
|
+
* listener that throws skips no listener after it and never leaves through the `install` or
|
|
939
|
+
* `sync` that had already changed the state, which would break, from the outside, the
|
|
940
|
+
* atomicity this class guarantees. Its fault is surfaced on a microtask.
|
|
941
|
+
*/
|
|
942
|
+
notify() {
|
|
943
|
+
this.revision += 1;
|
|
944
|
+
chunkPACIO4NS_cjs.notifyListeners(this.listeners);
|
|
945
|
+
}
|
|
946
|
+
/** emit reports one run to every observer, by the rule {@link notify} follows. */
|
|
947
|
+
emit(event) {
|
|
948
|
+
chunkPACIO4NS_cjs.notifyListeners(this.observers, event);
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
|
|
952
|
+
Object.defineProperty(exports, "RESERVED_PLUGIN_NAMESPACES", {
|
|
953
|
+
enumerable: true,
|
|
954
|
+
get: function () { return chunkTIBXK6B7_cjs.RESERVED_PLUGIN_NAMESPACES; }
|
|
955
|
+
});
|
|
956
|
+
Object.defineProperty(exports, "studioContributionIdPattern", {
|
|
957
|
+
enumerable: true,
|
|
958
|
+
get: function () { return chunkTIBXK6B7_cjs.studioContributionIdPattern; }
|
|
959
|
+
});
|
|
960
|
+
Object.defineProperty(exports, "studioPluginIdPattern", {
|
|
961
|
+
enumerable: true,
|
|
962
|
+
get: function () { return chunkTIBXK6B7_cjs.studioPluginIdPattern; }
|
|
963
|
+
});
|
|
964
|
+
exports.StudioPluginEngine = StudioPluginEngine;
|
|
965
|
+
exports.StudioPluginError = StudioPluginError;
|
|
966
|
+
exports.availableStudioContributions = availableStudioContributions;
|
|
967
|
+
exports.isStudioContributionAvailable = isStudioContributionAvailable;
|
|
968
|
+
exports.isStudioPluginError = isStudioPluginError;
|
|
969
|
+
exports.isStudioPluginToolName = isStudioPluginToolName;
|
|
970
|
+
exports.qualifyStudioContributionId = qualifyStudioContributionId;
|
|
971
|
+
exports.sortStudioContributions = sortStudioContributions;
|
|
972
|
+
exports.studioPluginDefectCodeSchema = studioPluginDefectCodeSchema;
|
|
973
|
+
exports.studioPluginSlotSchema = studioPluginSlotSchema;
|
|
974
|
+
exports.studioPluginToolPrefix = studioPluginToolPrefix;
|
|
975
|
+
exports.validateStudioPlugin = validateStudioPlugin;
|
|
976
|
+
//# sourceMappingURL=index.cjs.map
|
|
977
|
+
//# sourceMappingURL=index.cjs.map
|