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