@dxos/plugin-transcription 0.8.4-main.ae835ea → 0.8.4-main.bcb3aa67d6

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 (249) hide show
  1. package/dist/lib/browser/blueprints/index.mjs +31 -0
  2. package/dist/lib/browser/blueprints/index.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-HOOPZ7EM.mjs +35 -0
  4. package/dist/lib/browser/chunk-HOOPZ7EM.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  6. package/dist/lib/browser/chunk-RIUSFL62.mjs +112 -0
  7. package/dist/lib/browser/chunk-RIUSFL62.mjs.map +7 -0
  8. package/dist/lib/browser/chunk-YXU2ZO6W.mjs +17 -0
  9. package/dist/lib/browser/chunk-YXU2ZO6W.mjs.map +7 -0
  10. package/dist/lib/browser/create-IZPB7VZW.mjs +19 -0
  11. package/dist/lib/browser/create-IZPB7VZW.mjs.map +7 -0
  12. package/dist/lib/browser/index.mjs +1178 -97
  13. package/dist/lib/browser/index.mjs.map +4 -4
  14. package/dist/lib/browser/meta.json +1 -1
  15. package/dist/lib/browser/open-SN5O5I6X.mjs +29 -0
  16. package/dist/lib/browser/open-SN5O5I6X.mjs.map +7 -0
  17. package/dist/lib/browser/operations/index.mjs +13 -0
  18. package/dist/lib/browser/operations/index.mjs.map +7 -0
  19. package/dist/lib/browser/summarize-5MZENAU5.mjs +71 -0
  20. package/dist/lib/browser/summarize-5MZENAU5.mjs.map +7 -0
  21. package/dist/lib/browser/types/index.mjs +4 -6
  22. package/dist/lib/node-esm/blueprints/index.mjs +32 -0
  23. package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
  24. package/dist/lib/node-esm/chunk-3GSFEN4L.mjs +113 -0
  25. package/dist/lib/node-esm/chunk-3GSFEN4L.mjs.map +7 -0
  26. package/dist/lib/node-esm/chunk-BR2R6PCT.mjs +19 -0
  27. package/dist/lib/node-esm/chunk-BR2R6PCT.mjs.map +7 -0
  28. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  29. package/dist/lib/node-esm/chunk-NVM2QUMX.mjs +37 -0
  30. package/dist/lib/node-esm/chunk-NVM2QUMX.mjs.map +7 -0
  31. package/dist/lib/node-esm/create-TQDGXQBL.mjs +20 -0
  32. package/dist/lib/node-esm/create-TQDGXQBL.mjs.map +7 -0
  33. package/dist/lib/node-esm/index.mjs +1178 -97
  34. package/dist/lib/node-esm/index.mjs.map +4 -4
  35. package/dist/lib/node-esm/meta.json +1 -1
  36. package/dist/lib/node-esm/open-4GAAWWKJ.mjs +30 -0
  37. package/dist/lib/node-esm/open-4GAAWWKJ.mjs.map +7 -0
  38. package/dist/lib/node-esm/operations/index.mjs +14 -0
  39. package/dist/lib/node-esm/operations/index.mjs.map +7 -0
  40. package/dist/lib/node-esm/summarize-RVOSRHEC.mjs +72 -0
  41. package/dist/lib/node-esm/summarize-RVOSRHEC.mjs.map +7 -0
  42. package/dist/lib/node-esm/types/index.mjs +4 -6
  43. package/dist/types/src/TranscriptionPlugin.d.ts +2 -1
  44. package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
  45. package/dist/types/src/blueprints/index.d.ts +2 -0
  46. package/dist/types/src/blueprints/index.d.ts.map +1 -0
  47. package/dist/types/src/blueprints/transcription-blueprint.d.ts +4 -0
  48. package/dist/types/src/blueprints/transcription-blueprint.d.ts.map +1 -0
  49. package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -4
  50. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
  51. package/dist/types/src/capabilities/index.d.ts +6 -5
  52. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  53. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  54. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  55. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  56. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  57. package/dist/types/src/capabilities/transcriber.d.ts +4 -3
  58. package/dist/types/src/capabilities/transcriber.d.ts.map +1 -1
  59. package/dist/types/src/components/Transcription/Transcription.d.ts +22 -0
  60. package/dist/types/src/components/Transcription/Transcription.d.ts.map +1 -0
  61. package/dist/types/src/components/Transcription/Transcription.stories.d.ts +40 -0
  62. package/dist/types/src/components/Transcription/Transcription.stories.d.ts.map +1 -0
  63. package/dist/types/src/components/Transcription/index.d.ts +2 -0
  64. package/dist/types/src/components/Transcription/index.d.ts.map +1 -0
  65. package/dist/types/src/components/Transcription/transcription-extension.d.ts +15 -0
  66. package/dist/types/src/components/Transcription/transcription-extension.d.ts.map +1 -0
  67. package/dist/types/src/components/index.d.ts +1 -3
  68. package/dist/types/src/components/index.d.ts.map +1 -1
  69. package/dist/types/src/components/stories/FileTranscription.stories.d.ts +3 -3
  70. package/dist/types/src/components/stories/FileTranscription.stories.d.ts.map +1 -1
  71. package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts +2 -2
  72. package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts.map +1 -1
  73. package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts +5 -5
  74. package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts.map +1 -1
  75. package/dist/types/src/components/stories/TranscriptionStory.d.ts +2 -2
  76. package/dist/types/src/components/stories/TranscriptionStory.d.ts.map +1 -1
  77. package/dist/types/src/containers/TranscriptionContainer/TranscriptionContainer.d.ts +6 -0
  78. package/dist/types/src/containers/TranscriptionContainer/TranscriptionContainer.d.ts.map +1 -0
  79. package/dist/types/src/containers/TranscriptionContainer/index.d.ts +3 -0
  80. package/dist/types/src/containers/TranscriptionContainer/index.d.ts.map +1 -0
  81. package/dist/types/src/containers/index.d.ts +3 -0
  82. package/dist/types/src/containers/index.d.ts.map +1 -0
  83. package/dist/types/src/hooks/useQueueModelAdapter.d.ts +1 -1
  84. package/dist/types/src/hooks/useQueueModelAdapter.d.ts.map +1 -1
  85. package/dist/types/src/hooks/useTranscriber.d.ts +1 -1
  86. package/dist/types/src/hooks/useTranscriber.d.ts.map +1 -1
  87. package/dist/types/src/index.d.ts +1 -1
  88. package/dist/types/src/index.d.ts.map +1 -1
  89. package/dist/types/src/meta.d.ts +2 -2
  90. package/dist/types/src/meta.d.ts.map +1 -1
  91. package/dist/types/src/operations/create.d.ts +5 -0
  92. package/dist/types/src/operations/create.d.ts.map +1 -0
  93. package/dist/types/src/operations/definitions.d.ts +905 -0
  94. package/dist/types/src/operations/definitions.d.ts.map +1 -0
  95. package/dist/types/src/operations/index.d.ts +4 -0
  96. package/dist/types/src/operations/index.d.ts.map +1 -0
  97. package/dist/types/src/operations/open.d.ts +5 -0
  98. package/dist/types/src/operations/open.d.ts.map +1 -0
  99. package/dist/types/src/operations/summarize.d.ts +8 -0
  100. package/dist/types/src/operations/summarize.d.ts.map +1 -0
  101. package/dist/types/src/segments-normalization/message-normalizer.d.ts +5 -5
  102. package/dist/types/src/segments-normalization/message-normalizer.d.ts.map +1 -1
  103. package/dist/types/src/segments-normalization/normalization.d.ts +360 -474
  104. package/dist/types/src/segments-normalization/normalization.d.ts.map +1 -1
  105. package/dist/types/src/segments-normalization/utils.d.ts +2 -2
  106. package/dist/types/src/segments-normalization/utils.d.ts.map +1 -1
  107. package/dist/types/src/testing/testing.d.ts +9 -9
  108. package/dist/types/src/testing/testing.d.ts.map +1 -1
  109. package/dist/types/src/transcriber/media-stream-recorder.d.ts +2 -2
  110. package/dist/types/src/transcriber/media-stream-recorder.d.ts.map +1 -1
  111. package/dist/types/src/transcriber/transcriber.d.ts +4 -4
  112. package/dist/types/src/transcriber/transcriber.d.ts.map +1 -1
  113. package/dist/types/src/transcriber/transcription-manager.d.ts +9 -6
  114. package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -1
  115. package/dist/types/src/translations.d.ts +7 -7
  116. package/dist/types/src/translations.d.ts.map +1 -1
  117. package/dist/types/src/types/capabilities.d.ts +18 -0
  118. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  119. package/dist/types/src/types/index.d.ts +1 -2
  120. package/dist/types/src/types/index.d.ts.map +1 -1
  121. package/dist/types/src/util/index.d.ts +1 -0
  122. package/dist/types/src/util/index.d.ts.map +1 -1
  123. package/dist/types/src/util/render-byline.d.ts +4 -0
  124. package/dist/types/src/util/render-byline.d.ts.map +1 -0
  125. package/dist/types/tsconfig.tsbuildinfo +1 -1
  126. package/package.json +105 -70
  127. package/src/TranscriptionPlugin.tsx +40 -60
  128. package/src/blueprints/index.ts +5 -0
  129. package/src/blueprints/transcription-blueprint.ts +30 -0
  130. package/src/capabilities/blueprint-definition.ts +10 -24
  131. package/src/capabilities/index.ts +9 -7
  132. package/src/capabilities/operation-handler.ts +16 -0
  133. package/src/capabilities/react-surface.tsx +21 -13
  134. package/src/capabilities/transcriber.ts +51 -43
  135. package/src/components/{Transcript/Transcript.stories.tsx → Transcription/Transcription.stories.tsx} +49 -45
  136. package/src/components/Transcription/Transcription.tsx +65 -0
  137. package/src/components/{Transcript → Transcription}/index.ts +1 -1
  138. package/src/components/{Transcript/transcript-extension.ts → Transcription/transcription-extension.ts} +13 -9
  139. package/src/components/index.ts +1 -6
  140. package/src/components/stories/FileTranscription.stories.tsx +30 -36
  141. package/src/components/stories/KeyWordRecognition.stories.tsx +6 -6
  142. package/src/components/stories/MicrophoneTranscription.stories.tsx +53 -74
  143. package/src/components/stories/TranscriptionStory.tsx +7 -9
  144. package/src/containers/TranscriptionContainer/TranscriptionContainer.tsx +32 -0
  145. package/src/containers/TranscriptionContainer/index.ts +7 -0
  146. package/src/containers/index.ts +7 -0
  147. package/src/hooks/useQueueModelAdapter.ts +1 -1
  148. package/src/hooks/useTranscriber.ts +8 -3
  149. package/src/hooks/useVoiceInput.ts +2 -2
  150. package/src/index.ts +1 -1
  151. package/src/meta.ts +3 -3
  152. package/src/model/model.test.ts +20 -14
  153. package/src/operations/create.ts +22 -0
  154. package/src/operations/definitions.ts +102 -0
  155. package/src/operations/index.ts +13 -0
  156. package/src/operations/open.ts +31 -0
  157. package/src/{functions → operations}/summarize.ts +41 -47
  158. package/src/segments-normalization/message-normalizer.ts +18 -13
  159. package/src/segments-normalization/normalization.test.ts +6 -11
  160. package/src/segments-normalization/normalization.ts +34 -72
  161. package/src/segments-normalization/utils.ts +2 -2
  162. package/src/testing/testing.ts +28 -28
  163. package/src/transcriber/media-stream-recorder.ts +3 -3
  164. package/src/transcriber/transcriber.browser.test.ts +4 -4
  165. package/src/transcriber/transcriber.ts +7 -7
  166. package/src/transcriber/transcription-manager.ts +21 -15
  167. package/src/translations.ts +7 -7
  168. package/src/{capabilities → types}/capabilities.ts +10 -10
  169. package/src/types/index.ts +1 -2
  170. package/src/util/index.ts +1 -0
  171. package/src/util/render-byline.ts +33 -0
  172. package/dist/lib/browser/TranscriptContainer-2GSL2XB5.mjs +0 -11
  173. package/dist/lib/browser/blueprint-definition-UAAJYVLZ.mjs +0 -150
  174. package/dist/lib/browser/blueprint-definition-UAAJYVLZ.mjs.map +0 -7
  175. package/dist/lib/browser/chunk-3MKZ2MNQ.mjs +0 -16
  176. package/dist/lib/browser/chunk-3MKZ2MNQ.mjs.map +0 -7
  177. package/dist/lib/browser/chunk-535OJKFO.mjs +0 -8
  178. package/dist/lib/browser/chunk-535OJKFO.mjs.map +0 -7
  179. package/dist/lib/browser/chunk-7DR6HZEF.mjs +0 -732
  180. package/dist/lib/browser/chunk-7DR6HZEF.mjs.map +0 -7
  181. package/dist/lib/browser/chunk-VBUIO677.mjs +0 -29
  182. package/dist/lib/browser/chunk-VBUIO677.mjs.map +0 -7
  183. package/dist/lib/browser/chunk-W7WKZTM4.mjs +0 -63
  184. package/dist/lib/browser/chunk-W7WKZTM4.mjs.map +0 -7
  185. package/dist/lib/browser/chunk-WH36ENNE.mjs +0 -466
  186. package/dist/lib/browser/chunk-WH36ENNE.mjs.map +0 -7
  187. package/dist/lib/browser/intent-resolver-ZTKTEAQX.mjs +0 -25
  188. package/dist/lib/browser/intent-resolver-ZTKTEAQX.mjs.map +0 -7
  189. package/dist/lib/browser/react-surface-KA32A72I.mjs +0 -34
  190. package/dist/lib/browser/react-surface-KA32A72I.mjs.map +0 -7
  191. package/dist/lib/browser/transcriber-LWOLYQHC.mjs +0 -56
  192. package/dist/lib/browser/transcriber-LWOLYQHC.mjs.map +0 -7
  193. package/dist/lib/node-esm/TranscriptContainer-GRLDCESB.mjs +0 -12
  194. package/dist/lib/node-esm/blueprint-definition-Z3LTZ3ID.mjs +0 -151
  195. package/dist/lib/node-esm/blueprint-definition-Z3LTZ3ID.mjs.map +0 -7
  196. package/dist/lib/node-esm/chunk-K4AZOB5Y.mjs +0 -733
  197. package/dist/lib/node-esm/chunk-K4AZOB5Y.mjs.map +0 -7
  198. package/dist/lib/node-esm/chunk-OLMSTF3M.mjs +0 -64
  199. package/dist/lib/node-esm/chunk-OLMSTF3M.mjs.map +0 -7
  200. package/dist/lib/node-esm/chunk-Q6WD7L2J.mjs +0 -10
  201. package/dist/lib/node-esm/chunk-Q6WD7L2J.mjs.map +0 -7
  202. package/dist/lib/node-esm/chunk-SWUVPFKR.mjs +0 -17
  203. package/dist/lib/node-esm/chunk-SWUVPFKR.mjs.map +0 -7
  204. package/dist/lib/node-esm/chunk-YFN4FJFK.mjs +0 -467
  205. package/dist/lib/node-esm/chunk-YFN4FJFK.mjs.map +0 -7
  206. package/dist/lib/node-esm/chunk-YVNQN2J6.mjs +0 -30
  207. package/dist/lib/node-esm/chunk-YVNQN2J6.mjs.map +0 -7
  208. package/dist/lib/node-esm/intent-resolver-55WH2GY6.mjs +0 -26
  209. package/dist/lib/node-esm/intent-resolver-55WH2GY6.mjs.map +0 -7
  210. package/dist/lib/node-esm/react-surface-GU7LW2JO.mjs +0 -35
  211. package/dist/lib/node-esm/react-surface-GU7LW2JO.mjs.map +0 -7
  212. package/dist/lib/node-esm/transcriber-UGB7ECX6.mjs +0 -57
  213. package/dist/lib/node-esm/transcriber-UGB7ECX6.mjs.map +0 -7
  214. package/dist/types/src/capabilities/capabilities.d.ts +0 -17
  215. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  216. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  217. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  218. package/dist/types/src/components/Transcript/Transcript.d.ts +0 -20
  219. package/dist/types/src/components/Transcript/Transcript.d.ts.map +0 -1
  220. package/dist/types/src/components/Transcript/Transcript.stories.d.ts +0 -39
  221. package/dist/types/src/components/Transcript/Transcript.stories.d.ts.map +0 -1
  222. package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts +0 -28
  223. package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts.map +0 -1
  224. package/dist/types/src/components/Transcript/index.d.ts +0 -2
  225. package/dist/types/src/components/Transcript/index.d.ts.map +0 -1
  226. package/dist/types/src/components/Transcript/transcript-extension.d.ts +0 -15
  227. package/dist/types/src/components/Transcript/transcript-extension.d.ts.map +0 -1
  228. package/dist/types/src/components/TranscriptContainer.d.ts +0 -9
  229. package/dist/types/src/components/TranscriptContainer.d.ts.map +0 -1
  230. package/dist/types/src/functions/index.d.ts +0 -3
  231. package/dist/types/src/functions/index.d.ts.map +0 -1
  232. package/dist/types/src/functions/open.d.ts +0 -7
  233. package/dist/types/src/functions/open.d.ts.map +0 -1
  234. package/dist/types/src/functions/summarize.d.ts +0 -11
  235. package/dist/types/src/functions/summarize.d.ts.map +0 -1
  236. package/dist/types/src/types/Transcript.d.ts +0 -30
  237. package/dist/types/src/types/Transcript.d.ts.map +0 -1
  238. package/dist/types/src/types/TranscriptAction.d.ts +0 -23
  239. package/dist/types/src/types/TranscriptAction.d.ts.map +0 -1
  240. package/src/capabilities/intent-resolver.ts +0 -18
  241. package/src/components/Transcript/Transcript.tsx +0 -93
  242. package/src/components/Transcript/deprecated/OldTranscript.tsx +0 -260
  243. package/src/components/TranscriptContainer.tsx +0 -36
  244. package/src/functions/index.ts +0 -6
  245. package/src/functions/open.ts +0 -39
  246. package/src/types/Transcript.ts +0 -44
  247. package/src/types/TranscriptAction.ts +0 -24
  248. /package/dist/lib/browser/{TranscriptContainer-2GSL2XB5.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
  249. /package/dist/lib/node-esm/{TranscriptContainer-GRLDCESB.mjs.map → chunk-HSLMI22Q.mjs.map} +0 -0
@@ -1,260 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { intervalToDuration } from 'date-fns/intervalToDuration';
6
- import * as Schema from 'effect/Schema';
7
- import { yieldOrContinue } from 'main-thread-scheduling';
8
- import React, { type FC, type WheelEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react';
9
- import { type OnResizeCallback, useResizeDetector } from 'react-resize-detector';
10
-
11
- import { Type } from '@dxos/echo';
12
- import { IconButton, type ThemedClassName, useTranslation } from '@dxos/react-ui';
13
- import { useAttention } from '@dxos/react-ui-attention';
14
- import {
15
- type DxGridAxisMeta,
16
- type DxGridCellValue,
17
- type DxGridElement,
18
- type DxGridPlaneCells,
19
- Grid,
20
- toPlaneCellIndex,
21
- } from '@dxos/react-ui-grid';
22
- import { mx } from '@dxos/react-ui-theme';
23
-
24
- import { meta } from '../../../meta';
25
-
26
- /**
27
- * Transcription fragment.
28
- */
29
- const TranscriptSegment = Schema.Struct({
30
- // TODO(burdon): TS from service is not Unix TS (x1000).
31
- started: Schema.String,
32
- text: Schema.String,
33
- });
34
-
35
- type TranscriptSegment = Schema.Schema.Type<typeof TranscriptSegment>;
36
-
37
- /**
38
- * Transcription block (from single speaker).
39
- */
40
- const TranscriptBlock = Schema.Struct({
41
- id: Schema.String,
42
- authorName: Schema.optional(Schema.String), // TODO(burdon): Replace with identityDid.
43
- authorHue: Schema.optional(Schema.String), // TOOD(burdon): Remove.
44
- segments: Schema.Array(TranscriptSegment),
45
- }).pipe(
46
- Type.Obj({
47
- typename: 'dxos.org/type/TranscriptBlock',
48
- version: '0.1.0',
49
- }),
50
- );
51
-
52
- type TranscriptBlock = Schema.Schema.Type<typeof TranscriptBlock>;
53
-
54
- // TODO(burdon): Actions (e.g., mark, summarize, translate, label, delete).
55
-
56
- const lineHeight = 20;
57
- const cellSpacing = 8 + 2;
58
- const timestampColumnWidth = 68;
59
-
60
- const authorClasses = 'font-medium text-base leading-[20px]';
61
- const timestampClasses = 'text-xs leading-[20px] text-description pie-0 tabular-nums';
62
- const segmentTextClasses = 'text-sm whitespace-normal hyphens-auto';
63
- const measureClasses = mx(
64
- // NOTE(thure): The `inline-start` value must equal `timestampColumnWidth` plus grid’s gap (1px)
65
- 'absolute inline-start-[69px] inline-end-0 invisible z-[-1] border',
66
- 'pli-[--dx-grid-cell-padding-inline] plb-[--dx-grid-cell-padding-block] leading-[20px]',
67
- segmentTextClasses,
68
- );
69
-
70
- const rowDefault = {
71
- grid: { size: lineHeight + cellSpacing },
72
- };
73
-
74
- type QueueRows = [number, number][];
75
-
76
- const mapTranscriptQueue = (blocks?: TranscriptBlock[]): QueueRows => {
77
- if (!blocks || !Array.isArray(blocks) || blocks.length === 0) {
78
- return [];
79
- } else {
80
- return blocks.flatMap((block, blockIndex) => {
81
- return [
82
- [blockIndex, -1],
83
- ...block.segments.map((segment, segmentIndex) => {
84
- return [blockIndex, segmentIndex] as [number, number];
85
- }),
86
- ];
87
- });
88
- }
89
- };
90
-
91
- const pad = (n = 0) => String(n).padStart(2, '0');
92
-
93
- const formatTimestamp = (start: Date, end: Date) => {
94
- const { hours, minutes, seconds } = intervalToDuration({ start, end });
95
- return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`;
96
- };
97
-
98
- const measureRows = async (
99
- host: HTMLDivElement,
100
- blocks: TranscriptBlock[],
101
- queueMap: QueueRows,
102
- signal: AbortSignal,
103
- ) => {
104
- const result: DxGridAxisMeta = { grid: {} };
105
- for (let row = 0; row < queueMap.length; row++) {
106
- await yieldOrContinue('smooth', signal);
107
- const [blockIndex, segmentIndex] = queueMap[row];
108
- if (segmentIndex < 0) {
109
- result.grid[row] = { size: lineHeight + cellSpacing };
110
- } else {
111
- host.textContent = blocks[blockIndex]!.segments[segmentIndex]!.text;
112
- result.grid[row] = { size: host.offsetHeight };
113
- }
114
- }
115
- return result;
116
- };
117
-
118
- export type TranscriptViewProps = ThemedClassName<{
119
- blocks?: TranscriptBlock[];
120
- attendableId?: string;
121
- ignoreAttention?: boolean;
122
- }>;
123
-
124
- /**
125
- * @@deprecated
126
- */
127
- export const Transcript: FC<TranscriptViewProps> = ({ classNames, blocks, attendableId, ignoreAttention }) => {
128
- const { t } = useTranslation(meta.id);
129
- const [dxGrid, setDxGrid] = useState<DxGridElement | null>(null);
130
- const [rows, setRows] = useState<DxGridAxisMeta | undefined>(undefined);
131
- const [columns, setColumns] = useState<DxGridAxisMeta | undefined>(undefined);
132
-
133
- const queueMap = useMemo(() => mapTranscriptQueue(blocks), [blocks]);
134
-
135
- const { hasAttention } = useAttention(attendableId);
136
- const [autoScroll, setAutoScroll] = useState(true);
137
- const handleWheel = useCallback(
138
- (event: WheelEvent) => {
139
- setAutoScroll(false);
140
- if (!ignoreAttention && !hasAttention) {
141
- event.stopPropagation();
142
- }
143
- },
144
- [hasAttention, ignoreAttention],
145
- );
146
-
147
- const abortControllerRef = useRef<AbortController>(null);
148
-
149
- const handleResize = useCallback(
150
- async ({ entry }: { entry: { target: HTMLDivElement } | null }) => {
151
- if (entry?.target && Array.isArray(blocks) && blocks[0] && queueMap) {
152
- abortControllerRef.current?.abort();
153
- abortControllerRef.current = new AbortController();
154
- setColumns({ grid: { 0: { size: timestampColumnWidth }, 1: { size: entry.target.offsetWidth } } });
155
- return measureRows(entry.target, blocks, queueMap, abortControllerRef.current.signal)
156
- .then(setRows)
157
- .catch(() => {
158
- // Aborted mid-measurement by new size.
159
- });
160
- }
161
- },
162
- [blocks, queueMap],
163
- );
164
-
165
- const { width, ref: measureRef } = useResizeDetector({
166
- onResize: handleResize as OnResizeCallback,
167
- refreshOptions: { leading: true },
168
- });
169
-
170
- useEffect(() => {
171
- if (queueMap.length !== Object.keys(rows?.grid ?? {}).length) {
172
- void handleResize({ entry: { target: measureRef.current } }).then(() => {
173
- if (autoScroll) {
174
- // TODO(thure): Implement a deterministic way to do this when `rows` has fully settled and grid has a new `maxPosBlock`.
175
- setTimeout(() => dxGrid?.scrollToEndRow(), 50);
176
- }
177
- });
178
- }
179
- }, [blocks, queueMap, width, autoScroll]);
180
-
181
- useEffect(() => {
182
- if (dxGrid && Array.isArray(blocks) && blocks[0]) {
183
- const transcriptStart = blocks[0]!.segments[0]!.started;
184
- dxGrid.getCells = (range, plane) => {
185
- switch (plane) {
186
- case 'grid': {
187
- const cells: DxGridPlaneCells = {};
188
- for (let row = range.start.row; row <= range.end.row && row < queueMap.length; row++) {
189
- const [blockIndex, segmentIndex] = queueMap[row];
190
-
191
- cells[toPlaneCellIndex({ col: 0, row })] = {
192
- readonly: true,
193
- value:
194
- segmentIndex < 0
195
- ? formatTimestamp(
196
- new Date(transcriptStart),
197
- new Date(blocks[blockIndex]!.segments[Math.max(0, segmentIndex)]!.started),
198
- )
199
- : '',
200
- className: timestampClasses,
201
- } satisfies DxGridCellValue;
202
-
203
- cells[toPlaneCellIndex({ col: 1, row })] = (
204
- segmentIndex < 0
205
- ? {
206
- readonly: true,
207
- accessoryHtml: `<span data-hue="${blocks[blockIndex]!.authorHue}" class="dx-text-hue">${blocks[blockIndex]!.authorName}</span>`,
208
- className: authorClasses,
209
- }
210
- : {
211
- readonly: true,
212
- value: blocks[blockIndex]!.segments[segmentIndex]!.text,
213
- className: segmentTextClasses,
214
- }
215
- ) satisfies DxGridCellValue;
216
- }
217
- return cells;
218
- }
219
- default:
220
- return {};
221
- }
222
- };
223
- }
224
- }, [dxGrid, blocks]);
225
-
226
- const handleScrollToEnd = useCallback(() => {
227
- setAutoScroll(true);
228
- dxGrid?.scrollToEndRow();
229
- }, [dxGrid, autoScroll]);
230
-
231
- return (
232
- <div role='none' className={mx('relative min-bs-0', classNames)}>
233
- <Grid.Root id={`${attendableId}--transcript`}>
234
- <Grid.Content
235
- limitColumns={2}
236
- limitRows={queueMap.length}
237
- columns={columns}
238
- rows={rows}
239
- rowDefault={rowDefault}
240
- onWheel={handleWheel}
241
- className='[--dx-grid-base:var(--dx-baseSurface)] [--dx-grid-lines:var(--dx-baseSurface)] [&_.dx-grid]:min-bs-0 [&_.dx-grid]:min-is-0 [&_.dx-grid]:select-auto'
242
- ref={setDxGrid}
243
- />
244
- </Grid.Root>
245
- <div role='none' {...{ inert: true }} aria-hidden className={measureClasses} ref={measureRef} />
246
- <IconButton
247
- icon='ph--arrow-line-down--regular'
248
- iconOnly
249
- label={t('scroll to end label')}
250
- tooltipSide='left'
251
- data-state={autoScroll ? 'invisible' : 'visible'}
252
- classNames={[
253
- 'absolute inline-end-2 block-end-2 opacity-0 pointer-events-none',
254
- 'data-[state="visible"]:pointer-events-auto data-[state="visible"]:opacity-100 transition-opacity',
255
- ]}
256
- onClick={handleScrollToEnd}
257
- />
258
- </div>
259
- );
260
- };
@@ -1,36 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
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
- import { type DataType } from '@dxos/schema';
11
-
12
- import { useQueueModelAdapter } from '../hooks';
13
- import { type Transcript } from '../types';
14
-
15
- import { TranscriptView, renderByline } from './Transcript';
16
-
17
- export type TranscriptionContainerProps = {
18
- role: string;
19
- transcript: Transcript.Transcript;
20
- };
21
-
22
- export const TranscriptionContainer = ({ transcript }: TranscriptionContainerProps) => {
23
- const attendableId = fullyQualifiedId(transcript);
24
- const space = getSpace(transcript);
25
- const members = useMembers(space?.key).map((member) => member.identity);
26
- const queue = useQueue<DataType.Message>(transcript.queue.dxn, { pollInterval: 1_000 });
27
- const model = useQueueModelAdapter(renderByline(members), queue);
28
-
29
- return (
30
- <StackItem.Content>
31
- <TranscriptView attendableId={attendableId} space={space} model={model} transcript={transcript} />
32
- </StackItem.Content>
33
- );
34
- };
35
-
36
- export default TranscriptionContainer;
@@ -1,6 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- export { default as open } from './open';
6
- export { default as summarize } from './summarize';
@@ -1,39 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import * as Effect from 'effect/Effect';
6
- import * as Schema from 'effect/Schema';
7
-
8
- import { ArtifactId } from '@dxos/assistant';
9
- import { Obj } from '@dxos/echo';
10
- import { DatabaseService, QueueService, defineFunction } from '@dxos/functions';
11
- import { DataType } from '@dxos/schema';
12
-
13
- import { renderByline } from '../components';
14
- import { Transcript } from '../types';
15
-
16
- export default defineFunction({
17
- key: 'dxos.org/function/transcription/open',
18
- name: 'Open',
19
- description: 'Opens and reads the contents of a transcription object.',
20
- inputSchema: Schema.Struct({
21
- id: ArtifactId.annotations({
22
- description: 'The ID of the transcription object.',
23
- }),
24
- }),
25
- outputSchema: Schema.Struct({
26
- content: Schema.String,
27
- }),
28
- handler: Effect.fn(function* ({ data: { id } }) {
29
- const transcript = yield* DatabaseService.resolve(ArtifactId.toDXN(id), Transcript.Transcript);
30
- const { dxn } = yield* Effect.promise(() => transcript.queue.load());
31
- const queue = yield* QueueService.getQueue(dxn);
32
- yield* Effect.promise(() => queue?.queryObjects());
33
- const content = queue?.objects
34
- .filter((message) => Obj.instanceOf(DataType.Message, message))
35
- .flatMap((message, index) => renderByline([])(message, index))
36
- .join('\n\n');
37
- return { content };
38
- }),
39
- });
@@ -1,44 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import * as Schema from 'effect/Schema';
6
-
7
- import { Queue } from '@dxos/client/echo';
8
- import { type DXN, Obj, Ref, Type } from '@dxos/echo';
9
-
10
- /**
11
- * Root transcript object created when the user starts a transcription.
12
- */
13
- export const Transcript = Schema.Struct({
14
- // TODO(wittjosiah): Remove?
15
- // TODO(burdon): Use Date or string?
16
- started: Schema.optional(Schema.String),
17
- ended: Schema.optional(Schema.String),
18
-
19
- /**
20
- * Queue containing TranscriptBlock objects.
21
- */
22
- queue: Type.Ref(Queue),
23
- }).pipe(
24
- Type.Obj({
25
- typename: 'dxos.org/type/Transcript',
26
- version: '0.1.0',
27
- }),
28
- );
29
-
30
- export type Transcript = Schema.Schema.Type<typeof Transcript>;
31
-
32
- // TODO(burdon): Do these need to be kept in sync with EDGE?
33
-
34
- /**
35
- * First message in queue.
36
- * Contains metadata for the recording and transcript.
37
- */
38
- const TranscriptHeader = Schema.Struct({
39
- started: Schema.optional(Schema.String),
40
- });
41
-
42
- export type TranscriptHeader = Schema.Schema.Type<typeof TranscriptHeader>;
43
-
44
- export const makeTranscript = (queueDxn: DXN) => Obj.make(Transcript, { queue: Ref.fromDXN(queueDxn) });
@@ -1,24 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import * as Schema from 'effect/Schema';
6
-
7
- import { SpaceSchema } from '@dxos/client/echo';
8
-
9
- import { meta } from '../meta';
10
-
11
- import { Transcript } from './Transcript';
12
-
13
- /**
14
- * Endpoint to the calls service.
15
- */
16
- export class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {
17
- input: Schema.Struct({
18
- name: Schema.optional(Schema.String),
19
- space: SpaceSchema,
20
- }),
21
- output: Schema.Struct({
22
- object: Transcript,
23
- }),
24
- }) {}