@dxos/plugin-transcription 0.8.4-main.fcfe5033a5 → 0.8.4-staging.60fe92afc8
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/LICENSE +102 -5
- package/PLUGIN.mdl +401 -0
- package/README.md +1 -1
- package/dist/lib/neutral/TranscriptionArticle-L6XANBH5.mjs +54 -0
- package/dist/lib/neutral/TranscriptionArticle-L6XANBH5.mjs.map +7 -0
- package/dist/lib/neutral/TranscriptionPlugin.mjs +46 -0
- package/dist/lib/neutral/TranscriptionPlugin.mjs.map +7 -0
- package/dist/lib/neutral/TranscriptionPlugin.node.mjs +25 -0
- package/dist/lib/neutral/TranscriptionPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/TranscriptionPlugin.workerd.mjs +21 -0
- package/dist/lib/neutral/TranscriptionPlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/blueprint-definition-DA4QFRYJ.mjs +15 -0
- package/dist/lib/neutral/blueprint-definition-DA4QFRYJ.mjs.map +7 -0
- package/dist/lib/neutral/blueprints/index.mjs +8 -0
- package/dist/lib/neutral/capabilities/index.mjs +17 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FHNI26QW.mjs +45 -0
- package/dist/lib/neutral/chunk-FHNI26QW.mjs.map +7 -0
- package/dist/lib/{browser/chunk-HOOPZ7EM.mjs → neutral/chunk-KAEXRX3Y.mjs} +1 -1
- package/dist/lib/{browser/chunk-KOX4WNAR.mjs → neutral/chunk-KMT3BMMQ.mjs} +35 -22
- package/dist/lib/neutral/chunk-KMT3BMMQ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-KXJZEYS7.mjs +8 -0
- package/dist/lib/neutral/chunk-KXJZEYS7.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MLRJWAQH.mjs +179 -0
- package/dist/lib/neutral/chunk-MLRJWAQH.mjs.map +7 -0
- package/dist/lib/neutral/chunk-TO77KAQK.mjs +298 -0
- package/dist/lib/neutral/chunk-TO77KAQK.mjs.map +7 -0
- package/dist/lib/neutral/chunk-TX3NQISZ.mjs +435 -0
- package/dist/lib/neutral/chunk-TX3NQISZ.mjs.map +7 -0
- package/dist/lib/{browser/blueprints/index.mjs → neutral/chunk-ZR4BH4QQ.mjs} +5 -6
- package/dist/lib/neutral/chunk-ZR4BH4QQ.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +269 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +9 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/{browser/create-BTWYQ6IM.mjs → neutral/create-RVR7VC33.mjs} +5 -5
- package/dist/lib/neutral/create-RVR7VC33.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +19 -0
- package/dist/lib/neutral/index.mjs +44 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/{browser/open-CYRYIEZI.mjs → neutral/open-A5KXKRH4.mjs} +7 -7
- package/dist/lib/neutral/open-A5KXKRH4.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-NXMOAXFP.mjs +13 -0
- package/dist/lib/neutral/operation-handler-NXMOAXFP.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-YMZRO242.mjs +26 -0
- package/dist/lib/neutral/react-surface-YMZRO242.mjs.map +7 -0
- package/dist/lib/{browser/summarize-X2ZYTN7S.mjs → neutral/summarize-5XPPMVTE.mjs} +9 -11
- package/dist/lib/neutral/summarize-5XPPMVTE.mjs.map +7 -0
- package/dist/lib/neutral/text-content-KBB37HSM.mjs +30 -0
- package/dist/lib/neutral/text-content-KBB37HSM.mjs.map +7 -0
- package/dist/lib/neutral/transcriber-OGSF3XO5.mjs +59 -0
- package/dist/lib/neutral/transcriber-OGSF3XO5.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +24 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +10 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/TranscriptionPlugin.d.ts +1 -0
- package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
- package/dist/types/src/TranscriptionPlugin.node.d.ts +4 -0
- package/dist/types/src/TranscriptionPlugin.node.d.ts.map +1 -0
- package/dist/types/src/TranscriptionPlugin.test.d.ts +2 -0
- package/dist/types/src/TranscriptionPlugin.test.d.ts.map +1 -0
- package/dist/types/src/TranscriptionPlugin.workerd.d.ts +4 -0
- package/dist/types/src/TranscriptionPlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/blueprints/transcription-blueprint.d.ts +2 -2
- package/dist/types/src/blueprints/transcription-blueprint.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +8 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/text-content.d.ts +8 -0
- package/dist/types/src/capabilities/text-content.d.ts.map +1 -0
- package/dist/types/src/capabilities/transcriber.d.ts +1 -1
- package/dist/types/src/capabilities/transcriber.d.ts.map +1 -1
- package/dist/types/src/components/Oracle/Oracle.d.ts +24 -0
- package/dist/types/src/components/Oracle/Oracle.d.ts.map +1 -0
- package/dist/types/src/components/Oracle/Oracle.stories.d.ts +32 -0
- package/dist/types/src/components/Oracle/Oracle.stories.d.ts.map +1 -0
- package/dist/types/src/components/Oracle/index.d.ts +2 -0
- package/dist/types/src/components/Oracle/index.d.ts.map +1 -0
- package/dist/types/src/components/Transcription/Transcription.d.ts +1 -8
- package/dist/types/src/components/Transcription/Transcription.d.ts.map +1 -1
- package/dist/types/src/components/Transcription/Transcription.stories.d.ts +20 -23
- package/dist/types/src/components/Transcription/Transcription.stories.d.ts.map +1 -1
- package/dist/types/src/components/Transcription/transcription-extension.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/TranscriptionArticle/TranscriptionArticle.d.ts +6 -0
- package/dist/types/src/containers/TranscriptionArticle/TranscriptionArticle.d.ts.map +1 -0
- package/dist/types/src/containers/TranscriptionArticle/TranscriptionArticle.stories.d.ts +28 -0
- package/dist/types/src/containers/TranscriptionArticle/TranscriptionArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/TranscriptionArticle/index.d.ts +2 -0
- package/dist/types/src/containers/TranscriptionArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +1 -1
- package/dist/types/src/containers/index.d.ts.map +1 -1
- package/dist/types/src/enrichment/conversation.test.d.ts +2 -0
- package/dist/types/src/enrichment/conversation.test.d.ts.map +1 -0
- package/dist/types/src/enrichment/operations.d.ts +200 -0
- package/dist/types/src/enrichment/operations.d.ts.map +1 -0
- package/dist/types/src/enrichment/parser.d.ts +26 -0
- package/dist/types/src/enrichment/parser.d.ts.map +1 -0
- package/dist/types/src/enrichment/stream-simulator.d.ts +38 -0
- package/dist/types/src/enrichment/stream-simulator.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +2 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useAudioFile.d.ts.map +1 -1
- package/dist/types/src/hooks/useAudioTrack.d.ts.map +1 -1
- package/dist/types/src/hooks/useFeedModelAdapter.d.ts +12 -0
- package/dist/types/src/hooks/useFeedModelAdapter.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/hooks/useTranscriptionRecording.d.ts +12 -0
- package/dist/types/src/hooks/useTranscriptionRecording.d.ts.map +1 -0
- package/dist/types/src/hooks/useVoiceInput.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/model.d.ts +2 -2
- package/dist/types/src/model/model.d.ts.map +1 -1
- package/dist/types/src/{segments-normalization → normalization}/index.d.ts +1 -1
- package/dist/types/src/normalization/index.d.ts.map +1 -0
- package/dist/types/src/{segments-normalization → normalization}/message-normalizer.d.ts +7 -5
- package/dist/types/src/normalization/message-normalizer.d.ts.map +1 -0
- package/dist/types/src/{operations/definitions.d.ts → normalization/normalization.d.ts} +464 -547
- package/dist/types/src/normalization/normalization.d.ts.map +1 -0
- package/dist/types/src/normalization/normalization.test.d.ts.map +1 -0
- package/dist/types/src/normalization/utils.d.ts.map +1 -0
- package/dist/types/src/operations/create.d.ts +3 -3
- package/dist/types/src/operations/create.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts +1 -2
- package/dist/types/src/operations/index.d.ts.map +1 -1
- package/dist/types/src/operations/open.d.ts +3 -3
- package/dist/types/src/operations/open.d.ts.map +1 -1
- package/dist/types/src/operations/summarize.d.ts +3 -3
- package/dist/types/src/operations/summarize.d.ts.map +1 -1
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/stories/FileTranscription.stories.d.ts +20 -0
- package/dist/types/src/stories/FileTranscription.stories.d.ts.map +1 -0
- package/dist/types/src/stories/KeyWordRecognition.stories.d.ts.map +1 -0
- package/dist/types/src/{components/stories/MicrophoneTranscription.stories.d.ts → stories/LiveTranscription.stories.d.ts} +5 -5
- package/dist/types/src/stories/LiveTranscription.stories.d.ts.map +1 -0
- package/dist/types/src/stories/TranscriptionStory.d.ts +21 -0
- package/dist/types/src/stories/TranscriptionStory.d.ts.map +1 -0
- package/dist/types/src/stories/common.d.ts +248 -0
- package/dist/types/src/stories/common.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +5 -6
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/transcriber/index.d.ts +1 -1
- package/dist/types/src/transcriber/index.d.ts.map +1 -1
- package/dist/types/src/transcriber/media-stream-recorder.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcriber.d.ts +58 -3
- package/dist/types/src/transcriber/transcriber.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcriber.test.d.ts +2 -0
- package/dist/types/src/transcriber/transcriber.test.d.ts.map +1 -0
- package/dist/types/src/transcriber/transcription-manager.d.ts +6 -4
- package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +9 -8
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/TranscriptOperation.d.ts +1670 -0
- package/dist/types/src/types/TranscriptOperation.d.ts.map +1 -0
- package/dist/types/src/types/TranscriptionCapabilities.d.ts +17 -0
- package/dist/types/src/types/TranscriptionCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/util/array.d.ts.map +1 -1
- package/dist/types/src/util/get-time-str.d.ts.map +1 -1
- package/dist/types/src/util/monitor-audio-level.d.ts.map +1 -1
- package/dist/types/src/util/render-byline.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +136 -102
- package/src/TranscriptionPlugin.node.ts +20 -0
- package/src/TranscriptionPlugin.test.ts +31 -0
- package/src/TranscriptionPlugin.tsx +11 -31
- package/src/TranscriptionPlugin.workerd.ts +18 -0
- package/src/blueprints/transcription-blueprint.ts +3 -4
- package/src/capabilities/blueprint-definition.ts +6 -4
- package/src/capabilities/index.ts +9 -2
- package/src/capabilities/operation-handler.ts +1 -1
- package/src/capabilities/react-surface.tsx +2 -2
- package/src/capabilities/text-content.ts +33 -0
- package/src/capabilities/transcriber.ts +9 -5
- package/src/components/Oracle/Oracle.stories.tsx +147 -0
- package/src/components/Oracle/Oracle.tsx +142 -0
- package/src/components/Oracle/index.ts +5 -0
- package/src/components/Transcription/Transcription.stories.tsx +117 -153
- package/src/components/Transcription/Transcription.tsx +8 -17
- package/src/components/index.ts +1 -0
- package/src/containers/TranscriptionArticle/TranscriptionArticle.stories.tsx +61 -0
- package/src/containers/TranscriptionArticle/TranscriptionArticle.tsx +62 -0
- package/src/containers/TranscriptionArticle/index.ts +5 -0
- package/src/containers/index.ts +1 -1
- package/src/enrichment/conversation.test.ts +162 -0
- package/src/enrichment/conversation.txt +23 -0
- package/src/enrichment/operations.ts +271 -0
- package/src/enrichment/parser.ts +101 -0
- package/src/enrichment/stream-simulator.ts +125 -0
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useAudioTrack.ts +1 -1
- package/src/hooks/useFeedModelAdapter.ts +46 -0
- package/src/hooks/useTranscriber.ts +7 -5
- package/src/hooks/useTranscriptionRecording.ts +87 -0
- package/src/hooks/useVoiceInput.ts +1 -1
- package/src/index.ts +4 -5
- package/src/meta.ts +28 -6
- package/src/model/model.test.ts +5 -5
- package/src/model/model.ts +3 -3
- package/src/{segments-normalization → normalization}/message-normalizer.ts +25 -17
- package/src/{segments-normalization → normalization}/normalization.test.ts +4 -38
- package/src/{segments-normalization → normalization}/normalization.ts +8 -9
- package/src/operations/create.ts +3 -3
- package/src/operations/index.ts +1 -3
- package/src/operations/open.ts +3 -3
- package/src/operations/summarize.ts +7 -7
- package/src/plugin.ts +11 -0
- package/src/stories/FileTranscription.stories.tsx +143 -0
- package/src/{components/stories → stories}/KeyWordRecognition.stories.tsx +36 -36
- package/src/stories/LiveTranscription.stories.tsx +153 -0
- package/src/stories/TranscriptionStory.tsx +101 -0
- package/src/stories/common.ts +233 -0
- package/src/testing/testing.ts +22 -34
- package/src/transcriber/index.ts +1 -1
- package/src/transcriber/transcriber.test.ts +104 -0
- package/src/transcriber/transcriber.ts +100 -55
- package/src/transcriber/transcription-manager.ts +14 -9
- package/src/translations.ts +3 -0
- package/src/{operations/definitions.ts → types/TranscriptOperation.ts} +14 -9
- package/src/types/TranscriptionCapabilities.ts +39 -0
- package/src/types/index.ts +2 -2
- package/src/vite-env.d.ts +10 -0
- package/dist/lib/browser/blueprints/index.mjs.map +0 -7
- package/dist/lib/browser/chunk-5LWSJZTZ.mjs +0 -17
- package/dist/lib/browser/chunk-5LWSJZTZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-KOX4WNAR.mjs.map +0 -7
- package/dist/lib/browser/create-BTWYQ6IM.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -1213
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/open-CYRYIEZI.mjs.map +0 -7
- package/dist/lib/browser/operations/index.mjs +0 -13
- package/dist/lib/browser/operations/index.mjs.map +0 -7
- package/dist/lib/browser/summarize-X2ZYTN7S.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -10
- package/dist/lib/node-esm/blueprints/index.mjs +0 -32
- package/dist/lib/node-esm/blueprints/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-MT5I4NH5.mjs +0 -112
- package/dist/lib/node-esm/chunk-MT5I4NH5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NVM2QUMX.mjs +0 -37
- package/dist/lib/node-esm/chunk-NVM2QUMX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-X74WYCCE.mjs +0 -19
- package/dist/lib/node-esm/chunk-X74WYCCE.mjs.map +0 -7
- package/dist/lib/node-esm/create-MLUFPST2.mjs +0 -22
- package/dist/lib/node-esm/create-MLUFPST2.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -1214
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/open-5IOC2U4Z.mjs +0 -28
- package/dist/lib/node-esm/open-5IOC2U4Z.mjs.map +0 -7
- package/dist/lib/node-esm/operations/index.mjs +0 -14
- package/dist/lib/node-esm/operations/index.mjs.map +0 -7
- package/dist/lib/node-esm/summarize-IORITU7T.mjs +0 -80
- package/dist/lib/node-esm/summarize-IORITU7T.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -11
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts +0 -18
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts.map +0 -1
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts.map +0 -1
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts.map +0 -1
- package/dist/types/src/components/stories/TranscriptionStory.d.ts +0 -12
- package/dist/types/src/components/stories/TranscriptionStory.d.ts.map +0 -1
- package/dist/types/src/components/stories/useIsSpeaking.d.ts +0 -3
- package/dist/types/src/components/stories/useIsSpeaking.d.ts.map +0 -1
- package/dist/types/src/containers/TranscriptionContainer/TranscriptionContainer.d.ts +0 -6
- package/dist/types/src/containers/TranscriptionContainer/TranscriptionContainer.d.ts.map +0 -1
- package/dist/types/src/containers/TranscriptionContainer/index.d.ts +0 -2
- package/dist/types/src/containers/TranscriptionContainer/index.d.ts.map +0 -1
- package/dist/types/src/hooks/useQueueModelAdapter.d.ts +0 -8
- package/dist/types/src/hooks/useQueueModelAdapter.d.ts.map +0 -1
- package/dist/types/src/operations/definitions.d.ts.map +0 -1
- package/dist/types/src/segments-normalization/index.d.ts.map +0 -1
- package/dist/types/src/segments-normalization/message-normalizer.d.ts.map +0 -1
- package/dist/types/src/segments-normalization/normalization.d.ts +0 -364
- package/dist/types/src/segments-normalization/normalization.d.ts.map +0 -1
- package/dist/types/src/segments-normalization/normalization.test.d.ts.map +0 -1
- package/dist/types/src/segments-normalization/utils.d.ts.map +0 -1
- package/dist/types/src/types/capabilities.d.ts +0 -18
- package/dist/types/src/types/capabilities.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -5
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/components/stories/FileTranscription.stories.tsx +0 -250
- package/src/components/stories/MicrophoneTranscription.stories.tsx +0 -264
- package/src/components/stories/TranscriptionStory.tsx +0 -43
- package/src/components/stories/useIsSpeaking.tsx +0 -40
- package/src/containers/TranscriptionContainer/TranscriptionContainer.tsx +0 -35
- package/src/containers/TranscriptionContainer/index.ts +0 -5
- package/src/hooks/useQueueModelAdapter.ts +0 -66
- package/src/types/capabilities.ts +0 -34
- package/src/types/types.ts +0 -9
- package/dist/lib/{browser/types → neutral/blueprints}/index.mjs.map +0 -0
- package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
- package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs.map +0 -0
- package/dist/lib/{browser/chunk-HOOPZ7EM.mjs.map → neutral/chunk-KAEXRX3Y.mjs.map} +0 -0
- package/dist/lib/{node-esm/types → neutral/hooks}/index.mjs.map +0 -0
- package/dist/lib/{node-esm/chunk-HSLMI22Q.mjs.map → neutral/index.mjs.map} +0 -0
- package/dist/types/src/{segments-normalization → normalization}/normalization.test.d.ts +0 -0
- package/dist/types/src/{segments-normalization → normalization}/utils.d.ts +0 -0
- package/dist/types/src/{components/stories → stories}/KeyWordRecognition.stories.d.ts +0 -0
- package/src/{segments-normalization → normalization}/index.ts +1 -1
- /package/src/{segments-normalization → normalization}/utils.ts +0 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
8
|
+
|
|
9
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
|
+
import { ClientPlugin, initializeIdentity } from '@dxos/plugin-client/testing';
|
|
11
|
+
import { corePlugins } from '@dxos/plugin-testing';
|
|
12
|
+
import { IconButton, Panel, Toolbar } from '@dxos/react-ui';
|
|
13
|
+
import { withLayout } from '@dxos/react-ui/testing';
|
|
14
|
+
import { type ContentBlock, type Message } from '@dxos/types';
|
|
15
|
+
|
|
16
|
+
import { useAudioTrack, useTranscriber } from '#hooks';
|
|
17
|
+
import { translations } from '#translations';
|
|
18
|
+
|
|
19
|
+
import { TranscriptionPlugin } from '../../TranscriptionPlugin';
|
|
20
|
+
import { Oracle } from './Oracle';
|
|
21
|
+
|
|
22
|
+
type DefaultStoryProps = {
|
|
23
|
+
delay?: number;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const DefaultStory = ({ delay }: DefaultStoryProps) => {
|
|
27
|
+
const [recording, setRecording] = useState(false);
|
|
28
|
+
const [text, setText] = useState('');
|
|
29
|
+
const elapsed = useStopwatch(recording);
|
|
30
|
+
const track = useAudioTrack(recording);
|
|
31
|
+
|
|
32
|
+
// Build the latest transcribed text from incoming blocks.
|
|
33
|
+
const handleSegments = useCallback(async (blocks: Message.Message['blocks']) => {
|
|
34
|
+
const phrase = blocks
|
|
35
|
+
.filter((block): block is ContentBlock.Transcript => block._tag === 'transcript')
|
|
36
|
+
.map((block) => block.text.trim())
|
|
37
|
+
.filter(Boolean)
|
|
38
|
+
.join(' ');
|
|
39
|
+
|
|
40
|
+
setText((prev) => (prev ? `${prev} ${phrase}` : phrase));
|
|
41
|
+
}, []);
|
|
42
|
+
|
|
43
|
+
// Drive the transcriber off the recording flag.
|
|
44
|
+
// Default `transcribeAfterChunksAmount` is 50 × 200ms = 10s, so the first phrase only
|
|
45
|
+
// surfaces after ~10s. Drop it to 15 chunks (~3s) so the TextBlock starts updating fast.
|
|
46
|
+
const transcriber = useTranscriber({
|
|
47
|
+
audioStreamTrack: track,
|
|
48
|
+
onSegments: handleSegments,
|
|
49
|
+
transcriberConfig: { transcribeAfterChunksAmount: 15, prefixBufferChunksAmount: 5 },
|
|
50
|
+
});
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (!transcriber) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let cancelled = false;
|
|
57
|
+
void transcriber.open().then(() => {
|
|
58
|
+
if (!cancelled && recording) {
|
|
59
|
+
transcriber.startChunksRecording();
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return () => {
|
|
64
|
+
cancelled = true;
|
|
65
|
+
transcriber.stopChunksRecording();
|
|
66
|
+
};
|
|
67
|
+
}, [transcriber, recording]);
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<Panel.Root>
|
|
71
|
+
<Panel.Toolbar asChild>
|
|
72
|
+
<Toolbar.Root>
|
|
73
|
+
<IconButton
|
|
74
|
+
icon={recording ? 'ph--stop-circle--regular' : 'ph--microphone--regular'}
|
|
75
|
+
label={recording ? 'Stop' : 'Record'}
|
|
76
|
+
onClick={() => setRecording((value) => !value)}
|
|
77
|
+
/>
|
|
78
|
+
<IconButton disabled={recording} icon='ph--x--regular' label='Clear' onClick={() => setText('')} />
|
|
79
|
+
<Toolbar.Separator />
|
|
80
|
+
<Toolbar.Text classNames='text-right tabular-nums text-subdued'>{elapsed}s</Toolbar.Text>
|
|
81
|
+
</Toolbar.Root>
|
|
82
|
+
</Panel.Toolbar>
|
|
83
|
+
<Oracle.Root text={text} delay={delay}>
|
|
84
|
+
<Panel.Content asChild>
|
|
85
|
+
<Oracle.Content>
|
|
86
|
+
<Oracle.Canvas />
|
|
87
|
+
<Oracle.Text />
|
|
88
|
+
</Oracle.Content>
|
|
89
|
+
</Panel.Content>
|
|
90
|
+
</Oracle.Root>
|
|
91
|
+
</Panel.Root>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const meta = {
|
|
96
|
+
title: 'plugins/plugin-transcription/components/Oracle',
|
|
97
|
+
render: DefaultStory,
|
|
98
|
+
decorators: [
|
|
99
|
+
withLayout({ layout: 'fullscreen' }),
|
|
100
|
+
withPluginManager({
|
|
101
|
+
plugins: [
|
|
102
|
+
...corePlugins(),
|
|
103
|
+
ClientPlugin({
|
|
104
|
+
onClientInitialized: ({ client }) =>
|
|
105
|
+
Effect.gen(function* () {
|
|
106
|
+
yield* initializeIdentity(client);
|
|
107
|
+
}),
|
|
108
|
+
}),
|
|
109
|
+
TranscriptionPlugin(),
|
|
110
|
+
],
|
|
111
|
+
}),
|
|
112
|
+
],
|
|
113
|
+
parameters: {
|
|
114
|
+
layout: 'fullscreen',
|
|
115
|
+
translations,
|
|
116
|
+
},
|
|
117
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
118
|
+
|
|
119
|
+
export default meta;
|
|
120
|
+
|
|
121
|
+
type Story = StoryObj<typeof meta>;
|
|
122
|
+
|
|
123
|
+
export const Default: Story = {
|
|
124
|
+
args: {
|
|
125
|
+
delay: 12,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export const Instant: Story = {
|
|
130
|
+
args: {
|
|
131
|
+
delay: 0,
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/** Seconds elapsed while `running`; resets to 0 each time `running` toggles back to true. */
|
|
136
|
+
const useStopwatch = (running: boolean): number => {
|
|
137
|
+
const [seconds, setSeconds] = useState(0);
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
if (!running) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
setSeconds(0);
|
|
143
|
+
const id = setInterval(() => setSeconds((value) => value + 1), 1_000);
|
|
144
|
+
return () => clearInterval(id);
|
|
145
|
+
}, [running]);
|
|
146
|
+
return seconds;
|
|
147
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Primitive } from '@radix-ui/react-primitive';
|
|
6
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
7
|
+
import React, { type PropsWithChildren, createContext, useContext, useMemo } from 'react';
|
|
8
|
+
|
|
9
|
+
import '@dxos/react-ui-graph/styles/graph.css';
|
|
10
|
+
import { type ThemedClassName } from '@dxos/react-ui';
|
|
11
|
+
import { composableProps, slottable } from '@dxos/react-ui';
|
|
12
|
+
import { TextBlock } from '@dxos/react-ui-components';
|
|
13
|
+
import { SVG } from '@dxos/react-ui-graph';
|
|
14
|
+
import { mx } from '@dxos/ui-theme';
|
|
15
|
+
import { type SlottableProps } from '@dxos/ui-types';
|
|
16
|
+
|
|
17
|
+
//
|
|
18
|
+
// Context
|
|
19
|
+
//
|
|
20
|
+
|
|
21
|
+
type OracleContextValue = {
|
|
22
|
+
/** Latest utterance / phrase rendered by `Oracle.Text`. */
|
|
23
|
+
text: string;
|
|
24
|
+
/** Per-character reveal delay in ms for the streaming TextBlock. */
|
|
25
|
+
delay: number;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const OracleContext = createContext<OracleContextValue | null>(null);
|
|
29
|
+
|
|
30
|
+
const useOracleContext = (consumer: string): OracleContextValue => {
|
|
31
|
+
const ctx = useContext(OracleContext);
|
|
32
|
+
if (!ctx) {
|
|
33
|
+
throw new Error(`<Oracle.${consumer}> must be rendered inside <Oracle.Root>`);
|
|
34
|
+
}
|
|
35
|
+
return ctx;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//
|
|
39
|
+
// Root (headless — provides context only, renders no DOM)
|
|
40
|
+
//
|
|
41
|
+
|
|
42
|
+
export type OracleRootProps = PropsWithChildren<{
|
|
43
|
+
/** Latest utterance / phrase rendered by `Oracle.Text`. */
|
|
44
|
+
text?: string;
|
|
45
|
+
/** Per-character reveal delay in ms for the streaming TextBlock. @default 12 */
|
|
46
|
+
delay?: number;
|
|
47
|
+
}>;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Oracle surface root. Headless — provides text/delay context to subcomponents and renders
|
|
51
|
+
* no DOM of its own. Wrap subcomponents in `<Oracle.Content>` for the standard relative
|
|
52
|
+
* stacking layout, or place `<Oracle.Canvas>` / `<Oracle.Text>` inside any positioned
|
|
53
|
+
* container of your choice.
|
|
54
|
+
*/
|
|
55
|
+
const Root = ({ children, text = '', delay = 12 }: OracleRootProps) => {
|
|
56
|
+
const value = useMemo(() => ({ text, delay }), [text, delay]);
|
|
57
|
+
return <OracleContext.Provider value={value}>{children}</OracleContext.Provider>;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
//
|
|
61
|
+
// Content
|
|
62
|
+
//
|
|
63
|
+
|
|
64
|
+
export type OracleContentProps = SlottableProps;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Positioned container that stacks `Oracle.Canvas` (the SVG graph viewport, absolutely
|
|
68
|
+
* positioned to fill) under `Oracle.Text` (the centered overlay). Use this for the standard
|
|
69
|
+
* Oracle layout; skip it if you need custom positioning.
|
|
70
|
+
*
|
|
71
|
+
* Pass `asChild` to merge the positioning + sizing onto a parent slot (e.g. `Panel.Content`).
|
|
72
|
+
*/
|
|
73
|
+
const Content = slottable<HTMLDivElement>(({ children, asChild, ...props }, forwardedRef) => {
|
|
74
|
+
const Comp = asChild ? Slot : Primitive.div;
|
|
75
|
+
return (
|
|
76
|
+
<Comp {...composableProps(props, { classNames: 'relative dx-expander' })} ref={forwardedRef}>
|
|
77
|
+
{children}
|
|
78
|
+
</Comp>
|
|
79
|
+
);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
Content.displayName = 'Oracle.Content';
|
|
83
|
+
|
|
84
|
+
//
|
|
85
|
+
// Canvas
|
|
86
|
+
//
|
|
87
|
+
|
|
88
|
+
export type OracleCanvasProps = ThemedClassName<PropsWithChildren<{}>>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* SVG graph viewport. Renders sensible defaults (markers, grid, pan/zoom, empty graph)
|
|
92
|
+
* when no children are supplied; consumers can replace those by passing their own
|
|
93
|
+
* SVG.* children (e.g. a populated `<SVG.Graph model={…} />`).
|
|
94
|
+
*/
|
|
95
|
+
const Canvas = ({ classNames, children }: OracleCanvasProps) => (
|
|
96
|
+
<SVG.Root centered classNames={mx('absolute inset-0', classNames)}>
|
|
97
|
+
{children ?? (
|
|
98
|
+
<>
|
|
99
|
+
<SVG.Markers />
|
|
100
|
+
<SVG.Grid />
|
|
101
|
+
<SVG.Zoom extent={[1 / 4, 4]}>
|
|
102
|
+
<SVG.Graph />
|
|
103
|
+
</SVG.Zoom>
|
|
104
|
+
</>
|
|
105
|
+
)}
|
|
106
|
+
</SVG.Root>
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
//
|
|
110
|
+
// Text
|
|
111
|
+
//
|
|
112
|
+
|
|
113
|
+
export type OracleTextProps = ThemedClassName<{}>;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Centered text overlay. Reads `text` and `delay` from `Oracle.Root` context and renders
|
|
117
|
+
* a streaming `TextBlock` floating above the canvas. Pointer-events are disabled so the
|
|
118
|
+
* underlying graph remains interactive.
|
|
119
|
+
*/
|
|
120
|
+
const Text = ({ classNames }: OracleTextProps) => {
|
|
121
|
+
const { text, delay } = useOracleContext('Text');
|
|
122
|
+
return (
|
|
123
|
+
<div className='pointer-events-none absolute inset-0 flex items-center justify-center'>
|
|
124
|
+
<TextBlock
|
|
125
|
+
classNames={mx('max-w-xl px-6 py-4 text-center text-2xl font-medium text-balance text-subdued', classNames)}
|
|
126
|
+
text={text}
|
|
127
|
+
delay={delay}
|
|
128
|
+
/>
|
|
129
|
+
</div>
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
//
|
|
134
|
+
// Namespace
|
|
135
|
+
//
|
|
136
|
+
|
|
137
|
+
export const Oracle = {
|
|
138
|
+
Root,
|
|
139
|
+
Content,
|
|
140
|
+
Canvas,
|
|
141
|
+
Text,
|
|
142
|
+
};
|
|
@@ -5,89 +5,93 @@
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
import type * as Types from 'effect/Types';
|
|
8
|
-
import React, {
|
|
8
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
9
9
|
|
|
10
10
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
11
|
-
import {
|
|
12
|
-
import { ClientPlugin } from '@dxos/plugin-client';
|
|
13
|
-
import {
|
|
14
|
-
import { PreviewPlugin } from '@dxos/plugin-preview';
|
|
11
|
+
import { Feed, Filter, Obj, Query } from '@dxos/echo';
|
|
12
|
+
import { ClientPlugin, initializeIdentity } from '@dxos/plugin-client/testing';
|
|
13
|
+
import { PreviewPlugin } from '@dxos/plugin-preview/testing';
|
|
15
14
|
import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
|
|
16
15
|
import { random } from '@dxos/random';
|
|
17
|
-
import { useMembers, useSpaces } from '@dxos/react-client/echo';
|
|
18
|
-
import { IconButton, Toolbar } from '@dxos/react-ui';
|
|
19
|
-
import {
|
|
16
|
+
import { useMembers, useQuery, useSpaces } from '@dxos/react-client/echo';
|
|
17
|
+
import { IconButton, Panel, Toolbar } from '@dxos/react-ui';
|
|
18
|
+
import { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
20
19
|
import { withLayout } from '@dxos/react-ui/testing';
|
|
21
|
-
import {
|
|
22
|
-
import { type ContentBlock, type Message, Organization, Person } from '@dxos/types';
|
|
20
|
+
import { type ContentBlock, Message, Organization, Person } from '@dxos/types';
|
|
23
21
|
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
TestItem,
|
|
28
|
-
useTestTranscriptionQueue,
|
|
29
|
-
useTestTranscriptionQueueWithEntityExtraction,
|
|
30
|
-
} from '#testing';
|
|
22
|
+
import { useFeedModelAdapter } from '#hooks';
|
|
23
|
+
import { MessageBuilder, TestItem, useTestTranscriptionQueue } from '#testing';
|
|
24
|
+
import { translations } from '#translations';
|
|
31
25
|
|
|
32
26
|
import { SerializationModel } from '../../model';
|
|
33
|
-
import { translations } from '../../translations';
|
|
34
27
|
import { renderByline } from '../../util';
|
|
35
28
|
import { Transcription, type TranscriptionProps } from './Transcription';
|
|
36
29
|
|
|
37
30
|
random.seed(1);
|
|
38
31
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
{JSON.stringify(model.toJSON())}
|
|
56
|
-
</SyntaxHighlighter>
|
|
57
|
-
</div>
|
|
58
|
-
<Toolbar.Root classNames='justify-end'>
|
|
59
|
-
<IconButton
|
|
60
|
-
icon={running ? 'ph--pause--regular' : 'ph--play--regular'}
|
|
61
|
-
label={running ? 'Pause' : 'Start'}
|
|
62
|
-
onClick={() => onRunningChange(!running)}
|
|
63
|
-
/>
|
|
64
|
-
{onReset && <IconButton icon='ph--x--regular' label='Reset' onClick={onReset} />}
|
|
65
|
-
</Toolbar.Root>
|
|
66
|
-
</div>
|
|
67
|
-
</div>
|
|
32
|
+
type Source = 'local' | 'feed';
|
|
33
|
+
|
|
34
|
+
type DefaultStoryProps = {
|
|
35
|
+
/** Where transcript messages come from. */
|
|
36
|
+
source?: Source;
|
|
37
|
+
/** Number of synthetic messages to pre-populate (local source only). */
|
|
38
|
+
seed?: number;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const DefaultStory = ({ source = 'local', seed = 0, ...props }: DefaultStoryProps) => {
|
|
42
|
+
const [resetKey, setResetKey] = useState(0);
|
|
43
|
+
const handleReset = useCallback(() => setResetKey((value) => value + 1), []);
|
|
44
|
+
return source === 'feed' ? (
|
|
45
|
+
<FeedStory key={resetKey} onReset={handleReset} {...props} />
|
|
46
|
+
) : (
|
|
47
|
+
<LocalStory key={resetKey} seed={seed} onReset={handleReset} {...props} />
|
|
68
48
|
);
|
|
69
49
|
};
|
|
70
50
|
|
|
71
|
-
type
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
>;
|
|
51
|
+
type InnerProps = {
|
|
52
|
+
onReset: () => void;
|
|
53
|
+
};
|
|
75
54
|
|
|
76
|
-
|
|
77
|
-
* Basic story mutates array of messages.
|
|
78
|
-
*/
|
|
79
|
-
const BasicStory = ({ messages: initialMessages = [], ...props }: DefaultStoryProps) => {
|
|
80
|
-
const [reset, setReset] = useState({});
|
|
55
|
+
const LocalStory = ({ seed = 0, onReset, ...props }: InnerProps & { seed?: number }) => {
|
|
81
56
|
const builder = useMemo(() => new MessageBuilder(), []);
|
|
57
|
+
const [initialMessages, setInitialMessages] = useState<Message.Message[]>([]);
|
|
58
|
+
const [ready, setReady] = useState(seed === 0);
|
|
59
|
+
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
// Reset on every seed change so Storybook controls don't leave stale messages from a prior run.
|
|
62
|
+
let cancelled = false;
|
|
63
|
+
setInitialMessages([]);
|
|
64
|
+
setReady(seed === 0);
|
|
65
|
+
|
|
66
|
+
if (seed === 0) {
|
|
67
|
+
return () => {
|
|
68
|
+
cancelled = true;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
void Promise.all(Array.from({ length: seed }, () => builder.createMessage())).then((messages) => {
|
|
73
|
+
if (cancelled) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
setInitialMessages(messages);
|
|
77
|
+
setReady(true);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
return () => {
|
|
81
|
+
cancelled = true;
|
|
82
|
+
};
|
|
83
|
+
}, [seed, builder]);
|
|
84
|
+
|
|
82
85
|
const model = useMemo(
|
|
83
86
|
() => new SerializationModel<Message.Message>(renderByline([]), initialMessages),
|
|
84
|
-
[initialMessages
|
|
87
|
+
[initialMessages],
|
|
85
88
|
);
|
|
89
|
+
|
|
86
90
|
const [running, setRunning] = useState(true);
|
|
87
|
-
// Use mutable type for local message building (not ECHO-managed).
|
|
88
91
|
const [currentMessage, setCurrentMessage] = useState<Types.Mutable<Message.Message> | null>(null);
|
|
92
|
+
|
|
89
93
|
useEffect(() => {
|
|
90
|
-
if (!running) {
|
|
94
|
+
if (!ready || !running) {
|
|
91
95
|
return;
|
|
92
96
|
}
|
|
93
97
|
|
|
@@ -99,83 +103,68 @@ const BasicStory = ({ messages: initialMessages = [], ...props }: DefaultStoryPr
|
|
|
99
103
|
return;
|
|
100
104
|
}
|
|
101
105
|
|
|
102
|
-
const
|
|
103
|
-
if (currentMessage
|
|
106
|
+
const id = setInterval(() => {
|
|
107
|
+
if (currentMessage.blocks.length >= 3) {
|
|
104
108
|
setCurrentMessage(null);
|
|
105
|
-
clearInterval(
|
|
109
|
+
clearInterval(id);
|
|
106
110
|
return;
|
|
107
111
|
}
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
Obj.update(currentMessage, (currentMessage) => {
|
|
113
|
+
(currentMessage.blocks as ContentBlock.Any[]).push(builder.createBlock());
|
|
114
|
+
});
|
|
110
115
|
model.updateChunk(currentMessage);
|
|
111
116
|
}, 3_000);
|
|
112
117
|
|
|
113
|
-
return () => clearInterval(
|
|
114
|
-
}, [
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
setCurrentMessage(null);
|
|
118
|
-
setRunning(false);
|
|
119
|
-
setReset({});
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
return (
|
|
123
|
-
<TranscriptContainer
|
|
124
|
-
model={model}
|
|
125
|
-
running={running}
|
|
126
|
-
onRunningChange={setRunning}
|
|
127
|
-
onReset={handleReset}
|
|
128
|
-
{...props}
|
|
129
|
-
/>
|
|
130
|
-
);
|
|
118
|
+
return () => clearInterval(id);
|
|
119
|
+
}, [ready, running, currentMessage, model, builder]);
|
|
120
|
+
|
|
121
|
+
return <Shell model={model} running={running} onRunningChange={setRunning} onReset={onReset} {...props} />;
|
|
131
122
|
};
|
|
132
123
|
|
|
133
|
-
|
|
134
|
-
* Queue story mutates queue with model adapter.
|
|
135
|
-
*/
|
|
136
|
-
const QueueStory = ({
|
|
137
|
-
messages: initialMessages = [],
|
|
138
|
-
queueId,
|
|
139
|
-
onReset,
|
|
140
|
-
...props
|
|
141
|
-
}: DefaultStoryProps & { queueId: Key.ObjectId; onReset: () => void }) => {
|
|
124
|
+
const FeedStory = ({ onReset, ...props }: InnerProps) => {
|
|
142
125
|
const [running, setRunning] = useState(true);
|
|
143
126
|
const [space] = useSpaces();
|
|
144
127
|
const members = useMembers(space?.id).map((member) => member.identity);
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
<TranscriptContainer model={model} running={running} onRunningChange={setRunning} onReset={onReset} {...props} />
|
|
128
|
+
const feed = useTestTranscriptionQueue(space, running, 2_000);
|
|
129
|
+
const messages = useQuery(
|
|
130
|
+
space?.db,
|
|
131
|
+
feed ? Query.select(Filter.type(Message.Message)).from(feed) : Query.select(Filter.nothing()),
|
|
150
132
|
);
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
// TODO(burdon): Reconcile with QueueStory.
|
|
154
|
-
const EntityExtractionQueueStory = () => {
|
|
155
|
-
const [running, setRunning] = useState(true);
|
|
156
|
-
const [space] = useSpaces();
|
|
157
|
-
const members = useMembers(space?.key).map((member) => member.identity);
|
|
158
|
-
const queue = useTestTranscriptionQueueWithEntityExtraction(space, undefined, running, 2_000);
|
|
159
|
-
const model = useQueueModelAdapter(renderByline(members), queue, []);
|
|
133
|
+
const model = useFeedModelAdapter(renderByline(members), messages, []);
|
|
160
134
|
|
|
161
|
-
return <
|
|
135
|
+
return <Shell model={model} running={running} onRunningChange={setRunning} onReset={onReset} {...props} />;
|
|
162
136
|
};
|
|
163
137
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const [queueId] = useState(Key.ObjectId.random());
|
|
169
|
-
const [key, setKey] = useState(Key.ObjectId.random().toString());
|
|
170
|
-
const handleReset = () => {
|
|
171
|
-
setKey(Key.ObjectId.random().toString());
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
return <QueueStory key={key} queueId={queueId} onReset={handleReset} />;
|
|
138
|
+
type ShellProps = TranscriptionProps & {
|
|
139
|
+
running: boolean;
|
|
140
|
+
onRunningChange: (running: boolean) => void;
|
|
141
|
+
onReset: () => void;
|
|
175
142
|
};
|
|
176
143
|
|
|
144
|
+
const Shell = ({ model, running, onRunningChange, onReset, ...props }: ShellProps) => (
|
|
145
|
+
<Panel.Root>
|
|
146
|
+
<Panel.Toolbar asChild>
|
|
147
|
+
<Toolbar.Root classNames='justify-end'>
|
|
148
|
+
<IconButton
|
|
149
|
+
icon={running ? 'ph--pause--regular' : 'ph--play--regular'}
|
|
150
|
+
label={running ? 'Pause' : 'Start'}
|
|
151
|
+
onClick={() => onRunningChange(!running)}
|
|
152
|
+
/>
|
|
153
|
+
<IconButton icon='ph--x--regular' label='Reset' onClick={onReset} />
|
|
154
|
+
</Toolbar.Root>
|
|
155
|
+
</Panel.Toolbar>
|
|
156
|
+
<Panel.Content className='dx-document'>
|
|
157
|
+
<Transcription model={model} {...props} />
|
|
158
|
+
</Panel.Content>
|
|
159
|
+
<Panel.Statusbar className='flex items-center justify-center'>
|
|
160
|
+
<JsonHighlighter data={model.toJSON()} indent={0} classNames='text-sm' />
|
|
161
|
+
</Panel.Statusbar>
|
|
162
|
+
</Panel.Root>
|
|
163
|
+
);
|
|
164
|
+
|
|
177
165
|
const meta = {
|
|
178
166
|
title: 'plugins/plugin-transcription/components/Transcription',
|
|
167
|
+
render: DefaultStory,
|
|
179
168
|
decorators: [
|
|
180
169
|
withLayout({ layout: 'fullscreen' }),
|
|
181
170
|
withPluginManager({
|
|
@@ -183,13 +172,12 @@ const meta = {
|
|
|
183
172
|
...corePlugins(),
|
|
184
173
|
StorybookPlugin({}),
|
|
185
174
|
ClientPlugin({
|
|
186
|
-
types: [TestItem,
|
|
175
|
+
types: [TestItem, Person.Person, Organization.Organization, Feed.Feed, Message.Message],
|
|
187
176
|
onClientInitialized: ({ client }) =>
|
|
188
177
|
Effect.gen(function* () {
|
|
189
178
|
yield* initializeIdentity(client);
|
|
190
179
|
}),
|
|
191
180
|
}),
|
|
192
|
-
|
|
193
181
|
PreviewPlugin(),
|
|
194
182
|
],
|
|
195
183
|
}),
|
|
@@ -198,52 +186,28 @@ const meta = {
|
|
|
198
186
|
layout: 'fullscreen',
|
|
199
187
|
translations,
|
|
200
188
|
},
|
|
201
|
-
} satisfies Meta
|
|
189
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
202
190
|
|
|
203
191
|
export default meta;
|
|
204
192
|
|
|
205
|
-
|
|
206
|
-
const [messages, setMessages] = useState<Message.Message[]>([]);
|
|
207
|
-
useEffect(() => {
|
|
208
|
-
void Promise.all(Array.from({ length: 10 }, () => MessageBuilder.singleton.createMessage())).then(setMessages);
|
|
209
|
-
}, []);
|
|
210
|
-
if (messages.length === 0) {
|
|
211
|
-
return <div>Loading messages...</div>;
|
|
212
|
-
}
|
|
213
|
-
return <BasicStory {...props} messages={messages} />;
|
|
214
|
-
};
|
|
193
|
+
type Story = StoryObj<typeof meta>;
|
|
215
194
|
|
|
216
|
-
export const Default:
|
|
217
|
-
render: DefaultStory,
|
|
195
|
+
export const Default: Story = {
|
|
218
196
|
args: {
|
|
219
|
-
|
|
220
|
-
|
|
197
|
+
source: 'local',
|
|
198
|
+
seed: 10,
|
|
221
199
|
},
|
|
222
200
|
};
|
|
223
201
|
|
|
224
|
-
export const Empty:
|
|
225
|
-
render: BasicStory,
|
|
202
|
+
export const Empty: Story = {
|
|
226
203
|
args: {
|
|
227
|
-
|
|
228
|
-
|
|
204
|
+
source: 'local',
|
|
205
|
+
seed: 0,
|
|
229
206
|
},
|
|
230
207
|
};
|
|
231
208
|
|
|
232
|
-
export const WithQueue:
|
|
233
|
-
render: QueueStoryWrapper,
|
|
209
|
+
export const WithQueue: Story = {
|
|
234
210
|
args: {
|
|
235
|
-
|
|
236
|
-
attendableId: 'story',
|
|
211
|
+
source: 'feed',
|
|
237
212
|
},
|
|
238
213
|
};
|
|
239
|
-
|
|
240
|
-
// NOTE: We are running out of free quota on hugging face entity extraction.
|
|
241
|
-
// TODO(mykola): Fix AI service in entity extraction function.
|
|
242
|
-
// TODO(mykola): Fix hugging face quota issues.
|
|
243
|
-
// export const WithEntityExtractionQueue: StoryObj<typeof EntityExtractionQueueStory> = {
|
|
244
|
-
// render: EntityExtractionQueueStory,
|
|
245
|
-
// args: {
|
|
246
|
-
// ignoreAttention: true,
|
|
247
|
-
// attendableId: 'story',
|
|
248
|
-
// },
|
|
249
|
-
// };
|