@dxos/plugin-transcription 0.8.4-main.bc674ce → 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.
- package/dist/lib/browser/blueprints/index.mjs +27 -5
- package/dist/lib/browser/blueprints/index.mjs.map +4 -4
- package/dist/lib/browser/chunk-RIUSFL62.mjs +112 -0
- package/dist/lib/browser/chunk-RIUSFL62.mjs.map +7 -0
- package/dist/lib/browser/chunk-YXU2ZO6W.mjs +17 -0
- package/dist/lib/browser/chunk-YXU2ZO6W.mjs.map +7 -0
- package/dist/lib/browser/create-IZPB7VZW.mjs +19 -0
- package/dist/lib/browser/create-IZPB7VZW.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1154 -60
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/open-SN5O5I6X.mjs +29 -0
- package/dist/lib/browser/open-SN5O5I6X.mjs.map +7 -0
- package/dist/lib/browser/operations/index.mjs +13 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/summarize-5MZENAU5.mjs +71 -0
- package/dist/lib/browser/summarize-5MZENAU5.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -5
- package/dist/lib/node-esm/blueprints/index.mjs +27 -5
- package/dist/lib/node-esm/blueprints/index.mjs.map +4 -4
- package/dist/lib/node-esm/chunk-3GSFEN4L.mjs +113 -0
- package/dist/lib/node-esm/chunk-3GSFEN4L.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-BR2R6PCT.mjs +19 -0
- package/dist/lib/node-esm/chunk-BR2R6PCT.mjs.map +7 -0
- package/dist/lib/node-esm/create-TQDGXQBL.mjs +20 -0
- package/dist/lib/node-esm/create-TQDGXQBL.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1154 -60
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/open-4GAAWWKJ.mjs +30 -0
- package/dist/lib/node-esm/open-4GAAWWKJ.mjs.map +7 -0
- package/dist/lib/node-esm/operations/index.mjs +14 -0
- package/dist/lib/node-esm/operations/index.mjs.map +7 -0
- package/dist/lib/node-esm/summarize-RVOSRHEC.mjs +72 -0
- package/dist/lib/node-esm/summarize-RVOSRHEC.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -5
- package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +1 -1
- package/dist/types/src/blueprints/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/transcription-blueprint.d.ts +3 -20
- package/dist/types/src/blueprints/transcription-blueprint.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +6 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -4
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/transcriber.d.ts +9 -0
- package/dist/types/src/capabilities/transcriber.d.ts.map +1 -0
- package/dist/types/src/components/{Transcript/Transcript.d.ts → Transcription/Transcription.d.ts} +10 -5
- package/dist/types/src/components/Transcription/Transcription.d.ts.map +1 -0
- package/dist/types/src/components/{Transcript/Transcript.stories.d.ts → Transcription/Transcription.stories.d.ts} +12 -12
- package/dist/types/src/components/Transcription/Transcription.stories.d.ts.map +1 -0
- package/dist/types/src/components/Transcription/index.d.ts +2 -0
- package/dist/types/src/components/Transcription/index.d.ts.map +1 -0
- package/dist/types/src/components/{Transcript/transcript-extension.d.ts → Transcription/transcription-extension.d.ts} +3 -3
- package/dist/types/src/components/Transcription/transcription-extension.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts +2 -2
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts +2 -2
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/TranscriptionStory.d.ts.map +1 -1
- package/dist/types/src/containers/TranscriptionContainer/TranscriptionContainer.d.ts +6 -0
- package/dist/types/src/containers/TranscriptionContainer/TranscriptionContainer.d.ts.map +1 -0
- package/dist/types/src/containers/TranscriptionContainer/index.d.ts +3 -0
- package/dist/types/src/containers/TranscriptionContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +3 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useTranscriber.d.ts +1 -1
- package/dist/types/src/hooks/useTranscriber.d.ts.map +1 -1
- package/dist/types/src/operations/create.d.ts +5 -0
- package/dist/types/src/operations/create.d.ts.map +1 -0
- package/dist/types/src/operations/definitions.d.ts +905 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/open.d.ts +5 -0
- package/dist/types/src/operations/open.d.ts.map +1 -0
- package/dist/types/src/operations/summarize.d.ts +8 -0
- package/dist/types/src/operations/summarize.d.ts.map +1 -0
- package/dist/types/src/segments-normalization/normalization.d.ts +41 -200
- package/dist/types/src/segments-normalization/normalization.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +7 -7
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +0 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +86 -65
- package/src/TranscriptionPlugin.tsx +17 -13
- package/src/blueprints/index.ts +1 -1
- package/src/blueprints/transcription-blueprint.ts +13 -8
- package/src/capabilities/blueprint-definition.ts +17 -0
- package/src/capabilities/index.ts +10 -4
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +30 -0
- package/src/capabilities/{transcriber/transcriber.ts → transcriber.ts} +6 -6
- package/src/components/{Transcript/Transcript.stories.tsx → Transcription/Transcription.stories.tsx} +17 -14
- package/src/components/Transcription/Transcription.tsx +65 -0
- package/src/components/{Transcript → Transcription}/index.ts +1 -1
- package/src/components/{Transcript/transcript-extension.ts → Transcription/transcription-extension.ts} +4 -4
- package/src/components/index.ts +1 -6
- package/src/components/stories/FileTranscription.stories.tsx +9 -11
- package/src/components/stories/KeyWordRecognition.stories.tsx +6 -6
- package/src/components/stories/MicrophoneTranscription.stories.tsx +13 -31
- package/src/components/stories/TranscriptionStory.tsx +7 -5
- package/src/containers/TranscriptionContainer/TranscriptionContainer.tsx +32 -0
- package/src/containers/TranscriptionContainer/index.ts +7 -0
- package/src/containers/index.ts +7 -0
- package/src/hooks/useTranscriber.ts +2 -2
- package/src/meta.ts +1 -1
- package/src/model/model.test.ts +6 -6
- package/src/operations/create.ts +22 -0
- package/src/operations/definitions.ts +102 -0
- package/src/operations/index.ts +13 -0
- package/src/operations/open.ts +31 -0
- package/src/{functions → operations}/summarize.ts +41 -47
- package/src/segments-normalization/normalization.test.ts +1 -1
- package/src/segments-normalization/normalization.ts +33 -71
- package/src/testing/testing.ts +1 -11
- package/src/transcriber/transcriber.ts +1 -1
- package/src/translations.ts +7 -7
- package/src/types/capabilities.ts +3 -3
- package/src/types/index.ts +0 -2
- package/dist/lib/browser/TranscriptContainer-6EHKWVS4.mjs +0 -12
- package/dist/lib/browser/TranscriptContainer-6EHKWVS4.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-FTRNMLJZ.mjs +0 -18
- package/dist/lib/browser/blueprint-definition-FTRNMLJZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-ICM7JRCO.mjs +0 -698
- package/dist/lib/browser/chunk-ICM7JRCO.mjs.map +0 -7
- package/dist/lib/browser/chunk-Q5OC3WVG.mjs +0 -72
- package/dist/lib/browser/chunk-Q5OC3WVG.mjs.map +0 -7
- package/dist/lib/browser/chunk-SYGEFDWO.mjs +0 -8
- package/dist/lib/browser/chunk-SYGEFDWO.mjs.map +0 -7
- package/dist/lib/browser/chunk-TKFU53OZ.mjs +0 -460
- package/dist/lib/browser/chunk-TKFU53OZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZZF7ICVM.mjs +0 -150
- package/dist/lib/browser/chunk-ZZF7ICVM.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-ZUWTU7C5.mjs +0 -22
- package/dist/lib/browser/operation-resolver-ZUWTU7C5.mjs.map +0 -7
- package/dist/lib/browser/react-surface-ZXH5267I.mjs +0 -34
- package/dist/lib/browser/react-surface-ZXH5267I.mjs.map +0 -7
- package/dist/lib/browser/transcriber-EZZTUCPE.mjs +0 -60
- package/dist/lib/browser/transcriber-EZZTUCPE.mjs.map +0 -7
- package/dist/lib/node-esm/TranscriptContainer-5YT5W73I.mjs +0 -13
- package/dist/lib/node-esm/TranscriptContainer-5YT5W73I.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-IOX35YUX.mjs +0 -19
- package/dist/lib/node-esm/blueprint-definition-IOX35YUX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4BFY6P2D.mjs +0 -73
- package/dist/lib/node-esm/chunk-4BFY6P2D.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BX2AB7S7.mjs +0 -699
- package/dist/lib/node-esm/chunk-BX2AB7S7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CWP22IHV.mjs +0 -151
- package/dist/lib/node-esm/chunk-CWP22IHV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EPC27WWV.mjs +0 -461
- package/dist/lib/node-esm/chunk-EPC27WWV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GVAVEVZ6.mjs +0 -10
- package/dist/lib/node-esm/chunk-GVAVEVZ6.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-Z72B4H2Q.mjs +0 -23
- package/dist/lib/node-esm/operation-resolver-Z72B4H2Q.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-6GUBZX2V.mjs +0 -35
- package/dist/lib/node-esm/react-surface-6GUBZX2V.mjs.map +0 -7
- package/dist/lib/node-esm/transcriber-RGW3YYT4.mjs +0 -61
- package/dist/lib/node-esm/transcriber-RGW3YYT4.mjs.map +0 -7
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +0 -9
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +0 -3
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-handler/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-handler/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts +0 -5
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/transcriber/index.d.ts +0 -3
- package/dist/types/src/capabilities/transcriber/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/transcriber/transcriber.d.ts +0 -9
- package/dist/types/src/capabilities/transcriber/transcriber.d.ts.map +0 -1
- package/dist/types/src/components/Transcript/Transcript.d.ts.map +0 -1
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts.map +0 -1
- package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts +0 -28
- package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts.map +0 -1
- package/dist/types/src/components/Transcript/index.d.ts +0 -2
- package/dist/types/src/components/Transcript/index.d.ts.map +0 -1
- package/dist/types/src/components/Transcript/transcript-extension.d.ts.map +0 -1
- package/dist/types/src/components/TranscriptContainer.d.ts +0 -7
- package/dist/types/src/components/TranscriptContainer.d.ts.map +0 -1
- package/dist/types/src/functions/index.d.ts +0 -3
- package/dist/types/src/functions/index.d.ts.map +0 -1
- package/dist/types/src/functions/open.d.ts +0 -7
- package/dist/types/src/functions/open.d.ts.map +0 -1
- package/dist/types/src/functions/summarize.d.ts +0 -11
- package/dist/types/src/functions/summarize.d.ts.map +0 -1
- package/dist/types/src/types/TranscriptAction.d.ts +0 -25
- package/dist/types/src/types/TranscriptAction.d.ts.map +0 -1
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +0 -23
- package/src/capabilities/blueprint-definition/index.ts +0 -7
- package/src/capabilities/operation-handler/index.ts +0 -7
- package/src/capabilities/operation-handler/operation-handler.ts +0 -25
- package/src/capabilities/operation-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -25
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/react-surface/react-surface.tsx +0 -27
- package/src/capabilities/transcriber/index.ts +0 -7
- package/src/components/Transcript/Transcript.tsx +0 -66
- package/src/components/Transcript/deprecated/OldTranscript.tsx +0 -260
- package/src/components/TranscriptContainer.tsx +0 -34
- package/src/functions/index.ts +0 -6
- package/src/functions/open.ts +0 -39
- package/src/types/TranscriptAction.ts +0 -32
|
@@ -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/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.object({
|
|
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,34 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import { type SurfaceComponentProps } from '@dxos/app-framework/react';
|
|
8
|
-
import { Obj } from '@dxos/echo';
|
|
9
|
-
import { useMembers, useQueue } from '@dxos/react-client/echo';
|
|
10
|
-
import { Layout } from '@dxos/react-ui-mosaic';
|
|
11
|
-
import { type Message, type Transcript } from '@dxos/types';
|
|
12
|
-
|
|
13
|
-
import { useQueueModelAdapter } from '../hooks';
|
|
14
|
-
import { renderByline } from '../util';
|
|
15
|
-
|
|
16
|
-
import { TranscriptView } from './Transcript';
|
|
17
|
-
|
|
18
|
-
export type TranscriptionContainerProps = SurfaceComponentProps<Transcript.Transcript>;
|
|
19
|
-
|
|
20
|
-
export const TranscriptionContainer = ({ role, subject: transcript }: TranscriptionContainerProps) => {
|
|
21
|
-
const attendableId = Obj.getDXN(transcript).toString();
|
|
22
|
-
const db = Obj.getDatabase(transcript);
|
|
23
|
-
const members = useMembers(db?.spaceId).map((member) => member.identity);
|
|
24
|
-
const queue = useQueue<Message.Message>(transcript.queue.dxn, { pollInterval: 1_000 });
|
|
25
|
-
const model = useQueueModelAdapter(renderByline(members), queue);
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<Layout.Main role={role}>
|
|
29
|
-
<TranscriptView attendableId={attendableId} model={model} transcript={transcript} />
|
|
30
|
-
</Layout.Main>
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export default TranscriptionContainer;
|
package/src/functions/index.ts
DELETED
package/src/functions/open.ts
DELETED
|
@@ -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 { Database } from '@dxos/echo';
|
|
11
|
-
import { QueueService, defineFunction } from '@dxos/functions';
|
|
12
|
-
import { Message, Transcript } from '@dxos/types';
|
|
13
|
-
|
|
14
|
-
import { renderByline } from '../util';
|
|
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* Database.Service.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(Message.Message, message))
|
|
35
|
-
.flatMap((message, index) => renderByline([])(message, index))
|
|
36
|
-
.join('\n\n');
|
|
37
|
-
return { content };
|
|
38
|
-
}),
|
|
39
|
-
});
|
|
@@ -1,32 +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
|
-
import { Operation } from '@dxos/operation';
|
|
9
|
-
import { Transcript } from '@dxos/types';
|
|
10
|
-
|
|
11
|
-
import { meta } from '../meta';
|
|
12
|
-
|
|
13
|
-
//
|
|
14
|
-
// Operations
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
const TRANSCRIPT_OPERATION = `${meta.id}/operation`;
|
|
18
|
-
|
|
19
|
-
export namespace TranscriptOperation {
|
|
20
|
-
export const Create = Operation.make({
|
|
21
|
-
meta: { key: `${TRANSCRIPT_OPERATION}/create`, name: 'Create Transcript' },
|
|
22
|
-
schema: {
|
|
23
|
-
input: Schema.Struct({
|
|
24
|
-
name: Schema.optional(Schema.String),
|
|
25
|
-
space: SpaceSchema,
|
|
26
|
-
}),
|
|
27
|
-
output: Schema.Struct({
|
|
28
|
-
object: Transcript.Transcript,
|
|
29
|
-
}),
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
}
|