@dxos/plugin-thread 0.8.4-main.fd6878d → 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 +75 -0
- package/README.md +1 -1
- package/dist/lib/neutral/ChannelArticle-H633OM3U.mjs +57 -0
- package/dist/lib/neutral/ChannelArticle-H633OM3U.mjs.map +7 -0
- package/dist/lib/neutral/ChannelCreatePanel-NUXXKHZQ.mjs +38 -0
- package/dist/lib/neutral/ChannelCreatePanel-NUXXKHZQ.mjs.map +7 -0
- package/dist/lib/neutral/ThreadArticle-ROQXQLEZ.mjs +57 -0
- package/dist/lib/neutral/ThreadArticle-ROQXQLEZ.mjs.map +7 -0
- package/dist/lib/neutral/ThreadPlugin.mjs +67 -0
- package/dist/lib/neutral/ThreadPlugin.mjs.map +7 -0
- package/dist/lib/neutral/ThreadPlugin.node.mjs +29 -0
- package/dist/lib/neutral/ThreadPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/ThreadPlugin.workerd.mjs +27 -0
- package/dist/lib/neutral/ThreadPlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/app-graph-builder-OLKN3VTB.mjs +50 -0
- package/dist/lib/neutral/app-graph-builder-OLKN3VTB.mjs.map +7 -0
- package/dist/lib/neutral/append-channel-message-J6DXDPBH.mjs +34 -0
- package/dist/lib/neutral/append-channel-message-J6DXDPBH.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +19 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/channel-backend-feed-FCXGAIEC.mjs +58 -0
- package/dist/lib/neutral/channel-backend-feed-FCXGAIEC.mjs.map +7 -0
- package/dist/lib/neutral/chunk-AWAQTEU6.mjs +10 -0
- package/dist/lib/neutral/chunk-AWAQTEU6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-HJHK5O6F.mjs +109 -0
- package/dist/lib/neutral/chunk-HJHK5O6F.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-OOC6EQ7X.mjs +36 -0
- package/dist/lib/neutral/chunk-OOC6EQ7X.mjs.map +7 -0
- package/dist/lib/neutral/chunk-P4RSGFS4.mjs +69 -0
- package/dist/lib/neutral/chunk-P4RSGFS4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-SZXFLBZL.mjs +8 -0
- package/dist/lib/neutral/chunk-SZXFLBZL.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +93 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +13 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/create-channel-UW2LSL4G.mjs +41 -0
- package/dist/lib/neutral/create-channel-UW2LSL4G.mjs.map +7 -0
- package/dist/lib/neutral/create-object-RLCOUVAW.mjs +46 -0
- package/dist/lib/neutral/create-object-RLCOUVAW.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +11 -0
- package/dist/lib/neutral/index.mjs +34 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +10 -0
- package/dist/lib/neutral/navigation-resolver-4X4HCQYX.mjs +14 -0
- package/dist/lib/neutral/navigation-resolver-4X4HCQYX.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-RU6K2S4L.mjs +13 -0
- package/dist/lib/neutral/operation-handler-RU6K2S4L.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-G6KT7TSU.mjs +48 -0
- package/dist/lib/neutral/react-surface-G6KT7TSU.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +91 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +16 -0
- package/dist/types/src/ThreadPlugin.d.ts +3 -1
- package/dist/types/src/ThreadPlugin.d.ts.map +1 -1
- package/dist/types/src/ThreadPlugin.node.d.ts +4 -0
- package/dist/types/src/ThreadPlugin.node.d.ts.map +1 -0
- package/dist/types/src/ThreadPlugin.test.d.ts +2 -0
- package/dist/types/src/ThreadPlugin.test.d.ts.map +1 -0
- package/dist/types/src/ThreadPlugin.workerd.d.ts +4 -0
- package/dist/types/src/ThreadPlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/channel-backend-feed.d.ts +13 -0
- package/dist/types/src/capabilities/channel-backend-feed.d.ts.map +1 -0
- package/dist/types/src/capabilities/create-object.d.ts +11 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +12 -14
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/navigation-resolver.d.ts +6 -0
- package/dist/types/src/capabilities/navigation-resolver.d.ts.map +1 -0
- 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 +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/Chat/Chat.d.ts +43 -0
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -0
- package/dist/types/src/components/Chat/index.d.ts +2 -0
- package/dist/types/src/components/Chat/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -10
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/ChannelArticle/ChannelArticle.d.ts +19 -0
- package/dist/types/src/containers/ChannelArticle/ChannelArticle.d.ts.map +1 -0
- package/dist/types/src/containers/ChannelArticle/ChannelArticle.stories.d.ts +162 -0
- package/dist/types/src/containers/ChannelArticle/ChannelArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ChannelArticle/index.d.ts +2 -0
- package/dist/types/src/containers/ChannelArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ChannelCreatePanel/ChannelCreatePanel.d.ts +11 -0
- package/dist/types/src/containers/ChannelCreatePanel/ChannelCreatePanel.d.ts.map +1 -0
- package/dist/types/src/containers/ChannelCreatePanel/index.d.ts +2 -0
- package/dist/types/src/containers/ChannelCreatePanel/index.d.ts.map +1 -0
- package/dist/types/src/containers/ThreadArticle/ThreadArticle.d.ts +20 -0
- package/dist/types/src/containers/ThreadArticle/ThreadArticle.d.ts.map +1 -0
- package/dist/types/src/containers/ThreadArticle/ThreadArticle.stories.d.ts +162 -0
- package/dist/types/src/containers/ThreadArticle/ThreadArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ThreadArticle/index.d.ts +2 -0
- package/dist/types/src/containers/ThreadArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +5 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +1 -4
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useMessages.d.ts +4 -0
- package/dist/types/src/hooks/useMessages.d.ts.map +1 -0
- package/dist/types/src/hooks/useStatus.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 +3 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/append-channel-message.d.ts +5 -0
- package/dist/types/src/operations/append-channel-message.d.ts.map +1 -0
- package/dist/types/src/operations/create-channel.d.ts +5 -0
- package/dist/types/src/operations/create-channel.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/paths.d.ts +3 -0
- package/dist/types/src/paths.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +142 -72
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/ThreadCapabilities.d.ts +37 -0
- package/dist/types/src/types/ThreadCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/ThreadOperation.d.ts +91 -0
- package/dist/types/src/types/ThreadOperation.d.ts.map +1 -0
- package/dist/types/src/types/channel-backend.d.ts +16 -0
- package/dist/types/src/types/channel-backend.d.ts.map +1 -0
- package/dist/types/src/types/channel-backend.test.d.ts +2 -0
- package/dist/types/src/types/channel-backend.test.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +4 -20
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +108 -81
- package/src/ThreadPlugin.node.ts +26 -0
- package/src/ThreadPlugin.test.ts +27 -0
- package/src/ThreadPlugin.tsx +38 -144
- package/src/ThreadPlugin.workerd.ts +25 -0
- package/src/capabilities/app-graph-builder.ts +44 -174
- package/src/capabilities/channel-backend-feed.ts +60 -0
- package/src/capabilities/create-object.ts +46 -0
- package/src/capabilities/index.ts +11 -11
- package/src/capabilities/navigation-resolver.ts +18 -0
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +39 -79
- package/src/components/Chat/Chat.tsx +119 -0
- package/src/components/Chat/index.ts +5 -0
- package/src/components/index.ts +1 -14
- package/src/containers/ChannelArticle/ChannelArticle.stories.tsx +108 -0
- package/src/containers/ChannelArticle/ChannelArticle.tsx +83 -0
- package/src/containers/ChannelArticle/index.ts +5 -0
- package/src/containers/ChannelCreatePanel/ChannelCreatePanel.tsx +52 -0
- package/src/containers/ChannelCreatePanel/index.ts +5 -0
- package/src/containers/ThreadArticle/ThreadArticle.stories.tsx +86 -0
- package/src/containers/ThreadArticle/ThreadArticle.tsx +75 -0
- package/src/containers/ThreadArticle/index.ts +5 -0
- package/src/containers/index.ts +9 -0
- package/src/hooks/index.ts +1 -4
- package/src/hooks/useMessages.ts +37 -0
- package/src/index.ts +4 -4
- package/src/meta.ts +27 -9
- package/src/operations/append-channel-message.ts +31 -0
- package/src/operations/create-channel.ts +30 -0
- package/src/operations/index.ts +10 -0
- package/src/paths.ts +10 -0
- package/src/plugin.ts +11 -0
- package/src/translations.ts +75 -73
- package/src/types/ThreadCapabilities.ts +47 -0
- package/src/types/ThreadOperation.ts +49 -0
- package/src/types/channel-backend.test.ts +48 -0
- package/src/types/channel-backend.ts +54 -0
- package/src/types/index.ts +3 -2
- package/src/util.ts +35 -18
- package/src/vite-env.d.ts +10 -0
- package/dist/lib/browser/ChannelContainer-O2SFQJU7.mjs +0 -16
- package/dist/lib/browser/ChatContainer-PVT3DUZJ.mjs +0 -15
- package/dist/lib/browser/app-graph-builder-AF3M7UWN.mjs +0 -171
- package/dist/lib/browser/app-graph-builder-AF3M7UWN.mjs.map +0 -7
- package/dist/lib/browser/call-manager-XRRCAVLI.mjs +0 -24
- package/dist/lib/browser/call-manager-XRRCAVLI.mjs.map +0 -7
- package/dist/lib/browser/chunk-2CWJBXBH.mjs +0 -21
- package/dist/lib/browser/chunk-2CWJBXBH.mjs.map +0 -7
- package/dist/lib/browser/chunk-4APCDRSH.mjs +0 -18
- package/dist/lib/browser/chunk-4APCDRSH.mjs.map +0 -7
- package/dist/lib/browser/chunk-DW7JD64V.mjs +0 -137
- package/dist/lib/browser/chunk-DW7JD64V.mjs.map +0 -7
- package/dist/lib/browser/chunk-EV4JWI7L.mjs +0 -17
- package/dist/lib/browser/chunk-EV4JWI7L.mjs.map +0 -7
- package/dist/lib/browser/chunk-FY4ZRD5X.mjs +0 -367
- package/dist/lib/browser/chunk-FY4ZRD5X.mjs.map +0 -7
- package/dist/lib/browser/chunk-GERVMFQW.mjs +0 -31
- package/dist/lib/browser/chunk-GERVMFQW.mjs.map +0 -7
- package/dist/lib/browser/chunk-J3JO5NWO.mjs +0 -477
- package/dist/lib/browser/chunk-J3JO5NWO.mjs.map +0 -7
- package/dist/lib/browser/chunk-JGKMMI65.mjs +0 -56
- package/dist/lib/browser/chunk-JGKMMI65.mjs.map +0 -7
- package/dist/lib/browser/chunk-TUFWPOVS.mjs +0 -1698
- package/dist/lib/browser/chunk-TUFWPOVS.mjs.map +0 -7
- package/dist/lib/browser/chunk-X5PIP5YR.mjs +0 -149
- package/dist/lib/browser/chunk-X5PIP5YR.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZJ7QBXK6.mjs +0 -984
- package/dist/lib/browser/chunk-ZJ7QBXK6.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -302
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-DCY4P4OX.mjs +0 -369
- package/dist/lib/browser/intent-resolver-DCY4P4OX.mjs.map +0 -7
- package/dist/lib/browser/markdown-WZSXCEZJ.mjs +0 -169
- package/dist/lib/browser/markdown-WZSXCEZJ.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-root-QXPALOUQ.mjs +0 -28
- package/dist/lib/browser/react-root-QXPALOUQ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-PYAMIADB.mjs +0 -109
- package/dist/lib/browser/react-surface-PYAMIADB.mjs.map +0 -7
- package/dist/lib/browser/settings-AC6YSASL.mjs +0 -22
- package/dist/lib/browser/settings-AC6YSASL.mjs.map +0 -7
- package/dist/lib/browser/state-2T4KDWBX.mjs +0 -34
- package/dist/lib/browser/state-2T4KDWBX.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -16
- package/dist/lib/node-esm/ChannelContainer-B2ZGAE4P.mjs +0 -17
- package/dist/lib/node-esm/ChatContainer-2CT4PJ7I.mjs +0 -16
- package/dist/lib/node-esm/app-graph-builder-OLSJVCWY.mjs +0 -172
- package/dist/lib/node-esm/app-graph-builder-OLSJVCWY.mjs.map +0 -7
- package/dist/lib/node-esm/call-manager-EI7FXRAU.mjs +0 -25
- package/dist/lib/node-esm/call-manager-EI7FXRAU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4TME3BR4.mjs +0 -1699
- package/dist/lib/node-esm/chunk-4TME3BR4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-57XR3LEF.mjs +0 -33
- package/dist/lib/node-esm/chunk-57XR3LEF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6CRHHOST.mjs +0 -23
- package/dist/lib/node-esm/chunk-6CRHHOST.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BF4UKS55.mjs +0 -368
- package/dist/lib/node-esm/chunk-BF4UKS55.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GRLRWTRU.mjs +0 -19
- package/dist/lib/node-esm/chunk-GRLRWTRU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PYTVBN5J.mjs +0 -19
- package/dist/lib/node-esm/chunk-PYTVBN5J.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QBHKLWGR.mjs +0 -58
- package/dist/lib/node-esm/chunk-QBHKLWGR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SED3O2XO.mjs +0 -150
- package/dist/lib/node-esm/chunk-SED3O2XO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VNG6M2IY.mjs +0 -478
- package/dist/lib/node-esm/chunk-VNG6M2IY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XVKWHTH4.mjs +0 -138
- package/dist/lib/node-esm/chunk-XVKWHTH4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YIDU3DXK.mjs +0 -985
- package/dist/lib/node-esm/chunk-YIDU3DXK.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -303
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-QGTPU6QB.mjs +0 -370
- package/dist/lib/node-esm/intent-resolver-QGTPU6QB.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-3MZXUGUA.mjs +0 -170
- package/dist/lib/node-esm/markdown-3MZXUGUA.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-root-7ZFJYVUZ.mjs +0 -29
- package/dist/lib/node-esm/react-root-7ZFJYVUZ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-UJFCSFNO.mjs +0 -110
- package/dist/lib/node-esm/react-surface-UJFCSFNO.mjs.map +0 -7
- package/dist/lib/node-esm/settings-N52O7MLS.mjs +0 -23
- package/dist/lib/node-esm/settings-N52O7MLS.mjs.map +0 -7
- package/dist/lib/node-esm/state-62TQKQVB.mjs +0 -35
- package/dist/lib/node-esm/state-62TQKQVB.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -17
- package/dist/types/src/calls/call-manager.d.ts +0 -77
- package/dist/types/src/calls/call-manager.d.ts.map +0 -1
- package/dist/types/src/calls/call-swarm-synchronizer.d.ts +0 -66
- package/dist/types/src/calls/call-swarm-synchronizer.d.ts.map +0 -1
- package/dist/types/src/calls/index.d.ts +0 -7
- package/dist/types/src/calls/index.d.ts.map +0 -1
- package/dist/types/src/calls/media-manager.d.ts +0 -60
- package/dist/types/src/calls/media-manager.d.ts.map +0 -1
- package/dist/types/src/calls/speaking-monitor.d.ts +0 -24
- package/dist/types/src/calls/speaking-monitor.d.ts.map +0 -1
- package/dist/types/src/calls/types.d.ts +0 -45
- package/dist/types/src/calls/types.d.ts.map +0 -1
- package/dist/types/src/calls/util/audio.d.ts +0 -6
- package/dist/types/src/calls/util/audio.d.ts.map +0 -1
- package/dist/types/src/calls/util/calls-service.d.ts +0 -75
- package/dist/types/src/calls/util/calls-service.d.ts.map +0 -1
- package/dist/types/src/calls/util/history-cache.d.ts +0 -11
- package/dist/types/src/calls/util/history-cache.d.ts.map +0 -1
- package/dist/types/src/calls/util/index.d.ts +0 -5
- package/dist/types/src/calls/util/index.d.ts.map +0 -1
- package/dist/types/src/calls/util/media.d.ts +0 -6
- package/dist/types/src/calls/util/media.d.ts.map +0 -1
- package/dist/types/src/calls/util/stub-media-streams.d.ts +0 -18
- package/dist/types/src/calls/util/stub-media-streams.d.ts.map +0 -1
- package/dist/types/src/calls/util/task-scheduling.d.ts +0 -17
- package/dist/types/src/calls/util/task-scheduling.d.ts.map +0 -1
- package/dist/types/src/calls-service.stories.d.ts +0 -22
- package/dist/types/src/calls-service.stories.d.ts.map +0 -1
- package/dist/types/src/capabilities/call-manager.d.ts +0 -5
- package/dist/types/src/capabilities/call-manager.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -27
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/markdown.d.ts +0 -4
- package/dist/types/src/capabilities/markdown.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-root.d.ts +0 -7
- package/dist/types/src/capabilities/react-root.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings.d.ts +0 -4
- package/dist/types/src/capabilities/settings.d.ts.map +0 -1
- package/dist/types/src/capabilities/state.d.ts +0 -7
- package/dist/types/src/capabilities/state.d.ts.map +0 -1
- package/dist/types/src/components/Call/Call.d.ts +0 -17
- package/dist/types/src/components/Call/Call.d.ts.map +0 -1
- package/dist/types/src/components/Call/Toolbar.d.ts +0 -16
- package/dist/types/src/components/Call/Toolbar.d.ts.map +0 -1
- package/dist/types/src/components/Call/index.d.ts +0 -3
- package/dist/types/src/components/Call/index.d.ts.map +0 -1
- package/dist/types/src/components/CallDebugPanel.d.ts +0 -8
- package/dist/types/src/components/CallDebugPanel.d.ts.map +0 -1
- package/dist/types/src/components/CallSidebar.d.ts +0 -4
- package/dist/types/src/components/CallSidebar.d.ts.map +0 -1
- package/dist/types/src/components/ChannelContainer.d.ts +0 -14
- package/dist/types/src/components/ChannelContainer.d.ts.map +0 -1
- package/dist/types/src/components/ChannelContainer.stories.d.ts +0 -10
- package/dist/types/src/components/ChannelContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/Chat.stories.d.ts +0 -7
- package/dist/types/src/components/Chat.stories.d.ts.map +0 -1
- package/dist/types/src/components/ChatContainer.d.ts +0 -17
- package/dist/types/src/components/ChatContainer.d.ts.map +0 -1
- package/dist/types/src/components/Comments.stories.d.ts +0 -6
- package/dist/types/src/components/Comments.stories.d.ts.map +0 -1
- package/dist/types/src/components/CommentsContainer.d.ts +0 -13
- package/dist/types/src/components/CommentsContainer.d.ts.map +0 -1
- package/dist/types/src/components/CommentsThreadContainer.d.ts +0 -14
- package/dist/types/src/components/CommentsThreadContainer.d.ts.map +0 -1
- package/dist/types/src/components/Lobby/Lobby.d.ts +0 -15
- package/dist/types/src/components/Lobby/Lobby.d.ts.map +0 -1
- package/dist/types/src/components/Lobby/index.d.ts +0 -2
- package/dist/types/src/components/Lobby/index.d.ts.map +0 -1
- package/dist/types/src/components/Media/AudioStream.d.ts +0 -6
- package/dist/types/src/components/Media/AudioStream.d.ts.map +0 -1
- package/dist/types/src/components/Media/VideoObject.d.ts +0 -15
- package/dist/types/src/components/Media/VideoObject.d.ts.map +0 -1
- package/dist/types/src/components/Media/VideoObject.stories.d.ts +0 -8
- package/dist/types/src/components/Media/VideoObject.stories.d.ts.map +0 -1
- package/dist/types/src/components/Media/index.d.ts +0 -3
- package/dist/types/src/components/Media/index.d.ts.map +0 -1
- package/dist/types/src/components/MessageContainer.d.ts +0 -11
- package/dist/types/src/components/MessageContainer.d.ts.map +0 -1
- package/dist/types/src/components/Participant/Participant.d.ts +0 -6
- package/dist/types/src/components/Participant/Participant.d.ts.map +0 -1
- package/dist/types/src/components/Participant/ParticipantGrid.d.ts +0 -11
- package/dist/types/src/components/Participant/ParticipantGrid.d.ts.map +0 -1
- package/dist/types/src/components/Participant/index.d.ts +0 -3
- package/dist/types/src/components/Participant/index.d.ts.map +0 -1
- package/dist/types/src/components/ResponsiveGrid/ResponsiveContainer.d.ts +0 -12
- package/dist/types/src/components/ResponsiveGrid/ResponsiveContainer.d.ts.map +0 -1
- package/dist/types/src/components/ResponsiveGrid/ResponsiveContainer.stories.d.ts +0 -10
- package/dist/types/src/components/ResponsiveGrid/ResponsiveContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/ResponsiveGrid/ResponsiveGrid.d.ts +0 -32
- package/dist/types/src/components/ResponsiveGrid/ResponsiveGrid.d.ts.map +0 -1
- package/dist/types/src/components/ResponsiveGrid/ResponsiveGrid.stories.d.ts +0 -23
- package/dist/types/src/components/ResponsiveGrid/ResponsiveGrid.stories.d.ts.map +0 -1
- package/dist/types/src/components/ResponsiveGrid/ResponsiveGridItem.d.ts +0 -21
- package/dist/types/src/components/ResponsiveGrid/ResponsiveGridItem.d.ts.map +0 -1
- package/dist/types/src/components/ResponsiveGrid/index.d.ts +0 -4
- package/dist/types/src/components/ResponsiveGrid/index.d.ts.map +0 -1
- package/dist/types/src/components/ThreadComplementary.d.ts +0 -5
- package/dist/types/src/components/ThreadComplementary.d.ts.map +0 -1
- package/dist/types/src/components/ThreadSettings.d.ts +0 -6
- package/dist/types/src/components/ThreadSettings.d.ts.map +0 -1
- package/dist/types/src/components/command-extension.d.ts +0 -3
- package/dist/types/src/components/command-extension.d.ts.map +0 -1
- package/dist/types/src/components/testing.d.ts +0 -4
- package/dist/types/src/components/testing.d.ts.map +0 -1
- package/dist/types/src/extensions/index.d.ts +0 -2
- package/dist/types/src/extensions/index.d.ts.map +0 -1
- package/dist/types/src/extensions/threads.d.ts +0 -9
- package/dist/types/src/extensions/threads.d.ts.map +0 -1
- package/dist/types/src/hooks/analytics.d.ts +0 -4
- package/dist/types/src/hooks/analytics.d.ts.map +0 -1
- package/dist/types/src/hooks/useDebugMode.d.ts +0 -2
- package/dist/types/src/hooks/useDebugMode.d.ts.map +0 -1
- package/dist/types/src/hooks/useInaudibleAudioStreamTrack.d.ts +0 -2
- package/dist/types/src/hooks/useInaudibleAudioStreamTrack.d.ts.map +0 -1
- package/dist/types/src/hooks/useVideoStreamTrack.d.ts +0 -3
- package/dist/types/src/hooks/useVideoStreamTrack.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -2
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/dist/types/src/testing/stories.d.ts +0 -2
- package/dist/types/src/testing/stories.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -164
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -388
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/calls/call-manager.ts +0 -246
- package/src/calls/call-swarm-synchronizer.ts +0 -350
- package/src/calls/index.ts +0 -10
- package/src/calls/media-manager.ts +0 -349
- package/src/calls/speaking-monitor.ts +0 -85
- package/src/calls/types.ts +0 -70
- package/src/calls/util/audio.ts +0 -58
- package/src/calls/util/calls-service.ts +0 -531
- package/src/calls/util/history-cache.ts +0 -27
- package/src/calls/util/index.ts +0 -8
- package/src/calls/util/media.ts +0 -52
- package/src/calls/util/stub-media-streams.ts +0 -70
- package/src/calls/util/task-scheduling.ts +0 -92
- package/src/calls-service.stories.tsx +0 -216
- package/src/capabilities/call-manager.ts +0 -20
- package/src/capabilities/capabilities.ts +0 -33
- package/src/capabilities/intent-resolver.ts +0 -315
- package/src/capabilities/markdown.ts +0 -69
- package/src/capabilities/react-root.tsx +0 -17
- package/src/capabilities/settings.ts +0 -19
- package/src/capabilities/state.ts +0 -26
- package/src/components/Call/Call.tsx +0 -89
- package/src/components/Call/Toolbar.tsx +0 -182
- package/src/components/Call/index.ts +0 -6
- package/src/components/CallDebugPanel.tsx +0 -115
- package/src/components/CallSidebar.tsx +0 -18
- package/src/components/ChannelContainer.stories.tsx +0 -59
- package/src/components/ChannelContainer.tsx +0 -201
- package/src/components/Chat.stories.tsx +0 -89
- package/src/components/ChatContainer.tsx +0 -142
- package/src/components/Comments.stories.tsx +0 -93
- package/src/components/CommentsContainer.tsx +0 -72
- package/src/components/CommentsThreadContainer.tsx +0 -168
- package/src/components/Lobby/Lobby.tsx +0 -119
- package/src/components/Lobby/index.ts +0 -5
- package/src/components/Media/AudioStream.tsx +0 -67
- package/src/components/Media/VideoObject.stories.tsx +0 -53
- package/src/components/Media/VideoObject.tsx +0 -58
- package/src/components/Media/index.ts +0 -6
- package/src/components/MessageContainer.tsx +0 -152
- package/src/components/Participant/Participant.tsx +0 -57
- package/src/components/Participant/ParticipantGrid.tsx +0 -89
- package/src/components/Participant/index.ts +0 -6
- package/src/components/ResponsiveGrid/ResponsiveContainer.stories.tsx +0 -55
- package/src/components/ResponsiveGrid/ResponsiveContainer.tsx +0 -31
- package/src/components/ResponsiveGrid/ResponsiveGrid.stories.tsx +0 -157
- package/src/components/ResponsiveGrid/ResponsiveGrid.tsx +0 -341
- package/src/components/ResponsiveGrid/ResponsiveGridItem.tsx +0 -131
- package/src/components/ResponsiveGrid/index.ts +0 -7
- package/src/components/ThreadComplementary.tsx +0 -151
- package/src/components/ThreadSettings.tsx +0 -17
- package/src/components/command-extension.ts +0 -33
- package/src/components/testing.ts +0 -29
- package/src/extensions/index.ts +0 -5
- package/src/extensions/threads.ts +0 -126
- package/src/hooks/analytics.ts +0 -40
- package/src/hooks/useDebugMode.ts +0 -25
- package/src/hooks/useInaudibleAudioStreamTrack.tsx +0 -27
- package/src/hooks/useVideoStreamTrack.tsx +0 -33
- package/src/testing/index.ts +0 -5
- package/src/testing/stories.ts +0 -54
- package/src/types/schema.ts +0 -33
- package/src/types/types.ts +0 -119
- package/src/typings/peermetrics-webrtc-stats.d.ts +0 -30
- package/src/typings.d.ts +0 -8
- /package/dist/lib/{browser/ChannelContainer-O2SFQJU7.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{browser/types → neutral/hooks}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/types → neutral}/index.mjs.map +0 -0
- /package/dist/lib/{browser/ChatContainer-PVT3DUZJ.mjs.map → neutral/meta.mjs.map} +0 -0
- /package/dist/lib/{node-esm/ChannelContainer-B2ZGAE4P.mjs.map → neutral/operations/index.mjs.map} +0 -0
- /package/dist/lib/{node-esm/ChatContainer-2CT4PJ7I.mjs.map → neutral/types/index.mjs.map} +0 -0
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { computed } from '@preact/signals-core';
|
|
6
|
-
|
|
7
|
-
import { Event, synchronized } from '@dxos/async';
|
|
8
|
-
import { type Client } from '@dxos/client';
|
|
9
|
-
import { Resource } from '@dxos/context';
|
|
10
|
-
import { invariant } from '@dxos/invariant';
|
|
11
|
-
import { live } from '@dxos/live-object';
|
|
12
|
-
import { type Tracks } from '@dxos/protocols/proto/dxos/edge/calls';
|
|
13
|
-
import { isNonNullable } from '@dxos/util';
|
|
14
|
-
|
|
15
|
-
import { type CallState, CallSwarmSynchronizer } from './call-swarm-synchronizer';
|
|
16
|
-
import { MediaManager, type MediaState } from './media-manager';
|
|
17
|
-
import { type ActivityState, CALLS_URL, type EncodedTrackName, TrackNameCodec, type UserState } from './types';
|
|
18
|
-
|
|
19
|
-
export type GlobalState = {
|
|
20
|
-
call: CallState;
|
|
21
|
-
media: MediaState;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Top level manager for call state.
|
|
26
|
-
*/
|
|
27
|
-
export class CallManager extends Resource {
|
|
28
|
-
public readonly callStateUpdated = new Event<CallState>();
|
|
29
|
-
// TODO(wittjosiah): Consolidate isSpeaking into the MediaState type.
|
|
30
|
-
public readonly mediaStateUpdated = new Event<[MediaState, boolean]>();
|
|
31
|
-
public readonly left = new Event<string>();
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Live object state. Is changed on internal events.
|
|
35
|
-
* CAUTION: Do not change directly.
|
|
36
|
-
*/
|
|
37
|
-
private readonly _state = live<GlobalState>({
|
|
38
|
-
call: {},
|
|
39
|
-
media: { pulledAudioTracks: {}, pulledVideoStreams: {} },
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// TODO(wittjosiah): This shouldn't be necessary, live-object's signals should be granular.
|
|
43
|
-
private readonly _raisedHandSignal = computed(() => this._state.call.raisedHand ?? false);
|
|
44
|
-
private readonly _speakingSignal = computed(() => this._state.call.speaking ?? false);
|
|
45
|
-
private readonly _joinedSignal = computed(() => this._state.call.joined ?? false);
|
|
46
|
-
|
|
47
|
-
private readonly _swarmSynchronizer: CallSwarmSynchronizer;
|
|
48
|
-
private readonly _mediaManager: MediaManager;
|
|
49
|
-
|
|
50
|
-
/** @reactive */
|
|
51
|
-
get roomId(): string | undefined {
|
|
52
|
-
return this._state.call.roomId;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** @reactive */
|
|
56
|
-
get raisedHand(): boolean {
|
|
57
|
-
return this._raisedHandSignal.value;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/** @reactive */
|
|
61
|
-
get speaking(): boolean {
|
|
62
|
-
return this._speakingSignal.value;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** @reactive */
|
|
66
|
-
get joined(): boolean {
|
|
67
|
-
return this._joinedSignal.value;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** @reactive */
|
|
71
|
-
get self(): UserState {
|
|
72
|
-
return this._state.call.self ?? {};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** @reactive */
|
|
76
|
-
get tracks(): Tracks {
|
|
77
|
-
return this._state.call.tracks ?? {};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/** @reactive */
|
|
81
|
-
get users(): UserState[] {
|
|
82
|
-
return this._state.call.users ?? [];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** @reactive */
|
|
86
|
-
get media() {
|
|
87
|
-
return this._state.media;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/** @reactive */
|
|
91
|
-
get audioTracksToPlay(): MediaStreamTrack[] {
|
|
92
|
-
return (this._state.call.users ?? [])
|
|
93
|
-
.map((user) => (user.tracks?.audioEnabled ? user.tracks?.audio : undefined))
|
|
94
|
-
.filter(isNonNullable)
|
|
95
|
-
.map((track) => this._state.media.pulledAudioTracks[track as EncodedTrackName]?.track)
|
|
96
|
-
.filter(isNonNullable);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/** @reactive */
|
|
100
|
-
get state() {
|
|
101
|
-
return this._state;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/** @reactive */
|
|
105
|
-
getVideoStream(name?: EncodedTrackName): MediaStream | undefined {
|
|
106
|
-
return name ? this._state.media.pulledVideoStreams[name]?.stream : undefined;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/** @reactive */
|
|
110
|
-
getActivity(key: string): ActivityState | undefined {
|
|
111
|
-
return this._state.call.activities?.[key];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
setRoomId(roomId: string): void {
|
|
115
|
-
this._swarmSynchronizer._setRoomId(roomId);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
setSpeaking(speaking: boolean): void {
|
|
119
|
-
this._swarmSynchronizer.setSpeaking(speaking);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
setRaisedHand(raisedHand: boolean): void {
|
|
123
|
-
this._swarmSynchronizer.setRaisedHand(raisedHand);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
setActivity(key: string, payload: ActivityState['payload']): void {
|
|
127
|
-
this._swarmSynchronizer.setActivity(key, payload);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
turnAudioOn(): Promise<void> {
|
|
131
|
-
return this._mediaManager.turnAudioOn();
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
turnAudioOff(): Promise<void> {
|
|
135
|
-
return this._mediaManager.turnAudioOff();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
turnVideoOn(): Promise<void> {
|
|
139
|
-
return this._mediaManager.turnVideoOn();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
turnVideoOff(): Promise<void> {
|
|
143
|
-
return this._mediaManager.turnVideoOff();
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
turnScreenshareOn(): Promise<void> {
|
|
147
|
-
return this._mediaManager.turnScreenshareOn();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
turnScreenshareOff(): Promise<void> {
|
|
151
|
-
return this._mediaManager.turnScreenshareOff();
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// TODO(burdon): Can this be mocked?
|
|
155
|
-
constructor(private readonly _client: Client) {
|
|
156
|
-
super();
|
|
157
|
-
this._client.config.getOrThrow('runtime.services.edge.url');
|
|
158
|
-
const networkService = this._client.services.services.NetworkService;
|
|
159
|
-
invariant(networkService, 'network service not found');
|
|
160
|
-
this._swarmSynchronizer = new CallSwarmSynchronizer({ networkService });
|
|
161
|
-
this._mediaManager = new MediaManager();
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
protected override async _open(): Promise<void> {
|
|
165
|
-
await this._mediaManager.open();
|
|
166
|
-
await this._swarmSynchronizer.open();
|
|
167
|
-
const subscription = this._client.halo.identity.subscribe((identity) => {
|
|
168
|
-
if (identity) {
|
|
169
|
-
this._swarmSynchronizer._setIdentity(identity);
|
|
170
|
-
}
|
|
171
|
-
if (this._client.halo.device) {
|
|
172
|
-
this._swarmSynchronizer._setDevice(this._client.halo.device);
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
this._ctx.onDispose(() => subscription.unsubscribe());
|
|
176
|
-
|
|
177
|
-
this._swarmSynchronizer.stateUpdated.on(this._ctx, (state) => this._onCallStateUpdated(state));
|
|
178
|
-
this._mediaManager.stateUpdated.on(this._ctx, (state) => this._onMediaStateUpdated(state));
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
protected override async _close(): Promise<void> {
|
|
182
|
-
await this._swarmSynchronizer.leave();
|
|
183
|
-
await this._swarmSynchronizer.close();
|
|
184
|
-
await this._mediaManager.close();
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
async peek(roomId: string): Promise<number> {
|
|
188
|
-
const peers = await this._swarmSynchronizer.querySwarm(roomId);
|
|
189
|
-
return peers.length;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// TODO(mykola): Reconcile with _swarmSynchronizer.state.joined.
|
|
193
|
-
@synchronized
|
|
194
|
-
async join(): Promise<void> {
|
|
195
|
-
this._swarmSynchronizer.setJoined(true);
|
|
196
|
-
await this._swarmSynchronizer.join();
|
|
197
|
-
await this._mediaManager.join({
|
|
198
|
-
iceServers: this._client.config.get('runtime.services.ice'),
|
|
199
|
-
apiBase: `${CALLS_URL}/api/calls`,
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
@synchronized
|
|
204
|
-
async leave(): Promise<void> {
|
|
205
|
-
this._swarmSynchronizer.setJoined(false);
|
|
206
|
-
await this._swarmSynchronizer.leave();
|
|
207
|
-
await this._mediaManager.leave();
|
|
208
|
-
this.roomId && this.left.emit(this.roomId);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
private _onCallStateUpdated(state: CallState): void {
|
|
212
|
-
const tracksToPull = state.users
|
|
213
|
-
?.filter((user) => user.joined && user.id !== state.self?.id)
|
|
214
|
-
?.flatMap((user) => [user.tracks?.video, user.tracks?.audio, user.tracks?.screenshare])
|
|
215
|
-
.filter(isNonNullable);
|
|
216
|
-
this._mediaManager._schedulePullTracks(tracksToPull as EncodedTrackName[]);
|
|
217
|
-
|
|
218
|
-
this.callStateUpdated.emit(state);
|
|
219
|
-
this._updateState();
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
private _onMediaStateUpdated(state: MediaState): void {
|
|
223
|
-
this._swarmSynchronizer.setTracks({
|
|
224
|
-
video: state.pushedVideoTrack ? TrackNameCodec.encode(state.pushedVideoTrack) : undefined,
|
|
225
|
-
audio: state.pushedAudioTrack ? TrackNameCodec.encode(state.pushedAudioTrack) : undefined,
|
|
226
|
-
screenshare: state.pushedScreenshareTrack ? TrackNameCodec.encode(state.pushedScreenshareTrack) : undefined,
|
|
227
|
-
videoEnabled: state.videoEnabled,
|
|
228
|
-
audioEnabled: state.audioEnabled,
|
|
229
|
-
screenshareEnabled: state.screenshareEnabled,
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
const isSpeaking = this._mediaManager.isSpeaking ?? false;
|
|
233
|
-
this._swarmSynchronizer.setSpeaking(isSpeaking);
|
|
234
|
-
|
|
235
|
-
this.mediaStateUpdated.emit([state, isSpeaking]);
|
|
236
|
-
this._updateState();
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Only this method is allowed to change state.
|
|
241
|
-
*/
|
|
242
|
-
private _updateState(): void {
|
|
243
|
-
this._state.call = this._swarmSynchronizer._getState();
|
|
244
|
-
this._state.media = this._mediaManager._getState();
|
|
245
|
-
}
|
|
246
|
-
}
|
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import md5Hex from 'md5-hex';
|
|
6
|
-
|
|
7
|
-
import { DeferredTask, Event, scheduleTaskInterval, synchronized } from '@dxos/async';
|
|
8
|
-
import { type Identity } from '@dxos/client/halo';
|
|
9
|
-
import { Context, Resource } from '@dxos/context';
|
|
10
|
-
import { generateName } from '@dxos/display-name';
|
|
11
|
-
import { invariant } from '@dxos/invariant';
|
|
12
|
-
import { PublicKey } from '@dxos/keys';
|
|
13
|
-
import { log } from '@dxos/log';
|
|
14
|
-
import { buf } from '@dxos/protocols/buf';
|
|
15
|
-
import { ActivitySchema } from '@dxos/protocols/buf/dxos/edge/calls_pb';
|
|
16
|
-
import { type Device, type NetworkService } from '@dxos/protocols/proto/dxos/client/services';
|
|
17
|
-
import { ConnectionState, type SwarmResponse } from '@dxos/protocols/proto/dxos/edge/messenger';
|
|
18
|
-
import { isNonNullable } from '@dxos/util';
|
|
19
|
-
|
|
20
|
-
import { type ActivityState, type UserState, codec } from './types';
|
|
21
|
-
|
|
22
|
-
export type CallState = {
|
|
23
|
-
/**
|
|
24
|
-
* Room id.
|
|
25
|
-
*/
|
|
26
|
-
roomId?: string;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* All users states in the swarm.
|
|
30
|
-
*/
|
|
31
|
-
users?: UserState[];
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Self state inside swarm.
|
|
35
|
-
*/
|
|
36
|
-
self?: UserState;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Swarm synchronized CRDT transcription. Last write wins.
|
|
40
|
-
*/
|
|
41
|
-
activities?: Record<string, ActivityState>;
|
|
42
|
-
|
|
43
|
-
raisedHand?: boolean;
|
|
44
|
-
speaking?: boolean;
|
|
45
|
-
joined?: boolean;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Tracks pushed by self to calls service.
|
|
49
|
-
*/
|
|
50
|
-
tracks?: UserState['tracks'];
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export type CallSwarmSynchronizerParams = { networkService: NetworkService };
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Period for peer to reconnect to the call swarm gracefully if connection was lost abruptly.
|
|
57
|
-
*/
|
|
58
|
-
const DISCONNECTED_ABRUPT_TIMEOUT = 10_000; // [ms]
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Sends and receives state to/from Swarm network.
|
|
62
|
-
*/
|
|
63
|
-
export class CallSwarmSynchronizer extends Resource {
|
|
64
|
-
public readonly stateUpdated = new Event<CallState>();
|
|
65
|
-
|
|
66
|
-
private readonly _state: CallState = { activities: {} };
|
|
67
|
-
private readonly _networkService: NetworkService;
|
|
68
|
-
private _lastSwarmEvent?: SwarmResponse = undefined;
|
|
69
|
-
private _reconcileSwarmStateTask?: DeferredTask = undefined;
|
|
70
|
-
|
|
71
|
-
private _identityKey?: string = undefined;
|
|
72
|
-
private _deviceKey?: string = undefined;
|
|
73
|
-
private _displayName?: string = undefined;
|
|
74
|
-
|
|
75
|
-
private _swarmCtx?: Context = undefined;
|
|
76
|
-
|
|
77
|
-
private _sendStateTask?: DeferredTask = undefined;
|
|
78
|
-
|
|
79
|
-
constructor({ networkService }: CallSwarmSynchronizerParams) {
|
|
80
|
-
super();
|
|
81
|
-
this._networkService = networkService;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* @internal
|
|
86
|
-
*/
|
|
87
|
-
_getState(): CallState {
|
|
88
|
-
return this._state;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
setRaisedHand(raisedHand: boolean): void {
|
|
92
|
-
if (this._state.raisedHand === raisedHand) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
this._state.raisedHand = raisedHand;
|
|
97
|
-
this._notifyAndSchedule();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
setSpeaking(speaking: boolean): void {
|
|
101
|
-
if (this._state.speaking === speaking) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
this._state.speaking = speaking;
|
|
106
|
-
this._notifyAndSchedule();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
setJoined(joined: boolean): void {
|
|
110
|
-
if (this._state.joined === joined) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
this._state.joined = joined;
|
|
115
|
-
this._notifyAndSchedule();
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
setTracks(tracks: UserState['tracks']): void {
|
|
119
|
-
this._state.tracks = { ...this._state.tracks, ...tracks };
|
|
120
|
-
this._notifyAndSchedule();
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
setActivity(key: string, payload: ActivityState['payload']): void {
|
|
124
|
-
const lamportTimestamp = LamportTimestampCrdt.increment(
|
|
125
|
-
this._state.activities?.[key]?.lamportTimestamp ?? { id: this._deviceKey },
|
|
126
|
-
);
|
|
127
|
-
this._state.activities![key] = { lamportTimestamp, payload };
|
|
128
|
-
|
|
129
|
-
this._notifyAndSchedule();
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* @internal
|
|
134
|
-
*/
|
|
135
|
-
_setIdentity(identity: Identity): void {
|
|
136
|
-
this._identityKey = identity.identityKey.toHex();
|
|
137
|
-
this._displayName = identity.profile?.displayName ?? generateName(identity.identityKey.toHex());
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* @internal
|
|
142
|
-
*/
|
|
143
|
-
_setDevice(device: Device): void {
|
|
144
|
-
this._deviceKey = device.deviceKey.toHex();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* @internal
|
|
149
|
-
*/
|
|
150
|
-
_setRoomId(roomId?: string): void {
|
|
151
|
-
if (this._swarmCtx) {
|
|
152
|
-
log.verbose('joined to a different room', { roomId });
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
this._state.roomId = roomId;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
protected override async _open(): Promise<void> {
|
|
160
|
-
this._sendStateTask = new DeferredTask(this._ctx, async () => {
|
|
161
|
-
await this._sendState();
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
this._reconcileSwarmStateTask = new DeferredTask(this._ctx, async () => {
|
|
165
|
-
await this._reconcileSwarmState();
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
protected override async _close(): Promise<void> {
|
|
170
|
-
this._sendStateTask = undefined;
|
|
171
|
-
this._reconcileSwarmStateTask = undefined;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
@synchronized
|
|
175
|
-
async join(): Promise<void> {
|
|
176
|
-
invariant(this._state.roomId);
|
|
177
|
-
invariant(!this._swarmCtx, 'Already joined');
|
|
178
|
-
|
|
179
|
-
this._swarmCtx = new Context();
|
|
180
|
-
const topic = getTopic(this._state.roomId);
|
|
181
|
-
log('joining swarm', { topic, peer: { identityKey: this._identityKey, peerKey: this._deviceKey } });
|
|
182
|
-
const stream = this._networkService.subscribeSwarmState({ topic });
|
|
183
|
-
stream.subscribe((event) => this._processSwarmEvent(event));
|
|
184
|
-
|
|
185
|
-
const cleanup = () => {
|
|
186
|
-
void stream.close();
|
|
187
|
-
if (topic && this._identityKey && this._deviceKey) {
|
|
188
|
-
log('leaving swarm', { topic, peer: { identityKey: this._identityKey, peerKey: this._deviceKey } });
|
|
189
|
-
void this._networkService
|
|
190
|
-
.leaveSwarm({
|
|
191
|
-
topic,
|
|
192
|
-
peer: { identityKey: this._identityKey, peerKey: this._deviceKey },
|
|
193
|
-
})
|
|
194
|
-
.catch((err) => log.catch(err));
|
|
195
|
-
}
|
|
196
|
-
window.removeEventListener('beforeunload', cleanup);
|
|
197
|
-
};
|
|
198
|
-
window.addEventListener('beforeunload', cleanup);
|
|
199
|
-
this._swarmCtx.onDispose(cleanup);
|
|
200
|
-
|
|
201
|
-
this._notifyAndSchedule();
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
@synchronized
|
|
205
|
-
async leave(): Promise<void> {
|
|
206
|
-
if (!this._swarmCtx) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
await this._swarmCtx.dispose();
|
|
211
|
-
this._swarmCtx = undefined;
|
|
212
|
-
|
|
213
|
-
this._state.users = undefined;
|
|
214
|
-
this._state.self = undefined;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
async querySwarm(roomId: string) {
|
|
218
|
-
const topic = getTopic(roomId);
|
|
219
|
-
const swarm = await this._networkService.querySwarm({ topic });
|
|
220
|
-
return swarm.peers ?? [];
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Notify and schedule send state task.
|
|
225
|
-
*/
|
|
226
|
-
private _notifyAndSchedule(): void {
|
|
227
|
-
this.stateUpdated.emit(this._state);
|
|
228
|
-
if (this._state.joined) {
|
|
229
|
-
this._sendStateTask?.schedule();
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
private async _sendState(): Promise<void> {
|
|
234
|
-
if (!this._state.roomId || !this._identityKey || !this._deviceKey || !this._state.joined) {
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const state: UserState = {
|
|
239
|
-
...this._state,
|
|
240
|
-
id: this._deviceKey,
|
|
241
|
-
name: this._displayName,
|
|
242
|
-
activities: this._state.activities
|
|
243
|
-
? Object.fromEntries(
|
|
244
|
-
Object.entries(this._state.activities).map(([key, activity]) => [
|
|
245
|
-
key,
|
|
246
|
-
buf.create(ActivitySchema, activity),
|
|
247
|
-
]),
|
|
248
|
-
)
|
|
249
|
-
: {},
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
await this._networkService.joinSwarm({
|
|
253
|
-
topic: getTopic(this._state.roomId),
|
|
254
|
-
peer: {
|
|
255
|
-
identityKey: this._identityKey,
|
|
256
|
-
peerKey: this._deviceKey,
|
|
257
|
-
state: codec.encode(state),
|
|
258
|
-
},
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
private _processSwarmEvent(swarmEvent: SwarmResponse): void {
|
|
263
|
-
if (!this._state.joined) {
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
this._lastSwarmEvent = swarmEvent;
|
|
268
|
-
this._reconcileSwarmStateTask!.schedule();
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
private async _reconcileSwarmState(): Promise<void> {
|
|
272
|
-
const swarmEvent = this._lastSwarmEvent;
|
|
273
|
-
invariant(swarmEvent);
|
|
274
|
-
// We include inactive peers that were disconnected abruptly and have not yet reconnected to not drop them from call.
|
|
275
|
-
// Websocket connection could be unstable and we include graceful period for peers to reconnect.
|
|
276
|
-
const peers = [
|
|
277
|
-
...(swarmEvent.peers ?? []),
|
|
278
|
-
...(swarmEvent.inactivePeers ?? []).filter(
|
|
279
|
-
({ disconnected, connectionState }) =>
|
|
280
|
-
connectionState === ConnectionState.DISCONNECTED_ABRUPT &&
|
|
281
|
-
disconnected &&
|
|
282
|
-
disconnected > Date.now() - DISCONNECTED_ABRUPT_TIMEOUT,
|
|
283
|
-
),
|
|
284
|
-
].sort((peer1, peer2) => peer1.peerKey.localeCompare(peer2.peerKey));
|
|
285
|
-
const users = peers
|
|
286
|
-
.map((peer) => {
|
|
287
|
-
try {
|
|
288
|
-
return codec.decode(peer.state!);
|
|
289
|
-
} catch (error) {
|
|
290
|
-
log.error('error decoding peer state', { error, peer });
|
|
291
|
-
return undefined;
|
|
292
|
-
}
|
|
293
|
-
})
|
|
294
|
-
.filter(isNonNullable);
|
|
295
|
-
this._state.users = users;
|
|
296
|
-
this._state.self = users.find((user) => user.id === this._deviceKey);
|
|
297
|
-
log('reconciling swarm state', { users });
|
|
298
|
-
if (users.length === 0) {
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
const activityKeys = new Set<string>(users.flatMap((user) => Object.keys(user.activities)));
|
|
303
|
-
[...activityKeys].forEach((key) => {
|
|
304
|
-
const activities = users.map((user) => user.activities?.[key]).filter(isNonNullable);
|
|
305
|
-
const lastActivity = LamportTimestampCrdt.getLastState(activities);
|
|
306
|
-
if (
|
|
307
|
-
lastActivity &&
|
|
308
|
-
lastActivity.lamportTimestamp!.version! > (this._state.activities![key]?.lamportTimestamp?.version ?? 0)
|
|
309
|
-
) {
|
|
310
|
-
this._state.activities![key] = lastActivity;
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
this.stateUpdated.emit(this._state);
|
|
314
|
-
|
|
315
|
-
// Schedule next reconcile if there are inactive peer to drop them after timeout.
|
|
316
|
-
if (peers.some((peer) => peer.connectionState !== ConnectionState.CONNECTED)) {
|
|
317
|
-
scheduleTaskInterval(
|
|
318
|
-
this._ctx,
|
|
319
|
-
async () => this._reconcileSwarmStateTask!.schedule(),
|
|
320
|
-
Math.min(DISCONNECTED_ABRUPT_TIMEOUT / 2, 1000),
|
|
321
|
-
);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
type LamportTimestamp = ActivityState['lamportTimestamp'];
|
|
327
|
-
|
|
328
|
-
// TODO(mykola): Factor out.
|
|
329
|
-
class LamportTimestampCrdt {
|
|
330
|
-
static getLastState<T extends { lamportTimestamp?: LamportTimestamp }>(states: T[]): T | undefined {
|
|
331
|
-
const maxTimestamp = Math.max(...states.map((state) => state.lamportTimestamp?.version ?? 0));
|
|
332
|
-
const sortedStates = states
|
|
333
|
-
.filter(
|
|
334
|
-
(state) =>
|
|
335
|
-
state.lamportTimestamp && state.lamportTimestamp.version === maxTimestamp && state.lamportTimestamp.id,
|
|
336
|
-
)
|
|
337
|
-
.sort((a, b) => a.lamportTimestamp!.id!.localeCompare(b.lamportTimestamp!.id!));
|
|
338
|
-
return sortedStates[0];
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
static increment(timestamp: LamportTimestamp): LamportTimestamp {
|
|
342
|
-
return {
|
|
343
|
-
...(timestamp ?? {}),
|
|
344
|
-
version: (timestamp?.version ?? 0) + 1,
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
// TODO(mykola): Delete once we refactor swarm to accept string as topic.
|
|
350
|
-
const getTopic = (roomId: string): PublicKey => PublicKey.fromHex(md5Hex(roomId));
|
package/src/calls/index.ts
DELETED