@mieweb/ui 0.6.1-dev.168 → 0.6.1-dev.170

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 (95) hide show
  1. package/dist/brands/index.cjs +18 -18
  2. package/dist/brands/index.js +3 -3
  3. package/dist/chunk-3Q2VWPML.cjs +1802 -0
  4. package/dist/chunk-3Q2VWPML.cjs.map +1 -0
  5. package/dist/{chunk-67CEEDAP.cjs → chunk-3YRDZBW6.cjs} +7 -7
  6. package/dist/{chunk-67CEEDAP.cjs.map → chunk-3YRDZBW6.cjs.map} +1 -1
  7. package/dist/{chunk-UVQEHZRF.js → chunk-6VGXX6L6.js} +2 -2
  8. package/dist/{chunk-UVQEHZRF.js.map → chunk-6VGXX6L6.js.map} +1 -1
  9. package/dist/chunk-CH26CHPH.js +1776 -0
  10. package/dist/chunk-CH26CHPH.js.map +1 -0
  11. package/dist/{chunk-TXRQQMG5.js → chunk-CYMZ2QS5.js} +2 -2
  12. package/dist/{chunk-TXRQQMG5.js.map → chunk-CYMZ2QS5.js.map} +1 -1
  13. package/dist/chunk-FGP64Z24.js +131 -0
  14. package/dist/chunk-FGP64Z24.js.map +1 -0
  15. package/dist/chunk-FIWKHLWY.js +197 -0
  16. package/dist/chunk-FIWKHLWY.js.map +1 -0
  17. package/dist/chunk-GLXTVCHN.cjs +4 -0
  18. package/dist/chunk-GLXTVCHN.cjs.map +1 -0
  19. package/dist/chunk-J7KWQJOB.js +14 -0
  20. package/dist/chunk-J7KWQJOB.js.map +1 -0
  21. package/dist/{chunk-NINI4WVS.cjs → chunk-JC6Y3LGF.cjs} +297 -84
  22. package/dist/chunk-JC6Y3LGF.cjs.map +1 -0
  23. package/dist/chunk-JYZW2PZS.cjs +166 -0
  24. package/dist/chunk-JYZW2PZS.cjs.map +1 -0
  25. package/dist/chunk-LIH3IZYK.js +689 -0
  26. package/dist/chunk-LIH3IZYK.js.map +1 -0
  27. package/dist/{chunk-XVF472GT.js → chunk-NSLR3B7K.js} +2 -2
  28. package/dist/{chunk-XVF472GT.js.map → chunk-NSLR3B7K.js.map} +1 -1
  29. package/dist/chunk-NTYGCBCL.js +543 -0
  30. package/dist/chunk-NTYGCBCL.js.map +1 -0
  31. package/dist/chunk-RISZWWEQ.js +3 -0
  32. package/dist/chunk-RISZWWEQ.js.map +1 -0
  33. package/dist/chunk-S7JQ3FV5.cjs +16 -0
  34. package/dist/chunk-S7JQ3FV5.cjs.map +1 -0
  35. package/dist/{chunk-JWTCEWQ4.cjs → chunk-SNEQXSC5.cjs} +2 -2
  36. package/dist/{chunk-JWTCEWQ4.cjs.map → chunk-SNEQXSC5.cjs.map} +1 -1
  37. package/dist/chunk-SQHMGT4W.js +164 -0
  38. package/dist/chunk-SQHMGT4W.js.map +1 -0
  39. package/dist/chunk-UO3KEUYK.cjs +220 -0
  40. package/dist/chunk-UO3KEUYK.cjs.map +1 -0
  41. package/dist/{chunk-HUXOASEB.js → chunk-X763OLF2.js} +4 -4
  42. package/dist/{chunk-HUXOASEB.js.map → chunk-X763OLF2.js.map} +1 -1
  43. package/dist/{chunk-DKGUOMBC.cjs → chunk-X7J45FU5.cjs} +2 -2
  44. package/dist/{chunk-DKGUOMBC.cjs.map → chunk-X7J45FU5.cjs.map} +1 -1
  45. package/dist/chunk-Y4ESBDQ5.cjs +552 -0
  46. package/dist/chunk-Y4ESBDQ5.cjs.map +1 -0
  47. package/dist/{chunk-MJ7YITLN.cjs → chunk-Y65SK5Y2.cjs} +2 -2
  48. package/dist/{chunk-MJ7YITLN.cjs.map → chunk-Y65SK5Y2.cjs.map} +1 -1
  49. package/dist/chunk-YD23ZGRU.cjs +155 -0
  50. package/dist/chunk-YD23ZGRU.cjs.map +1 -0
  51. package/dist/components/DateInput/index.cjs +2 -2
  52. package/dist/components/DateInput/index.d.cts +8 -2
  53. package/dist/components/DateInput/index.d.ts +8 -2
  54. package/dist/components/DateInput/index.js +1 -1
  55. package/dist/components/Markdown/index.cjs +10 -10
  56. package/dist/components/Markdown/index.js +2 -2
  57. package/dist/components/MediaEditor/index.cjs +42 -0
  58. package/dist/components/MediaEditor/index.cjs.map +1 -0
  59. package/dist/components/MediaEditor/index.d.cts +151 -0
  60. package/dist/components/MediaEditor/index.d.ts +151 -0
  61. package/dist/components/MediaEditor/index.js +17 -0
  62. package/dist/components/MediaEditor/index.js.map +1 -0
  63. package/dist/components/MediaPlayer/index.cjs +24 -0
  64. package/dist/components/MediaPlayer/index.cjs.map +1 -0
  65. package/dist/components/MediaPlayer/index.d.cts +71 -0
  66. package/dist/components/MediaPlayer/index.d.ts +71 -0
  67. package/dist/components/MediaPlayer/index.js +7 -0
  68. package/dist/components/MediaPlayer/index.js.map +1 -0
  69. package/dist/components/TranscriptView/index.cjs +21 -0
  70. package/dist/components/TranscriptView/index.cjs.map +1 -0
  71. package/dist/components/TranscriptView/index.d.cts +55 -0
  72. package/dist/components/TranscriptView/index.d.ts +55 -0
  73. package/dist/components/TranscriptView/index.js +4 -0
  74. package/dist/components/TranscriptView/index.js.map +1 -0
  75. package/dist/esheet.cjs +6 -6
  76. package/dist/esheet.js +3 -3
  77. package/dist/hooks/index.cjs +49 -11
  78. package/dist/hooks/index.d.cts +88 -1
  79. package/dist/hooks/index.d.ts +88 -1
  80. package/dist/hooks/index.js +3 -1
  81. package/dist/index.cjs +380 -253
  82. package/dist/index.cjs.map +1 -1
  83. package/dist/index.d.cts +7 -2
  84. package/dist/index.d.ts +7 -2
  85. package/dist/index.js +89 -42
  86. package/dist/index.js.map +1 -1
  87. package/dist/styles.css +1 -1
  88. package/dist/transcript-oaWqY3yr.d.cts +81 -0
  89. package/dist/transcript-oaWqY3yr.d.ts +81 -0
  90. package/dist/useTranscriptEdits-BUylQFg0.d.cts +168 -0
  91. package/dist/useTranscriptEdits-CWYnjbGP.d.ts +168 -0
  92. package/package.json +1 -1
  93. package/dist/chunk-HYEJLKXI.js +0 -476
  94. package/dist/chunk-HYEJLKXI.js.map +0 -1
  95. package/dist/chunk-NINI4WVS.cjs.map +0 -1
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Transcript schema for @mieweb/ui media components.
3
+ *
4
+ * Provider-agnostic and persistence-agnostic. Canonical time unit is
5
+ * **milliseconds** (consumers with seconds-based data, e.g. osheet, adapt
6
+ * at the boundary).
7
+ *
8
+ * Shared by TranscriptView, MediaEditor, and useTranscriptEdits.
9
+ */
10
+ /** Type of transcript word - 'word' for spoken content, 'silence' for detected gaps, 'silence-newline' for longer pauses */
11
+ type WordType = 'word' | 'silence' | 'silence-newline';
12
+ interface TranscriptWord {
13
+ text: string;
14
+ startMs: number;
15
+ endMs: number;
16
+ /** References Speaker.id when diarization is available */
17
+ speakerId?: string;
18
+ confidence?: number;
19
+ /** Type of word: 'word' for spoken content, 'silence' for detected gaps. Defaults to 'word' */
20
+ wordType?: WordType;
21
+ }
22
+ /** A diarized segment of contiguous speech (osheet-style granularity) */
23
+ interface TranscriptSegment {
24
+ text: string;
25
+ startMs: number;
26
+ endMs: number;
27
+ /** References Speaker.id when diarization is available */
28
+ speakerId?: string;
29
+ words: TranscriptWord[];
30
+ }
31
+ interface Speaker {
32
+ id: string;
33
+ /** Display name (e.g. 'Clinician', 'Patient'). Hosts may remap via speakerLabels props. */
34
+ name?: string;
35
+ }
36
+ interface Transcript {
37
+ durationMs: number;
38
+ speakers?: Speaker[];
39
+ words: TranscriptWord[];
40
+ segments?: TranscriptSegment[];
41
+ }
42
+ /**
43
+ * An editable word that references the original transcript word.
44
+ * Used in the edited timeline to track deletions and reordering.
45
+ */
46
+ interface EditableWord {
47
+ /** Reference to original word in transcript.words */
48
+ originalIndex: number;
49
+ /** The word data (from original transcript) */
50
+ word: TranscriptWord;
51
+ /** Whether this word is marked as deleted */
52
+ deleted: boolean;
53
+ /** Whether this word was inserted (pasted from clipboard) */
54
+ inserted?: boolean;
55
+ }
56
+ /**
57
+ * Represents a contiguous segment of playback from the original media.
58
+ * Used when playing back an edited timeline with potentially reordered/deleted words.
59
+ */
60
+ interface PlaybackSegment {
61
+ startMs: number;
62
+ endMs: number;
63
+ /** Indices into the editedWords array that this segment covers */
64
+ editedIndices: number[];
65
+ }
66
+ /** Available playback speed multipliers */
67
+ type PlaybackSpeed = 0.5 | 0.75 | 1 | 1.25 | 1.5 | 1.75 | 2;
68
+ /** Array of all available speed options for dropdowns */
69
+ declare const PLAYBACK_SPEEDS: PlaybackSpeed[];
70
+ /**
71
+ * A speed marker applied to a word in the transcript.
72
+ * The speed applies from this word until the next speed marker or end of transcript.
73
+ */
74
+ interface SpeedMarker {
75
+ /** Index in the editedWords array where the speed marker is placed */
76
+ wordIndex: number;
77
+ /** The playback speed multiplier */
78
+ speed: PlaybackSpeed;
79
+ }
80
+
81
+ export { type EditableWord as E, type PlaybackSpeed as P, type SpeedMarker as S, type Transcript as T, type WordType as W, type PlaybackSegment as a, type TranscriptWord as b, PLAYBACK_SPEEDS as c, type Speaker as d, type TranscriptSegment as e };
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Transcript schema for @mieweb/ui media components.
3
+ *
4
+ * Provider-agnostic and persistence-agnostic. Canonical time unit is
5
+ * **milliseconds** (consumers with seconds-based data, e.g. osheet, adapt
6
+ * at the boundary).
7
+ *
8
+ * Shared by TranscriptView, MediaEditor, and useTranscriptEdits.
9
+ */
10
+ /** Type of transcript word - 'word' for spoken content, 'silence' for detected gaps, 'silence-newline' for longer pauses */
11
+ type WordType = 'word' | 'silence' | 'silence-newline';
12
+ interface TranscriptWord {
13
+ text: string;
14
+ startMs: number;
15
+ endMs: number;
16
+ /** References Speaker.id when diarization is available */
17
+ speakerId?: string;
18
+ confidence?: number;
19
+ /** Type of word: 'word' for spoken content, 'silence' for detected gaps. Defaults to 'word' */
20
+ wordType?: WordType;
21
+ }
22
+ /** A diarized segment of contiguous speech (osheet-style granularity) */
23
+ interface TranscriptSegment {
24
+ text: string;
25
+ startMs: number;
26
+ endMs: number;
27
+ /** References Speaker.id when diarization is available */
28
+ speakerId?: string;
29
+ words: TranscriptWord[];
30
+ }
31
+ interface Speaker {
32
+ id: string;
33
+ /** Display name (e.g. 'Clinician', 'Patient'). Hosts may remap via speakerLabels props. */
34
+ name?: string;
35
+ }
36
+ interface Transcript {
37
+ durationMs: number;
38
+ speakers?: Speaker[];
39
+ words: TranscriptWord[];
40
+ segments?: TranscriptSegment[];
41
+ }
42
+ /**
43
+ * An editable word that references the original transcript word.
44
+ * Used in the edited timeline to track deletions and reordering.
45
+ */
46
+ interface EditableWord {
47
+ /** Reference to original word in transcript.words */
48
+ originalIndex: number;
49
+ /** The word data (from original transcript) */
50
+ word: TranscriptWord;
51
+ /** Whether this word is marked as deleted */
52
+ deleted: boolean;
53
+ /** Whether this word was inserted (pasted from clipboard) */
54
+ inserted?: boolean;
55
+ }
56
+ /**
57
+ * Represents a contiguous segment of playback from the original media.
58
+ * Used when playing back an edited timeline with potentially reordered/deleted words.
59
+ */
60
+ interface PlaybackSegment {
61
+ startMs: number;
62
+ endMs: number;
63
+ /** Indices into the editedWords array that this segment covers */
64
+ editedIndices: number[];
65
+ }
66
+ /** Available playback speed multipliers */
67
+ type PlaybackSpeed = 0.5 | 0.75 | 1 | 1.25 | 1.5 | 1.75 | 2;
68
+ /** Array of all available speed options for dropdowns */
69
+ declare const PLAYBACK_SPEEDS: PlaybackSpeed[];
70
+ /**
71
+ * A speed marker applied to a word in the transcript.
72
+ * The speed applies from this word until the next speed marker or end of transcript.
73
+ */
74
+ interface SpeedMarker {
75
+ /** Index in the editedWords array where the speed marker is placed */
76
+ wordIndex: number;
77
+ /** The playback speed multiplier */
78
+ speed: PlaybackSpeed;
79
+ }
80
+
81
+ export { type EditableWord as E, type PlaybackSpeed as P, type SpeedMarker as S, type Transcript as T, type WordType as W, type PlaybackSegment as a, type TranscriptWord as b, PLAYBACK_SPEEDS as c, type Speaker as d, type TranscriptSegment as e };
@@ -0,0 +1,168 @@
1
+ import { E as EditableWord, T as Transcript, S as SpeedMarker, P as PlaybackSpeed, a as PlaybackSegment, b as TranscriptWord } from './transcript-oaWqY3yr.cjs';
2
+
3
+ /**
4
+ * useTranscriptEdits — headless transcript-editing state hook.
5
+ *
6
+ * Extracted from pulseclip's TranscriptViewer for @mieweb/ui. Holds the
7
+ * edited word timeline (deletions, insertions, text edits, silence
8
+ * splitting), a single-level undo stack, an internal clipboard, speed
9
+ * markers, and derived playback/statistics data.
10
+ *
11
+ * Controlled + persistence-agnostic: no DOM, no fetches. Selection lives in
12
+ * the UI layer — mutations take explicit indices. State flows out via
13
+ * `onChange` and back in via `initialEditedWords` / `initialUndoStack`.
14
+ */
15
+
16
+ /** Default filler words offered for removal */
17
+ declare const DEFAULT_FILLER_WORDS: string[];
18
+ /** Default minimum silence duration in milliseconds to detect and insert */
19
+ declare const DEFAULT_MIN_SILENCE_MS = 400;
20
+ /** Default threshold for "newline" silences - longer pauses that indicate paragraph breaks */
21
+ declare const DEFAULT_NL_SILENCE_MS = 1500;
22
+ /** Clipboard data for cut/copy/paste operations */
23
+ interface TranscriptClipboard {
24
+ words: EditableWord[];
25
+ operation: 'cut' | 'copy';
26
+ }
27
+ /** Count and total duration of silences above a given threshold (seconds) */
28
+ interface SilenceThresholdCount {
29
+ threshold: number;
30
+ count: number;
31
+ durationMs: number;
32
+ }
33
+ /**
34
+ * Builds playback segments from the edited word list.
35
+ * Consecutive words in original order are merged into single segments.
36
+ * Inserted (pasted) words each get their own segment since they may be duplicates.
37
+ */
38
+ declare function buildPlaybackSegments(editedWords: EditableWord[]): PlaybackSegment[];
39
+ /**
40
+ * Get the effective playback speed at a given word index.
41
+ * Finds the most recent speed marker at or before the word index,
42
+ * or returns the default speed if no marker applies.
43
+ */
44
+ declare function getSpeedAtIndex(wordIndex: number, speedMarkers: SpeedMarker[], defaultSpeed: PlaybackSpeed): PlaybackSpeed;
45
+ /**
46
+ * Detect silences between words and return a new array with silence pseudo-words inserted.
47
+ * Silences are detected as gaps between the endMs of one word and startMs of the next.
48
+ * Silences >= nlSilenceMs are marked as 'silence-newline' for visual line breaks.
49
+ */
50
+ declare function insertSilences(words: TranscriptWord[], minSilenceMs?: number, nlSilenceMs?: number): TranscriptWord[];
51
+ /** Initialize editable words from transcript, inserting detected silences */
52
+ declare function initEditableWords(transcript: Transcript, minSilenceMs?: number, nlSilenceMs?: number): EditableWord[];
53
+ interface UseTranscriptEditsOptions {
54
+ /** The source transcript (canonical, immutable) */
55
+ transcript: Transcript;
56
+ /** Initial edited words (from saved edits) */
57
+ initialEditedWords?: EditableWord[];
58
+ /** Initial undo stack (from saved edits) */
59
+ initialUndoStack?: EditableWord[][];
60
+ /** Fired after every mutation (for persistence) */
61
+ onChange?: (editedWords: EditableWord[], undoStack: EditableWord[][]) => void;
62
+ /** Minimum silence duration (ms) to detect and insert. Default 400 */
63
+ minSilenceMs?: number;
64
+ /** Threshold (ms) for "newline" silences (paragraph breaks). Default 1500 */
65
+ nlSilenceMs?: number;
66
+ }
67
+ interface TranscriptEditStats {
68
+ /** Non-deleted spoken words (silences excluded) */
69
+ activeWordCount: number;
70
+ /** Non-deleted silence entries */
71
+ activeSilenceCount: number;
72
+ /** Deleted spoken words */
73
+ deletedWordCount: number;
74
+ /** Deleted silence entries */
75
+ deletedSilenceCount: number;
76
+ /** Total duration of non-deleted entries, adjusted for speed markers */
77
+ editedDurationMs: number;
78
+ }
79
+ interface FillerAnalysis {
80
+ /** Occurrence count per normalized word (fillers and every active word) */
81
+ matchCounts: Map<string, number>;
82
+ /** Total duration (ms) per normalized word */
83
+ durations: Map<string, number>;
84
+ /** Count + total duration of active silences above each analysis threshold */
85
+ silenceCounts: SilenceThresholdCount[];
86
+ /** The built-in filler word list */
87
+ defaultFillerWords: string[];
88
+ }
89
+ interface UseTranscriptEditsResult {
90
+ /** The edited timeline (words + silence pseudo-words) */
91
+ editedWords: EditableWord[];
92
+ /** Undo snapshots, oldest first */
93
+ undoStack: EditableWord[][];
94
+ /** Internal clipboard from the last cut/copy, or null */
95
+ clipboard: TranscriptClipboard | null;
96
+ /** Whether any edit has been made (deletions, insertions, text edits, speed markers) */
97
+ hasEdits: boolean;
98
+ /** Push the current editedWords onto the undo stack (call before external batch mutations) */
99
+ pushUndo: () => void;
100
+ /** Restore the most recent undo snapshot */
101
+ undo: () => void;
102
+ /** Toggle the deleted flag on a single word */
103
+ toggleWordDeleted: (index: number) => void;
104
+ /**
105
+ * Toggle the deleted state of a contiguous range. The first index acts as
106
+ * the anchor: all words are set to the opposite of the anchor's state
107
+ * (delete all if anchor active, restore all if anchor deleted).
108
+ */
109
+ deleteRange: (indices: number[]) => void;
110
+ /** Cut words at the given indices into the clipboard (marks them deleted) */
111
+ cut: (indices: number[]) => void;
112
+ /** Copy non-deleted words at the given indices into the clipboard */
113
+ copy: (indices: number[]) => void;
114
+ /**
115
+ * Paste the clipboard at a word index. `before` (default true) inserts
116
+ * before the word at `atIndex`; false inserts after it. Returns the index
117
+ * where the first pasted word landed, or null if the clipboard was empty.
118
+ */
119
+ paste: (atIndex: number, before?: boolean) => number | null;
120
+ /** Replace a word's text (no-op if unchanged) */
121
+ setWordText: (index: number, text: string) => void;
122
+ /** Split a silence at the given index into segments with the given durations (seconds) */
123
+ splitSilence: (index: number, durationsSec: number[]) => void;
124
+ /** Toggle the word at the index deleted (editor "delete" action) */
125
+ deleteWord: (index: number) => void;
126
+ /** Replace the entire edit state from an external source (e.g. an editable script view); undo-safe */
127
+ replaceEditedWords: (next: EditableWord[]) => void;
128
+ /** Mark matching filler words (and silences above the given seconds threshold) deleted */
129
+ removeFillers: (fillerWords: string[], removeSilenceAboveSec: number | null) => void;
130
+ /** Rebuild silence detection with new thresholds, preserving word deletions */
131
+ setSilenceThresholds: (minMs: number, nlMs: number) => void;
132
+ /** Current silence detection thresholds (ms) */
133
+ silenceThresholds: {
134
+ minSilenceMs: number;
135
+ nlSilenceMs: number;
136
+ };
137
+ /** Speed markers, sorted by word index */
138
+ speedMarkers: SpeedMarker[];
139
+ /** Default playback speed when no marker applies */
140
+ defaultSpeed: PlaybackSpeed;
141
+ /** Set the default playback speed */
142
+ setDefaultSpeed: (speed: PlaybackSpeed) => void;
143
+ /** Add/update/remove a speed marker (re-selecting the same speed removes it) */
144
+ toggleSpeedMarker: (index: number, speed: PlaybackSpeed) => void;
145
+ /** Remove the speed marker at a word index, if any */
146
+ removeSpeedMarker: (index: number) => void;
147
+ /** Effective playback speed at a word index */
148
+ getSpeedAtIndex: (index: number) => PlaybackSpeed;
149
+ /** The speed marker at a word index, if any */
150
+ getSpeedMarkerAtIndex: (index: number) => SpeedMarker | undefined;
151
+ /** Contiguous playback segments built from the edited timeline */
152
+ playbackSegments: PlaybackSegment[];
153
+ /** Word/silence counts and speed-adjusted edited duration */
154
+ stats: TranscriptEditStats;
155
+ /** Filler word and silence analysis for removal UIs */
156
+ fillerAnalysis: FillerAnalysis;
157
+ }
158
+ /**
159
+ * Headless transcript-editing hook. See module docs for scope.
160
+ *
161
+ * Undo semantics: each mutation snapshots the full `editedWords` array onto
162
+ * a single-level stack before applying; `undo` pops one snapshot. Speed
163
+ * markers and silence-threshold changes are NOT part of the undo stack
164
+ * (matching the source component).
165
+ */
166
+ declare function useTranscriptEdits(options: UseTranscriptEditsOptions): UseTranscriptEditsResult;
167
+
168
+ export { DEFAULT_FILLER_WORDS as D, type FillerAnalysis as F, type SilenceThresholdCount as S, type TranscriptClipboard as T, type UseTranscriptEditsOptions as U, DEFAULT_MIN_SILENCE_MS as a, DEFAULT_NL_SILENCE_MS as b, type TranscriptEditStats as c, type UseTranscriptEditsResult as d, buildPlaybackSegments as e, insertSilences as f, getSpeedAtIndex as g, initEditableWords as i, useTranscriptEdits as u };
@@ -0,0 +1,168 @@
1
+ import { E as EditableWord, T as Transcript, S as SpeedMarker, P as PlaybackSpeed, a as PlaybackSegment, b as TranscriptWord } from './transcript-oaWqY3yr.js';
2
+
3
+ /**
4
+ * useTranscriptEdits — headless transcript-editing state hook.
5
+ *
6
+ * Extracted from pulseclip's TranscriptViewer for @mieweb/ui. Holds the
7
+ * edited word timeline (deletions, insertions, text edits, silence
8
+ * splitting), a single-level undo stack, an internal clipboard, speed
9
+ * markers, and derived playback/statistics data.
10
+ *
11
+ * Controlled + persistence-agnostic: no DOM, no fetches. Selection lives in
12
+ * the UI layer — mutations take explicit indices. State flows out via
13
+ * `onChange` and back in via `initialEditedWords` / `initialUndoStack`.
14
+ */
15
+
16
+ /** Default filler words offered for removal */
17
+ declare const DEFAULT_FILLER_WORDS: string[];
18
+ /** Default minimum silence duration in milliseconds to detect and insert */
19
+ declare const DEFAULT_MIN_SILENCE_MS = 400;
20
+ /** Default threshold for "newline" silences - longer pauses that indicate paragraph breaks */
21
+ declare const DEFAULT_NL_SILENCE_MS = 1500;
22
+ /** Clipboard data for cut/copy/paste operations */
23
+ interface TranscriptClipboard {
24
+ words: EditableWord[];
25
+ operation: 'cut' | 'copy';
26
+ }
27
+ /** Count and total duration of silences above a given threshold (seconds) */
28
+ interface SilenceThresholdCount {
29
+ threshold: number;
30
+ count: number;
31
+ durationMs: number;
32
+ }
33
+ /**
34
+ * Builds playback segments from the edited word list.
35
+ * Consecutive words in original order are merged into single segments.
36
+ * Inserted (pasted) words each get their own segment since they may be duplicates.
37
+ */
38
+ declare function buildPlaybackSegments(editedWords: EditableWord[]): PlaybackSegment[];
39
+ /**
40
+ * Get the effective playback speed at a given word index.
41
+ * Finds the most recent speed marker at or before the word index,
42
+ * or returns the default speed if no marker applies.
43
+ */
44
+ declare function getSpeedAtIndex(wordIndex: number, speedMarkers: SpeedMarker[], defaultSpeed: PlaybackSpeed): PlaybackSpeed;
45
+ /**
46
+ * Detect silences between words and return a new array with silence pseudo-words inserted.
47
+ * Silences are detected as gaps between the endMs of one word and startMs of the next.
48
+ * Silences >= nlSilenceMs are marked as 'silence-newline' for visual line breaks.
49
+ */
50
+ declare function insertSilences(words: TranscriptWord[], minSilenceMs?: number, nlSilenceMs?: number): TranscriptWord[];
51
+ /** Initialize editable words from transcript, inserting detected silences */
52
+ declare function initEditableWords(transcript: Transcript, minSilenceMs?: number, nlSilenceMs?: number): EditableWord[];
53
+ interface UseTranscriptEditsOptions {
54
+ /** The source transcript (canonical, immutable) */
55
+ transcript: Transcript;
56
+ /** Initial edited words (from saved edits) */
57
+ initialEditedWords?: EditableWord[];
58
+ /** Initial undo stack (from saved edits) */
59
+ initialUndoStack?: EditableWord[][];
60
+ /** Fired after every mutation (for persistence) */
61
+ onChange?: (editedWords: EditableWord[], undoStack: EditableWord[][]) => void;
62
+ /** Minimum silence duration (ms) to detect and insert. Default 400 */
63
+ minSilenceMs?: number;
64
+ /** Threshold (ms) for "newline" silences (paragraph breaks). Default 1500 */
65
+ nlSilenceMs?: number;
66
+ }
67
+ interface TranscriptEditStats {
68
+ /** Non-deleted spoken words (silences excluded) */
69
+ activeWordCount: number;
70
+ /** Non-deleted silence entries */
71
+ activeSilenceCount: number;
72
+ /** Deleted spoken words */
73
+ deletedWordCount: number;
74
+ /** Deleted silence entries */
75
+ deletedSilenceCount: number;
76
+ /** Total duration of non-deleted entries, adjusted for speed markers */
77
+ editedDurationMs: number;
78
+ }
79
+ interface FillerAnalysis {
80
+ /** Occurrence count per normalized word (fillers and every active word) */
81
+ matchCounts: Map<string, number>;
82
+ /** Total duration (ms) per normalized word */
83
+ durations: Map<string, number>;
84
+ /** Count + total duration of active silences above each analysis threshold */
85
+ silenceCounts: SilenceThresholdCount[];
86
+ /** The built-in filler word list */
87
+ defaultFillerWords: string[];
88
+ }
89
+ interface UseTranscriptEditsResult {
90
+ /** The edited timeline (words + silence pseudo-words) */
91
+ editedWords: EditableWord[];
92
+ /** Undo snapshots, oldest first */
93
+ undoStack: EditableWord[][];
94
+ /** Internal clipboard from the last cut/copy, or null */
95
+ clipboard: TranscriptClipboard | null;
96
+ /** Whether any edit has been made (deletions, insertions, text edits, speed markers) */
97
+ hasEdits: boolean;
98
+ /** Push the current editedWords onto the undo stack (call before external batch mutations) */
99
+ pushUndo: () => void;
100
+ /** Restore the most recent undo snapshot */
101
+ undo: () => void;
102
+ /** Toggle the deleted flag on a single word */
103
+ toggleWordDeleted: (index: number) => void;
104
+ /**
105
+ * Toggle the deleted state of a contiguous range. The first index acts as
106
+ * the anchor: all words are set to the opposite of the anchor's state
107
+ * (delete all if anchor active, restore all if anchor deleted).
108
+ */
109
+ deleteRange: (indices: number[]) => void;
110
+ /** Cut words at the given indices into the clipboard (marks them deleted) */
111
+ cut: (indices: number[]) => void;
112
+ /** Copy non-deleted words at the given indices into the clipboard */
113
+ copy: (indices: number[]) => void;
114
+ /**
115
+ * Paste the clipboard at a word index. `before` (default true) inserts
116
+ * before the word at `atIndex`; false inserts after it. Returns the index
117
+ * where the first pasted word landed, or null if the clipboard was empty.
118
+ */
119
+ paste: (atIndex: number, before?: boolean) => number | null;
120
+ /** Replace a word's text (no-op if unchanged) */
121
+ setWordText: (index: number, text: string) => void;
122
+ /** Split a silence at the given index into segments with the given durations (seconds) */
123
+ splitSilence: (index: number, durationsSec: number[]) => void;
124
+ /** Toggle the word at the index deleted (editor "delete" action) */
125
+ deleteWord: (index: number) => void;
126
+ /** Replace the entire edit state from an external source (e.g. an editable script view); undo-safe */
127
+ replaceEditedWords: (next: EditableWord[]) => void;
128
+ /** Mark matching filler words (and silences above the given seconds threshold) deleted */
129
+ removeFillers: (fillerWords: string[], removeSilenceAboveSec: number | null) => void;
130
+ /** Rebuild silence detection with new thresholds, preserving word deletions */
131
+ setSilenceThresholds: (minMs: number, nlMs: number) => void;
132
+ /** Current silence detection thresholds (ms) */
133
+ silenceThresholds: {
134
+ minSilenceMs: number;
135
+ nlSilenceMs: number;
136
+ };
137
+ /** Speed markers, sorted by word index */
138
+ speedMarkers: SpeedMarker[];
139
+ /** Default playback speed when no marker applies */
140
+ defaultSpeed: PlaybackSpeed;
141
+ /** Set the default playback speed */
142
+ setDefaultSpeed: (speed: PlaybackSpeed) => void;
143
+ /** Add/update/remove a speed marker (re-selecting the same speed removes it) */
144
+ toggleSpeedMarker: (index: number, speed: PlaybackSpeed) => void;
145
+ /** Remove the speed marker at a word index, if any */
146
+ removeSpeedMarker: (index: number) => void;
147
+ /** Effective playback speed at a word index */
148
+ getSpeedAtIndex: (index: number) => PlaybackSpeed;
149
+ /** The speed marker at a word index, if any */
150
+ getSpeedMarkerAtIndex: (index: number) => SpeedMarker | undefined;
151
+ /** Contiguous playback segments built from the edited timeline */
152
+ playbackSegments: PlaybackSegment[];
153
+ /** Word/silence counts and speed-adjusted edited duration */
154
+ stats: TranscriptEditStats;
155
+ /** Filler word and silence analysis for removal UIs */
156
+ fillerAnalysis: FillerAnalysis;
157
+ }
158
+ /**
159
+ * Headless transcript-editing hook. See module docs for scope.
160
+ *
161
+ * Undo semantics: each mutation snapshots the full `editedWords` array onto
162
+ * a single-level stack before applying; `undo` pops one snapshot. Speed
163
+ * markers and silence-threshold changes are NOT part of the undo stack
164
+ * (matching the source component).
165
+ */
166
+ declare function useTranscriptEdits(options: UseTranscriptEditsOptions): UseTranscriptEditsResult;
167
+
168
+ export { DEFAULT_FILLER_WORDS as D, type FillerAnalysis as F, type SilenceThresholdCount as S, type TranscriptClipboard as T, type UseTranscriptEditsOptions as U, DEFAULT_MIN_SILENCE_MS as a, DEFAULT_NL_SILENCE_MS as b, type TranscriptEditStats as c, type UseTranscriptEditsResult as d, buildPlaybackSegments as e, insertSilences as f, getSpeedAtIndex as g, initEditableWords as i, useTranscriptEdits as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mieweb/ui",
3
- "version": "0.6.1-dev.168",
3
+ "version": "0.6.1-dev.170",
4
4
  "description": "A themeable, accessible React component library built with Tailwind CSS",
5
5
  "author": "Medical Informatics Engineering, Inc.",
6
6
  "license": "SEE LICENSE IN LICENSE",