@sendproof/core 0.1.0-alpha.1 → 0.1.0-alpha.2

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 (116) hide show
  1. package/assets/api.js +2 -1
  2. package/assets/app.css +612 -1
  3. package/assets/app.js +89 -13
  4. package/assets/bar-fit.js +91 -0
  5. package/assets/commands.js +27 -4
  6. package/assets/dialog.css +125 -0
  7. package/assets/dialog.js +191 -0
  8. package/assets/fields/lookup-source.js +5 -2
  9. package/assets/fields/lookup.js +3 -2
  10. package/assets/i18n.js +13 -2
  11. package/assets/icons.js +18 -0
  12. package/assets/index.html +1 -0
  13. package/assets/journeys/compare.js +225 -0
  14. package/assets/journeys/expressions.js +89 -0
  15. package/assets/journeys/index.js +7 -0
  16. package/assets/journeys/run.js +152 -0
  17. package/assets/journeys/steps.js +163 -0
  18. package/assets/journeys-code.js +193 -0
  19. package/assets/journeys-dialog-model.js +172 -0
  20. package/assets/journeys-dialogs.js +301 -0
  21. package/assets/journeys-model.js +259 -0
  22. package/assets/journeys-runs.js +109 -0
  23. package/assets/journeys-session.js +135 -0
  24. package/assets/journeys-view.js +961 -0
  25. package/assets/journeys.js +962 -0
  26. package/assets/locales/ar-journeys.js +468 -0
  27. package/assets/locales/ar.js +2 -0
  28. package/assets/locales/cs-journeys.js +468 -0
  29. package/assets/locales/cs.js +2 -0
  30. package/assets/locales/da-journeys.js +465 -0
  31. package/assets/locales/da.js +2 -0
  32. package/assets/locales/de-journeys.js +465 -0
  33. package/assets/locales/de.js +2 -0
  34. package/assets/locales/el-journeys.js +465 -0
  35. package/assets/locales/el.js +2 -0
  36. package/assets/locales/en-journeys.js +467 -0
  37. package/assets/locales/en.js +2 -0
  38. package/assets/locales/es-journeys.js +467 -0
  39. package/assets/locales/es.js +2 -0
  40. package/assets/locales/fa-journeys.js +465 -0
  41. package/assets/locales/fa.js +2 -0
  42. package/assets/locales/fi-journeys.js +465 -0
  43. package/assets/locales/fi.js +2 -0
  44. package/assets/locales/fr-journeys.js +467 -0
  45. package/assets/locales/fr.js +2 -0
  46. package/assets/locales/he-journeys.js +468 -0
  47. package/assets/locales/he.js +2 -0
  48. package/assets/locales/hi-journeys.js +465 -0
  49. package/assets/locales/hi.js +2 -0
  50. package/assets/locales/id-journeys.js +466 -0
  51. package/assets/locales/id.js +2 -0
  52. package/assets/locales/it-journeys.js +467 -0
  53. package/assets/locales/it.js +2 -0
  54. package/assets/locales/ja-journeys.js +466 -0
  55. package/assets/locales/ja.js +2 -0
  56. package/assets/locales/ko-journeys.js +465 -0
  57. package/assets/locales/ko.js +2 -0
  58. package/assets/locales/nb-journeys.js +465 -0
  59. package/assets/locales/nb.js +2 -0
  60. package/assets/locales/nl-journeys.js +465 -0
  61. package/assets/locales/nl.js +2 -0
  62. package/assets/locales/pl-journeys.js +468 -0
  63. package/assets/locales/pl.js +2 -0
  64. package/assets/locales/pt-BR-journeys.js +467 -0
  65. package/assets/locales/pt-BR.js +2 -0
  66. package/assets/locales/pt-PT-journeys.js +467 -0
  67. package/assets/locales/pt-PT.js +2 -0
  68. package/assets/locales/ru-journeys.js +468 -0
  69. package/assets/locales/ru.js +2 -0
  70. package/assets/locales/sv-journeys.js +465 -0
  71. package/assets/locales/sv.js +2 -0
  72. package/assets/locales/th-journeys.js +466 -0
  73. package/assets/locales/th.js +2 -0
  74. package/assets/locales/tr-journeys.js +468 -0
  75. package/assets/locales/tr.js +2 -0
  76. package/assets/locales/uk-journeys.js +468 -0
  77. package/assets/locales/uk.js +2 -0
  78. package/assets/locales/vi-journeys.js +466 -0
  79. package/assets/locales/vi.js +2 -0
  80. package/assets/locales/zh-Hans-journeys.js +466 -0
  81. package/assets/locales/zh-Hans.js +2 -0
  82. package/assets/locales/zh-Hant-journeys.js +466 -0
  83. package/assets/locales/zh-Hant.js +2 -0
  84. package/assets/manifest.json +349 -104
  85. package/assets/markdown.js +27 -2
  86. package/assets/request-editor.js +7 -1
  87. package/assets/result-states.js +2 -2
  88. package/assets/results.js +41 -14
  89. package/assets/router.js +25 -1
  90. package/assets/seeded-menu.js +2 -1
  91. package/assets/shortcuts-sheet.js +3 -1
  92. package/assets/shortcuts.js +6 -0
  93. package/assets/sidebar.js +54 -5
  94. package/assets/signin.js +6 -3
  95. package/assets/styles.css +8 -2
  96. package/assets/toast.js +29 -0
  97. package/assets/vendor/arazzo-runtime-expression.js +136 -0
  98. package/assets/vendor/json-pointer.js +48 -0
  99. package/assets/vendor/jsonpath-rfc9535.js +15 -0
  100. package/assets/view.js +11 -3
  101. package/assets/views.css +7 -0
  102. package/dist/index.d.ts +7 -3
  103. package/dist/index.js +217 -26
  104. package/dist/journey-builder.d.ts +178 -0
  105. package/dist/journey-builder.js +169 -0
  106. package/dist/journeys.d.ts +24 -0
  107. package/dist/journeys.js +157 -0
  108. package/dist/node-http.d.ts +2 -0
  109. package/dist/node-http.js +17 -0
  110. package/dist/sessions.d.ts +43 -0
  111. package/dist/sessions.js +145 -0
  112. package/dist/statements.js +2 -2
  113. package/dist/stores/tables.d.ts +213 -0
  114. package/dist/stores/tables.js +213 -0
  115. package/dist/types.d.ts +34 -2
  116. package/package.json +1 -1
package/assets/app.js CHANGED
@@ -28,16 +28,19 @@ import { renderModel } from './model-view.js';
28
28
  import { renderOverview } from './overview-view.js';
29
29
  import { schemaName as nameOfSchema } from './schema-model.js';
30
30
  import { bindToggletips } from './toggletip.js';
31
- import { backTarget, createHistory, followModel, formatRoute, parseRoute } from './router.js';
31
+ import { backTarget, createHistory, followModel, formatRoute, isJourneyRoute, parseRoute } from './router.js';
32
+ import { createJourneys } from './journeys.js';
32
33
  import { findOperation, opKey } from './operations.js';
33
34
  import { contextBar } from './context-bar.js';
34
35
  import { watchCrumbs } from './crumb-fit.js';
36
+ import { watchBars } from './bar-fit.js';
35
37
  import { openSeededMenu } from './seeded-menu.js';
36
38
  import { resolvePersonaAccess } from './personas.js';
37
39
  import { carriedValues, replacements } from './deprecation.js';
38
40
 
39
41
  applySettings();
40
42
  watchCrumbs();
43
+ watchBars();
41
44
  const root = document.querySelector('#app');
42
45
  for (const node of root.querySelectorAll('[data-i18n]')) node.textContent = t(node.dataset.i18n);
43
46
  const loadingShell = root.firstElementChild.cloneNode(true);
@@ -45,7 +48,7 @@ const basePath = new URL('../', document.baseURI).pathname;
45
48
  const state = {
46
49
  cap: null, doc: null, ops: [], op: null, forms: [], bodyForm: null, body: undefined,
47
50
  tab: 'Form', resultTab: 'Response', result: null, history: [], headers: [], documentUrl: null,
48
- view: 'overview', model: null, modelFrom: null, route: { kind: 'overview' }, samples: [],
51
+ view: 'overview', model: null, modelFrom: null, route: { kind: 'overview' }, samples: [], mode: 'spec',
49
52
  };
50
53
  const $ = selector => document.querySelector(selector);
51
54
  let documentLoad = 0;
@@ -63,7 +66,7 @@ const {
63
66
  generateField, fieldCount,
64
67
  } = createRequestEditor({
65
68
  state, basePath, $, updateSnippet: () => {}, onLookupPreview: () => run(true), onHeadersChange: refreshIssues,
66
- sensitiveNames, onFilled: count => renderBarStatus(count),
69
+ sensitiveNames, onFilled: count => renderBarStatus(count), onRendered: () => journeys?.decorateStep(),
67
70
  });
68
71
  const {
69
72
  renderResult, renderBar, run, showError, copyFailedRequest, copyCurl, cancel, cancelConfirmation, previewAvailable,
@@ -71,15 +74,24 @@ const {
71
74
  state, basePath, $, readRequest, sensitiveNames, renderOperation, issues, selectView: setPane, onFollowUp: followUp,
72
75
  schemaName: schema => nameOfSchema(schema, state.doc), fillable: () => fieldCount() > 0,
73
76
  onCompleted: (result, { preview }) => { if (!preview && state.op?.method !== 'GET') refreshIdentity(); },
77
+ journey: () => journeys?.hooks(), databaseExtra: () => journeys?.copyCSharpButton() ?? '',
74
78
  });
75
- const sidebar = createSidebar({ state, $ });
79
+ /** Journeys mode (journeys.js): only when capabilities list journeys or Preview sessions. */
80
+ const journeys = createJourneys({
81
+ state, $, basePath, results: { run, renderResult, renderBar }, navigate: (route, options) => navigate(route, options),
82
+ openOperation: openJourneyOperation, announce: text => { const slot = $('[data-request-announcement]'); if (slot) slot.textContent = text; },
83
+ refreshIdentity: () => refreshIdentity(),
84
+ });
85
+ journeys.setReadRequest(() => readRequest());
86
+ journeys.setRedraw(() => redrawJourneys());
87
+ const sidebar = createSidebar({ state, $, journeys: journeys.sidebar });
76
88
  const { palette } = createNavigation({
77
89
  state, $, selectOperation, run, renderOperation, openModel: name => openModel(name), commands: () => commandRegistry.available(),
78
90
  });
79
91
  const commandRegistry = createCommands({
80
92
  state, $, chooseTab: selectRequestTab, chooseResult: selectResultTab, chooseOperation: selectOperation,
81
93
  fill: async mode => { cancelConfirmation(); await fillSample(mode); refreshIssues(); },
82
- preview: () => run(true), send: () => run(false, !!$('[data-action="confirm-send"]')),
94
+ preview: () => runRequest(true), send: () => runRequest(false, !!$('[data-action="confirm-send"]')), journeys,
83
95
  copyResponse: () => $('.response [data-action="copy-response"]')?.click(),
84
96
  openPalette: palette, openSheet: () => showShortcuts($('#overlay')), openSidebar: toggleNavigation,
85
97
  changePane: setPane, issues, addHeader, bulkEdit: showBulkHeaders, toggleHeader,
@@ -222,6 +234,12 @@ async function loadDocument(url) {
222
234
  * operation (Try it ⇄ Docs) and reset when it moves to another one.
223
235
  */
224
236
  function applyRoute(route, { reset } = {}) {
237
+ if (isJourneyRoute(route)) {
238
+ if (journeys.enabled()) return (state.route = journeys.applyRoute(route));
239
+ route = { kind: 'overview' };
240
+ }
241
+ // Leaving Journeys mode from a step starts a fresh draft, so no bound value or journey bar stays behind.
242
+ if (state.mode === 'journeys') { state.mode = 'spec'; if (state.view === 'try') reset ??= {}; }
225
243
  let shown = route;
226
244
  if (route.kind === 'op' || route.kind === 'docs') {
227
245
  const op = findOperation(state.ops, route.id);
@@ -286,7 +304,7 @@ function navigate(route, { reset, focus = true, replace = false } = {}) {
286
304
  nav.go(route, { replace });
287
305
  const shown = applyRoute(route, { reset });
288
306
  if (shown.kind !== route.kind || shown.name !== route.name) nav.go(shown, { replace: true });
289
- if (route.kind === 'op' || route.kind === 'docs') { if (sidebar.tab !== 'operations') sidebar.selectTab('operations'); }
307
+ if ((route.kind === 'op' || route.kind === 'docs') && state.mode !== 'journeys') { if (sidebar.tab !== 'operations') sidebar.selectTab('operations'); }
290
308
  applyView();
291
309
  restoreScroll();
292
310
  if (focus) focusPage();
@@ -294,7 +312,7 @@ function navigate(route, { reset, focus = true, replace = false } = {}) {
294
312
 
295
313
  /** Moves focus to the page's heading, so keyboard and screen reader users land on the new page. */
296
314
  function focusPage() {
297
- const heading = state.view === 'try' ? $('#op-title') || $('#request') : $('#doc-pane h1');
315
+ const heading = state.view === 'try' ? $('#op-title') || $('#request') : $('#doc-pane h1') || $('#doc-pane');
298
316
  heading?.focus?.({ preventScroll: true });
299
317
  }
300
318
 
@@ -350,6 +368,48 @@ function renderShell() {
350
368
  renderBar();
351
369
  renderResult();
352
370
  applyView();
371
+ journeys.load();
372
+ }
373
+
374
+ /** A journey step opens its operation's own screen with its bound values (journeys.js). */
375
+ function openJourneyOperation(op, parameters, body) {
376
+ resetOperation(op, parameters);
377
+ state.body = body;
378
+ state.tab = Object.keys(parameters).some(key => /^(path|query|cookie):/.test(key)) ? 'Params' : 'Form';
379
+ if ($('#context')) renderOperation();
380
+ }
381
+
382
+ /** Preview and Send: a journey step runs as a step of its run; anything else as before. */
383
+ async function runRequest(preview, confirmed = false) {
384
+ // ⌘↵ and ⇧⌘↵ press the bar's own buttons in Journeys mode: Preview run or Send run on an
385
+ // overview or summary (Send run when the journey is Send only), Preview step N+1 after a step.
386
+ if (state.view === 'journey' || state.view === 'jrun') {
387
+ const bar = $('#doc-pane .actionbar');
388
+ (bar?.querySelector(preview ? '[data-action="journey-preview-run"]' : '[data-action="journey-send-run"]:not(.btn-primary)')
389
+ ?? (preview ? bar?.querySelector('[data-action="journey-send-run"].btn-primary') : null))?.click();
390
+ return;
391
+ }
392
+ const next = preview && journeys.stepActive() && $('.actionbar [data-action="journey-next-run"]:not(:disabled)');
393
+ if (next) { next.click(); return; }
394
+ if (!confirmed && journeys.stepActive() && (await journeys.runStep(preview))) return;
395
+ return run(preview, confirmed);
396
+ }
397
+
398
+ /** After a journey run changes: the sidebar's rail, the step's strip, bar and result, or the reading panes. */
399
+ function redrawJourneys() {
400
+ if (!$('.workspace')) return;
401
+ if (state.view === 'journey' || state.view === 'jrun') {
402
+ const scroll = currentScroll();
403
+ journeys.renderReading($('#doc-pane'), $('#aside-pane'));
404
+ for (const pane of [$('#doc-pane'), $('#aside-pane')]) for (const node of pane.querySelectorAll('.pane-scroll')) node.dataset.scroll = pane.id === 'doc-pane' ? 'main' : 'aside';
405
+ restoreScroll(scroll);
406
+ } else if (state.view === 'try') {
407
+ const context = journeys.stepChrome();
408
+ if (context) $('#context').innerHTML = context;
409
+ renderBar();
410
+ renderResult();
411
+ }
412
+ sidebar.render();
353
413
  }
354
414
 
355
415
  /**
@@ -366,18 +426,32 @@ function applyView() {
366
426
  $('#request').hidden = reading;
367
427
  $('.response').hidden = reading;
368
428
  main.hidden = aside.hidden = !reading;
369
- $('.mobile-switch').hidden = reading;
429
+ // Journeys' reading views keep the phone's pane switch (mock m33): the journey or summary, then its runs.
430
+ const journeyReading = state.view === 'journey' || state.view === 'jrun';
431
+ $('.mobile-switch').hidden = reading && !journeyReading;
432
+ workspace.classList.toggle('j7-reading', journeyReading);
433
+ // A new journey page starts at its top: on a phone the workspace itself scrolls.
434
+ if (journeyReading && (state.shownView !== state.view || state.shownRoute !== formatRoute(state.route))) { setPane('request'); workspace.scrollTop = 0; }
435
+ state.shownRoute = formatRoute(state.route);
436
+ state.shownView = state.view;
437
+ const paneNames = journeys.paneNames(state.view);
438
+ for (const button of document.querySelectorAll('.mobile-switch [data-view]')) button.textContent = paneNames[button.dataset.view === 'request' ? 0 : 1];
370
439
  const route = state.route;
371
440
  const ui = state.op ? docsMemory.get(opKey(state.op)) ?? docsMemory.set(opKey(state.op), newDocsState()).get(opKey(state.op)) : newDocsState();
372
441
  const context = { state, route, ui, samples: state.samples, $, basePath };
373
442
  if (state.view === 'docs') { renderDocs(main, aside, context); main.setAttribute('aria-labelledby', 'doc-title'); aside.setAttribute('aria-label', t('docs.aside')); }
374
443
  else if (state.view === 'model') { renderModel(main, aside, context); main.setAttribute('aria-labelledby', 'model-title'); aside.setAttribute('aria-label', t('model.aside')); }
375
444
  else if (state.view === 'overview') { renderOverview(main, aside, context); main.setAttribute('aria-labelledby', 'ov-title'); aside.setAttribute('aria-label', t('overview.start')); }
445
+ else if (state.view === 'journey' || state.view === 'jrun') { journeys.renderReading(main, aside); main.setAttribute('aria-labelledby', 'jr-title'); aside.setAttribute('aria-label', t('jr.runs')); }
376
446
  else {
377
447
  main.replaceChildren();
378
448
  aside.replaceChildren();
379
- $('#context').innerHTML = contextBar(state.op ? { kind: 'op', op: state.op, view: 'try' } : { kind: 'overview' });
449
+ $('#context').innerHTML = journeys.stepChrome() ?? contextBar(state.op ? { kind: 'op', op: state.op, view: 'try' } : { kind: 'overview' });
380
450
  }
451
+ if (state.view !== 'try') journeys.stepChrome();
452
+ // A journey step draws its own bar and Expected tab; leaving one puts the operation's back.
453
+ if (state.view === 'try') { renderBar(); renderResult(); }
454
+ journeys.markMode();
381
455
  for (const pane of [main, aside]) for (const node of pane.querySelectorAll('.pane-scroll')) node.dataset.scroll = pane === main ? 'main' : 'aside';
382
456
  $('#request .pane-scroll').dataset.scroll = 'main';
383
457
  $('.skip-link').setAttribute('href', reading ? '#doc-pane' : '#request');
@@ -560,7 +634,7 @@ function openSignIn() {
560
634
  state.history = [];
561
635
  state.result = null;
562
636
  const back = () => start();
563
- showSignIn(root, state.cap, back, back);
637
+ showSignIn(root, state.cap, back, back, { confirmPersona: user => journeys.confirmPersona(user) });
564
638
  }
565
639
 
566
640
  /**
@@ -609,12 +683,12 @@ const handlers = {
609
683
  issues: () => issues.toggle(),
610
684
  sample: button => autofill(button, refreshIssues),
611
685
  'undo-fill': async () => { await fillSample('undo'); refreshIssues(); },
612
- send: () => run(false),
613
- preview: () => run(true),
686
+ send: () => runRequest(false),
687
+ preview: () => runRequest(true),
614
688
  'view-try': () => setView('try', { focus: true }),
615
689
  'view-docs': () => setView('docs', { focus: true }),
616
690
  'docs-try': () => openDocumentedExample(),
617
- 'seeded-menu': button => openSeededMenu(button, { capabilities: state.cap, onSignedIn: () => refreshIdentity() }),
691
+ 'seeded-menu': button => openSeededMenu(button, { capabilities: state.cap, onSignedIn: () => refreshIdentity(), confirmPersona: user => journeys.confirmPersona(user) }),
618
692
  'toggle-groups': () => sidebar.toggleAll(),
619
693
  'traced-on': () => setTraced(true),
620
694
  'traced-off': () => setTraced(false),
@@ -627,6 +701,7 @@ const handlers = {
627
701
 
628
702
  root.addEventListener('click', async event => {
629
703
  if (event.target.closest('#editor') || event.target.closest('[data-action="sample"]')) cancelConfirmation();
704
+ if (journeys.click(event)) return;
630
705
  // Links that are plain navigation keep the browser's own behaviour for new tabs and windows.
631
706
  const plain = !(event.button || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey);
632
707
  const crumb = event.target.closest('[data-crumb-route]');
@@ -715,6 +790,7 @@ root.addEventListener('change', event => {
715
790
  addEventListener('popstate', onPopState);
716
791
 
717
792
  document.addEventListener('keydown', event => {
793
+ if (journeys.keydown(event)) return;
718
794
  if (!state.doc && matchesShortcut('reload-spec', event) && $('[data-action="restart"]')) { event.preventDefault(); start(); return; }
719
795
  if (!$('.workspace') || event.defaultPrevented || event.isComposing) return;
720
796
  const tab = event.target.closest?.('[role="tab"]');
@@ -0,0 +1,91 @@
1
+ // Priority fitting of the top bar and the journey action bars: what gives way, in what order, when
2
+ // a row is too narrow for its content (a long translation, a larger text size, a narrow window).
3
+ // Media queries cannot see the text size (they read rem against the browser's own size, not the
4
+ // page's), so these are measured.
5
+ //
6
+ // The top bar gives way in this order, one step at a time, until nothing wraps or truncates: the
7
+ // Specification | Journeys switch shows icons, the search trigger shows its icon, the API version
8
+ // goes, the signed-in role goes, the database name goes (classes fit-mode, fit-search, fit-ver,
9
+ // fit-role, fit-db on .topbar; see app.css). Each keeps its title or accessible name.
10
+ //
11
+ // A journey action bar's priority order is: the status line shows its sentence, then only its icon (CSS, see
12
+ // .actionbar.j7-actions .status in app.css), then the buttons drop their shortcut hints. CSS cannot
13
+ // tell "the buttons need more than the bar has" in every locale and at every text size, so this
14
+ // measures it: a bar whose content overflows with the status already down to its icon gets
15
+ // `is-tight`, which hides the hints. It re-measures when the bar's width, the root font size, the
16
+ // language or a web font changes, and whenever a bar is rendered afresh.
17
+
18
+ const SELECTOR = '.actionbar.j7-actions';
19
+ const TOPBAR = '.topbar';
20
+ const STEPS = ['fit-mode', 'fit-search', 'fit-ver', 'fit-role', 'fit-db'];
21
+ // The topbar's elements that ellipsize when squeezed.
22
+ const SQUEEZABLE = '.api-switch .name, .env .ltr, .env strong, .persona .name, .search-trigger .grow';
23
+
24
+ /** Whether the top bar overflows its row or any text in it is cut off. */
25
+ function squeezed(bar) {
26
+ if (bar.scrollWidth > bar.clientWidth + 1) return true;
27
+ return [...bar.querySelectorAll(SQUEEZABLE)].some(item => item.clientWidth > 8 && item.scrollWidth > item.clientWidth + 1);
28
+ }
29
+
30
+ /**
31
+ * Applies the top bar's give-way steps in order, stopping at the first that leaves nothing cut off.
32
+ * @param {ParentNode} [root]
33
+ */
34
+ export function fitTopbar(root = document) {
35
+ const bar = root.querySelector(TOPBAR);
36
+ if (!bar || !bar.getClientRects().length) return;
37
+ bar.classList.remove(...STEPS);
38
+ for (const step of STEPS) {
39
+ if (!squeezed(bar)) break;
40
+ bar.classList.add(step);
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Sets `is-tight` on every journey action bar under `root` whose content overflows. The class is
46
+ * removed first so the measurement is of the full hints each time; all reads come before any write.
47
+ * @param {ParentNode} [root]
48
+ */
49
+ export function fitBars(root = document) {
50
+ const bars = [...root.querySelectorAll(SELECTOR)];
51
+ bars.forEach(bar => bar.classList.remove('is-tight'));
52
+ const overflowing = bars.map(bar => bar.scrollWidth > bar.clientWidth + 1);
53
+ bars.forEach((bar, index) => bar.classList.toggle('is-tight', overflowing[index]));
54
+ fitTopbar(root);
55
+ }
56
+
57
+ const addsBar = mutation => [...mutation.addedNodes].some(node =>
58
+ node.nodeType === 1 && [SELECTOR, TOPBAR].some(selector => node.matches?.(selector) || node.querySelector?.(selector) || node.parentElement?.matches?.(selector)));
59
+
60
+ /**
61
+ * Keeps the bars fitted for the life of the page. Call once at startup.
62
+ * @returns {() => void} stops watching
63
+ */
64
+ export function watchBars() {
65
+ let queued = false;
66
+ const schedule = () => {
67
+ if (queued) return;
68
+ queued = true;
69
+ requestAnimationFrame(() => { queued = false; fitBars(); });
70
+ };
71
+ // A bar is re-rendered by replacing its children, or the whole pane is replaced.
72
+ const added = new MutationObserver(mutations => { if (mutations.some(addsBar)) schedule(); });
73
+ added.observe(document.body, { childList: true, subtree: true });
74
+ const root = new MutationObserver(schedule);
75
+ root.observe(document.documentElement, { attributes: true, attributeFilter: ['style', 'class', 'lang', 'dir', 'data-density'] });
76
+ // A box one rem wide: it resizes exactly when the root font size does (text size, zoom, density).
77
+ const probe = Object.assign(document.createElement('span'), { ariaHidden: 'true' });
78
+ probe.style.cssText = 'position:fixed;inset-block-start:0;inset-inline-start:0;inline-size:1rem;block-size:0;visibility:hidden;pointer-events:none';
79
+ document.body.append(probe);
80
+ const sizes = typeof ResizeObserver === 'function' ? new ResizeObserver(schedule) : undefined;
81
+ sizes?.observe(probe);
82
+ sizes?.observe(document.body);
83
+ document.fonts?.addEventListener?.('loadingdone', schedule);
84
+ addEventListener('resize', schedule);
85
+ schedule();
86
+ return () => {
87
+ added.disconnect(); root.disconnect(); sizes?.disconnect(); probe.remove();
88
+ document.fonts?.removeEventListener?.('loadingdone', schedule);
89
+ removeEventListener('resize', schedule);
90
+ };
91
+ }
@@ -11,7 +11,7 @@ function editing(target) {
11
11
  export function createCommands({ $, state, chooseTab, chooseResult, chooseOperation, fill, preview,
12
12
  send, openPalette, openSheet, openSidebar, changePane, issues, addHeader, bulkEdit, toggleHeader, copyResponse,
13
13
  openDisplay, openHistory, toggleTheme, toggleDocs, sidebarTab, modelBack, generate, toggleTrace, traceAvailable,
14
- reloadSpec, canReload,
14
+ reloadSpec, canReload, journeys,
15
15
  }) {
16
16
  const click = selector => $(selector)?.click();
17
17
  const requestTab = () => [...document.querySelectorAll('.request-tabs [data-request-tab]')];
@@ -101,6 +101,11 @@ export function createCommands({ $, state, chooseTab, chooseResult, chooseOperat
101
101
  'change-prev': () => nextChange(-1),
102
102
  preview,
103
103
  send,
104
+ 'mode-spec': () => journeys?.switchMode('spec'),
105
+ 'mode-journeys': () => journeys?.switchMode('journeys'),
106
+ 'step-previous': () => journeys?.stepBy(-1),
107
+ 'step-next': () => journeys?.stepBy(1),
108
+ 'run-to-end': () => journeys?.runToEnd(),
104
109
  };
105
110
  for (const [id, definition] of Object.entries(SHORTCUTS)) {
106
111
  if (definition.mode) actions[id] = () => fill(definition.mode);
@@ -108,7 +113,9 @@ export function createCommands({ $, state, chooseTab, chooseResult, chooseOperat
108
113
 
109
114
  const canRun = {
110
115
  'editor-mode': () => !!$('[data-request-tab="Body"]') && state.view === 'try',
111
- docs: () => !!state.op && ['try', 'docs'].includes(state.view),
116
+ docs: () => !!state.op && ['try', 'docs'].includes(state.view) && state.mode !== 'journeys',
117
+ next: () => state.mode !== 'journeys',
118
+ previous: () => state.mode !== 'journeys',
112
119
  'model-back': () => state.view === 'model' && !!backTarget(state.route),
113
120
  generate: () => state.view === 'try',
114
121
  'generate-menu': () => state.view === 'try',
@@ -131,8 +138,13 @@ export function createCommands({ $, state, chooseTab, chooseResult, chooseOperat
131
138
  'wrap-lines': () => !!$('.response-viewer [data-wrap]:not([hidden])'),
132
139
  'change-next': () => !!$('.response .table-change'),
133
140
  'change-prev': () => !!$('.response .table-change'),
134
- preview: () => !!$('.actionbar [data-action="preview"]:not(:disabled)'),
135
- send: () => !!$('.actionbar [data-action="send"]:not(:disabled), [data-action="confirm-send"]'),
141
+ preview: () => !!$('.workspace > .pane:not([hidden]) .actionbar :is([data-action="preview"], [data-action="journey-preview-run"], [data-action="journey-next-run"]):not(:disabled)'),
142
+ 'mode-spec': () => !!journeys?.enabled() && state.mode === 'journeys',
143
+ 'mode-journeys': () => !!journeys?.enabled() && state.mode !== 'journeys',
144
+ 'step-previous': () => !!journeys?.stepActive(),
145
+ 'step-next': () => !!journeys?.stepActive(),
146
+ 'run-to-end': () => !!journeys?.canRunToEnd(),
147
+ send: () => !!$('.workspace > .pane:not([hidden]) .actionbar :is([data-action="send"], [data-action="journey-send-run"]):not(:disabled), [data-action="confirm-send"]'),
136
148
  };
137
149
  function tabCommands() {
138
150
  return [...requestTab().map((button, index) => ({
@@ -161,6 +173,17 @@ export function createCommands({ $, state, chooseTab, chooseResult, chooseOperat
161
173
  if (modal && !(modal.classList.contains('palette') && matchesShortcut('shortcuts', event))) return false;
162
174
 
163
175
  const isEditor = editing(target);
176
+ // The second key of a pending sequence (G then J) wins over a bare-key chord (J, next operation).
177
+ if (!isEditor && sequenceAt && performance.now() - sequenceAt.time < 900 && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) {
178
+ const key = event.key.toUpperCase();
179
+ const match = Object.entries(SHORTCUTS).find(([id, definition]) => definition.sequence?.[0] === sequenceAt.key && definition.sequence[1] === key && (!canRun[id] || canRun[id]()));
180
+ if (match && actions[match[0]]) {
181
+ sequenceAt = 0;
182
+ event.preventDefault();
183
+ actions[match[0]](target);
184
+ return true;
185
+ }
186
+ }
164
187
  const local = new Set(['add-row', 'remove-row', 'toggle-header']);
165
188
  for (const id of ['add-row', 'remove-row', 'toggle-header', ...Object.keys(actions).filter(id => !local.has(id))]) {
166
189
  const definition = SHORTCUTS[id];
@@ -0,0 +1,125 @@
1
+ /* The workbench's own dialog (dialog.js; mocks v8). One shape for every question or notice: a tinted
2
+ icon tile with the title and one sentence beside it, an optional list of what will happen (each
3
+ row a name with a subtitle under it, never text pushed to the right), then the meta on the left
4
+ of the footer and the actions on the right. A phone gets a bottom sheet. */
5
+
6
+ dialog.dl-host { position: fixed; inset: 0; inline-size: 100%; block-size: 100%; max-inline-size: none; max-block-size: none; margin: 0; padding: 1.5rem 1.5rem 12vh; border: 0; overflow: hidden; color: var(--text); background: oklch(0.2 0.02 268 / 0.32); overscroll-behavior: contain; }
7
+ [data-theme="dark"] dialog.dl-host { background: oklch(0 0 0 / 0.56); }
8
+ dialog.dl-host[open] { display: grid; grid-template-rows: minmax(0, 1fr); place-items: center; animation: dl-fade 140ms var(--ease) both; }
9
+ dialog.dl-host::backdrop { background: transparent; }
10
+ .dl { inline-size: min(28rem, 100%); max-block-size: 100%; overflow-y: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; padding: 1.125rem 1.125rem 1rem; border-radius: 0.875rem; background: var(--raised); border: 1px solid var(--line); box-shadow: var(--shadow-pop); animation: dl-rise 180ms cubic-bezier(0.16, 1, 0.3, 1) both; touch-action: pan-y; }
11
+ /* Large text can make the card taller than the window; focus scrolls the foot in, with room for its ring. */
12
+ .dl { scroll-padding-block: 1rem; }
13
+ @keyframes dl-fade { from { opacity: 0; } }
14
+ @keyframes dl-rise { from { opacity: 0; transform: translateY(0.375rem) scale(0.985); } }
15
+ @keyframes dl-sheet { from { transform: translateY(1.5rem); opacity: 0; } }
16
+ @media (prefers-reduced-motion: reduce) { dialog.dl-host[open], .dl { animation-duration: 1ms; } }
17
+ .dl-grab { display: none; }
18
+
19
+ .dl-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.875rem; align-items: start; }
20
+ .dl-tile { inline-size: 2.25rem; block-size: 2.25rem; border-radius: 0.625rem; display: grid; place-items: center; background: var(--sunken); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line); }
21
+ .dl-tile.is-warn { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--warn) 24%, transparent); }
22
+ .dl-tile.is-danger { background: var(--danger-soft); color: var(--danger); box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--danger) 22%, transparent); }
23
+ .dl-tile.is-neutral .i { color: var(--accent-text); }
24
+ .dl-titles { display: grid; gap: 0.25rem; min-inline-size: 0; padding-block-start: 0.0625rem; }
25
+ .dl-titles h2 { margin: 0; font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.011em; line-height: 1.35; color: var(--text); text-wrap: balance; }
26
+ .dl-titles p { margin: 0; font-size: var(--fs-md); line-height: 1.5; color: var(--text-2); text-wrap: pretty; }
27
+ .dl-close { margin: -0.25rem -0.25rem 0 0; color: var(--text-3); }
28
+ [dir="rtl"] .dl-close { margin: -0.25rem 0 0 -0.25rem; }
29
+
30
+ .dl-body { display: grid; gap: 0.625rem; min-inline-size: 0; }
31
+ .dl-label { margin: 0; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; font-size: var(--fs-sm); font-weight: 500; color: var(--text-3); }
32
+ .dl-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); overflow: hidden; }
33
+ .dl-row { display: flex; align-items: center; gap: 0.75rem; min-block-size: 3rem; padding: 0.4375rem 0.875rem; }
34
+ .dl-row + .dl-row { border-block-start: 1px solid var(--line); }
35
+ .dl-row > svg, .dl-row > .mk { flex: none; }
36
+ .dl-text { display: grid; gap: 0.0625rem; min-inline-size: 0; flex: 1; }
37
+ .dl-name { font-size: var(--fs-md); font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
38
+ .dl-name code { font-size: var(--fs-sm); font-weight: 400; color: var(--text-2); background: none; padding: 0; }
39
+ .dl-sub { font-size: var(--fs-sm); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
40
+ .dl-mark { inline-size: 1.25rem; block-size: 1.25rem; border-radius: 50%; display: grid; place-items: center; flex: none; color: var(--text-3); background: var(--sunken); box-shadow: inset 0 0 0 1px var(--line); }
41
+ .dl-mark .i { inline-size: 0.75rem; block-size: 0.75rem; }
42
+ .dl-mark.is-ok { color: var(--ok); background: var(--ok-soft); box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--ok) 30%, transparent); }
43
+ .dl-mark.is-warn { color: var(--warn); background: var(--warn-soft); box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--warn) 30%, transparent); }
44
+ .dl-mark.is-danger { color: var(--danger); background: var(--danger-soft); box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--danger) 30%, transparent); }
45
+ .dl-hint { margin: 0; display: flex; align-items: center; gap: 0.5rem; font-size: var(--fs-sm); color: var(--text-3); }
46
+ .dl-hint .i { flex: none; }
47
+
48
+ /* Stopping a Send run offers the operation that undoes it, as a row the person can open. */
49
+ .dl-undo { display: flex; align-items: center; gap: 0.75rem; inline-size: 100%; padding: 0.5rem 0.75rem 0.5rem 0.875rem; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--raised); box-shadow: var(--shadow-sm); color: var(--text); font: inherit; text-align: start; cursor: pointer; }
50
+ [dir="rtl"] .dl-undo { padding: 0.5rem 0.875rem 0.5rem 0.75rem; }
51
+ .dl-undo:hover { background: var(--hover); }
52
+ .dl-undo > .i { color: var(--text-3); flex: none; }
53
+ .dl-undo .method { flex: none; }
54
+
55
+ /* Switching persona: the two people are the dialog. The head tile is the pair of avatars; below,
56
+ a card each, the current one quiet and the next one lifted, each with its role and, when the
57
+ specification says which operations a role can call, one segment per journey step (refused
58
+ steps hatched), so the consequence reads at a glance. */
59
+ .dl-av { background: linear-gradient(145deg, oklch(0.9 0.07 35), oklch(0.82 0.1 20)); color: oklch(0.36 0.11 28); box-shadow: inset 0 0 0 1px oklch(0.3 0.1 28 / 0.08); }
60
+ .dl-av.is-alt { background: linear-gradient(145deg, oklch(0.9 0.07 195), oklch(0.8 0.09 215)); color: oklch(0.34 0.08 220); box-shadow: inset 0 0 0 1px oklch(0.3 0.08 220 / 0.1); }
61
+ [data-theme="dark"] .dl-av { background: linear-gradient(145deg, oklch(0.46 0.1 35), oklch(0.36 0.09 20)); color: oklch(0.94 0.03 35); }
62
+ [data-theme="dark"] .dl-av.is-alt { background: linear-gradient(145deg, oklch(0.46 0.08 195), oklch(0.36 0.08 215)); color: oklch(0.94 0.03 200); }
63
+ .dl-pair { position: relative; inline-size: 2.25rem; block-size: 2.25rem; flex: none; }
64
+ .dl-pair .avatar { inline-size: 2.25rem; block-size: 2.25rem; font-size: var(--fs-sm); }
65
+ .dl-pair-badge { position: absolute; inset-inline-end: -0.25rem; inset-block-end: -0.25rem; display: grid; place-items: center; inline-size: 1.125rem; block-size: 1.125rem; border-radius: 50%; background: var(--accent); color: var(--on-accent); box-shadow: 0 0 0 2px var(--raised); }
66
+ .dl-pair-badge .i { inline-size: 0.6875rem; block-size: 0.6875rem; }
67
+
68
+ .dl-people { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: stretch; }
69
+ .dl-pc { display: grid; gap: 0.625rem; align-content: start; min-inline-size: 0; padding: 0.75rem 0.875rem 0.875rem; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--panel); }
70
+ .dl-pc.is-next { background: var(--raised); border-color: color-mix(in oklch, var(--accent) 45%, var(--line)); box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 12%, transparent), var(--shadow-sm); }
71
+ .dl-pc-tag { display: inline-flex; align-items: center; gap: 0.3125rem; font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.02em; color: var(--text-3); white-space: nowrap; }
72
+ .dl-pc.is-next .dl-pc-tag { color: var(--accent-text); }
73
+ .dl-pc-who { display: flex; align-items: center; gap: 0.625rem; min-inline-size: 0; }
74
+ .dl-pc-who .avatar { inline-size: 2.25rem; block-size: 2.25rem; font-size: var(--fs-sm); flex: none; }
75
+ .dl-pc.is-now .dl-pc-who .avatar { filter: saturate(0.55); }
76
+ .dl-role { font: 400 var(--fs-xs)/1 var(--mono); color: var(--text-3); }
77
+ .dl-pc-access { display: flex; align-items: center; gap: 0.625rem; }
78
+ .dl-pc-count { font-size: var(--fs-xs); font-weight: 500; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
79
+ .dl-steps { flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0.1875rem; }
80
+ .dl-seg { block-size: 0.3125rem; border-radius: 999px; background: var(--ok); }
81
+ .dl-pc.is-now .dl-seg { background: color-mix(in oklch, var(--ok) 55%, var(--line)); }
82
+ .dl-seg.is-no, .dl-pc.is-now .dl-seg.is-no { background: repeating-linear-gradient(135deg, var(--danger) 0 2px, color-mix(in oklch, var(--danger) 25%, transparent) 2px 4px); }
83
+ .dl-hop { align-self: center; display: grid; place-items: center; inline-size: 1.625rem; block-size: 1.625rem; margin-inline: -0.375rem; z-index: 1; border-radius: 50%; background: var(--raised); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line), var(--shadow-sm); }
84
+
85
+ .dl-foot { display: flex; align-items: center; gap: 0.75rem; padding-block-start: 0.25rem; }
86
+ .dl-meta { flex: 1; min-inline-size: 0; display: flex; align-items: center; }
87
+ .dl-actions { display: flex; gap: 0.5rem; flex: none; }
88
+ .dl-actions .btn { gap: 0.4375rem; }
89
+ .dl-actions .btn .keys { margin-inline-start: 0.125rem; }
90
+ /* The safe action is always ringed, even when a click opened the dialog: it is where Enter lands. */
91
+ .dl-actions [data-dialog-initial]:focus { outline: 2px solid var(--focus); outline-offset: 2px; }
92
+ .dl-env { display: inline-flex; align-items: center; gap: 0.4375rem; block-size: 1.5rem; padding-inline: 0.5rem 0.5625rem; border-radius: 999px; background: var(--sunken); box-shadow: inset 0 0 0 1px var(--line); font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); white-space: nowrap; }
93
+ .dl-env .dot { inline-size: 0.4375rem; block-size: 0.4375rem; border-radius: 50%; background: var(--ok); }
94
+ .dl-env-db { font: 400 var(--fs-xs)/1 var(--mono); color: var(--text-3); }
95
+ .dl-foot-note { display: inline-flex; align-items: center; gap: 0.375rem; font-size: var(--fs-sm); color: var(--text-3); white-space: nowrap; }
96
+ .dl-danger { color: var(--danger); border-color: color-mix(in oklch, var(--danger) 40%, var(--line-strong)); }
97
+ .dl-danger:hover { background: var(--danger-soft); }
98
+ .dl-danger .i { color: var(--danger); }
99
+
100
+ /* Phones: a bottom sheet, the actions full width with the main one first, out of the thumb's way of Cancel. */
101
+ @media (max-width: 56rem) {
102
+ dialog.dl-host { padding: 0; }
103
+ dialog.dl-host[open] { place-items: end stretch; }
104
+ .dl { inline-size: 100%; max-block-size: 92%; border-radius: 1rem 1rem 0 0; border-block-end: 0; padding: 0.5rem 1rem calc(1rem + env(safe-area-inset-bottom)); gap: 0.875rem; animation-name: dl-sheet; }
105
+ .dl-grab { display: block; justify-self: center; inline-size: 2.25rem; block-size: 0.25rem; border-radius: 999px; background: var(--line-strong); margin-block-end: 0.25rem; }
106
+ .dl-close { display: none; }
107
+ .dl-head { grid-template-columns: auto minmax(0, 1fr); }
108
+ .dl-foot { flex-direction: column; align-items: stretch; gap: 0.625rem; }
109
+ .dl-meta:empty { display: none; }
110
+ .dl-actions { flex-direction: column-reverse; }
111
+ .dl-actions .btn { block-size: 2.75rem; justify-content: center; font-size: var(--fs-base); }
112
+ .dl-actions .btn .keys { display: none; }
113
+ .dl-people { grid-template-columns: minmax(0, 1fr); }
114
+ .dl-hop { justify-self: center; margin-block: -0.375rem; margin-inline: 0; transform: rotate(90deg); }
115
+ /* A phone has the height to spare, so a subtitle takes a second line rather than losing its end. */
116
+ .dl-sub { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; }
117
+ }
118
+
119
+ /* A quiet note: what the workbench did on the person's behalf. Never asks for anything. */
120
+ .toast { position: fixed; inset-block-end: 3.5rem; inset-inline-start: 50%; translate: -50% 0; z-index: 60; display: flex; align-items: center; gap: 0.5rem; max-inline-size: min(34rem, calc(100vw - 1.5rem)); padding: 0.5rem 0.5rem 0.5rem 0.75rem; border-radius: var(--r-lg); background: var(--raised); color: var(--text-2); font-size: var(--fs-sm, 0.8125rem); box-shadow: inset 0 0 0 1px var(--line), var(--shadow-pop); animation: toast-in 160ms ease-out; }
121
+ [dir="rtl"] .toast { translate: 50% 0; }
122
+ .toast > .i { flex: none; color: var(--text-3); }
123
+ .toast-text { min-inline-size: 0; }
124
+ @keyframes toast-in { from { opacity: 0; transform: translateY(0.5rem); } }
125
+ @media (prefers-reduced-motion: reduce) { .toast { animation-duration: 1ms; } }