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