screenreader-speech-capture 0.8.2-fix-ui-loopback.21 → 0.9.0-feat-bridge-focus-window.23

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 (176) hide show
  1. package/dist/cli.mjs +918 -250
  2. package/dist/ui/adapter-node.js +1 -1
  3. package/dist/ui/client/ui/_app/immutable/chunks/{CM9WugkD.js → 0YgL1EU2.js} +36 -36
  4. package/dist/ui/client/ui/_app/immutable/chunks/0YgL1EU2.js.br +0 -0
  5. package/dist/ui/client/ui/_app/immutable/chunks/0YgL1EU2.js.gz +0 -0
  6. package/dist/ui/client/ui/_app/immutable/chunks/BYvlzyV8.js +1 -0
  7. package/dist/ui/client/ui/_app/immutable/chunks/BYvlzyV8.js.br +2 -0
  8. package/dist/ui/client/ui/_app/immutable/chunks/BYvlzyV8.js.gz +0 -0
  9. package/dist/ui/client/ui/_app/immutable/chunks/BfvDkxmG.js +3 -0
  10. package/dist/ui/client/ui/_app/immutable/chunks/BfvDkxmG.js.br +0 -0
  11. package/dist/ui/client/ui/_app/immutable/chunks/BfvDkxmG.js.gz +0 -0
  12. package/dist/ui/client/ui/_app/immutable/chunks/CSCPyqWx.js +1 -0
  13. package/dist/ui/client/ui/_app/immutable/chunks/CSCPyqWx.js.br +3 -0
  14. package/dist/ui/client/ui/_app/immutable/chunks/CSCPyqWx.js.gz +0 -0
  15. package/dist/ui/client/ui/_app/immutable/chunks/{Fimt9aTv.js → Cba3ZwaX.js} +11 -11
  16. package/dist/ui/client/ui/_app/immutable/chunks/Cba3ZwaX.js.br +0 -0
  17. package/dist/ui/client/ui/_app/immutable/chunks/Cba3ZwaX.js.gz +0 -0
  18. package/dist/ui/client/ui/_app/immutable/chunks/DErxe_FC.js +3 -0
  19. package/dist/ui/client/ui/_app/immutable/chunks/DErxe_FC.js.br +0 -0
  20. package/dist/ui/client/ui/_app/immutable/chunks/DErxe_FC.js.gz +0 -0
  21. package/dist/ui/client/ui/_app/immutable/chunks/Dqufijaz.js +1 -0
  22. package/dist/ui/client/ui/_app/immutable/chunks/Dqufijaz.js.br +0 -0
  23. package/dist/ui/client/ui/_app/immutable/chunks/Dqufijaz.js.gz +0 -0
  24. package/dist/ui/client/ui/_app/immutable/chunks/WpCriteK.js +1 -0
  25. package/dist/ui/client/ui/_app/immutable/chunks/WpCriteK.js.br +1 -0
  26. package/dist/ui/client/ui/_app/immutable/chunks/WpCriteK.js.gz +0 -0
  27. package/dist/ui/client/ui/_app/immutable/chunks/wbLSPbHY.js +4 -0
  28. package/dist/ui/client/ui/_app/immutable/chunks/wbLSPbHY.js.br +0 -0
  29. package/dist/ui/client/ui/_app/immutable/chunks/wbLSPbHY.js.gz +0 -0
  30. package/dist/ui/client/ui/_app/immutable/entry/app.B6hhDf4F.js +2 -0
  31. package/dist/ui/client/ui/_app/immutable/entry/app.B6hhDf4F.js.br +0 -0
  32. package/dist/ui/client/ui/_app/immutable/entry/app.B6hhDf4F.js.gz +0 -0
  33. package/dist/ui/client/ui/_app/immutable/entry/{start.uodUAHNT.js → start.Dluk7nQO.js} +2 -2
  34. package/dist/ui/client/ui/_app/immutable/entry/start.Dluk7nQO.js.br +0 -0
  35. package/dist/ui/client/ui/_app/immutable/entry/start.Dluk7nQO.js.gz +0 -0
  36. package/dist/ui/client/ui/_app/immutable/nodes/0.D-lhv0Us.js +1 -0
  37. package/dist/ui/client/ui/_app/immutable/nodes/0.D-lhv0Us.js.br +0 -0
  38. package/dist/ui/client/ui/_app/immutable/nodes/0.D-lhv0Us.js.gz +0 -0
  39. package/dist/ui/client/ui/_app/immutable/nodes/1.Cs4GAsCO.js +1 -0
  40. package/dist/ui/client/ui/_app/immutable/nodes/1.Cs4GAsCO.js.br +1 -0
  41. package/dist/ui/client/ui/_app/immutable/nodes/1.Cs4GAsCO.js.gz +0 -0
  42. package/dist/ui/client/ui/_app/immutable/nodes/2.CmuzlN_T.js +52 -0
  43. package/dist/ui/client/ui/_app/immutable/nodes/2.CmuzlN_T.js.br +0 -0
  44. package/dist/ui/client/ui/_app/immutable/nodes/2.CmuzlN_T.js.gz +0 -0
  45. package/dist/ui/client/ui/_app/immutable/nodes/3.DMXXeBbC.js +5 -0
  46. package/dist/ui/client/ui/_app/immutable/nodes/3.DMXXeBbC.js.br +0 -0
  47. package/dist/ui/client/ui/_app/immutable/nodes/3.DMXXeBbC.js.gz +0 -0
  48. package/dist/ui/client/ui/_app/immutable/nodes/{4.DY8qq4Io.js → 4.CMHCNMDn.js} +1 -1
  49. package/dist/ui/client/ui/_app/immutable/nodes/4.CMHCNMDn.js.br +0 -0
  50. package/dist/ui/client/ui/_app/immutable/nodes/4.CMHCNMDn.js.gz +0 -0
  51. package/dist/ui/client/ui/_app/version.json +1 -1
  52. package/dist/ui/client/ui/_app/version.json.br +0 -0
  53. package/dist/ui/client/ui/_app/version.json.gz +0 -0
  54. package/dist/ui/server/.vite/manifest.json +97 -54
  55. package/dist/ui/server/chunks/composition.js +112 -118
  56. package/dist/ui/server/chunks/composition.js.map +1 -1
  57. package/dist/ui/server/chunks/config.js +139 -3
  58. package/dist/ui/server/chunks/config.js.map +1 -1
  59. package/dist/ui/server/chunks/exports.js +19 -204
  60. package/dist/ui/server/chunks/exports.js.map +1 -1
  61. package/dist/ui/server/chunks/functions.js +1 -1
  62. package/dist/ui/server/chunks/icon-button.js +1 -1
  63. package/dist/ui/server/chunks/instance.js +9 -56
  64. package/dist/ui/server/chunks/instance.js.map +1 -1
  65. package/dist/ui/server/chunks/internal.js +55 -4
  66. package/dist/ui/server/chunks/internal.js.map +1 -1
  67. package/dist/ui/server/chunks/outlined-text-field.js +1 -1
  68. package/dist/ui/server/chunks/remote-1j2tn2d.js +4 -0
  69. package/dist/ui/server/chunks/remote.js +1565 -0
  70. package/dist/ui/server/chunks/remote.js.map +1 -0
  71. package/dist/ui/server/chunks/scope.js +13 -0
  72. package/dist/ui/server/chunks/scope.js.map +1 -0
  73. package/dist/ui/server/chunks/server-errors.js +48 -1
  74. package/dist/ui/server/chunks/server-errors.js.map +1 -1
  75. package/dist/ui/server/chunks/server2.js +24 -1
  76. package/dist/ui/server/chunks/server2.js.map +1 -1
  77. package/dist/ui/server/chunks/sessions.js +65 -0
  78. package/dist/ui/server/chunks/sessions.js.map +1 -0
  79. package/dist/ui/server/chunks/sessions.remote.js +56 -0
  80. package/dist/ui/server/chunks/sessions.remote.js.map +1 -0
  81. package/dist/ui/server/chunks/shared-errors.js +214 -0
  82. package/dist/ui/server/chunks/shared-errors.js.map +1 -0
  83. package/dist/ui/server/chunks/src.js +112 -42
  84. package/dist/ui/server/chunks/src.js.map +1 -1
  85. package/dist/ui/server/entries/endpoints/api/config/_server.ts.js +3 -5
  86. package/dist/ui/server/entries/endpoints/api/config/_server.ts.js.map +1 -1
  87. package/dist/ui/server/entries/endpoints/api/markers/_server.ts.js +3 -4
  88. package/dist/ui/server/entries/endpoints/api/markers/_server.ts.js.map +1 -1
  89. package/dist/ui/server/entries/endpoints/api/sessions/_id_id_/_server.ts.js +12 -0
  90. package/dist/ui/server/entries/endpoints/api/sessions/_id_id_/_server.ts.js.map +1 -0
  91. package/dist/ui/server/entries/endpoints/api/sessions/_server.ts.js +4 -9
  92. package/dist/ui/server/entries/endpoints/api/sessions/_server.ts.js.map +1 -1
  93. package/dist/ui/server/entries/endpoints/api/sessions/end/_server.ts.js +2 -3
  94. package/dist/ui/server/entries/endpoints/api/sessions/end/_server.ts.js.map +1 -1
  95. package/dist/ui/server/entries/endpoints/api/speech/_server.ts.js +6 -9
  96. package/dist/ui/server/entries/endpoints/api/speech/_server.ts.js.map +1 -1
  97. package/dist/ui/server/entries/endpoints/api/speech/stream/_server.ts.js +3 -3
  98. package/dist/ui/server/entries/endpoints/api/speech/stream/_server.ts.js.map +1 -1
  99. package/dist/ui/server/entries/endpoints/api/status/_server.ts.js +2 -3
  100. package/dist/ui/server/entries/endpoints/api/status/_server.ts.js.map +1 -1
  101. package/dist/ui/server/entries/fallbacks/error.svelte.js +1 -1
  102. package/dist/ui/server/entries/hooks.server.js +145 -1
  103. package/dist/ui/server/entries/hooks.server.js.map +1 -1
  104. package/dist/ui/server/entries/pages/_layout.server.ts.js +2 -3
  105. package/dist/ui/server/entries/pages/_layout.server.ts.js.map +1 -1
  106. package/dist/ui/server/entries/pages/_layout.svelte.js +4 -2
  107. package/dist/ui/server/entries/pages/_layout.svelte.js.map +1 -1
  108. package/dist/ui/server/entries/pages/_page.server.ts.js +3 -3
  109. package/dist/ui/server/entries/pages/_page.server.ts.js.map +1 -1
  110. package/dist/ui/server/entries/pages/_page.svelte.js +11 -65
  111. package/dist/ui/server/entries/pages/_page.svelte.js.map +1 -1
  112. package/dist/ui/server/entries/pages/settings/_page.svelte.js +3 -2
  113. package/dist/ui/server/entries/pages/settings/_page.svelte.js.map +1 -1
  114. package/dist/ui/server/entries/params.js +60 -0
  115. package/dist/ui/server/entries/params.js.map +1 -0
  116. package/dist/ui/server/env.js +1 -1
  117. package/dist/ui/server/index.js +2 -2
  118. package/dist/ui/server/manifest-full.js +7 -6
  119. package/dist/ui/server/manifest.js +7 -6
  120. package/dist/ui/server/nodes/0.js +1 -1
  121. package/dist/ui/server/nodes/1.js +1 -1
  122. package/dist/ui/server/nodes/2.js +1 -1
  123. package/dist/ui/server/nodes/3.js +1 -1
  124. package/dist/ui/server/nodes/4.js +1 -1
  125. package/dist/ui/server/remote-entry.js +1 -1565
  126. package/dist/ui/server/server.js +7 -6
  127. package/package.json +3 -2
  128. package/dist/ui/client/ui/_app/immutable/chunks/C67ohLw_.js +0 -1
  129. package/dist/ui/client/ui/_app/immutable/chunks/C67ohLw_.js.br +0 -3
  130. package/dist/ui/client/ui/_app/immutable/chunks/C67ohLw_.js.gz +0 -0
  131. package/dist/ui/client/ui/_app/immutable/chunks/CKeiBgOI.js +0 -1
  132. package/dist/ui/client/ui/_app/immutable/chunks/CKeiBgOI.js.br +0 -1
  133. package/dist/ui/client/ui/_app/immutable/chunks/CKeiBgOI.js.gz +0 -0
  134. package/dist/ui/client/ui/_app/immutable/chunks/CM9WugkD.js.br +0 -0
  135. package/dist/ui/client/ui/_app/immutable/chunks/CM9WugkD.js.gz +0 -0
  136. package/dist/ui/client/ui/_app/immutable/chunks/CVUOwNb5.js +0 -3
  137. package/dist/ui/client/ui/_app/immutable/chunks/CVUOwNb5.js.br +0 -0
  138. package/dist/ui/client/ui/_app/immutable/chunks/CVUOwNb5.js.gz +0 -0
  139. package/dist/ui/client/ui/_app/immutable/chunks/CXrPUR7p.js +0 -4
  140. package/dist/ui/client/ui/_app/immutable/chunks/CXrPUR7p.js.br +0 -0
  141. package/dist/ui/client/ui/_app/immutable/chunks/CXrPUR7p.js.gz +0 -0
  142. package/dist/ui/client/ui/_app/immutable/chunks/Dksil5Gu.js +0 -1
  143. package/dist/ui/client/ui/_app/immutable/chunks/Dksil5Gu.js.br +0 -0
  144. package/dist/ui/client/ui/_app/immutable/chunks/Dksil5Gu.js.gz +0 -0
  145. package/dist/ui/client/ui/_app/immutable/chunks/DnL0kOQY.js +0 -1
  146. package/dist/ui/client/ui/_app/immutable/chunks/DnL0kOQY.js.br +0 -2
  147. package/dist/ui/client/ui/_app/immutable/chunks/DnL0kOQY.js.gz +0 -0
  148. package/dist/ui/client/ui/_app/immutable/chunks/Fimt9aTv.js.br +0 -0
  149. package/dist/ui/client/ui/_app/immutable/chunks/Fimt9aTv.js.gz +0 -0
  150. package/dist/ui/client/ui/_app/immutable/chunks/h7UQ89-l.js +0 -3
  151. package/dist/ui/client/ui/_app/immutable/chunks/h7UQ89-l.js.br +0 -0
  152. package/dist/ui/client/ui/_app/immutable/chunks/h7UQ89-l.js.gz +0 -0
  153. package/dist/ui/client/ui/_app/immutable/entry/app.CBrC_IQm.js +0 -2
  154. package/dist/ui/client/ui/_app/immutable/entry/app.CBrC_IQm.js.br +0 -0
  155. package/dist/ui/client/ui/_app/immutable/entry/app.CBrC_IQm.js.gz +0 -0
  156. package/dist/ui/client/ui/_app/immutable/entry/start.uodUAHNT.js.br +0 -0
  157. package/dist/ui/client/ui/_app/immutable/entry/start.uodUAHNT.js.gz +0 -0
  158. package/dist/ui/client/ui/_app/immutable/nodes/0.kO9a4iA1.js +0 -1
  159. package/dist/ui/client/ui/_app/immutable/nodes/0.kO9a4iA1.js.br +0 -0
  160. package/dist/ui/client/ui/_app/immutable/nodes/0.kO9a4iA1.js.gz +0 -0
  161. package/dist/ui/client/ui/_app/immutable/nodes/1.jZ-iBVjE.js +0 -1
  162. package/dist/ui/client/ui/_app/immutable/nodes/1.jZ-iBVjE.js.br +0 -2
  163. package/dist/ui/client/ui/_app/immutable/nodes/1.jZ-iBVjE.js.gz +0 -0
  164. package/dist/ui/client/ui/_app/immutable/nodes/2.C9mfOUwo.js +0 -52
  165. package/dist/ui/client/ui/_app/immutable/nodes/2.C9mfOUwo.js.br +0 -0
  166. package/dist/ui/client/ui/_app/immutable/nodes/2.C9mfOUwo.js.gz +0 -0
  167. package/dist/ui/client/ui/_app/immutable/nodes/3.DcigOv3T.js +0 -5
  168. package/dist/ui/client/ui/_app/immutable/nodes/3.DcigOv3T.js.br +0 -0
  169. package/dist/ui/client/ui/_app/immutable/nodes/3.DcigOv3T.js.gz +0 -0
  170. package/dist/ui/client/ui/_app/immutable/nodes/4.DY8qq4Io.js.br +0 -0
  171. package/dist/ui/client/ui/_app/immutable/nodes/4.DY8qq4Io.js.gz +0 -0
  172. package/dist/ui/server/chunks/bridge-api.js +0 -105
  173. package/dist/ui/server/chunks/bridge-api.js.map +0 -1
  174. package/dist/ui/server/entries/endpoints/api/sessions/_id_/_server.ts.js +0 -13
  175. package/dist/ui/server/entries/endpoints/api/sessions/_id_/_server.ts.js.map +0 -1
  176. package/dist/ui/server/remote-entry.js.map +0 -1
@@ -1,6 +1,8 @@
1
+ import { t as getSessions } from "./sessions.remote.js";
1
2
  import { mt as resolve } from "./internal.js";
2
- import { a as SpeechEntrySchema, c as SessionListSchema, d as ConfigOverridesSchema, n as checkDto, o as SpeechListSchema, p as ConfigSchema, r as StatusSchema, u as StartSessionResponseSchema } from "./src.js";
3
- import "./server2.js";
3
+ import { l as SpeechEntrySchema, n as checkDto } from "./src.js";
4
+ import { c as getContext, l as setContext } from "./server2.js";
5
+ import "./index-server.js";
4
6
  // ../../node_modules/.pnpm/tslib@2.9.1/node_modules/tslib/tslib.es6.mjs
5
7
  function __decorate(decorators, target, key, desc) {
6
8
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -2562,52 +2564,61 @@ function pendingFields(active, saved) {
2562
2564
  const running = flatten(active, "", /* @__PURE__ */ new Map());
2563
2565
  return [...flatten(saved, "", /* @__PURE__ */ new Map())].filter(([path, value]) => running.get(path) !== value).map(([path]) => path);
2564
2566
  }
2567
+ // src/lib/adapters/route-request.ts
2568
+ var defaultRejection = (error, status) => new Error(error?.message ?? `The request answered ${status}`);
2569
+ /** Calls one of the UI's own routes (`url` includes the base path) and rejects unless it is ok. */
2570
+ async function routeRequest(url, { method = "GET", body, signal, rejection = defaultRejection } = {}) {
2571
+ const response = await fetch(url, {
2572
+ method,
2573
+ headers: {
2574
+ accept: "application/json",
2575
+ ...body === void 0 ? {} : { "content-type": "application/json" }
2576
+ },
2577
+ body: body === void 0 ? void 0 : JSON.stringify(body),
2578
+ signal
2579
+ });
2580
+ if (!response.ok) throw rejection(await readRouteError(response), response.status);
2581
+ return response;
2582
+ }
2583
+ /**
2584
+ * {@link routeRequest} for a JSON answer. It is not checked again: the BFF already checked the
2585
+ * bridge's answer against the contract (`lib/server/bridge-api.ts`), and only the UI calls its
2586
+ * routes. `T` is what the route answers.
2587
+ */
2588
+ async function routeJson(url, request) {
2589
+ return await (await routeRequest(url, request)).json();
2590
+ }
2591
+ async function readRouteError(response) {
2592
+ const body = await response.json().catch(() => void 0);
2593
+ if (typeof body !== "object" || body === null || !("message" in body)) return null;
2594
+ const { message } = body;
2595
+ if (typeof message !== "string") return null;
2596
+ return {
2597
+ message,
2598
+ field: "field" in body && typeof body.field === "string" ? body.field : void 0
2599
+ };
2600
+ }
2565
2601
  // src/lib/adapters/http-config-api.ts
2602
+ /** A refused save names the bridge's reason (and the setting, when it names one). */
2603
+ var rejection = (error, status) => error === null ? /* @__PURE__ */ new Error(`The request answered ${status}`) : new SettingRejected(error.message, error.field);
2566
2604
  /** Reads and saves the configuration through the UI's own config route (`url` includes the base path). */
2567
2605
  var HttpConfigApi = class {
2568
2606
  url;
2569
2607
  constructor(url) {
2570
2608
  this.url = url;
2571
2609
  }
2572
- async fetch() {
2573
- const response = await fetch(this.url, { headers: { accept: "application/json" } });
2574
- if (!response.ok) throw await rejection(response);
2575
- const body = await response.json();
2576
- const active = checkDto(ConfigSchema, body.active);
2577
- const saved = checkDto(ConfigSchema, body.saved);
2578
- const overrides = checkDto(ConfigOverridesSchema, { overrides: body.overrides });
2579
- if (!active.ok || !saved.ok || !overrides.ok) throw new Error("Unexpected configuration answer from the bridge");
2580
- return {
2581
- active: active.value,
2582
- saved: saved.value,
2583
- overrides: overrides.value.overrides
2584
- };
2610
+ /** `GET /ui/api/config` answers `{ active, saved, overrides }` in one go. */
2611
+ fetch() {
2612
+ return routeJson(this.url, { rejection });
2585
2613
  }
2586
- async update(patch) {
2587
- const response = await fetch(this.url, {
2614
+ update(patch) {
2615
+ return routeJson(this.url, {
2588
2616
  method: "PUT",
2589
- headers: {
2590
- accept: "application/json",
2591
- "content-type": "application/json"
2592
- },
2593
- body: JSON.stringify(patch)
2617
+ body: patch,
2618
+ rejection
2594
2619
  });
2595
- if (!response.ok) throw await rejection(response);
2596
- const checked = checkDto(ConfigSchema, await response.json());
2597
- if (!checked.ok) throw new Error(`Unexpected answer at ${checked.field}: ${checked.message}`);
2598
- return checked.value;
2599
2620
  }
2600
2621
  };
2601
- /** SvelteKit's `error()` answers `{ message, field? }`; fall back to the status. */
2602
- async function rejection(response) {
2603
- const body = await response.json().catch(() => void 0);
2604
- if (typeof body === "object" && body !== null && "message" in body) {
2605
- const { message } = body;
2606
- const field = "field" in body && typeof body.field === "string" ? body.field : void 0;
2607
- if (typeof message === "string") return new SettingRejected(message, field);
2608
- }
2609
- return /* @__PURE__ */ new Error(`The request answered ${response.status}`);
2610
- }
2611
2622
  // src/lib/adapters/http-speech-api.ts
2612
2623
  /** Changes the speech through the UI's own markers and speech routes (the urls include the base path). */
2613
2624
  var HttpSpeechApi = class {
@@ -2618,80 +2629,47 @@ var HttpSpeechApi = class {
2618
2629
  this.speechUrl = speechUrl;
2619
2630
  }
2620
2631
  async addMarker(label) {
2621
- const response = await fetch(this.markersUrl, {
2632
+ await routeRequest(this.markersUrl, {
2622
2633
  method: "POST",
2623
- headers: {
2624
- accept: "application/json",
2625
- "content-type": "application/json"
2626
- },
2627
- body: JSON.stringify({ label })
2634
+ body: { label }
2628
2635
  });
2629
- if (!response.ok) throw new Error(await errorMessage$1(response));
2630
2636
  }
2631
2637
  async clear(scope) {
2632
- const response = await fetch(`${this.speechUrl}?session=${encodeURIComponent(String(scope))}`, {
2633
- method: "DELETE",
2634
- headers: { accept: "application/json" }
2635
- });
2636
- if (!response.ok) throw new Error(await errorMessage$1(response));
2638
+ await routeRequest(`${this.speechUrl}?session=${scope}`, { method: "DELETE" });
2637
2639
  }
2638
2640
  };
2639
- /** SvelteKit's `error()` answers `{ message }`; fall back to the status. */
2640
- async function errorMessage$1(response) {
2641
- const body = await response.json().catch(() => void 0);
2642
- if (typeof body === "object" && body !== null && "message" in body) {
2643
- const { message } = body;
2644
- if (typeof message === "string") return message;
2645
- }
2646
- return `The request answered ${response.status}`;
2647
- }
2648
2641
  // src/lib/adapters/http-sessions-api.ts
2649
- /** Reads and changes sessions through the UI's own sessions routes (`url` includes the base path). */
2642
+ /**
2643
+ * Reads the sessions with the `getSessions` remote query and changes them through the UI's own
2644
+ * sessions routes (`url` includes the base path).
2645
+ */
2650
2646
  var HttpSessionsApi = class {
2651
2647
  url;
2652
2648
  constructor(url) {
2653
2649
  this.url = url;
2654
2650
  }
2655
- list() {
2656
- return this.send("GET", this.url, void 0, SessionListSchema);
2651
+ /** Always asks the server again: a query keeps its last answer while anything still uses it. */
2652
+ async list() {
2653
+ const sessions = getSessions();
2654
+ await sessions.refresh();
2655
+ return sessions.current;
2657
2656
  }
2658
2657
  start(name, run) {
2659
- return this.send("POST", this.url, {
2660
- name,
2661
- run
2662
- }, StartSessionResponseSchema);
2658
+ return routeJson(this.url, {
2659
+ method: "POST",
2660
+ body: {
2661
+ name,
2662
+ run
2663
+ }
2664
+ });
2663
2665
  }
2664
2666
  async end() {
2665
- await this.send("POST", `${this.url}/end`, void 0, void 0);
2667
+ await routeRequest(`${this.url}/end`, { method: "POST" });
2666
2668
  }
2667
2669
  async delete(id) {
2668
- await this.send("DELETE", `${this.url}/${id}`, void 0, void 0);
2669
- }
2670
- async send(method, url, body, schema) {
2671
- const response = await fetch(url, {
2672
- method,
2673
- headers: {
2674
- accept: "application/json",
2675
- ...body === void 0 ? {} : { "content-type": "application/json" }
2676
- },
2677
- body: body === void 0 ? void 0 : JSON.stringify(body)
2678
- });
2679
- if (!response.ok) throw new Error(await errorMessage(response));
2680
- if (schema === void 0) return void 0;
2681
- const checked = checkDto(schema, await response.json());
2682
- if (!checked.ok) throw new Error(`Unexpected answer at ${checked.field}: ${checked.message}`);
2683
- return checked.value;
2670
+ await routeRequest(`${this.url}/${id}`, { method: "DELETE" });
2684
2671
  }
2685
2672
  };
2686
- /** SvelteKit's `error()` answers `{ message }`; fall back to the status. */
2687
- async function errorMessage(response) {
2688
- const body = await response.json().catch(() => void 0);
2689
- if (typeof body === "object" && body !== null && "message" in body) {
2690
- const { message } = body;
2691
- if (typeof message === "string") return message;
2692
- }
2693
- return `The request answered ${response.status}`;
2694
- }
2695
2673
  // src/lib/adapters/sse-speech-feed.ts
2696
2674
  /** Entries read per request when an ended session is read page by page. */
2697
2675
  var PAGE_SIZE = 1e3;
@@ -2740,14 +2718,7 @@ var SseSpeechFeed = class {
2740
2718
  since: String(since),
2741
2719
  limit: String(PAGE_SIZE)
2742
2720
  });
2743
- const response = await fetch(`${this.speechUrl}?${query}`, {
2744
- headers: { accept: "application/json" },
2745
- signal: abort.signal
2746
- });
2747
- if (!response.ok) throw new Error(`The request answered ${response.status}`);
2748
- const checked = checkDto(SpeechListSchema, await response.json());
2749
- if (!checked.ok) throw new Error(`Unexpected answer at ${checked.field}`);
2750
- const { entries, hasMore } = checked.value;
2721
+ const { entries, hasMore } = await routeJson(`${this.speechUrl}?${query}`, { signal: abort.signal });
2751
2722
  handlers.onEntries(entries);
2752
2723
  const last = entries.at(-1);
2753
2724
  if (!hasMore || last === void 0) return;
@@ -2767,12 +2738,8 @@ var HttpStatusApi = class {
2767
2738
  constructor(url) {
2768
2739
  this.url = url;
2769
2740
  }
2770
- async fetch() {
2771
- const response = await fetch(this.url, { headers: { accept: "application/json" } });
2772
- if (!response.ok) throw new Error(`The status request answered ${response.status}`);
2773
- const checked = checkDto(StatusSchema, await response.json());
2774
- if (!checked.ok) throw new Error(`Unexpected status at ${checked.field}: ${checked.message}`);
2775
- return checked.value;
2741
+ fetch() {
2742
+ return routeJson(this.url);
2776
2743
  }
2777
2744
  };
2778
2745
  // src/lib/core/sessions-pane.ts
@@ -2880,11 +2847,11 @@ function createSessionsStore(api) {
2880
2847
  let loaded = false;
2881
2848
  let now = Date.now();
2882
2849
  let inFlight = null;
2883
- function apply(list) {
2850
+ function apply(list, at = Date.now()) {
2884
2851
  sessions = list.sessions;
2885
2852
  currentId = list.currentId;
2886
2853
  outsideEntries = list.outsideEntries;
2887
- now = Date.now();
2854
+ now = at;
2888
2855
  loaded = true;
2889
2856
  }
2890
2857
  function read() {
@@ -2915,7 +2882,7 @@ function createSessionsStore(api) {
2915
2882
  get outsideEntries() {
2916
2883
  return outsideEntries;
2917
2884
  },
2918
- /** Whether a list has been applied yet; until then the page shows what the server rendered. */
2885
+ /** Whether a list has been applied yet (the seed or a read). */
2919
2886
  get loaded() {
2920
2887
  return loaded;
2921
2888
  },
@@ -2927,11 +2894,18 @@ function createSessionsStore(api) {
2927
2894
  return now;
2928
2895
  },
2929
2896
  /**
2930
- * Reads the list and keeps it fresh; `seed` is the list the server rendered, so there is no
2931
- * flash. Returns the function that stops the timers (call it when the page goes away).
2897
+ * Shows the list the page's load read (`now`: when it was read), before any request of its
2898
+ * own. Call it while the page renders, on the server too: the stores are per request, so the
2899
+ * server's HTML and the first browser render agree. Does nothing once a list is shown.
2932
2900
  */
2933
- init(seed) {
2934
- if (seed && sessions.length === 0) apply(seed);
2901
+ seed(list, at) {
2902
+ if (list !== null && !loaded) apply(list, at);
2903
+ },
2904
+ /**
2905
+ * Reads the list and keeps it fresh. Call it in the browser only. Returns the function that
2906
+ * stops the timers (call it when the page goes away).
2907
+ */
2908
+ init() {
2935
2909
  read();
2936
2910
  const tick = setInterval(() => {
2937
2911
  if (currentId !== null) now = Date.now();
@@ -3123,12 +3097,32 @@ function createThemeStore(storage) {
3123
3097
  }
3124
3098
  // src/lib/composition.ts
3125
3099
  /** Wires the adapters into the stores; components get the stores, never the adapters. */
3126
- var themeStore = createThemeStore(new BrowserThemeStorage());
3127
- var statusStore = createStatusStore(new HttpStatusApi(resolve("/api/status")));
3128
- var configStore = createConfigStore(new HttpConfigApi(resolve("/api/config")));
3129
- var sessionsStore = createSessionsStore(new HttpSessionsApi(resolve("/api/sessions")));
3130
- var speechStore = createSpeechStore(new SseSpeechFeed(resolve("/api/speech/stream"), resolve("/api/speech")), new HttpSpeechApi(resolve("/api/markers"), resolve("/api/speech")));
3131
- var sessionsPaneStore = createSessionsPaneStore(new BrowserSessionsPaneStorage());
3132
- export { B as A, __decorate as B, EASING as C, t as D, i$1 as E, e$4 as F, r$1 as I, n$2 as L, T as M, Z as N, i$2 as O, e$3 as P, i$4 as R, u as S, e$1 as T, mixinElementInternals as _, statusStore as a, mixinDelegatesAria as b, canClearSpeech as c, logHeading as d, THEMES as f, internals as g, mixinFormAssociated as h, speechStore as i, E as j, A as k, canDeleteSession as l, getFormValue as m, sessionsPaneStore as n, themeStore as o, mixinFormSubmitter as p, sessionsStore as r, canAddMarker as s, configStore as t, formatReceivedTime as u, afterDispatch as v, e as w, i as x, setupDispatchHooks as y, t$3 as z };
3100
+ function createAppStores() {
3101
+ return {
3102
+ theme: createThemeStore(new BrowserThemeStorage()),
3103
+ status: createStatusStore(new HttpStatusApi(resolve("/api/status"))),
3104
+ config: createConfigStore(new HttpConfigApi(resolve("/api/config"))),
3105
+ sessions: createSessionsStore(new HttpSessionsApi(resolve("/api/sessions"))),
3106
+ speech: createSpeechStore(new SseSpeechFeed(resolve("/api/speech/stream"), resolve("/api/speech")), new HttpSpeechApi(resolve("/api/markers"), resolve("/api/speech"))),
3107
+ sessionsPane: createSessionsPaneStore(new BrowserSessionsPaneStorage())
3108
+ };
3109
+ }
3110
+ /** The context key of the stores (component tests pass their own stores under it). */
3111
+ var APP_STORES = Symbol("app-stores");
3112
+ /**
3113
+ * Creates the stores of one app and hands them to the components below (the root layout calls it).
3114
+ * Not a module-level singleton: on the server every request renders its own app, and a store
3115
+ * shared by all of them would show one viewer's state to another.
3116
+ */
3117
+ function provideAppStores() {
3118
+ return setContext(APP_STORES, createAppStores());
3119
+ }
3120
+ /** The stores {@link provideAppStores} created. Call it while a component initialises. */
3121
+ function appStores() {
3122
+ const stores = getContext(APP_STORES);
3123
+ if (stores === void 0) throw new Error("appStores() needs provideAppStores() in a parent");
3124
+ return stores;
3125
+ }
3126
+ export { e$3 as A, t as C, E as D, B as E, t$3 as F, __decorate as I, r$1 as M, n$2 as N, T as O, i$4 as P, i$1 as S, A as T, i as _, canDeleteSession as a, e as b, THEMES as c, mixinFormAssociated as d, internals as f, mixinDelegatesAria as g, setupDispatchHooks as h, canClearSpeech as i, e$4 as j, Z as k, mixinFormSubmitter as l, afterDispatch as m, provideAppStores as n, formatReceivedTime as o, mixinElementInternals as p, canAddMarker as r, logHeading as s, appStores as t, getFormValue as u, u as v, i$2 as w, e$1 as x, EASING as y };
3133
3127
 
3134
3128
  //# sourceMappingURL=composition.js.map