@screenreader-speech-capture/bridge 0.3.0 → 0.4.1

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 (160) hide show
  1. package/dist/cli.mjs +4965 -4771
  2. package/dist/ui/adapter-node.js +1 -1
  3. package/dist/ui/client/ui/_app/immutable/assets/0.C_wdfB9t.css +1 -0
  4. package/dist/ui/client/ui/_app/immutable/assets/0.C_wdfB9t.css.br +0 -0
  5. package/dist/ui/client/ui/_app/immutable/assets/0.C_wdfB9t.css.gz +0 -0
  6. package/dist/ui/client/ui/_app/immutable/assets/2.GfBw0twm.css +1 -0
  7. package/dist/ui/client/ui/_app/immutable/assets/2.GfBw0twm.css.br +0 -0
  8. package/dist/ui/client/ui/_app/immutable/assets/2.GfBw0twm.css.gz +0 -0
  9. package/dist/ui/client/ui/_app/immutable/assets/3.C6Oee9hv.css +1 -0
  10. package/dist/ui/client/ui/_app/immutable/assets/3.C6Oee9hv.css.br +0 -0
  11. package/dist/ui/client/ui/_app/immutable/assets/3.C6Oee9hv.css.gz +0 -0
  12. package/dist/ui/client/ui/_app/immutable/assets/4.DwCEZqGT.css +1 -0
  13. package/dist/ui/client/ui/_app/immutable/assets/4.DwCEZqGT.css.br +0 -0
  14. package/dist/ui/client/ui/_app/immutable/assets/4.DwCEZqGT.css.gz +0 -0
  15. package/dist/ui/client/ui/_app/immutable/assets/5.DVcIZgbI.css +1 -0
  16. package/dist/ui/client/ui/_app/immutable/assets/5.DVcIZgbI.css.br +0 -0
  17. package/dist/ui/client/ui/_app/immutable/assets/5.DVcIZgbI.css.gz +0 -0
  18. package/dist/ui/client/ui/_app/immutable/assets/6.CgsZgeqQ.css +1 -0
  19. package/dist/ui/client/ui/_app/immutable/assets/6.CgsZgeqQ.css.br +0 -0
  20. package/dist/ui/client/ui/_app/immutable/assets/6.CgsZgeqQ.css.gz +0 -0
  21. package/dist/ui/client/ui/_app/immutable/assets/ActionDialog.DaaxszBK.css +1 -0
  22. package/dist/ui/client/ui/_app/immutable/assets/ActionDialog.DaaxszBK.css.br +0 -0
  23. package/dist/ui/client/ui/_app/immutable/assets/ActionDialog.DaaxszBK.css.gz +0 -0
  24. package/dist/ui/client/ui/_app/immutable/assets/Pane.DsGQzOhZ.css +1 -0
  25. package/dist/ui/client/ui/_app/immutable/assets/Pane.DsGQzOhZ.css.br +4 -0
  26. package/dist/ui/client/ui/_app/immutable/assets/Pane.DsGQzOhZ.css.gz +0 -0
  27. package/dist/ui/client/ui/_app/immutable/chunks/{Cb63XE4v.js → DbGQpjFg.js} +1 -1
  28. package/dist/ui/client/ui/_app/immutable/chunks/DbGQpjFg.js.br +0 -0
  29. package/dist/ui/client/ui/_app/immutable/chunks/DbGQpjFg.js.gz +0 -0
  30. package/dist/ui/client/ui/_app/immutable/chunks/{OAsMjdHF.js → cBM7TtzK.js} +13 -13
  31. package/dist/ui/client/ui/_app/immutable/chunks/cBM7TtzK.js.br +0 -0
  32. package/dist/ui/client/ui/_app/immutable/chunks/cBM7TtzK.js.gz +0 -0
  33. package/dist/ui/client/ui/_app/immutable/entry/app.sg1O-aaT.js +2 -0
  34. package/dist/ui/client/ui/_app/immutable/entry/app.sg1O-aaT.js.br +0 -0
  35. package/dist/ui/client/ui/_app/immutable/entry/app.sg1O-aaT.js.gz +0 -0
  36. package/dist/ui/client/ui/_app/immutable/nodes/0.ChTQinKu.js +1 -0
  37. package/dist/ui/client/ui/_app/immutable/nodes/0.ChTQinKu.js.br +0 -0
  38. package/dist/ui/client/ui/_app/immutable/nodes/0.ChTQinKu.js.gz +0 -0
  39. package/dist/ui/client/ui/_app/immutable/nodes/{2.4VpydhMh.js → 2.Bmw_bms2.js} +1 -1
  40. package/dist/ui/client/ui/_app/immutable/nodes/2.Bmw_bms2.js.br +0 -0
  41. package/dist/ui/client/ui/_app/immutable/nodes/2.Bmw_bms2.js.gz +0 -0
  42. package/dist/ui/client/ui/_app/immutable/nodes/3.D1KLwmTV.js +5 -0
  43. package/dist/ui/client/ui/_app/immutable/nodes/3.D1KLwmTV.js.br +0 -0
  44. package/dist/ui/client/ui/_app/immutable/nodes/3.D1KLwmTV.js.gz +0 -0
  45. package/dist/ui/client/ui/_app/immutable/nodes/{4.B9Ke6ZBV.js → 4.DxLsBVbm.js} +4 -4
  46. package/dist/ui/client/ui/_app/immutable/nodes/4.DxLsBVbm.js.br +0 -0
  47. package/dist/ui/client/ui/_app/immutable/nodes/4.DxLsBVbm.js.gz +0 -0
  48. package/dist/ui/client/ui/_app/immutable/nodes/5.mJKxiKw-.js +6 -0
  49. package/dist/ui/client/ui/_app/immutable/nodes/5.mJKxiKw-.js.br +0 -0
  50. package/dist/ui/client/ui/_app/immutable/nodes/5.mJKxiKw-.js.gz +0 -0
  51. package/dist/ui/client/ui/_app/immutable/nodes/6.BH9jsHQr.js +7 -0
  52. package/dist/ui/client/ui/_app/immutable/nodes/6.BH9jsHQr.js.br +0 -0
  53. package/dist/ui/client/ui/_app/immutable/nodes/6.BH9jsHQr.js.gz +0 -0
  54. package/dist/ui/client/ui/_app/version.json +1 -1
  55. package/dist/ui/client/ui/_app/version.json.br +0 -0
  56. package/dist/ui/client/ui/_app/version.json.gz +0 -0
  57. package/dist/ui/server/.vite/manifest.json +37 -28
  58. package/dist/ui/server/_app/immutable/assets/ActionDialog.DaaxszBK.css +1 -0
  59. package/dist/ui/server/_app/immutable/assets/Pane.DsGQzOhZ.css +1 -0
  60. package/dist/ui/server/_app/immutable/assets/_layout.C_wdfB9t.css +1 -0
  61. package/dist/ui/server/_app/immutable/assets/_layout.GfBw0twm.css +1 -0
  62. package/dist/ui/server/_app/immutable/assets/_page.C6Oee9hv.css +1 -0
  63. package/dist/ui/server/_app/immutable/assets/_page.CgsZgeqQ.css +1 -0
  64. package/dist/ui/server/_app/immutable/assets/_page.DVcIZgbI.css +1 -0
  65. package/dist/ui/server/_app/immutable/assets/_page.DwCEZqGT.css +1 -0
  66. package/dist/ui/server/chunks/{dialog.js → ActionDialog.js} +16 -2
  67. package/dist/ui/server/chunks/ActionDialog.js.map +1 -0
  68. package/dist/ui/server/chunks/Pane.js.map +1 -1
  69. package/dist/ui/server/chunks/instance.js +3 -3
  70. package/dist/ui/server/chunks/internal.js +1 -1
  71. package/dist/ui/server/chunks/sessions.js.map +1 -1
  72. package/dist/ui/server/chunks/setup.js.map +1 -1
  73. package/dist/ui/server/chunks/speech.js.map +1 -1
  74. package/dist/ui/server/chunks/src.js +43 -34
  75. package/dist/ui/server/chunks/src.js.map +1 -1
  76. package/dist/ui/server/chunks/validate.js.map +1 -1
  77. package/dist/ui/server/entries/endpoints/api/sessions/_id_id_/end/_server.ts.js +9 -0
  78. package/dist/ui/server/entries/endpoints/api/sessions/_id_id_/end/_server.ts.js.map +1 -0
  79. package/dist/ui/server/entries/hooks.server.js +3 -6
  80. package/dist/ui/server/entries/hooks.server.js.map +1 -1
  81. package/dist/ui/server/entries/pages/_layout.svelte.js +94 -78
  82. package/dist/ui/server/entries/pages/_layout.svelte.js.map +1 -1
  83. package/dist/ui/server/entries/pages/_page.server.ts.js.map +1 -1
  84. package/dist/ui/server/entries/pages/_page.svelte.js +121 -78
  85. package/dist/ui/server/entries/pages/_page.svelte.js.map +1 -1
  86. package/dist/ui/server/entries/pages/settings/_page.server.ts.js.map +1 -1
  87. package/dist/ui/server/entries/pages/settings/_page.svelte.js +15 -16
  88. package/dist/ui/server/entries/pages/settings/_page.svelte.js.map +1 -1
  89. package/dist/ui/server/entries/pages/setup/_layout.svelte.js.map +1 -1
  90. package/dist/ui/server/entries/pages/setup/_page.svelte.js +24 -13
  91. package/dist/ui/server/entries/pages/setup/_page.svelte.js.map +1 -1
  92. package/dist/ui/server/entries/pages/setup/instructions/_page.svelte.js +83 -59
  93. package/dist/ui/server/entries/pages/setup/instructions/_page.svelte.js.map +1 -1
  94. package/dist/ui/server/manifest-full.js +8 -8
  95. package/dist/ui/server/manifest.js +8 -8
  96. package/dist/ui/server/nodes/0.js +2 -2
  97. package/dist/ui/server/nodes/2.js +2 -2
  98. package/dist/ui/server/nodes/3.js +2 -2
  99. package/dist/ui/server/nodes/4.js +2 -2
  100. package/dist/ui/server/nodes/5.js +2 -2
  101. package/dist/ui/server/nodes/6.js +2 -2
  102. package/dist/ui/server/server.js +8 -8
  103. package/package.json +1 -1
  104. package/dist/ui/client/ui/_app/immutable/assets/0.ONZWQgDA.css +0 -1
  105. package/dist/ui/client/ui/_app/immutable/assets/0.ONZWQgDA.css.br +0 -0
  106. package/dist/ui/client/ui/_app/immutable/assets/0.ONZWQgDA.css.gz +0 -0
  107. package/dist/ui/client/ui/_app/immutable/assets/2.DSVNnDlO.css +0 -1
  108. package/dist/ui/client/ui/_app/immutable/assets/2.DSVNnDlO.css.br +0 -3
  109. package/dist/ui/client/ui/_app/immutable/assets/2.DSVNnDlO.css.gz +0 -0
  110. package/dist/ui/client/ui/_app/immutable/assets/3.WduKm4aT.css +0 -1
  111. package/dist/ui/client/ui/_app/immutable/assets/3.WduKm4aT.css.br +0 -0
  112. package/dist/ui/client/ui/_app/immutable/assets/3.WduKm4aT.css.gz +0 -0
  113. package/dist/ui/client/ui/_app/immutable/assets/4.DEk4yqpA.css +0 -1
  114. package/dist/ui/client/ui/_app/immutable/assets/4.DEk4yqpA.css.br +0 -0
  115. package/dist/ui/client/ui/_app/immutable/assets/4.DEk4yqpA.css.gz +0 -0
  116. package/dist/ui/client/ui/_app/immutable/assets/5.YyxFzHED.css +0 -1
  117. package/dist/ui/client/ui/_app/immutable/assets/5.YyxFzHED.css.br +0 -0
  118. package/dist/ui/client/ui/_app/immutable/assets/5.YyxFzHED.css.gz +0 -0
  119. package/dist/ui/client/ui/_app/immutable/assets/6.C0Nhvs_m.css +0 -1
  120. package/dist/ui/client/ui/_app/immutable/assets/6.C0Nhvs_m.css.br +0 -0
  121. package/dist/ui/client/ui/_app/immutable/assets/6.C0Nhvs_m.css.gz +0 -0
  122. package/dist/ui/client/ui/_app/immutable/assets/Pane.Dgdg5KMw.css +0 -1
  123. package/dist/ui/client/ui/_app/immutable/assets/Pane.Dgdg5KMw.css.br +0 -0
  124. package/dist/ui/client/ui/_app/immutable/assets/Pane.Dgdg5KMw.css.gz +0 -0
  125. package/dist/ui/client/ui/_app/immutable/chunks/Cb63XE4v.js.br +0 -0
  126. package/dist/ui/client/ui/_app/immutable/chunks/Cb63XE4v.js.gz +0 -0
  127. package/dist/ui/client/ui/_app/immutable/chunks/OAsMjdHF.js.br +0 -0
  128. package/dist/ui/client/ui/_app/immutable/chunks/OAsMjdHF.js.gz +0 -0
  129. package/dist/ui/client/ui/_app/immutable/entry/app.B2MXuPeH.js +0 -2
  130. package/dist/ui/client/ui/_app/immutable/entry/app.B2MXuPeH.js.br +0 -0
  131. package/dist/ui/client/ui/_app/immutable/entry/app.B2MXuPeH.js.gz +0 -0
  132. package/dist/ui/client/ui/_app/immutable/nodes/0.CEfoZ0Mb.js +0 -1
  133. package/dist/ui/client/ui/_app/immutable/nodes/0.CEfoZ0Mb.js.br +0 -0
  134. package/dist/ui/client/ui/_app/immutable/nodes/0.CEfoZ0Mb.js.gz +0 -0
  135. package/dist/ui/client/ui/_app/immutable/nodes/2.4VpydhMh.js.br +0 -0
  136. package/dist/ui/client/ui/_app/immutable/nodes/2.4VpydhMh.js.gz +0 -0
  137. package/dist/ui/client/ui/_app/immutable/nodes/3.BzIz3rja.js +0 -5
  138. package/dist/ui/client/ui/_app/immutable/nodes/3.BzIz3rja.js.br +0 -0
  139. package/dist/ui/client/ui/_app/immutable/nodes/3.BzIz3rja.js.gz +0 -0
  140. package/dist/ui/client/ui/_app/immutable/nodes/4.B9Ke6ZBV.js.br +0 -0
  141. package/dist/ui/client/ui/_app/immutable/nodes/4.B9Ke6ZBV.js.gz +0 -0
  142. package/dist/ui/client/ui/_app/immutable/nodes/5.Cm6I95kb.js +0 -6
  143. package/dist/ui/client/ui/_app/immutable/nodes/5.Cm6I95kb.js.br +0 -0
  144. package/dist/ui/client/ui/_app/immutable/nodes/5.Cm6I95kb.js.gz +0 -0
  145. package/dist/ui/client/ui/_app/immutable/nodes/6.B_1Pts2e.js +0 -6
  146. package/dist/ui/client/ui/_app/immutable/nodes/6.B_1Pts2e.js.br +0 -0
  147. package/dist/ui/client/ui/_app/immutable/nodes/6.B_1Pts2e.js.gz +0 -0
  148. package/dist/ui/server/_app/immutable/assets/Pane.Dgdg5KMw.css +0 -1
  149. package/dist/ui/server/_app/immutable/assets/_layout.DSVNnDlO.css +0 -1
  150. package/dist/ui/server/_app/immutable/assets/_layout.ONZWQgDA.css +0 -1
  151. package/dist/ui/server/_app/immutable/assets/_page.C0Nhvs_m.css +0 -1
  152. package/dist/ui/server/_app/immutable/assets/_page.DEk4yqpA.css +0 -1
  153. package/dist/ui/server/_app/immutable/assets/_page.WduKm4aT.css +0 -1
  154. package/dist/ui/server/_app/immutable/assets/_page.YyxFzHED.css +0 -1
  155. package/dist/ui/server/chunks/dialog.js.map +0 -1
  156. package/dist/ui/server/entries/endpoints/api/sessions/end/_server.ts.js +0 -9
  157. package/dist/ui/server/entries/endpoints/api/sessions/end/_server.ts.js.map +0 -1
  158. /package/dist/ui/client/ui/_app/immutable/chunks/{BlC5mir6.js → D-UxlRn_.js} +0 -0
  159. /package/dist/ui/client/ui/_app/immutable/chunks/{BlC5mir6.js.br → D-UxlRn_.js.br} +0 -0
  160. /package/dist/ui/client/ui/_app/immutable/chunks/{BlC5mir6.js.gz → D-UxlRn_.js.gz} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"validate.js","names":["v.safeParse","v.getDotPath"],"sources":["../../../../shared/src/validate.ts"],"sourcesContent":["import * as v from 'valibot';\n\n/** A schema of the API contract (`SpeechEntrySchema`, …). */\nexport type DtoSchema = v.GenericSchema;\n\n/** The DTO type a schema describes. */\nexport type DtoOf<S extends DtoSchema> = v.InferOutput<S>;\n\n/** What {@link checkDto} found: the DTO, or the first field that doesn't match and why. */\nexport type DtoCheck<S extends DtoSchema> =\n | { readonly ok: true; readonly value: DtoOf<S> }\n | { readonly ok: false; readonly field: string; readonly message: string };\n\n/**\n * Checks `value` against `schema`. Unknown keys of an answer don't fail it and are left out of the\n * result: a newer bridge of the same major version may add fields. The request schemas are strict\n * and refuse them (docs/usage/http-api.md#requests).\n */\nexport function checkDto<S extends DtoSchema>(schema: S, value: unknown): DtoCheck<S> {\n const result = v.safeParse(schema, value);\n if (result.success) return { ok: true, value: result.output };\n const [issue] = result.issues;\n return { ok: false, field: v.getDotPath(issue) ?? '(body)', message: issue.message };\n}\n"],"mappings":";;;;;;;AAkBA,SAAgB,SAA8B,QAAW,OAA6B;CACpF,MAAM,SAASA,UAAY,QAAQ,KAAK;CACxC,IAAI,OAAO,SAAS,OAAO;EAAE,IAAI;EAAM,OAAO,OAAO;CAAO;CAC5D,MAAM,CAAC,SAAS,OAAO;CACvB,OAAO;EAAE,IAAI;EAAO,OAAOC,WAAa,KAAK,KAAK;EAAU,SAAS,MAAM;CAAQ;AACrF"}
1
+ {"version":3,"file":"validate.js","names":["v.safeParse","v.getDotPath"],"sources":["../../../../shared/src/validate.ts"],"sourcesContent":["import * as v from 'valibot';\n\n/** A schema of the API contract (`SpeechEntrySchema`, …). */\nexport type DtoSchema = v.GenericSchema;\n\nexport type DtoOf<S extends DtoSchema> = v.InferOutput<S>;\n\n/** What {@link checkDto} found: the DTO, or the first field that doesn't match and why. */\nexport type DtoCheck<S extends DtoSchema> =\n | { readonly ok: true; readonly value: DtoOf<S> }\n | { readonly ok: false; readonly field: string; readonly message: string };\n\n/**\n * Checks `value` against `schema`. Unknown keys of an answer don't fail it and are left out of the\n * result: a newer bridge of the same major version may add fields. The request schemas are strict\n * and refuse them (docs/usage/http-api.md#requests).\n */\nexport function checkDto<S extends DtoSchema>(schema: S, value: unknown): DtoCheck<S> {\n const result = v.safeParse(schema, value);\n if (result.success) return { ok: true, value: result.output };\n const [issue] = result.issues;\n return { ok: false, field: v.getDotPath(issue) ?? '(body)', message: issue.message };\n}\n"],"mappings":";;;;;;;AAiBA,SAAgB,SAA8B,QAAW,OAA6B;CACpF,MAAM,SAASA,UAAY,QAAQ,KAAK;CACxC,IAAI,OAAO,SAAS,OAAO;EAAE,IAAI;EAAM,OAAO,OAAO;CAAO;CAC5D,MAAM,CAAC,SAAS,OAAO;CACvB,OAAO;EAAE,IAAI;EAAO,OAAOC,WAAa,KAAK,KAAK;EAAU,SAAS,MAAM;CAAQ;AACrF"}
@@ -0,0 +1,9 @@
1
+ // src/routes/api/sessions/[id=id]/end/+server.ts
2
+ /** Ends the session, if it is the current one (nothing happens otherwise). */
3
+ var POST = async ({ params, locals }) => {
4
+ await locals.bridge.endSession(params.id);
5
+ return new Response(null, { status: 204 });
6
+ };
7
+ export { POST };
8
+
9
+ //# sourceMappingURL=_server.ts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_server.ts.js","names":[],"sources":["../../../../../../../../src/routes/api/sessions/[id=id]/end/+server.ts"],"sourcesContent":["import type { RequestHandler } from './$types';\n\n/** Ends the session, if it is the current one (nothing happens otherwise). */\nexport const POST: RequestHandler = async ({ params, locals }) => {\n await locals.bridge.endSession(params.id);\n return new Response(null, { status: 204 });\n};\n"],"mappings":";;AAGA,IAAa,OAAuB,OAAO,EAAE,QAAQ,aAAa;CAChE,MAAM,OAAO,OAAO,WAAW,OAAO,EAAE;CACxC,OAAO,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC;AAC3C"}
@@ -1,10 +1,7 @@
1
- import { a as StartSessionResponseSchema, d as AnyErrorBodySchema, f as ConfigOverridesSchema, l as SpeechEntrySchema, m as ConfigSchema, n as CLIENT_HEADER, o as InputCaptureSchema, r as SessionListSchema, t as StatusSchema, u as SpeechListSchema } from "../chunks/src.js";
1
+ import { _ as API_PREFIX, a as StartSessionResponseSchema, d as AnyErrorBodySchema, f as ConfigOverridesSchema, l as SpeechEntrySchema, m as ConfigSchema, n as CLIENT_HEADER, o as InputCaptureSchema, r as SessionListSchema, t as StatusSchema, u as SpeechListSchema } from "../chunks/src.js";
2
2
  import { t as dynamic_private_env } from "../chunks/config.js";
3
3
  import { t as error } from "../chunks/exports.js";
4
4
  import { t as checkDto } from "../chunks/validate.js";
5
- // ../shared/src/api-version.ts
6
- /** Path prefix of every API route. */
7
- var API_PREFIX = "/api/v1";
8
5
  // ../shared/src/ui-host.ts
9
6
  /**
10
7
  * The header that tells the UI its page is opened from the bridge's own machine, where the screen
@@ -69,8 +66,8 @@ function createBridgeApi(baseUrl, fetchFn) {
69
66
  status: () => read("GET", "/status", StatusSchema),
70
67
  sessions: () => read("GET", "/sessions", SessionListSchema),
71
68
  startSession: (request) => read("POST", "/sessions", StartSessionResponseSchema, request),
72
- endSession: async () => {
73
- await call("POST", "/sessions/end");
69
+ endSession: async (id) => {
70
+ await call("POST", `/sessions/end?session=${id}`);
74
71
  },
75
72
  deleteSession: async (id) => {
76
73
  await call("DELETE", `/sessions?session=${id}`);
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.server.js","names":["env"],"sources":["../../../../shared/src/api-version.ts","../../../../shared/src/ui-host.ts","../../../.svelte-kit/generated/build/env/private/server.js","../../../src/lib/server/bridge-api.ts","../../../src/lib/server/bridge-from-env.ts","../../../src/lib/server/log.ts","../../../src/hooks.server.ts"],"sourcesContent":["/**\n * `<major>.<minor>` of the HTTP API. Minor versions only add things, with the exceptions in\n * docs/usage/http-api.md#versioning. Within a major version the enums of the answers never grow\n * (`openapi/freeze.test.ts`).\n */\nexport const API_VERSION = '1.34';\n\n/** Path prefix of every API route. */\nexport const API_PREFIX = '/api/v1';\n\n/**\n * Response header with {@link API_VERSION} on every answer under {@link API_PREFIX} (since 1.22),\n * so a client checks the version on each answer instead of asking `GET /status` first.\n */\nexport const API_VERSION_HEADER = 'X-SR-Speech-Api-Version';\n","// What the bridge hands the web UI it hosts (docs/implementation/architecture.md#the-web-ui-a-sveltekit-bff).\n// The bridge and the UI don't import each other; both import these names, so a rename can't turn\n// one side off unnoticed.\n\n/** The environment variable the UI's BFF reads the bridge's address from. */\nexport const BRIDGE_API_URL_ENV = 'SR_BRIDGE_API_URL';\n\n/**\n * The header that tells the UI its page is opened from the bridge's own machine, where the screen\n * reader would read the live log and feed it back (docs/usage/web-ui.md#accessibility-of-the-ui-itself).\n * The bridge sets (`1`) or removes it on every request, so a client can't send it.\n */\nexport const LOCAL_HEADER = 'x-sr-bridge-local';\n\n/**\n * Where the UI's server code finds the bridge log: a `Symbol.for` key on `globalThis`. Its lines\n * get the `[web-ui]` prefix, go to the log file and never block on the console.\n */\nexport const UI_LOGGER_KEY = Symbol.for('screenreader-speech-capture.ui-logger');\n\n/** What the UI's server code logs through: the bridge's `Logger`, as far as the UI uses it. */\nexport interface UiServerLog {\n error(message: string): void;\n warn(message: string): void;\n}\n","import { dynamic_private_env as env } from '../config.js';\n\nexport const SR_BRIDGE_API_URL = env.SR_BRIDGE_API_URL;\n","import { error } from '@sveltejs/kit';\nimport {\n AnyErrorBodySchema,\n API_PREFIX,\n CLIENT_HEADER,\n checkDto,\n InputCaptureSchema,\n type CaptureOptionsDto,\n type InputCaptureDto,\n ConfigOverridesSchema,\n ConfigSchema,\n SessionListSchema,\n SpeechEntrySchema,\n SpeechListSchema,\n StartSessionResponseSchema,\n StatusSchema,\n type ConfigDto,\n type ConfigOverridesDto,\n type ConfigPatchDto,\n type DtoOf,\n type DtoSchema,\n type KeysRequestDto,\n type SessionListDto,\n type SpeechEntryDto,\n type SpeechListDto,\n type StartSessionRequestDto,\n type StartSessionResponseDto,\n type StatusDto,\n} from '@screenreader-speech-capture/shared';\nimport type { SessionScope } from '#lib/core/sessions.js';\n\ntype Fetch = typeof fetch;\n\n/** Which page of speech to read, as the browser asked; the bridge checks it. */\nexport interface SpeechPageQuery {\n since: string | null;\n limit: string | null;\n}\n\n/** The bridge's HTTP API as the BFF uses it: the only place the UI server talks to the bridge. */\nexport interface BridgeApi {\n status(): Promise<StatusDto>;\n sessions(): Promise<SessionListDto>;\n startSession(request: StartSessionRequestDto): Promise<StartSessionResponseDto>;\n /** Ends the current session; does nothing if none is current. */\n endSession(): Promise<void>;\n /** Deletes an ended session and its speech (the bridge refuses the current one). */\n deleteSession(id: number): Promise<void>;\n /** Clears the speech of the current session or of `none` (`session`: an id or `none`); it keeps running. */\n clearSpeech(session: SessionScope): Promise<void>;\n /** The configuration in use (`active`) or the one the next start will use (`saved`). */\n config(view: 'active' | 'saved'): Promise<ConfigDto>;\n /** The settings a flag or environment variable sets: the config file can't change them. */\n configOverrides(): Promise<ConfigOverridesDto>;\n /**\n * Saves a partial config for the next start and answers with the saved config. Rejects with the\n * bridge's status and message, plus `field` (`tcp.port`) when the bridge names one.\n */\n updateConfig(patch: ConfigPatchDto): Promise<ConfigDto>;\n /** Presses keys in the foreground window of the bridge's machine. */\n pressKeys(keys: KeysRequestDto['keys']): Promise<void>;\n /** Presses keys and answers with the speech they caused; `signal` ends the capture. */\n captureKeys(\n keys: KeysRequestDto['keys'],\n capture: CaptureOptionsDto,\n signal: AbortSignal,\n ): Promise<InputCaptureDto>;\n /** Inserts a marker; the bridge files it under the current session (or outside any). */\n addMarker(label: string): Promise<SpeechEntryDto>;\n /** One page of a scope's entries with `seq > since`, oldest first (`session`: an id or `none`). */\n speech(session: SessionScope | null, page: SpeechPageQuery): Promise<SpeechListDto>;\n /**\n * Opens the bridge's SSE stream (`session`: an id or `none`). The body is passed on as it is,\n * so `Last-Event-ID` replays and every event name reach the browser untouched.\n */\n openSpeechStream(\n session: SessionScope | null,\n lastEventId: string | null,\n signal: AbortSignal,\n ): Promise<Response>;\n}\n\n/** Named in the bridge's logs when this UI ends or replaces another client's session. */\nconst UI_CLIENT = 'web-ui';\n\n/**\n * `baseUrl` is the bridge's origin (no path). `fetchFn` is SvelteKit's `event.fetch` in\n * routes and a fake in tests.\n */\nexport function createBridgeApi(baseUrl: string, fetchFn: Fetch): BridgeApi {\n const root = baseUrl.replace(/\\/+$/, '') + API_PREFIX;\n // SvelteKit's `event.fetch` adds `Origin: <the UI's own origin>` to every call to another origin\n // (`pnpm dev:ui`: http://localhost:5173). The bridge refuses a POST from any origin but its own\n // (docs/usage/security.md#host-and-origin), so name the bridge itself: this is a server-side\n // call, not a page of another site.\n const origin = new URL(root).origin;\n\n async function call(\n method: 'GET' | 'POST' | 'PUT' | 'DELETE',\n path: string,\n body?: unknown,\n signal?: AbortSignal,\n ): Promise<unknown> {\n let response: Response;\n try {\n response = await fetchFn(`${root}${path}`, {\n method,\n headers: {\n accept: 'application/json',\n origin,\n [CLIENT_HEADER]: UI_CLIENT,\n ...(body === undefined ? {} : { 'content-type': 'application/json' }),\n },\n body: body === undefined ? undefined : JSON.stringify(body),\n ...(signal === undefined ? {} : { signal }),\n });\n } catch (cause) {\n error(502, `The bridge is not reachable: ${describe(cause)}`);\n }\n const answer: unknown = await response.json().catch(() => undefined);\n if (!response.ok) {\n const apiError = checkDto(AnyErrorBodySchema, answer);\n if (!apiError.ok) error(response.status, `The bridge answered ${response.status}`);\n const { message, details } = apiError.value.error;\n const field = details?.field;\n if (typeof field === 'string') error(response.status, { message, field });\n error(response.status, message);\n }\n return answer;\n }\n\n async function read<S extends DtoSchema>(\n method: 'GET' | 'POST' | 'PUT',\n path: string,\n schema: S,\n body?: unknown,\n signal?: AbortSignal,\n ): Promise<DtoOf<S>> {\n const checked = checkDto(schema, await call(method, path, body, signal));\n if (!checked.ok) {\n error(502, `Unexpected answer from the bridge at ${checked.field}: ${checked.message}`);\n }\n return checked.value;\n }\n\n return {\n status: () => read('GET', '/status', StatusSchema),\n sessions: () => read('GET', '/sessions', SessionListSchema),\n startSession: (request) => read('POST', '/sessions', StartSessionResponseSchema, request),\n endSession: async () => {\n await call('POST', '/sessions/end');\n },\n deleteSession: async (id) => {\n await call('DELETE', `/sessions?session=${id}`);\n },\n clearSpeech: async (session) => {\n await call('DELETE', `/speech?session=${session}`);\n },\n config: (view) => read('GET', `/config?view=${view}`, ConfigSchema),\n configOverrides: () => read('GET', '/config/overrides', ConfigOverridesSchema),\n updateConfig: (patch) => read('PUT', '/config', ConfigSchema, patch),\n pressKeys: async (keys) => {\n await call('POST', '/input/keys', { keys });\n },\n captureKeys: (keys, capture, signal) =>\n read('POST', '/input/keys', InputCaptureSchema, { keys, capture }, signal),\n addMarker: (label) => read('POST', '/markers', SpeechEntrySchema, { label }),\n speech: (session, { since, limit }) => {\n const query = new URLSearchParams();\n if (since !== null) query.set('since', since);\n if (limit !== null) query.set('limit', limit);\n if (session !== null) query.set('session', String(session));\n return read('GET', `/speech?${query}`, SpeechListSchema);\n },\n openSpeechStream: async (session, lastEventId, signal) => {\n const query = session === null ? '' : `?session=${session}`;\n let response: Response;\n try {\n response = await fetchFn(`${root}/speech/stream${query}`, {\n headers: {\n accept: 'text/event-stream',\n origin,\n [CLIENT_HEADER]: UI_CLIENT,\n ...(lastEventId === null ? {} : { 'last-event-id': lastEventId }),\n },\n signal,\n });\n } catch (cause) {\n error(502, `The bridge is not reachable: ${describe(cause)}`);\n }\n if (!response.ok || response.body === null) {\n // Unread, the body would hold the bridge connection until it is garbage collected, and\n // `EventSource` retries every few seconds while the bridge refuses.\n await response.body?.cancel().catch(() => undefined);\n error(\n response.status === 200 ? 502 : response.status,\n 'The speech stream is not available',\n );\n }\n return response;\n },\n };\n}\n\nfunction describe(cause: unknown): string {\n return cause instanceof Error ? cause.message : String(cause);\n}\n","import { SR_BRIDGE_API_URL } from '$app/env/private';\nimport { createBridgeApi, type BridgeApi } from './bridge-api.js';\n\n/** The bridge API of this deployment, at `SR_BRIDGE_API_URL` (`src/env.ts`). */\nexport function bridgeApiFromEnv(fetchFn: typeof fetch): BridgeApi {\n return createBridgeApi(SR_BRIDGE_API_URL, fetchFn);\n}\n","import { UI_LOGGER_KEY, type UiServerLog } from '@screenreader-speech-capture/shared';\n\nfunction isServerLog(value: unknown): value is UiServerLog {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as UiServerLog).error === 'function' &&\n typeof (value as UiServerLog).warn === 'function'\n );\n}\n\n/** `pnpm dev:ui` has no bridge in its process: the Vite dev server's console stands in. */\nconst consoleLog: UiServerLog = {\n error: (message) => console.error(`[web-ui] ${message}`),\n warn: (message) => console.warn(`[web-ui] ${message}`),\n};\n\n/**\n * The bridge log the bridge puts on `globalThis` before it loads the UI, the console otherwise.\n * Read per call, so it doesn't matter whether this module loads before or after the bridge sets it.\n */\nexport function serverLog(): UiServerLog {\n const bridge = (globalThis as Record<symbol, unknown>)[UI_LOGGER_KEY];\n return isServerLog(bridge) ? bridge : consoleLog;\n}\n","import { LOCAL_HEADER } from '@screenreader-speech-capture/shared';\nimport type { Handle, HandleServerError } from '@sveltejs/kit/hooks';\nimport { bridgeApiFromEnv } from '#lib/server/bridge-from-env.js';\nimport { serverLog } from '#lib/server/log.js';\n\nexport const handle: Handle = ({ event, resolve }) => {\n // Set by the bridge on a request from its own machine, and removed from every other one.\n event.locals.local = event.request.headers.get(LOCAL_HEADER) === '1';\n // Built once per request and with its `fetch`, so routes and loads share one way to the bridge.\n event.locals.bridge = bridgeApiFromEnv(event.fetch);\n return resolve(event);\n};\n\n/**\n * An unexpected error (`kind: 'unknown'`: not one thrown with `error()`, not SvelteKit's own such\n * as a 404) is one line in the bridge log; the browser keeps SvelteKit's generic answer. The line\n * names the path but never the query, which can hold speech text that must stay off the console\n * (docs/usage/operations.md#speech-text-stays-off-the-console).\n */\nexport const handleError: HandleServerError = ({ kind, error, event }) => {\n if (kind !== 'unknown') return;\n const reason = error instanceof Error ? `${error.name}: ${error.message}` : String(error);\n serverLog().error(`${event.request.method} ${event.url.pathname}: ${reason}`);\n};\n"],"mappings":";;;;;;AAQA,IAAa,aAAa;;;;;;;ACI1B,IAAa,eAAe;;;;;AAM5B,IAAa,gBAAgB,OAAO,IAAI,uCAAuC;;AChB/E,IAAa,oBAAoBA,oBAAI;;;ACiFrC,IAAM,YAAY;;;;;AAMlB,SAAgB,gBAAgB,SAAiB,SAA2B;CAC1E,MAAM,OAAO,QAAQ,QAAQ,QAAQ,EAAE,IAAI;CAK3C,MAAM,SAAS,IAAI,IAAI,IAAI,CAAC,CAAC;CAE7B,eAAe,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,KAAA,CAAS;IACnD,MACE,SAAS,WAAW,MAAM,MAAM,SAAS,QACzC,oCACF;GACF;GACA,OAAO;EACT;CACF;AACF;AAEA,SAAS,SAAS,OAAwB;CACxC,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;;;AC1MA,SAAgB,iBAAiB,SAAkC;CACjE,OAAO,gBAAgB,mBAAmB,OAAO;AACnD;;ACJA,SAAS,YAAY,OAAsC;CACzD,OACE,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAAsB,UAAU,cACxC,OAAQ,MAAsB,SAAS;AAE3C;;AAGA,IAAM,aAA0B;CAC9B,QAAQ,YAAY,QAAQ,MAAM,YAAY,SAAS;CACvD,OAAO,YAAY,QAAQ,KAAK,YAAY,SAAS;AACvD;;;;;AAMA,SAAgB,YAAyB;CACvC,MAAM,SAAU,WAAuC;CACvD,OAAO,YAAY,MAAM,IAAI,SAAS;AACxC;;ACnBA,IAAa,UAAkB,EAAE,OAAO,cAAc;CAEpD,MAAM,OAAO,QAAQ,MAAM,QAAQ,QAAQ,IAAI,YAAY,MAAM;CAEjE,MAAM,OAAO,SAAS,iBAAiB,MAAM,KAAK;CAClD,OAAO,QAAQ,KAAK;AACtB;;;;;;;AAQA,IAAa,eAAkC,EAAE,MAAM,OAAO,YAAY;CACxE,IAAI,SAAS,WAAW;CACxB,MAAM,SAAS,iBAAiB,QAAQ,GAAG,MAAM,KAAK,IAAI,MAAM,YAAY,OAAO,KAAK;CACxF,UAAU,CAAC,CAAC,MAAM,GAAG,MAAM,QAAQ,OAAO,GAAG,MAAM,IAAI,SAAS,IAAI,QAAQ;AAC9E"}
1
+ {"version":3,"file":"hooks.server.js","names":["env"],"sources":["../../../../shared/src/ui-host.ts","../../../.svelte-kit/generated/build/env/private/server.js","../../../src/lib/server/bridge-api.ts","../../../src/lib/server/bridge-from-env.ts","../../../src/lib/server/log.ts","../../../src/hooks.server.ts"],"sourcesContent":["// What the bridge hands the web UI it hosts (docs/implementation/architecture.md#the-web-ui-a-sveltekit-bff).\n// The bridge and the UI don't import each other; both import these names, so a rename can't turn\n// one side off unnoticed.\n\n/** The environment variable the UI's BFF reads the bridge's address from. */\nexport const BRIDGE_API_URL_ENV = 'SR_BRIDGE_API_URL';\n\n/**\n * The header that tells the UI its page is opened from the bridge's own machine, where the screen\n * reader would read the live log and feed it back (docs/usage/web-ui.md#accessibility-of-the-ui-itself).\n * The bridge sets (`1`) or removes it on every request, so a client can't send it.\n */\nexport const LOCAL_HEADER = 'x-sr-bridge-local';\n\n/**\n * Where the UI's server code finds the bridge log: a `Symbol.for` key on `globalThis`. Its lines\n * get the `[web-ui]` prefix, go to the log file and never block on the console.\n */\nexport const UI_LOGGER_KEY = Symbol.for('screenreader-speech-capture.ui-logger');\n\n/** What the UI's server code logs through: the bridge's `Logger`, as far as the UI uses it. */\nexport interface UiServerLog {\n error(message: string): void;\n warn(message: string): void;\n}\n","import { dynamic_private_env as env } from '../config.js';\n\nexport const SR_BRIDGE_API_URL = env.SR_BRIDGE_API_URL;\n","import { error } from '@sveltejs/kit';\nimport {\n AnyErrorBodySchema,\n API_PREFIX,\n CLIENT_HEADER,\n checkDto,\n InputCaptureSchema,\n type CaptureOptionsDto,\n type InputCaptureDto,\n ConfigOverridesSchema,\n ConfigSchema,\n SessionListSchema,\n SpeechEntrySchema,\n SpeechListSchema,\n StartSessionResponseSchema,\n StatusSchema,\n type ConfigDto,\n type ConfigOverridesDto,\n type ConfigPatchDto,\n type DtoOf,\n type DtoSchema,\n type KeysRequestDto,\n type SessionListDto,\n type SpeechEntryDto,\n type SpeechListDto,\n type StartSessionRequestDto,\n type StartSessionResponseDto,\n type StatusDto,\n} from '@screenreader-speech-capture/shared';\nimport type { SessionScope } from '#lib/core/sessions.js';\n\ntype Fetch = typeof fetch;\n\n/** Which page of speech to read, as the browser asked; the bridge checks it. */\nexport interface SpeechPageQuery {\n since: string | null;\n limit: string | null;\n}\n\n/** The bridge's HTTP API as the BFF uses it: the only place the UI server talks to the bridge. */\nexport interface BridgeApi {\n status(): Promise<StatusDto>;\n sessions(): Promise<SessionListDto>;\n startSession(request: StartSessionRequestDto): Promise<StartSessionResponseDto>;\n /** Ends the session `id`; does nothing if it is not the current one. */\n endSession(id: number): Promise<void>;\n /** Deletes an ended session and its speech (the bridge refuses the current one). */\n deleteSession(id: number): Promise<void>;\n /** Clears the speech of the current session or of `none` (`session`: an id or `none`); it keeps running. */\n clearSpeech(session: SessionScope): Promise<void>;\n /** The configuration in use (`active`) or the one the next start will use (`saved`). */\n config(view: 'active' | 'saved'): Promise<ConfigDto>;\n /** The settings a flag or environment variable sets: the config file can't change them. */\n configOverrides(): Promise<ConfigOverridesDto>;\n /**\n * Saves a partial config for the next start and answers with the saved config. Rejects with the\n * bridge's status and message, plus `field` (`tcp.port`) when the bridge names one.\n */\n updateConfig(patch: ConfigPatchDto): Promise<ConfigDto>;\n /** Presses keys in the foreground window of the bridge's machine. */\n pressKeys(keys: KeysRequestDto['keys']): Promise<void>;\n /** Presses keys and answers with the speech they caused; `signal` ends the capture. */\n captureKeys(\n keys: KeysRequestDto['keys'],\n capture: CaptureOptionsDto,\n signal: AbortSignal,\n ): Promise<InputCaptureDto>;\n /** Inserts a marker; the bridge files it under the current session (or outside any). */\n addMarker(label: string): Promise<SpeechEntryDto>;\n /** One page of a scope's entries with `seq > since`, oldest first (`session`: an id or `none`). */\n speech(session: SessionScope | null, page: SpeechPageQuery): Promise<SpeechListDto>;\n /**\n * Opens the bridge's SSE stream (`session`: an id or `none`). The body is passed on as it is,\n * so `Last-Event-ID` replays and every event name reach the browser untouched.\n */\n openSpeechStream(\n session: SessionScope | null,\n lastEventId: string | null,\n signal: AbortSignal,\n ): Promise<Response>;\n}\n\n/** Named in the bridge's logs when this UI ends or replaces another client's session. */\nconst UI_CLIENT = 'web-ui';\n\n/**\n * `baseUrl` is the bridge's origin (no path). `fetchFn` is SvelteKit's `event.fetch` in\n * routes and a fake in tests.\n */\nexport function createBridgeApi(baseUrl: string, fetchFn: Fetch): BridgeApi {\n const root = baseUrl.replace(/\\/+$/, '') + API_PREFIX;\n // SvelteKit's `event.fetch` adds `Origin: <the UI's own origin>` to every call to another origin\n // (`pnpm dev:ui`: http://localhost:5173). The bridge refuses a POST from any origin but its own\n // (docs/usage/security.md#host-and-origin), so name the bridge itself: this is a server-side\n // call, not a page of another site.\n const origin = new URL(root).origin;\n\n async function call(\n method: 'GET' | 'POST' | 'PUT' | 'DELETE',\n path: string,\n body?: unknown,\n signal?: AbortSignal,\n ): Promise<unknown> {\n let response: Response;\n try {\n response = await fetchFn(`${root}${path}`, {\n method,\n headers: {\n accept: 'application/json',\n origin,\n [CLIENT_HEADER]: UI_CLIENT,\n ...(body === undefined ? {} : { 'content-type': 'application/json' }),\n },\n body: body === undefined ? undefined : JSON.stringify(body),\n ...(signal === undefined ? {} : { signal }),\n });\n } catch (cause) {\n error(502, `The bridge is not reachable: ${describe(cause)}`);\n }\n const answer: unknown = await response.json().catch(() => undefined);\n if (!response.ok) {\n const apiError = checkDto(AnyErrorBodySchema, answer);\n if (!apiError.ok) error(response.status, `The bridge answered ${response.status}`);\n const { message, details } = apiError.value.error;\n const field = details?.field;\n if (typeof field === 'string') error(response.status, { message, field });\n error(response.status, message);\n }\n return answer;\n }\n\n async function read<S extends DtoSchema>(\n method: 'GET' | 'POST' | 'PUT',\n path: string,\n schema: S,\n body?: unknown,\n signal?: AbortSignal,\n ): Promise<DtoOf<S>> {\n const checked = checkDto(schema, await call(method, path, body, signal));\n if (!checked.ok) {\n error(502, `Unexpected answer from the bridge at ${checked.field}: ${checked.message}`);\n }\n return checked.value;\n }\n\n return {\n status: () => read('GET', '/status', StatusSchema),\n sessions: () => read('GET', '/sessions', SessionListSchema),\n startSession: (request) => read('POST', '/sessions', StartSessionResponseSchema, request),\n endSession: async (id) => {\n await call('POST', `/sessions/end?session=${id}`);\n },\n deleteSession: async (id) => {\n await call('DELETE', `/sessions?session=${id}`);\n },\n clearSpeech: async (session) => {\n await call('DELETE', `/speech?session=${session}`);\n },\n config: (view) => read('GET', `/config?view=${view}`, ConfigSchema),\n configOverrides: () => read('GET', '/config/overrides', ConfigOverridesSchema),\n updateConfig: (patch) => read('PUT', '/config', ConfigSchema, patch),\n pressKeys: async (keys) => {\n await call('POST', '/input/keys', { keys });\n },\n captureKeys: (keys, capture, signal) =>\n read('POST', '/input/keys', InputCaptureSchema, { keys, capture }, signal),\n addMarker: (label) => read('POST', '/markers', SpeechEntrySchema, { label }),\n speech: (session, { since, limit }) => {\n const query = new URLSearchParams();\n if (since !== null) query.set('since', since);\n if (limit !== null) query.set('limit', limit);\n if (session !== null) query.set('session', String(session));\n return read('GET', `/speech?${query}`, SpeechListSchema);\n },\n openSpeechStream: async (session, lastEventId, signal) => {\n const query = session === null ? '' : `?session=${session}`;\n let response: Response;\n try {\n response = await fetchFn(`${root}/speech/stream${query}`, {\n headers: {\n accept: 'text/event-stream',\n origin,\n [CLIENT_HEADER]: UI_CLIENT,\n ...(lastEventId === null ? {} : { 'last-event-id': lastEventId }),\n },\n signal,\n });\n } catch (cause) {\n error(502, `The bridge is not reachable: ${describe(cause)}`);\n }\n if (!response.ok || response.body === null) {\n // Unread, the body would hold the bridge connection until it is garbage collected, and\n // `EventSource` retries every few seconds while the bridge refuses.\n await response.body?.cancel().catch(() => undefined);\n error(\n response.status === 200 ? 502 : response.status,\n 'The speech stream is not available',\n );\n }\n return response;\n },\n };\n}\n\nfunction describe(cause: unknown): string {\n return cause instanceof Error ? cause.message : String(cause);\n}\n","import { SR_BRIDGE_API_URL } from '$app/env/private';\nimport { createBridgeApi, type BridgeApi } from './bridge-api.js';\n\n/** The bridge API of this deployment, at `SR_BRIDGE_API_URL` (`src/env.ts`). */\nexport function bridgeApiFromEnv(fetchFn: typeof fetch): BridgeApi {\n return createBridgeApi(SR_BRIDGE_API_URL, fetchFn);\n}\n","import { UI_LOGGER_KEY, type UiServerLog } from '@screenreader-speech-capture/shared';\n\nfunction isServerLog(value: unknown): value is UiServerLog {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as UiServerLog).error === 'function' &&\n typeof (value as UiServerLog).warn === 'function'\n );\n}\n\n/** `pnpm dev:ui` has no bridge in its process: the Vite dev server's console stands in. */\nconst consoleLog: UiServerLog = {\n error: (message) => console.error(`[web-ui] ${message}`),\n warn: (message) => console.warn(`[web-ui] ${message}`),\n};\n\n/**\n * The bridge log the bridge puts on `globalThis` before it loads the UI, the console otherwise.\n * Read per call, so it doesn't matter whether this module loads before or after the bridge sets it.\n */\nexport function serverLog(): UiServerLog {\n const bridge = (globalThis as Record<symbol, unknown>)[UI_LOGGER_KEY];\n return isServerLog(bridge) ? bridge : consoleLog;\n}\n","import { LOCAL_HEADER } from '@screenreader-speech-capture/shared';\nimport type { Handle, HandleServerError } from '@sveltejs/kit/hooks';\nimport { bridgeApiFromEnv } from '#lib/server/bridge-from-env.js';\nimport { serverLog } from '#lib/server/log.js';\n\nexport const handle: Handle = ({ event, resolve }) => {\n // Set by the bridge on a request from its own machine, and removed from every other one.\n event.locals.local = event.request.headers.get(LOCAL_HEADER) === '1';\n // Built once per request and with its `fetch`, so routes and loads share one way to the bridge.\n event.locals.bridge = bridgeApiFromEnv(event.fetch);\n return resolve(event);\n};\n\n/**\n * An unexpected error (`kind: 'unknown'`: not one thrown with `error()`, not SvelteKit's own such\n * as a 404) is one line in the bridge log; the browser keeps SvelteKit's generic answer. The line\n * names the path but never the query, which can hold speech text that must stay off the console\n * (docs/usage/operations.md#speech-text-stays-off-the-console).\n */\nexport const handleError: HandleServerError = ({ kind, error, event }) => {\n if (kind !== 'unknown') return;\n const reason = error instanceof Error ? `${error.name}: ${error.message}` : String(error);\n serverLog().error(`${event.request.method} ${event.url.pathname}: ${reason}`);\n};\n"],"mappings":";;;;;;;;;;AAYA,IAAa,eAAe;;;;;AAM5B,IAAa,gBAAgB,OAAO,IAAI,uCAAuC;;AChB/E,IAAa,oBAAoBA,oBAAI;;;ACiFrC,IAAM,YAAY;;;;;AAMlB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.js";
2
- import { a as head, c as stringify, d as attr, f as clsx, h as escape_html, i as ensure_array_like, o as props_id, r as derived, t as attr_class, u as setContext } from "../../chunks/server2.js";
2
+ import { a as head, c as stringify, d as attr, f as clsx, h as escape_html, i as ensure_array_like, m as run, o as props_id, r as derived, t as attr_class, u as setContext } from "../../chunks/server2.js";
3
3
  import "../../chunks/index-server.js";
4
4
  import { t as checkDto } from "../../chunks/validate.js";
5
5
  import "../../chunks/paths.js";
6
6
  import { t as page } from "../../chunks/state.js";
7
- import { n as appStores, t as APP_STORES } from "../../chunks/app-context.js";
7
+ import { t as APP_STORES } from "../../chunks/app-context.js";
8
8
  import { t as MAX_ROWS } from "../../chunks/speech.js";
9
9
  import { t as isCurrent } from "../../chunks/navigation.js";
10
10
  import { c as parseTheme, o as DEFAULT_THEME, t as SettingRejected } from "../../chunks/config2.js";
@@ -15,6 +15,14 @@ import { i as QUIET_MS, n as CHECK_CHORD, r as LISTEN_TIMEOUT_MS, t as CHECK_CAP
15
15
  var favicon_default = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='44'%20height='44'%20viewBox='0%200%2044%2044'%3e%3ctitle%3eSpeech%20Capture%3c/title%3e%3crect%20width='44'%20height='44'%20rx='14'%20fill='%23415f91'/%3e%3cpath%20d='M4%2010v4M8%206v12M12%203v18M16%208v8M20%2011v2'%20transform='translate(10%2010)'%20fill='none'%20stroke='%23fff'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e";
16
16
  // ../../node_modules/.pnpm/@fontsource+material-symbols-outlined@5.3.9/node_modules/@fontsource/material-symbols-outlined/files/material-symbols-outlined-latin-400-normal.woff2?url
17
17
  var material_symbols_outlined_latin_400_normal_default = "/ui/_app/immutable/assets/material-symbols-outlined-latin-400-normal.BhEvR8fk.woff2";
18
+ // src/lib/components/AppHeader/AppHeader.svelte
19
+ function AppHeader($$renderer, $$props) {
20
+ /** What sits at the end of the bar: the bridge's status. */
21
+ let { host, children } = $$props;
22
+ $$renderer.push(`<header class="svelte-4j9s4f"><div class="logo-slot svelte-4j9s4f"><div class="logo svelte-4j9s4f"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 10v4M8 6v12M12 3v18M16 8v8M20 11v2"></path></svg></div></div> <div class="title svelte-4j9s4f"><span class="name svelte-4j9s4f">Speech Capture</span> <span class="meta svelte-4j9s4f">${escape_html(host)}</span></div> `);
23
+ children?.($$renderer);
24
+ $$renderer.push(`<!----></header>`);
25
+ }
18
26
  // src/lib/components/StatusChips/StatusChips.svelte
19
27
  function StatusChips($$renderer, $$props) {
20
28
  $$renderer.component(($$renderer) => {
@@ -33,13 +41,13 @@ function StatusChips($$renderer, $$props) {
33
41
  }
34
42
  // src/lib/components/StatusRefresh/StatusRefresh.svelte
35
43
  function StatusRefresh($$renderer, $$props) {
36
- let { loading, onRetry } = $$props;
37
- $$renderer.push(`<md-icon-button title="Refresh status" aria-label="Refresh status" class="svelte-5q7qd7"><md-icon aria-hidden="true"${attr_class("svelte-5q7qd7", void 0, { "spin": loading })}>refresh</md-icon></md-icon-button>`);
44
+ let { reading, onRefresh } = $$props;
45
+ $$renderer.push(`<md-icon-button title="Refresh status" aria-label="Refresh status" class="svelte-5q7qd7"><md-icon aria-hidden="true"${attr_class("svelte-5q7qd7", void 0, { "spin": reading })}>refresh</md-icon></md-icon-button>`);
38
46
  }
39
47
  // src/lib/core/status.ts
40
48
  /**
41
- * Only what needs a look: a service that is not running (not enabled) has no chip, and the session
42
- * is the sessions pane's business. An unreachable bridge is a chip of its own.
49
+ * Only what needs attention gets a chip: a stopped (not enabled) service has none, and sessions are
50
+ * left to the sessions pane. An unreachable bridge gets a chip of its own.
43
51
  */
44
52
  function deriveChips(status, reachable) {
45
53
  if (!reachable) return [{
@@ -92,32 +100,26 @@ function announcement(chips, reachable) {
92
100
  // src/lib/components/BridgeStatus/BridgeStatus.svelte
93
101
  function BridgeStatus($$renderer, $$props) {
94
102
  $$renderer.component(($$renderer) => {
95
- const statusStore = appStores().status;
96
- const seed = derived(() => page.data.status);
97
- const status = derived(() => statusStore.status ?? seed());
98
- const chips = derived(() => deriveChips(status(), statusStore.reachable));
103
+ /** `null` until the status was read once. */
104
+ /** Whether the last read of the status worked. */
105
+ /** Whether a read of the status is under way. */
106
+ let { status, reachable, reading, onRefresh } = $$props;
107
+ const chips = derived(() => deriveChips(status, reachable));
99
108
  StatusChips($$renderer, {
100
109
  chips: chips(),
101
- announcement: announcement(chips(), statusStore.reachable)
110
+ announcement: announcement(chips(), reachable)
102
111
  });
103
112
  $$renderer.push(`<!----> `);
104
- if (!statusStore.reachable) {
113
+ if (!reachable) {
105
114
  $$renderer.push("<!--[0-->");
106
115
  StatusRefresh($$renderer, {
107
- loading: statusStore.loading,
108
- onRetry: () => void statusStore.retry()
116
+ reading,
117
+ onRefresh
109
118
  });
110
119
  } else $$renderer.push("<!--[-1-->");
111
120
  $$renderer.push(`<!--]-->`);
112
121
  });
113
122
  }
114
- // src/lib/components/AppHeader/AppHeader.svelte
115
- function AppHeader($$renderer, $$props) {
116
- let { host } = $$props;
117
- $$renderer.push(`<header class="svelte-4j9s4f"><div class="logo-slot svelte-4j9s4f"><div class="logo svelte-4j9s4f"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 10v4M8 6v12M12 3v18M16 8v8M20 11v2"></path></svg></div></div> <div class="title svelte-4j9s4f"><span class="name svelte-4j9s4f">Speech Capture</span> <span class="meta svelte-4j9s4f">${escape_html(host)}</span></div> `);
118
- BridgeStatus($$renderer, {});
119
- $$renderer.push(`<!----></header>`);
120
- }
121
123
  // src/lib/components/NavRail/NavRail.svelte
122
124
  function NavRail($$renderer, $$props) {
123
125
  $$renderer.component(($$renderer) => {
@@ -139,7 +141,8 @@ function NavRail($$renderer, $$props) {
139
141
  // src/lib/adapters/browser-clipboard.ts
140
142
  /**
141
143
  * The browser's clipboard. `navigator.clipboard` only exists in a secure context, and the bridge
142
- * speaks plain HTTP: opened from another machine, the old selection command has to do it.
144
+ * speaks plain HTTP: opened from another machine, the old selection-based copy command has to be
145
+ * used.
143
146
  */
144
147
  var BrowserClipboard = class {
145
148
  async copy(text) {
@@ -228,20 +231,20 @@ async function readRouteError(response) {
228
231
  };
229
232
  }
230
233
  // src/lib/adapters/http-config-api.ts
231
- /** A refused save names the bridge's reason (and the setting, when it names one). */
234
+ /** A refused save rejects with the bridge's reason (and the setting, if the bridge names one). */
232
235
  var rejection = (error, status) => error === null ? /* @__PURE__ */ new Error(`The request answered ${status}`) : new SettingRejected(error.message, error.field);
233
236
  /** Reads and saves the configuration through the UI's own config route (`url` includes the base path). */
234
237
  var HttpConfigApi = class {
235
- url;
238
+ #url;
236
239
  constructor(url) {
237
- this.url = url;
240
+ this.#url = url;
238
241
  }
239
242
  /** `GET /ui/api/config` answers `{ active, saved, overrides }` in one go. */
240
243
  fetch() {
241
- return routeJson(this.url, { rejection });
244
+ return routeJson(this.#url, { rejection });
242
245
  }
243
246
  update(patch) {
244
- return routeJson(this.url, {
247
+ return routeJson(this.#url, {
245
248
  method: "PUT",
246
249
  body: patch,
247
250
  rejection
@@ -251,12 +254,12 @@ var HttpConfigApi = class {
251
254
  // src/lib/adapters/http-keys-api.ts
252
255
  /** Sends key presses through the UI's own route (`url` includes the base path). */
253
256
  var HttpKeysApi = class {
254
- url;
257
+ #url;
255
258
  constructor(url) {
256
- this.url = url;
259
+ this.#url = url;
257
260
  }
258
261
  pressAndCapture(keys, capture, signal) {
259
- return routeJson(this.url, {
262
+ return routeJson(this.#url, {
260
263
  method: "POST",
261
264
  body: {
262
265
  keys,
@@ -269,20 +272,20 @@ var HttpKeysApi = class {
269
272
  // src/lib/adapters/http-speech-api.ts
270
273
  /** Changes the speech through the UI's own markers and speech routes (the urls include the base path). */
271
274
  var HttpSpeechApi = class {
272
- markersUrl;
273
- speechUrl;
275
+ #markersUrl;
276
+ #speechUrl;
274
277
  constructor(markersUrl, speechUrl) {
275
- this.markersUrl = markersUrl;
276
- this.speechUrl = speechUrl;
278
+ this.#markersUrl = markersUrl;
279
+ this.#speechUrl = speechUrl;
277
280
  }
278
281
  async addMarker(label) {
279
- await routeRequest(this.markersUrl, {
282
+ await routeRequest(this.#markersUrl, {
280
283
  method: "POST",
281
284
  body: { label }
282
285
  });
283
286
  }
284
287
  async clear(scope) {
285
- await routeRequest(`${this.speechUrl}?session=${scope}`, { method: "DELETE" });
288
+ await routeRequest(`${this.#speechUrl}?session=${scope}`, { method: "DELETE" });
286
289
  }
287
290
  };
288
291
  // src/lib/adapters/http-sessions-api.ts
@@ -291,9 +294,9 @@ var HttpSpeechApi = class {
291
294
  * sessions routes (`url` includes the base path).
292
295
  */
293
296
  var HttpSessionsApi = class {
294
- url;
297
+ #url;
295
298
  constructor(url) {
296
- this.url = url;
299
+ this.#url = url;
297
300
  }
298
301
  /** Always asks the server again: a query keeps its last answer while anything still uses it. */
299
302
  async list() {
@@ -302,7 +305,7 @@ var HttpSessionsApi = class {
302
305
  return sessions.current;
303
306
  }
304
307
  start(name, run) {
305
- return routeJson(this.url, {
308
+ return routeJson(this.#url, {
306
309
  method: "POST",
307
310
  body: {
308
311
  name,
@@ -310,11 +313,11 @@ var HttpSessionsApi = class {
310
313
  }
311
314
  });
312
315
  }
313
- async end() {
314
- await routeRequest(`${this.url}/end`, { method: "POST" });
316
+ async end(id) {
317
+ await routeRequest(`${this.#url}/${id}/end`, { method: "POST" });
315
318
  }
316
319
  async delete(id) {
317
- await routeRequest(`${this.url}/${id}`, { method: "DELETE" });
320
+ await routeRequest(`${this.#url}/${id}`, { method: "DELETE" });
318
321
  }
319
322
  };
320
323
  // src/lib/adapters/sse-speech-feed.ts
@@ -329,33 +332,33 @@ var PAGE_SIZE = 1e3;
329
332
  * - An ended session never gets new entries: it is read page by page, once, without a stream.
330
333
  */
331
334
  var SseSpeechFeed = class {
332
- streamUrl;
333
- speechUrl;
335
+ #streamUrl;
336
+ #speechUrl;
334
337
  constructor(streamUrl, speechUrl) {
335
- this.streamUrl = streamUrl;
336
- this.speechUrl = speechUrl;
338
+ this.#streamUrl = streamUrl;
339
+ this.#speechUrl = speechUrl;
337
340
  }
338
341
  open(scope, live, handlers) {
339
342
  handlers.onState("connecting");
340
- return live ? this.follow(scope, handlers) : this.read(scope, handlers);
343
+ return live ? this.#follow(scope, handlers) : this.#read(scope, handlers);
341
344
  }
342
345
  listen(since, handlers) {
343
- const source = this.stream(`since=${since}`, (entry) => handlers.onEntry(entry));
344
- this.report(source, (state) => handlers.onState(state));
346
+ const source = this.#stream(`since=${since}`, (entry) => handlers.onEntry(entry));
347
+ this.#report(source, (state) => handlers.onState(state));
345
348
  return () => source.close();
346
349
  }
347
- follow(scope, handlers) {
348
- const source = this.stream(`session=${encodeURIComponent(String(scope))}&since=0`, (entry) => handlers.onEntry(entry));
349
- this.report(source, (state) => handlers.onState(state));
350
+ #follow(scope, handlers) {
351
+ const source = this.#stream(`session=${encodeURIComponent(String(scope))}&since=0`, (entry) => handlers.onEntry(entry));
352
+ this.#report(source, (state) => handlers.onState(state));
350
353
  source.addEventListener("clear", () => handlers.onClear());
351
354
  return () => source.close();
352
355
  }
353
- report(source, onState) {
356
+ #report(source, onState) {
354
357
  source.onopen = () => onState("live");
355
358
  source.onerror = () => onState(source.readyState === EventSource.CLOSED ? "failed" : "reconnecting");
356
359
  }
357
- stream(query, onEntry) {
358
- const source = new EventSource(`${this.streamUrl}?${query}`);
360
+ #stream(query, onEntry) {
361
+ const source = new EventSource(`${this.#streamUrl}?${query}`);
359
362
  source.addEventListener("entry", (event) => {
360
363
  let data;
361
364
  try {
@@ -368,7 +371,7 @@ var SseSpeechFeed = class {
368
371
  });
369
372
  return source;
370
373
  }
371
- read(scope, handlers) {
374
+ #read(scope, handlers) {
372
375
  const abort = new AbortController();
373
376
  const load = async () => {
374
377
  let since = 0;
@@ -378,7 +381,7 @@ var SseSpeechFeed = class {
378
381
  since: String(since),
379
382
  limit: String(PAGE_SIZE)
380
383
  });
381
- const { entries, hasMore } = await routeJson(`${this.speechUrl}?${query}`, { signal: abort.signal });
384
+ const { entries, hasMore } = await routeJson(`${this.#speechUrl}?${query}`, { signal: abort.signal });
382
385
  handlers.onEntries(entries);
383
386
  const last = entries.at(-1);
384
387
  if (!hasMore || last === void 0) return;
@@ -394,12 +397,12 @@ var SseSpeechFeed = class {
394
397
  // src/lib/adapters/http-status-api.ts
395
398
  /** Reads the bridge status through the UI's own status route (`url` includes the base path). */
396
399
  var HttpStatusApi = class {
397
- url;
400
+ #url;
398
401
  constructor(url) {
399
- this.url = url;
402
+ this.#url = url;
400
403
  }
401
404
  fetch() {
402
- return routeJson(this.url);
405
+ return routeJson(this.#url);
403
406
  }
404
407
  };
405
408
  // src/lib/core/sessions-pane.ts
@@ -450,10 +453,6 @@ function createConfigStore(api) {
450
453
  return inFlight;
451
454
  }
452
455
  return {
453
- /** Whether a configuration has been read yet. */
454
- get loaded() {
455
- return state !== null;
456
- },
457
456
  get reachable() {
458
457
  return reachable;
459
458
  },
@@ -600,8 +599,9 @@ function createSessionsStore(api) {
600
599
  await refreshAfterChange();
601
600
  return started;
602
601
  },
603
- async end() {
604
- await api.end();
602
+ /** Ends the session `id`; does nothing if it is no longer the current one. */
603
+ async end(id) {
604
+ await api.end(id);
605
605
  await refreshAfterChange();
606
606
  },
607
607
  /** Deletes an ended session. Rejects with the bridge's message. */
@@ -675,18 +675,18 @@ function createSpeechStore(feed, api) {
675
675
  function createStatusStore(api) {
676
676
  let status = null;
677
677
  let reachable = true;
678
- let loading = false;
678
+ let reading = false;
679
679
  let inFlight = null;
680
680
  function read() {
681
681
  if (inFlight) return inFlight;
682
- loading = true;
682
+ reading = true;
683
683
  inFlight = api.fetch().then((next) => {
684
684
  status = next;
685
685
  reachable = true;
686
686
  }).catch(() => {
687
687
  reachable = false;
688
688
  }).finally(() => {
689
- loading = false;
689
+ reading = false;
690
690
  inFlight = null;
691
691
  });
692
692
  return inFlight;
@@ -698,8 +698,9 @@ function createStatusStore(api) {
698
698
  get reachable() {
699
699
  return reachable;
700
700
  },
701
- get loading() {
702
- return loading;
701
+ /** Whether a read of the status is under way. */
702
+ get reading() {
703
+ return reading;
703
704
  },
704
705
  /** Shows the status the server rendered, so there is no flash. Does nothing once one is shown. */
705
706
  seed(next) {
@@ -709,8 +710,8 @@ function createStatusStore(api) {
709
710
  init() {
710
711
  read();
711
712
  },
712
- /** The refresh button. */
713
- retry() {
713
+ /** Reads the status now (also after a failed read, to try again). */
714
+ refresh() {
714
715
  return read();
715
716
  }
716
717
  };
@@ -740,12 +741,15 @@ function createVoiceCheckStore(statusApi, probe, keysApi) {
740
741
  let entries = [];
741
742
  let reconnecting = false;
742
743
  let failure = "";
743
- /** Counts the runs: whatever answers for an earlier one is ignored. */
744
+ /** Counts the runs: answers that belong to an earlier run are ignored. */
744
745
  let run = 0;
745
746
  /** Ends what the current run has open: its stream or its capture. */
746
747
  let close = null;
747
748
  let timer;
748
- /** Ends the current run: its stream or capture, its timer and every answer still to come. */
749
+ /**
750
+ * Ends the current run: closes its stream or capture, stops its timer and ignores any answer
751
+ * still to come.
752
+ */
749
753
  function finish() {
750
754
  run++;
751
755
  clearTimeout(timer);
@@ -881,8 +885,9 @@ function provideAppStores() {
881
885
  // src/routes/+layout.svelte
882
886
  function _layout($$renderer, $$props) {
883
887
  $$renderer.component(($$renderer) => {
884
- let { children } = $$props;
885
- const { theme: themeStore } = provideAppStores();
888
+ let { data, children } = $$props;
889
+ const { theme: themeStore, status: statusStore } = provideAppStores();
890
+ run(() => statusStore.seed(data.status));
886
891
  const navItems = [
887
892
  {
888
893
  href: resolve("/"),
@@ -905,7 +910,18 @@ function _layout($$renderer, $$props) {
905
910
  $$renderer.push(`<link rel="icon"${attr("href", favicon_default)}/> <link rel="preload" as="font" type="font/woff2"${attr("href", material_symbols_outlined_latin_400_normal_default)} crossorigin="anonymous"/> <meta name="color-scheme" content="light dark"/>`);
906
911
  });
907
912
  $$renderer.push(`<div class="app svelte-12qhfyh">`);
908
- AppHeader($$renderer, { host: page.url.host });
913
+ AppHeader($$renderer, {
914
+ host: page.url.host,
915
+ children: ($$renderer) => {
916
+ BridgeStatus($$renderer, {
917
+ status: statusStore.status,
918
+ reachable: statusStore.reachable,
919
+ reading: statusStore.reading,
920
+ onRefresh: () => void statusStore.refresh()
921
+ });
922
+ },
923
+ $$slots: { default: true }
924
+ });
909
925
  $$renderer.push(`<!----> <div class="body svelte-12qhfyh">`);
910
926
  NavRail($$renderer, {
911
927
  items: navItems,