dsh-mimo-speak 0.0.0-stage → 0.1.2

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 (109) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +197 -2
  3. package/README.zh.md +166 -0
  4. package/cordis.patch.yml +20 -0
  5. package/icon.svg +6 -0
  6. package/lib/client.js +3607 -0
  7. package/lib/client.js.map +1 -0
  8. package/lib/node/brief.d.ts +23 -0
  9. package/lib/node/brief.js +110 -0
  10. package/lib/node/brief.js.map +1 -0
  11. package/lib/node/client/BundleConfigCard.d.ts +15 -0
  12. package/lib/node/client/BundleConfigCard.js +22 -0
  13. package/lib/node/client/BundleConfigCard.js.map +1 -0
  14. package/lib/node/client/PlayerBar.d.ts +45 -0
  15. package/lib/node/client/PlayerBar.js +83 -0
  16. package/lib/node/client/PlayerBar.js.map +1 -0
  17. package/lib/node/client/SettingsSectionCard.d.ts +14 -0
  18. package/lib/node/client/SettingsSectionCard.js +19 -0
  19. package/lib/node/client/SettingsSectionCard.js.map +1 -0
  20. package/lib/node/client/SpeakAction.d.ts +32 -0
  21. package/lib/node/client/SpeakAction.js +651 -0
  22. package/lib/node/client/SpeakAction.js.map +1 -0
  23. package/lib/node/client/SpeakerIcon.d.ts +11 -0
  24. package/lib/node/client/SpeakerIcon.js +5 -0
  25. package/lib/node/client/SpeakerIcon.js.map +1 -0
  26. package/lib/node/client/TtsSettingsForm.d.ts +27 -0
  27. package/lib/node/client/TtsSettingsForm.js +164 -0
  28. package/lib/node/client/TtsSettingsForm.js.map +1 -0
  29. package/lib/node/client/api.d.ts +89 -0
  30. package/lib/node/client/api.js +247 -0
  31. package/lib/node/client/api.js.map +1 -0
  32. package/lib/node/client/audio-bus.d.ts +29 -0
  33. package/lib/node/client/audio-bus.js +91 -0
  34. package/lib/node/client/audio-bus.js.map +1 -0
  35. package/lib/node/client/chat-text.d.ts +32 -0
  36. package/lib/node/client/chat-text.js +90 -0
  37. package/lib/node/client/chat-text.js.map +1 -0
  38. package/lib/node/client/highlight.d.ts +45 -0
  39. package/lib/node/client/highlight.js +198 -0
  40. package/lib/node/client/highlight.js.map +1 -0
  41. package/lib/node/client/index.d.ts +26 -0
  42. package/lib/node/client/index.js +89 -0
  43. package/lib/node/client/index.js.map +1 -0
  44. package/lib/node/client/locales.d.ts +19 -0
  45. package/lib/node/client/locales.js +180 -0
  46. package/lib/node/client/locales.js.map +1 -0
  47. package/lib/node/client/panel-visibility.d.ts +24 -0
  48. package/lib/node/client/panel-visibility.js +16 -0
  49. package/lib/node/client/panel-visibility.js.map +1 -0
  50. package/lib/node/client/settings-controller.d.ts +116 -0
  51. package/lib/node/client/settings-controller.js +201 -0
  52. package/lib/node/client/settings-controller.js.map +1 -0
  53. package/lib/node/client/settings-registration.d.ts +24 -0
  54. package/lib/node/client/settings-registration.js +21 -0
  55. package/lib/node/client/settings-registration.js.map +1 -0
  56. package/lib/node/client/slots.d.ts +48 -0
  57. package/lib/node/client/slots.js +15 -0
  58. package/lib/node/client/slots.js.map +1 -0
  59. package/lib/node/client/speech-cache.d.ts +59 -0
  60. package/lib/node/client/speech-cache.js +68 -0
  61. package/lib/node/client/speech-cache.js.map +1 -0
  62. package/lib/node/client/split-speech.d.ts +20 -0
  63. package/lib/node/client/split-speech.js +100 -0
  64. package/lib/node/client/split-speech.js.map +1 -0
  65. package/lib/node/client/status.d.ts +28 -0
  66. package/lib/node/client/status.js +60 -0
  67. package/lib/node/client/status.js.map +1 -0
  68. package/lib/node/client/stream-dispose.d.ts +119 -0
  69. package/lib/node/client/stream-dispose.js +249 -0
  70. package/lib/node/client/stream-dispose.js.map +1 -0
  71. package/lib/node/client/styles.d.ts +19 -0
  72. package/lib/node/client/styles.js +176 -0
  73. package/lib/node/client/styles.js.map +1 -0
  74. package/lib/node/client/use-audio-player.d.ts +44 -0
  75. package/lib/node/client/use-audio-player.js +102 -0
  76. package/lib/node/client/use-audio-player.js.map +1 -0
  77. package/lib/node/client/use-audio-queue.d.ts +44 -0
  78. package/lib/node/client/use-audio-queue.js +151 -0
  79. package/lib/node/client/use-audio-queue.js.map +1 -0
  80. package/lib/node/client/use-stream-player.d.ts +41 -0
  81. package/lib/node/client/use-stream-player.js +60 -0
  82. package/lib/node/client/use-stream-player.js.map +1 -0
  83. package/lib/node/edge-tts.d.ts +21 -0
  84. package/lib/node/edge-tts.js +111 -0
  85. package/lib/node/edge-tts.js.map +1 -0
  86. package/lib/node/index.d.ts +97 -0
  87. package/lib/node/index.js +463 -0
  88. package/lib/node/index.js.map +1 -0
  89. package/lib/node/normalize.d.ts +30 -0
  90. package/lib/node/normalize.js +72 -0
  91. package/lib/node/normalize.js.map +1 -0
  92. package/lib/node/settings.d.ts +186 -0
  93. package/lib/node/settings.js +74 -0
  94. package/lib/node/settings.js.map +1 -0
  95. package/lib/node/summarize.d.ts +29 -0
  96. package/lib/node/summarize.js +131 -0
  97. package/lib/node/summarize.js.map +1 -0
  98. package/lib/node/tool.d.ts +54 -0
  99. package/lib/node/tool.js +123 -0
  100. package/lib/node/tool.js.map +1 -0
  101. package/lib/node/tts.d.ts +127 -0
  102. package/lib/node/tts.js +361 -0
  103. package/lib/node/tts.js.map +1 -0
  104. package/lib/node/wav.d.ts +32 -0
  105. package/lib/node/wav.js +63 -0
  106. package/lib/node/wav.js.map +1 -0
  107. package/locale/en.json +6 -0
  108. package/locale/zh.json +6 -0
  109. package/package.json +122 -4
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Sentence-aligned text splitting for pipelined playback.
3
+ *
4
+ * The browser splits already-normalized speakable text into chunks around a
5
+ * configured size, then synthesizes and plays them back-to-back while the next
6
+ * chunk is still being produced. Splitting at sentence boundaries keeps chunks
7
+ * sounding natural; a sentence longer than the budget is hard-split at a
8
+ * punctuation or whitespace seam.
9
+ * @module dsh-mimo-speak/client/split-speech
10
+ */
11
+ /** Characters that end a spoken sentence. */
12
+ const SENTENCE_END = '。!?!?;;…\n';
13
+ /** Longest tolerated chunk before a sentence is hard-split. */
14
+ function clampChunkChars(value) {
15
+ if (!Number.isFinite(value))
16
+ return 120;
17
+ return Math.min(1000, Math.max(20, Math.round(value)));
18
+ }
19
+ /**
20
+ * Hard-split one over-long sentence at punctuation seams, preferring the
21
+ * second half of the budget so the tail of each chunk stays natural.
22
+ * @param piece - one sentence that exceeds the chunk budget.
23
+ * @param limit - chunk size in characters.
24
+ * @returns the sentence broken into budget-sized pieces.
25
+ */
26
+ function hardSplit(piece, limit) {
27
+ const parts = [];
28
+ let rest = piece;
29
+ while (rest.length > limit) {
30
+ let cut = -1;
31
+ const floor = Math.floor(limit * 0.5);
32
+ for (let index = Math.min(limit, rest.length - 1); index > floor; index -= 1) {
33
+ const char = rest.charAt(index);
34
+ if (char === ' ' || char === '\n' || char === ',' || char === ',' || char === '、') {
35
+ cut = index + 1;
36
+ break;
37
+ }
38
+ }
39
+ if (cut <= 0)
40
+ cut = limit;
41
+ parts.push(rest.slice(0, cut));
42
+ rest = rest.slice(cut);
43
+ }
44
+ if (rest.length > 0)
45
+ parts.push(rest);
46
+ return parts;
47
+ }
48
+ /**
49
+ * Split normalized speakable text into ordered chunks at sentence boundaries.
50
+ *
51
+ * @param text - plain text, already stripped of Markdown by the Host's
52
+ * normalizer; this function only partitions it for playback.
53
+ * @param chunkChars - target chunk size in characters.
54
+ * @returns speakable chunks, each non-empty and at most `chunkChars` long
55
+ * except when a single unbroken sentence must be hard-split.
56
+ */
57
+ export function splitForSpeech(text, chunkChars) {
58
+ const trimmed = (text ?? '').trim();
59
+ if (trimmed.length === 0)
60
+ return [];
61
+ const limit = clampChunkChars(chunkChars);
62
+ const sentences = [];
63
+ let buffer = '';
64
+ for (let index = 0; index < trimmed.length; index += 1) {
65
+ const char = trimmed.charAt(index);
66
+ buffer += char;
67
+ if (SENTENCE_END.indexOf(char) >= 0) {
68
+ sentences.push(buffer);
69
+ buffer = '';
70
+ }
71
+ }
72
+ if (buffer.length > 0)
73
+ sentences.push(buffer);
74
+ const chunks = [];
75
+ let current = '';
76
+ for (const sentence of sentences) {
77
+ if (sentence.trim().length === 0)
78
+ continue;
79
+ if (sentence.length > limit) {
80
+ if (current.trim().length > 0) {
81
+ chunks.push(current.trim());
82
+ current = '';
83
+ }
84
+ for (const part of hardSplit(sentence, limit)) {
85
+ if (part.trim().length > 0)
86
+ chunks.push(part.trim());
87
+ }
88
+ continue;
89
+ }
90
+ if (current.length + sentence.length > limit && current.trim().length > 0) {
91
+ chunks.push(current.trim());
92
+ current = '';
93
+ }
94
+ current += sentence;
95
+ }
96
+ if (current.trim().length > 0)
97
+ chunks.push(current.trim());
98
+ return chunks.filter(chunk => chunk.length > 0);
99
+ }
100
+ //# sourceMappingURL=split-speech.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"split-speech.js","sourceRoot":"","sources":["../../../src/client/split-speech.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,6CAA6C;AAC7C,MAAM,YAAY,GAAG,YAAY,CAAA;AAEjC,+DAA+D;AAC/D,SAAS,eAAe,CAAC,KAAa;IACpC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,GAAG,CAAA;IACvC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AACxD,CAAC;AAED;;;;;;GAMG;AACH,SAAS,SAAS,CAAC,KAAa,EAAE,KAAa;IAC7C,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,IAAI,IAAI,GAAG,KAAK,CAAA;IAChB,OAAO,IAAI,CAAC,MAAM,GAAG,KAAK,EAAE,CAAC;QAC3B,IAAI,GAAG,GAAG,CAAC,CAAC,CAAA;QACZ,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,CAAA;QACrC,KAAK,IAAI,KAAK,GAAG,IAAI,CAAC,GAA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A;QACd,CAAC;QACD,OAAO,IAAI,QAAQ,CAAA;IACrB,CAAC;IACD,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;IAC1D,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;AACjD,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The engine-status mirror shared by the speak entries and the Plugins-page
3
+ * card.
4
+ *
5
+ * One `GET /api/mimo-speak/status` answers every mounted control: entries lazy-
6
+ * load it on first hover/focus, the Plugins-page card refreshes it after each
7
+ * write that could change whether a key exists. Failures publish the
8
+ * "unconfigured" view rather than an error state — a missing answer must not
9
+ * claim a key exists.
10
+ * @module dsh-mimo-speak/client/status
11
+ */
12
+ import { type SnapshotStore } from '@deepseek-ai/dsh-client-store';
13
+ import type { TtsStatusView } from '../settings.ts';
14
+ /**
15
+ * @returns the shared status mirror every control derives from.
16
+ */
17
+ export declare function ttsStatusStore(): SnapshotStore<TtsStatusView>;
18
+ /**
19
+ * Ensure one status read is under way; concurrent callers share it.
20
+ * @returns the read in flight, which never rejects.
21
+ */
22
+ export declare function ensureTtsStatus(): Promise<void>;
23
+ /**
24
+ * Re-read the status even when one is already under way; called after writes
25
+ * that could add or remove the API key.
26
+ * @returns the fresh read, which never rejects.
27
+ */
28
+ export declare function refreshTtsStatus(): Promise<void>;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The engine-status mirror shared by the speak entries and the Plugins-page
3
+ * card.
4
+ *
5
+ * One `GET /api/mimo-speak/status` answers every mounted control: entries lazy-
6
+ * load it on first hover/focus, the Plugins-page card refreshes it after each
7
+ * write that could change whether a key exists. Failures publish the
8
+ * "unconfigured" view rather than an error state — a missing answer must not
9
+ * claim a key exists.
10
+ * @module dsh-mimo-speak/client/status
11
+ */
12
+ import { createSnapshotStore } from '@deepseek-ai/dsh-client-store';
13
+ import { DEFAULT_BASE_URL, DEFAULT_CHUNK_CHARS, DEFAULT_EDGE_VOICE, DEFAULT_FALLBACK_ENGINE, DEFAULT_HIGHLIGHT, DEFAULT_MAX_CHARS, DEFAULT_MODEL, DEFAULT_MUTE_WHILE_RECORDING, DEFAULT_PROGRESS_BAR, DEFAULT_READ_SCOPE, DEFAULT_VOICE, } from "../settings.js";
14
+ import { fetchTtsStatus } from "./api.js";
15
+ const store = createSnapshotStore({
16
+ configured: false,
17
+ model: DEFAULT_MODEL,
18
+ voice: DEFAULT_VOICE,
19
+ hasVoiceSample: false,
20
+ baseUrl: DEFAULT_BASE_URL,
21
+ autoRead: false,
22
+ maxChars: DEFAULT_MAX_CHARS,
23
+ chunkChars: DEFAULT_CHUNK_CHARS,
24
+ fallbackEngine: DEFAULT_FALLBACK_ENGINE,
25
+ edgeVoice: DEFAULT_EDGE_VOICE,
26
+ readScope: DEFAULT_READ_SCOPE,
27
+ highlight: DEFAULT_HIGHLIGHT,
28
+ progressBar: DEFAULT_PROGRESS_BAR,
29
+ muteWhileRecording: DEFAULT_MUTE_WHILE_RECORDING,
30
+ });
31
+ let inflight = null;
32
+ /**
33
+ * @returns the shared status mirror every control derives from.
34
+ */
35
+ export function ttsStatusStore() {
36
+ return store;
37
+ }
38
+ /**
39
+ * Ensure one status read is under way; concurrent callers share it.
40
+ * @returns the read in flight, which never rejects.
41
+ */
42
+ export function ensureTtsStatus() {
43
+ if (inflight !== null)
44
+ return inflight;
45
+ inflight = fetchTtsStatus()
46
+ .then((view) => { store.set(view); })
47
+ .catch(() => undefined)
48
+ .finally(() => { inflight = null; });
49
+ return inflight;
50
+ }
51
+ /**
52
+ * Re-read the status even when one is already under way; called after writes
53
+ * that could add or remove the API key.
54
+ * @returns the fresh read, which never rejects.
55
+ */
56
+ export function refreshTtsStatus() {
57
+ inflight = null;
58
+ return ensureTtsStatus();
59
+ }
60
+ //# sourceMappingURL=status.js.map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AAO,CAAC,GAAG,EAAE,GAAG,QAAQ,GAAG,IAAI,CAAA,CAAC,CAAC,CAAC,CAAA;IACrC,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,QAAQ,GAAG,IAAI,CAAA;IACf,OAAO,eAAe,EAAE,CAAA;AAC1B,CAAC"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Framework-free scheduling core of the progressive PCM stream player.
3
+ *
4
+ * `use-stream-player` keeps its playback bookkeeping in React refs so the
5
+ * scheduled-chunk timeline survives renders. Those refs also survive unmount,
6
+ * and an in-flight SSE callback can call `feed()` after the component is gone;
7
+ * without a guard that call rebuilds the AudioContext and resumes scheduling.
8
+ *
9
+ * The mutable scheduling lives here as two seams:
10
+ * - `StreamTimeline` owns the disposed flag and the timing fields.
11
+ * - `createStreamSink` owns the whole playback state machine behind an injected
12
+ * `AudioContext` factory, so `feed` can be driven from Node tests with a fake
13
+ * context and assert that a disposed sink never creates one.
14
+ * @module dsh-mimo-speak/client/stream-dispose
15
+ */
16
+ /** The player fields an in-flight callback could still reach after dispose. */
17
+ export interface StreamTimeline {
18
+ /** True after dispose until the next setup; every mutating control no-ops. */
19
+ disposed: boolean;
20
+ /** Whether audio is currently advancing. */
21
+ playing: boolean;
22
+ /** Whether the stream was marked complete. */
23
+ finished: boolean;
24
+ /** Context time the next chunk starts at. */
25
+ nextAt: number;
26
+ /** Total scheduled audio, in seconds. */
27
+ totalDuration: number;
28
+ }
29
+ /** A fresh, live timeline. */
30
+ export declare function createStreamTimeline(): StreamTimeline;
31
+ /**
32
+ * Whether one more chunk may be scheduled. This is the single decision point
33
+ * `feed` consults before it touches the context factory, so a disposed player
34
+ * can never rebuild its `AudioContext`.
35
+ * @param timeline - the player's live bookkeeping.
36
+ */
37
+ export declare function streamShouldFeed(timeline: StreamTimeline): boolean;
38
+ /**
39
+ * The context time the next chunk should start at: never earlier than the
40
+ * timeline's back-to-back position, and never before the context clock.
41
+ * @param timeline - the player's live bookkeeping.
42
+ * @param ctxNow - the current `AudioContext.currentTime`.
43
+ */
44
+ export declare function feedStartAt(timeline: StreamTimeline, ctxNow: number): number;
45
+ /** Record that one chunk of `duration` seconds started at `when`. */
46
+ export declare function recordScheduledChunk(timeline: StreamTimeline, when: number, duration: number): void;
47
+ /** Disable the player and reset every field a late callback could misuse. */
48
+ export declare function disposeStreamTimeline(timeline: StreamTimeline): void;
49
+ /** Re-enable after a remount (StrictMode setup or in-place re-entry). */
50
+ export declare function resetStreamTimeline(timeline: StreamTimeline): void;
51
+ /** Live playback state the sink publishes. */
52
+ export interface StreamState {
53
+ /** Whether audio is currently advancing. */
54
+ playing: boolean;
55
+ /** Current position in seconds. */
56
+ currentTime: number;
57
+ /** Total scheduled audio, in seconds. */
58
+ duration: number;
59
+ /** Whether playback ran to the end. */
60
+ ended: boolean;
61
+ }
62
+ /** The slice of `AudioContext` the sink schedules on. */
63
+ export interface StreamAudioContext {
64
+ readonly currentTime: number;
65
+ readonly state: string;
66
+ readonly destination: unknown;
67
+ createBuffer(channels: number, length: number, sampleRate: number): StreamAudioBuffer;
68
+ createBufferSource(): StreamBufferSource;
69
+ resume(): Promise<void>;
70
+ suspend(): Promise<void>;
71
+ close(): Promise<void>;
72
+ }
73
+ /** A decoded chunk handed to the context. */
74
+ export interface StreamAudioBuffer {
75
+ readonly duration: number;
76
+ copyToChannel(source: Float32Array, channelNumber: number): void;
77
+ }
78
+ /** A scheduled buffer source. */
79
+ export interface StreamBufferSource {
80
+ buffer: unknown;
81
+ connect(destination: unknown): void;
82
+ start(when?: number): void;
83
+ stop(): void;
84
+ onended: (() => void) | null;
85
+ }
86
+ /** External effects the sink reaches for, injected so tests stay browser-free. */
87
+ export interface StreamSinkDeps {
88
+ /** Create the context on first use; the hook passes `new AudioContext(...)`. */
89
+ createContext: () => StreamAudioContext;
90
+ /** Publish a partial state update (the hook mirrors this into React state). */
91
+ onState: (patch: Partial<StreamState>) => void;
92
+ /** Start the progress tick. */
93
+ setInterval: (handler: () => void, ms: number) => unknown;
94
+ /** Stop the progress tick. */
95
+ clearInterval: (handle: unknown) => void;
96
+ /** Pause every other plugin player before this one starts. */
97
+ onStart: () => void;
98
+ }
99
+ /** What the sink gives its hook. */
100
+ export interface StreamSink {
101
+ feed: (pcm: Uint8Array) => void;
102
+ finish: () => void;
103
+ clear: () => void;
104
+ toggle: () => void;
105
+ pause: () => void;
106
+ scheduled: () => number;
107
+ /** Permanently stop this sink; every mutating control becomes a no-op. */
108
+ dispose: () => void;
109
+ /** Revive after an in-place remount (React StrictMode double-invoke). */
110
+ revive: () => void;
111
+ }
112
+ /**
113
+ * Bind one context to a stream of PCM chunks.
114
+ * @param deps - injected context factory, state publisher, timers and bus hook.
115
+ * @returns scheduling controls plus dispose/revive.
116
+ */
117
+ export declare function createStreamSink(deps: StreamSinkDeps): StreamSink;
118
+ /** MiMo streams 24 kHz mono PCM; the context renders at the native rate. */
119
+ export declare const PCM_SAMPLE_RATE = 24000;
@@ -0,0 +1,249 @@
1
+ /**
2
+ * Framework-free scheduling core of the progressive PCM stream player.
3
+ *
4
+ * `use-stream-player` keeps its playback bookkeeping in React refs so the
5
+ * scheduled-chunk timeline survives renders. Those refs also survive unmount,
6
+ * and an in-flight SSE callback can call `feed()` after the component is gone;
7
+ * without a guard that call rebuilds the AudioContext and resumes scheduling.
8
+ *
9
+ * The mutable scheduling lives here as two seams:
10
+ * - `StreamTimeline` owns the disposed flag and the timing fields.
11
+ * - `createStreamSink` owns the whole playback state machine behind an injected
12
+ * `AudioContext` factory, so `feed` can be driven from Node tests with a fake
13
+ * context and assert that a disposed sink never creates one.
14
+ * @module dsh-mimo-speak/client/stream-dispose
15
+ */
16
+ /** A fresh, live timeline. */
17
+ export function createStreamTimeline() {
18
+ return { disposed: false, playing: false, finished: false, nextAt: 0, totalDuration: 0 };
19
+ }
20
+ /**
21
+ * Whether one more chunk may be scheduled. This is the single decision point
22
+ * `feed` consults before it touches the context factory, so a disposed player
23
+ * can never rebuild its `AudioContext`.
24
+ * @param timeline - the player's live bookkeeping.
25
+ */
26
+ export function streamShouldFeed(timeline) {
27
+ return !timeline.disposed;
28
+ }
29
+ /**
30
+ * The context time the next chunk should start at: never earlier than the
31
+ * timeline's back-to-back position, and never before the context clock.
32
+ * @param timeline - the player's live bookkeeping.
33
+ * @param ctxNow - the current `AudioContext.currentTime`.
34
+ */
35
+ export function feedStartAt(timeline, ctxNow) {
36
+ return Math.max(timeline.nextAt, ctxNow + 0.02);
37
+ }
38
+ /** Record that one chunk of `duration` seconds started at `when`. */
39
+ export function recordScheduledChunk(timeline, when, duration) {
40
+ timeline.nextAt = when + duration;
41
+ timeline.totalDuration += duration;
42
+ }
43
+ /** Disable the player and reset every field a late callback could misuse. */
44
+ export function disposeStreamTimeline(timeline) {
45
+ timeline.disposed = true;
46
+ timeline.playing = false;
47
+ timeline.finished = false;
48
+ timeline.nextAt = 0;
49
+ timeline.totalDuration = 0;
50
+ }
51
+ /** Re-enable after a remount (StrictMode setup or in-place re-entry). */
52
+ export function resetStreamTimeline(timeline) {
53
+ timeline.disposed = false;
54
+ }
55
+ const IDLE = { playing: false, currentTime: 0, duration: 0, ended: false };
56
+ /**
57
+ * Bind one context to a stream of PCM chunks.
58
+ * @param deps - injected context factory, state publisher, timers and bus hook.
59
+ * @returns scheduling controls plus dispose/revive.
60
+ */
61
+ export function createStreamSink(deps) {
62
+ const timeline = createStreamTimeline();
63
+ let ctx = null;
64
+ let sources = [];
65
+ let startedAt = 0;
66
+ let playedBeforePause = 0;
67
+ let tick = null;
68
+ const publish = (patch) => { deps.onState(patch); };
69
+ const clearTick = () => {
70
+ if (tick !== null) {
71
+ deps.clearInterval(tick);
72
+ tick = null;
73
+ }
74
+ };
75
+ const syncProgress = () => {
76
+ if (ctx === null || !timeline.playing)
77
+ return;
78
+ const elapsed = Math.max(0, ctx.currentTime - startedAt);
79
+ publish({ currentTime: playedBeforePause + elapsed });
80
+ };
81
+ const startTick = () => {
82
+ clearTick();
83
+ tick = deps.setInterval(syncProgress, 200);
84
+ };
85
+ const ensureCtx = () => {
86
+ if (ctx === null)
87
+ ctx = deps.createContext();
88
+ return ctx;
89
+ };
90
+ const stopSources = () => {
91
+ for (const source of sources) {
92
+ try {
93
+ source.stop();
94
+ }
95
+ catch {
96
+ // Already stopped.
97
+ }
98
+ }
99
+ sources = [];
100
+ };
101
+ const maybeEnded = () => {
102
+ if (!timeline.finished || !timeline.playing)
103
+ return;
104
+ if (sources.length > 0)
105
+ return;
106
+ const total = timeline.totalDuration;
107
+ const played = playedBeforePause + (ctx !== null ? Math.max(0, ctx.currentTime - startedAt) : 0);
108
+ if (played >= total - 0.05) {
109
+ timeline.playing = false;
110
+ clearTick();
111
+ publish({ playing: false, ended: true, currentTime: 0 });
112
+ }
113
+ };
114
+ const feed = (pcm) => {
115
+ // The single guard against the resume-after-unmount bug: after dispose a
116
+ // late SSE chunk must not rebuild the AudioContext, so this check runs
117
+ // before the context factory is ever reached.
118
+ if (!streamShouldFeed(timeline))
119
+ return;
120
+ const context = ensureCtx();
121
+ let resumePromise = Promise.resolve();
122
+ if (!timeline.playing) {
123
+ timeline.playing = true;
124
+ timeline.finished = false;
125
+ playedBeforePause = 0;
126
+ timeline.totalDuration = 0;
127
+ startedAt = context.currentTime + 0.08;
128
+ timeline.nextAt = startedAt;
129
+ deps.onStart();
130
+ resumePromise = context.state === 'suspended' ? context.resume().catch(() => { }) : Promise.resolve();
131
+ startTick();
132
+ }
133
+ const length = Math.floor(pcm.length / 2);
134
+ if (length === 0)
135
+ return;
136
+ const floats = new Float32Array(length);
137
+ const view = new DataView(pcm.buffer, pcm.byteOffset, pcm.byteLength);
138
+ for (let index = 0; index < length; index += 1) {
139
+ floats[index] = view.getInt16(index * 2, true) / 32768;
140
+ }
141
+ const buffer = context.createBuffer(1, length, PCM_SAMPLE_RATE);
142
+ buffer.copyToChannel(floats, 0);
143
+ const source = context.createBufferSource();
144
+ source.buffer = buffer;
145
+ source.connect(context.destination);
146
+ const when = feedStartAt(timeline, context.currentTime);
147
+ source.start(when);
148
+ recordScheduledChunk(timeline, when, buffer.duration);
149
+ sources.push(source);
150
+ source.onended = () => {
151
+ sources = sources.filter(item => item !== source);
152
+ maybeEnded();
153
+ };
154
+ publish({
155
+ playing: context.state === 'running',
156
+ ended: false,
157
+ duration: timeline.totalDuration,
158
+ });
159
+ if (context.state !== 'running') {
160
+ void resumePromise.then(() => {
161
+ if (timeline.playing)
162
+ publish({ playing: context.state === 'running' });
163
+ });
164
+ }
165
+ };
166
+ const finish = () => {
167
+ if (!streamShouldFeed(timeline))
168
+ return;
169
+ timeline.finished = true;
170
+ maybeEnded();
171
+ };
172
+ const clear = () => {
173
+ if (!streamShouldFeed(timeline))
174
+ return;
175
+ stopSources();
176
+ timeline.playing = false;
177
+ timeline.finished = false;
178
+ timeline.totalDuration = 0;
179
+ clearTick();
180
+ publish(IDLE);
181
+ };
182
+ const toggle = () => {
183
+ if (!streamShouldFeed(timeline))
184
+ return;
185
+ const context = ensureCtx();
186
+ if (timeline.playing) {
187
+ if (context.state === 'suspended') {
188
+ void context.resume().catch(() => { });
189
+ // The AudioContext clock froze while suspended. Rebase the clock so
190
+ // progress and end detection count only the audio played after resume.
191
+ startedAt = context.currentTime;
192
+ startTick();
193
+ publish({ playing: true, ended: false });
194
+ return;
195
+ }
196
+ void context.suspend().catch(() => { });
197
+ const elapsed = Math.max(0, context.currentTime - startedAt);
198
+ playedBeforePause += elapsed;
199
+ clearTick();
200
+ publish({ playing: false });
201
+ return;
202
+ }
203
+ void context.resume().catch(() => { });
204
+ startedAt = context.currentTime;
205
+ timeline.playing = true;
206
+ timeline.finished = timeline.finished && sources.length === 0;
207
+ startTick();
208
+ publish({ playing: true, ended: false });
209
+ };
210
+ const pause = () => {
211
+ if (!streamShouldFeed(timeline))
212
+ return;
213
+ if (ctx === null || !timeline.playing)
214
+ return;
215
+ if (ctx.state === 'suspended') {
216
+ clearTick();
217
+ publish({ playing: false });
218
+ return;
219
+ }
220
+ const elapsed = Math.max(0, ctx.currentTime - startedAt);
221
+ playedBeforePause += elapsed;
222
+ void ctx.suspend().catch(() => { });
223
+ clearTick();
224
+ publish({ playing: false });
225
+ };
226
+ const scheduled = () => {
227
+ return timeline.disposed ? 0 : timeline.totalDuration;
228
+ };
229
+ const dispose = () => {
230
+ if (timeline.disposed)
231
+ return;
232
+ disposeStreamTimeline(timeline);
233
+ stopSources();
234
+ clearTick();
235
+ if (ctx !== null)
236
+ void ctx.close().catch(() => { });
237
+ ctx = null;
238
+ startedAt = 0;
239
+ playedBeforePause = 0;
240
+ sources = [];
241
+ };
242
+ const revive = () => {
243
+ resetStreamTimeline(timeline);
244
+ };
245
+ return { feed, finish, clear, toggle, pause, scheduled, dispose, revive };
246
+ }
247
+ /** MiMo streams 24 kHz mono PCM; the context renders at the native rate. */
248
+ export const PCM_SAMPLE_RATE = 24_000;
249
+ //# sourceMappingURL=stream-dispose.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-dispose.js","sourceRoot":"","sources":["../../../src/client/stream-dispose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAgBH,8BAA8B;AAC9B,MAAM,UAAU,oBAAoB;IAClC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAA;AAC1F,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAwB;IACvD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAA;AAC3B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,QAAwB,EAAE,MAAc;IAClE,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAA;AACjD,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,oBAAoB,CAA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-0,0 +1,19 @@
1
+ /**
2
+ * Plugin-owned stylesheet.
3
+ *
4
+ * The in-repo client bundles compile CSS Modules through their tsdown preset;
5
+ * this out-of-tree plugin keeps one plain stylesheet and injects it with the
6
+ * same shape the platform's own bundle loader uses (a `data-plugin-css` style
7
+ * tag owned by the plugin's effect lifetime). Class names are namespaced
8
+ * `mimo-speak-`, and colors/radii ride the shared `--dsw-*` design tokens so both
9
+ * themes stay correct without owning theme state.
10
+ * @module dsh-mimo-speak/client/styles
11
+ */
12
+ /** The plugin's stylesheet text. */
13
+ export declare const CSS = "\n.mimo-speak-root { position: relative; display: inline-flex; align-items: center; }\n\n.mimo-speak-button {\n display: inline-flex; align-items: center; justify-content: center;\n width: 28px; height: 28px; padding: 6px;\n border: none; border-radius: var(--dsw-radius-sm);\n background: transparent; color: var(--dsw-alias-label-tertiary);\n cursor: pointer;\n}\n.mimo-speak-button:hover { background: var(--dsw-alias-interactive-bg-hover); }\n.mimo-speak-button:focus-visible { outline: var(--dsw-focus-ring-width) solid var(--dsw-alias-state-business-primary); outline-offset: 1px; }\n.mimo-speak-button[aria-pressed=\"true\"] { color: var(--dsw-alias-brand-primary); }\n\n.mimo-speak-failure {\n display: inline-flex; align-items: center; color: var(--dsw-alias-label-error);\n cursor: default;\n}\n\n/* Status notes stay in the DOM for screen readers when no panel is shown. */\n.mimo-speak-srOnly {\n position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;\n overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;\n}\n\n/* Synthesizing: the button itself pulses, so the wait is legible with no panel. */\n.mimo-speak-buttonBusy {\n color: var(--dsw-alias-brand-primary);\n background: var(--dsw-alias-interactive-bg-hover);\n animation: mimo-speak-pulse 1.4s ease-in-out infinite;\n}\n@keyframes mimo-speak-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }\n\n.mimo-speak-spin { display: inline-flex; animation: mimo-speak-spin 1.1s linear infinite; }\n@keyframes mimo-speak-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }\n\n.mimo-speak-panel {\n position: absolute; top: 50%; left: 100%; transform: translateY(-50%); margin-left: 4px; z-index: 40;\n display: block; width: 280px; padding: 8px 10px;\n background: var(--dsw-alias-bg-layer-2);\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: var(--dsw-radius-md);\n box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);\n}\n.mimo-speak-panelLeft { left: auto; right: 100%; margin-left: 0; margin-right: 4px; }\n\n.mimo-speak-bar { display: flex; align-items: center; gap: 8px; height: 24px; }\n/* Transport-only variant: no track and no clock, so the panel stays one control. */\n.mimo-speak-barCompact { gap: 0; justify-content: flex-start; }\n\n.mimo-speak-barButton {\n display: inline-flex; align-items: center; justify-content: center;\n width: 22px; height: 22px; padding: 0;\n border: none; border-radius: var(--dsw-radius-xs);\n background: transparent; color: var(--dsw-alias-label-primary);\n cursor: pointer;\n}\n.mimo-speak-barButton:hover { background: var(--dsw-alias-interactive-bg-hover); }\n\n.mimo-speak-track {\n position: relative; flex: 1 1 auto; height: 14px; cursor: pointer;\n display: flex; align-items: center; touch-action: none;\n}\n.mimo-speak-track::before {\n content: \"\"; position: absolute; left: 0; right: 0; height: 4px;\n background: var(--dsw-alias-border-l3); border-radius: 2px;\n}\n.mimo-speak-track:focus-visible { outline: var(--dsw-focus-ring-width) solid var(--dsw-alias-state-business-primary); outline-offset: 2px; border-radius: var(--dsw-radius-xs); }\n\n/* Streaming playback cannot seek: the track becomes a progress readout with\n no thumb and no pointer affordance. */\n.mimo-speak-trackStatic { cursor: default; }\n.mimo-speak-trackStatic .mimo-speak-thumb { display: none; }\n\n.mimo-speak-fill {\n position: absolute; left: 0; height: 4px; max-width: 100%;\n background: var(--dsw-alias-brand-primary); border-radius: 2px;\n}\n\n.mimo-speak-thumb {\n position: absolute; width: 10px; height: 10px; margin-left: -5px;\n background: var(--dsw-alias-brand-primary); border-radius: 50%;\n box-shadow: 0 0 0 2px var(--dsw-alias-bg-layer-2);\n}\n.mimo-speak-trackDragging .mimo-speak-thumb { transform: scale(1.2); }\n\n.mimo-speak-time {\n flex: 0 0 auto; font-size: 11px; line-height: 1;\n color: var(--dsw-alias-label-tertiary); font-variant-numeric: tabular-nums;\n white-space: nowrap;\n}\n\n.mimo-speak-audition { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }\n.mimo-speak-auditionHint {\n margin: 0; font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary);\n}\n.mimo-speak-auditionRow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }\n.mimo-speak-auditionRow .mimo-speak-bar { flex: 1 1 220px; min-width: 180px; }\n.mimo-speak-auditionButton {\n height: 28px; padding: 0 14px;\n border: 1px solid var(--dsw-alias-border-l2);\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-button-tool-bar-fill);\n color: var(--dsw-alias-label-primary);\n font-size: 12px; cursor: pointer;\n}\n.mimo-speak-auditionButton:hover:not(:disabled) { background: var(--dsw-alias-button-tool-bar-hover); }\n.mimo-speak-auditionButton:disabled { opacity: 0.6; cursor: default; }\n\n.mimo-speak-fieldError { margin: 0; font-size: 12px; color: var(--dsw-alias-label-error); }\n\n/* Preset-voice dropdown, styled to sit inside the shared settings form frame\n like the primitive text fields around it. */\n.mimo-speak-selectField { display: flex; flex-direction: column; gap: 6px; }\n.mimo-speak-selectLabel { font-size: 13px; font-weight: 500; line-height: 18px; color: var(--dsw-alias-label-primary); }\n.mimo-speak-select {\n height: 34px; padding: 0 10px;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-3);\n color: var(--dsw-alias-label-primary);\n font-size: 13px;\n}\n.mimo-speak-select:focus-visible { outline: var(--dsw-focus-ring-width) solid var(--dsw-alias-state-business-primary); outline-offset: 1px; }\n.mimo-speak-select:disabled { opacity: 0.6; cursor: default; }\n\n/* Section titles inside the configuration card. */\n.mimo-speak-sectionTitle {\n margin: 16px 0 0; padding-top: 12px;\n border-top: 0.5px solid var(--dsw-alias-border-l2);\n font-size: 12px; font-weight: 600; letter-spacing: 0.02em;\n color: var(--dsw-alias-label-secondary); text-transform: uppercase;\n}\n.mimo-speak-sectionTitle:first-child { margin-top: 0; padding-top: 0; border-top: none; }\n\n/* Status lines inside the floating player panel. */\n.mimo-speak-panelStatus { margin: 0; font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-error); }\n.mimo-speak-panelNote { margin: 0; font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }\n\n/* While a player is open, the message's action strip stays visible even when\n the pointer leaves the row \u2014 audio must not fade out mid-playback. The\n selector reads ui-chat's reveal attribute as a progressive enhancement: with\n the attribute absent the rule simply never matches. */\n@media (hover: hover) {\n [data-actions-reveal=\"hover\"]:has(.mimo-speak-open) .actions { opacity: 1; }\n}\n";
14
+ /**
15
+ * Inject the plugin stylesheet into the page.
16
+ * @returns the disposer removing the style tag (HMR-safe: re-injection after a
17
+ * rebuild replaces the tag by its data attribute).
18
+ */
19
+ export declare function injectStyles(): () => void;