@theoremjs/studio 0.3.4-next.735.g8d504c6 → 0.3.4-next.747.g0909061

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 (159) hide show
  1. package/installed.mjs +10 -1
  2. package/label-areas.d.ts +5 -0
  3. package/label-areas.js +6 -0
  4. package/package.json +19 -4
  5. package/page/assets/Badge-D78MvW22.js +1 -0
  6. package/page/assets/{BottomSheet-Dbh6A5Vl.js → BottomSheet-CS905Wxu.js} +1 -1
  7. package/page/assets/Card-D_40unTk.js +1 -0
  8. package/page/assets/CheckboxInput-MMjt4mDv.js +2 -0
  9. package/page/assets/CodeBlock-DzXH_9DF.js +3 -0
  10. package/page/assets/CollapsibleGroup-D1qiJpkR.js +1 -0
  11. package/page/assets/ConsoleFrame-BoayVeCq.js +3 -0
  12. package/page/assets/DateInput-BvG86MuZ.js +1 -0
  13. package/page/assets/{Dialog-Sd04KQS2.js → Dialog-DUNBjHOI.js} +1 -1
  14. package/page/assets/{HoverCard-DMyWUvwP.js → HoverCard-DMHc1Gh1.js} +1 -1
  15. package/page/assets/Icon-3c9WmPTH.js +3 -0
  16. package/page/assets/{IconButton-DVUFx-8p.js → IconButton-BeI1pXEZ.js} +1 -1
  17. package/page/assets/IconFilter-BO98ezum.js +1 -0
  18. package/page/assets/IconHistory-VvDVN7WG.js +1 -0
  19. package/page/assets/{ItemSwipeLayer-Ckn4X6h9.js → ItemSwipeLayer-BzVkYf4E.js} +1 -1
  20. package/page/assets/{ListItem-QF7KFt0h.js → ListItem-MWWVygeh.js} +1 -1
  21. package/page/assets/MenuBottomSheet-D5tp1i_-.js +1 -0
  22. package/page/assets/MenuBottomSheetActionList-CYZ56fty.js +1 -0
  23. package/page/assets/OverflowList-CoxIfkMv.js +1 -0
  24. package/page/assets/SchemaFields-tYFYYahf.js +1 -0
  25. package/page/assets/ScrollableArea-CZpbLBeP.js +1 -0
  26. package/page/assets/SidePanel-Bp_RI52Y.js +2 -0
  27. package/page/assets/{Text-BOqCfzZC.js → Text-B74VhVA7.js} +2 -2
  28. package/page/assets/TextInput-D1GkClqk.js +1 -0
  29. package/page/assets/{TimestampHoverCard-CDCVpEWM.js → TimestampHoverCard-BNDnoAyp.js} +1 -1
  30. package/page/assets/ToolResultCharts-BWfWMqlR.js +1 -0
  31. package/page/assets/Toolbar-DHVYq2_l.js +1 -0
  32. package/page/assets/{Tooltip-BWs5DLrM.js → Tooltip-DrSpWxD8.js} +1 -1
  33. package/page/assets/TraceInspector-CHfNL5A-.js +1 -0
  34. package/page/assets/{TraceOverview-DqCofwm4.js → TraceOverview-D_hfr4c-.js} +4 -4
  35. package/page/assets/{_virtual_studio-type-sources-nXG6uotl.js → _virtual_studio-type-sources-Cc4WAdgD.js} +50 -17
  36. package/page/assets/browser-connection-159CdeHX.js +1 -0
  37. package/page/assets/browser-engine-CEC4HFG-.js +16 -0
  38. package/page/assets/browser-transport-TSTeQ-sR.js +45 -0
  39. package/page/assets/compile-iB2CAmRL.js +2 -0
  40. package/page/assets/{container.stylex-BmOi-8DQ.js → container.stylex-C2nFBhUj.js} +1 -1
  41. package/page/assets/{embedding-space-view-CN0VHXXH.js → embedding-space-view-JuXKDaFw.js} +1 -1
  42. package/page/assets/encode-files-CeZxxjYd.js +1 -0
  43. package/page/assets/{export-agent-BrN5vTz2.js → export-agent-BgFM3Bl8.js} +3 -3
  44. package/page/assets/{fieldParts-CoOpDoax.js → fieldParts-Dtp1EoJQ.js} +1 -1
  45. package/page/assets/{focusOutline.stylex-BT0kfa4t.js → focusOutline.stylex-B9nWSXsG.js} +1 -1
  46. package/page/assets/guardrail-tester-C4z8FjFN.js +9 -0
  47. package/page/assets/highlightRanges-yrVxbmkN.js +51 -0
  48. package/page/assets/index-DakRjE8R.css +1 -0
  49. package/page/assets/index-nkhNFTq4.js +149 -0
  50. package/page/assets/{labels-provider-uONlWExD.js → labels-provider-Dc-AJqPH.js} +2 -2
  51. package/page/assets/{live-messages-_FDpxQYF.js → live-messages-Bqz1Qeph.js} +1 -1
  52. package/page/assets/menuItemRoles-Bod0knkp.js +1 -0
  53. package/page/assets/prompt-row-B1r2Wl_P.js +71 -0
  54. package/page/assets/prompt-row-beoYzntJ.css +1 -0
  55. package/page/assets/reader-Duft1Xr7.js +5 -0
  56. package/page/assets/registry-DP0ArymS.js +1 -0
  57. package/page/assets/schema-Cv4HAfBT.js +3 -0
  58. package/page/assets/shaped-data-DCfLI4gb.js +21 -0
  59. package/page/assets/{stub-J0Ig6FyA.js → stub-REBz-ZC7.js} +1 -1
  60. package/page/assets/studio-code-pane-5YnNxTk_.js +10 -0
  61. package/page/assets/{studio-console-BG1WmM3M.js → studio-console-Dwbc0RtX.js} +1 -1
  62. package/page/assets/studio-decision-CQcvYjzv.js +1 -0
  63. package/page/assets/studio-embedding-CwwCUKc9.js +2 -0
  64. package/page/assets/studio-host-console-CIh1ojgr.js +2 -0
  65. package/page/assets/studio-labels-APWMRX3W.js +3 -0
  66. package/page/assets/studio-live-BtCt43TJ.js +5 -0
  67. package/page/assets/studio-map-SLIQYxJF.js +1 -0
  68. package/page/assets/studio-trace-replay-lHRB3Hb-.js +3 -0
  69. package/page/assets/{studio-type-checker-CF7Re1aY.js → studio-type-checker-JZuu4iVI.js} +1 -1
  70. package/page/assets/{tokens.stylex-DkHf0P9C.js → tokens.stylex-BpCwr7Mf.js} +1 -1
  71. package/page/assets/tool-schema-BwaPiLtT.js +17 -0
  72. package/page/assets/{trace-patterns-D6TbkLLr.js → trace-patterns-D5Rcl0G4.js} +1 -1
  73. package/page/assets/{trace-record-YSvR6YMe.js → trace-record--uEnDt_D.js} +1 -1
  74. package/page/assets/tree-CL4ETBd5.js +3 -0
  75. package/page/assets/{turn-client-Xn70kpoZ.js → turn-client-CqKkEDLt.js} +2 -2
  76. package/page/assets/types-BDx4pnrt.js +1 -0
  77. package/page/assets/use-one-call-BqUlgQIr.js +1 -0
  78. package/page/assets/use-second-ticker-DhbZ0Soz.js +1 -0
  79. package/page/assets/{useAnnounce-DTSHZvjg.js → useAnnounce-DOkF3CS1.js} +1 -1
  80. package/page/assets/useAnnounceRenderedText-aqUr1P16.js +1 -0
  81. package/page/assets/{useClipboard-CbN9bb4J.js → useClipboard-BC4cMFBa.js} +1 -1
  82. package/page/assets/useKeyboardHint-BBkDGjRh.js +1 -0
  83. package/page/assets/useLocale-D8GRz3lz.js +1 -0
  84. package/page/assets/useMenuDrillIn-tTYG6Wzi.js +1 -0
  85. package/page/assets/{useMenuPress-DLG1QOiE.js → useMenuPress-DPpqa6F7.js} +1 -1
  86. package/page/assets/{useResolvedRequired-DbsOcDqy.js → useResolvedRequired-68GOSl0j.js} +1 -1
  87. package/page/assets/{useTooltip-c097gL_-.js → useTooltip-BaCjTHk-.js} +1 -1
  88. package/page/assets/{workspace-Bfoebvk4.js → workspace-B6d08n7C.js} +1 -1
  89. package/page/index.html +53 -42
  90. package/prompt-doc.d.ts +24 -0
  91. package/prompt-doc.js +251 -0
  92. package/read-source.js +25 -33
  93. package/section-notes.d.ts +16 -2
  94. package/section-notes.js +16 -2
  95. package/server/runs.d.ts +17 -0
  96. package/server/runs.js +73 -0
  97. package/server/save-session.d.ts +4 -0
  98. package/server/save-session.js +10 -6
  99. package/server/serve.js +41 -8
  100. package/ui/built/theme.css +1 -1
  101. package/ui/built/theorem-studio.js +1 -1
  102. package/ui/inspector-context.d.ts +2 -0
  103. package/ui/inspector-context.js +2 -0
  104. package/ui/inspector.d.ts +44 -2
  105. package/ui/inspector.js +20 -9
  106. package/ui/profile-editor.js +47 -40
  107. package/ui/prompt-editor.css +112 -0
  108. package/ui/prompt-editor.d.ts +16 -0
  109. package/ui/prompt-editor.js +315 -0
  110. package/ui/prompt-line-node.d.ts +29 -0
  111. package/ui/prompt-line-node.js +112 -0
  112. package/ui/prompt-row.d.ts +9 -0
  113. package/ui/prompt-row.js +25 -0
  114. package/ui/provider-editor.js +2 -1
  115. package/ui/studio-compare.js +13 -6
  116. package/ui/studio-save.js +3 -3
  117. package/ui/studio-screen.js +18 -16
  118. package/ui/studio-theme.d.ts +1 -1
  119. package/ui/studio-theme.js +2 -0
  120. package/ui/studio-trace-replay.js +5 -5
  121. package/ui/studio.css +42 -14
  122. package/page/assets/Banner-BXQ3eMGX.js +0 -3
  123. package/page/assets/Card-DruykyeB.js +0 -1
  124. package/page/assets/CheckboxInput-CFZ_Wq8-.js +0 -2
  125. package/page/assets/CodeBlock-CfVOtDeO.js +0 -52
  126. package/page/assets/CollapsibleGroup-BsIYDnJR.js +0 -1
  127. package/page/assets/ConsoleFrame-DDSgPsZH.js +0 -3
  128. package/page/assets/DateInput-CalwZl6a.js +0 -1
  129. package/page/assets/Icon-BqkS-pIq.js +0 -3
  130. package/page/assets/IconEye-BB5aY-wQ.js +0 -1
  131. package/page/assets/MenuBottomSheet-CGBoKe8D.js +0 -1
  132. package/page/assets/SchemaFields-D7ClAIou.js +0 -1
  133. package/page/assets/ScrollableArea-ChTx-OVZ.js +0 -1
  134. package/page/assets/SegmentedControlItem-CZs-ycSA.js +0 -1
  135. package/page/assets/SidePanel-DEd3R1Q3.js +0 -2
  136. package/page/assets/ToolResultCharts-DiEXUaNn.js +0 -1
  137. package/page/assets/TraceInspector-CaNKb5tj.js +0 -1
  138. package/page/assets/browser-connection-Dm_C2k-h.js +0 -3
  139. package/page/assets/browser-engine-BfnMGcT2.js +0 -16
  140. package/page/assets/browser-transport-9tBHJSxP.js +0 -45
  141. package/page/assets/crypto-DbeKCGAB.js +0 -1
  142. package/page/assets/encode-files-BdORDAbw.js +0 -1
  143. package/page/assets/guardrail-tester-BrSKPdyb.js +0 -9
  144. package/page/assets/index-Boxd3JUw.js +0 -149
  145. package/page/assets/index-C9rhrCGT.css +0 -1
  146. package/page/assets/reader-CHvIE7jW.js +0 -5
  147. package/page/assets/shaped-data-B5yHkAzM.js +0 -21
  148. package/page/assets/studio-code-pane-B4bfZLeO.js +0 -10
  149. package/page/assets/studio-decision-Ck3RM4xV.js +0 -1
  150. package/page/assets/studio-embedding-pvHODyby.js +0 -2
  151. package/page/assets/studio-host-console-DAv2ocEl.js +0 -2
  152. package/page/assets/studio-labels-DLm-OIlS.js +0 -3
  153. package/page/assets/studio-live-BBVkUupj.js +0 -5
  154. package/page/assets/studio-map-DE4o1Dw6.js +0 -1
  155. package/page/assets/studio-trace-replay-DMnAw57P.js +0 -3
  156. package/page/assets/tool-schema-CAhMfN4z.js +0 -17
  157. package/page/assets/tree-sm5ci1wZ.js +0 -3
  158. package/page/assets/use-one-call-DJQhFDfz.js +0 -1
  159. package/page/assets/use-second-ticker-B_tRvZF_.js +0 -1
package/server/runs.js ADDED
@@ -0,0 +1,73 @@
1
+ /**
2
+ * The runs that are going on in the project's loads: turns and voice calls, while the page is
3
+ * joined to them. A load holds its runs in memory, so it is not replaced under one.
4
+ *
5
+ * @module
6
+ */
7
+ /** Keeps count of the runs. `idle` is called each time the last one ends. */
8
+ export function createRuns(idle) {
9
+ let open = 0;
10
+ const waiting = [];
11
+ const ended = () => {
12
+ // invariant: a waiter runs in the tick the count reaches none, so no run starts between.
13
+ while (open === 0 && waiting.length)
14
+ waiting.shift()?.();
15
+ if (open === 0)
16
+ idle();
17
+ };
18
+ return {
19
+ begin: () => {
20
+ open += 1;
21
+ let over = false;
22
+ return () => {
23
+ if (over)
24
+ return;
25
+ over = true;
26
+ open -= 1;
27
+ if (open === 0)
28
+ ended();
29
+ };
30
+ },
31
+ busy: () => open > 0,
32
+ whenIdle: (then) => {
33
+ if (open === 0)
34
+ then();
35
+ else
36
+ waiting.push(then);
37
+ },
38
+ };
39
+ }
40
+ /** `response` as it was, with `end` called when its body is read to the end, fails or is dropped. */
41
+ export function untilRead(response, end) {
42
+ if (!response.body) {
43
+ end();
44
+ return response;
45
+ }
46
+ const reader = response.body.getReader();
47
+ const body = new ReadableStream({
48
+ async pull(controller) {
49
+ try {
50
+ const { done, value } = await reader.read();
51
+ if (done) {
52
+ end();
53
+ controller.close();
54
+ }
55
+ else
56
+ controller.enqueue(value);
57
+ }
58
+ catch (error) {
59
+ end();
60
+ controller.error(error);
61
+ }
62
+ },
63
+ cancel(reason) {
64
+ end();
65
+ return reader.cancel(reason);
66
+ },
67
+ });
68
+ return new Response(body, {
69
+ status: response.status,
70
+ statusText: response.statusText,
71
+ headers: response.headers,
72
+ });
73
+ }
@@ -32,6 +32,10 @@ export interface SaveHost<Loaded> {
32
32
  /** Loads the project from disk. Throws what it printed when it does not start. */
33
33
  load(): Promise<Loaded>;
34
34
  stop(loaded: Loaded): Promise<void>;
35
+ /** Whether a load is running a turn or a call now. */
36
+ running(): boolean;
37
+ /** Calls `swap` when no load is running anything. Nothing starts between that and the swap. */
38
+ whenQuiet(swap: () => void): Promise<void>;
35
39
  /** The workspace a load opened as. */
36
40
  opened(loaded: Loaded): StudioWorkspace;
37
41
  /** The profiles a load registered that the studio could not open, by id. They are not unregistered. */
@@ -272,10 +272,13 @@ export function createSaveSession(host, first) {
272
272
  await host.stop(next);
273
273
  return refusal('differs', differs);
274
274
  }
275
- const old = project;
276
- project = next;
277
- loadedFrom = from;
278
- unloaded = undefined;
275
+ let old = project;
276
+ await host.whenQuiet(() => {
277
+ old = project;
278
+ project = next;
279
+ loadedFrom = from;
280
+ unloaded = undefined;
281
+ });
279
282
  await host.stop(old);
280
283
  return undefined;
281
284
  };
@@ -284,8 +287,9 @@ export function createSaveSession(host, first) {
284
287
  const now = heldIn(files);
285
288
  if (now === loadedFrom)
286
289
  unloaded = undefined;
287
- // Files that did not load are not tried again until they change.
288
- else if (unloaded?.from !== now) {
290
+ // Files that did not load are not tried again until they change. A running turn keeps its
291
+ // load: the page is told of the files again when the turn ends.
292
+ else if (unloaded?.from !== now && !host.running()) {
289
293
  said?.({ again: true });
290
294
  const refused = await reload(() => [], now);
291
295
  if (refused)
package/server/serve.js CHANGED
@@ -32,6 +32,7 @@ import { corsHeaders, isForeign, json, KEYS_PATH, STUDIO_BASE, } from "./handler
32
32
  import { answerOpen, chosenEditor, defaultEditor } from "./open-editor.js";
33
33
  import { PROJECT_READY } from "./project.js";
34
34
  import { entryOf, isInside } from "./project-source.js";
35
+ import { createRuns, untilRead } from "./runs.js";
35
36
  import { answerSave, createSaveSession, isSaveRequest } from "./save-session.js";
36
37
  import { createWatchFeed, watchFiles } from "./watch.js";
37
38
  function flag(name, fallback) {
@@ -185,6 +186,8 @@ catch (error) {
185
186
  console.error(error instanceof Error ? error.message : error);
186
187
  Deno.exit(1);
187
188
  }
189
+ /** What the loads are running. When it ends the page hears of the files it was not told of. */
190
+ const runs = createRuns(() => void tellChanged());
188
191
  /** The load that runs the builder's unsaved edits, while the page compares it with the files. */
189
192
  const edited = createEditedSession({
190
193
  load: loadProject,
@@ -202,12 +205,18 @@ const session = createSaveSession({
202
205
  },
203
206
  remove: (path) => Deno.removeSync(path),
204
207
  typeChecks,
205
- // The files changed: the edited load lies over files that are gone.
206
- load: async () => {
208
+ load: loadProject,
209
+ stop,
210
+ running: runs.busy,
211
+ // The files changed: the edited load lies over files that are gone, once its runs are done.
212
+ whenQuiet: async (swap) => {
213
+ await new Promise((quiet) => runs.whenIdle(quiet));
207
214
  await edited.close();
208
- return loadProject();
215
+ await new Promise((swapped) => runs.whenIdle(() => {
216
+ swap();
217
+ swapped();
218
+ }));
209
219
  },
210
- stop,
211
220
  opened: (loaded) => loaded.description.workspace,
212
221
  unopened: (loaded) => loaded.description.problems.map((problem) => problem.profile),
213
222
  }, first);
@@ -216,13 +225,26 @@ async function forward(request, loaded = session.project(), path) {
216
225
  const url = new URL(request.url);
217
226
  const to = path ?? url.pathname;
218
227
  if (request.headers.get('upgrade')?.toLowerCase() === 'websocket') {
219
- return forwardSocket(request, `${loaded.origin}${to}${url.search}`);
228
+ return forwardSocket(request, `${loaded.origin}${to}${url.search}`, runs.begin());
220
229
  }
230
+ const target = `${loaded.origin}${to}${url.search}`;
231
+ // invariant: counted before anything is awaited, in the tick that picked `loaded`.
232
+ if (request.method !== 'POST' || !to.startsWith(PROFILES))
233
+ return passOn(request, target, to);
234
+ const ended = runs.begin();
235
+ const answer = await passOn(request, target, to).catch((error) => {
236
+ ended();
237
+ throw error;
238
+ });
239
+ return untilRead(answer, ended);
240
+ }
241
+ /** The project's answer to a request, watched when it is a run. */
242
+ async function passOn(request, target, to) {
221
243
  const headers = new Headers(request.headers);
222
244
  headers.delete('host');
223
245
  let response;
224
246
  try {
225
- response = await fetch(`${loaded.origin}${to}${url.search}`, {
247
+ response = await fetch(target, {
226
248
  method: request.method,
227
249
  headers,
228
250
  body: await bodyOf(request),
@@ -254,13 +276,14 @@ function watchedRun(method, to, response) {
254
276
  * Joins the page's socket to the same path of the project: a voice call. What the page sends
255
277
  * before the project's side opens is held, because a call opens with the page's first message.
256
278
  */
257
- function forwardSocket(request, to) {
279
+ function forwardSocket(request, to, ended) {
258
280
  const { socket: page, response } = Deno.upgradeWebSocket(request);
259
281
  const project = new WebSocket(to.replace(/^http/, 'ws'));
260
282
  page.binaryType = 'arraybuffer';
261
283
  project.binaryType = 'arraybuffer';
262
284
  const held = [];
263
285
  const shut = (other) => () => {
286
+ ended();
264
287
  if (other.readyState === WebSocket.OPEN || other.readyState === WebSocket.CONNECTING)
265
288
  other.close();
266
289
  };
@@ -422,11 +445,21 @@ function openedSaying(request) {
422
445
  }
423
446
  /** Tells the page when the builder's editor writes a file the setup reads, unless `--no-watch` says not to. */
424
447
  const feed = Deno.args.includes('--no-watch') ? undefined : createWatchFeed();
448
+ /** Tells the page which files hold something the load that answers was not read from. */
449
+ async function tellChanged() {
450
+ const files = await session.changed().catch(() => []);
451
+ if (files.length && !runs.busy())
452
+ feed?.tell(files);
453
+ }
425
454
  if (feed) {
426
455
  watchFiles({
427
456
  files: () => session.watched(),
428
457
  changed: () => session.changed(),
429
- tell: feed.tell,
458
+ // why: the page would read files the running load was not read from; the end of the run tells it.
459
+ tell: (files) => {
460
+ if (!runs.busy())
461
+ feed.tell(files);
462
+ },
430
463
  watch: (folders) => Deno.watchFs(folders, { recursive: false }),
431
464
  });
432
465
  }
@@ -180,7 +180,7 @@
180
180
  --color-accent-muted: light-dark(#f1f1f1, #262626);
181
181
  --color-neutral: light-dark(#0000000F, #ffffff1A);
182
182
  --color-overlay: light-dark(#00000080, #000000CC);
183
- --color-overlay-hover: light-dark(#0000000D, #ffffff0D);
183
+ --color-overlay-hover: light-dark(#05365914, #FFFFFF14);
184
184
  --color-overlay-pressed: light-dark(#0000001A, #ffffff1A);
185
185
  --color-text-primary: light-dark(#000000, #ffffff);
186
186
  --color-text-secondary: light-dark(#474747, #9e9e9e);
@@ -114,7 +114,7 @@ export const theoremStudioTheme = {
114
114
  "--color-accent-muted": "light-dark(#f1f1f1, #262626)",
115
115
  "--color-neutral": "light-dark(#0000000F, #ffffff1A)",
116
116
  "--color-overlay": "light-dark(#00000080, #000000CC)",
117
- "--color-overlay-hover": "light-dark(#0000000D, #ffffff0D)",
117
+ "--color-overlay-hover": "light-dark(#05365914, #FFFFFF14)",
118
118
  "--color-overlay-pressed": "light-dark(#0000001A, #ffffff1A)",
119
119
  "--color-text-primary": "light-dark(#000000, #ffffff)",
120
120
  "--color-text-secondary": "light-dark(#474747, #9e9e9e)",
@@ -91,6 +91,8 @@ export interface WorkspaceAgent {
91
91
  agentId: string;
92
92
  type: string;
93
93
  }
94
+ /** Whether a change waits on the shared-change dialog, so a field showing it isn't reset yet. */
95
+ export declare const ChangeHeld: import("react").Context<boolean>;
94
96
  /**
95
97
  * The workspace around the agent the editor shows: the agents it can name, which of the library's
96
98
  * tools it allows, and, on a project, a way to add or change a provider. `null` when the editor
@@ -66,6 +66,8 @@ export const GuardrailTest = createContext(null);
66
66
  /** What the studio runs on: the page's lent keys, the builder's own, or their machine. */
67
67
  export const RunsOn = createContext(ON_OWN_KEYS);
68
68
  export const LocalConnection = createContext(null);
69
+ /** Whether a change waits on the shared-change dialog, so a field showing it isn't reset yet. */
70
+ export const ChangeHeld = createContext(false);
69
71
  /**
70
72
  * The workspace around the agent the editor shows: the agents it can name, which of the library's
71
73
  * tools it allows, and, on a project, a way to add or change a provider. `null` when the editor
package/ui/inspector.d.ts CHANGED
@@ -35,9 +35,16 @@ export declare function OriginLine({ origin, onOpen }: {
35
35
  * field the section edits (`path`) on hover, as a row's label does. Under it, `note`: only what
36
36
  * the catalog does not say, such as how the editor or the studio treats the field.
37
37
  */
38
- export declare function InspectorSection({ title, path, note, children, }: {
38
+ /** Rows of `path`. A field the files set in code says so once, and its rows take no edit. */
39
+ export declare function OwnField({ path, children }: {
40
+ path?: string;
41
+ children: ReactNode;
42
+ }): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
43
+ export declare function InspectorSection({ title, path, hint, note, children, }: {
39
44
  title?: string;
40
45
  path?: string;
46
+ /** The title's hover, for a section no one catalog field describes. */
47
+ hint?: string;
41
48
  note?: string;
42
49
  children: ReactNode;
43
50
  }): import("react").JSX.Element;
@@ -75,6 +82,22 @@ export type FieldRowProps = {
75
82
  /** The draft field whose issues show on this row. */
76
83
  field?: string;
77
84
  } & IsRequired;
85
+ /**
86
+ * A field row's issue status and presence, and the props its one control shares: labelled but with
87
+ * the label hidden, since the row shows it.
88
+ */
89
+ export declare function useFieldRow({ label, path, field, isRequired }: FieldRowProps): {
90
+ status: InputStatus | undefined;
91
+ required: boolean;
92
+ unset: string | undefined;
93
+ control: {
94
+ label: string;
95
+ status: InputStatus | undefined;
96
+ isLabelHidden: boolean;
97
+ isRequired: boolean;
98
+ size: "sm";
99
+ };
100
+ };
78
101
  /**
79
102
  * The names and values of an object the draft holds as JSON text, a row each. The rows are kept
80
103
  * here while they are typed, since a row with no name is no part of the object yet, and start
@@ -106,6 +129,15 @@ export declare function TextRow(props: FieldRowProps & {
106
129
  maxLength?: number;
107
130
  onChange: (next: string) => void;
108
131
  }): import("react").JSX.Element;
132
+ /** A field whose control sits under its label, with room for an `action` across from the label. */
133
+ export declare function WideRow({ label, path, isRequired, hasIssue, action, children, }: {
134
+ label: string;
135
+ path: string;
136
+ isRequired: boolean;
137
+ hasIssue: boolean;
138
+ action?: ReactNode;
139
+ children: ReactNode;
140
+ }): import("react").JSX.Element;
109
141
  /**
110
142
  * Longer text, under its label rather than beside it: wording and JSON. Left blank, it shows
111
143
  * `placeholder` (for wording, the kernel's own default line) for Tab to take up, else `hint`.
@@ -118,6 +150,7 @@ export declare function TextAreaRow(props: FieldRowProps & {
118
150
  hasSpellCheck?: boolean;
119
151
  /** A status of the row's own, such as text that is not JSON; the field's issues win. */
120
152
  status?: InputStatus;
153
+ action?: ReactNode;
121
154
  onChange: (next: string) => void;
122
155
  }): import("react").JSX.Element;
123
156
  /** A number the kernel leaves unset when cleared: it gives `null`, shown as what leaving it out does. */
@@ -261,7 +294,7 @@ export declare function ListRow({ label, path, field, value, options, onChange,
261
294
  onChange: (next: string[]) => void;
262
295
  }): import("react").JSX.Element;
263
296
  /** Names as tokens, typed and committed with Enter. Duplicates and blanks never make a token. */
264
- export declare function NamesInput({ label, status, value, placeholder, isDisabled, disabledMessage, overflow, onChange, }: {
297
+ export declare function NamesInput({ label, status, value, placeholder, isDisabled, disabledMessage, overflow, marked, onMark, markHint, onChange, }: {
265
298
  label: string;
266
299
  status?: InputStatus;
267
300
  value: string[];
@@ -270,6 +303,15 @@ export declare function NamesInput({ label, status, value, placeholder, isDisabl
270
303
  disabledMessage?: string;
271
304
  /** `none` keeps every token in sight, at the same height, focused or not. */
272
305
  overflow?: 'none' | 'unfocusedInline';
306
+ /** The token shown as chosen. */
307
+ marked?: string;
308
+ /** Pressing a token chooses it. */
309
+ onMark?: (name: string) => void;
310
+ /** What a token's hover says: of the marked one, and of the rest. */
311
+ markHint?: {
312
+ marked: string;
313
+ other: string;
314
+ };
273
315
  onChange: (next: string[]) => void;
274
316
  }): import("react").JSX.Element;
275
317
  /**
package/ui/inspector.js CHANGED
@@ -74,12 +74,16 @@ export function OriginLine({ origin, onOpen }) {
74
74
  * field the section edits (`path`) on hover, as a row's label does. Under it, `note`: only what
75
75
  * the catalog does not say, such as how the editor or the studio treats the field.
76
76
  */
77
- export function InspectorSection({ title, path, note, children, }) {
78
- const heading = title && (_jsx(Text, { type: "label", weight: "semibold", children: title }));
79
- // A section whose own field the files set in code says so once, and its rows take no edit.
77
+ /** Rows of `path`. A field the files set in code says so once, and its rows take no edit. */
78
+ export function OwnField({ path, children }) {
80
79
  const found = useRowOrigin(path);
81
- const says = found && !found.said ? found : undefined;
82
- return (_jsx(Section, { variant: "transparent", padding: 3, children: _jsxs(VStack, { gap: 3, children: [_jsxs(VStack, { gap: 1, hAlign: "start", children: [heading && title && path !== undefined ? (_jsx(CatalogHover, { label: title, path: path, children: heading })) : (heading), note && _jsx(Text, { type: "supporting", children: note })] }), says ? (_jsxs(SaidOrigin, { value: says.origin, children: [_jsx(OriginLine, { origin: says.origin, onOpen: says.open }), _jsx(SetInCode, { children: _jsx(VStack, { gap: 3, children: children }) })] })) : (children)] }) }));
80
+ if (!found || found.said)
81
+ return children;
82
+ return (_jsxs(SaidOrigin, { value: found.origin, children: [_jsx(OriginLine, { origin: found.origin, onOpen: found.open }), _jsx(SetInCode, { children: _jsx(VStack, { gap: 3, children: children }) })] }));
83
+ }
84
+ export function InspectorSection({ title, path, hint, note, children, }) {
85
+ const heading = title && (_jsx(Text, { type: "label", weight: "semibold", children: title }));
86
+ return (_jsx(Section, { variant: "transparent", padding: 3, children: _jsxs(VStack, { gap: 3, children: [_jsxs(VStack, { gap: 1, hAlign: "start", children: [heading && title && path !== undefined && (_jsx(CatalogHover, { label: title, path: path, children: heading })), heading && title && path === undefined && hint !== undefined && (_jsx(HoverCard, { label: title, content: _jsx(VStack, { maxWidth: 280, children: _jsx(Text, { children: hint }) }), children: heading })), heading && path === undefined && hint === undefined && heading, note && _jsx(Text, { type: "supporting", children: note })] }), _jsx(OwnField, { path: path, children: children })] }) }));
83
87
  }
84
88
  /**
85
89
  * The name of a group of rows inside a section. Astryx's ladder, top down: the page title is 14
@@ -132,7 +136,7 @@ export function InspectorRow({ label, path, isRequired = false, hasIssue, hasNot
132
136
  * A field row's issue status and presence, and the props its one control shares: labelled but with
133
137
  * the label hidden, since the row shows it.
134
138
  */
135
- function useFieldRow({ label, path, field, isRequired }) {
139
+ export function useFieldRow({ label, path, field, isRequired }) {
136
140
  const status = useFieldStatus()(field);
137
141
  const { required, unset } = presence(path, isRequired);
138
142
  const control = { label, status, isLabelHidden: true, isRequired: required, size: 'sm' };
@@ -196,6 +200,10 @@ export function TextRow(props) {
196
200
  props.onChange(chars.slice(0, props.maxLength).join(''));
197
201
  } }) }));
198
202
  }
203
+ /** A field whose control sits under its label, with room for an `action` across from the label. */
204
+ export function WideRow({ label, path, isRequired, hasIssue, action, children, }) {
205
+ return (_jsxs(VStack, { gap: 1, [ISSUE_ROW_ATTRIBUTE]: hasIssue || undefined, children: [_jsxs(HStack, { hAlign: "between", vAlign: "center", children: [_jsx(RowLabel, { label: label, path: path, isRequired: isRequired }), action] }), children] }));
206
+ }
199
207
  /**
200
208
  * Longer text, under its label rather than beside it: wording and JSON. Left blank, it shows
201
209
  * `placeholder` (for wording, the kernel's own default line) for Tab to take up, else `hint`.
@@ -204,7 +212,7 @@ export function TextAreaRow(props) {
204
212
  const { label, path, value, placeholder, hint, rows = 3, hasSpellCheck = true, onChange } = props;
205
213
  const { status: fieldStatus, required, unset, control } = useFieldRow(props);
206
214
  const status = fieldStatus ?? props.status;
207
- return (_jsxs(VStack, { gap: 1, [ISSUE_ROW_ATTRIBUTE]: fieldStatus !== undefined || undefined, children: [_jsx(RowLabel, { label: label, path: path, isRequired: required }), _jsx(TextArea, { ...control, status: status, rows: rows, hasSpellCheck: hasSpellCheck, value: value, placeholder: placeholder ?? hint ?? unset, onKeyDown: tabFills(value, placeholder, onChange), onChange: onChange })] }));
215
+ return (_jsx(WideRow, { label: label, path: path, isRequired: required, hasIssue: fieldStatus !== undefined, action: props.action, children: _jsx(TextArea, { ...control, status: status, rows: rows, hasSpellCheck: hasSpellCheck, value: value, placeholder: placeholder ?? hint ?? unset, onKeyDown: tabFills(value, placeholder, onChange), onChange: onChange }) }));
208
216
  }
209
217
  /** A number the kernel leaves unset when cleared: it gives `null`, shown as what leaving it out does. */
210
218
  export function NumberRow(props) {
@@ -314,8 +322,11 @@ export function ListRow({ label, path, field, value, options, onChange, }) {
314
322
  /** A names row suggests nothing; every token is one the user typed. */
315
323
  const NO_SUGGESTIONS = { search: () => [], bootstrap: () => [] };
316
324
  /** Names as tokens, typed and committed with Enter. Duplicates and blanks never make a token. */
317
- export function NamesInput({ label, status, value, placeholder, isDisabled, disabledMessage, overflow = 'unfocusedInline', onChange, }) {
318
- return (_jsx(Tokenizer, { label: label, status: status, isLabelHidden: true, size: "sm", value: value.map((name) => ({ id: name, label: name })), searchSource: NO_SUGGESTIONS, hasCreate: true, debounceMs: 0, placeholder: placeholder, isDisabled: isDisabled, disabledMessage: disabledMessage, tokenOverflowBehavior: overflow, onChange: (items) => {
325
+ export function NamesInput({ label, status, value, placeholder, isDisabled, disabledMessage, overflow = 'unfocusedInline', marked, onMark, markHint, onChange, }) {
326
+ return (_jsx(Tokenizer, { label: label, status: status, isLabelHidden: true, size: "sm", value: value.map((name) => ({ id: name, label: name })), searchSource: NO_SUGGESTIONS, hasCreate: true, debounceMs: 0, placeholder: placeholder, isDisabled: isDisabled, disabledMessage: disabledMessage, tokenOverflowBehavior: overflow, renderToken: onMark &&
327
+ ((item, onRemove) => (_jsx(Tooltip, { content: item.label === marked ? markHint?.marked : markHint?.other, isEnabled: markHint !== undefined, children: _jsx(Token, { label: item.label, size: "sm", color: item.label === marked ? 'blue' : 'default', onClick: () => {
328
+ onMark(item.label);
329
+ }, onRemove: onRemove }) }))), onChange: (items) => {
319
330
  const names = items.map((item) => item.label.trim()).filter(Boolean);
320
331
  onChange([...new Set(names)]);
321
332
  } }));