@mountaya/studio 0.1.0 → 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.
Files changed (260) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/agent/index.cjs +2561 -2815
  3. package/dist/agent/index.cjs.map +1 -1
  4. package/dist/agent/index.d.cts +766 -786
  5. package/dist/agent/index.d.ts +766 -786
  6. package/dist/agent/index.js +2553 -2790
  7. package/dist/agent/index.js.map +1 -1
  8. package/dist/chunk-3Oi_Zrtm.js +9 -0
  9. package/dist/chunk-3Oi_Zrtm.js.map +1 -0
  10. package/dist/chunk-B18OPIu_.js +6 -0
  11. package/dist/chunk-B18OPIu_.js.map +1 -0
  12. package/dist/chunk-B5Uz3Qct.cjs +15 -0
  13. package/dist/chunk-B5Uz3Qct.cjs.map +1 -0
  14. package/dist/chunk-BBEJwkd3.d.cts +839 -0
  15. package/dist/chunk-BIEc_SkR.cjs +29 -0
  16. package/dist/chunk-BIEc_SkR.cjs.map +1 -0
  17. package/dist/chunk-BKMFOe-N.js +171 -0
  18. package/dist/chunk-BKMFOe-N.js.map +1 -0
  19. package/dist/chunk-BP4uy7E1.d.ts +11583 -0
  20. package/dist/chunk-BSHTsFiB.js +1403 -0
  21. package/dist/chunk-BSHTsFiB.js.map +1 -0
  22. package/dist/chunk-BTUUABGI.js +17 -0
  23. package/dist/chunk-BTUUABGI.js.map +1 -0
  24. package/dist/chunk-BaPiaz5X.cjs +115 -0
  25. package/dist/chunk-BaPiaz5X.cjs.map +1 -0
  26. package/dist/chunk-BeCVpkYr.cjs +542 -0
  27. package/dist/chunk-BeCVpkYr.cjs.map +1 -0
  28. package/dist/chunk-BgngsvK8.cjs +6202 -0
  29. package/dist/chunk-BgngsvK8.cjs.map +1 -0
  30. package/dist/chunk-BhInd7CJ.d.cts +253 -0
  31. package/dist/chunk-Bn6ZbxkS.cjs +27 -0
  32. package/dist/chunk-By9ZnkVI.js +60 -0
  33. package/dist/chunk-By9ZnkVI.js.map +1 -0
  34. package/dist/chunk-BzqPhxsz.cjs +367 -0
  35. package/dist/chunk-BzqPhxsz.cjs.map +1 -0
  36. package/dist/chunk-C2mMX81q.d.ts +443 -0
  37. package/dist/chunk-C2rr9Q0V.cjs +1402 -0
  38. package/dist/chunk-C2rr9Q0V.cjs.map +1 -0
  39. package/dist/{directorThreads-CqmvsV8b.d.cts → chunk-CDJCbwIQ.d.cts} +20 -22
  40. package/dist/chunk-CLGvBOVH.d.cts +1654 -0
  41. package/dist/chunk-COdw1dc6.d.ts +525 -0
  42. package/dist/chunk-CQCJnT2i.d.ts +511 -0
  43. package/dist/chunk-CSyHY67q.cjs +353 -0
  44. package/dist/chunk-CSyHY67q.cjs.map +1 -0
  45. package/dist/chunk-CiK1Iqrv.js +950 -0
  46. package/dist/chunk-CiK1Iqrv.js.map +1 -0
  47. package/dist/chunk-CmJBgSwZ.cjs +24 -0
  48. package/dist/chunk-CmJBgSwZ.cjs.map +1 -0
  49. package/dist/chunk-CnrsRK2u.cjs +83 -0
  50. package/dist/chunk-CnrsRK2u.cjs.map +1 -0
  51. package/dist/chunk-Co782_9r.js +326 -0
  52. package/dist/chunk-Co782_9r.js.map +1 -0
  53. package/dist/chunk-Csr3KDpZ.cjs +32 -0
  54. package/dist/chunk-Csr3KDpZ.cjs.map +1 -0
  55. package/dist/chunk-CwkmccXv.js +89 -0
  56. package/dist/chunk-CwkmccXv.js.map +1 -0
  57. package/dist/chunk-D0Q4iL9B.cjs +255 -0
  58. package/dist/chunk-D0Q4iL9B.cjs.map +1 -0
  59. package/dist/chunk-DFwiSzUS.cjs +72 -0
  60. package/dist/chunk-DFwiSzUS.cjs.map +1 -0
  61. package/dist/chunk-DIFayl2P.d.cts +443 -0
  62. package/dist/chunk-DIGF58ux.d.cts +525 -0
  63. package/dist/chunk-DKuuuld5.js +101 -0
  64. package/dist/chunk-DKuuuld5.js.map +1 -0
  65. package/dist/chunk-DMePkFEo.js +5054 -0
  66. package/dist/chunk-DMePkFEo.js.map +1 -0
  67. package/dist/chunk-DO5SIBgu.js +305 -0
  68. package/dist/chunk-DO5SIBgu.js.map +1 -0
  69. package/dist/chunk-DOQ_7eE5.d.ts +6662 -0
  70. package/dist/{tabs-B2nRO4p_.d.ts → chunk-DThaaNeb.d.cts} +2 -2
  71. package/dist/{tabs-B2nRO4p_.d.cts → chunk-DThaaNeb.d.ts} +2 -2
  72. package/dist/{directorThreads-CqmvsV8b.d.ts → chunk-DUQzjUJy.d.ts} +20 -22
  73. package/dist/chunk-DX37IPhV.cjs +1903 -0
  74. package/dist/chunk-DX37IPhV.cjs.map +1 -0
  75. package/dist/chunk-Damps5Tk.cjs +155 -0
  76. package/dist/chunk-Damps5Tk.cjs.map +1 -0
  77. package/dist/chunk-DbK5PhpJ.d.ts +1654 -0
  78. package/dist/chunk-De0vAASv.d.ts +253 -0
  79. package/dist/chunk-DhSZ7YZt.d.cts +6662 -0
  80. package/dist/chunk-DjEvqvPA.cjs +43 -0
  81. package/dist/chunk-DjEvqvPA.cjs.map +1 -0
  82. package/dist/{saveFile-j-1kkApx.d.cts → chunk-DkwDzwvu.d.cts} +7 -9
  83. package/dist/{saveFile-j-1kkApx.d.ts → chunk-DkwDzwvu.d.ts} +7 -9
  84. package/dist/chunk-Dmszv9If.js +71 -0
  85. package/dist/chunk-Dmszv9If.js.map +1 -0
  86. package/dist/chunk-Dp_ftNWY.d.cts +511 -0
  87. package/dist/chunk-DsHQySz0.js +31 -0
  88. package/dist/chunk-DsHQySz0.js.map +1 -0
  89. package/dist/chunk-DwoUyHHh.js +281 -0
  90. package/dist/chunk-DwoUyHHh.js.map +1 -0
  91. package/dist/chunk-IaIDQflj.d.cts +2315 -0
  92. package/dist/chunk-IaIDQflj.d.ts +2315 -0
  93. package/dist/chunk-cVXLsZfL.d.ts +839 -0
  94. package/dist/chunk-mIaCX9EJ.d.cts +11583 -0
  95. package/dist/chunk-nJQxbOwQ.cjs +8962 -0
  96. package/dist/chunk-nJQxbOwQ.cjs.map +1 -0
  97. package/dist/chunk-o9jaxhCO.js +8852 -0
  98. package/dist/chunk-o9jaxhCO.js.map +1 -0
  99. package/dist/chunk-p-Tt_Lwz.js +14 -0
  100. package/dist/chunk-p-Tt_Lwz.js.map +1 -0
  101. package/dist/engines/index.cjs +2046 -3401
  102. package/dist/engines/index.cjs.map +1 -1
  103. package/dist/engines/index.d.cts +1510 -1550
  104. package/dist/engines/index.d.ts +1510 -1550
  105. package/dist/engines/index.js +2039 -3380
  106. package/dist/engines/index.js.map +1 -1
  107. package/dist/handlers/index.cjs +47 -93
  108. package/dist/handlers/index.cjs.map +1 -1
  109. package/dist/handlers/index.d.cts +61 -103
  110. package/dist/handlers/index.d.ts +61 -103
  111. package/dist/handlers/index.js +27 -36
  112. package/dist/handlers/index.js.map +1 -1
  113. package/dist/index.cjs +3347 -4398
  114. package/dist/index.cjs.map +1 -1
  115. package/dist/index.d.cts +8 -7297
  116. package/dist/index.d.ts +8 -7297
  117. package/dist/index.js +2997 -3187
  118. package/dist/index.js.map +1 -1
  119. package/dist/plugins/index.cjs +482 -949
  120. package/dist/plugins/index.cjs.map +1 -1
  121. package/dist/plugins/index.d.cts +44 -61
  122. package/dist/plugins/index.d.ts +44 -61
  123. package/dist/plugins/index.js +471 -915
  124. package/dist/plugins/index.js.map +1 -1
  125. package/dist/seams/index.cjs +77 -140
  126. package/dist/seams/index.cjs.map +1 -1
  127. package/dist/seams/index.d.cts +125 -158
  128. package/dist/seams/index.d.ts +125 -158
  129. package/dist/seams/index.js +41 -71
  130. package/dist/seams/index.js.map +1 -1
  131. package/dist/strings/fr/index.cjs +2130 -2116
  132. package/dist/strings/fr/index.cjs.map +1 -1
  133. package/dist/strings/fr/index.d.cts +3 -5
  134. package/dist/strings/fr/index.d.ts +3 -5
  135. package/dist/strings/fr/index.js +2125 -2114
  136. package/dist/strings/fr/index.js.map +1 -1
  137. package/dist/strings/index.cjs +2331 -2625
  138. package/dist/strings/index.cjs.map +1 -1
  139. package/dist/strings/index.d.cts +3 -731
  140. package/dist/strings/index.d.ts +3 -731
  141. package/dist/strings/index.js +2324 -2615
  142. package/dist/strings/index.js.map +1 -1
  143. package/dist/testing/index.cjs +214 -276
  144. package/dist/testing/index.cjs.map +1 -1
  145. package/dist/testing/index.d.cts +61 -121
  146. package/dist/testing/index.d.ts +61 -121
  147. package/dist/testing/index.js +208 -273
  148. package/dist/testing/index.js.map +1 -1
  149. package/dist/time/index.cjs +23 -23
  150. package/dist/time/index.cjs.map +1 -1
  151. package/dist/time/index.d.cts +5 -7
  152. package/dist/time/index.d.ts +5 -7
  153. package/dist/time/index.js +18 -21
  154. package/dist/time/index.js.map +1 -1
  155. package/package.json +14 -15
  156. package/src/agent/rules/stateDelta.ts +1 -0
  157. package/src/agent/stores/agentThreads.ts +1 -4
  158. package/src/bus/rules/bus.ts +1 -2
  159. package/src/bus/rules/defineRegistry.ts +3 -5
  160. package/src/bus/rules/types.ts +6 -7
  161. package/src/chrome/stores/uiStore.ts +4 -2
  162. package/src/embed/rules/fieldDependencies.ts +2 -0
  163. package/src/embed/rules/safetyRules.ts +2 -0
  164. package/src/embed/rules/tableCode.ts +4 -3
  165. package/src/index.ts +6 -27
  166. package/src/itinerary/rules/import.ts +6 -8
  167. package/src/plugins/contracts/plugin.ts +4 -2
  168. package/src/seams/rules/formatters.ts +5 -3
  169. package/src/testing/index.ts +1 -5
  170. package/src/viewer/rules/platformViewer.ts +1 -0
  171. package/dist/bus-BwiNiXdH.d.ts +0 -514
  172. package/dist/bus-DzmhPwdK.d.cts +0 -514
  173. package/dist/chainModel-B23pEP_1.d.cts +0 -127
  174. package/dist/chainModel-B23pEP_1.d.ts +0 -127
  175. package/dist/chunk-2HFY7ETU.js +0 -5721
  176. package/dist/chunk-2HFY7ETU.js.map +0 -1
  177. package/dist/chunk-355TOXSB.js +0 -72
  178. package/dist/chunk-355TOXSB.js.map +0 -1
  179. package/dist/chunk-4ZCUZVSV.js +0 -10275
  180. package/dist/chunk-4ZCUZVSV.js.map +0 -1
  181. package/dist/chunk-6HEKY3NF.js +0 -95
  182. package/dist/chunk-6HEKY3NF.js.map +0 -1
  183. package/dist/chunk-7GFLGGBX.cjs +0 -8
  184. package/dist/chunk-7GFLGGBX.cjs.map +0 -1
  185. package/dist/chunk-7NBRCENN.cjs +0 -19
  186. package/dist/chunk-7NBRCENN.cjs.map +0 -1
  187. package/dist/chunk-AF5GCXE3.js +0 -8
  188. package/dist/chunk-AF5GCXE3.js.map +0 -1
  189. package/dist/chunk-CJDIFRGZ.cjs +0 -2005
  190. package/dist/chunk-CJDIFRGZ.cjs.map +0 -1
  191. package/dist/chunk-CNPZY7N3.js +0 -349
  192. package/dist/chunk-CNPZY7N3.js.map +0 -1
  193. package/dist/chunk-DZJHTWSF.cjs +0 -45
  194. package/dist/chunk-DZJHTWSF.cjs.map +0 -1
  195. package/dist/chunk-EABIHHWA.js +0 -42
  196. package/dist/chunk-EABIHHWA.js.map +0 -1
  197. package/dist/chunk-EKZWV6RS.cjs +0 -415
  198. package/dist/chunk-EKZWV6RS.cjs.map +0 -1
  199. package/dist/chunk-EOKRXXAC.cjs +0 -24
  200. package/dist/chunk-EOKRXXAC.cjs.map +0 -1
  201. package/dist/chunk-F73W2ZTJ.js +0 -1126
  202. package/dist/chunk-F73W2ZTJ.js.map +0 -1
  203. package/dist/chunk-H4DVOZ5O.js +0 -1897
  204. package/dist/chunk-H4DVOZ5O.js.map +0 -1
  205. package/dist/chunk-HI52PBFT.cjs +0 -10314
  206. package/dist/chunk-HI52PBFT.cjs.map +0 -1
  207. package/dist/chunk-IDBXFBLG.cjs +0 -1225
  208. package/dist/chunk-IDBXFBLG.cjs.map +0 -1
  209. package/dist/chunk-LBWTJZUJ.js +0 -297
  210. package/dist/chunk-LBWTJZUJ.js.map +0 -1
  211. package/dist/chunk-NCLA6DKD.cjs +0 -310
  212. package/dist/chunk-NCLA6DKD.cjs.map +0 -1
  213. package/dist/chunk-O4MC5DPD.js +0 -19
  214. package/dist/chunk-O4MC5DPD.js.map +0 -1
  215. package/dist/chunk-OP37FKW6.cjs +0 -98
  216. package/dist/chunk-OP37FKW6.cjs.map +0 -1
  217. package/dist/chunk-OQSYFH3Z.cjs +0 -5945
  218. package/dist/chunk-OQSYFH3Z.cjs.map +0 -1
  219. package/dist/chunk-PACIO4NS.cjs +0 -26
  220. package/dist/chunk-PACIO4NS.cjs.map +0 -1
  221. package/dist/chunk-PSZ2R3TC.cjs +0 -75
  222. package/dist/chunk-PSZ2R3TC.cjs.map +0 -1
  223. package/dist/chunk-QFO5CZG2.cjs +0 -136
  224. package/dist/chunk-QFO5CZG2.cjs.map +0 -1
  225. package/dist/chunk-QL63MUEW.cjs +0 -140
  226. package/dist/chunk-QL63MUEW.cjs.map +0 -1
  227. package/dist/chunk-RFUPPVZO.js +0 -17
  228. package/dist/chunk-RFUPPVZO.js.map +0 -1
  229. package/dist/chunk-RPG2LWMP.js +0 -23
  230. package/dist/chunk-RPG2LWMP.js.map +0 -1
  231. package/dist/chunk-TIBXK6B7.cjs +0 -12
  232. package/dist/chunk-TIBXK6B7.cjs.map +0 -1
  233. package/dist/chunk-UU65VNEV.js +0 -381
  234. package/dist/chunk-UU65VNEV.js.map +0 -1
  235. package/dist/chunk-VGX6TR2I.js +0 -209
  236. package/dist/chunk-VGX6TR2I.js.map +0 -1
  237. package/dist/chunk-WUTDDBVP.js +0 -130
  238. package/dist/chunk-WUTDDBVP.js.map +0 -1
  239. package/dist/chunk-WVQQLKCI.cjs +0 -224
  240. package/dist/chunk-WVQQLKCI.cjs.map +0 -1
  241. package/dist/chunk-WZYXG3SE.js +0 -111
  242. package/dist/chunk-WZYXG3SE.js.map +0 -1
  243. package/dist/chunk-XDI2X3KE.js +0 -6
  244. package/dist/chunk-XDI2X3KE.js.map +0 -1
  245. package/dist/chunk-XKHLRIC7.cjs +0 -381
  246. package/dist/chunk-XKHLRIC7.cjs.map +0 -1
  247. package/dist/context-DNtd2WUv.d.cts +0 -11666
  248. package/dist/context-DgB72Bur.d.ts +0 -11666
  249. package/dist/en-Bu4Ti9Ev.d.cts +0 -2315
  250. package/dist/en-Bu4Ti9Ev.d.ts +0 -2315
  251. package/dist/shareLink-B6hlt942.d.ts +0 -144
  252. package/dist/shareLink-C7rIMb7x.d.ts +0 -527
  253. package/dist/shareLink-CnTxxXjp.d.cts +0 -144
  254. package/dist/shareLink-DyZVYH2V.d.cts +0 -527
  255. package/dist/studioPlugin-C3C7VjMy.d.ts +0 -847
  256. package/dist/studioPlugin-Cf3OBNUv.d.cts +0 -847
  257. package/dist/types-BzJRV6UI.d.cts +0 -845
  258. package/dist/types-BzJRV6UI.d.ts +0 -845
  259. package/dist/zoneForm-CdYNtnnA.d.cts +0 -320
  260. package/dist/zoneForm-mG85yt5e.d.ts +0 -320
@@ -0,0 +1,839 @@
1
+ import { C as StudioCapability, a as StudioToolContext, c as StudioEntitlement, i as StudioTool, qi as ContextMenu } from "./chunk-BP4uy7E1.js";
2
+ import * as z$1 from "zod";
3
+ /**
4
+ * The places a studio lets a plugin put something, and what each one hands over.
5
+ *
6
+ * A closed vocabulary of this package, spelled `<surface>.<region>`. The studio is
7
+ * TypeScript-only, so no other language SDK implements it: it is this package's own, and a
8
+ * plugin manifest (one id, one slot name, one label) names an insertion in this studio. Renaming
9
+ * one breaks every manifest that names it, which is why they are settled here and validated with
10
+ * Zod rather than left as a string.
11
+ *
12
+ * A z.enum rather than a union alias because a manifest can arrive off a wire (a host storing
13
+ * a workspace's enabled plugins in their own database, a settings import), and a slot name that
14
+ * resolves to nothing has to be REFUSED at that boundary rather than silently rendering nowhere.
15
+ *
16
+ * **Panels and the sidenav are deliberately absent.** Both vocabularies are closed `z.enum`s on
17
+ * the shared store (`studioPanelSchema`, `studioContentSchema`), so a contributed panel is not a
18
+ * new render site: it is a change to the store's shape, and to every surface that branches on
19
+ * it. That is a different feature, and it is not this one.
20
+ */
21
+ declare const studioPluginSlotSchema: z$1.ZodEnum<{
22
+ "itinerary.menu": "itinerary.menu";
23
+ "map.contextMenu": "map.contextMenu";
24
+ "map.controls": "map.controls";
25
+ "profile.header": "profile.header";
26
+ "profile.plot": "profile.plot";
27
+ "segment.menu": "segment.menu";
28
+ "waypoint.menu": "waypoint.menu";
29
+ "zone.menu": "zone.menu";
30
+ }>;
31
+ /** One slot a plugin contributes to, derived from {@link studioPluginSlotSchema}. */
32
+ type StudioPluginSlot = z$1.infer<typeof studioPluginSlotSchema>;
33
+ /**
34
+ * StudioPluginItineraryMenuTarget is what the itinerary's three-dots menu hands a contribution.
35
+ *
36
+ * `organizationId` rides along because the gate a plugin most often wants here is the one the
37
+ * package's own Embed item uses (is this itinerary owned by a real organization), and reading
38
+ * it off the store would mean reaching past the seam for a fact the menu already holds.
39
+ */
40
+ interface StudioPluginItineraryMenuTarget {
41
+ readonly itineraryId: string;
42
+ /** The itinerary's owning organization, or null for a personal one. */
43
+ readonly organizationId: string | null;
44
+ }
45
+ /**
46
+ * StudioPluginMapContextMenuTarget is what the map's right-click menu hands a contribution: the
47
+ * itinerary open behind it, and the WHOLE open menu.
48
+ *
49
+ * The whole {@link ContextMenu} rather than a coordinate, deliberately. Everything a plugin
50
+ * could want at a clicked point (the POIs resolved there, the active overlay's features, the
51
+ * zone under the cursor) is already in that value, and handing over only the coordinate would
52
+ * make every interesting plugin reach past this seam into the store for the rest. A seam a
53
+ * consumer has to work around is a seam that does not hold.
54
+ */
55
+ interface StudioPluginMapContextMenuTarget {
56
+ readonly itineraryId: string | null;
57
+ readonly menu: ContextMenu;
58
+ }
59
+ /** StudioPluginMapControlsTarget is what the map control rail hands a contribution. */
60
+ interface StudioPluginMapControlsTarget {
61
+ /** The itinerary the controls act on, or null when none is open. */
62
+ readonly itineraryId: string | null;
63
+ }
64
+ /**
65
+ * StudioPluginProfileTarget is what both elevation-profile regions hand a contribution.
66
+ *
67
+ * One interface for two slots because the two regions answer the same question (which
68
+ * itinerary is being profiled) and differ only in where they draw. A header piece is chrome
69
+ * beside the actions menu; a plot piece is a layer over the curve, positioning itself against
70
+ * the plot the element actually drew.
71
+ */
72
+ interface StudioPluginProfileTarget {
73
+ readonly itineraryId: string | null;
74
+ }
75
+ /**
76
+ * StudioPluginSegmentMenuTarget is what a segment row's `…` menu hands a contribution.
77
+ *
78
+ * `itineraryId` is nullable because the same row renders for an import DRAFT, whose chain has no
79
+ * server-side itinerary behind it yet. A contribution that needs one gates on it rather than
80
+ * assuming it.
81
+ */
82
+ interface StudioPluginSegmentMenuTarget {
83
+ readonly itineraryId: string | null;
84
+ readonly segmentId: string;
85
+ }
86
+ /** StudioPluginWaypointMenuTarget is what a waypoint row's `…` menu hands a contribution. */
87
+ interface StudioPluginWaypointMenuTarget {
88
+ readonly itineraryId: string | null;
89
+ readonly waypointId: string;
90
+ }
91
+ /**
92
+ * StudioPluginZoneMenuTarget is what the zone panel's `…` menu hands a contribution.
93
+ *
94
+ * It carries no itinerary: the zone panel edits a zone, which is a resource of its own and is
95
+ * reached with no itinerary open at all.
96
+ */
97
+ interface StudioPluginZoneMenuTarget {
98
+ readonly zoneId: string;
99
+ }
100
+ /**
101
+ * StudioPluginSlotTargets maps every slot to what it hands over.
102
+ *
103
+ * A record keyed by the slot union rather than one loose type per slot, and that is the PARITY
104
+ * GATE for this whole file: a name added to {@link studioPluginSlotSchema} with no entry here
105
+ * fails at this declaration, before anything reads it. The alternative, a switch somewhere that
106
+ * resolves a slot to a target, would compile with a slot missing and fail at the render site.
107
+ */
108
+ interface StudioPluginSlotTargets {
109
+ readonly "itinerary.menu": StudioPluginItineraryMenuTarget;
110
+ readonly "map.contextMenu": StudioPluginMapContextMenuTarget;
111
+ readonly "map.controls": StudioPluginMapControlsTarget;
112
+ readonly "profile.header": StudioPluginProfileTarget;
113
+ readonly "profile.plot": StudioPluginProfileTarget;
114
+ readonly "segment.menu": StudioPluginSegmentMenuTarget;
115
+ readonly "waypoint.menu": StudioPluginWaypointMenuTarget;
116
+ readonly "zone.menu": StudioPluginZoneMenuTarget;
117
+ }
118
+ /**
119
+ * StudioPluginTarget is what a given slot hands a contribution.
120
+ *
121
+ * An indexed access rather than a conditional type, so `StudioPluginTarget<"zone.menu">` resolves
122
+ * to the interface itself, which is what a reader hovering it sees, and what an error message
123
+ * names.
124
+ */
125
+ type StudioPluginTarget<TSlot extends StudioPluginSlot> = StudioPluginSlotTargets[TSlot];
126
+ /**
127
+ * What a plugin IS, and what it puts where.
128
+ *
129
+ * A host replaces what the studio DOES through a handler, a seam or a confirm gate; a plugin
130
+ * ADDS to it. "Send this segment to Strava" or "band the elevation plot with today's avalanche
131
+ * bulletin" is a contribution a plugin declares rather than a fork of the component that draws
132
+ * the menu.
133
+ *
134
+ * **A contribution is DATA, with a component escape hatch.** Most of the slots are uniformly
135
+ * action-shaped (a label, a glyph, something to run), which is what lets the studio draw a
136
+ * native-looking, correctly-gated, correctly-disabled menu item from a plugin author who has
137
+ * never installed the design system. `view` is the other half, and it is what makes a plot layer
138
+ * or a control with its own popover possible at all.
139
+ *
140
+ * **One type parameter carries both, and this package never binds it.** `TView` defaults to
141
+ * `never`, which makes a bare `StudioPlugin` exactly the TOOLS-ONLY plugin: the one a
142
+ * render-free test builds, and the one a port's first milestone ships before it has a single
143
+ * renderer. `@mountaya/studio-react` binds it once as `StudioPlugin<ReactNode>`.
144
+ *
145
+ * `TView` appears only in OUTPUT position (a property, never a parameter), which is what keeps
146
+ * `StudioPlugin<never>` assignable to `StudioPlugin<ReactNode>`. Moving it into a parameter (a
147
+ * `render(view: TView)` callback, say) makes the two unrelated types and takes that portability
148
+ * with it.
149
+ */
150
+ /**
151
+ * StudioPluginGate is when a contribution is available at all.
152
+ *
153
+ * Three clauses, ANDed, each ABSENT meaning no constraint, so `{}` and an omitted gate are the
154
+ * same thing, and a gate naming one clause does not implicitly refuse on the others.
155
+ *
156
+ * The vocabulary is the studio's own, which is the point: a plugin gates on `editor` and
157
+ * `video-export` rather than inventing a parallel permission model a host would then have to
158
+ * keep in step with the one the studio already reads.
159
+ */
160
+ interface StudioPluginGate {
161
+ /** Every capability the surface must hold. */
162
+ readonly capabilities?: readonly StudioCapability[] | undefined;
163
+ /** Every entitlement the viewer must hold. */
164
+ readonly entitlements?: readonly StudioEntitlement[] | undefined;
165
+ /**
166
+ * The plugin's own predicate over the live tool context, for a condition no grant can express:
167
+ * "only while a segment is selected", "only for an itinerary with elevation".
168
+ *
169
+ * It runs at RENDER time, once per contribution per render of the surface, so it must be
170
+ * cheap and must not mutate. A predicate that THROWS resolves to unavailable: a gate that
171
+ * cannot answer has not said yes, and refusing in that direction is the safe one.
172
+ */
173
+ readonly when?: ((ctx: StudioToolContext) => boolean) | undefined;
174
+ }
175
+ /**
176
+ * StudioSlotContribution is one thing a plugin puts in one slot.
177
+ *
178
+ * It needs EITHER `label` + `run` (the action form) OR `view` (the component form);
179
+ * `validateStudioPlugin` refuses one with neither, because a contribution the studio cannot
180
+ * draw is an install that silently does nothing.
181
+ *
182
+ * `id` is local to the plugin (the registry qualifies it with the plugin's own id before
183
+ * anything else sees it), so two plugins may both contribute `export`.
184
+ */
185
+ interface StudioSlotContribution<TSlot extends StudioPluginSlot, TView = never> {
186
+ /** Draws the action in the destructive tone the studio's own delete verbs use. */
187
+ readonly destructive?: boolean | undefined;
188
+ readonly gate?: StudioPluginGate | undefined;
189
+ /** The glyph beside the label. Rendered as-is, so its size is the plugin's to match. */
190
+ readonly icon?: TView | undefined;
191
+ /** Unique within the plugin. See `studioContributionIdPattern` in `contracts/ids`. */
192
+ readonly id: string;
193
+ /** What the action says. Already localized: this package ships no words. */
194
+ readonly label?: string | undefined;
195
+ /**
196
+ * Where it sits among the other contributions in the slot, ascending.
197
+ *
198
+ * Uncoordinated on purpose: two plugins both picking `100` are resolved by INSTALL order,
199
+ * deterministically, which is a smaller thing to explain than a `before`/`after` graph and
200
+ * covers the case that actually arises. Absent is `0`.
201
+ */
202
+ readonly order?: number | undefined;
203
+ /**
204
+ * What the action does, handed the host's live tool context and this instance's target.
205
+ *
206
+ * It may return a promise; the registry awaits it and reports the outcome, and a rejection is
207
+ * caught rather than left unhandled. A `run` is a CLICK and nothing else: see
208
+ * {@link StudioPlugin.tools} for the half a co-pilot can reach.
209
+ */
210
+ readonly run?: ((ctx: StudioToolContext, target: StudioPluginTarget<TSlot>) => void | Promise<void>) | undefined;
211
+ readonly slot: TSlot;
212
+ /**
213
+ * The component form: whatever the binding's view type is, rendered in the slot.
214
+ *
215
+ * It is how a contribution carries its own interaction (a popover, a plot layer, a control
216
+ * with state) rather than being one row in somebody else's menu. A view that also sets
217
+ * `label`/`run` is fine and the view wins; the action fields are then documentation.
218
+ */
219
+ readonly view?: TView | undefined;
220
+ }
221
+ /**
222
+ * StudioPluginContribution is a contribution to ANY slot, with its target already narrowed.
223
+ *
224
+ * Distributed over the slot union rather than written as
225
+ * `StudioSlotContribution<StudioPluginSlot, TView>`, and the difference is the whole ergonomics
226
+ * of the type: this way `slot: "zone.menu"` narrows `run`'s second parameter to
227
+ * `StudioPluginZoneMenuTarget` at the declaration site, with no cast and no generic argument for
228
+ * the author to write. The non-distributed spelling would give every `run` a union target that
229
+ * every plugin then has to narrow by hand.
230
+ */
231
+ type StudioPluginContribution<TView = never> = { [TSlot in StudioPluginSlot]: StudioSlotContribution<TSlot, TView>; }[StudioPluginSlot];
232
+ /**
233
+ * StudioSlotEntry is a contribution as the REGISTRY holds it: what the plugin declared, plus
234
+ * where it came from and when.
235
+ *
236
+ * `qualifiedId` is `${pluginId}:${id}`, which is the stable identity a surface keys a list on
237
+ * and a host records a preference against. `sequence` is the install counter, and it is what
238
+ * makes {@link StudioSlotContribution.order} a total order rather than a partial one: ties break
239
+ * on it, so two plugins picking the same number render in the order they were installed and in
240
+ * that order every time.
241
+ */
242
+ interface StudioSlotEntry<TSlot extends StudioPluginSlot, TView = never> extends StudioSlotContribution<TSlot, TView> {
243
+ readonly pluginId: string;
244
+ readonly qualifiedId: string;
245
+ readonly sequence: number;
246
+ }
247
+ /** StudioPluginEntry is a registry entry for ANY slot, narrowed the way its contribution is. */
248
+ type StudioPluginEntry<TView = never> = { [TSlot in StudioPluginSlot]: StudioSlotEntry<TSlot, TView>; }[StudioPluginSlot];
249
+ /**
250
+ * StudioPluginSubject is WHICH contribution something is about, with the verb left off.
251
+ *
252
+ * It is what a report takes ("this one failed", "this one ran"), and it is a separate type
253
+ * rather than {@link StudioPluginContribution} because of one member. `run`'s target is keyed on
254
+ * the contribution's own slot, so it sits in PARAMETER position; a function generic over the
255
+ * slot holds a `StudioSlotEntry<TSlot, …>` whose `run` accepts `Target<TSlot>`, and widening
256
+ * that to the union would ask it to accept every other slot's target too. Contravariance refuses
257
+ * it, correctly: a segment verb cannot be handed a zone.
258
+ *
259
+ * Omitting the verb leaves only covariant members, so an entry for ANY slot, a generic one
260
+ * included, is assignable here without a cast. What is left is everything a reporter reads:
261
+ * the plugin, the qualified id, the slot, the label, the rank.
262
+ */
263
+ type StudioPluginSubject<TView = never> = Omit<StudioSlotEntry<StudioPluginSlot, TView>, "run">;
264
+ /**
265
+ * StudioPlugin is the whole declaration a host installs.
266
+ *
267
+ * The smallest useful one is `{ id, contributions }`. `tools` is the opt-in
268
+ * half a co-pilot can reach: a `run` is a click and the agent cannot see it, by design, so a
269
+ * plugin that wants its verb driven by the co-pilot declares a tool with a Zod schema and
270
+ * dispatches THAT from its own `run`: one implementation reached two ways, rather than two
271
+ * implementations that agree until one is edited.
272
+ *
273
+ * Hoist the declaration to module scope. The registry reconciles by id and replaces a stored
274
+ * declaration when its object reference changed, so an array rebuilt inline on every host render
275
+ * re-renders the menus beneath it; a module-level constant changes never, and a host that
276
+ * localizes its labels rebuilds the array exactly when the language changes.
277
+ */
278
+ interface StudioPlugin<TView = never> {
279
+ readonly contributions?: readonly StudioPluginContribution<TView>[] | undefined;
280
+ /** Vendor-namespaced and unique. See `studioPluginIdPattern` in `contracts/ids`. */
281
+ readonly id: string;
282
+ /**
283
+ * Tools to register on the host's bus for as long as this plugin is installed.
284
+ *
285
+ * The key is the tool's own `name`, as everywhere else in this package. Every name must be
286
+ * prefixed with the plugin's id (see `studioPluginToolPrefix` in `rules/ids`), which is what
287
+ * keeps a plugin out of the studio's own `studio.*` namespace and out of every other plugin's.
288
+ *
289
+ * A `run` chaining into one reaches for `ctx.bus.dispatchUnsafe` rather than `dispatch`: the
290
+ * typed member is keyed on the STUDIO's tool names and a plugin's verb is not one of them.
291
+ * Nothing is lost by it: the bus still parses the input against the tool's own Zod schema and
292
+ * gates it on its capability; what "unsafe" names is the compile-time key check, which cannot
293
+ * apply to a name the studio's own registry has never heard of.
294
+ *
295
+ * `ctx.bus` is the DISPATCH SURFACE and not the bus: `dispatch` and `dispatchUnsafe` are the
296
+ * only members on it. Registering, unregistering and observing belong to whoever built the bus,
297
+ * and a plugin that reaches for one of them gets a `TypeError` where the mistake is rather than
298
+ * a studio that quietly stops working.
299
+ *
300
+ * @default undefined, and the plugin registers no tool
301
+ */
302
+ readonly tools?: Readonly<Record<string, StudioTool>> | undefined;
303
+ }
304
+ /**
305
+ * StudioPluginToolSink is where a plugin's tools go, structurally.
306
+ *
307
+ * A `ToolBus` satisfies it with no adapter, which is the entire design: naming the class here
308
+ * would put the bus (the playbook, the Zod render, the confirmation machinery) in the graph of
309
+ * an entry whose job is to hold a list. Declared with METHOD syntax rather than arrow
310
+ * properties, which makes the parameters bivariant and is what lets the bus's own
311
+ * `register(tool: Tool<TCtx>)` satisfy `register(tool: StudioTool)`.
312
+ *
313
+ * `registered` is asked for one thing only (the names already taken), so its element type is
314
+ * the narrowest shape that answers: a return type is covariant, so the bus's richer `Tool` list
315
+ * satisfies it unchanged.
316
+ *
317
+ * `unregister` answers whether the name left the sink. A sink may refuse to release a name it
318
+ * holds, as a `ToolBus` does for a vendor segment it reserves: the tool then stays on it, and
319
+ * the registry keeps the name as its plugin's own, so the same declaration installs again and
320
+ * the same tool is met where it was left.
321
+ *
322
+ * After a release the sink refused, the registry asks `registered` whether the name is still
323
+ * listed, and asks again before it meets a kept tool: a name the sink does not list by then is
324
+ * registered as a new tool, and a fault thrown from that read refuses the plugin as one thrown
325
+ * from `register` does.
326
+ *
327
+ * How a kept name is read later follows from what `registered` listed when the sink kept it.
328
+ * Where it listed the very tool `register` was given, the kept tool is found by identity:
329
+ * another object under that name later is another tool, the one the sink's owner registered
330
+ * since. The name is then taken, so an install of the plugin is refused with `tool_name_taken`,
331
+ * and an attach offers the sink the plugin's tool and is refused in the sink's own words. Where
332
+ * it listed another object, as a sink that wraps what it holds does, on every call, the kept
333
+ * tool is found by name, and what stands there is taken for the tool handed over.
334
+ *
335
+ * The registry asks a name back only where it put the tool itself. A fault thrown by
336
+ * `unregister` or `registered` while a name is taken back interrupts nothing: the plugin leaves
337
+ * the registry, the subscribers are told, and the fault reaches the program as an uncaught error
338
+ * on a microtask.
339
+ */
340
+ interface StudioPluginToolSink {
341
+ register(tool: StudioTool): void;
342
+ registered(): readonly {
343
+ readonly name: string;
344
+ }[];
345
+ unregister(name: string): boolean;
346
+ }
347
+ /**
348
+ * StudioPluginRunOutcome is how a `run` ended, and it never includes "rejected".
349
+ *
350
+ * - `ran`: the verb ran to completion, promise and all.
351
+ * - `threw`: the verb throws or rejects, and the throw is caught here.
352
+ * - `gated`: its gate does not pass at the click. A menu can outlive the entitlement that
353
+ * opened it.
354
+ * - `inert`: the contribution is a `view` with no `run`, so there was nothing to call.
355
+ * - `unknown`: the plugin was uninstalled, or its declaration replaced, since the menu drew.
356
+ */
357
+ type StudioPluginRunOutcome = "gated" | "inert" | "ran" | "threw" | "unknown";
358
+ /**
359
+ * StudioPluginRunEvent is one `run`, reported to {@link StudioPluginEngine.observe}.
360
+ *
361
+ * The deliberate twin of `ToolDispatchEvent`: an outcome, a latency, and what it was about. A
362
+ * host already sending tool dispatches to their telemetry gets plugin actions in the same shape,
363
+ * which is what makes "which plugin is slow" answerable without a second pipeline.
364
+ */
365
+ interface StudioPluginRunEvent {
366
+ /** What was thrown, present only on `threw`. */
367
+ readonly error?: unknown;
368
+ readonly latencyMs: number;
369
+ readonly outcome: StudioPluginRunOutcome;
370
+ readonly pluginId: string;
371
+ readonly qualifiedId: string;
372
+ readonly slot: StudioPluginSlot;
373
+ }
374
+ /**
375
+ * StudioPluginObserver receives one event per `run`.
376
+ *
377
+ * One that throws changes no outcome and stops no observer after it: its fault reaches the
378
+ * program as an uncaught error on a microtask.
379
+ */
380
+ type StudioPluginObserver = (event: StudioPluginRunEvent) => void;
381
+ /**
382
+ * StudioPluginRefusalReporter is how a caller hears that ONE declaration was refused, without the
383
+ * refusal taking the rest of the batch with it.
384
+ *
385
+ * Supplied, a refused plugin is reported and skipped; omitted, the refusal throws. That is the
386
+ * split between the two callers this object has. A host reconciling a declared list is running
387
+ * inside somebody else's render tree, where a throw unmounts the studio over one malformed
388
+ * plugin: the studio being gone is a worse report than the item being missing. A direct caller
389
+ * asked for one install and has a `catch` to put it in.
390
+ *
391
+ * `unknown` rather than {@link StudioPluginError}, because a validation defect is not the only way
392
+ * a plugin is refused: the sink can throw on a tool name it already holds, and that value is the
393
+ * sink's. Narrow with `isStudioPluginError` to read the defect list when there is one. A reporter
394
+ * that itself throws stops nothing, as an observer that throws stops nothing: its fault reaches
395
+ * the program as an uncaught error on a microtask.
396
+ *
397
+ * `plugin` is always a declaration: an object, which a reporter reads `plugin.id` off with no
398
+ * narrowing of its own. A member of a declared list that is no object, a `null` off a manifest
399
+ * among them, is handed to no reporter. {@link StudioPluginEngine.sync} surfaces its refusal as
400
+ * an uncaught error on a microtask, as a fault of the list's author, and applies the rest of the
401
+ * list. A seed surfaces none: see {@link StudioPluginEngineOptions.onRefused}.
402
+ *
403
+ * A declared list is told of a refusal once for as long as it goes on stating it: the seed and
404
+ * every {@link StudioPluginEngine.sync} after it report a declaration refused again in the same
405
+ * words to nobody. A refusal is told again once the list stopped stating its declaration and
406
+ * states it again, and when the declaration is refused in other words.
407
+ *
408
+ * A list written inline is told once all the same, though its members are other objects each
409
+ * time it is stated: a declaration is found again by the id it states. A member that states
410
+ * none is found by what it is, a value that is no object by itself, any function as a function
411
+ * and any object as an object, and is told apart there by the words of its refusal.
412
+ *
413
+ * A plugin a sink refuses when it is attached is reported by
414
+ * {@link StudioPluginEngine.attachTools}. The reconciliation after it meets the declaration
415
+ * anew and may refuse it in other words, for the name the sink holds: a declared list that
416
+ * states the plugin is told of that refusal by the attach alone.
417
+ */
418
+ type StudioPluginRefusalReporter<TView = never> = (error: unknown, plugin: StudioPlugin<TView>) => void;
419
+ /**
420
+ * What a plugin engine is built with. Every member is optional: `new StudioPluginEngine()`
421
+ * is valid.
422
+ */
423
+ interface StudioPluginEngineOptions<TView = never> {
424
+ /**
425
+ * Plugins installed AT CONSTRUCTION, before anything can subscribe.
426
+ *
427
+ * It is what makes a plugin visible on the surface's FIRST paint rather than after the host's
428
+ * first effect, which matters for anything already open when the studio mounts, and is
429
+ * invisible in a test that flushes effects before asserting.
430
+ *
431
+ * These are DECLARED, in {@link StudioPluginEngine.sync}'s sense: this list is the same list
432
+ * a host then reconciles, so a later `sync([])` takes them back. An `install()` call is the
433
+ * other path and is never reconciled away.
434
+ *
435
+ * @default undefined, and nothing is installed at construction
436
+ */
437
+ readonly install?: readonly StudioPlugin<TView>[] | undefined;
438
+ /**
439
+ * Where a refused seed is reported. Omitted, the construction throws on the first refused seed
440
+ * and asks the sink for every tool a seed registered, so a sink that releases what it is asked
441
+ * for is left as it was found. A sink that keeps a name, as a `ToolBus` does for a vendor
442
+ * segment it reserves, still holds that tool.
443
+ *
444
+ * The constructor's half of {@link StudioPluginEngine.sync}'s reporter, and it is what lets a
445
+ * binding seed at construction (inside a render) without a malformed plugin taking the tree
446
+ * down with it.
447
+ *
448
+ * A seed that is no object is handed to no reporter and is skipped: nothing is queued from a
449
+ * construction, which a binding runs inside a render. The first
450
+ * {@link StudioPluginEngine.sync} of a list that still states the member surfaces its refusal.
451
+ */
452
+ readonly onRefused?: StudioPluginRefusalReporter<TView> | undefined;
453
+ /**
454
+ * Where a plugin's declared tools are registered. Omitted, they are validated and not registered.
455
+ *
456
+ * For a caller holding a sink already. A binding whose sink is rebuilt during the engine's
457
+ * lifetime (a React host whose bus is a memo) passes none and drives
458
+ * {@link StudioPluginEngine.attachTools} from an effect instead.
459
+ */
460
+ readonly tools?: StudioPluginToolSink | undefined;
461
+ }
462
+ /**
463
+ * StudioPluginEngine holds the installed plugins and the per-slot index a surface renders.
464
+ *
465
+ * Three properties carry the design, and each is a decision rather than an implementation
466
+ * detail:
467
+ *
468
+ * **1. `at(slot)` is materialised and sorted at MUTATION time, and is the same array between
469
+ * changes.** Only the slots a plugin actually touched are rebuilt; every empty one is the one
470
+ * shared frozen array. This is the `useSyncExternalStore` snapshot contract, and a `?? []` at
471
+ * the call site breaks it.
472
+ *
473
+ * **2. `at` does NOT resolve gates.** A gate reads the tool context, which changes underneath
474
+ * this object with nothing to notify it, so a gated snapshot could not be stable by
475
+ * construction. The split: `at(slot)` is the store, `availableStudioContributions(entries, ctx)`
476
+ * is the render-time filter.
477
+ *
478
+ * **3. `install` is ATOMIC**, unlike `ToolBus.registerAll`. Validate everything, register the
479
+ * tools with rollback, then mutate the index, which cannot fail. The bus is non-atomic because
480
+ * registration is a startup fact and a partial bus on a thrown startup is the correct outcome;
481
+ * an install is a LIFECYCLE operation on code the host may not have written, and it can happen
482
+ * at any point in a session.
483
+ *
484
+ * @example
485
+ * ```ts
486
+ * declare const bus: ToolBus<StudioToolContext>;
487
+ *
488
+ * const engine = new StudioPluginEngine({ tools: bus });
489
+ * engine.install({ contributions: [], id: "acme.huts" });
490
+ * ```
491
+ */
492
+ declare class StudioPluginEngine<TView = never> {
493
+ private readonly listeners;
494
+ private readonly observers;
495
+ /** The installed declarations, by id, in install order. */
496
+ private readonly plugins;
497
+ /** Each plugin's resolved entries, by id, in declaration order. */
498
+ private readonly entries;
499
+ /**
500
+ * Every tool name THIS registry owns, mapped to the plugin that brought it.
501
+ *
502
+ * Ownership rather than registration state, which is the difference that matters while there is
503
+ * no sink: {@link attachTools} is allowed to arrive late, and the names a plugin claimed have to
504
+ * be known before then, both to re-register them when a sink appears and to refuse a second
505
+ * plugin claiming the same one in the meantime.
506
+ */
507
+ private readonly toolNames;
508
+ /**
509
+ * The tools this registry put on the attached sink, by name: the ones it registered there and
510
+ * the ones it adopted where the sink had kept them.
511
+ *
512
+ * It is what {@link withdraw} reads before it asks the sink for a name back. A name that is
513
+ * not here was never this registry's on that sink, whoever holds it there, and is never asked
514
+ * for. Empty while no sink is attached.
515
+ */
516
+ private readonly placed;
517
+ /**
518
+ * The names each sink would not release, by sink: each with the plugin that brought it and
519
+ * the tool that plugin declared.
520
+ *
521
+ * A sink answers `unregister` with false for a name it keeps. The tool is then on the sink
522
+ * with no installed plugin behind it, and this map is what lets the plugin's own declaration
523
+ * meet that sink again, by a new install or by a new attach: the name reads as the plugin's
524
+ * and the held tool is adopted where it stands. An entry is a fact about its sink and stands
525
+ * while another sink is attached, so a registry that returns to a sink it left finds its
526
+ * tools there. Keyed weakly, so a sink that is gone keeps nothing alive.
527
+ *
528
+ * An entry is what the registry remembers, and the sink decides: its owner may take a kept
529
+ * name off it at any time. So a kept name is met again only while the sink still lists it,
530
+ * which {@link register} reads before it adopts, and an entry the sink no longer lists is
531
+ * forgotten there.
532
+ */
533
+ private readonly unreleased;
534
+ /**
535
+ * The ids a DECLARED list owns, which is the only thing {@link sync} may take back.
536
+ *
537
+ * The two install paths compose rather than competing, and this set is what makes that true. A
538
+ * host's `install` array is one authority and a settings screen calling `install()` is another;
539
+ * a reconciliation that dropped every id absent from its own list would silently uninstall the
540
+ * other's the moment the array's identity changed. Seeded by the constructor's `install`,
541
+ * because that is the same declared list the host then syncs.
542
+ */
543
+ private readonly declared;
544
+ /**
545
+ * What the declared list read last was told of, which holds each refusal to one report while
546
+ * the list goes on stating it. See {@link declaredListReporter}.
547
+ */
548
+ private told;
549
+ private index;
550
+ private sequence;
551
+ private revision;
552
+ /** The installed declarations as {@link installed} hands them back, or null when stale. */
553
+ private snapshot;
554
+ private sink;
555
+ constructor(options?: StudioPluginEngineOptions<TView>);
556
+ /**
557
+ * at returns the installed contributions for one slot, sorted, UNGATED.
558
+ *
559
+ * The same array between mutations, as the class docblock states. Cast-free, which is why the
560
+ * index is a mapped-type record rather than a `Map`: the one member every render touches is the
561
+ * one that should not need a cast.
562
+ */
563
+ at<TSlot extends StudioPluginSlot>(slot: TSlot): readonly StudioSlotEntry<TSlot, TView>[];
564
+ /**
565
+ * installed returns the declarations currently installed, in install order.
566
+ *
567
+ * Materialised once per change and handed back by reference until the next one, for the reason
568
+ * this file's opening comment gives about `at`: a getter shaped like a snapshot will be read as
569
+ * one (`useSyncExternalStore(engine.subscribe, engine.installed)` is the obvious thing for
570
+ * a consumer holding the engine to write), and a fresh array per call is an infinite render
571
+ * loop. An arrow PROPERTY for the same reason {@link subscribe} is one: it is passed detached.
572
+ */
573
+ readonly installed: () => readonly StudioPlugin<TView>[];
574
+ /**
575
+ * version is a counter that changes whenever any slot does.
576
+ *
577
+ * The scalar a `useSyncExternalStore` reads, so the binding subscribes once for the whole
578
+ * engine rather than once per slot, and the per-slot arrays stay plain reads inside the
579
+ * memo that filters them. An arrow PROPERTY for the same reason {@link subscribe} is one.
580
+ */
581
+ readonly version: () => number;
582
+ /**
583
+ * subscribe registers a listener called after any change, and returns the detach.
584
+ *
585
+ * An arrow PROPERTY rather than a method, and this is not style: `useSyncExternalStore` calls
586
+ * it detached from the object (`useSyncExternalStore(engine.subscribe, …)`), so a method
587
+ * would arrive with `this` unbound and throw on the first render that reads it.
588
+ */
589
+ readonly subscribe: (listener: () => void) => (() => void);
590
+ /** observe registers a per-`run` telemetry observer and returns the detach. */
591
+ observe(observer: StudioPluginObserver): () => void;
592
+ /**
593
+ * attachTools points the engine at a tool sink, moving every installed plugin's tools onto it.
594
+ *
595
+ * The sink is a LIFETIME rather than a construction fact, and this is the member that says so. An
596
+ * engine outlives the bus a binding built for it (a React host rebuilds the bus whenever its
597
+ * handlers, its grants or its confirm gate move), and an engine holding the one it was
598
+ * constructed with would keep registering a plugin's verbs onto a bus nothing dispatches
599
+ * through. It is also the only way an engine a CONSUMER constructed, and handed to the studio,
600
+ * ever reaches a bus at all.
601
+ *
602
+ * It is total in both directions: the outgoing sink gives every name back, the incoming one
603
+ * receives every installed plugin's tools, and `null` detaches. A sink that REFUSES a plugin's
604
+ * tools (a name it already holds) costs that plugin its install, reported through the refusal
605
+ * reporter, because a plugin whose contributions are on the menu and whose verbs are on no bus
606
+ * is half-installed in the one way nothing downstream can see.
607
+ *
608
+ * A detach moves tools and no ownership. The names stay their plugins' while no sink is
609
+ * attached, so a second plugin claiming one is refused when it is installed, and the tools go
610
+ * onto the sink that arrives next.
611
+ *
612
+ * With no reporter the first refusal is thrown, and only once every other plugin's tools are
613
+ * on the incoming sink and the subscribers have heard: a throw never leaves a later plugin on
614
+ * the menu with its verbs on no sink.
615
+ *
616
+ * With a reporter, a refused plugin a declared list states is told of here once: the
617
+ * reconciliation after this attach reports its refusal to nobody, in whatever words it reads
618
+ * there. See {@link StudioPluginRefusalReporter}.
619
+ *
620
+ * It does not notify on its own: moving tools between buses changes no slot. A refusal does
621
+ * change one, and that notifies.
622
+ *
623
+ * `onRefused` is a parameter here rather than a construction option, as it is on {@link sync},
624
+ * and deliberately: a reporter held as a FIELD would put `TView` in an input position on this
625
+ * class, which is what keeps `StudioPluginEngine<never>` (the engine a bare
626
+ * `new StudioPluginEngine()` builds) assignable to the bound one a React host takes.
627
+ */
628
+ attachTools(sink: StudioPluginToolSink | null, onRefused?: StudioPluginRefusalReporter<TView>): void;
629
+ /**
630
+ * install validates a plugin, registers its tools and indexes its contributions, or refuses
631
+ * the whole thing.
632
+ *
633
+ * It throws a {@link StudioPluginError} carrying EVERY defect, because an install a host asked
634
+ * for and did not get has to be loud: a plugin that silently failed to install is a menu item
635
+ * that is missing, which reads as the studio being broken rather than as the plugin being
636
+ * malformed. A sink that refuses one of the plugin's tools throws ITS OWN error through here
637
+ * unchanged, after the rollback, so a caller catching this catches both kinds.
638
+ *
639
+ * A value that is no declaration at all, `null` off a manifest for one, is refused the same
640
+ * way: a {@link StudioPluginError} whose defect says it states no id.
641
+ *
642
+ * What it installs is never reconciled away: {@link sync} owns the ids a DECLARED list brought,
643
+ * and this is the other path. A settings screen installing on demand and a host declaring an
644
+ * array compose rather than competing, until the same id appears in the declared list, which
645
+ * takes ownership of it.
646
+ *
647
+ * @throws StudioPluginError carrying every defect of a declaration the validation refuses.
648
+ * @throws whatever the tool sink throws for a tool it refuses, after the rollback.
649
+ */
650
+ install(plugin: StudioPlugin<TView>): void;
651
+ /**
652
+ * uninstall removes a plugin and everything it brought, reporting whether it was there.
653
+ *
654
+ * It takes back only the tool names THIS engine registered for THIS plugin (tracked as they
655
+ * are registered rather than recomputed from the declaration), which is what guarantees an
656
+ * uninstall can never take a `studio.*` verb, or another plugin's, down with it.
657
+ */
658
+ uninstall(pluginId: string): boolean;
659
+ /**
660
+ * sync reconciles the installed set against a declared list, and notifies at most once.
661
+ *
662
+ * It reconciles by ID for install and uninstall, and ADDITIONALLY replaces a stored
663
+ * declaration when the plugin's object reference changed: rebuilding the touched slots, and
664
+ * re-registering bus tools only when the tool-name list actually differs.
665
+ *
666
+ * Replacing on reference is the one place this departs from a pure by-id reconciliation, and
667
+ * the reason is a real trap: a host that changes language and passes new labels under the same
668
+ * ids would otherwise see nothing change. It is safe HERE because the notification flows
669
+ * strictly DOWN (every subscriber is a menu below the host, and a menu re-rendering never
670
+ * re-renders the host), so there is no cycle to fall into.
671
+ *
672
+ * What it costs is a host who writes the array inline: the menus beneath them re-render
673
+ * whenever the host does. Hoist the declarations to module scope, which is the natural way to
674
+ * write them, and nothing churns.
675
+ *
676
+ * **It removes only what a DECLARED list installed.** An id that arrived through
677
+ * {@link install} (a settings screen, a marketplace loading one on demand) is another
678
+ * authority's, and a reconciliation that dropped it would make the two paths compete for the
679
+ * engine rather than compose in it. A declaration naming that id takes ownership of it from
680
+ * then on.
681
+ *
682
+ * `onRefused` decides what a malformed declaration costs. Supplied, it is reported and skipped
683
+ * and every other declaration still lands; omitted, the first refusal is thrown once every
684
+ * declaration that could be applied has been and the subscribers have heard. A binding
685
+ * reconciling inside a render tree passes one: see {@link StudioPluginRefusalReporter}.
686
+ *
687
+ * A member of the list that is no object is one more malformed declaration: refused where it
688
+ * stands, with the defect of a declaration that states no id. With no reporter it is thrown as
689
+ * any refusal is. With one it is handed to nobody, since a reporter is handed a declaration:
690
+ * its refusal is surfaced on a microtask. Subscribers hear of what the list applied whatever
691
+ * leaves this call.
692
+ *
693
+ * A refusal is reported, or surfaced, once while the list goes on stating it, the seed's list
694
+ * included and a list written inline as well: see {@link StudioPluginRefusalReporter}. With no
695
+ * reporter every call throws its first refusal, since each call is one its caller asked for.
696
+ */
697
+ sync(plugins: readonly StudioPlugin<TView>[], onRefused?: StudioPluginRefusalReporter<TView>): void;
698
+ /**
699
+ * reconcile brings one declaration of a declared list in under its id: installed where the id
700
+ * is new, replaced where its reference changed, and left where it is the one installed.
701
+ *
702
+ * @returns Whether a slot may have changed: a plugin was installed, replaced, or lost to a
703
+ * sink that refused its replacement.
704
+ */
705
+ private reconcile;
706
+ /**
707
+ * run invokes a contribution's verb and reports how it ended. It ALWAYS resolves.
708
+ *
709
+ * It re-checks two things the caller cannot, because a menu can outlive both: that the entry is
710
+ * still installed (a plugin uninstalled, or its declaration replaced, while the dropdown was
711
+ * open) and that its gate still passes (an entitlement that lapsed mid-session). Neither is a
712
+ * throw: a stale click is a no-op with a reason, not a crash.
713
+ *
714
+ * `onError` is how the thrown value reaches a caller that has to report it. The outcome alone
715
+ * cannot carry one, and an observer is registered per ENGINE rather than per call, so a
716
+ * binding wanting to hand the failure to a host seam beside the contribution it came from
717
+ * passes this. It is called at most once, before the promise resolves. An `onError` that itself
718
+ * throws leaves the outcome `threw`, and its fault is surfaced on a microtask.
719
+ */
720
+ run<TSlot extends StudioPluginSlot>(entry: StudioSlotEntry<TSlot, TView>, ctx: StudioToolContext, target: StudioPluginTarget<TSlot>, onError?: (error: unknown) => void): Promise<StudioPluginRunOutcome>;
721
+ /**
722
+ * dispose uninstalls everything and drops every listener and observer.
723
+ *
724
+ * It leaves an EMPTY engine rather than a poisoned one (installing into it afterwards works),
725
+ * because the alternative breaks React's StrictMode, where an effect's cleanup runs between
726
+ * two runs of the effect itself.
727
+ *
728
+ * An empty engine was told of nothing: a list declared after it is told of its refusals as a
729
+ * list stated for the first time is.
730
+ */
731
+ dispose(): void;
732
+ /**
733
+ * adopt is install without the notification: validate, register with rollback, then index.
734
+ *
735
+ * The order is the atomicity. Validation reads and changes nothing; tool registration is the
736
+ * only step that can fail, and it unwinds its own partial work; indexing is pure mutation of
737
+ * state this object owns and cannot throw. So a refused install leaves the bus and every slot
738
+ * exactly as they were.
739
+ *
740
+ * A sink that keeps a name it is asked for is the one exception, and {@link register} states
741
+ * what becomes of that name.
742
+ */
743
+ private adopt;
744
+ /**
745
+ * register puts one plugin's tools on a sink, unwinding its own partial work if one is refused.
746
+ *
747
+ * The only step of an adoption that can fail, which is why it is the only one with a rollback
748
+ * (see {@link install}'s note on atomicity). `instanceof Error` here is the narrow question "is
749
+ * this already a throwable with a message", not the class-identity check `isStudioPluginError`
750
+ * exists to avoid: the value is the sink's, and wrapping one that is already an error would
751
+ * bury the bus's own message one `cause` deeper.
752
+ *
753
+ * The rollback asks the sink for each name back through {@link withdraw}, as an uninstall
754
+ * does. A name the sink keeps is remembered as the plugin's own, so the declaration put right
755
+ * meets its tool where the refusal left it.
756
+ *
757
+ * A name the sink kept from the plugin's earlier install ({@link unreleased}) is adopted
758
+ * where it stands, and only while the sink still lists it: the sink is read once, when the
759
+ * first such name is met. A kept name the sink does not list then is forgotten and its tool is
760
+ * registered as any other. So is a kept name under which the sink lists another tool, where
761
+ * the sink lists what it is given ({@link isStillKept}): its owner registered that tool since,
762
+ * the sink is offered the plugin's and answers for the name itself. A sink that throws from
763
+ * that read refuses the plugin, as one that throws from `register` does.
764
+ */
765
+ private register;
766
+ /**
767
+ * take is {@link adopt} with the refusal routed rather than thrown. Reports whether it landed.
768
+ *
769
+ * The one place the two postures meet: with a reporter a refusal is one plugin's problem, and
770
+ * without one it is the caller's. Everything above that wants "apply what you can" goes through
771
+ * here, and the atomicity `adopt` guarantees is untouched either way.
772
+ */
773
+ private take;
774
+ /** report hands a refusal to the reporter, or rethrows it when there is none. */
775
+ private report;
776
+ /** drop is uninstall without the notification. Reports whether the plugin was there. */
777
+ private drop;
778
+ /**
779
+ * withdraw asks a sink for one name back, and remembers a name the sink would not give up.
780
+ *
781
+ * Only a name this registry put there ({@link placed}) is asked for: a name the sink holds
782
+ * for somebody else was never this registry's to take back.
783
+ *
784
+ * `unregister` answers false for a name the sink never held and for one it refuses to release,
785
+ * so the sink is asked whether it still lists the name. A tool left there stays in service
786
+ * with no installed plugin behind it, and is remembered with the tool this registry handed
787
+ * over: see {@link unreleased}. The sink is read by name, since it may hand back another object
788
+ * than it was given.
789
+ *
790
+ * A fault the sink throws here is surfaced on a microtask and leaves through no caller: an
791
+ * uninstall, a reconciliation and a move between sinks each finish what they were doing.
792
+ */
793
+ private withdraw;
794
+ /**
795
+ * rebuild re-materialises exactly the slots named, and nothing else.
796
+ *
797
+ * Only the touched ones, which is what makes "installing a `segment.menu` plugin leaves
798
+ * `at('map.controls')` referentially identical" true: the property a memo keyed on a slot's
799
+ * array depends on.
800
+ */
801
+ private rebuild;
802
+ /**
803
+ * setSlot writes one slot of the index.
804
+ *
805
+ * The second localized cast, and it is the mapped type's: writing through a key whose type is
806
+ * the whole union makes TypeScript demand a value assignable to EVERY member's value type at
807
+ * once, which nothing is. Moving the index to a `Map` would trade this cast for one in `at`,
808
+ * the wrong side of the trade, since `at` is the member every render touches.
809
+ */
810
+ private setSlot;
811
+ /**
812
+ * The collision scope a declaration of `pluginId` is validated against: the ids installed, and
813
+ * every tool name already taken.
814
+ *
815
+ * `replacing` takes the installed plugin of that id back out of it: its id and the names it
816
+ * brought, including the ones the sink is holding for it. That is what lets a replacement be
817
+ * validated while its incumbent is still installed. Without it every re-declaration under an
818
+ * unchanged id would read as `plugin_id_taken` plus one `tool_name_taken` per verb.
819
+ *
820
+ * A name the sink kept from an earlier install of the same id is the plugin's own either way,
821
+ * and taken for every other plugin: see {@link unreleased}. It is the plugin's own only while
822
+ * what the sink lists under it is still the tool it kept ({@link isStillKept}): a name its
823
+ * owner gave another tool since is taken, for this plugin as for any other.
824
+ */
825
+ private scope;
826
+ /**
827
+ * notify advances the version FIRST, so a listener reading `at` already sees the new list.
828
+ *
829
+ * Every listener is told, by the one rule the package's engines share (`notifyListeners`). A
830
+ * listener that throws skips no listener after it and never leaves through the `install` or
831
+ * `sync` that had already changed the state, which would break, from the outside, the
832
+ * atomicity this class guarantees. Its fault is surfaced on a microtask.
833
+ */
834
+ private notify;
835
+ /** emit reports one run to every observer, by the rule {@link notify} follows. */
836
+ private emit;
837
+ }
838
+ export { StudioPluginWaypointMenuTarget as C, StudioPluginTarget as S, studioPluginSlotSchema as T, StudioPluginMapControlsTarget as _, StudioPluginRunEvent as a, StudioPluginSlot as b, StudioPlugin as c, StudioPluginGate as d, StudioPluginSubject as f, StudioPluginMapContextMenuTarget as g, StudioPluginItineraryMenuTarget as h, StudioPluginRefusalReporter as i, StudioPluginContribution as l, StudioSlotEntry as m, StudioPluginEngineOptions as n, StudioPluginRunOutcome as o, StudioSlotContribution as p, StudioPluginObserver as r, StudioPluginToolSink as s, StudioPluginEngine as t, StudioPluginEntry as u, StudioPluginProfileTarget as v, StudioPluginZoneMenuTarget as w, StudioPluginSlotTargets as x, StudioPluginSegmentMenuTarget as y };
839
+ //# sourceMappingURL=chunk-cVXLsZfL.d.ts.map