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