@dxos/plugin-transcription 0.8.1 → 0.8.2-main.2f9c567

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 (241) hide show
  1. package/dist/lib/browser/{TranscriptContainer-JQ3HFHLQ.mjs → TranscriptContainer-3LU3XBEB.mjs} +3 -2
  2. package/dist/lib/browser/app-graph-builder-YXELPN6F.mjs +349 -0
  3. package/dist/lib/browser/app-graph-builder-YXELPN6F.mjs.map +7 -0
  4. package/dist/lib/browser/{chunk-YCZISX63.mjs → chunk-GWY2Q2NE.mjs} +108 -81
  5. package/dist/lib/browser/chunk-GWY2Q2NE.mjs.map +7 -0
  6. package/dist/lib/browser/chunk-HNIKXVCG.mjs +720 -0
  7. package/dist/lib/browser/chunk-HNIKXVCG.mjs.map +7 -0
  8. package/dist/lib/browser/chunk-HRDAILQX.mjs +27 -0
  9. package/dist/lib/browser/chunk-HRDAILQX.mjs.map +7 -0
  10. package/dist/lib/browser/{chunk-GU2BNYKZ.mjs → chunk-KLD7O5GJ.mjs} +2 -12
  11. package/dist/lib/browser/chunk-KLD7O5GJ.mjs.map +7 -0
  12. package/dist/lib/browser/{chunk-YEPT334A.mjs → chunk-LTIQFX4W.mjs} +1 -1
  13. package/dist/lib/browser/chunk-LTIQFX4W.mjs.map +7 -0
  14. package/dist/lib/browser/chunk-TGOKX32G.mjs +63 -0
  15. package/dist/lib/browser/chunk-TGOKX32G.mjs.map +7 -0
  16. package/dist/lib/browser/index.mjs +46 -209
  17. package/dist/lib/browser/index.mjs.map +4 -4
  18. package/dist/lib/browser/{intent-resolver-4R66ZCKT.mjs → intent-resolver-BBB3DWV4.mjs} +8 -8
  19. package/dist/lib/browser/intent-resolver-BBB3DWV4.mjs.map +7 -0
  20. package/dist/lib/browser/{meeting-transcription-state-DLFHQK72.mjs → meeting-transcription-state-MNA2XROE.mjs} +4 -4
  21. package/dist/lib/browser/meeting-transcription-state-MNA2XROE.mjs.map +7 -0
  22. package/dist/lib/browser/meta.json +1 -1
  23. package/dist/lib/browser/{react-surface-FQUHU5G7.mjs → react-surface-R277DACJ.mjs} +18 -6
  24. package/dist/lib/browser/react-surface-R277DACJ.mjs.map +7 -0
  25. package/dist/lib/browser/settings-I226DZ27.mjs +24 -0
  26. package/dist/lib/browser/settings-I226DZ27.mjs.map +7 -0
  27. package/dist/lib/browser/{transcriber-LGMIWDYI.mjs → transcriber-QRSS6X6S.mjs} +8 -7
  28. package/dist/lib/browser/{transcriber-LGMIWDYI.mjs.map → transcriber-QRSS6X6S.mjs.map} +3 -3
  29. package/dist/lib/browser/types/index.mjs +3 -3
  30. package/dist/lib/node/{TranscriptContainer-QEYTTT2V.cjs → TranscriptContainer-DICOMZLM.cjs} +8 -7
  31. package/dist/lib/node/TranscriptContainer-DICOMZLM.cjs.map +7 -0
  32. package/dist/lib/node/app-graph-builder-I6LYVIYY.cjs +350 -0
  33. package/dist/lib/node/app-graph-builder-I6LYVIYY.cjs.map +7 -0
  34. package/dist/lib/node/{chunk-P4VVD6ZO.cjs → chunk-34WFY7M7.cjs} +24 -34
  35. package/dist/lib/node/chunk-34WFY7M7.cjs.map +7 -0
  36. package/dist/lib/node/chunk-4JOJCZPJ.cjs +737 -0
  37. package/dist/lib/node/chunk-4JOJCZPJ.cjs.map +7 -0
  38. package/dist/lib/node/{chunk-3KHUSQNW.cjs → chunk-J72PUQ3C.cjs} +6 -15
  39. package/dist/lib/node/chunk-J72PUQ3C.cjs.map +7 -0
  40. package/dist/lib/node/{chunk-CZMLKKWT.cjs → chunk-JUGOXWES.cjs} +4 -4
  41. package/dist/lib/node/chunk-JUGOXWES.cjs.map +7 -0
  42. package/dist/lib/node/{chunk-LP4FG423.cjs → chunk-K553L7CZ.cjs} +23 -8
  43. package/dist/lib/node/chunk-K553L7CZ.cjs.map +7 -0
  44. package/dist/lib/node/{chunk-FCCJALOT.cjs → chunk-RK4BEN5E.cjs} +111 -83
  45. package/dist/lib/node/chunk-RK4BEN5E.cjs.map +7 -0
  46. package/dist/lib/node/index.cjs +65 -237
  47. package/dist/lib/node/index.cjs.map +4 -4
  48. package/dist/lib/node/{intent-resolver-WMMCOUEH.cjs → intent-resolver-7XY3WITN.cjs} +11 -10
  49. package/dist/lib/node/intent-resolver-7XY3WITN.cjs.map +7 -0
  50. package/dist/lib/node/{meeting-transcription-state-URIYILEQ.cjs → meeting-transcription-state-5XLTMWPA.cjs} +7 -7
  51. package/dist/lib/node/meeting-transcription-state-5XLTMWPA.cjs.map +7 -0
  52. package/dist/lib/node/meta.json +1 -1
  53. package/dist/lib/node/{react-surface-WI2MGWCC.cjs → react-surface-HUSWAORU.cjs} +20 -10
  54. package/dist/lib/node/react-surface-HUSWAORU.cjs.map +7 -0
  55. package/dist/lib/node/settings-NDMU3EWQ.cjs +38 -0
  56. package/dist/lib/node/settings-NDMU3EWQ.cjs.map +7 -0
  57. package/dist/lib/node/{transcriber-QG5WPKX4.cjs → transcriber-UZJMG44C.cjs} +14 -13
  58. package/dist/lib/node/{transcriber-QG5WPKX4.cjs.map → transcriber-UZJMG44C.cjs.map} +3 -3
  59. package/dist/lib/node/types/index.cjs +8 -8
  60. package/dist/lib/node/types/index.cjs.map +1 -1
  61. package/dist/lib/node-esm/{TranscriptContainer-ZXUCOWGY.mjs → TranscriptContainer-K4E4P5T6.mjs} +3 -2
  62. package/dist/lib/node-esm/app-graph-builder-6FY2UQOH.mjs +350 -0
  63. package/dist/lib/node-esm/app-graph-builder-6FY2UQOH.mjs.map +7 -0
  64. package/dist/lib/node-esm/chunk-3I7AC3D3.mjs +28 -0
  65. package/dist/lib/node-esm/chunk-3I7AC3D3.mjs.map +7 -0
  66. package/dist/lib/node-esm/{chunk-PTZHDZ36.mjs → chunk-5E2MR5XK.mjs} +1 -1
  67. package/dist/lib/node-esm/chunk-5E2MR5XK.mjs.map +7 -0
  68. package/dist/lib/node-esm/chunk-6C34FO4C.mjs +721 -0
  69. package/dist/lib/node-esm/chunk-6C34FO4C.mjs.map +7 -0
  70. package/dist/lib/node-esm/{chunk-YQYBLFNI.mjs → chunk-CKANLRS4.mjs} +108 -81
  71. package/dist/lib/node-esm/chunk-CKANLRS4.mjs.map +7 -0
  72. package/dist/lib/node-esm/chunk-KUQ3ZTRX.mjs +64 -0
  73. package/dist/lib/node-esm/chunk-KUQ3ZTRX.mjs.map +7 -0
  74. package/dist/lib/node-esm/{chunk-HKATMD34.mjs → chunk-QMHMEKB3.mjs} +2 -12
  75. package/dist/lib/node-esm/chunk-QMHMEKB3.mjs.map +7 -0
  76. package/dist/lib/node-esm/index.mjs +46 -209
  77. package/dist/lib/node-esm/index.mjs.map +4 -4
  78. package/dist/lib/node-esm/{intent-resolver-QN2LO5TX.mjs → intent-resolver-ACGAPLDZ.mjs} +8 -8
  79. package/dist/lib/node-esm/intent-resolver-ACGAPLDZ.mjs.map +7 -0
  80. package/dist/lib/node-esm/{meeting-transcription-state-ZYVRAW6Y.mjs → meeting-transcription-state-3WOZ52BQ.mjs} +4 -4
  81. package/dist/lib/node-esm/meeting-transcription-state-3WOZ52BQ.mjs.map +7 -0
  82. package/dist/lib/node-esm/meta.json +1 -1
  83. package/dist/lib/node-esm/{react-surface-PCH6NTVB.mjs → react-surface-G2OY4MWL.mjs} +18 -6
  84. package/dist/lib/node-esm/react-surface-G2OY4MWL.mjs.map +7 -0
  85. package/dist/lib/node-esm/settings-O7X2UQQG.mjs +25 -0
  86. package/dist/lib/node-esm/settings-O7X2UQQG.mjs.map +7 -0
  87. package/dist/lib/node-esm/{transcriber-TMPYZ5L4.mjs → transcriber-NVVFH7IF.mjs} +8 -7
  88. package/dist/lib/node-esm/{transcriber-TMPYZ5L4.mjs.map → transcriber-NVVFH7IF.mjs.map} +3 -3
  89. package/dist/lib/node-esm/types/index.mjs +3 -3
  90. package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
  91. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  92. package/dist/types/src/capabilities/capabilities.d.ts +5 -7
  93. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
  94. package/dist/types/src/capabilities/index.d.ts +2 -4
  95. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  96. package/dist/types/src/capabilities/meeting-transcription-state.d.ts +2 -4
  97. package/dist/types/src/capabilities/meeting-transcription-state.d.ts.map +1 -1
  98. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  99. package/dist/types/src/capabilities/settings.d.ts +4 -0
  100. package/dist/types/src/capabilities/settings.d.ts.map +1 -0
  101. package/dist/types/src/capabilities/transcriber.d.ts.map +1 -1
  102. package/dist/types/src/components/Transcript/Transcript.d.ts +14 -4
  103. package/dist/types/src/components/Transcript/Transcript.d.ts.map +1 -1
  104. package/dist/types/src/components/Transcript/Transcript.stories.d.ts +19 -4
  105. package/dist/types/src/components/Transcript/Transcript.stories.d.ts.map +1 -1
  106. package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts +27 -0
  107. package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts.map +1 -0
  108. package/dist/types/src/components/Transcript/transcript-extension.d.ts +19 -0
  109. package/dist/types/src/components/Transcript/transcript-extension.d.ts.map +1 -0
  110. package/dist/types/src/components/TranscriptContainer.d.ts.map +1 -1
  111. package/dist/types/src/components/TranscriptionSettings/TranscriptionSettings.d.ts +6 -0
  112. package/dist/types/src/components/TranscriptionSettings/TranscriptionSettings.d.ts.map +1 -0
  113. package/dist/types/src/components/TranscriptionSettings/index.d.ts +2 -0
  114. package/dist/types/src/components/TranscriptionSettings/index.d.ts.map +1 -0
  115. package/dist/types/src/components/index.d.ts +1 -0
  116. package/dist/types/src/components/index.d.ts.map +1 -1
  117. package/dist/types/src/components/transcription.stories.d.ts +6 -3
  118. package/dist/types/src/components/transcription.stories.d.ts.map +1 -1
  119. package/dist/types/src/entity-extraction/entity-extraction.d.ts +42 -0
  120. package/dist/types/src/entity-extraction/entity-extraction.d.ts.map +1 -0
  121. package/dist/types/src/entity-extraction/entity-extraction.test.d.ts +2 -0
  122. package/dist/types/src/entity-extraction/entity-extraction.test.d.ts.map +1 -0
  123. package/dist/types/src/entity-extraction/index.d.ts +2 -0
  124. package/dist/types/src/entity-extraction/index.d.ts.map +1 -0
  125. package/dist/types/src/hooks/index.d.ts +1 -0
  126. package/dist/types/src/hooks/index.d.ts.map +1 -1
  127. package/dist/types/src/hooks/useQueueModelAdapter.d.ts +7 -0
  128. package/dist/types/src/hooks/useQueueModelAdapter.d.ts.map +1 -0
  129. package/dist/types/src/hooks/useTranscriber.d.ts +1 -1
  130. package/dist/types/src/hooks/useTranscriber.d.ts.map +1 -1
  131. package/dist/types/src/model/index.d.ts +2 -0
  132. package/dist/types/src/model/index.d.ts.map +1 -0
  133. package/dist/types/src/model/model.d.ts +68 -0
  134. package/dist/types/src/model/model.d.ts.map +1 -0
  135. package/dist/types/src/model/model.test.d.ts +2 -0
  136. package/dist/types/src/model/model.test.d.ts.map +1 -0
  137. package/dist/types/src/testing/index.d.ts +2 -0
  138. package/dist/types/src/testing/index.d.ts.map +1 -0
  139. package/dist/types/src/testing/testing.d.ts +40 -0
  140. package/dist/types/src/testing/testing.d.ts.map +1 -0
  141. package/dist/types/src/transcriber/transcriber.browser.test.d.ts +2 -0
  142. package/dist/types/src/transcriber/transcriber.browser.test.d.ts.map +1 -0
  143. package/dist/types/src/transcriber/transcriber.d.ts +2 -2
  144. package/dist/types/src/transcriber/transcriber.d.ts.map +1 -1
  145. package/dist/types/src/transcriber/transcription-manager.d.ts +17 -15
  146. package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -1
  147. package/dist/types/src/translations.d.ts +3 -0
  148. package/dist/types/src/translations.d.ts.map +1 -1
  149. package/dist/types/src/types/schema.d.ts +26 -40
  150. package/dist/types/src/types/schema.d.ts.map +1 -1
  151. package/dist/types/src/types/types.d.ts +11 -7
  152. package/dist/types/src/types/types.d.ts.map +1 -1
  153. package/dist/types/src/util/index.d.ts +0 -1
  154. package/dist/types/src/util/index.d.ts.map +1 -1
  155. package/package.json +53 -40
  156. package/src/TranscriptionPlugin.tsx +29 -12
  157. package/src/capabilities/app-graph-builder.ts +111 -52
  158. package/src/capabilities/capabilities.ts +4 -3
  159. package/src/capabilities/index.ts +1 -0
  160. package/src/capabilities/intent-resolver.ts +5 -5
  161. package/src/capabilities/meeting-transcription-state.ts +2 -2
  162. package/src/capabilities/react-surface.tsx +12 -4
  163. package/src/capabilities/settings.ts +20 -0
  164. package/src/capabilities/transcriber.ts +2 -1
  165. package/src/components/Transcript/Transcript.stories.tsx +201 -43
  166. package/src/components/Transcript/Transcript.tsx +83 -208
  167. package/src/components/Transcript/deprecated/OldTranscript.tsx +260 -0
  168. package/src/components/Transcript/transcript-extension.ts +236 -0
  169. package/src/components/TranscriptContainer.tsx +11 -6
  170. package/src/components/TranscriptionSettings/TranscriptionSettings.tsx +26 -0
  171. package/src/components/TranscriptionSettings/index.ts +5 -0
  172. package/src/components/index.ts +1 -0
  173. package/src/components/transcription.stories.tsx +163 -60
  174. package/src/entity-extraction/entity-extraction.test.ts +97 -0
  175. package/src/entity-extraction/entity-extraction.ts +149 -0
  176. package/src/entity-extraction/index.ts +5 -0
  177. package/src/entity-extraction/system-prompt.tpl +38 -0
  178. package/src/entity-extraction/types.d.ts +8 -0
  179. package/src/hooks/index.ts +1 -0
  180. package/src/hooks/useQueueModelAdapter.ts +63 -0
  181. package/src/hooks/useTranscriber.ts +3 -2
  182. package/src/model/index.ts +5 -0
  183. package/src/model/model.test.ts +169 -0
  184. package/src/model/model.ts +229 -0
  185. package/src/testing/index.ts +5 -0
  186. package/src/testing/testing.ts +221 -0
  187. package/src/transcriber/{transcriber.test.ts → transcriber.browser.test.ts} +3 -3
  188. package/src/transcriber/transcriber.ts +20 -11
  189. package/src/transcriber/transcription-manager.ts +67 -58
  190. package/src/translations.ts +2 -0
  191. package/src/types/schema.ts +11 -32
  192. package/src/types/types.ts +19 -9
  193. package/src/util/index.ts +0 -1
  194. package/dist/lib/browser/app-graph-builder-VDQOVX7P.mjs +0 -191
  195. package/dist/lib/browser/app-graph-builder-VDQOVX7P.mjs.map +0 -7
  196. package/dist/lib/browser/chunk-G4B6CPC2.mjs +0 -253
  197. package/dist/lib/browser/chunk-G4B6CPC2.mjs.map +0 -7
  198. package/dist/lib/browser/chunk-GU2BNYKZ.mjs.map +0 -7
  199. package/dist/lib/browser/chunk-K7FOYAXO.mjs +0 -8
  200. package/dist/lib/browser/chunk-K7FOYAXO.mjs.map +0 -7
  201. package/dist/lib/browser/chunk-OGNXNGJB.mjs +0 -73
  202. package/dist/lib/browser/chunk-OGNXNGJB.mjs.map +0 -7
  203. package/dist/lib/browser/chunk-YCZISX63.mjs.map +0 -7
  204. package/dist/lib/browser/chunk-YEPT334A.mjs.map +0 -7
  205. package/dist/lib/browser/intent-resolver-4R66ZCKT.mjs.map +0 -7
  206. package/dist/lib/browser/meeting-transcription-state-DLFHQK72.mjs.map +0 -7
  207. package/dist/lib/browser/react-surface-FQUHU5G7.mjs.map +0 -7
  208. package/dist/lib/node/TranscriptContainer-QEYTTT2V.cjs.map +0 -7
  209. package/dist/lib/node/app-graph-builder-IFSIVNUR.cjs +0 -200
  210. package/dist/lib/node/app-graph-builder-IFSIVNUR.cjs.map +0 -7
  211. package/dist/lib/node/chunk-3KHUSQNW.cjs.map +0 -7
  212. package/dist/lib/node/chunk-CZMLKKWT.cjs.map +0 -7
  213. package/dist/lib/node/chunk-FCCJALOT.cjs.map +0 -7
  214. package/dist/lib/node/chunk-LP4FG423.cjs.map +0 -7
  215. package/dist/lib/node/chunk-P4VVD6ZO.cjs.map +0 -7
  216. package/dist/lib/node/chunk-UOFHT4GZ.cjs +0 -280
  217. package/dist/lib/node/chunk-UOFHT4GZ.cjs.map +0 -7
  218. package/dist/lib/node/intent-resolver-WMMCOUEH.cjs.map +0 -7
  219. package/dist/lib/node/meeting-transcription-state-URIYILEQ.cjs.map +0 -7
  220. package/dist/lib/node/react-surface-WI2MGWCC.cjs.map +0 -7
  221. package/dist/lib/node-esm/app-graph-builder-UL6XLIZY.mjs +0 -192
  222. package/dist/lib/node-esm/app-graph-builder-UL6XLIZY.mjs.map +0 -7
  223. package/dist/lib/node-esm/chunk-6X7X2UZF.mjs +0 -254
  224. package/dist/lib/node-esm/chunk-6X7X2UZF.mjs.map +0 -7
  225. package/dist/lib/node-esm/chunk-GIO6J6FE.mjs +0 -74
  226. package/dist/lib/node-esm/chunk-GIO6J6FE.mjs.map +0 -7
  227. package/dist/lib/node-esm/chunk-HKATMD34.mjs.map +0 -7
  228. package/dist/lib/node-esm/chunk-J4D2RBBH.mjs +0 -10
  229. package/dist/lib/node-esm/chunk-J4D2RBBH.mjs.map +0 -7
  230. package/dist/lib/node-esm/chunk-PTZHDZ36.mjs.map +0 -7
  231. package/dist/lib/node-esm/chunk-YQYBLFNI.mjs.map +0 -7
  232. package/dist/lib/node-esm/intent-resolver-QN2LO5TX.mjs.map +0 -7
  233. package/dist/lib/node-esm/meeting-transcription-state-ZYVRAW6Y.mjs.map +0 -7
  234. package/dist/lib/node-esm/react-surface-PCH6NTVB.mjs.map +0 -7
  235. package/dist/types/src/transcriber/transcriber.test.d.ts +0 -2
  236. package/dist/types/src/transcriber/transcriber.test.d.ts.map +0 -1
  237. package/dist/types/src/util/random-queue-dxn.d.ts +0 -3
  238. package/dist/types/src/util/random-queue-dxn.d.ts.map +0 -1
  239. package/src/util/random-queue-dxn.ts +0 -9
  240. /package/dist/lib/browser/{TranscriptContainer-JQ3HFHLQ.mjs.map → TranscriptContainer-3LU3XBEB.mjs.map} +0 -0
  241. /package/dist/lib/node-esm/{TranscriptContainer-ZXUCOWGY.mjs.map → TranscriptContainer-K4E4P5T6.mjs.map} +0 -0
@@ -0,0 +1,720 @@
1
+ import {
2
+ TranscriptionCapabilities
3
+ } from "./chunk-LTIQFX4W.mjs";
4
+
5
+ // packages/plugins/plugin-transcription/src/components/TranscriptContainer.tsx
6
+ import React2 from "react";
7
+ import { fullyQualifiedId, getSpace } from "@dxos/client/echo";
8
+ import { useMembers, useQueue } from "@dxos/react-client/echo";
9
+ import { StackItem } from "@dxos/react-ui-stack";
10
+
11
+ // packages/plugins/plugin-transcription/src/components/Transcript/Transcript.tsx
12
+ import React from "react";
13
+ import { IconButton, useThemeContext } from "@dxos/react-ui";
14
+ import { createBasicExtensions, createMarkdownExtensions, createRenderer, createThemeExtensions, decorateMarkdown, editorWidth, preview, useTextEditor } from "@dxos/react-ui-editor";
15
+ import { mx } from "@dxos/react-ui-theme";
16
+ import { isNotFalsy } from "@dxos/util";
17
+
18
+ // packages/plugins/plugin-transcription/src/components/Transcript/transcript-extension.ts
19
+ import { RangeSetBuilder } from "@codemirror/state";
20
+ import { EditorView, GutterMarker, ViewPlugin, gutter } from "@codemirror/view";
21
+ import { format } from "date-fns/format";
22
+ import { intervalToDuration } from "date-fns/intervalToDuration";
23
+ import { addEventListener, combine } from "@dxos/async";
24
+
25
+ // packages/plugins/plugin-transcription/src/model/model.ts
26
+ import { Text } from "@codemirror/state";
27
+ import { Event } from "@dxos/async";
28
+ import { invariant } from "@dxos/invariant";
29
+ import { log } from "@dxos/log";
30
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-transcription/src/model/model.ts";
31
+ var DocumentAdapter = class {
32
+ constructor(_view) {
33
+ this._view = _view;
34
+ }
35
+ /** The document must always have at least one line. */
36
+ lineCount() {
37
+ return this._view.state.doc.lines - 1;
38
+ }
39
+ replaceLines(from, remove, insert) {
40
+ log("replaceLines", {
41
+ count: this._view.state.doc.lines,
42
+ from,
43
+ remove,
44
+ insert
45
+ }, {
46
+ F: __dxlog_file,
47
+ L: 39,
48
+ S: this,
49
+ C: (f, a) => f(...a)
50
+ });
51
+ const numLines = this._view.state.doc.lines;
52
+ const posFrom = this._view.state.doc.line(from).from;
53
+ const posTo = remove === 0 ? posFrom : this._view.state.doc.line(Math.min(numLines, from + remove)).from;
54
+ let text = insert.join("\n");
55
+ if (posTo === this._view.state.doc.length) {
56
+ text += "\n";
57
+ }
58
+ this._view.dispatch({
59
+ changes: {
60
+ from: posFrom,
61
+ to: posTo,
62
+ insert: text
63
+ }
64
+ });
65
+ }
66
+ };
67
+ var SerializationModel = class {
68
+ constructor(_renderer, initialChunks = []) {
69
+ this._renderer = _renderer;
70
+ this._chunks = [];
71
+ this._chunkLineCounts = /* @__PURE__ */ new Map();
72
+ this._lineToChunk = /* @__PURE__ */ new Map();
73
+ this._changes = [];
74
+ this.update = new Event();
75
+ initialChunks.forEach((chunk) => {
76
+ this.appendChunk(chunk);
77
+ });
78
+ }
79
+ toJSON() {
80
+ return {
81
+ chunks: this._chunks.length,
82
+ changes: this._changes.length
83
+ };
84
+ }
85
+ get doc() {
86
+ return Text.of([
87
+ ...this._chunks.flatMap((chunk, index) => this._renderer(chunk, index)),
88
+ ""
89
+ ]);
90
+ }
91
+ get chunks() {
92
+ return this._chunks;
93
+ }
94
+ /**
95
+ * Get the block ID at the given line number.
96
+ */
97
+ getChunkAtLine(line) {
98
+ return this._lineToChunk.get(line);
99
+ }
100
+ reset() {
101
+ this._chunks.length = 0;
102
+ this._chunkLineCounts.clear();
103
+ this._lineToChunk.clear();
104
+ this.update.emit();
105
+ return this;
106
+ }
107
+ appendChunk(chunk) {
108
+ const index = this._chunks.length;
109
+ this._chunks.push(chunk);
110
+ this._changes.push({
111
+ type: "append",
112
+ index,
113
+ chunk
114
+ });
115
+ this.update.emit();
116
+ return this;
117
+ }
118
+ updateChunk(chunk) {
119
+ const index = this._chunks.findIndex((c) => c.id === chunk.id);
120
+ invariant(index !== -1, void 0, {
121
+ F: __dxlog_file,
122
+ L: 147,
123
+ S: this,
124
+ A: [
125
+ "index !== -1",
126
+ ""
127
+ ]
128
+ });
129
+ this._chunks[index] = chunk;
130
+ this._changes.push({
131
+ type: "update",
132
+ index,
133
+ chunk
134
+ });
135
+ this.update.emit();
136
+ return this;
137
+ }
138
+ deleteBlock(id) {
139
+ const index = this._chunks.findIndex((c) => c.id === id);
140
+ invariant(index !== -1, void 0, {
141
+ F: __dxlog_file,
142
+ L: 156,
143
+ S: this,
144
+ A: [
145
+ "index !== -1",
146
+ ""
147
+ ]
148
+ });
149
+ this._chunks.splice(index, 1);
150
+ this._changes.push({
151
+ type: "delete",
152
+ index,
153
+ id
154
+ });
155
+ this.update.emit();
156
+ return this;
157
+ }
158
+ /**
159
+ * Syncs the tracked changes with the ChunkDocument.
160
+ */
161
+ sync(document2) {
162
+ log("sync", {
163
+ changes: this._changes
164
+ }, {
165
+ F: __dxlog_file,
166
+ L: 167,
167
+ S: this,
168
+ C: (f, a) => f(...a)
169
+ });
170
+ for (const change of this._changes) {
171
+ switch (change.type) {
172
+ case "append": {
173
+ const lines = this._renderer(change.chunk, change.index);
174
+ const lastLine = document2.lineCount();
175
+ document2.replaceLines(lastLine + 1, 0, lines);
176
+ break;
177
+ }
178
+ case "update": {
179
+ let lineStart = 1;
180
+ for (let i = 0; i < change.index; i++) {
181
+ lineStart += this._chunkLineCounts.get(this._chunks[i].id);
182
+ }
183
+ const previousLineCount = this._chunkLineCounts.get(change.chunk.id);
184
+ const newLines = this._renderer(change.chunk, change.index);
185
+ document2.replaceLines(lineStart, previousLineCount, newLines);
186
+ break;
187
+ }
188
+ case "delete": {
189
+ let lineStart = 1;
190
+ for (let i = 0; i < change.index; i++) {
191
+ lineStart += this._chunkLineCounts.get(this._chunks[i].id);
192
+ }
193
+ const previousLineCount = this._chunkLineCounts.get(change.id);
194
+ document2.replaceLines(lineStart, previousLineCount, []);
195
+ break;
196
+ }
197
+ }
198
+ }
199
+ this._lineToChunk.clear();
200
+ let currentLine = 1;
201
+ for (const [index, chunk] of this._chunks.entries()) {
202
+ const lineCount = this._renderer(chunk, index).length;
203
+ this._chunkLineCounts.set(chunk.id, lineCount);
204
+ this._lineToChunk.set(currentLine, chunk);
205
+ currentLine += lineCount;
206
+ }
207
+ const chunkIds = new Set(this._chunks.map((chunk) => chunk.id));
208
+ for (const id of this._chunkLineCounts.keys()) {
209
+ if (!chunkIds.has(id)) {
210
+ this._chunkLineCounts.delete(id);
211
+ }
212
+ }
213
+ this._changes.length = 0;
214
+ return this;
215
+ }
216
+ };
217
+
218
+ // packages/plugins/plugin-transcription/src/components/Transcript/transcript-extension.ts
219
+ var transcript = ({ model, started, renderButton }) => {
220
+ return [
221
+ // Show timestamps in the gutter.
222
+ gutter({
223
+ class: "cm-timestamp-gutter",
224
+ lineMarkerChange: (update) => update.docChanged || update.viewportChanged,
225
+ markers: (view) => {
226
+ const start = getStartTime(started, model.chunks[0]);
227
+ const builder = new RangeSetBuilder();
228
+ for (const { from, to } of view.visibleRanges) {
229
+ let line = view.state.doc.lineAt(from);
230
+ while (line.from <= to) {
231
+ const block = model.getChunkAtLine(line.number)?.blocks[0];
232
+ const timestamp = block?.type === "transcription" && block.started;
233
+ if (timestamp) {
234
+ builder.add(line.from, line.from, new TimestampMarker(line.number, new Date(timestamp), start));
235
+ }
236
+ if (line.to + 1 > view.state.doc.length) {
237
+ break;
238
+ }
239
+ line = view.state.doc.lineAt(line.to + 1);
240
+ }
241
+ }
242
+ return builder.finish();
243
+ }
244
+ }),
245
+ // Listen for model updates.
246
+ ViewPlugin.fromClass(class {
247
+ constructor(view) {
248
+ this._initialized = false;
249
+ this._adapter = new DocumentAdapter(view);
250
+ const scroller = view.scrollDOM;
251
+ let isAutoScrolling = false;
252
+ let hasScrolled = false;
253
+ let timeout;
254
+ const scrollToBottom = (smooth = false) => {
255
+ scroller.style.scrollBehavior = smooth ? "smooth" : "";
256
+ scroller.classList.add("cm-hide-scrollbar");
257
+ isAutoScrolling = true;
258
+ clearTimeout(timeout);
259
+ timeout = setTimeout(() => {
260
+ this._controls?.classList.add("opacity-0");
261
+ scroller.classList.remove("cm-hide-scrollbar");
262
+ isAutoScrolling = false;
263
+ }, 500);
264
+ view.dispatch({
265
+ effects: EditorView.scrollIntoView(view.state.doc.length, {
266
+ y: "end"
267
+ })
268
+ });
269
+ };
270
+ if (renderButton) {
271
+ this._controls = document.createElement("div");
272
+ this._controls.classList.add("cm-controls", "transition-opacity", "duration-300", "opacity-0");
273
+ view.dom.appendChild(this._controls);
274
+ renderButton(this._controls, {
275
+ onClick: () => {
276
+ scrollToBottom(false);
277
+ }
278
+ }, view);
279
+ }
280
+ this._cleanup = combine(addEventListener(view.scrollDOM, "scroll", () => {
281
+ if (!isAutoScrolling) {
282
+ hasScrolled = true;
283
+ this._controls?.classList.remove("opacity-0");
284
+ }
285
+ }), model.update.on(() => {
286
+ const autoScroll = scroller.scrollHeight - scroller.scrollTop - scroller.clientHeight === 0 || !hasScrolled;
287
+ model.sync(this._adapter);
288
+ if (autoScroll) {
289
+ scrollToBottom(true);
290
+ }
291
+ }));
292
+ }
293
+ update(update) {
294
+ if (!this._initialized) {
295
+ this._initialized = true;
296
+ setTimeout(() => {
297
+ model.sync(this._adapter);
298
+ });
299
+ }
300
+ }
301
+ destroy() {
302
+ this._controls?.remove();
303
+ this._cleanup();
304
+ }
305
+ }),
306
+ EditorView.theme({
307
+ ".cm-scroller": {
308
+ overflowY: "scroll"
309
+ },
310
+ ".cm-hide-scrollbar": {
311
+ scrollbarWidth: "none",
312
+ "-ms-overflow-style": "none"
313
+ },
314
+ ".cm-hide-scrollbar::-webkit-scrollbar": {
315
+ display: "none"
316
+ },
317
+ ".cm-controls": {
318
+ position: "absolute",
319
+ bottom: "0.5rem",
320
+ right: "0.5rem",
321
+ zIndex: 1e3
322
+ },
323
+ ".cm-line": {
324
+ paddingRight: "1rem"
325
+ },
326
+ ".cm-timestamp-gutter": {
327
+ width: "6rem",
328
+ paddingRight: "1rem"
329
+ },
330
+ ".cm-timestamp-gutter > .cm-gutterElement > div": {
331
+ display: "inline-flex",
332
+ textAlign: "right",
333
+ padding: "3px"
334
+ }
335
+ })
336
+ ];
337
+ };
338
+ var TimestampMarker = class extends GutterMarker {
339
+ constructor(_line, _timestamp, _started) {
340
+ super();
341
+ this._line = _line;
342
+ this._timestamp = _timestamp;
343
+ this._started = _started;
344
+ }
345
+ eq(other) {
346
+ return other._timestamp === this._timestamp;
347
+ }
348
+ toDOM(view) {
349
+ const el = document.createElement("div");
350
+ el.className = "text-sm text-subdued hover:bg-hoverSurface cursor-pointer";
351
+ el.textContent = formatTimestamp(this._timestamp, this._started);
352
+ el.onclick = () => {
353
+ const pos = view.state.doc.line(this._line).from;
354
+ view.dispatch({
355
+ effects: EditorView.scrollIntoView(pos, {
356
+ y: "start"
357
+ })
358
+ });
359
+ };
360
+ return el;
361
+ }
362
+ };
363
+ var getStartTime = (started, message) => {
364
+ if (started) {
365
+ return started;
366
+ }
367
+ if (message?.blocks[0]?.type === "transcription" && message.blocks[0].started) {
368
+ return new Date(message.blocks[0].started);
369
+ }
370
+ return void 0;
371
+ };
372
+ var formatTimestamp = (timestamp, relative) => {
373
+ if (relative) {
374
+ const pad = (n = 0) => String(n).padStart(2, "0");
375
+ const { hours, minutes, seconds } = intervalToDuration({
376
+ start: relative,
377
+ end: timestamp
378
+ });
379
+ return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`;
380
+ } else {
381
+ return format(timestamp, "HH:mm:ss");
382
+ }
383
+ };
384
+
385
+ // packages/plugins/plugin-transcription/src/components/Transcript/Transcript.tsx
386
+ var renderMarkdown = (identities) => (message, index, debug = false) => {
387
+ if (message.sender.role === "assistant") {
388
+ return [
389
+ message.blocks.find((block) => block.type === "transcription")?.text ?? "",
390
+ ""
391
+ ];
392
+ }
393
+ const identity = identities.find((identity2) => identity2.did === message.sender.identityDid);
394
+ const name = identity?.profile?.displayName ?? message.sender.contact?.target?.fullName ?? message.sender.name ?? message.sender.email ?? message.sender.identityDid;
395
+ const blocks = message.blocks.filter((block) => block.type === "transcription");
396
+ return [
397
+ `###### ${name}` + (debug ? ` [${index}]:${message.id}` : ""),
398
+ blocks.map((block) => block.text.trim()).join(" "),
399
+ ""
400
+ ];
401
+ };
402
+ var Transcript = ({ classNames, transcript: object, space, model, attendableId, ignoreAttention }) => {
403
+ const { themeMode } = useThemeContext();
404
+ const { parentRef } = useTextEditor(() => {
405
+ return {
406
+ extensions: [
407
+ createBasicExtensions({
408
+ readOnly: true,
409
+ lineWrapping: true
410
+ }),
411
+ createMarkdownExtensions({
412
+ themeMode
413
+ }),
414
+ createThemeExtensions({
415
+ themeMode
416
+ }),
417
+ decorateMarkdown(),
418
+ space && preview(),
419
+ transcript({
420
+ model,
421
+ started: object?.started ? new Date(object.started) : void 0,
422
+ renderButton: createRenderer(({ onClick }) => /* @__PURE__ */ React.createElement(IconButton, {
423
+ icon: "ph--arrow-line-down--regular",
424
+ iconOnly: true,
425
+ label: "Scroll to bottom",
426
+ onClick
427
+ }))
428
+ })
429
+ ].filter(isNotFalsy)
430
+ };
431
+ }, [
432
+ space,
433
+ model
434
+ ]);
435
+ return /* @__PURE__ */ React.createElement("div", {
436
+ ref: parentRef,
437
+ className: mx("flex grow overflow-hidden", editorWidth, classNames),
438
+ "data-popover-collision-boundary": true
439
+ });
440
+ };
441
+
442
+ // packages/plugins/plugin-transcription/src/hooks/useAudioFile.ts
443
+ import { useEffect, useState } from "react";
444
+ import { log as log2 } from "@dxos/log";
445
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-transcription/src/hooks/useAudioFile.ts";
446
+ var useAudioFile = (audioUrl) => {
447
+ const [{ audio, stream, track }, setStream] = useState({});
448
+ useEffect(() => {
449
+ const t = setTimeout(async () => {
450
+ const response = await fetch(audioUrl);
451
+ const blob = await response.blob();
452
+ const audio2 = new Audio();
453
+ audio2.src = URL.createObjectURL(blob);
454
+ await new Promise((resolve, reject) => {
455
+ audio2.addEventListener("error", (err) => {
456
+ log2.error("error", {
457
+ err
458
+ }, {
459
+ F: __dxlog_file2,
460
+ L: 27,
461
+ S: void 0,
462
+ C: (f, a) => f(...a)
463
+ });
464
+ reject(err);
465
+ }, {
466
+ once: true
467
+ });
468
+ audio2.addEventListener("canplay", () => {
469
+ log2.info("starting...", void 0, {
470
+ F: __dxlog_file2,
471
+ L: 35,
472
+ S: void 0,
473
+ C: (f, a) => f(...a)
474
+ });
475
+ resolve();
476
+ }, {
477
+ once: true
478
+ });
479
+ audio2.load();
480
+ });
481
+ const ctx = new AudioContext();
482
+ const destination = ctx.createMediaStreamDestination();
483
+ destination.channelCount = 1;
484
+ const source = ctx.createMediaElementSource(audio2);
485
+ source.connect(destination);
486
+ setStream({
487
+ audio: audio2,
488
+ stream: destination.stream,
489
+ track: destination.stream.getAudioTracks()[0]
490
+ });
491
+ });
492
+ return () => clearTimeout(t);
493
+ }, [
494
+ audioUrl
495
+ ]);
496
+ return {
497
+ audio,
498
+ stream,
499
+ track
500
+ };
501
+ };
502
+
503
+ // packages/plugins/plugin-transcription/src/hooks/useAudioTrack.ts
504
+ import { useEffect as useEffect2, useState as useState2 } from "react";
505
+ var useAudioTrack = (active) => {
506
+ const [track, setTrack] = useState2();
507
+ useEffect2(() => {
508
+ if (!active) {
509
+ track?.stop();
510
+ setTrack(void 0);
511
+ return;
512
+ }
513
+ const initAudio = async () => {
514
+ const audio = new Audio();
515
+ audio.srcObject = await navigator.mediaDevices.getUserMedia({
516
+ audio: true
517
+ });
518
+ const [track2] = audio.srcObject.getAudioTracks();
519
+ if (track2) {
520
+ setTrack(track2);
521
+ }
522
+ };
523
+ if (active) {
524
+ void initAudio();
525
+ }
526
+ }, [
527
+ active
528
+ ]);
529
+ return track;
530
+ };
531
+
532
+ // packages/plugins/plugin-transcription/src/hooks/useQueueModelAdapter.ts
533
+ import { useMemo, useEffect as useEffect3, useState as useState3 } from "react";
534
+ var useQueueModelAdapter = (renderer, queue, initialChunks = []) => {
535
+ const model = useMemo(() => new SerializationModel(renderer, initialChunks), [
536
+ queue
537
+ ]);
538
+ const [loaded, setLoaded] = useState3(false);
539
+ useEffect3(() => {
540
+ if (!queue) {
541
+ return;
542
+ }
543
+ const update = () => {
544
+ for (const block of queue?.items ?? []) {
545
+ model.appendChunk(block);
546
+ }
547
+ setLoaded(true);
548
+ };
549
+ let i;
550
+ if (queue.isLoading) {
551
+ i = setInterval(() => {
552
+ if (!queue?.isLoading) {
553
+ clearInterval(i);
554
+ update();
555
+ }
556
+ }, 1e3);
557
+ } else {
558
+ update();
559
+ }
560
+ return () => clearTimeout(i);
561
+ }, [
562
+ model,
563
+ queue
564
+ ]);
565
+ useEffect3(() => {
566
+ if (!loaded || !queue || model.chunks.length === queue.items.length) {
567
+ return;
568
+ }
569
+ const chunk = queue.items[queue.items.length - 1];
570
+ model.appendChunk(chunk);
571
+ }, [
572
+ model,
573
+ loaded,
574
+ queue?.items.length
575
+ ]);
576
+ return model;
577
+ };
578
+
579
+ // packages/plugins/plugin-transcription/src/hooks/useTranscriber.ts
580
+ import { useEffect as useEffect4, useMemo as useMemo2 } from "react";
581
+ import { useCapabilities } from "@dxos/app-framework";
582
+
583
+ // packages/plugins/plugin-transcription/src/capabilities/index.ts
584
+ import { lazy } from "@dxos/app-framework";
585
+ var AppGraphBuilder = lazy(() => import("./app-graph-builder-YXELPN6F.mjs"));
586
+ var IntentResolver = lazy(() => import("./intent-resolver-BBB3DWV4.mjs"));
587
+ var MeetingTranscriptionState = lazy(() => import("./meeting-transcription-state-MNA2XROE.mjs"));
588
+ var ReactSurface = lazy(() => import("./react-surface-R277DACJ.mjs"));
589
+ var Transcriber = lazy(() => import("./transcriber-QRSS6X6S.mjs"));
590
+ var Settings = lazy(() => import("./settings-I226DZ27.mjs"));
591
+
592
+ // packages/plugins/plugin-transcription/src/hooks/useTranscriber.ts
593
+ var useTranscriber = ({ audioStreamTrack, onSegments, config }) => {
594
+ const [getTranscriber] = useCapabilities(TranscriptionCapabilities.Transcriber);
595
+ const transcriber = useMemo2(() => {
596
+ if (!onSegments || !audioStreamTrack || !getTranscriber) {
597
+ return void 0;
598
+ }
599
+ return getTranscriber({
600
+ audioStreamTrack,
601
+ onSegments,
602
+ config
603
+ });
604
+ }, [
605
+ audioStreamTrack,
606
+ onSegments,
607
+ getTranscriber,
608
+ config
609
+ ]);
610
+ useEffect4(() => {
611
+ return () => {
612
+ void transcriber?.close();
613
+ };
614
+ }, [
615
+ transcriber
616
+ ]);
617
+ return transcriber;
618
+ };
619
+
620
+ // packages/plugins/plugin-transcription/src/hooks/useVoiceInput.ts
621
+ import { useState as useState4, useEffect as useEffect5, useCallback } from "react";
622
+ import { scheduleMicroTask } from "@dxos/async";
623
+ import { Context } from "@dxos/context";
624
+ import { log as log3 } from "@dxos/log";
625
+ import { useSoundEffect } from "@dxos/react-ui-sfx";
626
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-transcription/src/hooks/useVoiceInput.ts";
627
+ var useVoiceInput = ({ active, onUpdate }) => {
628
+ const soundStart = useSoundEffect("StartRecording");
629
+ const soundStop = useSoundEffect("StopRecording");
630
+ const handleSegments = useCallback(async (segments) => {
631
+ const text = segments.map((str) => str.text.trim().replace(/[^\w\s]/g, "")).join(" ");
632
+ onUpdate(text);
633
+ }, []);
634
+ const [recording, setRecording] = useState4(false);
635
+ const track = useAudioTrack(active);
636
+ const transcriber = useTranscriber({
637
+ audioStreamTrack: track,
638
+ onSegments: handleSegments
639
+ });
640
+ useEffect5(() => {
641
+ const ctx = new Context(void 0, {
642
+ F: __dxlog_file3,
643
+ L: 43
644
+ });
645
+ scheduleMicroTask(ctx, async () => {
646
+ if (active && transcriber) {
647
+ await transcriber.open();
648
+ log3.info("starting...", void 0, {
649
+ F: __dxlog_file3,
650
+ L: 47,
651
+ S: void 0,
652
+ C: (f, a) => f(...a)
653
+ });
654
+ setRecording(true);
655
+ void soundStart.play();
656
+ transcriber.startChunksRecording();
657
+ } else if (!active && transcriber?.isOpen) {
658
+ transcriber?.stopChunksRecording();
659
+ await transcriber?.close();
660
+ log3.info("stopped", void 0, {
661
+ F: __dxlog_file3,
662
+ L: 54,
663
+ S: void 0,
664
+ C: (f, a) => f(...a)
665
+ });
666
+ setRecording(false);
667
+ void soundStop.play();
668
+ }
669
+ });
670
+ return () => {
671
+ void ctx.dispose();
672
+ };
673
+ }, [
674
+ active,
675
+ transcriber
676
+ ]);
677
+ return {
678
+ recording
679
+ };
680
+ };
681
+
682
+ // packages/plugins/plugin-transcription/src/components/TranscriptContainer.tsx
683
+ var TranscriptionContainer = ({ role, transcript: transcript2 }) => {
684
+ const attendableId = fullyQualifiedId(transcript2);
685
+ const space = getSpace(transcript2);
686
+ const members = useMembers(space?.key).map((member) => member.identity);
687
+ const queue = useQueue(transcript2.queue.dxn, {
688
+ pollInterval: 1e3
689
+ });
690
+ const model = useQueueModelAdapter(renderMarkdown(members), queue);
691
+ return /* @__PURE__ */ React2.createElement(StackItem.Content, {
692
+ role,
693
+ classNames: "container-max-width pli-2"
694
+ }, /* @__PURE__ */ React2.createElement(Transcript, {
695
+ attendableId,
696
+ space,
697
+ model,
698
+ transcript: transcript2
699
+ }));
700
+ };
701
+ var TranscriptContainer_default = TranscriptionContainer;
702
+
703
+ export {
704
+ renderMarkdown,
705
+ Transcript,
706
+ useAudioFile,
707
+ useAudioTrack,
708
+ useQueueModelAdapter,
709
+ useTranscriber,
710
+ useVoiceInput,
711
+ TranscriptionContainer,
712
+ TranscriptContainer_default,
713
+ AppGraphBuilder,
714
+ IntentResolver,
715
+ MeetingTranscriptionState,
716
+ ReactSurface,
717
+ Transcriber,
718
+ Settings
719
+ };
720
+ //# sourceMappingURL=chunk-HNIKXVCG.mjs.map