@burdenoff/fe-libs 2026.1118.6 → 2026.1118.8
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/shared/assistant/avatar/live/createLiveAvatarSeam.js +8 -6
- package/dist/shared/assistant/speech/hostedTtsSpeechEngine.js +37 -27
- package/dist/shared/assistant/speech/index.d.ts +1 -1
- package/dist/shared/assistant/speech/notifyCancellationSpeechEngine.d.ts +14 -1
- package/dist/shared/assistant/speech/notifyCancellationSpeechEngine.js +3 -0
- package/dist/shared/assistant/speech/routingSpeechEngine.js +4 -4
- package/dist/shared/assistant/speech/speechFeed.d.ts +20 -3
- package/dist/shared/assistant/speech/speechFeed.js +25 -17
- package/dist/shared/assistant/speech/types.d.ts +68 -1
- package/dist/shared/assistant/speech/types.js +7 -2
- package/dist/shared/assistant/turnTimeline.d.ts +32 -0
- package/dist/shared/assistant/turnTimeline.js +3 -3
- package/dist/shared/assistant/ui/AssistantChatArea.js +1228 -1227
- package/dist/shared/assistant/ui/AssistantSpeechProvider.d.ts +5 -3
- package/dist/shared/assistant/ui/AssistantSpeechProvider.js +393 -346
- package/dist/shared/assistant/voice/firstClipPrefetchConfig.d.ts +19 -0
- package/dist/shared/assistant/voice/firstClipPrefetchConfig.js +8 -1
- package/dist/shared/assistant/voice/livePhraseSpeech.d.ts +23 -0
- package/dist/shared/assistant/voice/livePhraseSpeech.js +30 -30
- package/dist/shared/assistant/voice/phraseGate.d.ts +13 -0
- package/dist/shared/assistant/voice/phraseGate.js +6 -2
- package/dist/shared/assistant/voice/phrasePlayback.d.ts +59 -0
- package/dist/shared/assistant/voice/phrasePlayback.js +56 -34
- package/dist/shared/backgrounds/useBackgroundPreference.d.ts +10 -4
- package/dist/shared/backgrounds/useBackgroundPreference.js +69 -47
- package/dist/shared-assistant.js +418 -418
- package/package.json +1 -1
|
@@ -2,3 +2,22 @@ export declare function configureFirstClipPrefetch(options: {
|
|
|
2
2
|
enabled: boolean;
|
|
3
3
|
} | null): void;
|
|
4
4
|
export declare function firstClipPrefetchEnabled(): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* ★★ P1 fix 2 (BOFF-12936): the ONE first-piece rule of a voice reply, for
|
|
7
|
+
* every route that speaks one: the feed's `speak` (published at `answerDone`),
|
|
8
|
+
* the complete edge of a voice turn while P1 is on, the phrase queue's first
|
|
9
|
+
* append (alpha and the production hold alike) and the early fetch
|
|
10
|
+
* (`settledFirstChunk`). A first piece computed by one route and spoken by
|
|
11
|
+
* another used to differ: the phrase queue and the complete edge packed short
|
|
12
|
+
* replies whole, so the clip fetched early was paid for and never used.
|
|
13
|
+
*
|
|
14
|
+
* A short first segment (`SPEECH_FIRST_CHUNK_MAX_CHARS`, BOFF-8062) always;
|
|
15
|
+
* with P1 on, a first sentence of at least `FIRST_CLIP_LEAD_MIN_CHARS` also
|
|
16
|
+
* leads alone (`chunkForSpeech`'s `leadSentenceMinChars`). With P1 off every
|
|
17
|
+
* route chunks exactly as before: the feed and the phrase queue with the short
|
|
18
|
+
* first segment alone, the complete edge without this rule at all.
|
|
19
|
+
*/
|
|
20
|
+
export declare function voiceFirstPieceOptions(): {
|
|
21
|
+
firstChunkMaxChars: number;
|
|
22
|
+
leadSentenceMinChars?: number;
|
|
23
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "./speakableText.js";
|
|
1
2
|
// src/shared/assistant/voice/firstClipPrefetchConfig.ts
|
|
2
3
|
var e = !1;
|
|
3
4
|
function t(t) {
|
|
@@ -6,4 +7,10 @@ function t(t) {
|
|
|
6
7
|
function n() {
|
|
7
8
|
return e;
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
+
function r() {
|
|
11
|
+
return {
|
|
12
|
+
firstChunkMaxChars: 110,
|
|
13
|
+
...e ? { leadSentenceMinChars: 40 } : {}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export { t as configureFirstClipPrefetch, n as firstClipPrefetchEnabled, r as voiceFirstPieceOptions };
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { LiveDeltaState } from '../liveDeltas';
|
|
2
|
+
import { TurnStreamStatus } from '../turnStream';
|
|
2
3
|
export declare const NARRATION_HOLD_MS = 700;
|
|
3
4
|
export interface LivePhraseSpeech {
|
|
4
5
|
update(visible: string, live: LiveDeltaState, floor: number): void;
|
|
5
6
|
invalidate(live: LiveDeltaState, floor: number): void;
|
|
6
7
|
close(): void;
|
|
8
|
+
/**
|
|
9
|
+
* ★★ P1 review (BOFF-12936): stopped before its first release, for the
|
|
10
|
+
* source it reads now (a phrase not on screen, a part it cannot vouch for, a
|
|
11
|
+
* step that called a tool). It releases nothing more from that source, so
|
|
12
|
+
* the reply is read whole at its publish. A new source (a new text part on
|
|
13
|
+
* alpha, a new step under the production hold) re-arms it.
|
|
14
|
+
*/
|
|
15
|
+
readonly silent: boolean;
|
|
7
16
|
}
|
|
8
17
|
/** One turn's narrator. Its caller runs only on an opted-in voice/SSE overlay. */
|
|
9
18
|
export declare function createLivePhraseSpeech(options: {
|
|
@@ -41,3 +50,17 @@ export declare function createLivePhraseSpeech(options: {
|
|
|
41
50
|
setTimer?: (run: () => void, ms: number) => unknown;
|
|
42
51
|
clearTimer?: (timer: unknown) => void;
|
|
43
52
|
}): LivePhraseSpeech;
|
|
53
|
+
/**
|
|
54
|
+
* ★★ P1 review (BOFF-12936): will this turn's narrator release nothing for the
|
|
55
|
+
* answer as it stands? Then the reply is read whole at its publish (the speak
|
|
56
|
+
* route), and the first clip's early fetch must not predict the phrase route
|
|
57
|
+
* for it (`SpeechFeedItem.phraseRoute`). True when the turn has no narrator
|
|
58
|
+
* (phrase speech off, or a mode that accumulates narration), when it stopped
|
|
59
|
+
* before its first release (`silent`), or when the stream can carry no live
|
|
60
|
+
* text any more and carried none (a relay that refused the stream: the turn is
|
|
61
|
+
* polled). While the stream is minting or connecting the narrator may still
|
|
62
|
+
* release, and so it may while it has live text.
|
|
63
|
+
*/
|
|
64
|
+
export declare function narratorReleasesNothing(narrator: LivePhraseSpeech | null, stream: {
|
|
65
|
+
readonly status: TurnStreamStatus;
|
|
66
|
+
}, live: LiveDeltaState): boolean;
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { hasLiveText as e } from "../liveDeltas.js";
|
|
2
|
+
import { phraseCandidates as t, phrasesShown as n } from "./phraseGate.js";
|
|
3
3
|
// src/shared/assistant/voice/livePhraseSpeech.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
let
|
|
4
|
+
var r = 700, i = /* @__PURE__ */ new Set(["tool-calls", "error"]);
|
|
5
|
+
function a(e) {
|
|
6
|
+
let r = e.holdForFinalAnswer === !0, a = e.setTimer ?? ((e, t) => setTimeout(e, t)), o = e.clearTimer ?? ((e) => {
|
|
7
7
|
clearTimeout(e);
|
|
8
8
|
}), s = null, c = "", l = [], u = [], d = "", f = !1, p = !1, m = () => {
|
|
9
9
|
s !== null && o(s), s = null;
|
|
10
10
|
}, h = () => {
|
|
11
|
-
m(),
|
|
12
|
-
}, g = (
|
|
13
|
-
if (p || f ||
|
|
14
|
-
let
|
|
15
|
-
l = u.slice(0,
|
|
11
|
+
m(), e.retract(), f = !0;
|
|
12
|
+
}, g = (t) => {
|
|
13
|
+
if (p || f || t <= l.length) return;
|
|
14
|
+
let n = u.slice(l.length, t);
|
|
15
|
+
l = u.slice(0, t), e.append(n, d);
|
|
16
16
|
}, _ = (e, t) => {
|
|
17
17
|
let n = [...e.messages].filter(([, e]) => (e.created ?? 0) > t);
|
|
18
18
|
n.sort((e, t) => (e[1].created ?? 0) - (t[1].created ?? 0));
|
|
19
|
-
let
|
|
20
|
-
if (
|
|
21
|
-
let a = [...e.parts].filter(([, e]) => e.messageId ===
|
|
22
|
-
if (o) return
|
|
23
|
-
key:
|
|
24
|
-
messageId:
|
|
19
|
+
let i = n.at(-1)?.[0];
|
|
20
|
+
if (i === void 0) return;
|
|
21
|
+
let a = [...e.parts].filter(([, e]) => e.messageId === i), o = a.at(-1);
|
|
22
|
+
if (o) return r ? {
|
|
23
|
+
key: i,
|
|
24
|
+
messageId: i,
|
|
25
25
|
parts: a
|
|
26
26
|
} : {
|
|
27
|
-
key: `${
|
|
28
|
-
messageId:
|
|
27
|
+
key: `${i}/${o[0]}/${o[1].generation}`,
|
|
28
|
+
messageId: i,
|
|
29
29
|
parts: [o]
|
|
30
30
|
};
|
|
31
31
|
}, v = (e, t) => e.parts.some(([, e]) => !e.live || e.gapped || e.frozen || e.toolAfter || e.generation !== t.generation);
|
|
@@ -39,32 +39,32 @@ function i(n) {
|
|
|
39
39
|
if (p) return;
|
|
40
40
|
let x = _(y, b);
|
|
41
41
|
if (!x) return;
|
|
42
|
-
if (x.key !== c && (m(), c &&
|
|
42
|
+
if (x.key !== c && (m(), c && e.retract(), c = x.key, l = [], f = !1), v(x, y)) {
|
|
43
43
|
h();
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
if (f) return;
|
|
47
47
|
let S = y.messages.get(x.messageId), C = x.parts.every(([, e]) => e.ended) && S?.completed !== void 0;
|
|
48
|
-
if (
|
|
49
|
-
if (C && S?.finish !== void 0 &&
|
|
48
|
+
if (r) {
|
|
49
|
+
if (C && S?.finish !== void 0 && i.has(S.finish)) {
|
|
50
50
|
h();
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
if (!C) return;
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
h();
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
d = o;
|
|
60
|
-
let w = t(o).replace(/\s+/g, " ");
|
|
61
|
-
u.some((e) => !w.includes(e.replace(/\s+/g, " "))) ? h() : C ? (m(), g(u.length)) : (g(Math.max(0, u.length - 1)), l.length === u.length ? m() : s === null && (s = a(() => {
|
|
55
|
+
u = x.parts.flatMap(([, e]) => t(e.text, C)), l.some((e, t) => u[t] !== e) ? h() : (d = o, n(u, o) ? C ? (m(), g(u.length)) : (g(Math.max(0, u.length - 1)), l.length === u.length ? m() : s === null && (s = a(() => {
|
|
62
56
|
s = null, g(u.length);
|
|
63
|
-
}, 700)));
|
|
57
|
+
}, 700))) : h());
|
|
64
58
|
},
|
|
65
59
|
close() {
|
|
66
60
|
p = !0, m();
|
|
61
|
+
},
|
|
62
|
+
get silent() {
|
|
63
|
+
return f && l.length === 0;
|
|
67
64
|
}
|
|
68
65
|
};
|
|
69
66
|
}
|
|
70
|
-
|
|
67
|
+
function o(t, n, r) {
|
|
68
|
+
return t === null || t.silent ? !0 : (n.status === "unavailable" || n.status === "closed") && !e(r);
|
|
69
|
+
}
|
|
70
|
+
export { r as NARRATION_HOLD_MS, a as createLivePhraseSpeech, o as narratorReleasesNothing };
|
|
@@ -4,6 +4,19 @@
|
|
|
4
4
|
* Unfinished paragraphs contribute only sentences with a confirmed ending.
|
|
5
5
|
*/
|
|
6
6
|
export declare function phraseCandidates(markdown: string, final?: boolean): string[];
|
|
7
|
+
/**
|
|
8
|
+
* Is every phrase in the text the person sees (`visible`, the bubble's
|
|
9
|
+
* markdown), as it would be spoken? The narrator (`createLivePhraseSpeech`)
|
|
10
|
+
* releases nothing more once one is not, so speech never says what the screen
|
|
11
|
+
* does not show. A phrase is built with silent labels, so one that carries an
|
|
12
|
+
* e-mail address or a bare URL is never found: such a reply is read whole once
|
|
13
|
+
* it is done.
|
|
14
|
+
*
|
|
15
|
+
* ★★ P1 review (BOFF-12936): ONE function for the narrator and for the first
|
|
16
|
+
* clip's guard (`phraseRouteFirstPiece`), which reads a phrase that is not
|
|
17
|
+
* shown as "the narrator will release nothing": the two cannot drift.
|
|
18
|
+
*/
|
|
19
|
+
export declare function phrasesShown(phrases: readonly string[], visible: string): boolean;
|
|
7
20
|
/** Reconcile F against accepted/unwithdrawn S without reading the final twice. */
|
|
8
21
|
export declare function unspokenFinal(final: string, segments: readonly string[]): {
|
|
9
22
|
text: string;
|
|
@@ -35,7 +35,11 @@ function s(t, n = !1) {
|
|
|
35
35
|
}
|
|
36
36
|
return a;
|
|
37
37
|
}
|
|
38
|
-
function c(e,
|
|
38
|
+
function c(e, n) {
|
|
39
|
+
let r = t(n).replace(/\s+/g, " ");
|
|
40
|
+
return e.every((e) => r.includes(e.replace(/\s+/g, " ")));
|
|
41
|
+
}
|
|
42
|
+
function l(e, t) {
|
|
39
43
|
let n = (e) => e.replace(/\s+/g, " ").trim(), r = n(e), i = n(t.filter(Boolean).join(" "));
|
|
40
44
|
if (!i) return {
|
|
41
45
|
text: r,
|
|
@@ -60,4 +64,4 @@ function c(e, t) {
|
|
|
60
64
|
diverged: !0
|
|
61
65
|
};
|
|
62
66
|
}
|
|
63
|
-
export { s as phraseCandidates, c as unspokenFinal };
|
|
67
|
+
export { s as phraseCandidates, c as phrasesShown, l as unspokenFinal };
|
|
@@ -5,5 +5,64 @@ export interface PhrasePlayback {
|
|
|
5
5
|
retract(): void;
|
|
6
6
|
cancel(): void;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* The chunks of a reply's FIRST append, while nothing has been accepted yet:
|
|
10
|
+
* the voice reply's one first-piece rule (`voiceFirstPieceOptions`). ★ P1 fix 2
|
|
11
|
+
* (BOFF-12936): the production hold releases every phrase of the answer's step
|
|
12
|
+
* in one append, and a fast alpha stream two or three; packed whole, their first
|
|
13
|
+
* piece was not the one fetched early, and the early clip was paid for and
|
|
14
|
+
* thrown away. With P1 off this is the short first segment alone, as before.
|
|
15
|
+
*/
|
|
16
|
+
export declare function firstAppendChunks(text: string): string[];
|
|
17
|
+
/** Which route will speak a reply first, as the first clip's guard predicts it. */
|
|
18
|
+
export type PhraseRoutePrediction =
|
|
19
|
+
/** The narrator's first release: the phrase queue's first piece, and its locale. */
|
|
20
|
+
{
|
|
21
|
+
readonly route: 'phrase';
|
|
22
|
+
readonly locale: string;
|
|
23
|
+
readonly piece: string;
|
|
24
|
+
}
|
|
25
|
+
/** The narrator will release nothing: the reply is read whole at its publish. */
|
|
26
|
+
| {
|
|
27
|
+
readonly route: 'speak';
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* ★★ P1 fix 3 (BOFF-12936): the first piece the PHRASE route will speak for an
|
|
31
|
+
* answer still being written (`markdown`, as the person sees it; `visible`,
|
|
32
|
+
* the bubble's text the narrator checks), with its locale; null while that
|
|
33
|
+
* cannot be known yet.
|
|
34
|
+
*
|
|
35
|
+
* The narrator (`createLivePhraseSpeech`) releases first:
|
|
36
|
+
* - on alpha, the first completed phrase: alone (once a second one completes,
|
|
37
|
+
* or after `NARRATION_HOLD_MS`), or with the next ones (on a fast stream, or
|
|
38
|
+
* every phrase still held when the step completes);
|
|
39
|
+
* - under the production hold (`holdForFinalAnswer`), every phrase of the
|
|
40
|
+
* answer's step at once, when the step completes.
|
|
41
|
+
* Its phrases are `phraseCandidates`, whose rules are not the chunker's: a
|
|
42
|
+
* filler ("Sure.") is dropped, "approx.", "min." or "No." end a phrase, and a
|
|
43
|
+
* list, a table or a code block is withheld, so the phrases released at the
|
|
44
|
+
* step's end may join a closing line written after one. `render` must turn
|
|
45
|
+
* the released phrases into their locale and spoken text exactly as the
|
|
46
|
+
* provider's append path does; the piece is then the first chunk of the
|
|
47
|
+
* queue's first append (`firstAppendChunks`).
|
|
48
|
+
*
|
|
49
|
+
* ★★ P1 review (BOFF-12936):
|
|
50
|
+
* - Null until the first piece of the phrases so far, JOINED, is final
|
|
51
|
+
* (`firstPieceFinal`), in both modes: a later phrase (the closing line after
|
|
52
|
+
* a list, or one the step's end releases with the first) must not be able to
|
|
53
|
+
* pack into it. A short intro followed by a list and a short closing line
|
|
54
|
+
* used to be predicted as the intro alone, and the clip went unused.
|
|
55
|
+
* - `speak` when a phrase so far is not on screen as it would be spoken
|
|
56
|
+
* (`phrasesShown`, the narrator's own check: an e-mail address or a bare URL
|
|
57
|
+
* in it). The narrator then stops before any release (on alpha at once,
|
|
58
|
+
* under the hold at the step's end), and the reply is read whole at its
|
|
59
|
+
* publish, so its first piece is the speak route's. A new source re-arms the
|
|
60
|
+
* narrator (a new text part on alpha, a new step under the hold): the same
|
|
61
|
+
* bet as narration before a tool (first-clip-prefetch.md, known content bets).
|
|
62
|
+
*/
|
|
63
|
+
export declare function phraseRouteFirstPiece(markdown: string, visible: string, holdForFinalAnswer: boolean, render: (phrases: string) => {
|
|
64
|
+
locale: string;
|
|
65
|
+
text: string;
|
|
66
|
+
}): PhraseRoutePrediction | null;
|
|
8
67
|
/** One reply, one engine request. Buffer text only; synthesis stays one ahead. */
|
|
9
68
|
export declare function createPhrasePlayback(open: (handlers: SpeechSpeakHandlers) => SpeechQueue, handlers: SpeechSpeakHandlers, changed: (chunks: readonly string[]) => void, divergence: () => void): PhrasePlayback;
|
|
@@ -1,71 +1,93 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { voiceFirstPieceOptions as e } from "./firstClipPrefetchConfig.js";
|
|
2
|
+
import { MAX_SPEAKABLE_CHARS as t, chunkForSpeech as n } from "./speakableText.js";
|
|
3
|
+
import { phraseCandidates as r, phrasesShown as i, unspokenFinal as a } from "./phraseGate.js";
|
|
3
4
|
// src/shared/assistant/voice/phrasePlayback.ts
|
|
4
|
-
function
|
|
5
|
-
|
|
5
|
+
function o(t) {
|
|
6
|
+
return n(t, void 0, void 0, e());
|
|
7
|
+
}
|
|
8
|
+
var s = "4 more.";
|
|
9
|
+
function c(e) {
|
|
10
|
+
let t = o(e)[0];
|
|
11
|
+
return t !== void 0 && t === o(`${e} ${s}`)[0];
|
|
12
|
+
}
|
|
13
|
+
function l(e, t, n, a) {
|
|
14
|
+
let s = r(e), l = s[0];
|
|
15
|
+
if (l === void 0) return null;
|
|
16
|
+
if (!i(s, t)) return { route: "speak" };
|
|
17
|
+
let u = a(s.join(" "));
|
|
18
|
+
if (!c(u.text)) return null;
|
|
19
|
+
let { locale: d, text: f } = n ? u : a(l), p = o(f)[0];
|
|
20
|
+
return p === void 0 ? null : {
|
|
21
|
+
route: "phrase",
|
|
22
|
+
locale: d,
|
|
23
|
+
piece: p
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function u(e, r, i, s) {
|
|
27
|
+
let c = [], l = [], u = 0, d = !1, f = !1, p = !1, m = !1, h = !1, g = e({
|
|
6
28
|
onStart: () => {
|
|
7
|
-
|
|
29
|
+
m || r.onStart?.();
|
|
8
30
|
},
|
|
9
31
|
onChunkStart: (e) => {
|
|
10
|
-
|
|
32
|
+
m || r.onChunkStart?.(e);
|
|
11
33
|
},
|
|
12
34
|
onPause: () => {
|
|
13
|
-
|
|
35
|
+
m || r.onPause?.();
|
|
14
36
|
},
|
|
15
37
|
onDeviceFallback: () => {
|
|
16
|
-
|
|
38
|
+
m || r.onDeviceFallback?.();
|
|
17
39
|
},
|
|
18
40
|
onChunkEnd(e) {
|
|
19
|
-
|
|
41
|
+
m || (_(), r.onChunkEnd?.(e));
|
|
20
42
|
},
|
|
21
43
|
onRetract(e) {
|
|
22
|
-
if (!
|
|
23
|
-
for (let t of e)
|
|
24
|
-
|
|
44
|
+
if (!m) {
|
|
45
|
+
for (let t of e) c[t] = "";
|
|
46
|
+
i([...c]), r.onRetract?.(e);
|
|
25
47
|
}
|
|
26
48
|
},
|
|
27
49
|
onEnd() {
|
|
28
|
-
|
|
50
|
+
m || (m = !0, r.onEnd?.());
|
|
29
51
|
},
|
|
30
52
|
onError(e) {
|
|
31
|
-
|
|
53
|
+
m || (m = !0, l = [], r.onError?.(e));
|
|
32
54
|
}
|
|
33
55
|
});
|
|
34
|
-
function
|
|
35
|
-
if (!(
|
|
36
|
-
|
|
56
|
+
function _() {
|
|
57
|
+
if (!(h || m)) {
|
|
58
|
+
h = !0;
|
|
37
59
|
try {
|
|
38
|
-
for (;
|
|
39
|
-
let e =
|
|
40
|
-
if (
|
|
41
|
-
|
|
60
|
+
for (; l.length && !m && (f || !c.some(Boolean) || l.length > 1);) {
|
|
61
|
+
let e = l[0];
|
|
62
|
+
if (c.push(e), i([...c]), !g.append([e])) {
|
|
63
|
+
c.pop(), i([...c]);
|
|
42
64
|
break;
|
|
43
65
|
}
|
|
44
|
-
|
|
66
|
+
l.shift();
|
|
45
67
|
}
|
|
46
|
-
|
|
68
|
+
f && !l.length && !m && !p && (p = !0, g.end());
|
|
47
69
|
} finally {
|
|
48
|
-
|
|
70
|
+
h = !1;
|
|
49
71
|
}
|
|
50
72
|
}
|
|
51
73
|
}
|
|
52
|
-
let
|
|
74
|
+
let v = (e) => c.some(Boolean) ? n(e, void 0, void 0, { packFirstChunk: !0 }) : o(e);
|
|
53
75
|
return {
|
|
54
76
|
append(e) {
|
|
55
|
-
|
|
77
|
+
f || m || d || (u + e.length > 8e3 ? d = !0 : (u += e.length, l = v([...l, e].filter(Boolean).join(" ")), _()));
|
|
56
78
|
},
|
|
57
|
-
finish(
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
let
|
|
61
|
-
|
|
79
|
+
finish(e) {
|
|
80
|
+
if (f || m) return;
|
|
81
|
+
f = !0;
|
|
82
|
+
let n = a(e.slice(0, t), c);
|
|
83
|
+
n.diverged && s(), l = v(n.text), _();
|
|
62
84
|
},
|
|
63
85
|
retract() {
|
|
64
|
-
|
|
86
|
+
f || m || (l = [], g.retract());
|
|
65
87
|
},
|
|
66
88
|
cancel() {
|
|
67
|
-
|
|
89
|
+
m = !0, l = [], g.cancel();
|
|
68
90
|
}
|
|
69
91
|
};
|
|
70
92
|
}
|
|
71
|
-
export {
|
|
93
|
+
export { u as createPhrasePlayback, o as firstAppendChunks, l as phraseRouteFirstPiece };
|
|
@@ -10,17 +10,23 @@ export declare const BACKGROUND_PREFERENCE_KEY = "boff-background";
|
|
|
10
10
|
export interface UseBackgroundPreferenceOptions {
|
|
11
11
|
/** The keys' namespace (default `boff-background`). */
|
|
12
12
|
storageKey?: string;
|
|
13
|
+
/**
|
|
14
|
+
* This product's own default, merged over the library default (dotted waves, accent, subtle).
|
|
15
|
+
* It applies wherever nothing valid is stored, and `reset()` returns to it. Pass a stable
|
|
16
|
+
* value (a module constant); its fields, not its identity, are what is used.
|
|
17
|
+
*/
|
|
18
|
+
defaults?: Partial<BackgroundPreference>;
|
|
13
19
|
}
|
|
14
20
|
export interface BackgroundPreferenceControls extends BackgroundPreference {
|
|
15
21
|
setEffect(effect: BackgroundEffectName): void;
|
|
16
22
|
setColors(colors: BackgroundColorMode): void;
|
|
17
23
|
setStrength(strength: BackgroundStrength): void;
|
|
18
|
-
/** Back to the default. */
|
|
24
|
+
/** Back to the default (the `defaults` option merged over the library default). */
|
|
19
25
|
reset(): void;
|
|
20
26
|
}
|
|
21
|
-
/** The stored choice (each field validated; anything else is the default). */
|
|
22
|
-
export declare function readBackgroundPreference(storageKey?: string): BackgroundPreference;
|
|
27
|
+
/** The stored choice (each field validated; anything else is the default, or the given `defaults`). */
|
|
28
|
+
export declare function readBackgroundPreference(storageKey?: string, defaults?: Partial<BackgroundPreference>): BackgroundPreference;
|
|
23
29
|
/** The person's background choice and its setters. */
|
|
24
|
-
export declare function useBackgroundPreference({ storageKey, }?: UseBackgroundPreferenceOptions): BackgroundPreferenceControls;
|
|
30
|
+
export declare function useBackgroundPreference({ storageKey, defaults, }?: UseBackgroundPreferenceOptions): BackgroundPreferenceControls;
|
|
25
31
|
/** Tests only: forget the in-memory channels (the stored values stay). */
|
|
26
32
|
export declare function resetBackgroundPreferenceChannels(): void;
|
|
@@ -24,86 +24,108 @@ function u() {
|
|
|
24
24
|
function d(e, t) {
|
|
25
25
|
return l[e].includes(t);
|
|
26
26
|
}
|
|
27
|
-
function f(e
|
|
28
|
-
let t =
|
|
29
|
-
|
|
27
|
+
function f(e) {
|
|
28
|
+
let t = { ...o };
|
|
29
|
+
if (!e) return t;
|
|
30
|
+
let n = (n) => {
|
|
31
|
+
let r = e[n];
|
|
32
|
+
d(n, r) && (t[n] = r);
|
|
33
|
+
};
|
|
34
|
+
return n("effect"), n("colors"), n("strength"), t;
|
|
35
|
+
}
|
|
36
|
+
function p(e = s, t) {
|
|
37
|
+
let n = f(t), r = u(), i = (t) => {
|
|
38
|
+
let i = null;
|
|
30
39
|
try {
|
|
31
|
-
|
|
40
|
+
i = r?.getItem(`${e}-${t}`) ?? null;
|
|
32
41
|
} catch {
|
|
33
|
-
|
|
42
|
+
i = null;
|
|
34
43
|
}
|
|
35
|
-
return d(
|
|
44
|
+
return d(t, i) ? i : n[t];
|
|
36
45
|
};
|
|
37
46
|
return {
|
|
38
|
-
effect:
|
|
39
|
-
colors:
|
|
40
|
-
strength:
|
|
47
|
+
effect: i("effect"),
|
|
48
|
+
colors: i("colors"),
|
|
49
|
+
strength: i("strength")
|
|
41
50
|
};
|
|
42
51
|
}
|
|
43
|
-
var
|
|
44
|
-
function
|
|
45
|
-
let
|
|
46
|
-
if (!
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
var m = /* @__PURE__ */ new Map(), h = (e, t) => c.every((n) => e[n] === t[n]);
|
|
53
|
+
function g(e, t) {
|
|
54
|
+
let n = m.get(e);
|
|
55
|
+
if (!n) {
|
|
56
|
+
let r = f(t);
|
|
57
|
+
n = {
|
|
58
|
+
value: p(e, r),
|
|
59
|
+
defaults: r,
|
|
60
|
+
listeners: /* @__PURE__ */ new Set(),
|
|
61
|
+
unpersisted: !1
|
|
62
|
+
}, m.set(e, n);
|
|
63
|
+
} else if (n.listeners.size === 0 && !n.unpersisted) {
|
|
64
|
+
t && (n.defaults = f(t));
|
|
65
|
+
let r = p(e, n.defaults);
|
|
66
|
+
h(r, n.value) || (n.value = r);
|
|
54
67
|
}
|
|
55
|
-
return
|
|
68
|
+
return n;
|
|
56
69
|
}
|
|
57
|
-
function
|
|
58
|
-
let n =
|
|
59
|
-
if (!
|
|
70
|
+
function _(e, t) {
|
|
71
|
+
let n = g(e);
|
|
72
|
+
if (!h(n.value, t)) {
|
|
60
73
|
n.value = t;
|
|
61
74
|
for (let e of [...n.listeners]) e();
|
|
62
75
|
}
|
|
63
76
|
}
|
|
64
|
-
function
|
|
77
|
+
function v(e, t) {
|
|
65
78
|
let n = u(), r = n !== null;
|
|
66
79
|
for (let i of c) try {
|
|
67
80
|
n?.setItem(`${e}-${i}`, t[i]);
|
|
68
81
|
} catch {
|
|
69
82
|
r = !1;
|
|
70
83
|
}
|
|
71
|
-
|
|
84
|
+
g(e).unpersisted = !r, _(e, t);
|
|
72
85
|
}
|
|
73
|
-
var
|
|
74
|
-
function
|
|
75
|
-
for (let [t, n] of
|
|
86
|
+
var y = 0;
|
|
87
|
+
function b(e) {
|
|
88
|
+
for (let [t, n] of m) (e.key === null || e.key.startsWith(`${t}-`)) && (n.unpersisted = !1, _(t, p(t, n.defaults)));
|
|
76
89
|
}
|
|
77
|
-
function
|
|
90
|
+
function x() {
|
|
78
91
|
if (typeof window > "u") return () => void 0;
|
|
79
|
-
|
|
92
|
+
y === 0 && window.addEventListener("storage", b), y += 1;
|
|
80
93
|
let e = !1;
|
|
81
94
|
return () => {
|
|
82
|
-
e || (e = !0, --
|
|
95
|
+
e || (e = !0, --y, y === 0 && window.removeEventListener("storage", b));
|
|
83
96
|
};
|
|
84
97
|
}
|
|
85
|
-
function
|
|
86
|
-
let t =
|
|
87
|
-
|
|
98
|
+
function S({ storageKey: e = s, defaults: t } = {}) {
|
|
99
|
+
let { effect: n, colors: o, strength: c } = t ?? {}, l = i(() => f({
|
|
100
|
+
effect: n,
|
|
101
|
+
colors: o,
|
|
102
|
+
strength: c
|
|
103
|
+
}), [
|
|
104
|
+
n,
|
|
105
|
+
o,
|
|
106
|
+
c
|
|
107
|
+
]), u = r((t) => {
|
|
108
|
+
let n = x(), r = g(e, l);
|
|
88
109
|
return r.listeners.add(t), () => {
|
|
89
110
|
r.listeners.delete(t), n();
|
|
90
111
|
};
|
|
91
|
-
}, [e]),
|
|
92
|
-
d(t, n) &&
|
|
93
|
-
...
|
|
112
|
+
}, [e, l]), p = r(() => g(e, l).value, [e, l]), m = a(u, p, () => l), h = r((t, n) => {
|
|
113
|
+
d(t, n) && v(e, {
|
|
114
|
+
...g(e).value,
|
|
94
115
|
[t]: n
|
|
95
116
|
});
|
|
96
117
|
}, [e]);
|
|
97
118
|
return i(() => ({
|
|
98
|
-
...
|
|
99
|
-
setEffect: (e) =>
|
|
100
|
-
setColors: (e) =>
|
|
101
|
-
setStrength: (e) =>
|
|
102
|
-
reset: () =>
|
|
119
|
+
...m,
|
|
120
|
+
setEffect: (e) => h("effect", e),
|
|
121
|
+
setColors: (e) => h("colors", e),
|
|
122
|
+
setStrength: (e) => h("strength", e),
|
|
123
|
+
reset: () => v(e, { ...g(e, l).defaults })
|
|
103
124
|
}), [
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
e
|
|
125
|
+
m,
|
|
126
|
+
h,
|
|
127
|
+
e,
|
|
128
|
+
l
|
|
107
129
|
]);
|
|
108
130
|
}
|
|
109
|
-
export { s as BACKGROUND_PREFERENCE_KEY, o as DEFAULT_BACKGROUND_PREFERENCE,
|
|
131
|
+
export { s as BACKGROUND_PREFERENCE_KEY, o as DEFAULT_BACKGROUND_PREFERENCE, p as readBackgroundPreference, S as useBackgroundPreference };
|