@dxos/plugin-transcription 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae

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 (263) hide show
  1. package/dist/lib/browser/TranscriptionContainer-RBFHP2AV.mjs +41 -0
  2. package/dist/lib/browser/TranscriptionContainer-RBFHP2AV.mjs.map +7 -0
  3. package/dist/lib/browser/blueprint-definition-C6XA2SVZ.mjs +18 -0
  4. package/dist/lib/browser/blueprint-definition-C6XA2SVZ.mjs.map +7 -0
  5. package/dist/lib/browser/blueprints/index.mjs +9 -0
  6. package/dist/lib/browser/chunk-2B74LZZD.mjs +22 -0
  7. package/dist/lib/browser/chunk-2B74LZZD.mjs.map +7 -0
  8. package/dist/lib/browser/{chunk-COBQIZ6B.mjs → chunk-EV5ZYKET.mjs} +60 -86
  9. package/dist/lib/browser/chunk-EV5ZYKET.mjs.map +7 -0
  10. package/dist/lib/browser/chunk-GH4IIQ6C.mjs +54 -0
  11. package/dist/lib/browser/chunk-GH4IIQ6C.mjs.map +7 -0
  12. package/dist/lib/browser/chunk-HOOPZ7EM.mjs +35 -0
  13. package/dist/lib/browser/chunk-HOOPZ7EM.mjs.map +7 -0
  14. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  15. package/dist/lib/browser/{blueprint-definition-GO6GTEBT.mjs → chunk-O7ILGNBZ.mjs} +39 -41
  16. package/dist/lib/browser/chunk-O7ILGNBZ.mjs.map +7 -0
  17. package/dist/lib/browser/{chunk-ZS2FXKEF.mjs → chunk-XLMRCOQN.mjs} +383 -470
  18. package/dist/lib/browser/chunk-XLMRCOQN.mjs.map +7 -0
  19. package/dist/lib/browser/index.mjs +62 -77
  20. package/dist/lib/browser/index.mjs.map +4 -4
  21. package/dist/lib/browser/meta.json +1 -1
  22. package/dist/lib/browser/operation-resolver-5BLRH4XE.mjs +23 -0
  23. package/dist/lib/browser/operation-resolver-5BLRH4XE.mjs.map +7 -0
  24. package/dist/lib/browser/react-surface-U2SI74JK.mjs +36 -0
  25. package/dist/lib/browser/react-surface-U2SI74JK.mjs.map +7 -0
  26. package/dist/lib/browser/{transcriber-NG5MRCP6.mjs → transcriber-WCPHHJYY.mjs} +19 -14
  27. package/dist/lib/browser/transcriber-WCPHHJYY.mjs.map +7 -0
  28. package/dist/lib/browser/types/index.mjs +8 -5
  29. package/dist/lib/node-esm/TranscriptionContainer-3OOID5KH.mjs +42 -0
  30. package/dist/lib/node-esm/TranscriptionContainer-3OOID5KH.mjs.map +7 -0
  31. package/dist/lib/node-esm/blueprint-definition-TLXDUXIQ.mjs +19 -0
  32. package/dist/lib/node-esm/blueprint-definition-TLXDUXIQ.mjs.map +7 -0
  33. package/dist/lib/node-esm/blueprints/index.mjs +10 -0
  34. package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
  35. package/dist/lib/node-esm/chunk-6GW5NZYG.mjs +55 -0
  36. package/dist/lib/node-esm/chunk-6GW5NZYG.mjs.map +7 -0
  37. package/dist/lib/node-esm/{chunk-A6SB234F.mjs → chunk-7UE7G6DE.mjs} +60 -86
  38. package/dist/lib/node-esm/chunk-7UE7G6DE.mjs.map +7 -0
  39. package/dist/lib/node-esm/{chunk-PEZRQYKO.mjs → chunk-DYUGYQCB.mjs} +383 -470
  40. package/dist/lib/node-esm/chunk-DYUGYQCB.mjs.map +7 -0
  41. package/dist/lib/node-esm/{chunk-KLTPFUKN.mjs → chunk-F47HK7GT.mjs} +7 -8
  42. package/dist/lib/node-esm/chunk-F47HK7GT.mjs.map +7 -0
  43. package/dist/lib/node-esm/{blueprint-definition-6SU7GLBR.mjs → chunk-H3MXHMQL.mjs} +39 -41
  44. package/dist/lib/node-esm/chunk-H3MXHMQL.mjs.map +7 -0
  45. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  46. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  47. package/dist/lib/node-esm/chunk-NVM2QUMX.mjs +37 -0
  48. package/dist/lib/node-esm/chunk-NVM2QUMX.mjs.map +7 -0
  49. package/dist/lib/node-esm/index.mjs +62 -77
  50. package/dist/lib/node-esm/index.mjs.map +4 -4
  51. package/dist/lib/node-esm/meta.json +1 -1
  52. package/dist/lib/node-esm/operation-resolver-CVZB7BF4.mjs +24 -0
  53. package/dist/lib/node-esm/operation-resolver-CVZB7BF4.mjs.map +7 -0
  54. package/dist/lib/node-esm/react-surface-2ICJPBPX.mjs +37 -0
  55. package/dist/lib/node-esm/react-surface-2ICJPBPX.mjs.map +7 -0
  56. package/dist/lib/node-esm/{transcriber-SMU7HD6F.mjs → transcriber-2RIHUEX4.mjs} +19 -14
  57. package/dist/lib/node-esm/transcriber-2RIHUEX4.mjs.map +7 -0
  58. package/dist/lib/node-esm/types/index.mjs +8 -5
  59. package/dist/types/src/TranscriptionPlugin.d.ts +2 -1
  60. package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
  61. package/dist/types/src/blueprints/index.d.ts +2 -0
  62. package/dist/types/src/blueprints/index.d.ts.map +1 -0
  63. package/dist/types/src/blueprints/transcription-blueprint.d.ts +4 -0
  64. package/dist/types/src/blueprints/transcription-blueprint.d.ts.map +1 -0
  65. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +6 -0
  66. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
  67. package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
  68. package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
  69. package/dist/types/src/capabilities/index.d.ts +4 -5
  70. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  71. package/dist/types/src/capabilities/operation-handler/index.d.ts +3 -0
  72. package/dist/types/src/capabilities/operation-handler/index.d.ts.map +1 -0
  73. package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts +5 -0
  74. package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts.map +1 -0
  75. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  76. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  77. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  78. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  79. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  80. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  81. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  82. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  83. package/dist/types/src/capabilities/transcriber/index.d.ts +3 -0
  84. package/dist/types/src/capabilities/transcriber/index.d.ts.map +1 -0
  85. package/dist/types/src/capabilities/transcriber/transcriber.d.ts +9 -0
  86. package/dist/types/src/capabilities/transcriber/transcriber.d.ts.map +1 -0
  87. package/dist/types/src/components/Transcription/Transcription.d.ts +17 -0
  88. package/dist/types/src/components/Transcription/Transcription.d.ts.map +1 -0
  89. package/dist/types/src/components/{Transcript/Transcript.stories.d.ts → Transcription/Transcription.stories.d.ts} +7 -6
  90. package/dist/types/src/components/Transcription/Transcription.stories.d.ts.map +1 -0
  91. package/dist/types/src/components/Transcription/index.d.ts +2 -0
  92. package/dist/types/src/components/Transcription/index.d.ts.map +1 -0
  93. package/dist/types/src/components/Transcription/transcription-extension.d.ts +15 -0
  94. package/dist/types/src/components/Transcription/transcription-extension.d.ts.map +1 -0
  95. package/dist/types/src/components/index.d.ts +1 -3
  96. package/dist/types/src/components/index.d.ts.map +1 -1
  97. package/dist/types/src/components/stories/FileTranscription.stories.d.ts +3 -6
  98. package/dist/types/src/components/stories/FileTranscription.stories.d.ts.map +1 -1
  99. package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts +0 -3
  100. package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts.map +1 -1
  101. package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts +3 -6
  102. package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts.map +1 -1
  103. package/dist/types/src/components/stories/TranscriptionStory.d.ts +2 -2
  104. package/dist/types/src/components/stories/TranscriptionStory.d.ts.map +1 -1
  105. package/dist/types/src/containers/TranscriptionContainer/TranscriptionContainer.d.ts +6 -0
  106. package/dist/types/src/containers/TranscriptionContainer/TranscriptionContainer.d.ts.map +1 -0
  107. package/dist/types/src/containers/TranscriptionContainer/index.d.ts +3 -0
  108. package/dist/types/src/containers/TranscriptionContainer/index.d.ts.map +1 -0
  109. package/dist/types/src/containers/index.d.ts +3 -0
  110. package/dist/types/src/containers/index.d.ts.map +1 -0
  111. package/dist/types/src/functions/index.d.ts +17 -2
  112. package/dist/types/src/functions/index.d.ts.map +1 -1
  113. package/dist/types/src/functions/open.d.ts +6 -2
  114. package/dist/types/src/functions/open.d.ts.map +1 -1
  115. package/dist/types/src/functions/summarize.d.ts +1 -1
  116. package/dist/types/src/hooks/useQueueModelAdapter.d.ts +1 -1
  117. package/dist/types/src/hooks/useQueueModelAdapter.d.ts.map +1 -1
  118. package/dist/types/src/hooks/useTranscriber.d.ts +1 -1
  119. package/dist/types/src/hooks/useTranscriber.d.ts.map +1 -1
  120. package/dist/types/src/index.d.ts +1 -1
  121. package/dist/types/src/index.d.ts.map +1 -1
  122. package/dist/types/src/meta.d.ts +2 -2
  123. package/dist/types/src/meta.d.ts.map +1 -1
  124. package/dist/types/src/segments-normalization/message-normalizer.d.ts +5 -5
  125. package/dist/types/src/segments-normalization/message-normalizer.d.ts.map +1 -1
  126. package/dist/types/src/segments-normalization/normalization.d.ts +515 -448
  127. package/dist/types/src/segments-normalization/normalization.d.ts.map +1 -1
  128. package/dist/types/src/segments-normalization/utils.d.ts +2 -2
  129. package/dist/types/src/segments-normalization/utils.d.ts.map +1 -1
  130. package/dist/types/src/testing/testing.d.ts +9 -9
  131. package/dist/types/src/testing/testing.d.ts.map +1 -1
  132. package/dist/types/src/transcriber/media-stream-recorder.d.ts +2 -2
  133. package/dist/types/src/transcriber/media-stream-recorder.d.ts.map +1 -1
  134. package/dist/types/src/transcriber/transcriber.d.ts +4 -4
  135. package/dist/types/src/transcriber/transcriber.d.ts.map +1 -1
  136. package/dist/types/src/transcriber/transcription-manager.d.ts +9 -6
  137. package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -1
  138. package/dist/types/src/types/TranscriptAction.d.ts +22 -20
  139. package/dist/types/src/types/TranscriptAction.d.ts.map +1 -1
  140. package/dist/types/src/types/capabilities.d.ts +18 -0
  141. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  142. package/dist/types/src/types/index.d.ts +2 -1
  143. package/dist/types/src/types/index.d.ts.map +1 -1
  144. package/dist/types/src/util/index.d.ts +1 -0
  145. package/dist/types/src/util/index.d.ts.map +1 -1
  146. package/dist/types/src/util/render-byline.d.ts +4 -0
  147. package/dist/types/src/util/render-byline.d.ts.map +1 -0
  148. package/dist/types/tsconfig.tsbuildinfo +1 -1
  149. package/package.json +84 -69
  150. package/src/TranscriptionPlugin.tsx +35 -57
  151. package/src/blueprints/index.ts +5 -0
  152. package/src/blueprints/transcription-blueprint.ts +33 -0
  153. package/src/capabilities/blueprint-definition/blueprint-definition.ts +17 -0
  154. package/src/capabilities/blueprint-definition/index.ts +7 -0
  155. package/src/capabilities/index.ts +4 -8
  156. package/src/capabilities/operation-handler/index.ts +7 -0
  157. package/src/capabilities/operation-handler/operation-handler.ts +25 -0
  158. package/src/capabilities/operation-resolver/index.ts +7 -0
  159. package/src/capabilities/operation-resolver/operation-resolver.ts +25 -0
  160. package/src/capabilities/react-surface/index.ts +7 -0
  161. package/src/capabilities/react-surface/react-surface.tsx +28 -0
  162. package/src/capabilities/transcriber/index.ts +7 -0
  163. package/src/capabilities/transcriber/transcriber.ts +85 -0
  164. package/src/components/{Transcript/Transcript.stories.tsx → Transcription/Transcription.stories.tsx} +42 -41
  165. package/src/components/Transcription/Transcription.tsx +63 -0
  166. package/src/components/{Transcript → Transcription}/index.ts +1 -1
  167. package/src/components/{Transcript/transcript-extension.ts → Transcription/transcription-extension.ts} +13 -9
  168. package/src/components/index.ts +1 -6
  169. package/src/components/stories/FileTranscription.stories.tsx +30 -36
  170. package/src/components/stories/KeyWordRecognition.stories.tsx +5 -8
  171. package/src/components/stories/MicrophoneTranscription.stories.tsx +50 -55
  172. package/src/components/stories/TranscriptionStory.tsx +7 -11
  173. package/src/containers/TranscriptionContainer/TranscriptionContainer.tsx +33 -0
  174. package/src/containers/TranscriptionContainer/index.ts +7 -0
  175. package/src/containers/index.ts +7 -0
  176. package/src/functions/index.ts +7 -2
  177. package/src/functions/open.ts +9 -11
  178. package/src/hooks/useQueueModelAdapter.ts +1 -1
  179. package/src/hooks/useTranscriber.ts +8 -3
  180. package/src/hooks/useVoiceInput.ts +2 -2
  181. package/src/index.ts +1 -1
  182. package/src/meta.ts +8 -3
  183. package/src/model/model.test.ts +20 -14
  184. package/src/segments-normalization/message-normalizer.ts +18 -13
  185. package/src/segments-normalization/normalization.test.ts +6 -11
  186. package/src/segments-normalization/normalization.ts +6 -6
  187. package/src/segments-normalization/utils.ts +2 -2
  188. package/src/testing/testing.ts +28 -18
  189. package/src/transcriber/media-stream-recorder.ts +3 -3
  190. package/src/transcriber/transcriber.browser.test.ts +4 -4
  191. package/src/transcriber/transcriber.ts +6 -6
  192. package/src/transcriber/transcription-manager.ts +21 -15
  193. package/src/types/TranscriptAction.ts +21 -13
  194. package/src/{capabilities → types}/capabilities.ts +8 -8
  195. package/src/types/index.ts +2 -1
  196. package/src/util/index.ts +1 -0
  197. package/src/util/render-byline.ts +33 -0
  198. package/dist/lib/browser/TranscriptContainer-QN5WUMWJ.mjs +0 -11
  199. package/dist/lib/browser/blueprint-definition-GO6GTEBT.mjs.map +0 -7
  200. package/dist/lib/browser/chunk-77NWYLC6.mjs +0 -8
  201. package/dist/lib/browser/chunk-77NWYLC6.mjs.map +0 -7
  202. package/dist/lib/browser/chunk-7LNCQDTT.mjs +0 -24
  203. package/dist/lib/browser/chunk-7LNCQDTT.mjs.map +0 -7
  204. package/dist/lib/browser/chunk-COBQIZ6B.mjs.map +0 -7
  205. package/dist/lib/browser/chunk-GGHMOEKZ.mjs +0 -63
  206. package/dist/lib/browser/chunk-GGHMOEKZ.mjs.map +0 -7
  207. package/dist/lib/browser/chunk-LCK3YRQF.mjs +0 -16
  208. package/dist/lib/browser/chunk-LCK3YRQF.mjs.map +0 -7
  209. package/dist/lib/browser/chunk-ZS2FXKEF.mjs.map +0 -7
  210. package/dist/lib/browser/intent-resolver-52EPFRMR.mjs +0 -25
  211. package/dist/lib/browser/intent-resolver-52EPFRMR.mjs.map +0 -7
  212. package/dist/lib/browser/react-surface-LCP2D2MF.mjs +0 -34
  213. package/dist/lib/browser/react-surface-LCP2D2MF.mjs.map +0 -7
  214. package/dist/lib/browser/transcriber-NG5MRCP6.mjs.map +0 -7
  215. package/dist/lib/node-esm/TranscriptContainer-WCUWVVSD.mjs +0 -12
  216. package/dist/lib/node-esm/blueprint-definition-6SU7GLBR.mjs.map +0 -7
  217. package/dist/lib/node-esm/chunk-A6SB234F.mjs.map +0 -7
  218. package/dist/lib/node-esm/chunk-FTTZ4YSX.mjs +0 -64
  219. package/dist/lib/node-esm/chunk-FTTZ4YSX.mjs.map +0 -7
  220. package/dist/lib/node-esm/chunk-KLTPFUKN.mjs.map +0 -7
  221. package/dist/lib/node-esm/chunk-N5Z4SKPH.mjs +0 -10
  222. package/dist/lib/node-esm/chunk-N5Z4SKPH.mjs.map +0 -7
  223. package/dist/lib/node-esm/chunk-PEZRQYKO.mjs.map +0 -7
  224. package/dist/lib/node-esm/chunk-RWRG3S2O.mjs +0 -17
  225. package/dist/lib/node-esm/chunk-RWRG3S2O.mjs.map +0 -7
  226. package/dist/lib/node-esm/intent-resolver-DZBQQRHN.mjs +0 -26
  227. package/dist/lib/node-esm/intent-resolver-DZBQQRHN.mjs.map +0 -7
  228. package/dist/lib/node-esm/react-surface-7UC2YXX2.mjs +0 -35
  229. package/dist/lib/node-esm/react-surface-7UC2YXX2.mjs.map +0 -7
  230. package/dist/lib/node-esm/transcriber-SMU7HD6F.mjs.map +0 -7
  231. package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -5
  232. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
  233. package/dist/types/src/capabilities/capabilities.d.ts +0 -17
  234. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  235. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  236. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  237. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  238. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  239. package/dist/types/src/capabilities/transcriber.d.ts +0 -8
  240. package/dist/types/src/capabilities/transcriber.d.ts.map +0 -1
  241. package/dist/types/src/components/Transcript/Transcript.d.ts +0 -20
  242. package/dist/types/src/components/Transcript/Transcript.d.ts.map +0 -1
  243. package/dist/types/src/components/Transcript/Transcript.stories.d.ts.map +0 -1
  244. package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts +0 -28
  245. package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts.map +0 -1
  246. package/dist/types/src/components/Transcript/index.d.ts +0 -2
  247. package/dist/types/src/components/Transcript/index.d.ts.map +0 -1
  248. package/dist/types/src/components/Transcript/transcript-extension.d.ts +0 -15
  249. package/dist/types/src/components/Transcript/transcript-extension.d.ts.map +0 -1
  250. package/dist/types/src/components/TranscriptContainer.d.ts +0 -9
  251. package/dist/types/src/components/TranscriptContainer.d.ts.map +0 -1
  252. package/dist/types/src/types/Transcript.d.ts +0 -30
  253. package/dist/types/src/types/Transcript.d.ts.map +0 -1
  254. package/src/capabilities/blueprint-definition.ts +0 -31
  255. package/src/capabilities/intent-resolver.ts +0 -18
  256. package/src/capabilities/react-surface.tsx +0 -22
  257. package/src/capabilities/transcriber.ts +0 -77
  258. package/src/components/Transcript/Transcript.tsx +0 -93
  259. package/src/components/Transcript/deprecated/OldTranscript.tsx +0 -260
  260. package/src/components/TranscriptContainer.tsx +0 -36
  261. package/src/types/Transcript.ts +0 -44
  262. /package/dist/lib/browser/{TranscriptContainer-QN5WUMWJ.mjs.map → blueprints/index.mjs.map} +0 -0
  263. /package/dist/lib/{node-esm/TranscriptContainer-WCUWVVSD.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
@@ -1,167 +1,46 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
  import {
3
3
  TranscriptionCapabilities
4
- } from "./chunk-RWRG3S2O.mjs";
4
+ } from "./chunk-6GW5NZYG.mjs";
5
5
 
6
- // src/components/TranscriptContainer.tsx
7
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
8
- import React2 from "react";
9
- import { fullyQualifiedId, getSpace } from "@dxos/client/echo";
10
- import { useMembers, useQueue } from "@dxos/react-client/echo";
11
- import { StackItem } from "@dxos/react-ui-stack";
12
-
13
- // src/hooks/useAudioFile.ts
14
- import { useEffect, useState } from "react";
15
- import { scheduleTask } from "@dxos/async";
16
- import { Context } from "@dxos/context";
17
- import { log } from "@dxos/log";
18
- var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/hooks/useAudioFile.ts";
19
- var useAudioFile = (audioUrl, constraints) => {
20
- const [{ audio, stream, track }, setStream] = useState({});
21
- useEffect(() => {
22
- const ctx = new Context(void 0, {
23
- F: __dxlog_file,
24
- L: 20
25
- });
26
- scheduleTask(ctx, async () => {
27
- try {
28
- const response = await fetch(audioUrl);
29
- const blob = await response.blob();
30
- const objectUrl = URL.createObjectURL(blob);
31
- ctx.onDispose(() => {
32
- URL.revokeObjectURL(objectUrl);
33
- });
34
- const audio2 = new Audio();
35
- audio2.src = objectUrl;
36
- await new Promise((resolve, reject) => {
37
- audio2.addEventListener("error", (err) => {
38
- log.error("error", {
39
- err
40
- }, {
41
- F: __dxlog_file,
42
- L: 39,
43
- S: void 0,
44
- C: (f, a) => f(...a)
45
- });
46
- reject(err);
47
- }, {
48
- once: true
49
- });
50
- audio2.addEventListener("canplay", async () => {
51
- resolve();
52
- }, {
53
- once: true
54
- });
55
- audio2.load();
56
- });
57
- const audioCtx = new AudioContext();
58
- if (audioCtx.state === "suspended") {
59
- await audioCtx.resume();
60
- }
61
- const destination = audioCtx.createMediaStreamDestination();
62
- destination.channelCount = 1;
63
- const source = audioCtx.createMediaElementSource(audio2);
64
- source.connect(destination);
65
- const track2 = destination.stream.getAudioTracks()[0];
66
- if (constraints) {
67
- await track2.applyConstraints(constraints).catch((err) => log.catch(err, void 0, {
68
- F: __dxlog_file,
69
- L: 68,
70
- S: void 0,
71
- C: (f, a) => f(...a)
72
- }));
73
- }
74
- setStream({
75
- audio: audio2,
76
- stream: destination.stream,
77
- track: destination.stream.getAudioTracks()[0]
78
- });
79
- } catch (err) {
80
- log.catch(err, void 0, {
81
- F: __dxlog_file,
82
- L: 78,
83
- S: void 0,
84
- C: (f, a) => f(...a)
85
- });
86
- }
87
- });
88
- return () => {
89
- void ctx.dispose();
90
- };
91
- }, [
92
- audioUrl
93
- ]);
94
- return {
95
- audio,
96
- stream,
97
- track
98
- };
99
- };
100
-
101
- // src/hooks/useAudioTrack.ts
102
- import { useEffect as useEffect2, useState as useState2 } from "react";
103
- var useAudioTrack = (active, constraints) => {
104
- const [track, setTrack] = useState2();
105
- useEffect2(() => {
106
- if (!active) {
107
- track?.stop();
108
- setTrack(void 0);
109
- return;
110
- }
111
- const initAudio = async () => {
112
- const audio = new Audio();
113
- audio.srcObject = await navigator.mediaDevices.getUserMedia({
114
- audio: constraints ?? true
115
- });
116
- const [track2] = audio.srcObject.getAudioTracks();
117
- if (track2) {
118
- setTrack(track2);
119
- }
120
- };
121
- if (active) {
122
- void initAudio();
123
- }
124
- }, [
125
- active
126
- ]);
127
- return track;
128
- };
6
+ // src/components/Transcription/Transcription.tsx
7
+ import React from "react";
8
+ import { useThemeContext } from "@dxos/react-ui";
9
+ import { useTextEditor } from "@dxos/react-ui-editor";
10
+ import { autoScroll, createBasicExtensions, createMarkdownExtensions, createThemeExtensions, decorateMarkdown, editorSlots, preview } from "@dxos/ui-editor";
11
+ import { mx } from "@dxos/ui-theme";
12
+ import { isTruthy } from "@dxos/util";
129
13
 
130
- // src/hooks/useQueueModelAdapter.ts
131
- import { useEffect as useEffect3, useMemo, useState as useState3 } from "react";
14
+ // src/components/Transcription/transcription-extension.ts
15
+ import { RangeSetBuilder } from "@codemirror/state";
16
+ import { EditorView, GutterMarker, ViewPlugin, gutter } from "@codemirror/view";
17
+ import { format } from "date-fns/format";
18
+ import { intervalToDuration } from "date-fns/intervalToDuration";
19
+ import { addEventListener, combine } from "@dxos/async";
132
20
 
133
21
  // src/model/model.ts
134
22
  import { Text } from "@codemirror/state";
135
23
  import { Event } from "@dxos/async";
136
24
  import { invariant } from "@dxos/invariant";
137
- import { log as log2 } from "@dxos/log";
138
- function _define_property(obj, key, value) {
139
- if (key in obj) {
140
- Object.defineProperty(obj, key, {
141
- value,
142
- enumerable: true,
143
- configurable: true,
144
- writable: true
145
- });
146
- } else {
147
- obj[key] = value;
148
- }
149
- return obj;
150
- }
151
- var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/model/model.ts";
25
+ import { log } from "@dxos/log";
26
+ var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/model/model.ts";
152
27
  var DocumentAdapter = class {
28
+ _view;
29
+ constructor(_view) {
30
+ this._view = _view;
31
+ }
153
32
  /** The document must always have at least one line. */
154
33
  lineCount() {
155
34
  return this._view.state.doc.lines - 1;
156
35
  }
157
36
  replaceLines(from, remove, insert) {
158
- log2("replaceLines", {
37
+ log("replaceLines", {
159
38
  count: this._view.state.doc.lines,
160
39
  from,
161
40
  remove,
162
41
  insert
163
42
  }, {
164
- F: __dxlog_file2,
43
+ F: __dxlog_file,
165
44
  L: 39,
166
45
  S: this,
167
46
  C: (f, a) => f(...a)
@@ -181,12 +60,25 @@ var DocumentAdapter = class {
181
60
  }
182
61
  });
183
62
  }
184
- constructor(_view) {
185
- _define_property(this, "_view", void 0);
186
- this._view = _view;
187
- }
188
63
  };
189
64
  var SerializationModel = class {
65
+ _renderer;
66
+ /** Ordered set of chunks. */
67
+ _chunks = [];
68
+ /** Map of chunk IDs to their current line counts. */
69
+ _chunkLineCounts = /* @__PURE__ */ new Map();
70
+ /** Map of line numbers to chunk IDs. */
71
+ _lineToChunk = /* @__PURE__ */ new Map();
72
+ /** Track chunk changes since last sync. */
73
+ _changes = [];
74
+ /** Emits when the document is updated. */
75
+ update = new Event();
76
+ constructor(_renderer, initialChunks = []) {
77
+ this._renderer = _renderer;
78
+ initialChunks.forEach((chunk) => {
79
+ this.appendChunk(chunk);
80
+ });
81
+ }
190
82
  toJSON() {
191
83
  return {
192
84
  chunks: this._chunks.length,
@@ -229,7 +121,7 @@ var SerializationModel = class {
229
121
  updateChunk(chunk) {
230
122
  const index = this._chunks.findIndex((c) => c.id === chunk.id);
231
123
  invariant(index !== -1, void 0, {
232
- F: __dxlog_file2,
124
+ F: __dxlog_file,
233
125
  L: 147,
234
126
  S: this,
235
127
  A: [
@@ -249,7 +141,7 @@ var SerializationModel = class {
249
141
  deleteBlock(id) {
250
142
  const index = this._chunks.findIndex((c) => c.id === id);
251
143
  invariant(index !== -1, void 0, {
252
- F: __dxlog_file2,
144
+ F: __dxlog_file,
253
145
  L: 156,
254
146
  S: this,
255
147
  A: [
@@ -270,10 +162,10 @@ var SerializationModel = class {
270
162
  * Syncs the tracked changes with the ChunkDocument.
271
163
  */
272
164
  sync(document2) {
273
- log2("sync", {
165
+ log("sync", {
274
166
  changes: this._changes
275
167
  }, {
276
- F: __dxlog_file2,
168
+ F: __dxlog_file,
277
169
  L: 167,
278
170
  S: this,
279
171
  C: (f, a) => f(...a)
@@ -324,65 +216,346 @@ var SerializationModel = class {
324
216
  this._changes.length = 0;
325
217
  return this;
326
218
  }
327
- constructor(_renderer, initialChunks = []) {
328
- _define_property(this, "_renderer", void 0);
329
- _define_property(this, "_chunks", void 0);
330
- _define_property(this, "_chunkLineCounts", void 0);
331
- _define_property(this, "_lineToChunk", void 0);
332
- _define_property(this, "_changes", void 0);
333
- _define_property(this, "update", void 0);
334
- this._renderer = _renderer;
335
- this._chunks = [];
336
- this._chunkLineCounts = /* @__PURE__ */ new Map();
337
- this._lineToChunk = /* @__PURE__ */ new Map();
338
- this._changes = [];
339
- this.update = new Event();
340
- initialChunks.forEach((chunk) => {
341
- this.appendChunk(chunk);
342
- });
343
- }
344
219
  };
345
220
 
346
- // src/hooks/useQueueModelAdapter.ts
347
- var useQueueModelAdapter = (renderer, queue, initialChunks = []) => {
348
- const model = useMemo(() => new SerializationModel(renderer, initialChunks), [
349
- queue
350
- ]);
351
- const [loaded, setLoaded] = useState3(false);
352
- useEffect3(() => {
353
- if (!queue) {
354
- return;
355
- }
356
- const update = () => {
357
- for (const block of queue?.objects ?? []) {
358
- model.appendChunk(block);
221
+ // src/components/Transcription/transcription-extension.ts
222
+ var transcription = ({ model, started }) => {
223
+ return [
224
+ // Show timestamps in the gutter.
225
+ gutter({
226
+ class: "cm-timestamp-gutter",
227
+ lineMarkerChange: (update) => update.docChanged || update.viewportChanged,
228
+ markers: (view) => {
229
+ const start = getStartTime(started, model.chunks[0]);
230
+ const builder = new RangeSetBuilder();
231
+ for (const { from, to } of view.visibleRanges) {
232
+ let line = view.state.doc.lineAt(from);
233
+ while (line.from <= to) {
234
+ const block = model.getChunkAtLine(line.number)?.blocks[0];
235
+ const timestamp = block?._tag === "transcript" && block.started;
236
+ if (timestamp) {
237
+ builder.add(line.from, line.from, new TimestampMarker(line.number, new Date(timestamp), start));
238
+ }
239
+ if (line.to + 1 > view.state.doc.length) {
240
+ break;
241
+ }
242
+ line = view.state.doc.lineAt(line.to + 1);
243
+ }
244
+ }
245
+ return builder.finish();
359
246
  }
360
- setLoaded(true);
361
- };
362
- let i;
363
- if (queue.isLoading) {
364
- i = setInterval(() => {
365
- if (!queue?.isLoading) {
366
- clearInterval(i);
367
- update();
247
+ }),
248
+ // Listen for model updates.
249
+ ViewPlugin.fromClass(class {
250
+ _controls;
251
+ _cleanup;
252
+ _adapter;
253
+ _initialized = false;
254
+ constructor(view) {
255
+ this._adapter = new DocumentAdapter(view);
256
+ const scroller = view.scrollDOM;
257
+ let isAutoScrolling = false;
258
+ let hasScrolled = false;
259
+ let timeout;
260
+ const scrollToBottom = (smooth = false) => {
261
+ scroller.style.scrollBehavior = smooth ? "smooth" : "";
262
+ scroller.classList.add("cm-hide-scrollbar");
263
+ isAutoScrolling = true;
264
+ clearTimeout(timeout);
265
+ timeout = setTimeout(() => {
266
+ this._controls?.classList.add("opacity-0");
267
+ scroller.classList.remove("cm-hide-scrollbar");
268
+ isAutoScrolling = false;
269
+ }, 500);
270
+ view.dispatch({
271
+ effects: EditorView.scrollIntoView(view.state.doc.length, {
272
+ y: "end"
273
+ })
274
+ });
275
+ };
276
+ this._cleanup = combine(addEventListener(view.scrollDOM, "scroll", () => {
277
+ if (!isAutoScrolling) {
278
+ hasScrolled = true;
279
+ this._controls?.classList.remove("opacity-0");
280
+ }
281
+ }), model.update.on(() => {
282
+ const autoScroll2 = scroller.scrollHeight - scroller.scrollTop - scroller.clientHeight === 0 || !hasScrolled;
283
+ model.sync(this._adapter);
284
+ if (autoScroll2) {
285
+ scrollToBottom(true);
286
+ }
287
+ }));
288
+ }
289
+ update(_update) {
290
+ if (!this._initialized) {
291
+ this._initialized = true;
292
+ setTimeout(() => {
293
+ model.sync(this._adapter);
294
+ });
368
295
  }
369
- }, 1e3);
370
- } else {
371
- update();
372
- }
373
- return () => clearTimeout(i);
374
- }, [
375
- model,
376
- queue
377
- ]);
378
- useEffect3(() => {
379
- if (!loaded || !queue || model.chunks.length === queue.objects.length) {
380
- return;
381
- }
382
- const chunk = queue.objects.at(-1);
383
- if (chunk) {
384
- model.appendChunk(chunk);
385
- }
296
+ }
297
+ destroy() {
298
+ this._controls?.remove();
299
+ this._cleanup();
300
+ }
301
+ }),
302
+ EditorView.theme({
303
+ ".cm-gutters": {
304
+ backgroundColor: "var(--color-base-surface)"
305
+ },
306
+ ".cm-timestamp-gutter": {
307
+ width: "6rem",
308
+ paddingLeft: "0.5rem",
309
+ paddingRight: "1rem"
310
+ },
311
+ ".cm-timestamp-gutter > .cm-gutterElement > div": {
312
+ display: "inline-flex",
313
+ textAlign: "right",
314
+ padding: "3px"
315
+ }
316
+ })
317
+ ];
318
+ };
319
+ var TimestampMarker = class extends GutterMarker {
320
+ _line;
321
+ _timestamp;
322
+ _started;
323
+ constructor(_line, _timestamp, _started) {
324
+ super(), this._line = _line, this._timestamp = _timestamp, this._started = _started;
325
+ }
326
+ eq(other) {
327
+ return this._timestamp === other._timestamp;
328
+ }
329
+ toDOM(view) {
330
+ const el = document.createElement("div");
331
+ el.className = "text-sm text-subdued hover:bg-hover-surface cursor-pointer";
332
+ el.textContent = formatTimestamp(this._timestamp, this._started);
333
+ el.onclick = () => {
334
+ const pos = view.state.doc.line(this._line).from;
335
+ view.dispatch({
336
+ effects: EditorView.scrollIntoView(pos, {
337
+ y: "start"
338
+ })
339
+ });
340
+ };
341
+ return el;
342
+ }
343
+ };
344
+ var getStartTime = (started, message) => {
345
+ if (started) {
346
+ return started;
347
+ }
348
+ if (message?.blocks[0]?._tag === "transcript" && message.blocks[0].started) {
349
+ return new Date(message.blocks[0].started);
350
+ }
351
+ return void 0;
352
+ };
353
+ var formatTimestamp = (timestamp, relative) => {
354
+ if (relative) {
355
+ const pad = (n = 0) => String(n).padStart(2, "0");
356
+ const { hours, minutes, seconds } = intervalToDuration({
357
+ start: relative,
358
+ end: timestamp
359
+ });
360
+ return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`;
361
+ } else {
362
+ return format(timestamp, "HH:mm:ss");
363
+ }
364
+ };
365
+
366
+ // src/components/Transcription/Transcription.tsx
367
+ var Transcription = ({ classNames, transcript: object, model }) => {
368
+ const { themeMode } = useThemeContext();
369
+ const { parentRef } = useTextEditor(() => {
370
+ return {
371
+ extensions: [
372
+ createBasicExtensions({
373
+ readOnly: true,
374
+ lineWrapping: true,
375
+ search: true
376
+ }),
377
+ createMarkdownExtensions(),
378
+ createThemeExtensions({
379
+ themeMode,
380
+ slots: editorSlots
381
+ }),
382
+ decorateMarkdown(),
383
+ preview(),
384
+ transcription({
385
+ model,
386
+ started: object?.started ? new Date(object.started) : void 0
387
+ }),
388
+ autoScroll()
389
+ ].filter(isTruthy)
390
+ };
391
+ }, [
392
+ model
393
+ ]);
394
+ return /* @__PURE__ */ React.createElement("div", {
395
+ ref: parentRef,
396
+ className: mx("dx-container", classNames),
397
+ "data-popover-collision-boundary": true
398
+ });
399
+ };
400
+
401
+ // src/hooks/useAudioFile.ts
402
+ import { useEffect, useState } from "react";
403
+ import { scheduleTask } from "@dxos/async";
404
+ import { Context } from "@dxos/context";
405
+ import { log as log2 } from "@dxos/log";
406
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/hooks/useAudioFile.ts";
407
+ var useAudioFile = (audioUrl, constraints) => {
408
+ const [{ audio, stream, track }, setStream] = useState({});
409
+ useEffect(() => {
410
+ const ctx = new Context(void 0, {
411
+ F: __dxlog_file2,
412
+ L: 20
413
+ });
414
+ scheduleTask(ctx, async () => {
415
+ try {
416
+ const response = await fetch(audioUrl);
417
+ const blob = await response.blob();
418
+ const objectUrl = URL.createObjectURL(blob);
419
+ ctx.onDispose(() => {
420
+ URL.revokeObjectURL(objectUrl);
421
+ });
422
+ const audio2 = new Audio();
423
+ audio2.src = objectUrl;
424
+ await new Promise((resolve, reject) => {
425
+ audio2.addEventListener("error", (err) => {
426
+ log2.error("error", {
427
+ err
428
+ }, {
429
+ F: __dxlog_file2,
430
+ L: 39,
431
+ S: void 0,
432
+ C: (f, a) => f(...a)
433
+ });
434
+ reject(err);
435
+ }, {
436
+ once: true
437
+ });
438
+ audio2.addEventListener("canplay", async () => {
439
+ resolve();
440
+ }, {
441
+ once: true
442
+ });
443
+ audio2.load();
444
+ });
445
+ const audioCtx = new AudioContext();
446
+ if (audioCtx.state === "suspended") {
447
+ await audioCtx.resume();
448
+ }
449
+ const destination = audioCtx.createMediaStreamDestination();
450
+ destination.channelCount = 1;
451
+ const source = audioCtx.createMediaElementSource(audio2);
452
+ source.connect(destination);
453
+ const track2 = destination.stream.getAudioTracks()[0];
454
+ if (constraints) {
455
+ await track2.applyConstraints(constraints).catch((err) => log2.catch(err, void 0, {
456
+ F: __dxlog_file2,
457
+ L: 68,
458
+ S: void 0,
459
+ C: (f, a) => f(...a)
460
+ }));
461
+ }
462
+ setStream({
463
+ audio: audio2,
464
+ stream: destination.stream,
465
+ track: destination.stream.getAudioTracks()[0]
466
+ });
467
+ } catch (err) {
468
+ log2.catch(err, void 0, {
469
+ F: __dxlog_file2,
470
+ L: 78,
471
+ S: void 0,
472
+ C: (f, a) => f(...a)
473
+ });
474
+ }
475
+ });
476
+ return () => {
477
+ void ctx.dispose();
478
+ };
479
+ }, [
480
+ audioUrl
481
+ ]);
482
+ return {
483
+ audio,
484
+ stream,
485
+ track
486
+ };
487
+ };
488
+
489
+ // src/hooks/useAudioTrack.ts
490
+ import { useEffect as useEffect2, useState as useState2 } from "react";
491
+ var useAudioTrack = (active, constraints) => {
492
+ const [track, setTrack] = useState2();
493
+ useEffect2(() => {
494
+ if (!active) {
495
+ track?.stop();
496
+ setTrack(void 0);
497
+ return;
498
+ }
499
+ const initAudio = async () => {
500
+ const audio = new Audio();
501
+ audio.srcObject = await navigator.mediaDevices.getUserMedia({
502
+ audio: constraints ?? true
503
+ });
504
+ const [track2] = audio.srcObject.getAudioTracks();
505
+ if (track2) {
506
+ setTrack(track2);
507
+ }
508
+ };
509
+ if (active) {
510
+ void initAudio();
511
+ }
512
+ }, [
513
+ active
514
+ ]);
515
+ return track;
516
+ };
517
+
518
+ // src/hooks/useQueueModelAdapter.ts
519
+ import { useEffect as useEffect3, useMemo, useState as useState3 } from "react";
520
+ var useQueueModelAdapter = (renderer, queue, initialChunks = []) => {
521
+ const model = useMemo(() => new SerializationModel(renderer, initialChunks), [
522
+ queue
523
+ ]);
524
+ const [loaded, setLoaded] = useState3(false);
525
+ useEffect3(() => {
526
+ if (!queue) {
527
+ return;
528
+ }
529
+ const update = () => {
530
+ for (const block of queue?.objects ?? []) {
531
+ model.appendChunk(block);
532
+ }
533
+ setLoaded(true);
534
+ };
535
+ let i;
536
+ if (queue.isLoading) {
537
+ i = setInterval(() => {
538
+ if (!queue?.isLoading) {
539
+ clearInterval(i);
540
+ update();
541
+ }
542
+ }, 1e3);
543
+ } else {
544
+ update();
545
+ }
546
+ return () => clearTimeout(i);
547
+ }, [
548
+ model,
549
+ queue
550
+ ]);
551
+ useEffect3(() => {
552
+ if (!loaded || !queue || model.chunks.length === queue.objects.length) {
553
+ return;
554
+ }
555
+ const chunk = queue.objects.at(-1);
556
+ if (chunk) {
557
+ model.appendChunk(chunk);
558
+ }
386
559
  }, [
387
560
  model,
388
561
  loaded,
@@ -393,16 +566,7 @@ var useQueueModelAdapter = (renderer, queue, initialChunks = []) => {
393
566
 
394
567
  // src/hooks/useTranscriber.ts
395
568
  import { useEffect as useEffect4, useMemo as useMemo2 } from "react";
396
- import { useCapabilities } from "@dxos/app-framework";
397
-
398
- // src/capabilities/index.ts
399
- import { lazy } from "@dxos/app-framework";
400
- var BlueprintDefinition = lazy(() => import("./blueprint-definition-6SU7GLBR.mjs"));
401
- var IntentResolver = lazy(() => import("./intent-resolver-DZBQQRHN.mjs"));
402
- var ReactSurface = lazy(() => import("./react-surface-7UC2YXX2.mjs"));
403
- var Transcriber = lazy(() => import("./transcriber-SMU7HD6F.mjs"));
404
-
405
- // src/hooks/useTranscriber.ts
569
+ import { useCapabilities } from "@dxos/app-framework/ui";
406
570
  var useTranscriber = ({ audioStreamTrack, recorderConfig, transcriberConfig, onSegments }) => {
407
571
  const [getTranscriber] = useCapabilities(TranscriptionCapabilities.Transcriber);
408
572
  const transcriber = useMemo2(() => {
@@ -494,263 +658,12 @@ var useVoiceInput = ({ active, onUpdate }) => {
494
658
  };
495
659
  };
496
660
 
497
- // src/components/Transcript/Transcript.tsx
498
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
499
- import React from "react";
500
- import { useThemeContext } from "@dxos/react-ui";
501
- import { autoScroll, createBasicExtensions, createMarkdownExtensions, createThemeExtensions, decorateMarkdown, preview, useTextEditor } from "@dxos/react-ui-editor";
502
- import { mx } from "@dxos/react-ui-theme";
503
- import { isTruthy } from "@dxos/util";
504
-
505
- // src/components/Transcript/transcript-extension.ts
506
- import { RangeSetBuilder } from "@codemirror/state";
507
- import { EditorView, GutterMarker, ViewPlugin, gutter } from "@codemirror/view";
508
- import { format } from "date-fns/format";
509
- import { intervalToDuration } from "date-fns/intervalToDuration";
510
- import { addEventListener, combine } from "@dxos/async";
511
- function _define_property2(obj, key, value) {
512
- if (key in obj) {
513
- Object.defineProperty(obj, key, {
514
- value,
515
- enumerable: true,
516
- configurable: true,
517
- writable: true
518
- });
519
- } else {
520
- obj[key] = value;
521
- }
522
- return obj;
523
- }
524
- var transcript = ({ model, started }) => {
525
- return [
526
- // Show timestamps in the gutter.
527
- gutter({
528
- class: "cm-timestamp-gutter",
529
- lineMarkerChange: (update) => update.docChanged || update.viewportChanged,
530
- markers: (view) => {
531
- const start = getStartTime(started, model.chunks[0]);
532
- const builder = new RangeSetBuilder();
533
- for (const { from, to } of view.visibleRanges) {
534
- let line = view.state.doc.lineAt(from);
535
- while (line.from <= to) {
536
- const block = model.getChunkAtLine(line.number)?.blocks[0];
537
- const timestamp = block?._tag === "transcript" && block.started;
538
- if (timestamp) {
539
- builder.add(line.from, line.from, new TimestampMarker(line.number, new Date(timestamp), start));
540
- }
541
- if (line.to + 1 > view.state.doc.length) {
542
- break;
543
- }
544
- line = view.state.doc.lineAt(line.to + 1);
545
- }
546
- }
547
- return builder.finish();
548
- }
549
- }),
550
- // Listen for model updates.
551
- ViewPlugin.fromClass(class {
552
- update(_update) {
553
- if (!this._initialized) {
554
- this._initialized = true;
555
- setTimeout(() => {
556
- model.sync(this._adapter);
557
- });
558
- }
559
- }
560
- destroy() {
561
- this._controls?.remove();
562
- this._cleanup();
563
- }
564
- constructor(view) {
565
- _define_property2(this, "_controls", void 0);
566
- _define_property2(this, "_cleanup", void 0);
567
- _define_property2(this, "_adapter", void 0);
568
- _define_property2(this, "_initialized", false);
569
- this._adapter = new DocumentAdapter(view);
570
- const scroller = view.scrollDOM;
571
- let isAutoScrolling = false;
572
- let hasScrolled = false;
573
- let timeout;
574
- const scrollToBottom = (smooth = false) => {
575
- scroller.style.scrollBehavior = smooth ? "smooth" : "";
576
- scroller.classList.add("cm-hide-scrollbar");
577
- isAutoScrolling = true;
578
- clearTimeout(timeout);
579
- timeout = setTimeout(() => {
580
- this._controls?.classList.add("opacity-0");
581
- scroller.classList.remove("cm-hide-scrollbar");
582
- isAutoScrolling = false;
583
- }, 500);
584
- view.dispatch({
585
- effects: EditorView.scrollIntoView(view.state.doc.length, {
586
- y: "end"
587
- })
588
- });
589
- };
590
- this._cleanup = combine(addEventListener(view.scrollDOM, "scroll", () => {
591
- if (!isAutoScrolling) {
592
- hasScrolled = true;
593
- this._controls?.classList.remove("opacity-0");
594
- }
595
- }), model.update.on(() => {
596
- const autoScroll2 = scroller.scrollHeight - scroller.scrollTop - scroller.clientHeight === 0 || !hasScrolled;
597
- model.sync(this._adapter);
598
- if (autoScroll2) {
599
- scrollToBottom(true);
600
- }
601
- }));
602
- }
603
- }),
604
- EditorView.theme({
605
- ".cm-timestamp-gutter": {
606
- width: "6rem",
607
- paddingRight: "1rem"
608
- },
609
- ".cm-timestamp-gutter > .cm-gutterElement > div": {
610
- display: "inline-flex",
611
- textAlign: "right",
612
- padding: "3px"
613
- }
614
- })
615
- ];
616
- };
617
- var TimestampMarker = class extends GutterMarker {
618
- eq(other) {
619
- return other._timestamp === this._timestamp;
620
- }
621
- toDOM(view) {
622
- const el = document.createElement("div");
623
- el.className = "text-sm text-subdued hover:bg-hoverSurface cursor-pointer";
624
- el.textContent = formatTimestamp(this._timestamp, this._started);
625
- el.onclick = () => {
626
- const pos = view.state.doc.line(this._line).from;
627
- view.dispatch({
628
- effects: EditorView.scrollIntoView(pos, {
629
- y: "start"
630
- })
631
- });
632
- };
633
- return el;
634
- }
635
- constructor(_line, _timestamp, _started) {
636
- super(), _define_property2(this, "_line", void 0), _define_property2(this, "_timestamp", void 0), _define_property2(this, "_started", void 0), this._line = _line, this._timestamp = _timestamp, this._started = _started;
637
- }
638
- };
639
- var getStartTime = (started, message) => {
640
- if (started) {
641
- return started;
642
- }
643
- if (message?.blocks[0]?._tag === "transcript" && message.blocks[0].started) {
644
- return new Date(message.blocks[0].started);
645
- }
646
- return void 0;
647
- };
648
- var formatTimestamp = (timestamp, relative) => {
649
- if (relative) {
650
- const pad = (n = 0) => String(n).padStart(2, "0");
651
- const { hours, minutes, seconds } = intervalToDuration({
652
- start: relative,
653
- end: timestamp
654
- });
655
- return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`;
656
- } else {
657
- return format(timestamp, "HH:mm:ss");
658
- }
659
- };
660
-
661
- // src/components/Transcript/Transcript.tsx
662
- var renderByline = (identities) => (message, index, debug = false) => {
663
- if (message.sender.role === "assistant") {
664
- return [
665
- message.blocks.find((block) => block._tag === "transcript")?.text ?? "",
666
- ""
667
- ];
668
- }
669
- const identity = identities.find((identity2) => identity2.did === message.sender.identityDid);
670
- const name = identity?.profile?.displayName ?? message.sender.contact?.target?.fullName ?? message.sender.name ?? message.sender.email ?? message.sender.identityDid;
671
- const blocks = message.blocks.filter((block) => block._tag === "transcript");
672
- return [
673
- // TODO(thure): Use an XML tag with the bits needed here.
674
- `###### ${name}` + (debug ? ` [${index}]:${message.id}` : ""),
675
- blocks.map((block) => block.text.trim()).join(" "),
676
- ""
677
- ];
678
- };
679
- var TranscriptView = ({ classNames, space, transcript: object, model }) => {
680
- var _effect = _useSignals();
681
- try {
682
- const { themeMode } = useThemeContext();
683
- const { parentRef } = useTextEditor(() => {
684
- return {
685
- extensions: [
686
- createBasicExtensions({
687
- readOnly: true,
688
- lineWrapping: true,
689
- search: true
690
- }),
691
- createMarkdownExtensions(),
692
- createThemeExtensions({
693
- themeMode
694
- }),
695
- decorateMarkdown(),
696
- preview(),
697
- transcript({
698
- model,
699
- started: object?.started ? new Date(object.started) : void 0
700
- }),
701
- autoScroll()
702
- ].filter(isTruthy)
703
- };
704
- }, [
705
- space,
706
- model
707
- ]);
708
- return /* @__PURE__ */ React.createElement("div", {
709
- ref: parentRef,
710
- className: mx("flex grow overflow-hidden container-max-width", classNames),
711
- "data-popover-collision-boundary": true
712
- });
713
- } finally {
714
- _effect.f();
715
- }
716
- };
717
-
718
- // src/components/TranscriptContainer.tsx
719
- var TranscriptionContainer = ({ transcript: transcript2 }) => {
720
- var _effect = _useSignals2();
721
- try {
722
- const attendableId = fullyQualifiedId(transcript2);
723
- const space = getSpace(transcript2);
724
- const members = useMembers(space?.key).map((member) => member.identity);
725
- const queue = useQueue(transcript2.queue.dxn, {
726
- pollInterval: 1e3
727
- });
728
- const model = useQueueModelAdapter(renderByline(members), queue);
729
- return /* @__PURE__ */ React2.createElement(StackItem.Content, null, /* @__PURE__ */ React2.createElement(TranscriptView, {
730
- attendableId,
731
- space,
732
- model,
733
- transcript: transcript2
734
- }));
735
- } finally {
736
- _effect.f();
737
- }
738
- };
739
- var TranscriptContainer_default = TranscriptionContainer;
740
-
741
661
  export {
742
- renderByline,
743
- TranscriptView,
662
+ Transcription,
744
663
  useAudioFile,
745
664
  useAudioTrack,
746
665
  useQueueModelAdapter,
747
666
  useTranscriber,
748
- useVoiceInput,
749
- TranscriptionContainer,
750
- TranscriptContainer_default,
751
- BlueprintDefinition,
752
- IntentResolver,
753
- ReactSurface,
754
- Transcriber
667
+ useVoiceInput
755
668
  };
756
- //# sourceMappingURL=chunk-PEZRQYKO.mjs.map
669
+ //# sourceMappingURL=chunk-DYUGYQCB.mjs.map