@screenreader-speech-capture/bridge 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/dist/cli.mjs +1109 -792
  2. package/dist/ui/adapter-node.js +1 -1
  3. package/dist/ui/client/ui/_app/immutable/chunks/BEImj5AP.js +1 -0
  4. package/dist/ui/client/ui/_app/immutable/chunks/BEImj5AP.js.br +0 -0
  5. package/dist/ui/client/ui/_app/immutable/chunks/BEImj5AP.js.gz +0 -0
  6. package/dist/ui/client/ui/_app/immutable/chunks/B__KpOuX.js +3 -0
  7. package/dist/ui/client/ui/_app/immutable/chunks/B__KpOuX.js.br +0 -0
  8. package/dist/ui/client/ui/_app/immutable/chunks/B__KpOuX.js.gz +0 -0
  9. package/dist/ui/client/ui/_app/immutable/chunks/BkoDSEOx.js +1 -0
  10. package/dist/ui/client/ui/_app/immutable/chunks/BkoDSEOx.js.br +0 -0
  11. package/dist/ui/client/ui/_app/immutable/chunks/BkoDSEOx.js.gz +0 -0
  12. package/dist/ui/client/ui/_app/immutable/chunks/BlC5mir6.js +1 -0
  13. package/dist/ui/client/ui/_app/immutable/chunks/BlC5mir6.js.br +2 -0
  14. package/dist/ui/client/ui/_app/immutable/chunks/BlC5mir6.js.gz +0 -0
  15. package/dist/ui/client/ui/_app/immutable/chunks/BquQTeuV.js +1 -0
  16. package/dist/ui/client/ui/_app/immutable/chunks/BquQTeuV.js.br +0 -0
  17. package/dist/ui/client/ui/_app/immutable/chunks/BquQTeuV.js.gz +0 -0
  18. package/dist/ui/client/ui/_app/immutable/chunks/BtnuBvK5.js +1 -0
  19. package/dist/ui/client/ui/_app/immutable/chunks/BtnuBvK5.js.br +1 -0
  20. package/dist/ui/client/ui/_app/immutable/chunks/BtnuBvK5.js.gz +0 -0
  21. package/dist/ui/client/ui/_app/immutable/chunks/{Dk73DTz3.js → BuwZGWCm.js} +21 -21
  22. package/dist/ui/client/ui/_app/immutable/chunks/BuwZGWCm.js.br +0 -0
  23. package/dist/ui/client/ui/_app/immutable/chunks/BuwZGWCm.js.gz +0 -0
  24. package/dist/ui/client/ui/_app/immutable/chunks/Bxh3K0TK.js +1 -0
  25. package/dist/ui/client/ui/_app/immutable/chunks/Bxh3K0TK.js.br +0 -0
  26. package/dist/ui/client/ui/_app/immutable/chunks/Bxh3K0TK.js.gz +0 -0
  27. package/dist/ui/client/ui/_app/immutable/chunks/C06IiL6m.js +1 -0
  28. package/dist/ui/client/ui/_app/immutable/chunks/C06IiL6m.js.br +2 -0
  29. package/dist/ui/client/ui/_app/immutable/chunks/C06IiL6m.js.gz +0 -0
  30. package/dist/ui/client/ui/_app/immutable/chunks/C75l7c5l.js +1 -0
  31. package/dist/ui/client/ui/_app/immutable/chunks/C75l7c5l.js.br +0 -0
  32. package/dist/ui/client/ui/_app/immutable/chunks/C75l7c5l.js.gz +0 -0
  33. package/dist/ui/client/ui/_app/immutable/chunks/{hhZsYtkz.js → CAZ56n62.js} +3 -3
  34. package/dist/ui/client/ui/_app/immutable/chunks/CAZ56n62.js.br +0 -0
  35. package/dist/ui/client/ui/_app/immutable/chunks/CAZ56n62.js.gz +0 -0
  36. package/dist/ui/client/ui/_app/immutable/chunks/Cb63XE4v.js +33 -0
  37. package/dist/ui/client/ui/_app/immutable/chunks/Cb63XE4v.js.br +0 -0
  38. package/dist/ui/client/ui/_app/immutable/chunks/Cb63XE4v.js.gz +0 -0
  39. package/dist/ui/client/ui/_app/immutable/chunks/DRNNJMYk.js +5 -0
  40. package/dist/ui/client/ui/_app/immutable/chunks/DRNNJMYk.js.br +0 -0
  41. package/dist/ui/client/ui/_app/immutable/chunks/DRNNJMYk.js.gz +0 -0
  42. package/dist/ui/client/ui/_app/immutable/chunks/DWjfB3ah.js +1 -0
  43. package/dist/ui/client/ui/_app/immutable/chunks/DWjfB3ah.js.br +0 -0
  44. package/dist/ui/client/ui/_app/immutable/chunks/DWjfB3ah.js.gz +0 -0
  45. package/dist/ui/client/ui/_app/immutable/chunks/JsC3ASJq.js +3 -0
  46. package/dist/ui/client/ui/_app/immutable/chunks/JsC3ASJq.js.br +0 -0
  47. package/dist/ui/client/ui/_app/immutable/chunks/JsC3ASJq.js.gz +0 -0
  48. package/dist/ui/client/ui/_app/immutable/chunks/{DU8ibkb0.js → OAsMjdHF.js} +13 -13
  49. package/dist/ui/client/ui/_app/immutable/chunks/OAsMjdHF.js.br +0 -0
  50. package/dist/ui/client/ui/_app/immutable/chunks/OAsMjdHF.js.gz +0 -0
  51. package/dist/ui/client/ui/_app/immutable/chunks/UKukklIc.js +1 -0
  52. package/dist/ui/client/ui/_app/immutable/chunks/UKukklIc.js.br +2 -0
  53. package/dist/ui/client/ui/_app/immutable/chunks/UKukklIc.js.gz +0 -0
  54. package/dist/ui/client/ui/_app/immutable/chunks/{DoG5cwE3.js → VxDST09k.js} +1 -1
  55. package/dist/ui/client/ui/_app/immutable/chunks/VxDST09k.js.br +0 -0
  56. package/dist/ui/client/ui/_app/immutable/chunks/VxDST09k.js.gz +0 -0
  57. package/dist/ui/client/ui/_app/immutable/chunks/{CEGGem4o.js → vPs9G1oN.js} +36 -36
  58. package/dist/ui/client/ui/_app/immutable/chunks/vPs9G1oN.js.br +0 -0
  59. package/dist/ui/client/ui/_app/immutable/chunks/vPs9G1oN.js.gz +0 -0
  60. package/dist/ui/client/ui/_app/immutable/chunks/{Bq3k_s8n.js → w5i9ZoX_.js} +2 -2
  61. package/dist/ui/client/ui/_app/immutable/chunks/w5i9ZoX_.js.br +0 -0
  62. package/dist/ui/client/ui/_app/immutable/chunks/w5i9ZoX_.js.gz +0 -0
  63. package/dist/ui/client/ui/_app/immutable/entry/app.B2MXuPeH.js +2 -0
  64. package/dist/ui/client/ui/_app/immutable/entry/app.B2MXuPeH.js.br +0 -0
  65. package/dist/ui/client/ui/_app/immutable/entry/app.B2MXuPeH.js.gz +0 -0
  66. package/dist/ui/client/ui/_app/immutable/entry/start.4hiWLKwq.js +2 -0
  67. package/dist/ui/client/ui/_app/immutable/entry/start.4hiWLKwq.js.br +0 -0
  68. package/dist/ui/client/ui/_app/immutable/entry/start.4hiWLKwq.js.gz +0 -0
  69. package/dist/ui/client/ui/_app/immutable/nodes/0.CEfoZ0Mb.js +1 -0
  70. package/dist/ui/client/ui/_app/immutable/nodes/0.CEfoZ0Mb.js.br +0 -0
  71. package/dist/ui/client/ui/_app/immutable/nodes/0.CEfoZ0Mb.js.gz +0 -0
  72. package/dist/ui/client/ui/_app/immutable/nodes/1.BBl7b45u.js +1 -0
  73. package/dist/ui/client/ui/_app/immutable/nodes/1.BBl7b45u.js.br +0 -0
  74. package/dist/ui/client/ui/_app/immutable/nodes/1.BBl7b45u.js.gz +0 -0
  75. package/dist/ui/client/ui/_app/immutable/nodes/2.4VpydhMh.js +1 -0
  76. package/dist/ui/client/ui/_app/immutable/nodes/2.4VpydhMh.js.br +0 -0
  77. package/dist/ui/client/ui/_app/immutable/nodes/2.4VpydhMh.js.gz +0 -0
  78. package/dist/ui/client/ui/_app/immutable/nodes/3.BzIz3rja.js +5 -0
  79. package/dist/ui/client/ui/_app/immutable/nodes/3.BzIz3rja.js.br +0 -0
  80. package/dist/ui/client/ui/_app/immutable/nodes/3.BzIz3rja.js.gz +0 -0
  81. package/dist/ui/client/ui/_app/immutable/nodes/4.B9Ke6ZBV.js +180 -0
  82. package/dist/ui/client/ui/_app/immutable/nodes/4.B9Ke6ZBV.js.br +0 -0
  83. package/dist/ui/client/ui/_app/immutable/nodes/4.B9Ke6ZBV.js.gz +0 -0
  84. package/dist/ui/client/ui/_app/immutable/nodes/5.Cm6I95kb.js +6 -0
  85. package/dist/ui/client/ui/_app/immutable/nodes/5.Cm6I95kb.js.br +0 -0
  86. package/dist/ui/client/ui/_app/immutable/nodes/5.Cm6I95kb.js.gz +0 -0
  87. package/dist/ui/client/ui/_app/immutable/nodes/6.B_1Pts2e.js +6 -0
  88. package/dist/ui/client/ui/_app/immutable/nodes/6.B_1Pts2e.js.br +0 -0
  89. package/dist/ui/client/ui/_app/immutable/nodes/6.B_1Pts2e.js.gz +0 -0
  90. package/dist/ui/client/ui/_app/version.json +1 -1
  91. package/dist/ui/client/ui/_app/version.json.br +0 -0
  92. package/dist/ui/client/ui/_app/version.json.gz +0 -0
  93. package/dist/ui/server/.vite/manifest.json +83 -38
  94. package/dist/ui/server/chunks/{composition.js → app-context.js} +5 -965
  95. package/dist/ui/server/chunks/app-context.js.map +1 -0
  96. package/dist/ui/server/chunks/config2.js +106 -0
  97. package/dist/ui/server/chunks/config2.js.map +1 -0
  98. package/dist/ui/server/chunks/dialog.js +1 -1
  99. package/dist/ui/server/chunks/instance.js +3 -3
  100. package/dist/ui/server/chunks/internal.js +1 -1
  101. package/dist/ui/server/chunks/outlined-button.js +1 -1
  102. package/dist/ui/server/chunks/outlined-text-field.js +1 -1
  103. package/dist/ui/server/chunks/redispatch-event.js +1 -1
  104. package/dist/ui/server/chunks/rolldown-runtime.js +12 -0
  105. package/dist/ui/server/chunks/rules.js +173 -0
  106. package/dist/ui/server/chunks/rules.js.map +1 -0
  107. package/dist/ui/server/chunks/sessions.remote.js +1 -11
  108. package/dist/ui/server/chunks/sessions.remote.js.map +1 -1
  109. package/dist/ui/server/chunks/setup.js +86 -0
  110. package/dist/ui/server/chunks/setup.js.map +1 -0
  111. package/dist/ui/server/chunks/{icon-button.js → speech.js} +42 -3
  112. package/dist/ui/server/chunks/speech.js.map +1 -0
  113. package/dist/ui/server/chunks/src.js +37 -183
  114. package/dist/ui/server/chunks/src.js.map +1 -1
  115. package/dist/ui/server/chunks/static-html.js +1 -1
  116. package/dist/ui/server/chunks/text-button.js +1 -1
  117. package/dist/ui/server/chunks/validate.js +23 -0
  118. package/dist/ui/server/chunks/validate.js.map +1 -0
  119. package/dist/ui/server/chunks/vocabulary.js +19 -0
  120. package/dist/ui/server/chunks/vocabulary.js.map +1 -0
  121. package/dist/ui/server/entries/endpoints/api/config/_server.ts.js +4 -2
  122. package/dist/ui/server/entries/endpoints/api/config/_server.ts.js.map +1 -1
  123. package/dist/ui/server/entries/endpoints/api/input/keys/_server.ts.js +15 -5
  124. package/dist/ui/server/entries/endpoints/api/input/keys/_server.ts.js.map +1 -1
  125. package/dist/ui/server/entries/endpoints/api/markers/_server.ts.js +4 -2
  126. package/dist/ui/server/entries/endpoints/api/markers/_server.ts.js.map +1 -1
  127. package/dist/ui/server/entries/endpoints/api/sessions/_server.ts.js +4 -2
  128. package/dist/ui/server/entries/endpoints/api/sessions/_server.ts.js.map +1 -1
  129. package/dist/ui/server/entries/endpoints/api/speech/_server.ts.js +10 -13
  130. package/dist/ui/server/entries/endpoints/api/speech/_server.ts.js.map +1 -1
  131. package/dist/ui/server/entries/endpoints/api/status/_server.ts.js +2 -1
  132. package/dist/ui/server/entries/endpoints/api/status/_server.ts.js.map +1 -1
  133. package/dist/ui/server/entries/hooks.server.js +30 -25
  134. package/dist/ui/server/entries/hooks.server.js.map +1 -1
  135. package/dist/ui/server/entries/pages/_layout.svelte.js +750 -3
  136. package/dist/ui/server/entries/pages/_layout.svelte.js.map +1 -1
  137. package/dist/ui/server/entries/pages/_page.svelte.js +34 -25
  138. package/dist/ui/server/entries/pages/_page.svelte.js.map +1 -1
  139. package/dist/ui/server/entries/pages/settings/_page.svelte.js +5 -3
  140. package/dist/ui/server/entries/pages/settings/_page.svelte.js.map +1 -1
  141. package/dist/ui/server/entries/pages/setup/_page.svelte.js +2 -1
  142. package/dist/ui/server/entries/pages/setup/_page.svelte.js.map +1 -1
  143. package/dist/ui/server/entries/pages/setup/instructions/_page.svelte.js +3 -2
  144. package/dist/ui/server/entries/pages/setup/instructions/_page.svelte.js.map +1 -1
  145. package/dist/ui/server/manifest-full.js +1 -1
  146. package/dist/ui/server/manifest.js +1 -1
  147. package/dist/ui/server/nodes/0.js +1 -1
  148. package/dist/ui/server/nodes/1.js +1 -1
  149. package/dist/ui/server/nodes/2.js +1 -1
  150. package/dist/ui/server/nodes/3.js +1 -1
  151. package/dist/ui/server/nodes/4.js +1 -1
  152. package/dist/ui/server/nodes/5.js +1 -1
  153. package/dist/ui/server/nodes/6.js +1 -1
  154. package/dist/ui/server/server.js +1 -1
  155. package/package.json +1 -1
  156. package/dist/ui/client/ui/_app/immutable/chunks/0FroJ-XN.js +0 -3
  157. package/dist/ui/client/ui/_app/immutable/chunks/0FroJ-XN.js.br +0 -0
  158. package/dist/ui/client/ui/_app/immutable/chunks/0FroJ-XN.js.gz +0 -0
  159. package/dist/ui/client/ui/_app/immutable/chunks/B_ZElYu_.js +0 -1
  160. package/dist/ui/client/ui/_app/immutable/chunks/B_ZElYu_.js.br +0 -2
  161. package/dist/ui/client/ui/_app/immutable/chunks/B_ZElYu_.js.gz +0 -0
  162. package/dist/ui/client/ui/_app/immutable/chunks/Bq3k_s8n.js.br +0 -0
  163. package/dist/ui/client/ui/_app/immutable/chunks/Bq3k_s8n.js.gz +0 -0
  164. package/dist/ui/client/ui/_app/immutable/chunks/CEGGem4o.js.br +0 -0
  165. package/dist/ui/client/ui/_app/immutable/chunks/CEGGem4o.js.gz +0 -0
  166. package/dist/ui/client/ui/_app/immutable/chunks/CVpgcnu3.js +0 -1
  167. package/dist/ui/client/ui/_app/immutable/chunks/CVpgcnu3.js.br +0 -0
  168. package/dist/ui/client/ui/_app/immutable/chunks/CVpgcnu3.js.gz +0 -0
  169. package/dist/ui/client/ui/_app/immutable/chunks/Cwz551Q0.js +0 -5
  170. package/dist/ui/client/ui/_app/immutable/chunks/Cwz551Q0.js.br +0 -0
  171. package/dist/ui/client/ui/_app/immutable/chunks/Cwz551Q0.js.gz +0 -0
  172. package/dist/ui/client/ui/_app/immutable/chunks/D-2Nx62w.js +0 -1
  173. package/dist/ui/client/ui/_app/immutable/chunks/D-2Nx62w.js.br +0 -4
  174. package/dist/ui/client/ui/_app/immutable/chunks/D-2Nx62w.js.gz +0 -0
  175. package/dist/ui/client/ui/_app/immutable/chunks/DHsTyp2W.js +0 -1
  176. package/dist/ui/client/ui/_app/immutable/chunks/DHsTyp2W.js.br +0 -2
  177. package/dist/ui/client/ui/_app/immutable/chunks/DHsTyp2W.js.gz +0 -0
  178. package/dist/ui/client/ui/_app/immutable/chunks/DJvJc_zO.js +0 -33
  179. package/dist/ui/client/ui/_app/immutable/chunks/DJvJc_zO.js.br +0 -0
  180. package/dist/ui/client/ui/_app/immutable/chunks/DJvJc_zO.js.gz +0 -0
  181. package/dist/ui/client/ui/_app/immutable/chunks/DU8ibkb0.js.br +0 -0
  182. package/dist/ui/client/ui/_app/immutable/chunks/DU8ibkb0.js.gz +0 -0
  183. package/dist/ui/client/ui/_app/immutable/chunks/Dk73DTz3.js.br +0 -0
  184. package/dist/ui/client/ui/_app/immutable/chunks/Dk73DTz3.js.gz +0 -0
  185. package/dist/ui/client/ui/_app/immutable/chunks/DoG5cwE3.js.br +0 -3
  186. package/dist/ui/client/ui/_app/immutable/chunks/DoG5cwE3.js.gz +0 -0
  187. package/dist/ui/client/ui/_app/immutable/chunks/Dvxhfd7j.js +0 -3
  188. package/dist/ui/client/ui/_app/immutable/chunks/Dvxhfd7j.js.br +0 -0
  189. package/dist/ui/client/ui/_app/immutable/chunks/Dvxhfd7j.js.gz +0 -0
  190. package/dist/ui/client/ui/_app/immutable/chunks/DzInmTUe.js +0 -1
  191. package/dist/ui/client/ui/_app/immutable/chunks/DzInmTUe.js.br +0 -1
  192. package/dist/ui/client/ui/_app/immutable/chunks/DzInmTUe.js.gz +0 -0
  193. package/dist/ui/client/ui/_app/immutable/chunks/hhZsYtkz.js.br +0 -0
  194. package/dist/ui/client/ui/_app/immutable/chunks/hhZsYtkz.js.gz +0 -0
  195. package/dist/ui/client/ui/_app/immutable/entry/app.Bic9wlww.js +0 -2
  196. package/dist/ui/client/ui/_app/immutable/entry/app.Bic9wlww.js.br +0 -0
  197. package/dist/ui/client/ui/_app/immutable/entry/app.Bic9wlww.js.gz +0 -0
  198. package/dist/ui/client/ui/_app/immutable/entry/start.DqIv9xYX.js +0 -2
  199. package/dist/ui/client/ui/_app/immutable/entry/start.DqIv9xYX.js.br +0 -0
  200. package/dist/ui/client/ui/_app/immutable/entry/start.DqIv9xYX.js.gz +0 -0
  201. package/dist/ui/client/ui/_app/immutable/nodes/0.IqK6bsxB.js +0 -1
  202. package/dist/ui/client/ui/_app/immutable/nodes/0.IqK6bsxB.js.br +0 -0
  203. package/dist/ui/client/ui/_app/immutable/nodes/0.IqK6bsxB.js.gz +0 -0
  204. package/dist/ui/client/ui/_app/immutable/nodes/1.C81neQJL.js +0 -1
  205. package/dist/ui/client/ui/_app/immutable/nodes/1.C81neQJL.js.br +0 -0
  206. package/dist/ui/client/ui/_app/immutable/nodes/1.C81neQJL.js.gz +0 -0
  207. package/dist/ui/client/ui/_app/immutable/nodes/2.CmlyeAx_.js +0 -1
  208. package/dist/ui/client/ui/_app/immutable/nodes/2.CmlyeAx_.js.br +0 -0
  209. package/dist/ui/client/ui/_app/immutable/nodes/2.CmlyeAx_.js.gz +0 -0
  210. package/dist/ui/client/ui/_app/immutable/nodes/3.DYZ3H5TS.js +0 -5
  211. package/dist/ui/client/ui/_app/immutable/nodes/3.DYZ3H5TS.js.br +0 -0
  212. package/dist/ui/client/ui/_app/immutable/nodes/3.DYZ3H5TS.js.gz +0 -0
  213. package/dist/ui/client/ui/_app/immutable/nodes/4.Lwlmq1AY.js +0 -180
  214. package/dist/ui/client/ui/_app/immutable/nodes/4.Lwlmq1AY.js.br +0 -0
  215. package/dist/ui/client/ui/_app/immutable/nodes/4.Lwlmq1AY.js.gz +0 -0
  216. package/dist/ui/client/ui/_app/immutable/nodes/5.rBMVkFpN.js +0 -6
  217. package/dist/ui/client/ui/_app/immutable/nodes/5.rBMVkFpN.js.br +0 -0
  218. package/dist/ui/client/ui/_app/immutable/nodes/5.rBMVkFpN.js.gz +0 -0
  219. package/dist/ui/client/ui/_app/immutable/nodes/6.nui9awM2.js +0 -6
  220. package/dist/ui/client/ui/_app/immutable/nodes/6.nui9awM2.js.br +0 -0
  221. package/dist/ui/client/ui/_app/immutable/nodes/6.nui9awM2.js.gz +0 -0
  222. package/dist/ui/server/chunks/composition.js.map +0 -1
  223. package/dist/ui/server/chunks/icon-button.js.map +0 -1
@@ -1,9 +1,5 @@
1
- import { t as getSessions } from "./sessions.remote.js";
2
- import { nt as resolve } from "./internal.js";
3
- import { _ as CONFIG_LIMITS, n as checkDto, u as SpeechEntrySchema, v as EXACT_VERSION_PATTERN } from "./src.js";
4
- import { l as getContext, u as setContext } from "./server2.js";
1
+ import { l as getContext } from "./server2.js";
5
2
  import "./index-server.js";
6
- import "./paths.js";
7
3
  // ../../node_modules/.pnpm/tslib@2.9.1/node_modules/tslib/tslib.es6.mjs
8
4
  function __decorate(decorators, target, key, desc) {
9
5
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -2553,971 +2549,15 @@ function mixinFormSubmitter(base) {
2553
2549
  __decorate([n$1({ reflect: true })], FormSubmitterElement.prototype, "value", void 0);
2554
2550
  return FormSubmitterElement;
2555
2551
  }
2556
- // src/lib/adapters/browser-clipboard.ts
2557
- /**
2558
- * The browser's clipboard. `navigator.clipboard` only exists in a secure context, and the bridge
2559
- * speaks plain HTTP: opened from another machine, the old selection command has to do it.
2560
- */
2561
- var BrowserClipboard = class {
2562
- async copy(text) {
2563
- const modern = navigator.clipboard;
2564
- if (modern !== void 0) try {
2565
- await modern.writeText(text);
2566
- return true;
2567
- } catch {}
2568
- return copySelected(text);
2569
- }
2570
- };
2571
- /** Copies through a text area that exists only for this, then gives the focus back. */
2572
- function copySelected(text) {
2573
- const focused = document.activeElement;
2574
- const area = document.createElement("textarea");
2575
- area.value = text;
2576
- area.readOnly = true;
2577
- area.setAttribute("aria-hidden", "true");
2578
- Object.assign(area.style, {
2579
- position: "fixed",
2580
- top: "0",
2581
- left: "0",
2582
- opacity: "0"
2583
- });
2584
- document.body.append(area);
2585
- try {
2586
- area.select();
2587
- return document.execCommand("copy");
2588
- } catch {
2589
- return false;
2590
- } finally {
2591
- area.remove();
2592
- if (focused instanceof HTMLElement) focused.focus({ preventScroll: true });
2593
- }
2594
- }
2595
- // src/lib/core/theme.ts
2596
- var DEFAULT_THEME = "light";
2597
- /** The choices in the order the settings page lists them. */
2598
- var THEMES = [
2599
- {
2600
- value: "light",
2601
- label: "Light",
2602
- description: "Default light scheme."
2603
- },
2604
- {
2605
- value: "dark",
2606
- label: "Dark",
2607
- description: "Default dark scheme."
2608
- },
2609
- {
2610
- value: "high-contrast",
2611
- label: "High contrast",
2612
- description: "White surface, black text, 2px outlines."
2613
- },
2614
- {
2615
- value: "dark-high-contrast",
2616
- label: "Dark high contrast",
2617
- description: "Black surface, white text, 2px outlines."
2618
- }
2619
- ];
2620
- function parseTheme(raw) {
2621
- return THEMES.find((t) => t.value === raw)?.value ?? null;
2622
- }
2623
- // src/lib/adapters/browser-theme-storage.ts
2624
- var THEME_STORAGE_KEY = "sr-theme";
2625
- /** Keeps the theme in `localStorage` and applies it as `data-theme` on `<html>`. */
2626
- var BrowserThemeStorage = class {
2627
- read() {
2628
- try {
2629
- return parseTheme(localStorage.getItem(THEME_STORAGE_KEY));
2630
- } catch {
2631
- return null;
2632
- }
2633
- }
2634
- write(theme) {
2635
- document.documentElement.dataset.theme = theme;
2636
- try {
2637
- localStorage.setItem(THEME_STORAGE_KEY, theme);
2638
- } catch {}
2639
- }
2640
- };
2641
- // src/lib/core/config.ts
2642
- /** The bridge (or the BFF) refused a setting; `field` is its dotted path when it names one. */
2643
- var SettingRejected = class extends Error {
2644
- field;
2645
- constructor(message, field) {
2646
- super(message);
2647
- this.field = field;
2648
- this.name = "SettingRejected";
2649
- }
2650
- };
2651
- function flatten(value, path, into) {
2652
- if (typeof value === "object" && value !== null && !Array.isArray(value)) for (const [key, inner] of Object.entries(value)) flatten(inner, path === "" ? key : `${path}.${key}`, into);
2653
- else into.set(path, JSON.stringify(value));
2654
- return into;
2655
- }
2656
- /**
2657
- * The dotted paths of the settings whose saved value differs from the one in use: they wait for a
2658
- * restart of the bridge.
2659
- */
2660
- function pendingFields(active, saved) {
2661
- const running = flatten(active, "", /* @__PURE__ */ new Map());
2662
- return [...flatten(saved, "", /* @__PURE__ */ new Map())].filter(([path, value]) => running.get(path) !== value).map(([path]) => path);
2663
- }
2664
- var PORT_MESSAGE = "Enter a port from 1 to 65535.";
2665
- /**
2666
- * Reads a port as typed. Only whole numbers from 1 to 65535: the API also takes 0 (a random
2667
- * port), but a voice that has its port built in can't find that one.
2668
- */
2669
- function parsePort(text) {
2670
- const trimmed = text.trim();
2671
- if (!/^\d{1,5}$/.test(trimmed)) return {
2672
- ok: false,
2673
- message: PORT_MESSAGE
2674
- };
2675
- const port = Number(trimmed);
2676
- return port >= 1 && port <= 65535 ? {
2677
- ok: true,
2678
- port
2679
- } : {
2680
- ok: false,
2681
- message: PORT_MESSAGE
2682
- };
2683
- }
2684
- var PLAYWRIGHT_VERSION_MESSAGE = "Enter an exact version like 1.65.0, or leave the field empty.";
2685
- /** Reads a Playwright version as typed: an exact version, or empty for the bundled one (`null`). */
2686
- function parsePlaywrightVersion(text) {
2687
- const trimmed = text.trim();
2688
- if (trimmed === "") return {
2689
- ok: true,
2690
- version: null
2691
- };
2692
- return EXACT_VERSION_PATTERN.test(trimmed) ? {
2693
- ok: true,
2694
- version: trimmed
2695
- } : {
2696
- ok: false,
2697
- message: PLAYWRIGHT_VERSION_MESSAGE
2698
- };
2699
- }
2700
- var { min: MIN_ENTRIES, max: MAX_ENTRIES } = CONFIG_LIMITS.maxEntries;
2701
- var MAX_ENTRIES_MESSAGE = `Enter a whole number from ${MIN_ENTRIES} to ${MAX_ENTRIES}.`;
2702
- /** Reads the size of the speech buffer as typed: a whole number within the API's limits. */
2703
- function parseMaxEntries(text) {
2704
- const trimmed = text.trim();
2705
- const entries = /^\d+$/.test(trimmed) ? Number(trimmed) : NaN;
2706
- return entries >= MIN_ENTRIES && entries <= MAX_ENTRIES ? {
2707
- ok: true,
2708
- entries
2709
- } : {
2710
- ok: false,
2711
- message: MAX_ENTRIES_MESSAGE
2712
- };
2713
- }
2714
- // src/lib/adapters/route-request.ts
2715
- var defaultRejection = (error, status) => new Error(error?.message ?? `The request answered ${status}`);
2716
- /** Calls one of the UI's own routes (`url` includes the base path) and rejects unless it is ok. */
2717
- async function routeRequest(url, { method = "GET", body, signal, rejection = defaultRejection } = {}) {
2718
- const response = await fetch(url, {
2719
- method,
2720
- headers: {
2721
- accept: "application/json",
2722
- ...body === void 0 ? {} : { "content-type": "application/json" }
2723
- },
2724
- body: body === void 0 ? void 0 : JSON.stringify(body),
2725
- signal
2726
- });
2727
- if (!response.ok) throw rejection(await readRouteError(response), response.status);
2728
- return response;
2729
- }
2730
- /**
2731
- * {@link routeRequest} for a JSON answer. It is not checked again: the BFF already checked the
2732
- * bridge's answer against the contract (`lib/server/bridge-api.ts`), and only the UI calls its
2733
- * routes. `T` is what the route answers.
2734
- */
2735
- async function routeJson(url, request) {
2736
- return await (await routeRequest(url, request)).json();
2737
- }
2738
- async function readRouteError(response) {
2739
- const body = await response.json().catch(() => void 0);
2740
- if (typeof body !== "object" || body === null || !("message" in body)) return null;
2741
- const { message } = body;
2742
- if (typeof message !== "string") return null;
2743
- return {
2744
- message,
2745
- field: "field" in body && typeof body.field === "string" ? body.field : void 0
2746
- };
2747
- }
2748
- // src/lib/adapters/http-config-api.ts
2749
- /** A refused save names the bridge's reason (and the setting, when it names one). */
2750
- var rejection = (error, status) => error === null ? /* @__PURE__ */ new Error(`The request answered ${status}`) : new SettingRejected(error.message, error.field);
2751
- /** Reads and saves the configuration through the UI's own config route (`url` includes the base path). */
2752
- var HttpConfigApi = class {
2753
- url;
2754
- constructor(url) {
2755
- this.url = url;
2756
- }
2757
- /** `GET /ui/api/config` answers `{ active, saved, overrides }` in one go. */
2758
- fetch() {
2759
- return routeJson(this.url, { rejection });
2760
- }
2761
- update(patch) {
2762
- return routeJson(this.url, {
2763
- method: "PUT",
2764
- body: patch,
2765
- rejection
2766
- });
2767
- }
2768
- };
2769
- // src/lib/adapters/http-keys-api.ts
2770
- /** Sends key presses through the UI's own route (`url` includes the base path). */
2771
- var HttpKeysApi = class {
2772
- url;
2773
- constructor(url) {
2774
- this.url = url;
2775
- }
2776
- async press(keys) {
2777
- await routeRequest(this.url, {
2778
- method: "POST",
2779
- body: { keys }
2780
- });
2781
- }
2782
- };
2783
- // src/lib/adapters/http-speech-api.ts
2784
- /** Changes the speech through the UI's own markers and speech routes (the urls include the base path). */
2785
- var HttpSpeechApi = class {
2786
- markersUrl;
2787
- speechUrl;
2788
- constructor(markersUrl, speechUrl) {
2789
- this.markersUrl = markersUrl;
2790
- this.speechUrl = speechUrl;
2791
- }
2792
- async addMarker(label) {
2793
- await routeRequest(this.markersUrl, {
2794
- method: "POST",
2795
- body: { label }
2796
- });
2797
- }
2798
- async clear(scope) {
2799
- await routeRequest(`${this.speechUrl}?session=${scope}`, { method: "DELETE" });
2800
- }
2801
- };
2802
- // src/lib/adapters/http-sessions-api.ts
2803
- /**
2804
- * Reads the sessions with the `getSessions` remote query and changes them through the UI's own
2805
- * sessions routes (`url` includes the base path).
2806
- */
2807
- var HttpSessionsApi = class {
2808
- url;
2809
- constructor(url) {
2810
- this.url = url;
2811
- }
2812
- /** Always asks the server again: a query keeps its last answer while anything still uses it. */
2813
- async list() {
2814
- const sessions = getSessions();
2815
- await sessions.refresh();
2816
- return sessions.current;
2817
- }
2818
- start(name, run) {
2819
- return routeJson(this.url, {
2820
- method: "POST",
2821
- body: {
2822
- name,
2823
- run
2824
- }
2825
- });
2826
- }
2827
- async end() {
2828
- await routeRequest(`${this.url}/end`, { method: "POST" });
2829
- }
2830
- async delete(id) {
2831
- await routeRequest(`${this.url}/${id}`, { method: "DELETE" });
2832
- }
2833
- };
2834
- // src/lib/adapters/sse-speech-feed.ts
2835
- /** Entries read per request when an ended session is read page by page. */
2836
- var PAGE_SIZE = 1e3;
2837
- /**
2838
- * Reads the speech of a scope through the UI's own routes (`urls` include the base path):
2839
- * - A live scope is followed on the stream relay with `?since=0`, so the bridge replays the
2840
- * buffer first. `EventSource` reconnects by itself and sends `Last-Event-ID`, so a drop only
2841
- * shows as `reconnecting` and the missed entries are replayed. A refused stream shows as
2842
- * `failed`.
2843
- * - An ended session never gets new entries: it is read page by page, once, without a stream.
2844
- */
2845
- var SseSpeechFeed = class {
2846
- streamUrl;
2847
- speechUrl;
2848
- constructor(streamUrl, speechUrl) {
2849
- this.streamUrl = streamUrl;
2850
- this.speechUrl = speechUrl;
2851
- }
2852
- open(scope, live, handlers) {
2853
- handlers.onState("connecting");
2854
- return live ? this.follow(scope, handlers) : this.read(scope, handlers);
2855
- }
2856
- listen(since, handlers) {
2857
- const source = this.stream(`since=${since}`, (entry) => handlers.onEntry(entry));
2858
- this.report(source, (state) => handlers.onState(state));
2859
- return () => source.close();
2860
- }
2861
- follow(scope, handlers) {
2862
- const source = this.stream(`session=${encodeURIComponent(String(scope))}&since=0`, (entry) => handlers.onEntry(entry));
2863
- this.report(source, (state) => handlers.onState(state));
2864
- source.addEventListener("clear", () => handlers.onClear());
2865
- return () => source.close();
2866
- }
2867
- report(source, onState) {
2868
- source.onopen = () => onState("live");
2869
- source.onerror = () => onState(source.readyState === EventSource.CLOSED ? "failed" : "reconnecting");
2870
- }
2871
- stream(query, onEntry) {
2872
- const source = new EventSource(`${this.streamUrl}?${query}`);
2873
- source.addEventListener("entry", (event) => {
2874
- let data;
2875
- try {
2876
- data = JSON.parse(event.data);
2877
- } catch {
2878
- return;
2879
- }
2880
- const checked = checkDto(SpeechEntrySchema, data);
2881
- if (checked.ok) onEntry(checked.value);
2882
- });
2883
- return source;
2884
- }
2885
- read(scope, handlers) {
2886
- const abort = new AbortController();
2887
- const load = async () => {
2888
- let since = 0;
2889
- for (;;) {
2890
- const query = new URLSearchParams({
2891
- session: String(scope),
2892
- since: String(since),
2893
- limit: String(PAGE_SIZE)
2894
- });
2895
- const { entries, hasMore } = await routeJson(`${this.speechUrl}?${query}`, { signal: abort.signal });
2896
- handlers.onEntries(entries);
2897
- const last = entries.at(-1);
2898
- if (!hasMore || last === void 0) return;
2899
- since = last.seq;
2900
- }
2901
- };
2902
- load().then(() => handlers.onState("ended"), () => {
2903
- if (!abort.signal.aborted) handlers.onState("failed");
2904
- });
2905
- return () => abort.abort();
2906
- }
2907
- };
2908
- // src/lib/adapters/http-status-api.ts
2909
- /** Reads the bridge status through the UI's own status route (`url` includes the base path). */
2910
- var HttpStatusApi = class {
2911
- url;
2912
- constructor(url) {
2913
- this.url = url;
2914
- }
2915
- fetch() {
2916
- return routeJson(this.url);
2917
- }
2918
- };
2919
- // src/lib/core/sessions-pane.ts
2920
- /** Parses the stored text; anything but `'1'` / `'0'` counts as no choice. */
2921
- function parseCollapsed(raw) {
2922
- if (raw === "1") return true;
2923
- if (raw === "0") return false;
2924
- return null;
2925
- }
2926
- function serializeCollapsed(collapsed) {
2927
- return collapsed ? "1" : "0";
2928
- }
2929
- // src/lib/adapters/browser-sessions-pane-storage.ts
2930
- var SESSIONS_PANE_STORAGE_KEY = "sr-sessions-collapsed";
2931
- /** Keeps the sessions pane's collapsed choice in `localStorage`. */
2932
- var BrowserSessionsPaneStorage = class {
2933
- read() {
2934
- try {
2935
- return parseCollapsed(localStorage.getItem(SESSIONS_PANE_STORAGE_KEY));
2936
- } catch {
2937
- return null;
2938
- }
2939
- }
2940
- write(collapsed) {
2941
- try {
2942
- localStorage.setItem(SESSIONS_PANE_STORAGE_KEY, serializeCollapsed(collapsed));
2943
- } catch {}
2944
- }
2945
- };
2946
- // src/lib/stores/config.svelte.ts
2947
- function createConfigStore(api) {
2948
- let state = null;
2949
- let reachable = true;
2950
- let reading = false;
2951
- let inFlight = null;
2952
- function read() {
2953
- if (inFlight) return inFlight;
2954
- reading = true;
2955
- inFlight = api.fetch().then((next) => {
2956
- state = next;
2957
- reachable = true;
2958
- }).catch(() => {
2959
- reachable = false;
2960
- }).finally(() => {
2961
- inFlight = null;
2962
- reading = false;
2963
- });
2964
- return inFlight;
2965
- }
2966
- return {
2967
- /** Whether a configuration has been read yet. */
2968
- get loaded() {
2969
- return state !== null;
2970
- },
2971
- get reachable() {
2972
- return reachable;
2973
- },
2974
- /** Whether a read of the configuration is under way. */
2975
- get reading() {
2976
- return reading;
2977
- },
2978
- get active() {
2979
- return state?.active ?? null;
2980
- },
2981
- get saved() {
2982
- return state?.saved ?? null;
2983
- },
2984
- /** Settings a flag or variable sets, by dotted path, with what sets them. */
2985
- get overrides() {
2986
- return state?.overrides ?? {};
2987
- },
2988
- /** Dotted paths of the saved settings that wait for a restart. */
2989
- get pending() {
2990
- return state === null ? [] : pendingFields(state.active, state.saved);
2991
- },
2992
- /**
2993
- * Shows the configuration the page's load read, before any request of its own. Call it while
2994
- * the page renders, on the server too: the stores are per request, so the server's HTML and the
2995
- * first browser render agree. Unlike a list that is polled, every load's answer replaces what
2996
- * is shown; `null` (the load failed) changes nothing.
2997
- */
2998
- seed(next) {
2999
- if (next === null) return;
3000
- state = next;
3001
- reachable = true;
3002
- },
3003
- /** Reads the configuration now (also after a failed read, to try again). */
3004
- refresh() {
3005
- return read();
3006
- },
3007
- /** Saves a partial config for the next start. Rejects with the bridge's message. */
3008
- async save(patch) {
3009
- await api.update(patch);
3010
- await inFlight;
3011
- await read();
3012
- }
3013
- };
3014
- }
3015
- // src/lib/stores/sessions-pane.svelte.ts
3016
- function createSessionsPaneStore(storage) {
3017
- let collapsed = true;
3018
- return {
3019
- get collapsed() {
3020
- return collapsed;
3021
- },
3022
- /** Pick up the saved choice. Call it in the browser only, after hydration. */
3023
- init() {
3024
- collapsed = storage.read() ?? false;
3025
- },
3026
- toggle() {
3027
- collapsed = !collapsed;
3028
- storage.write(collapsed);
3029
- }
3030
- };
3031
- }
3032
- // src/lib/stores/sessions.svelte.ts
3033
- var REFRESH_MS = 3e3;
3034
- function createSessionsStore(api) {
3035
- let sessions = [];
3036
- let currentId = null;
3037
- let outsideEntries = 0;
3038
- let reachable = true;
3039
- let loaded = false;
3040
- let now = Date.now();
3041
- let inFlight = null;
3042
- function apply(list, at = Date.now()) {
3043
- sessions = list.sessions;
3044
- currentId = list.currentId;
3045
- outsideEntries = list.outsideEntries;
3046
- now = at;
3047
- loaded = true;
3048
- }
3049
- function read() {
3050
- if (inFlight) return inFlight;
3051
- inFlight = api.list().then((list) => {
3052
- apply(list);
3053
- reachable = true;
3054
- }).catch(() => {
3055
- reachable = false;
3056
- }).finally(() => {
3057
- inFlight = null;
3058
- });
3059
- return inFlight;
3060
- }
3061
- /** A read that started before the change would show the old list, so wait for it and read again. */
3062
- async function refreshAfterChange() {
3063
- await inFlight;
3064
- await read();
3065
- }
3066
- return {
3067
- get sessions() {
3068
- return sessions;
3069
- },
3070
- get currentId() {
3071
- return currentId;
3072
- },
3073
- /** Entries in the buffer recorded outside any session. */
3074
- get outsideEntries() {
3075
- return outsideEntries;
3076
- },
3077
- /** Whether a list has been applied yet (the seed or a read). */
3078
- get loaded() {
3079
- return loaded;
3080
- },
3081
- get reachable() {
3082
- return reachable;
3083
- },
3084
- /** Epoch ms, ticking once a second while a session is live (for its duration). */
3085
- get now() {
3086
- return now;
3087
- },
3088
- /**
3089
- * Shows the list the page's load read (`now`: when it was read), before any request of its
3090
- * own. Call it while the page renders, on the server too: the stores are per request, so the
3091
- * server's HTML and the first browser render agree. Does nothing once a list is shown.
3092
- */
3093
- seed(list, at) {
3094
- if (list !== null && !loaded) apply(list, at);
3095
- },
3096
- /**
3097
- * Reads the list and keeps it fresh. Call it in the browser only. Returns the function that
3098
- * stops the timers (call it when the page goes away).
3099
- */
3100
- init() {
3101
- read();
3102
- const tick = setInterval(() => {
3103
- if (currentId !== null) now = Date.now();
3104
- }, 1e3);
3105
- const refresh = setInterval(() => void read(), REFRESH_MS);
3106
- return () => {
3107
- clearInterval(tick);
3108
- clearInterval(refresh);
3109
- };
3110
- },
3111
- /** Reads the list now, for a change made elsewhere (the speech of a scope was cleared). */
3112
- refresh() {
3113
- return refreshAfterChange();
3114
- },
3115
- /** Starts a session, which ends the previous one. Rejects with the bridge's message. */
3116
- async start(name, run) {
3117
- const started = await api.start(name, run);
3118
- await refreshAfterChange();
3119
- return started;
3120
- },
3121
- async end() {
3122
- await api.end();
3123
- await refreshAfterChange();
3124
- },
3125
- /** Deletes an ended session. Rejects with the bridge's message. */
3126
- async delete(id) {
3127
- await api.delete(id);
3128
- await refreshAfterChange();
3129
- }
3130
- };
3131
- }
3132
- // src/lib/core/speech.ts
3133
- /** The table keeps this many rows; the oldest go first (the bridge's own buffer is capped too). */
3134
- var MAX_ROWS = 5e3;
3135
- /**
3136
- * Whether a marker added now shows up in `scope`. The bridge files a marker under the current
3137
- * session, or outside any session when none is current: it has no way to name another scope.
3138
- */
3139
- function canAddMarker(scope, currentId) {
3140
- return currentId === null ? scope === "none" : scope === currentId;
3141
- }
3142
- /**
3143
- * Whether the log can clear `scope`: the current session or the speech outside sessions, the scopes
3144
- * that can still receive speech. An ended session can only be deleted.
3145
- */
3146
- function canClearSpeech(scope, currentId) {
3147
- return isLiveScope(scope, currentId);
3148
- }
3149
- /** Whether the log can delete `scope`: an ended session, never the current one or the outside log. */
3150
- function canDeleteSession(scope, currentId) {
3151
- return scope !== "none" && scope !== currentId;
3152
- }
3153
- /** Whether new speech can still arrive in `scope`. */
3154
- function isLiveScope(scope, currentId) {
3155
- return scope === "none" || scope === currentId;
3156
- }
3157
- /** `14:03:07.042` in the browser's time zone. */
3158
- function formatReceivedTime(iso) {
3159
- const date = new Date(iso);
3160
- if (Number.isNaN(date.getTime())) return iso;
3161
- const two = (value) => String(value).padStart(2, "0");
3162
- const millis = String(date.getMilliseconds()).padStart(3, "0");
3163
- return `${two(date.getHours())}:${two(date.getMinutes())}:${two(date.getSeconds())}.${millis}`;
3164
- }
3165
- /** `Checkout flow #3`, or what the log shows when no session is selected. */
3166
- function logHeading(scope, sessions) {
3167
- if (scope === "none") return "Records outside sessions";
3168
- const session = sessions.find((candidate) => candidate.id === scope);
3169
- return session === void 0 ? `#${scope}` : `${session.name} #${session.id}`;
3170
- }
3171
- // src/lib/stores/speech.svelte.ts
3172
- function createSpeechStore(feed, api) {
3173
- let entries = [];
3174
- let connection = "connecting";
3175
- let close = null;
3176
- function stop() {
3177
- close?.();
3178
- close = null;
3179
- }
3180
- /** Adds entries newer than the last one shown (a replay after a reconnect repeats some). */
3181
- function append(added) {
3182
- let lastSeq = entries.at(-1)?.seq ?? 0;
3183
- const fresh = [];
3184
- for (const entry of added) {
3185
- if (entry.seq <= lastSeq) continue;
3186
- fresh.push(entry);
3187
- lastSeq = entry.seq;
3188
- }
3189
- if (fresh.length === 0) return;
3190
- const next = [...entries, ...fresh];
3191
- entries = next.length > 5e3 ? next.slice(next.length - MAX_ROWS) : next;
3192
- }
3193
- return {
3194
- get entries() {
3195
- return entries;
3196
- },
3197
- get connection() {
3198
- return connection;
3199
- },
3200
- /**
3201
- * Shows the speech of `scope`, replacing what was shown. A live scope replays the buffer and
3202
- * follows; an ended session is read once. After a reconnect the stream resumes where it left
3203
- * off, and an entry seen twice is dropped. Returns the function that stops the stream.
3204
- */
3205
- open(scope, live) {
3206
- stop();
3207
- entries = [];
3208
- connection = "connecting";
3209
- close = feed.open(scope, live, {
3210
- onEntry: (entry) => append([entry]),
3211
- onEntries: append,
3212
- onClear() {
3213
- entries = [];
3214
- },
3215
- onState(state) {
3216
- connection = state;
3217
- }
3218
- });
3219
- return stop;
3220
- },
3221
- /** Rejects with the reason; the table empties through the feed (the bridge's `clear` event). */
3222
- clear(scope) {
3223
- return api.clear(scope);
3224
- },
3225
- /** Rejects with the reason; the new entry arrives through the feed, so nothing is added here. */
3226
- addMarker(label) {
3227
- return api.addMarker(label);
3228
- }
3229
- };
3230
- }
3231
- // src/lib/stores/status.svelte.ts
3232
- function createStatusStore(api) {
3233
- let status = null;
3234
- let reachable = true;
3235
- let loading = false;
3236
- let inFlight = null;
3237
- function read() {
3238
- if (inFlight) return inFlight;
3239
- loading = true;
3240
- inFlight = api.fetch().then((next) => {
3241
- status = next;
3242
- reachable = true;
3243
- }).catch(() => {
3244
- reachable = false;
3245
- }).finally(() => {
3246
- loading = false;
3247
- inFlight = null;
3248
- });
3249
- return inFlight;
3250
- }
3251
- return {
3252
- get status() {
3253
- return status;
3254
- },
3255
- get reachable() {
3256
- return reachable;
3257
- },
3258
- get loading() {
3259
- return loading;
3260
- },
3261
- /** Reads the status once; `seed` is the status the server rendered, so there is no flash. */
3262
- init(seed) {
3263
- if (seed && status === null) status = seed;
3264
- read();
3265
- },
3266
- /** The refresh button. */
3267
- retry() {
3268
- return read();
3269
- }
3270
- };
3271
- }
3272
- // src/lib/stores/theme.svelte.ts
3273
- function createThemeStore(storage) {
3274
- let current = DEFAULT_THEME;
3275
- return {
3276
- get current() {
3277
- return current;
3278
- },
3279
- /** Pick up the saved choice. Call it in the browser only, after hydration. */
3280
- init() {
3281
- current = storage.read() ?? "light";
3282
- },
3283
- /** Apply and remember a choice. */
3284
- set(theme) {
3285
- current = theme;
3286
- storage.write(theme);
3287
- }
3288
- };
3289
- }
3290
- // src/lib/core/setup.ts
3291
- /** The keys of the check: "read the window title" in NVDA and JAWS. */
3292
- var CHECK_CHORD = "Insert+T";
3293
- /** The marker in front of the check's keys, so the speech they cause is told apart. */
3294
- var CHECK_MARKER = `ui: ${CHECK_CHORD}`;
3295
- /** How long the check waits for speech someone makes by hand. */
3296
- var LISTEN_TIMEOUT_MS = 3e4;
3297
- /** How long it waits for speech after it sent the keys. */
3298
- var KEYS_TIMEOUT_MS = 5e3;
3299
- /** After the first speech, the check collects what follows until nothing came for this long. */
3300
- var QUIET_MS = 1e3;
3301
- /** The id of the screen reader heading in the Setup instructions, where the check links to. */
3302
- var SCREEN_READER_ID = "screen-reader-heading";
3303
- var DOCS_URL = "https://github.com/TimoSto/screenreader-speech-capture/blob";
3304
- /**
3305
- * A page of `docs/` on GitHub, as of the bridge's release. Only stable releases are tagged, so a
3306
- * preview, a development build and an unknown version read `main`.
3307
- */
3308
- function docsUrl(version, path) {
3309
- return `${DOCS_URL}/${version !== null && /^\d+\.\d+\.\d+$/.test(version) ? `@screenreader-speech-capture/bridge@${version}` : "main"}/docs/${path}`;
3310
- }
3311
- /** Where the libraries behind a feature live, by the `backend` name the bridge reports. */
3312
- var LIBRARY_REPOS = /* @__PURE__ */ new Map([["robotjs", "https://github.com/jitsi/robotjs"], ["koffi", "https://github.com/Koromix/koffi"]]);
3313
- /** What the bridge itself knows about the setup, one row each. */
3314
- function deriveCheckRows(status) {
3315
- const link = (label, path) => ({
3316
- label,
3317
- href: docsUrl(status.bridge.version, path)
3318
- });
3319
- const row = (id, label, tone, state, help, library = null) => ({
3320
- id,
3321
- label,
3322
- tone,
3323
- state,
3324
- library,
3325
- help: tone === "ok" ? null : "path" in help ? link(help.label, help.path) : help
3326
- });
3327
- const { listening, port, encoding, connections } = status.tcp;
3328
- const voices = [...new Set(connections.flatMap(({ voice }) => voice === null ? [] : [voice]))];
3329
- const count = connections.length === 1 ? "1 connection" : `${connections.length} connections`;
3330
- const input = (id, label, { available, backend, reason }, help) => row(id, label, available ? "ok" : "warning", available ? "Available" : `Not available: ${reason ?? "no reason given"}`, help, backend === null ? null : {
3331
- name: backend,
3332
- href: LIBRARY_REPOS.get(backend) ?? null
3333
- });
3334
- const service = (id, label, { state, version }) => {
3335
- const [tone, words] = {
3336
- running: ["ok", `Running, version ${version}`],
3337
- starting: ["neutral", `Starting, version ${version}`],
3338
- stopped: ["neutral", "Off"],
3339
- crashed: ["warning", `Crashed, version ${version}. It restarts by itself.`],
3340
- failed: ["warning", `Failed, version ${version}`]
3341
- }[state];
3342
- return row(id, label, tone, words, {
3343
- label: "Child services",
3344
- path: "usage/operations.md#child-service-crashes"
3345
- });
3346
- };
3347
- return [
3348
- row("listener", "Speech listener", listening ? "ok" : "warning", listening ? `Listening on port ${port} (${encoding})` : `Not listening on port ${port}`, {
3349
- label: "Troubleshooting",
3350
- path: "usage/troubleshooting.md#speech"
3351
- }),
3352
- row("voice", "Voice connected", connections.length > 0 ? "ok" : "neutral", connections.length > 0 ? `${count}${voices.length > 0 ? ` (voice ${voices.join(", ")})` : ""}` : "None yet: the voice connects with its first words", {
3353
- label: "Select the voice",
3354
- screenReader: true
3355
- }),
3356
- input("input", "Native input", status.input.native, {
3357
- label: "Troubleshooting",
3358
- path: "usage/troubleshooting.md#browser-and-input"
3359
- }),
3360
- input("focus", "Window focus", status.input.focus, {
3361
- label: "Bringing the browser to the front",
3362
- path: "usage/native-input.md#bringing-the-browser-to-the-front"
3363
- }),
3364
- service("playwright", "Playwright server", status.playwright),
3365
- service("mcp", "Playwright MCP", status.mcp)
3366
- ];
3367
- }
3368
- // src/lib/stores/voice-check.svelte.ts
3369
- function createVoiceCheckStore(statusApi, probe, keysApi, speechApi) {
3370
- let phase = "idle";
3371
- let via = "manual";
3372
- let entries = [];
3373
- let reconnecting = false;
3374
- let failure = "";
3375
- /** Counts the runs: whatever answers for an earlier one is ignored. */
3376
- let run = 0;
3377
- let close = null;
3378
- let timer;
3379
- /** Ends the current run: its stream, its timer and every answer still to come. */
3380
- function finish() {
3381
- run++;
3382
- clearTimeout(timer);
3383
- close?.();
3384
- close = null;
3385
- reconnecting = false;
3386
- }
3387
- function fail(message) {
3388
- finish();
3389
- phase = "failed";
3390
- failure = message;
3391
- }
3392
- /** Gives up after `ms`. A lost connection is a failure, not silence. */
3393
- function giveUpAfter(ms) {
3394
- timer = setTimeout(() => {
3395
- if (reconnecting) {
3396
- fail("The connection to the bridge was lost.");
3397
- return;
3398
- }
3399
- finish();
3400
- phase = "silent";
3401
- }, ms);
3402
- }
3403
- return {
3404
- get phase() {
3405
- return phase;
3406
- },
3407
- get via() {
3408
- return via;
3409
- },
3410
- /** The speech that arrived, oldest first. */
3411
- get entries() {
3412
- return entries;
3413
- },
3414
- get reconnecting() {
3415
- return reconnecting;
3416
- },
3417
- /** Why the check failed. */
3418
- get failure() {
3419
- return failure;
3420
- },
3421
- /**
3422
- * Waits for new speech. With `keys` it also sends {@link CHECK_CHORD}, after a marker, and
3423
- * only counts the speech after that marker. Replaces a run that is still going.
3424
- */
3425
- async start(how) {
3426
- finish();
3427
- const mine = run;
3428
- via = how;
3429
- phase = "starting";
3430
- entries = [];
3431
- failure = "";
3432
- let since;
3433
- try {
3434
- since = (await statusApi.fetch()).buffer.lastSeq ?? 0;
3435
- } catch {
3436
- if (mine === run) fail("The bridge is not reachable.");
3437
- return;
3438
- }
3439
- if (mine !== run) return;
3440
- let counting = how === "manual";
3441
- phase = "listening";
3442
- close = probe.listen(since, {
3443
- onEntry(entry) {
3444
- if (mine !== run) return;
3445
- if (entry.kind === "marker") {
3446
- if (entry.text === "ui: Insert+T") counting = true;
3447
- return;
3448
- }
3449
- if (!counting) return;
3450
- entries = [...entries, entry];
3451
- phase = "heard";
3452
- clearTimeout(timer);
3453
- if (entries.length >= 5) finish();
3454
- else timer = setTimeout(finish, QUIET_MS);
3455
- },
3456
- onState(state) {
3457
- if (mine !== run) return;
3458
- if (state !== "failed") reconnecting = state === "reconnecting";
3459
- else if (phase === "heard") finish();
3460
- else fail("The speech stream is not available.");
3461
- }
3462
- });
3463
- if (how === "manual") {
3464
- giveUpAfter(LISTEN_TIMEOUT_MS);
3465
- return;
3466
- }
3467
- try {
3468
- await speechApi.addMarker(CHECK_MARKER);
3469
- if (mine !== run) return;
3470
- await keysApi.press(CHECK_CHORD);
3471
- } catch (cause) {
3472
- if (mine === run && entries.length === 0) fail(cause instanceof Error ? cause.message : "The keys could not be sent.");
3473
- return;
3474
- }
3475
- if (mine === run && entries.length === 0) giveUpAfter(KEYS_TIMEOUT_MS);
3476
- },
3477
- /** Stops listening and forgets the result. */
3478
- stop() {
3479
- finish();
3480
- phase = "idle";
3481
- entries = [];
3482
- failure = "";
3483
- }
3484
- };
3485
- }
3486
- // src/lib/composition.ts
3487
- /** Wires the adapters into the stores; components get the stores, never the adapters. */
3488
- function createAppStores() {
3489
- const statusApi = new HttpStatusApi(resolve("/api/status"));
3490
- const speechFeed = new SseSpeechFeed(resolve("/api/speech/stream"), resolve("/api/speech"));
3491
- const speechApi = new HttpSpeechApi(resolve("/api/markers"), resolve("/api/speech"));
3492
- const clipboard = new BrowserClipboard();
3493
- return {
3494
- theme: createThemeStore(new BrowserThemeStorage()),
3495
- status: createStatusStore(statusApi),
3496
- config: createConfigStore(new HttpConfigApi(resolve("/api/config"))),
3497
- sessions: createSessionsStore(new HttpSessionsApi(resolve("/api/sessions"))),
3498
- speech: createSpeechStore(speechFeed, speechApi),
3499
- voiceCheck: createVoiceCheckStore(statusApi, speechFeed, new HttpKeysApi(resolve("/api/input/keys")), speechApi),
3500
- sessionsPane: createSessionsPaneStore(new BrowserSessionsPaneStorage()),
3501
- /** A port without state, so there is no store around it. */
3502
- clipboard
3503
- };
3504
- }
2552
+ // src/lib/app-context.ts
3505
2553
  /** The context key of the stores (component tests pass their own stores under it). */
3506
2554
  var APP_STORES = Symbol("app-stores");
3507
- /**
3508
- * Creates the stores of one app and hands them to the components below (the root layout calls it).
3509
- * Not a module-level singleton: on the server every request renders its own app, and a store
3510
- * shared by all of them would show one viewer's state to another.
3511
- */
3512
- function provideAppStores() {
3513
- return setContext(APP_STORES, createAppStores());
3514
- }
3515
- /** The stores {@link provideAppStores} created. Call it while a component initialises. */
2555
+ /** The stores the root layout provided. Call it while a component initialises. */
3516
2556
  function appStores() {
3517
2557
  const stores = getContext(APP_STORES);
3518
2558
  if (stores === void 0) throw new Error("appStores() needs provideAppStores() in a parent");
3519
2559
  return stores;
3520
2560
  }
3521
- export { i as A, e$3 as B, afterDispatch as C, createAnimationSignal as D, EASING as E, E as F, t$3 as G, r$1 as H, T as I, __decorate as K, Z as L, i$1 as M, A as N, e as O, B as P, b as R, mixinElementInternals as S, mixinDelegatesAria as T, n$1 as U, e$4 as V, i$3 as W, THEMES as _, deriveCheckRows as a, mixinFormAssociated as b, canClearSpeech as c, logHeading as d, SettingRejected as f, pendingFields as g, parsePort as h, SCREEN_READER_ID as i, t as j, e$1 as k, canDeleteSession as l, parsePlaywrightVersion as m, provideAppStores as n, docsUrl as o, parseMaxEntries as p, CHECK_CHORD as r, canAddMarker as s, appStores as t, formatReceivedTime as u, mixinFormSubmitter as v, setupDispatchHooks as w, internals as x, getFormValue as y, w as z };
2561
+ export { t$3 as A, b as C, r$1 as D, e$4 as E, n$1 as O, Z as S, e$3 as T, i$1 as _, mixinFormAssociated as a, E as b, afterDispatch as c, EASING as d, createAnimationSignal as f, t as g, i as h, getFormValue as i, __decorate as j, i$3 as k, setupDispatchHooks as l, e$1 as m, appStores as n, internals as o, e as p, mixinFormSubmitter as r, mixinElementInternals as s, APP_STORES as t, mixinDelegatesAria as u, A as v, w, T as x, B as y };
3522
2562
 
3523
- //# sourceMappingURL=composition.js.map
2563
+ //# sourceMappingURL=app-context.js.map