@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.
- package/dist/cli.mjs +1109 -792
- package/dist/ui/adapter-node.js +1 -1
- package/dist/ui/client/ui/_app/immutable/chunks/BEImj5AP.js +1 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BEImj5AP.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BEImj5AP.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/B__KpOuX.js +3 -0
- package/dist/ui/client/ui/_app/immutable/chunks/B__KpOuX.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/B__KpOuX.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BkoDSEOx.js +1 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BkoDSEOx.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BkoDSEOx.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BlC5mir6.js +1 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BlC5mir6.js.br +2 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BlC5mir6.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BquQTeuV.js +1 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BquQTeuV.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BquQTeuV.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BtnuBvK5.js +1 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BtnuBvK5.js.br +1 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BtnuBvK5.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/{Dk73DTz3.js → BuwZGWCm.js} +21 -21
- package/dist/ui/client/ui/_app/immutable/chunks/BuwZGWCm.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/BuwZGWCm.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Bxh3K0TK.js +1 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Bxh3K0TK.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Bxh3K0TK.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/C06IiL6m.js +1 -0
- package/dist/ui/client/ui/_app/immutable/chunks/C06IiL6m.js.br +2 -0
- package/dist/ui/client/ui/_app/immutable/chunks/C06IiL6m.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/C75l7c5l.js +1 -0
- package/dist/ui/client/ui/_app/immutable/chunks/C75l7c5l.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/C75l7c5l.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/{hhZsYtkz.js → CAZ56n62.js} +3 -3
- package/dist/ui/client/ui/_app/immutable/chunks/CAZ56n62.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/CAZ56n62.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Cb63XE4v.js +33 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Cb63XE4v.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Cb63XE4v.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DRNNJMYk.js +5 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DRNNJMYk.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DRNNJMYk.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DWjfB3ah.js +1 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DWjfB3ah.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DWjfB3ah.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/JsC3ASJq.js +3 -0
- package/dist/ui/client/ui/_app/immutable/chunks/JsC3ASJq.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/JsC3ASJq.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/{DU8ibkb0.js → OAsMjdHF.js} +13 -13
- package/dist/ui/client/ui/_app/immutable/chunks/OAsMjdHF.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/OAsMjdHF.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/UKukklIc.js +1 -0
- package/dist/ui/client/ui/_app/immutable/chunks/UKukklIc.js.br +2 -0
- package/dist/ui/client/ui/_app/immutable/chunks/UKukklIc.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/{DoG5cwE3.js → VxDST09k.js} +1 -1
- package/dist/ui/client/ui/_app/immutable/chunks/VxDST09k.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/VxDST09k.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/{CEGGem4o.js → vPs9G1oN.js} +36 -36
- package/dist/ui/client/ui/_app/immutable/chunks/vPs9G1oN.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/vPs9G1oN.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/{Bq3k_s8n.js → w5i9ZoX_.js} +2 -2
- package/dist/ui/client/ui/_app/immutable/chunks/w5i9ZoX_.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/w5i9ZoX_.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/entry/app.B2MXuPeH.js +2 -0
- package/dist/ui/client/ui/_app/immutable/entry/app.B2MXuPeH.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/entry/app.B2MXuPeH.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/entry/start.4hiWLKwq.js +2 -0
- package/dist/ui/client/ui/_app/immutable/entry/start.4hiWLKwq.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/entry/start.4hiWLKwq.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/0.CEfoZ0Mb.js +1 -0
- package/dist/ui/client/ui/_app/immutable/nodes/0.CEfoZ0Mb.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/0.CEfoZ0Mb.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/1.BBl7b45u.js +1 -0
- package/dist/ui/client/ui/_app/immutable/nodes/1.BBl7b45u.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/1.BBl7b45u.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/2.4VpydhMh.js +1 -0
- package/dist/ui/client/ui/_app/immutable/nodes/2.4VpydhMh.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/2.4VpydhMh.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/3.BzIz3rja.js +5 -0
- package/dist/ui/client/ui/_app/immutable/nodes/3.BzIz3rja.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/3.BzIz3rja.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/4.B9Ke6ZBV.js +180 -0
- package/dist/ui/client/ui/_app/immutable/nodes/4.B9Ke6ZBV.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/4.B9Ke6ZBV.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/5.Cm6I95kb.js +6 -0
- package/dist/ui/client/ui/_app/immutable/nodes/5.Cm6I95kb.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/5.Cm6I95kb.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/6.B_1Pts2e.js +6 -0
- package/dist/ui/client/ui/_app/immutable/nodes/6.B_1Pts2e.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/6.B_1Pts2e.js.gz +0 -0
- package/dist/ui/client/ui/_app/version.json +1 -1
- package/dist/ui/client/ui/_app/version.json.br +0 -0
- package/dist/ui/client/ui/_app/version.json.gz +0 -0
- package/dist/ui/server/.vite/manifest.json +83 -38
- package/dist/ui/server/chunks/{composition.js → app-context.js} +5 -965
- package/dist/ui/server/chunks/app-context.js.map +1 -0
- package/dist/ui/server/chunks/config2.js +106 -0
- package/dist/ui/server/chunks/config2.js.map +1 -0
- package/dist/ui/server/chunks/dialog.js +1 -1
- package/dist/ui/server/chunks/instance.js +3 -3
- package/dist/ui/server/chunks/internal.js +1 -1
- package/dist/ui/server/chunks/outlined-button.js +1 -1
- package/dist/ui/server/chunks/outlined-text-field.js +1 -1
- package/dist/ui/server/chunks/redispatch-event.js +1 -1
- package/dist/ui/server/chunks/rolldown-runtime.js +12 -0
- package/dist/ui/server/chunks/rules.js +173 -0
- package/dist/ui/server/chunks/rules.js.map +1 -0
- package/dist/ui/server/chunks/sessions.remote.js +1 -11
- package/dist/ui/server/chunks/sessions.remote.js.map +1 -1
- package/dist/ui/server/chunks/setup.js +86 -0
- package/dist/ui/server/chunks/setup.js.map +1 -0
- package/dist/ui/server/chunks/{icon-button.js → speech.js} +42 -3
- package/dist/ui/server/chunks/speech.js.map +1 -0
- package/dist/ui/server/chunks/src.js +37 -183
- package/dist/ui/server/chunks/src.js.map +1 -1
- package/dist/ui/server/chunks/static-html.js +1 -1
- package/dist/ui/server/chunks/text-button.js +1 -1
- package/dist/ui/server/chunks/validate.js +23 -0
- package/dist/ui/server/chunks/validate.js.map +1 -0
- package/dist/ui/server/chunks/vocabulary.js +19 -0
- package/dist/ui/server/chunks/vocabulary.js.map +1 -0
- package/dist/ui/server/entries/endpoints/api/config/_server.ts.js +4 -2
- package/dist/ui/server/entries/endpoints/api/config/_server.ts.js.map +1 -1
- package/dist/ui/server/entries/endpoints/api/input/keys/_server.ts.js +15 -5
- package/dist/ui/server/entries/endpoints/api/input/keys/_server.ts.js.map +1 -1
- package/dist/ui/server/entries/endpoints/api/markers/_server.ts.js +4 -2
- package/dist/ui/server/entries/endpoints/api/markers/_server.ts.js.map +1 -1
- package/dist/ui/server/entries/endpoints/api/sessions/_server.ts.js +4 -2
- package/dist/ui/server/entries/endpoints/api/sessions/_server.ts.js.map +1 -1
- package/dist/ui/server/entries/endpoints/api/speech/_server.ts.js +10 -13
- package/dist/ui/server/entries/endpoints/api/speech/_server.ts.js.map +1 -1
- package/dist/ui/server/entries/endpoints/api/status/_server.ts.js +2 -1
- package/dist/ui/server/entries/endpoints/api/status/_server.ts.js.map +1 -1
- package/dist/ui/server/entries/hooks.server.js +30 -25
- package/dist/ui/server/entries/hooks.server.js.map +1 -1
- package/dist/ui/server/entries/pages/_layout.svelte.js +750 -3
- package/dist/ui/server/entries/pages/_layout.svelte.js.map +1 -1
- package/dist/ui/server/entries/pages/_page.svelte.js +34 -25
- package/dist/ui/server/entries/pages/_page.svelte.js.map +1 -1
- package/dist/ui/server/entries/pages/settings/_page.svelte.js +5 -3
- package/dist/ui/server/entries/pages/settings/_page.svelte.js.map +1 -1
- package/dist/ui/server/entries/pages/setup/_page.svelte.js +2 -1
- package/dist/ui/server/entries/pages/setup/_page.svelte.js.map +1 -1
- package/dist/ui/server/entries/pages/setup/instructions/_page.svelte.js +3 -2
- package/dist/ui/server/entries/pages/setup/instructions/_page.svelte.js.map +1 -1
- package/dist/ui/server/manifest-full.js +1 -1
- package/dist/ui/server/manifest.js +1 -1
- package/dist/ui/server/nodes/0.js +1 -1
- package/dist/ui/server/nodes/1.js +1 -1
- package/dist/ui/server/nodes/2.js +1 -1
- package/dist/ui/server/nodes/3.js +1 -1
- package/dist/ui/server/nodes/4.js +1 -1
- package/dist/ui/server/nodes/5.js +1 -1
- package/dist/ui/server/nodes/6.js +1 -1
- package/dist/ui/server/server.js +1 -1
- package/package.json +1 -1
- package/dist/ui/client/ui/_app/immutable/chunks/0FroJ-XN.js +0 -3
- package/dist/ui/client/ui/_app/immutable/chunks/0FroJ-XN.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/0FroJ-XN.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/B_ZElYu_.js +0 -1
- package/dist/ui/client/ui/_app/immutable/chunks/B_ZElYu_.js.br +0 -2
- package/dist/ui/client/ui/_app/immutable/chunks/B_ZElYu_.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Bq3k_s8n.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Bq3k_s8n.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/CEGGem4o.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/CEGGem4o.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/CVpgcnu3.js +0 -1
- package/dist/ui/client/ui/_app/immutable/chunks/CVpgcnu3.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/CVpgcnu3.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Cwz551Q0.js +0 -5
- package/dist/ui/client/ui/_app/immutable/chunks/Cwz551Q0.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Cwz551Q0.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/D-2Nx62w.js +0 -1
- package/dist/ui/client/ui/_app/immutable/chunks/D-2Nx62w.js.br +0 -4
- package/dist/ui/client/ui/_app/immutable/chunks/D-2Nx62w.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DHsTyp2W.js +0 -1
- package/dist/ui/client/ui/_app/immutable/chunks/DHsTyp2W.js.br +0 -2
- package/dist/ui/client/ui/_app/immutable/chunks/DHsTyp2W.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DJvJc_zO.js +0 -33
- package/dist/ui/client/ui/_app/immutable/chunks/DJvJc_zO.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DJvJc_zO.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DU8ibkb0.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DU8ibkb0.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Dk73DTz3.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Dk73DTz3.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DoG5cwE3.js.br +0 -3
- package/dist/ui/client/ui/_app/immutable/chunks/DoG5cwE3.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Dvxhfd7j.js +0 -3
- package/dist/ui/client/ui/_app/immutable/chunks/Dvxhfd7j.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/Dvxhfd7j.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/DzInmTUe.js +0 -1
- package/dist/ui/client/ui/_app/immutable/chunks/DzInmTUe.js.br +0 -1
- package/dist/ui/client/ui/_app/immutable/chunks/DzInmTUe.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/hhZsYtkz.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/chunks/hhZsYtkz.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/entry/app.Bic9wlww.js +0 -2
- package/dist/ui/client/ui/_app/immutable/entry/app.Bic9wlww.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/entry/app.Bic9wlww.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/entry/start.DqIv9xYX.js +0 -2
- package/dist/ui/client/ui/_app/immutable/entry/start.DqIv9xYX.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/entry/start.DqIv9xYX.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/0.IqK6bsxB.js +0 -1
- package/dist/ui/client/ui/_app/immutable/nodes/0.IqK6bsxB.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/0.IqK6bsxB.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/1.C81neQJL.js +0 -1
- package/dist/ui/client/ui/_app/immutable/nodes/1.C81neQJL.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/1.C81neQJL.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/2.CmlyeAx_.js +0 -1
- package/dist/ui/client/ui/_app/immutable/nodes/2.CmlyeAx_.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/2.CmlyeAx_.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/3.DYZ3H5TS.js +0 -5
- package/dist/ui/client/ui/_app/immutable/nodes/3.DYZ3H5TS.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/3.DYZ3H5TS.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/4.Lwlmq1AY.js +0 -180
- package/dist/ui/client/ui/_app/immutable/nodes/4.Lwlmq1AY.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/4.Lwlmq1AY.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/5.rBMVkFpN.js +0 -6
- package/dist/ui/client/ui/_app/immutable/nodes/5.rBMVkFpN.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/5.rBMVkFpN.js.gz +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/6.nui9awM2.js +0 -6
- package/dist/ui/client/ui/_app/immutable/nodes/6.nui9awM2.js.br +0 -0
- package/dist/ui/client/ui/_app/immutable/nodes/6.nui9awM2.js.gz +0 -0
- package/dist/ui/server/chunks/composition.js.map +0 -1
- package/dist/ui/server/chunks/icon-button.js.map +0 -1
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { nt as resolve } from "../../chunks/internal.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 } 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, 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
|
+
import { t as checkDto } from "../../chunks/validate.js";
|
|
4
5
|
import "../../chunks/paths.js";
|
|
5
6
|
import { t as page } from "../../chunks/state.js";
|
|
6
|
-
import { n as
|
|
7
|
-
import "../../chunks/
|
|
7
|
+
import { n as appStores, t as APP_STORES } from "../../chunks/app-context.js";
|
|
8
|
+
import { t as MAX_ROWS } from "../../chunks/speech.js";
|
|
8
9
|
import { t as isCurrent } from "../../chunks/navigation.js";
|
|
10
|
+
import { c as parseTheme, o as DEFAULT_THEME, t as SettingRejected } from "../../chunks/config2.js";
|
|
11
|
+
import { t as getSessions } from "../../chunks/sessions.remote.js";
|
|
12
|
+
import { l as SpeechEntrySchema } from "../../chunks/src.js";
|
|
13
|
+
import { i as QUIET_MS, n as CHECK_CHORD, r as LISTEN_TIMEOUT_MS, t as CHECK_CAPTURE } from "../../chunks/setup.js";
|
|
9
14
|
// src/lib/assets/favicon.svg
|
|
10
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";
|
|
11
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
|
|
@@ -131,6 +136,748 @@ function NavRail($$renderer, $$props) {
|
|
|
131
136
|
$$renderer.push(`<!--]--></ul></nav> <span class="visually-hidden" role="status">${escape_html(announcement)}</span>`);
|
|
132
137
|
});
|
|
133
138
|
}
|
|
139
|
+
// src/lib/adapters/browser-clipboard.ts
|
|
140
|
+
/**
|
|
141
|
+
* 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.
|
|
143
|
+
*/
|
|
144
|
+
var BrowserClipboard = class {
|
|
145
|
+
async copy(text) {
|
|
146
|
+
const modern = navigator.clipboard;
|
|
147
|
+
if (modern !== void 0) try {
|
|
148
|
+
await modern.writeText(text);
|
|
149
|
+
return true;
|
|
150
|
+
} catch {}
|
|
151
|
+
return copySelected(text);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
/** Copies through a text area that exists only for this, then gives the focus back. */
|
|
155
|
+
function copySelected(text) {
|
|
156
|
+
const focused = document.activeElement;
|
|
157
|
+
const area = document.createElement("textarea");
|
|
158
|
+
area.value = text;
|
|
159
|
+
area.readOnly = true;
|
|
160
|
+
area.setAttribute("aria-hidden", "true");
|
|
161
|
+
Object.assign(area.style, {
|
|
162
|
+
position: "fixed",
|
|
163
|
+
top: "0",
|
|
164
|
+
left: "0",
|
|
165
|
+
opacity: "0"
|
|
166
|
+
});
|
|
167
|
+
document.body.append(area);
|
|
168
|
+
try {
|
|
169
|
+
area.select();
|
|
170
|
+
return document.execCommand("copy");
|
|
171
|
+
} catch {
|
|
172
|
+
return false;
|
|
173
|
+
} finally {
|
|
174
|
+
area.remove();
|
|
175
|
+
if (focused instanceof HTMLElement) focused.focus({ preventScroll: true });
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// src/lib/adapters/browser-theme-storage.ts
|
|
179
|
+
var THEME_STORAGE_KEY = "sr-theme";
|
|
180
|
+
/** Keeps the theme in `localStorage` and applies it as `data-theme` on `<html>`. */
|
|
181
|
+
var BrowserThemeStorage = class {
|
|
182
|
+
read() {
|
|
183
|
+
try {
|
|
184
|
+
return parseTheme(localStorage.getItem(THEME_STORAGE_KEY));
|
|
185
|
+
} catch {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
write(theme) {
|
|
190
|
+
document.documentElement.dataset.theme = theme;
|
|
191
|
+
try {
|
|
192
|
+
localStorage.setItem(THEME_STORAGE_KEY, theme);
|
|
193
|
+
} catch {}
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
// src/lib/adapters/route-request.ts
|
|
197
|
+
var defaultRejection = (error, status) => new Error(error?.message ?? `The request answered ${status}`);
|
|
198
|
+
/** Calls one of the UI's own routes (`url` includes the base path) and rejects unless it is ok. */
|
|
199
|
+
async function routeRequest(url, { method = "GET", body, signal, rejection = defaultRejection } = {}) {
|
|
200
|
+
const response = await fetch(url, {
|
|
201
|
+
method,
|
|
202
|
+
headers: {
|
|
203
|
+
accept: "application/json",
|
|
204
|
+
...body === void 0 ? {} : { "content-type": "application/json" }
|
|
205
|
+
},
|
|
206
|
+
body: body === void 0 ? void 0 : JSON.stringify(body),
|
|
207
|
+
signal
|
|
208
|
+
});
|
|
209
|
+
if (!response.ok) throw rejection(await readRouteError(response), response.status);
|
|
210
|
+
return response;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* {@link routeRequest} for a JSON answer. It is not checked again: the BFF already checked the
|
|
214
|
+
* bridge's answer against the contract (`lib/server/bridge-api.ts`), and only the UI calls its
|
|
215
|
+
* routes. `T` is what the route answers.
|
|
216
|
+
*/
|
|
217
|
+
async function routeJson(url, request) {
|
|
218
|
+
return await (await routeRequest(url, request)).json();
|
|
219
|
+
}
|
|
220
|
+
async function readRouteError(response) {
|
|
221
|
+
const body = await response.json().catch(() => void 0);
|
|
222
|
+
if (typeof body !== "object" || body === null || !("message" in body)) return null;
|
|
223
|
+
const { message } = body;
|
|
224
|
+
if (typeof message !== "string") return null;
|
|
225
|
+
return {
|
|
226
|
+
message,
|
|
227
|
+
field: "field" in body && typeof body.field === "string" ? body.field : void 0
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
// src/lib/adapters/http-config-api.ts
|
|
231
|
+
/** A refused save names the bridge's reason (and the setting, when it names one). */
|
|
232
|
+
var rejection = (error, status) => error === null ? /* @__PURE__ */ new Error(`The request answered ${status}`) : new SettingRejected(error.message, error.field);
|
|
233
|
+
/** Reads and saves the configuration through the UI's own config route (`url` includes the base path). */
|
|
234
|
+
var HttpConfigApi = class {
|
|
235
|
+
url;
|
|
236
|
+
constructor(url) {
|
|
237
|
+
this.url = url;
|
|
238
|
+
}
|
|
239
|
+
/** `GET /ui/api/config` answers `{ active, saved, overrides }` in one go. */
|
|
240
|
+
fetch() {
|
|
241
|
+
return routeJson(this.url, { rejection });
|
|
242
|
+
}
|
|
243
|
+
update(patch) {
|
|
244
|
+
return routeJson(this.url, {
|
|
245
|
+
method: "PUT",
|
|
246
|
+
body: patch,
|
|
247
|
+
rejection
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
// src/lib/adapters/http-keys-api.ts
|
|
252
|
+
/** Sends key presses through the UI's own route (`url` includes the base path). */
|
|
253
|
+
var HttpKeysApi = class {
|
|
254
|
+
url;
|
|
255
|
+
constructor(url) {
|
|
256
|
+
this.url = url;
|
|
257
|
+
}
|
|
258
|
+
pressAndCapture(keys, capture, signal) {
|
|
259
|
+
return routeJson(this.url, {
|
|
260
|
+
method: "POST",
|
|
261
|
+
body: {
|
|
262
|
+
keys,
|
|
263
|
+
capture
|
|
264
|
+
},
|
|
265
|
+
signal
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
// src/lib/adapters/http-speech-api.ts
|
|
270
|
+
/** Changes the speech through the UI's own markers and speech routes (the urls include the base path). */
|
|
271
|
+
var HttpSpeechApi = class {
|
|
272
|
+
markersUrl;
|
|
273
|
+
speechUrl;
|
|
274
|
+
constructor(markersUrl, speechUrl) {
|
|
275
|
+
this.markersUrl = markersUrl;
|
|
276
|
+
this.speechUrl = speechUrl;
|
|
277
|
+
}
|
|
278
|
+
async addMarker(label) {
|
|
279
|
+
await routeRequest(this.markersUrl, {
|
|
280
|
+
method: "POST",
|
|
281
|
+
body: { label }
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
async clear(scope) {
|
|
285
|
+
await routeRequest(`${this.speechUrl}?session=${scope}`, { method: "DELETE" });
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
// src/lib/adapters/http-sessions-api.ts
|
|
289
|
+
/**
|
|
290
|
+
* Reads the sessions with the `getSessions` remote query and changes them through the UI's own
|
|
291
|
+
* sessions routes (`url` includes the base path).
|
|
292
|
+
*/
|
|
293
|
+
var HttpSessionsApi = class {
|
|
294
|
+
url;
|
|
295
|
+
constructor(url) {
|
|
296
|
+
this.url = url;
|
|
297
|
+
}
|
|
298
|
+
/** Always asks the server again: a query keeps its last answer while anything still uses it. */
|
|
299
|
+
async list() {
|
|
300
|
+
const sessions = getSessions();
|
|
301
|
+
await sessions.refresh();
|
|
302
|
+
return sessions.current;
|
|
303
|
+
}
|
|
304
|
+
start(name, run) {
|
|
305
|
+
return routeJson(this.url, {
|
|
306
|
+
method: "POST",
|
|
307
|
+
body: {
|
|
308
|
+
name,
|
|
309
|
+
run
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
async end() {
|
|
314
|
+
await routeRequest(`${this.url}/end`, { method: "POST" });
|
|
315
|
+
}
|
|
316
|
+
async delete(id) {
|
|
317
|
+
await routeRequest(`${this.url}/${id}`, { method: "DELETE" });
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
// src/lib/adapters/sse-speech-feed.ts
|
|
321
|
+
/** Entries read per request when an ended session is read page by page. */
|
|
322
|
+
var PAGE_SIZE = 1e3;
|
|
323
|
+
/**
|
|
324
|
+
* Reads the speech of a scope through the UI's own routes (`urls` include the base path):
|
|
325
|
+
* - A live scope is followed on the stream relay with `?since=0`, so the bridge replays the
|
|
326
|
+
* buffer first. `EventSource` reconnects by itself and sends `Last-Event-ID`, so a drop only
|
|
327
|
+
* shows as `reconnecting` and the missed entries are replayed. A refused stream shows as
|
|
328
|
+
* `failed`.
|
|
329
|
+
* - An ended session never gets new entries: it is read page by page, once, without a stream.
|
|
330
|
+
*/
|
|
331
|
+
var SseSpeechFeed = class {
|
|
332
|
+
streamUrl;
|
|
333
|
+
speechUrl;
|
|
334
|
+
constructor(streamUrl, speechUrl) {
|
|
335
|
+
this.streamUrl = streamUrl;
|
|
336
|
+
this.speechUrl = speechUrl;
|
|
337
|
+
}
|
|
338
|
+
open(scope, live, handlers) {
|
|
339
|
+
handlers.onState("connecting");
|
|
340
|
+
return live ? this.follow(scope, handlers) : this.read(scope, handlers);
|
|
341
|
+
}
|
|
342
|
+
listen(since, handlers) {
|
|
343
|
+
const source = this.stream(`since=${since}`, (entry) => handlers.onEntry(entry));
|
|
344
|
+
this.report(source, (state) => handlers.onState(state));
|
|
345
|
+
return () => source.close();
|
|
346
|
+
}
|
|
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
|
+
source.addEventListener("clear", () => handlers.onClear());
|
|
351
|
+
return () => source.close();
|
|
352
|
+
}
|
|
353
|
+
report(source, onState) {
|
|
354
|
+
source.onopen = () => onState("live");
|
|
355
|
+
source.onerror = () => onState(source.readyState === EventSource.CLOSED ? "failed" : "reconnecting");
|
|
356
|
+
}
|
|
357
|
+
stream(query, onEntry) {
|
|
358
|
+
const source = new EventSource(`${this.streamUrl}?${query}`);
|
|
359
|
+
source.addEventListener("entry", (event) => {
|
|
360
|
+
let data;
|
|
361
|
+
try {
|
|
362
|
+
data = JSON.parse(event.data);
|
|
363
|
+
} catch {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
const checked = checkDto(SpeechEntrySchema, data);
|
|
367
|
+
if (checked.ok) onEntry(checked.value);
|
|
368
|
+
});
|
|
369
|
+
return source;
|
|
370
|
+
}
|
|
371
|
+
read(scope, handlers) {
|
|
372
|
+
const abort = new AbortController();
|
|
373
|
+
const load = async () => {
|
|
374
|
+
let since = 0;
|
|
375
|
+
for (;;) {
|
|
376
|
+
const query = new URLSearchParams({
|
|
377
|
+
session: String(scope),
|
|
378
|
+
since: String(since),
|
|
379
|
+
limit: String(PAGE_SIZE)
|
|
380
|
+
});
|
|
381
|
+
const { entries, hasMore } = await routeJson(`${this.speechUrl}?${query}`, { signal: abort.signal });
|
|
382
|
+
handlers.onEntries(entries);
|
|
383
|
+
const last = entries.at(-1);
|
|
384
|
+
if (!hasMore || last === void 0) return;
|
|
385
|
+
since = last.seq;
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
load().then(() => handlers.onState("ended"), () => {
|
|
389
|
+
if (!abort.signal.aborted) handlers.onState("failed");
|
|
390
|
+
});
|
|
391
|
+
return () => abort.abort();
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
// src/lib/adapters/http-status-api.ts
|
|
395
|
+
/** Reads the bridge status through the UI's own status route (`url` includes the base path). */
|
|
396
|
+
var HttpStatusApi = class {
|
|
397
|
+
url;
|
|
398
|
+
constructor(url) {
|
|
399
|
+
this.url = url;
|
|
400
|
+
}
|
|
401
|
+
fetch() {
|
|
402
|
+
return routeJson(this.url);
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
// src/lib/core/sessions-pane.ts
|
|
406
|
+
/** Parses the stored text; anything but `'1'` / `'0'` counts as no choice. */
|
|
407
|
+
function parseCollapsed(raw) {
|
|
408
|
+
if (raw === "1") return true;
|
|
409
|
+
if (raw === "0") return false;
|
|
410
|
+
return null;
|
|
411
|
+
}
|
|
412
|
+
function serializeCollapsed(collapsed) {
|
|
413
|
+
return collapsed ? "1" : "0";
|
|
414
|
+
}
|
|
415
|
+
// src/lib/adapters/browser-sessions-pane-storage.ts
|
|
416
|
+
var SESSIONS_PANE_STORAGE_KEY = "sr-sessions-collapsed";
|
|
417
|
+
/** Keeps the sessions pane's collapsed choice in `localStorage`. */
|
|
418
|
+
var BrowserSessionsPaneStorage = class {
|
|
419
|
+
read() {
|
|
420
|
+
try {
|
|
421
|
+
return parseCollapsed(localStorage.getItem(SESSIONS_PANE_STORAGE_KEY));
|
|
422
|
+
} catch {
|
|
423
|
+
return null;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
write(collapsed) {
|
|
427
|
+
try {
|
|
428
|
+
localStorage.setItem(SESSIONS_PANE_STORAGE_KEY, serializeCollapsed(collapsed));
|
|
429
|
+
} catch {}
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
// src/lib/stores/config.svelte.ts
|
|
433
|
+
function createConfigStore(api) {
|
|
434
|
+
let state = null;
|
|
435
|
+
let reachable = true;
|
|
436
|
+
let reading = false;
|
|
437
|
+
let inFlight = null;
|
|
438
|
+
function read() {
|
|
439
|
+
if (inFlight) return inFlight;
|
|
440
|
+
reading = true;
|
|
441
|
+
inFlight = api.fetch().then((next) => {
|
|
442
|
+
state = next;
|
|
443
|
+
reachable = true;
|
|
444
|
+
}).catch(() => {
|
|
445
|
+
reachable = false;
|
|
446
|
+
}).finally(() => {
|
|
447
|
+
inFlight = null;
|
|
448
|
+
reading = false;
|
|
449
|
+
});
|
|
450
|
+
return inFlight;
|
|
451
|
+
}
|
|
452
|
+
return {
|
|
453
|
+
/** Whether a configuration has been read yet. */
|
|
454
|
+
get loaded() {
|
|
455
|
+
return state !== null;
|
|
456
|
+
},
|
|
457
|
+
get reachable() {
|
|
458
|
+
return reachable;
|
|
459
|
+
},
|
|
460
|
+
/** Whether a read of the configuration is under way. */
|
|
461
|
+
get reading() {
|
|
462
|
+
return reading;
|
|
463
|
+
},
|
|
464
|
+
get active() {
|
|
465
|
+
return state?.active ?? null;
|
|
466
|
+
},
|
|
467
|
+
get saved() {
|
|
468
|
+
return state?.saved ?? null;
|
|
469
|
+
},
|
|
470
|
+
/** Settings a flag or variable sets, by dotted path, with what sets them. */
|
|
471
|
+
get overrides() {
|
|
472
|
+
return state?.overrides ?? {};
|
|
473
|
+
},
|
|
474
|
+
/**
|
|
475
|
+
* Shows the configuration the page's load read, before any request of its own. Call it while
|
|
476
|
+
* the page renders, on the server too: the stores are per request, so the server's HTML and the
|
|
477
|
+
* first browser render agree. Unlike a list that is polled, every load's answer replaces what
|
|
478
|
+
* is shown; `null` (the load failed) changes nothing.
|
|
479
|
+
*/
|
|
480
|
+
seed(next) {
|
|
481
|
+
if (next === null) return;
|
|
482
|
+
state = next;
|
|
483
|
+
reachable = true;
|
|
484
|
+
},
|
|
485
|
+
/** Reads the configuration now (also after a failed read, to try again). */
|
|
486
|
+
refresh() {
|
|
487
|
+
return read();
|
|
488
|
+
},
|
|
489
|
+
/** Saves a partial config for the next start. Rejects with the bridge's message. */
|
|
490
|
+
async save(patch) {
|
|
491
|
+
await api.update(patch);
|
|
492
|
+
await inFlight;
|
|
493
|
+
await read();
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
// src/lib/stores/sessions-pane.svelte.ts
|
|
498
|
+
function createSessionsPaneStore(storage) {
|
|
499
|
+
let collapsed = true;
|
|
500
|
+
return {
|
|
501
|
+
get collapsed() {
|
|
502
|
+
return collapsed;
|
|
503
|
+
},
|
|
504
|
+
/** Pick up the saved choice. Call it in the browser only, after hydration. */
|
|
505
|
+
init() {
|
|
506
|
+
collapsed = storage.read() ?? false;
|
|
507
|
+
},
|
|
508
|
+
toggle() {
|
|
509
|
+
collapsed = !collapsed;
|
|
510
|
+
storage.write(collapsed);
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
// src/lib/stores/sessions.svelte.ts
|
|
515
|
+
var REFRESH_MS = 3e3;
|
|
516
|
+
function createSessionsStore(api) {
|
|
517
|
+
let sessions = [];
|
|
518
|
+
let currentId = null;
|
|
519
|
+
let outsideEntries = 0;
|
|
520
|
+
let reachable = true;
|
|
521
|
+
let loaded = false;
|
|
522
|
+
let now = Date.now();
|
|
523
|
+
let inFlight = null;
|
|
524
|
+
function apply(list, at = Date.now()) {
|
|
525
|
+
sessions = list.sessions;
|
|
526
|
+
currentId = list.currentId;
|
|
527
|
+
outsideEntries = list.outsideEntries;
|
|
528
|
+
now = at;
|
|
529
|
+
loaded = true;
|
|
530
|
+
}
|
|
531
|
+
function read() {
|
|
532
|
+
if (inFlight) return inFlight;
|
|
533
|
+
inFlight = api.list().then((list) => {
|
|
534
|
+
apply(list);
|
|
535
|
+
reachable = true;
|
|
536
|
+
}).catch(() => {
|
|
537
|
+
reachable = false;
|
|
538
|
+
}).finally(() => {
|
|
539
|
+
inFlight = null;
|
|
540
|
+
});
|
|
541
|
+
return inFlight;
|
|
542
|
+
}
|
|
543
|
+
/** A read that started before the change would show the old list, so wait for it and read again. */
|
|
544
|
+
async function refreshAfterChange() {
|
|
545
|
+
await inFlight;
|
|
546
|
+
await read();
|
|
547
|
+
}
|
|
548
|
+
return {
|
|
549
|
+
get sessions() {
|
|
550
|
+
return sessions;
|
|
551
|
+
},
|
|
552
|
+
get currentId() {
|
|
553
|
+
return currentId;
|
|
554
|
+
},
|
|
555
|
+
/** Entries in the buffer recorded outside any session. */
|
|
556
|
+
get outsideEntries() {
|
|
557
|
+
return outsideEntries;
|
|
558
|
+
},
|
|
559
|
+
/** Whether a list has been applied yet (the seed or a read). */
|
|
560
|
+
get loaded() {
|
|
561
|
+
return loaded;
|
|
562
|
+
},
|
|
563
|
+
get reachable() {
|
|
564
|
+
return reachable;
|
|
565
|
+
},
|
|
566
|
+
/** Epoch ms, ticking once a second while a session is live (for its duration). */
|
|
567
|
+
get now() {
|
|
568
|
+
return now;
|
|
569
|
+
},
|
|
570
|
+
/**
|
|
571
|
+
* Shows the list the page's load read (`now`: when it was read), before any request of its
|
|
572
|
+
* own. Call it while the page renders, on the server too: the stores are per request, so the
|
|
573
|
+
* server's HTML and the first browser render agree. Does nothing once a list is shown.
|
|
574
|
+
*/
|
|
575
|
+
seed(list, at) {
|
|
576
|
+
if (list !== null && !loaded) apply(list, at);
|
|
577
|
+
},
|
|
578
|
+
/**
|
|
579
|
+
* Reads the list and keeps it fresh. Call it in the browser only. Returns the function that
|
|
580
|
+
* stops the timers (call it when the page goes away).
|
|
581
|
+
*/
|
|
582
|
+
init() {
|
|
583
|
+
read();
|
|
584
|
+
const tick = setInterval(() => {
|
|
585
|
+
if (currentId !== null) now = Date.now();
|
|
586
|
+
}, 1e3);
|
|
587
|
+
const refresh = setInterval(() => void read(), REFRESH_MS);
|
|
588
|
+
return () => {
|
|
589
|
+
clearInterval(tick);
|
|
590
|
+
clearInterval(refresh);
|
|
591
|
+
};
|
|
592
|
+
},
|
|
593
|
+
/** Reads the list now, for a change made elsewhere (the speech of a scope was cleared). */
|
|
594
|
+
refresh() {
|
|
595
|
+
return refreshAfterChange();
|
|
596
|
+
},
|
|
597
|
+
/** Starts a session, which ends the previous one. Rejects with the bridge's message. */
|
|
598
|
+
async start(name, run) {
|
|
599
|
+
const started = await api.start(name, run);
|
|
600
|
+
await refreshAfterChange();
|
|
601
|
+
return started;
|
|
602
|
+
},
|
|
603
|
+
async end() {
|
|
604
|
+
await api.end();
|
|
605
|
+
await refreshAfterChange();
|
|
606
|
+
},
|
|
607
|
+
/** Deletes an ended session. Rejects with the bridge's message. */
|
|
608
|
+
async delete(id) {
|
|
609
|
+
await api.delete(id);
|
|
610
|
+
await refreshAfterChange();
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
// src/lib/stores/speech.svelte.ts
|
|
615
|
+
function createSpeechStore(feed, api) {
|
|
616
|
+
let entries = [];
|
|
617
|
+
let connection = "connecting";
|
|
618
|
+
let close = null;
|
|
619
|
+
function stop() {
|
|
620
|
+
close?.();
|
|
621
|
+
close = null;
|
|
622
|
+
}
|
|
623
|
+
/** Adds entries newer than the last one shown (a replay after a reconnect repeats some). */
|
|
624
|
+
function append(added) {
|
|
625
|
+
let lastSeq = entries.at(-1)?.seq ?? 0;
|
|
626
|
+
const fresh = [];
|
|
627
|
+
for (const entry of added) {
|
|
628
|
+
if (entry.seq <= lastSeq) continue;
|
|
629
|
+
fresh.push(entry);
|
|
630
|
+
lastSeq = entry.seq;
|
|
631
|
+
}
|
|
632
|
+
if (fresh.length === 0) return;
|
|
633
|
+
const next = [...entries, ...fresh];
|
|
634
|
+
entries = next.length > 5e3 ? next.slice(next.length - MAX_ROWS) : next;
|
|
635
|
+
}
|
|
636
|
+
return {
|
|
637
|
+
get entries() {
|
|
638
|
+
return entries;
|
|
639
|
+
},
|
|
640
|
+
get connection() {
|
|
641
|
+
return connection;
|
|
642
|
+
},
|
|
643
|
+
/**
|
|
644
|
+
* Shows the speech of `scope`, replacing what was shown. A live scope replays the buffer and
|
|
645
|
+
* follows; an ended session is read once. After a reconnect the stream resumes where it left
|
|
646
|
+
* off, and an entry seen twice is dropped. Returns the function that stops the stream.
|
|
647
|
+
*/
|
|
648
|
+
open(scope, live) {
|
|
649
|
+
stop();
|
|
650
|
+
entries = [];
|
|
651
|
+
connection = "connecting";
|
|
652
|
+
close = feed.open(scope, live, {
|
|
653
|
+
onEntry: (entry) => append([entry]),
|
|
654
|
+
onEntries: append,
|
|
655
|
+
onClear() {
|
|
656
|
+
entries = [];
|
|
657
|
+
},
|
|
658
|
+
onState(state) {
|
|
659
|
+
connection = state;
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
return stop;
|
|
663
|
+
},
|
|
664
|
+
/** Rejects with the reason; the table empties through the feed (the bridge's `clear` event). */
|
|
665
|
+
clear(scope) {
|
|
666
|
+
return api.clear(scope);
|
|
667
|
+
},
|
|
668
|
+
/** Rejects with the reason; the new entry arrives through the feed, so nothing is added here. */
|
|
669
|
+
addMarker(label) {
|
|
670
|
+
return api.addMarker(label);
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
// src/lib/stores/status.svelte.ts
|
|
675
|
+
function createStatusStore(api) {
|
|
676
|
+
let status = null;
|
|
677
|
+
let reachable = true;
|
|
678
|
+
let loading = false;
|
|
679
|
+
let inFlight = null;
|
|
680
|
+
function read() {
|
|
681
|
+
if (inFlight) return inFlight;
|
|
682
|
+
loading = true;
|
|
683
|
+
inFlight = api.fetch().then((next) => {
|
|
684
|
+
status = next;
|
|
685
|
+
reachable = true;
|
|
686
|
+
}).catch(() => {
|
|
687
|
+
reachable = false;
|
|
688
|
+
}).finally(() => {
|
|
689
|
+
loading = false;
|
|
690
|
+
inFlight = null;
|
|
691
|
+
});
|
|
692
|
+
return inFlight;
|
|
693
|
+
}
|
|
694
|
+
return {
|
|
695
|
+
get status() {
|
|
696
|
+
return status;
|
|
697
|
+
},
|
|
698
|
+
get reachable() {
|
|
699
|
+
return reachable;
|
|
700
|
+
},
|
|
701
|
+
get loading() {
|
|
702
|
+
return loading;
|
|
703
|
+
},
|
|
704
|
+
/** Shows the status the server rendered, so there is no flash. Does nothing once one is shown. */
|
|
705
|
+
seed(next) {
|
|
706
|
+
if (next !== null && status === null) status = next;
|
|
707
|
+
},
|
|
708
|
+
/** Reads the status once. Call it in the browser only. */
|
|
709
|
+
init() {
|
|
710
|
+
read();
|
|
711
|
+
},
|
|
712
|
+
/** The refresh button. */
|
|
713
|
+
retry() {
|
|
714
|
+
return read();
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
// src/lib/stores/theme.svelte.ts
|
|
719
|
+
function createThemeStore(storage) {
|
|
720
|
+
let current = DEFAULT_THEME;
|
|
721
|
+
return {
|
|
722
|
+
get current() {
|
|
723
|
+
return current;
|
|
724
|
+
},
|
|
725
|
+
/** Pick up the saved choice. Call it in the browser only, after hydration. */
|
|
726
|
+
init() {
|
|
727
|
+
current = storage.read() ?? "light";
|
|
728
|
+
},
|
|
729
|
+
/** Apply and remember a choice. */
|
|
730
|
+
set(theme) {
|
|
731
|
+
current = theme;
|
|
732
|
+
storage.write(theme);
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
// src/lib/stores/voice-check.svelte.ts
|
|
737
|
+
function createVoiceCheckStore(statusApi, probe, keysApi) {
|
|
738
|
+
let phase = "idle";
|
|
739
|
+
let via = "manual";
|
|
740
|
+
let entries = [];
|
|
741
|
+
let reconnecting = false;
|
|
742
|
+
let failure = "";
|
|
743
|
+
/** Counts the runs: whatever answers for an earlier one is ignored. */
|
|
744
|
+
let run = 0;
|
|
745
|
+
/** Ends what the current run has open: its stream or its capture. */
|
|
746
|
+
let close = null;
|
|
747
|
+
let timer;
|
|
748
|
+
/** Ends the current run: its stream or capture, its timer and every answer still to come. */
|
|
749
|
+
function finish() {
|
|
750
|
+
run++;
|
|
751
|
+
clearTimeout(timer);
|
|
752
|
+
close?.();
|
|
753
|
+
close = null;
|
|
754
|
+
reconnecting = false;
|
|
755
|
+
}
|
|
756
|
+
function fail(message) {
|
|
757
|
+
finish();
|
|
758
|
+
phase = "failed";
|
|
759
|
+
failure = message;
|
|
760
|
+
}
|
|
761
|
+
/** Gives up listening after a while. A lost connection is a failure, not silence. */
|
|
762
|
+
function giveUpListening() {
|
|
763
|
+
timer = setTimeout(() => {
|
|
764
|
+
if (reconnecting) {
|
|
765
|
+
fail("The connection to the bridge was lost.");
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
finish();
|
|
769
|
+
phase = "silent";
|
|
770
|
+
}, LISTEN_TIMEOUT_MS);
|
|
771
|
+
}
|
|
772
|
+
/** Waits for speech someone makes by hand, in any session or outside one. */
|
|
773
|
+
async function listen(mine) {
|
|
774
|
+
phase = "starting";
|
|
775
|
+
let since;
|
|
776
|
+
try {
|
|
777
|
+
since = (await statusApi.fetch()).buffer.lastSeq ?? 0;
|
|
778
|
+
} catch {
|
|
779
|
+
if (mine === run) fail("The bridge is not reachable.");
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
if (mine !== run) return;
|
|
783
|
+
phase = "listening";
|
|
784
|
+
close = probe.listen(since, {
|
|
785
|
+
onEntry(entry) {
|
|
786
|
+
if (mine !== run || entry.kind === "marker") return;
|
|
787
|
+
entries = [...entries, entry];
|
|
788
|
+
phase = "heard";
|
|
789
|
+
clearTimeout(timer);
|
|
790
|
+
if (entries.length >= 5) finish();
|
|
791
|
+
else timer = setTimeout(finish, QUIET_MS);
|
|
792
|
+
},
|
|
793
|
+
onState(state) {
|
|
794
|
+
if (mine !== run) return;
|
|
795
|
+
if (state !== "failed") reconnecting = state === "reconnecting";
|
|
796
|
+
else if (phase === "heard") finish();
|
|
797
|
+
else fail("The speech stream is not available.");
|
|
798
|
+
}
|
|
799
|
+
});
|
|
800
|
+
giveUpListening();
|
|
801
|
+
}
|
|
802
|
+
/** Has the bridge send {@link CHECK_CHORD} and answer with the speech it caused. */
|
|
803
|
+
async function sendKeys(mine) {
|
|
804
|
+
phase = "listening";
|
|
805
|
+
const request = new AbortController();
|
|
806
|
+
close = () => request.abort();
|
|
807
|
+
try {
|
|
808
|
+
const capture = await keysApi.pressAndCapture(CHECK_CHORD, CHECK_CAPTURE, request.signal);
|
|
809
|
+
if (mine !== run) return;
|
|
810
|
+
finish();
|
|
811
|
+
entries = capture.entries.slice(0, 5);
|
|
812
|
+
phase = entries.length > 0 ? "heard" : "silent";
|
|
813
|
+
} catch (cause) {
|
|
814
|
+
if (mine === run) fail(cause instanceof Error ? cause.message : "The keys could not be sent.");
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
return {
|
|
818
|
+
get phase() {
|
|
819
|
+
return phase;
|
|
820
|
+
},
|
|
821
|
+
get via() {
|
|
822
|
+
return via;
|
|
823
|
+
},
|
|
824
|
+
/** The speech that arrived, oldest first. */
|
|
825
|
+
get entries() {
|
|
826
|
+
return entries;
|
|
827
|
+
},
|
|
828
|
+
get reconnecting() {
|
|
829
|
+
return reconnecting;
|
|
830
|
+
},
|
|
831
|
+
/** Why the check failed. */
|
|
832
|
+
get failure() {
|
|
833
|
+
return failure;
|
|
834
|
+
},
|
|
835
|
+
/**
|
|
836
|
+
* Waits for new speech (`manual`), or sends the keys and takes what they cause (`keys`).
|
|
837
|
+
* Replaces a run that is still going.
|
|
838
|
+
*/
|
|
839
|
+
async start(how) {
|
|
840
|
+
finish();
|
|
841
|
+
via = how;
|
|
842
|
+
entries = [];
|
|
843
|
+
failure = "";
|
|
844
|
+
await (how === "manual" ? listen(run) : sendKeys(run));
|
|
845
|
+
},
|
|
846
|
+
/** Stops listening and forgets the result. */
|
|
847
|
+
stop() {
|
|
848
|
+
finish();
|
|
849
|
+
phase = "idle";
|
|
850
|
+
entries = [];
|
|
851
|
+
failure = "";
|
|
852
|
+
}
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
// src/lib/composition.ts
|
|
856
|
+
/** Wires the adapters into the stores; components get the stores, never the adapters. */
|
|
857
|
+
function createAppStores() {
|
|
858
|
+
const statusApi = new HttpStatusApi(resolve("/api/status"));
|
|
859
|
+
const speechFeed = new SseSpeechFeed(resolve("/api/speech/stream"), resolve("/api/speech"));
|
|
860
|
+
const speechApi = new HttpSpeechApi(resolve("/api/markers"), resolve("/api/speech"));
|
|
861
|
+
const clipboard = new BrowserClipboard();
|
|
862
|
+
return {
|
|
863
|
+
theme: createThemeStore(new BrowserThemeStorage()),
|
|
864
|
+
status: createStatusStore(statusApi),
|
|
865
|
+
config: createConfigStore(new HttpConfigApi(resolve("/api/config"))),
|
|
866
|
+
sessions: createSessionsStore(new HttpSessionsApi(resolve("/api/sessions"))),
|
|
867
|
+
speech: createSpeechStore(speechFeed, speechApi),
|
|
868
|
+
voiceCheck: createVoiceCheckStore(statusApi, speechFeed, new HttpKeysApi(resolve("/api/input/keys"))),
|
|
869
|
+
sessionsPane: createSessionsPaneStore(new BrowserSessionsPaneStorage()),
|
|
870
|
+
clipboard
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Creates the stores of one app and hands them to the components below (the root layout calls it).
|
|
875
|
+
* Not a module-level singleton: on the server every request renders its own app, and a store
|
|
876
|
+
* shared by all of them would show one viewer's state to another.
|
|
877
|
+
*/
|
|
878
|
+
function provideAppStores() {
|
|
879
|
+
return setContext(APP_STORES, createAppStores());
|
|
880
|
+
}
|
|
134
881
|
// src/routes/+layout.svelte
|
|
135
882
|
function _layout($$renderer, $$props) {
|
|
136
883
|
$$renderer.component(($$renderer) => {
|