@dxos/plugin-thread 0.8.4-main.9735255 → 0.8.4-main.9be5663bfe
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/add-message-A33GVGQX.mjs +97 -0
- package/dist/lib/browser/add-message-A33GVGQX.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +33 -4
- package/dist/lib/browser/blueprints/index.mjs.map +4 -4
- package/dist/lib/browser/chunk-2QNKWX4H.mjs +259 -0
- package/dist/lib/browser/chunk-2QNKWX4H.mjs.map +7 -0
- package/dist/lib/browser/chunk-7T7J6ZR6.mjs +61 -0
- package/dist/lib/browser/chunk-7T7J6ZR6.mjs.map +7 -0
- package/dist/lib/browser/create-N2ZVTONJ.mjs +55 -0
- package/dist/lib/browser/create-N2ZVTONJ.mjs.map +7 -0
- package/dist/lib/browser/create-channel-Y4H3535D.mjs +21 -0
- package/dist/lib/browser/create-channel-Y4H3535D.mjs.map +7 -0
- package/dist/lib/browser/create-channel-thread-6N7TKEAW.mjs +28 -0
- package/dist/lib/browser/create-channel-thread-6N7TKEAW.mjs.map +7 -0
- package/dist/lib/browser/create-proposals-VTOSWUOX.mjs +57 -0
- package/dist/lib/browser/create-proposals-VTOSWUOX.mjs.map +7 -0
- package/dist/lib/browser/delete-QZZE655Y.mjs +59 -0
- package/dist/lib/browser/delete-QZZE655Y.mjs.map +7 -0
- package/dist/lib/browser/delete-message-WQAZLYBO.mjs +64 -0
- package/dist/lib/browser/delete-message-WQAZLYBO.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +2225 -211
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/on-create-space-2UGS234J.mjs +25 -0
- package/dist/lib/browser/on-create-space-2UGS234J.mjs.map +7 -0
- package/dist/lib/browser/operations/index.mjs +14 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/restore-KKQHFLYO.mjs +33 -0
- package/dist/lib/browser/restore-KKQHFLYO.mjs.map +7 -0
- package/dist/lib/browser/restore-message-VOP2UE7N.mjs +42 -0
- package/dist/lib/browser/restore-message-VOP2UE7N.mjs.map +7 -0
- package/dist/lib/browser/select-VBJ3MBLN.mjs +26 -0
- package/dist/lib/browser/select-VBJ3MBLN.mjs.map +7 -0
- package/dist/lib/browser/toggle-resolved-GIYF3KWJ.mjs +45 -0
- package/dist/lib/browser/toggle-resolved-GIYF3KWJ.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +5 -7
- package/dist/lib/node-esm/add-message-E6XC6E3Z.mjs +98 -0
- package/dist/lib/node-esm/add-message-E6XC6E3Z.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +33 -4
- package/dist/lib/node-esm/blueprints/index.mjs.map +4 -4
- package/dist/lib/node-esm/chunk-I6LAZYVU.mjs +260 -0
- package/dist/lib/node-esm/chunk-I6LAZYVU.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UGSMYQLZ.mjs +62 -0
- package/dist/lib/node-esm/chunk-UGSMYQLZ.mjs.map +7 -0
- package/dist/lib/node-esm/create-A6XQZR7M.mjs +56 -0
- package/dist/lib/node-esm/create-A6XQZR7M.mjs.map +7 -0
- package/dist/lib/node-esm/create-channel-KA5T23ZS.mjs +22 -0
- package/dist/lib/node-esm/create-channel-KA5T23ZS.mjs.map +7 -0
- package/dist/lib/node-esm/create-channel-thread-44PXAPGM.mjs +29 -0
- package/dist/lib/node-esm/create-channel-thread-44PXAPGM.mjs.map +7 -0
- package/dist/lib/node-esm/create-proposals-HDBVDNUX.mjs +58 -0
- package/dist/lib/node-esm/create-proposals-HDBVDNUX.mjs.map +7 -0
- package/dist/lib/node-esm/delete-3RAWD5GG.mjs +60 -0
- package/dist/lib/node-esm/delete-3RAWD5GG.mjs.map +7 -0
- package/dist/lib/node-esm/delete-message-W4XFE4KW.mjs +65 -0
- package/dist/lib/node-esm/delete-message-W4XFE4KW.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +2225 -211
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/on-create-space-ZURB6UKR.mjs +26 -0
- package/dist/lib/node-esm/on-create-space-ZURB6UKR.mjs.map +7 -0
- package/dist/lib/node-esm/operations/index.mjs +15 -0
- package/dist/lib/node-esm/operations/index.mjs.map +7 -0
- package/dist/lib/node-esm/restore-PDYEKDE3.mjs +34 -0
- package/dist/lib/node-esm/restore-PDYEKDE3.mjs.map +7 -0
- package/dist/lib/node-esm/restore-message-O5XC34MW.mjs +43 -0
- package/dist/lib/node-esm/restore-message-O5XC34MW.mjs.map +7 -0
- package/dist/lib/node-esm/select-6KETLVWY.mjs +27 -0
- package/dist/lib/node-esm/select-6KETLVWY.mjs.map +7 -0
- package/dist/lib/node-esm/toggle-resolved-QR3SOXR7.mjs +46 -0
- package/dist/lib/node-esm/toggle-resolved-QR3SOXR7.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +5 -7
- package/dist/types/src/ThreadPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +1 -1
- package/dist/types/src/blueprints/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/thread-blueprint.d.ts +3 -20
- package/dist/types/src/blueprints/thread-blueprint.d.ts.map +1 -1
- package/dist/types/src/calls/util/calls-service.d.ts.map +1 -1
- package/dist/types/src/calls-service.stories.d.ts +2 -2
- package/dist/types/src/calls-service.stories.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts +6 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/call-manager.d.ts +6 -0
- package/dist/types/src/capabilities/call-manager.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +15 -10
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown.d.ts +5 -0
- package/dist/types/src/capabilities/markdown.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-root/react-root.d.ts → react-root.d.ts} +1 -1
- package/dist/types/src/capabilities/react-root.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +6 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/capabilities/state.d.ts +7 -0
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/undo-mappings.d.ts +5 -0
- package/dist/types/src/capabilities/undo-mappings.d.ts.map +1 -0
- package/dist/types/src/components/Call/Toolbar.d.ts +1 -1
- package/dist/types/src/components/Call/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/CommentsPanel/CommentsPanel.d.ts +13 -0
- package/dist/types/src/components/CommentsPanel/CommentsPanel.d.ts.map +1 -0
- package/dist/types/src/components/CommentsPanel/CommentsPanel.stories.d.ts +160 -0
- package/dist/types/src/components/CommentsPanel/CommentsPanel.stories.d.ts.map +1 -0
- package/dist/types/src/components/{CommentsThreadContainer.d.ts → CommentsPanel/CommentsThread.d.ts} +3 -3
- package/dist/types/src/components/CommentsPanel/CommentsThread.d.ts.map +1 -0
- package/dist/types/src/components/CommentsPanel/index.d.ts +3 -0
- package/dist/types/src/components/CommentsPanel/index.d.ts.map +1 -0
- package/dist/types/src/components/Lobby/Lobby.d.ts.map +1 -1
- package/dist/types/src/components/Media/VideoObject.stories.d.ts.map +1 -1
- package/dist/types/src/components/MessagePanel/MessagePanel.d.ts +15 -0
- package/dist/types/src/components/MessagePanel/MessagePanel.d.ts.map +1 -0
- package/dist/types/src/components/MessagePanel/index.d.ts +2 -0
- package/dist/types/src/components/MessagePanel/index.d.ts.map +1 -0
- package/dist/types/src/components/Participant/Participant.d.ts.map +1 -1
- package/dist/types/src/components/Participant/ParticipantGrid.d.ts.map +1 -1
- package/dist/types/src/components/ResponsiveGrid/ResponsiveGrid.d.ts.map +1 -1
- package/dist/types/src/components/ResponsiveGrid/ResponsiveGrid.stories.d.ts +142 -144
- package/dist/types/src/components/ResponsiveGrid/ResponsiveGrid.stories.d.ts.map +1 -1
- package/dist/types/src/components/ResponsiveGrid/{ResponsiveContainer.d.ts → ResponsivePanel.d.ts} +4 -4
- package/dist/types/src/components/ResponsiveGrid/ResponsivePanel.d.ts.map +1 -0
- package/dist/types/src/components/ResponsiveGrid/ResponsivePanel.stories.d.ts +164 -0
- package/dist/types/src/components/ResponsiveGrid/ResponsivePanel.stories.d.ts.map +1 -0
- package/dist/types/src/components/ResponsiveGrid/index.d.ts +1 -1
- package/dist/types/src/components/ResponsiveGrid/index.d.ts.map +1 -1
- package/dist/types/src/components/ThreadSettings/ThreadSettings.d.ts +6 -0
- package/dist/types/src/components/ThreadSettings/ThreadSettings.d.ts.map +1 -0
- package/dist/types/src/components/ThreadSettings/ThreadSettings.stories.d.ts +161 -0
- package/dist/types/src/components/ThreadSettings/ThreadSettings.stories.d.ts.map +1 -0
- package/dist/types/src/components/ThreadSettings/index.d.ts +2 -0
- package/dist/types/src/components/ThreadSettings/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +4 -9
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/{components → containers/CallDebugPanel}/CallDebugPanel.d.ts +1 -1
- package/dist/types/src/containers/CallDebugPanel/CallDebugPanel.d.ts.map +1 -0
- package/dist/types/src/containers/CallDebugPanel/index.d.ts +2 -0
- package/dist/types/src/containers/CallDebugPanel/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/CallSidebar}/CallSidebar.d.ts +0 -1
- package/dist/types/src/containers/CallSidebar/CallSidebar.d.ts.map +1 -0
- package/dist/types/src/containers/CallSidebar/index.d.ts +2 -0
- package/dist/types/src/containers/CallSidebar/index.d.ts.map +1 -0
- package/dist/types/src/containers/ChannelContainer/ChannelContainer.d.ts +12 -0
- package/dist/types/src/containers/ChannelContainer/ChannelContainer.d.ts.map +1 -0
- package/dist/types/src/containers/ChannelContainer/ChannelContainer.stories.d.ts +162 -0
- package/dist/types/src/containers/ChannelContainer/ChannelContainer.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ChannelContainer/index.d.ts +2 -0
- package/dist/types/src/containers/ChannelContainer/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/ChatContainer}/ChatContainer.d.ts +3 -5
- package/dist/types/src/containers/ChatContainer/ChatContainer.d.ts.map +1 -0
- package/dist/types/src/containers/ChatContainer/ChatContainer.stories.d.ts +162 -0
- package/dist/types/src/containers/ChatContainer/ChatContainer.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ChatContainer/index.d.ts +4 -0
- package/dist/types/src/containers/ChatContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/ThreadCompanion/ThreadCompanion.d.ts +8 -0
- package/dist/types/src/containers/ThreadCompanion/ThreadCompanion.d.ts.map +1 -0
- package/dist/types/src/containers/ThreadCompanion/index.d.ts +2 -0
- package/dist/types/src/containers/ThreadCompanion/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +7 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/{components/command-extension.d.ts → extensions/command.d.ts} +1 -1
- package/dist/types/src/extensions/command.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +1 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -1
- package/dist/types/src/extensions/threads.d.ts +1 -1
- package/dist/types/src/extensions/threads.d.ts.map +1 -1
- package/dist/types/src/hooks/analytics.d.ts.map +1 -1
- package/dist/types/src/operations/add-message.d.ts +5 -0
- package/dist/types/src/operations/add-message.d.ts.map +1 -0
- package/dist/types/src/operations/create-channel-thread.d.ts +5 -0
- package/dist/types/src/operations/create-channel-thread.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/create-proposals.d.ts +5 -0
- package/dist/types/src/operations/create-proposals.d.ts.map +1 -0
- package/dist/types/src/operations/create.d.ts +5 -0
- package/dist/types/src/operations/create.d.ts.map +1 -0
- package/dist/types/src/operations/definitions.d.ts +2789 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/delete-message.d.ts +5 -0
- package/dist/types/src/operations/delete-message.d.ts.map +1 -0
- package/dist/types/src/operations/delete.d.ts +5 -0
- package/dist/types/src/operations/delete.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/on-create-space.d.ts +5 -0
- package/dist/types/src/operations/on-create-space.d.ts.map +1 -0
- package/dist/types/src/operations/restore-message.d.ts +5 -0
- package/dist/types/src/operations/restore-message.d.ts.map +1 -0
- package/dist/types/src/operations/restore.d.ts +5 -0
- package/dist/types/src/operations/restore.d.ts.map +1 -0
- package/dist/types/src/operations/select.d.ts +5 -0
- package/dist/types/src/operations/select.d.ts.map +1 -0
- package/dist/types/src/operations/toggle-resolved.d.ts +5 -0
- package/dist/types/src/operations/toggle-resolved.d.ts.map +1 -0
- package/dist/types/src/{components/testing.d.ts → testing/data.d.ts} +1 -1
- package/dist/types/src/testing/data.d.ts.map +1 -0
- package/dist/types/src/testing/stories.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +140 -142
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Channel.d.ts +25 -9
- package/dist/types/src/types/Channel.d.ts.map +1 -1
- package/dist/types/src/types/Settings.d.ts +4 -0
- package/dist/types/src/types/Settings.d.ts.map +1 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +1 -3227
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +88 -66
- package/src/ThreadPlugin.tsx +54 -56
- package/src/blueprints/index.ts +1 -1
- package/src/blueprints/thread-blueprint.ts +13 -8
- package/src/calls/util/calls-service.ts +0 -1
- package/src/calls-service.stories.tsx +10 -9
- package/src/capabilities/{app-graph-builder/app-graph-builder.ts → app-graph-builder.ts} +42 -50
- package/src/capabilities/blueprint-definition.ts +17 -0
- package/src/capabilities/{call-manager/call-manager.ts → call-manager.ts} +6 -5
- package/src/capabilities/index.ts +16 -10
- package/src/capabilities/{markdown/markdown.ts → markdown.ts} +14 -15
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/{react-root/react-root.tsx → react-root.tsx} +4 -4
- package/src/capabilities/react-surface.tsx +90 -0
- package/src/capabilities/{settings/settings.ts → settings.ts} +9 -7
- package/src/capabilities/{state/state.ts → state.ts} +1 -1
- package/src/capabilities/undo-mappings.ts +46 -0
- package/src/components/Call/Call.tsx +5 -5
- package/src/components/Call/Toolbar.tsx +30 -21
- package/src/components/{Comments.stories.tsx → CommentsPanel/CommentsPanel.stories.tsx} +16 -16
- package/src/components/{CommentsContainer.tsx → CommentsPanel/CommentsPanel.tsx} +15 -14
- package/src/components/{CommentsThreadContainer.tsx → CommentsPanel/CommentsThread.tsx} +19 -20
- package/src/components/CommentsPanel/index.ts +6 -0
- package/src/components/Lobby/Lobby.tsx +8 -7
- package/src/components/Media/VideoObject.stories.tsx +6 -7
- package/src/components/Media/VideoObject.tsx +1 -1
- package/src/components/{MessageContainer.tsx → MessagePanel/MessagePanel.tsx} +24 -18
- package/src/components/MessagePanel/index.ts +5 -0
- package/src/components/Participant/Participant.tsx +3 -2
- package/src/components/Participant/ParticipantGrid.tsx +0 -1
- package/src/components/ResponsiveGrid/ResponsiveGrid.stories.tsx +10 -11
- package/src/components/ResponsiveGrid/ResponsiveGrid.tsx +8 -8
- package/src/components/ResponsiveGrid/ResponsiveGridItem.tsx +9 -9
- package/src/components/ResponsiveGrid/{ResponsiveContainer.stories.tsx → ResponsivePanel.stories.tsx} +7 -8
- package/src/components/ResponsiveGrid/{ResponsiveContainer.tsx → ResponsivePanel.tsx} +5 -5
- package/src/components/ResponsiveGrid/index.ts +1 -1
- package/src/components/ThreadSettings/ThreadSettings.stories.tsx +31 -0
- package/src/components/ThreadSettings/ThreadSettings.tsx +20 -0
- package/src/components/ThreadSettings/index.ts +5 -0
- package/src/components/index.ts +5 -9
- package/src/{components → containers/CallDebugPanel}/CallDebugPanel.tsx +8 -7
- package/src/containers/CallDebugPanel/index.ts +5 -0
- package/src/{components → containers/CallSidebar}/CallSidebar.tsx +4 -6
- package/src/containers/CallSidebar/index.ts +5 -0
- package/src/{components → containers/ChannelContainer}/ChannelContainer.stories.tsx +14 -14
- package/src/{components → containers/ChannelContainer}/ChannelContainer.tsx +75 -59
- package/src/containers/ChannelContainer/index.ts +5 -0
- package/src/{components/Chat.stories.tsx → containers/ChatContainer/ChatContainer.stories.tsx} +22 -20
- package/src/containers/ChatContainer/ChatContainer.tsx +131 -0
- package/src/containers/ChatContainer/index.ts +8 -0
- package/src/{components → containers/ThreadCompanion}/ThreadCompanion.tsx +74 -50
- package/src/containers/ThreadCompanion/index.ts +5 -0
- package/src/containers/index.ts +11 -0
- package/src/{components/command-extension.ts → extensions/command.ts} +1 -1
- package/src/extensions/index.ts +1 -0
- package/src/extensions/threads.ts +14 -13
- package/src/hooks/analytics.ts +3 -2
- package/src/meta.ts +2 -2
- package/src/operations/add-message.ts +81 -0
- package/src/operations/create-channel-thread.ts +26 -0
- package/src/operations/create-channel.ts +20 -0
- package/src/operations/create-proposals.ts +49 -0
- package/src/operations/create.ts +48 -0
- package/src/operations/definitions.ts +177 -0
- package/src/operations/delete-message.ts +53 -0
- package/src/operations/delete.ts +63 -0
- package/src/operations/index.ts +22 -0
- package/src/operations/on-create-space.ts +27 -0
- package/src/operations/restore-message.ts +38 -0
- package/src/operations/restore.ts +38 -0
- package/src/operations/select.ts +24 -0
- package/src/operations/toggle-resolved.ts +41 -0
- package/src/{components/testing.ts → testing/data.ts} +7 -7
- package/src/testing/stories.ts +7 -11
- package/src/translations.ts +72 -76
- package/src/types/Channel.ts +11 -4
- package/src/types/Settings.ts +10 -0
- package/src/types/capabilities.ts +9 -7
- package/src/types/types.ts +2 -184
- package/src/util.ts +1 -1
- package/dist/lib/browser/app-graph-builder-7C2QW32W.mjs +0 -188
- package/dist/lib/browser/app-graph-builder-7C2QW32W.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-UQ63QKQG.mjs +0 -17
- package/dist/lib/browser/blueprint-definition-UQ63QKQG.mjs.map +0 -7
- package/dist/lib/browser/call-manager-4P536YNX.mjs +0 -26
- package/dist/lib/browser/call-manager-4P536YNX.mjs.map +0 -7
- package/dist/lib/browser/chunk-2FIHSX35.mjs +0 -293
- package/dist/lib/browser/chunk-2FIHSX35.mjs.map +0 -7
- package/dist/lib/browser/chunk-CP7E2HRE.mjs +0 -31
- package/dist/lib/browser/chunk-CP7E2HRE.mjs.map +0 -7
- package/dist/lib/browser/chunk-DLO2G3DM.mjs +0 -184
- package/dist/lib/browser/chunk-DLO2G3DM.mjs.map +0 -7
- package/dist/lib/browser/chunk-ERK254BS.mjs +0 -1810
- package/dist/lib/browser/chunk-ERK254BS.mjs.map +0 -7
- package/dist/lib/browser/chunk-ISCHODBV.mjs +0 -106
- package/dist/lib/browser/chunk-ISCHODBV.mjs.map +0 -7
- package/dist/lib/browser/chunk-YSHXWAL3.mjs +0 -1815
- package/dist/lib/browser/chunk-YSHXWAL3.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZFLSTQSE.mjs +0 -106
- package/dist/lib/browser/chunk-ZFLSTQSE.mjs.map +0 -7
- package/dist/lib/browser/markdown-QMJLRR6R.mjs +0 -210
- package/dist/lib/browser/markdown-QMJLRR6R.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-T63EP5TY.mjs +0 -441
- package/dist/lib/browser/operation-resolver-T63EP5TY.mjs.map +0 -7
- package/dist/lib/browser/react-root-56MJI77R.mjs +0 -25
- package/dist/lib/browser/react-root-56MJI77R.mjs.map +0 -7
- package/dist/lib/browser/react-surface-DMBHQOXJ.mjs +0 -110
- package/dist/lib/browser/react-surface-DMBHQOXJ.mjs.map +0 -7
- package/dist/lib/browser/repair-6OZ75AUU.mjs +0 -38
- package/dist/lib/browser/repair-6OZ75AUU.mjs.map +0 -7
- package/dist/lib/browser/settings-WZMJMML3.mjs +0 -32
- package/dist/lib/browser/settings-WZMJMML3.mjs.map +0 -7
- package/dist/lib/browser/state-SJR2GL5G.mjs +0 -24
- package/dist/lib/browser/state-SJR2GL5G.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-JCSVFRVY.mjs +0 -189
- package/dist/lib/node-esm/app-graph-builder-JCSVFRVY.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-MZZXXL37.mjs +0 -18
- package/dist/lib/node-esm/blueprint-definition-MZZXXL37.mjs.map +0 -7
- package/dist/lib/node-esm/call-manager-FMLRR5S5.mjs +0 -27
- package/dist/lib/node-esm/call-manager-FMLRR5S5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7XQLXMX7.mjs +0 -1816
- package/dist/lib/node-esm/chunk-7XQLXMX7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ABUFOZVX.mjs +0 -33
- package/dist/lib/node-esm/chunk-ABUFOZVX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AQHPP6ZX.mjs +0 -107
- package/dist/lib/node-esm/chunk-AQHPP6ZX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KRBZBJRI.mjs +0 -185
- package/dist/lib/node-esm/chunk-KRBZBJRI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QP3KQOPQ.mjs +0 -1811
- package/dist/lib/node-esm/chunk-QP3KQOPQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VBI32FGI.mjs +0 -108
- package/dist/lib/node-esm/chunk-VBI32FGI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WMWUXWAS.mjs +0 -294
- package/dist/lib/node-esm/chunk-WMWUXWAS.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-L6LLQLIN.mjs +0 -211
- package/dist/lib/node-esm/markdown-L6LLQLIN.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-G6GZPBRP.mjs +0 -442
- package/dist/lib/node-esm/operation-resolver-G6GZPBRP.mjs.map +0 -7
- package/dist/lib/node-esm/react-root-V4W4X5GL.mjs +0 -26
- package/dist/lib/node-esm/react-root-V4W4X5GL.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-ELDSTUA3.mjs +0 -111
- package/dist/lib/node-esm/react-surface-ELDSTUA3.mjs.map +0 -7
- package/dist/lib/node-esm/repair-6777EPOM.mjs +0 -39
- package/dist/lib/node-esm/repair-6777EPOM.mjs.map +0 -7
- package/dist/lib/node-esm/settings-37CO3SNR.mjs +0 -33
- package/dist/lib/node-esm/settings-37CO3SNR.mjs.map +0 -7
- package/dist/lib/node-esm/state-5R3TZJQE.mjs +0 -25
- package/dist/lib/node-esm/state-5R3TZJQE.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +0 -6
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +0 -3
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +0 -9
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +0 -3
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/call-manager/call-manager.d.ts +0 -6
- package/dist/types/src/capabilities/call-manager/call-manager.d.ts.map +0 -1
- package/dist/types/src/capabilities/call-manager/index.d.ts +0 -3
- package/dist/types/src/capabilities/call-manager/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/markdown/index.d.ts +0 -3
- package/dist/types/src/capabilities/markdown/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/markdown/markdown.d.ts +0 -5
- package/dist/types/src/capabilities/markdown/markdown.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-root/index.d.ts +0 -6
- package/dist/types/src/capabilities/react-root/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-root/react-root.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/repair/index.d.ts +0 -3
- package/dist/types/src/capabilities/repair/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/repair/repair.d.ts +0 -6
- package/dist/types/src/capabilities/repair/repair.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings/index.d.ts +0 -3
- package/dist/types/src/capabilities/settings/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings/settings.d.ts +0 -5
- package/dist/types/src/capabilities/settings/settings.d.ts.map +0 -1
- package/dist/types/src/capabilities/state/index.d.ts +0 -3
- package/dist/types/src/capabilities/state/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/state/state.d.ts +0 -7
- package/dist/types/src/capabilities/state/state.d.ts.map +0 -1
- package/dist/types/src/components/CallDebugPanel.d.ts.map +0 -1
- package/dist/types/src/components/CallSidebar.d.ts.map +0 -1
- package/dist/types/src/components/ChannelContainer.d.ts +0 -13
- package/dist/types/src/components/ChannelContainer.d.ts.map +0 -1
- package/dist/types/src/components/ChannelContainer.stories.d.ts +0 -164
- package/dist/types/src/components/ChannelContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/Chat.stories.d.ts +0 -164
- package/dist/types/src/components/Chat.stories.d.ts.map +0 -1
- package/dist/types/src/components/ChatContainer.d.ts.map +0 -1
- package/dist/types/src/components/Comments.stories.d.ts +0 -162
- 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.map +0 -1
- package/dist/types/src/components/MessageContainer.d.ts +0 -15
- package/dist/types/src/components/MessageContainer.d.ts.map +0 -1
- package/dist/types/src/components/ResponsiveGrid/ResponsiveContainer.d.ts.map +0 -1
- package/dist/types/src/components/ResponsiveGrid/ResponsiveContainer.stories.d.ts +0 -166
- package/dist/types/src/components/ResponsiveGrid/ResponsiveContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/ThreadCompanion.d.ts +0 -5
- package/dist/types/src/components/ThreadCompanion.d.ts.map +0 -1
- package/dist/types/src/components/ThreadSettings.d.ts +0 -8
- package/dist/types/src/components/ThreadSettings.d.ts.map +0 -1
- package/dist/types/src/components/command-extension.d.ts.map +0 -1
- package/dist/types/src/components/testing.d.ts.map +0 -1
- package/dist/types/src/functions/create-proposals.d.ts +0 -6
- package/dist/types/src/functions/create-proposals.d.ts.map +0 -1
- package/dist/types/src/functions/index.d.ts +0 -2
- package/dist/types/src/functions/index.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder/index.ts +0 -7
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +0 -23
- package/src/capabilities/blueprint-definition/index.ts +0 -7
- package/src/capabilities/call-manager/index.ts +0 -7
- package/src/capabilities/markdown/index.ts +0 -7
- package/src/capabilities/operation-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -400
- package/src/capabilities/react-root/index.ts +0 -7
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/react-surface/react-surface.tsx +0 -97
- package/src/capabilities/repair/index.ts +0 -7
- package/src/capabilities/repair/repair.ts +0 -51
- package/src/capabilities/settings/index.ts +0 -7
- package/src/capabilities/state/index.ts +0 -7
- package/src/components/ChatContainer.tsx +0 -155
- package/src/components/ThreadSettings.tsx +0 -21
- package/src/functions/create-proposals.ts +0 -57
- package/src/functions/index.ts +0 -5
|
@@ -1,1810 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createBlackCanvasStreamTrack,
|
|
3
|
-
createInaudibleAudioStreamTrack
|
|
4
|
-
} from "./chunk-ISCHODBV.mjs";
|
|
5
|
-
|
|
6
|
-
// src/calls/types.ts
|
|
7
|
-
import { invariant } from "@dxos/invariant";
|
|
8
|
-
import { buf } from "@dxos/protocols/buf";
|
|
9
|
-
import { UserStateSchema } from "@dxos/protocols/buf/dxos/edge/calls_pb";
|
|
10
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-thread/src/calls/types.ts";
|
|
11
|
-
var CALLS_URL = "https://calls-service.dxos.workers.dev";
|
|
12
|
-
var codec = {
|
|
13
|
-
encode: (message) => {
|
|
14
|
-
return buf.toBinary(UserStateSchema, buf.create(UserStateSchema, message));
|
|
15
|
-
},
|
|
16
|
-
decode: (message) => {
|
|
17
|
-
return buf.fromBinary(UserStateSchema, message);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
var TrackNameCodec = {
|
|
21
|
-
encode: (trackData) => {
|
|
22
|
-
invariant(trackData.sessionId, void 0, {
|
|
23
|
-
F: __dxlog_file,
|
|
24
|
-
L: 65,
|
|
25
|
-
S: void 0,
|
|
26
|
-
A: [
|
|
27
|
-
"trackData.sessionId",
|
|
28
|
-
""
|
|
29
|
-
]
|
|
30
|
-
});
|
|
31
|
-
invariant(trackData.trackName, void 0, {
|
|
32
|
-
F: __dxlog_file,
|
|
33
|
-
L: 66,
|
|
34
|
-
S: void 0,
|
|
35
|
-
A: [
|
|
36
|
-
"trackData.trackName",
|
|
37
|
-
""
|
|
38
|
-
]
|
|
39
|
-
});
|
|
40
|
-
invariant(trackData.mid, void 0, {
|
|
41
|
-
F: __dxlog_file,
|
|
42
|
-
L: 67,
|
|
43
|
-
S: void 0,
|
|
44
|
-
A: [
|
|
45
|
-
"trackData.mid",
|
|
46
|
-
""
|
|
47
|
-
]
|
|
48
|
-
});
|
|
49
|
-
return trackData.sessionId + "/" + trackData.trackName + "/" + trackData.mid;
|
|
50
|
-
},
|
|
51
|
-
decode: (name) => {
|
|
52
|
-
const [sessionId, trackName, mid] = name.split("/");
|
|
53
|
-
return {
|
|
54
|
-
sessionId,
|
|
55
|
-
trackName,
|
|
56
|
-
location: "remote",
|
|
57
|
-
mid
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
// src/calls/call-swarm-synchronizer.ts
|
|
63
|
-
import md5Hex from "md5-hex";
|
|
64
|
-
import { DeferredTask, Event, scheduleTaskInterval, synchronized } from "@dxos/async";
|
|
65
|
-
import { Context, Resource } from "@dxos/context";
|
|
66
|
-
import { generateName } from "@dxos/display-name";
|
|
67
|
-
import { invariant as invariant2 } from "@dxos/invariant";
|
|
68
|
-
import { PublicKey } from "@dxos/keys";
|
|
69
|
-
import { log } from "@dxos/log";
|
|
70
|
-
import { buf as buf2 } from "@dxos/protocols/buf";
|
|
71
|
-
import { ActivitySchema } from "@dxos/protocols/buf/dxos/edge/calls_pb";
|
|
72
|
-
import { ConnectionState } from "@dxos/protocols/proto/dxos/edge/messenger";
|
|
73
|
-
import { isNonNullable } from "@dxos/util";
|
|
74
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
75
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
76
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
77
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
78
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
79
|
-
}
|
|
80
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-thread/src/calls/call-swarm-synchronizer.ts";
|
|
81
|
-
var DISCONNECTED_ABRUPT_TIMEOUT = 1e4;
|
|
82
|
-
var CallSwarmSynchronizer = class extends Resource {
|
|
83
|
-
stateUpdated = new Event();
|
|
84
|
-
_state = {
|
|
85
|
-
activities: {}
|
|
86
|
-
};
|
|
87
|
-
_networkService;
|
|
88
|
-
_lastSwarmEvent = void 0;
|
|
89
|
-
_reconcileSwarmStateTask = void 0;
|
|
90
|
-
_identityKey = void 0;
|
|
91
|
-
_deviceKey = void 0;
|
|
92
|
-
_displayName = void 0;
|
|
93
|
-
_swarmCtx = void 0;
|
|
94
|
-
_sendStateTask = void 0;
|
|
95
|
-
constructor({ networkService }) {
|
|
96
|
-
super();
|
|
97
|
-
this._networkService = networkService;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* @internal
|
|
101
|
-
*/
|
|
102
|
-
_getState() {
|
|
103
|
-
return this._state;
|
|
104
|
-
}
|
|
105
|
-
setRaisedHand(raisedHand) {
|
|
106
|
-
if (this._state.raisedHand === raisedHand) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
this._state.raisedHand = raisedHand;
|
|
110
|
-
this._notifyAndSchedule();
|
|
111
|
-
}
|
|
112
|
-
setSpeaking(speaking) {
|
|
113
|
-
if (this._state.speaking === speaking) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
this._state.speaking = speaking;
|
|
117
|
-
this._notifyAndSchedule();
|
|
118
|
-
}
|
|
119
|
-
setJoined(joined) {
|
|
120
|
-
if (this._state.joined === joined) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
this._state.joined = joined;
|
|
124
|
-
this._notifyAndSchedule();
|
|
125
|
-
}
|
|
126
|
-
setTracks(tracks) {
|
|
127
|
-
this._state.tracks = {
|
|
128
|
-
...this._state.tracks,
|
|
129
|
-
...tracks
|
|
130
|
-
};
|
|
131
|
-
this._notifyAndSchedule();
|
|
132
|
-
}
|
|
133
|
-
setActivity(key, payload) {
|
|
134
|
-
const lamportTimestamp = LamportTimestampCrdt.increment(this._state.activities?.[key]?.lamportTimestamp ?? {
|
|
135
|
-
id: this._deviceKey
|
|
136
|
-
});
|
|
137
|
-
this._state.activities[key] = {
|
|
138
|
-
lamportTimestamp,
|
|
139
|
-
payload
|
|
140
|
-
};
|
|
141
|
-
this._notifyAndSchedule();
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* @internal
|
|
145
|
-
*/
|
|
146
|
-
_setIdentity(identity) {
|
|
147
|
-
this._identityKey = identity.identityKey.toHex();
|
|
148
|
-
this._displayName = identity.profile?.displayName ?? generateName(identity.identityKey.toHex());
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* @internal
|
|
152
|
-
*/
|
|
153
|
-
_setDevice(device) {
|
|
154
|
-
this._deviceKey = device.deviceKey.toHex();
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* @internal
|
|
158
|
-
*/
|
|
159
|
-
_setRoomId(roomId) {
|
|
160
|
-
if (this._swarmCtx) {
|
|
161
|
-
log.verbose("joined to a different room", {
|
|
162
|
-
roomId
|
|
163
|
-
}, {
|
|
164
|
-
F: __dxlog_file2,
|
|
165
|
-
L: 152,
|
|
166
|
-
S: this,
|
|
167
|
-
C: (f, a) => f(...a)
|
|
168
|
-
});
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
this._state.roomId = roomId;
|
|
172
|
-
}
|
|
173
|
-
async _open() {
|
|
174
|
-
this._sendStateTask = new DeferredTask(this._ctx, async () => {
|
|
175
|
-
await this._sendState();
|
|
176
|
-
});
|
|
177
|
-
this._reconcileSwarmStateTask = new DeferredTask(this._ctx, async () => {
|
|
178
|
-
await this._reconcileSwarmState();
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
async _close() {
|
|
182
|
-
this._sendStateTask = void 0;
|
|
183
|
-
this._reconcileSwarmStateTask = void 0;
|
|
184
|
-
}
|
|
185
|
-
async join() {
|
|
186
|
-
invariant2(this._state.roomId, void 0, {
|
|
187
|
-
F: __dxlog_file2,
|
|
188
|
-
L: 176,
|
|
189
|
-
S: this,
|
|
190
|
-
A: [
|
|
191
|
-
"this._state.roomId",
|
|
192
|
-
""
|
|
193
|
-
]
|
|
194
|
-
});
|
|
195
|
-
invariant2(!this._swarmCtx, "Already joined", {
|
|
196
|
-
F: __dxlog_file2,
|
|
197
|
-
L: 177,
|
|
198
|
-
S: this,
|
|
199
|
-
A: [
|
|
200
|
-
"!this._swarmCtx",
|
|
201
|
-
"'Already joined'"
|
|
202
|
-
]
|
|
203
|
-
});
|
|
204
|
-
this._swarmCtx = new Context(void 0, {
|
|
205
|
-
F: __dxlog_file2,
|
|
206
|
-
L: 179
|
|
207
|
-
});
|
|
208
|
-
const topic = getTopic(this._state.roomId);
|
|
209
|
-
log("joining swarm", {
|
|
210
|
-
topic,
|
|
211
|
-
peer: {
|
|
212
|
-
identityKey: this._identityKey,
|
|
213
|
-
peerKey: this._deviceKey
|
|
214
|
-
}
|
|
215
|
-
}, {
|
|
216
|
-
F: __dxlog_file2,
|
|
217
|
-
L: 181,
|
|
218
|
-
S: this,
|
|
219
|
-
C: (f, a) => f(...a)
|
|
220
|
-
});
|
|
221
|
-
const stream = this._networkService.subscribeSwarmState({
|
|
222
|
-
topic
|
|
223
|
-
});
|
|
224
|
-
stream.subscribe((event) => this._processSwarmEvent(event));
|
|
225
|
-
const cleanup = () => {
|
|
226
|
-
void stream.close();
|
|
227
|
-
if (topic && this._identityKey && this._deviceKey) {
|
|
228
|
-
log("leaving swarm", {
|
|
229
|
-
topic,
|
|
230
|
-
peer: {
|
|
231
|
-
identityKey: this._identityKey,
|
|
232
|
-
peerKey: this._deviceKey
|
|
233
|
-
}
|
|
234
|
-
}, {
|
|
235
|
-
F: __dxlog_file2,
|
|
236
|
-
L: 188,
|
|
237
|
-
S: this,
|
|
238
|
-
C: (f, a) => f(...a)
|
|
239
|
-
});
|
|
240
|
-
void this._networkService.leaveSwarm({
|
|
241
|
-
topic,
|
|
242
|
-
peer: {
|
|
243
|
-
identityKey: this._identityKey,
|
|
244
|
-
peerKey: this._deviceKey
|
|
245
|
-
}
|
|
246
|
-
}).catch((err) => log.catch(err, void 0, {
|
|
247
|
-
F: __dxlog_file2,
|
|
248
|
-
L: 194,
|
|
249
|
-
S: this,
|
|
250
|
-
C: (f, a) => f(...a)
|
|
251
|
-
}));
|
|
252
|
-
}
|
|
253
|
-
window.removeEventListener("beforeunload", cleanup);
|
|
254
|
-
};
|
|
255
|
-
window.addEventListener("beforeunload", cleanup);
|
|
256
|
-
this._swarmCtx.onDispose(cleanup);
|
|
257
|
-
this._notifyAndSchedule();
|
|
258
|
-
}
|
|
259
|
-
async leave() {
|
|
260
|
-
if (!this._swarmCtx) {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
await this._swarmCtx.dispose();
|
|
264
|
-
this._swarmCtx = void 0;
|
|
265
|
-
this._state.users = void 0;
|
|
266
|
-
this._state.self = void 0;
|
|
267
|
-
}
|
|
268
|
-
async querySwarm(roomId) {
|
|
269
|
-
const topic = getTopic(roomId);
|
|
270
|
-
const swarm = await this._networkService.querySwarm({
|
|
271
|
-
topic
|
|
272
|
-
});
|
|
273
|
-
return swarm.peers ?? [];
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Notify and schedule send state task.
|
|
277
|
-
*/
|
|
278
|
-
_notifyAndSchedule() {
|
|
279
|
-
this.stateUpdated.emit(this._state);
|
|
280
|
-
if (this._state.joined) {
|
|
281
|
-
this._sendStateTask?.schedule();
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
async _sendState() {
|
|
285
|
-
if (!this._state.roomId || !this._identityKey || !this._deviceKey || !this._state.joined) {
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
const state = {
|
|
289
|
-
...this._state,
|
|
290
|
-
id: this._deviceKey,
|
|
291
|
-
name: this._displayName,
|
|
292
|
-
activities: this._state.activities ? Object.fromEntries(Object.entries(this._state.activities).map(([key, activity]) => [
|
|
293
|
-
key,
|
|
294
|
-
buf2.create(ActivitySchema, activity)
|
|
295
|
-
])) : {}
|
|
296
|
-
};
|
|
297
|
-
await this._networkService.joinSwarm({
|
|
298
|
-
topic: getTopic(this._state.roomId),
|
|
299
|
-
peer: {
|
|
300
|
-
identityKey: this._identityKey,
|
|
301
|
-
peerKey: this._deviceKey,
|
|
302
|
-
state: codec.encode(state)
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
_processSwarmEvent(swarmEvent) {
|
|
307
|
-
if (!this._state.joined) {
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
this._lastSwarmEvent = swarmEvent;
|
|
311
|
-
this._reconcileSwarmStateTask.schedule();
|
|
312
|
-
}
|
|
313
|
-
async _reconcileSwarmState() {
|
|
314
|
-
const swarmEvent = this._lastSwarmEvent;
|
|
315
|
-
invariant2(swarmEvent, void 0, {
|
|
316
|
-
F: __dxlog_file2,
|
|
317
|
-
L: 273,
|
|
318
|
-
S: this,
|
|
319
|
-
A: [
|
|
320
|
-
"swarmEvent",
|
|
321
|
-
""
|
|
322
|
-
]
|
|
323
|
-
});
|
|
324
|
-
const peers = [
|
|
325
|
-
...swarmEvent.peers ?? [],
|
|
326
|
-
...(swarmEvent.inactivePeers ?? []).filter(({ disconnected, connectionState }) => connectionState === ConnectionState.DISCONNECTED_ABRUPT && disconnected && disconnected > Date.now() - DISCONNECTED_ABRUPT_TIMEOUT)
|
|
327
|
-
].sort((peer1, peer2) => peer1.peerKey.localeCompare(peer2.peerKey));
|
|
328
|
-
const users = peers.map((peer) => {
|
|
329
|
-
try {
|
|
330
|
-
return codec.decode(peer.state);
|
|
331
|
-
} catch (error) {
|
|
332
|
-
log.error("error decoding peer state", {
|
|
333
|
-
error,
|
|
334
|
-
peer
|
|
335
|
-
}, {
|
|
336
|
-
F: __dxlog_file2,
|
|
337
|
-
L: 290,
|
|
338
|
-
S: this,
|
|
339
|
-
C: (f, a) => f(...a)
|
|
340
|
-
});
|
|
341
|
-
return void 0;
|
|
342
|
-
}
|
|
343
|
-
}).filter(isNonNullable);
|
|
344
|
-
this._state.users = users;
|
|
345
|
-
this._state.self = users.find((user) => user.id === this._deviceKey);
|
|
346
|
-
log("reconciling swarm state", {
|
|
347
|
-
users
|
|
348
|
-
}, {
|
|
349
|
-
F: __dxlog_file2,
|
|
350
|
-
L: 297,
|
|
351
|
-
S: this,
|
|
352
|
-
C: (f, a) => f(...a)
|
|
353
|
-
});
|
|
354
|
-
if (users.length === 0) {
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
const activityKeys = new Set(users.flatMap((user) => Object.keys(user.activities)));
|
|
358
|
-
[
|
|
359
|
-
...activityKeys
|
|
360
|
-
].forEach((key) => {
|
|
361
|
-
const activities = users.map((user) => user.activities?.[key]).filter(isNonNullable);
|
|
362
|
-
const lastActivity = LamportTimestampCrdt.getLastState(activities);
|
|
363
|
-
if (lastActivity && lastActivity.lamportTimestamp.version > (this._state.activities[key]?.lamportTimestamp?.version ?? 0)) {
|
|
364
|
-
this._state.activities[key] = lastActivity;
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
this.stateUpdated.emit(this._state);
|
|
368
|
-
if (peers.some((peer) => peer.connectionState !== ConnectionState.CONNECTED)) {
|
|
369
|
-
scheduleTaskInterval(this._ctx, async () => this._reconcileSwarmStateTask.schedule(), Math.min(DISCONNECTED_ABRUPT_TIMEOUT / 2, 1e3));
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
_ts_decorate([
|
|
374
|
-
synchronized
|
|
375
|
-
], CallSwarmSynchronizer.prototype, "join", null);
|
|
376
|
-
_ts_decorate([
|
|
377
|
-
synchronized
|
|
378
|
-
], CallSwarmSynchronizer.prototype, "leave", null);
|
|
379
|
-
var LamportTimestampCrdt = class {
|
|
380
|
-
static getLastState(states) {
|
|
381
|
-
const maxTimestamp = Math.max(...states.map((state) => state.lamportTimestamp?.version ?? 0));
|
|
382
|
-
const sortedStates = states.filter((state) => state.lamportTimestamp && state.lamportTimestamp.version === maxTimestamp && state.lamportTimestamp.id).sort((a, b) => a.lamportTimestamp.id.localeCompare(b.lamportTimestamp.id));
|
|
383
|
-
return sortedStates[0];
|
|
384
|
-
}
|
|
385
|
-
static increment(timestamp) {
|
|
386
|
-
return {
|
|
387
|
-
...timestamp ?? {},
|
|
388
|
-
version: (timestamp?.version ?? 0) + 1
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
var getTopic = (roomId) => PublicKey.fromHex(md5Hex(roomId));
|
|
393
|
-
|
|
394
|
-
// src/calls/util/audio.ts
|
|
395
|
-
var monitorAudioLevel = ({ mediaStreamTrack, intervalMs = 1e3 / 10, onMeasure }) => {
|
|
396
|
-
let timeout = -1;
|
|
397
|
-
let interval = -1;
|
|
398
|
-
const audioContext = new AudioContext();
|
|
399
|
-
const stream = new MediaStream();
|
|
400
|
-
stream.addTrack(mediaStreamTrack);
|
|
401
|
-
const mediaStreamAudioSourceNode = audioContext.createMediaStreamSource(stream);
|
|
402
|
-
const analyserNode = audioContext.createAnalyser();
|
|
403
|
-
mediaStreamAudioSourceNode.connect(analyserNode);
|
|
404
|
-
analyserNode.fftSize = 32;
|
|
405
|
-
const pcmData = new Float32Array(analyserNode.fftSize);
|
|
406
|
-
let peak = 0;
|
|
407
|
-
interval = window.setInterval(() => {
|
|
408
|
-
onMeasure(peak);
|
|
409
|
-
peak = 0;
|
|
410
|
-
}, intervalMs);
|
|
411
|
-
const tick = () => {
|
|
412
|
-
timeout = window.setTimeout(() => {
|
|
413
|
-
analyserNode.getFloatTimeDomainData(pcmData);
|
|
414
|
-
let sumSquares = 0;
|
|
415
|
-
for (const amplitude of pcmData) {
|
|
416
|
-
sumSquares += amplitude * amplitude;
|
|
417
|
-
}
|
|
418
|
-
const current = Math.sqrt(sumSquares / pcmData.length);
|
|
419
|
-
if (current > peak) {
|
|
420
|
-
peak = current;
|
|
421
|
-
}
|
|
422
|
-
tick();
|
|
423
|
-
}, intervalMs);
|
|
424
|
-
};
|
|
425
|
-
tick();
|
|
426
|
-
return () => {
|
|
427
|
-
mediaStreamAudioSourceNode.disconnect();
|
|
428
|
-
analyserNode.disconnect();
|
|
429
|
-
void audioContext.close();
|
|
430
|
-
clearInterval(interval);
|
|
431
|
-
clearTimeout(timeout);
|
|
432
|
-
stream.removeTrack(mediaStreamTrack);
|
|
433
|
-
};
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
// src/calls/util/calls-service.ts
|
|
437
|
-
import { PersistentLifecycle, Trigger, scheduleTask } from "@dxos/async";
|
|
438
|
-
import { Resource as Resource2 } from "@dxos/context";
|
|
439
|
-
import { invariant as invariant3 } from "@dxos/invariant";
|
|
440
|
-
import { log as log2 } from "@dxos/log";
|
|
441
|
-
|
|
442
|
-
// src/calls/util/history-cache.ts
|
|
443
|
-
var HistoryCache = class {
|
|
444
|
-
_limit;
|
|
445
|
-
_messages;
|
|
446
|
-
constructor(limit = 100) {
|
|
447
|
-
this._limit = limit;
|
|
448
|
-
this._messages = [];
|
|
449
|
-
}
|
|
450
|
-
push(...messages) {
|
|
451
|
-
if (this._messages.length >= this._limit) {
|
|
452
|
-
this._messages.shift();
|
|
453
|
-
}
|
|
454
|
-
this._messages.push(...messages);
|
|
455
|
-
}
|
|
456
|
-
get() {
|
|
457
|
-
return this._messages;
|
|
458
|
-
}
|
|
459
|
-
};
|
|
460
|
-
|
|
461
|
-
// src/calls/util/task-scheduling.ts
|
|
462
|
-
var DefaultBatchSizeLimit = 64;
|
|
463
|
-
var FIFOScheduler = class {
|
|
464
|
-
#schedulerChain;
|
|
465
|
-
constructor() {
|
|
466
|
-
this.#schedulerChain = Promise.resolve();
|
|
467
|
-
}
|
|
468
|
-
schedule(task) {
|
|
469
|
-
return new Promise((resolve, reject) => {
|
|
470
|
-
this.#schedulerChain = this.#schedulerChain.then(async () => {
|
|
471
|
-
try {
|
|
472
|
-
resolve(await task());
|
|
473
|
-
} catch (error) {
|
|
474
|
-
reject(error);
|
|
475
|
-
}
|
|
476
|
-
});
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
};
|
|
480
|
-
var BulkRequestDispatcher = class {
|
|
481
|
-
#currentBatch;
|
|
482
|
-
#currentBulkResponse;
|
|
483
|
-
#batchSizeLimit;
|
|
484
|
-
constructor(batchSizeLimit = DefaultBatchSizeLimit) {
|
|
485
|
-
this.#currentBatch = [];
|
|
486
|
-
this.#currentBulkResponse = null;
|
|
487
|
-
this.#batchSizeLimit = batchSizeLimit;
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* Returns a bulk response promise.
|
|
491
|
-
* At the event loop iteration end, the accumulated entries will be dispatched as a bulk request.
|
|
492
|
-
*/
|
|
493
|
-
doBulkRequest(params, bulkRequestFunc) {
|
|
494
|
-
if (this.#currentBatch.length >= this.#batchSizeLimit) {
|
|
495
|
-
this.#currentBatch = [];
|
|
496
|
-
this.#currentBulkResponse = null;
|
|
497
|
-
}
|
|
498
|
-
this.#currentBatch.push(params);
|
|
499
|
-
if (this.#currentBulkResponse != null) {
|
|
500
|
-
return this.#currentBulkResponse;
|
|
501
|
-
}
|
|
502
|
-
const batch = this.#currentBatch;
|
|
503
|
-
this.#currentBulkResponse = new Promise((resolve, reject) => {
|
|
504
|
-
setTimeout(() => {
|
|
505
|
-
this.#currentBulkResponse = null;
|
|
506
|
-
const batchCopy = batch.splice(0, batch.length);
|
|
507
|
-
bulkRequestFunc(batchCopy).then((result) => {
|
|
508
|
-
resolve(result);
|
|
509
|
-
}).catch((err) => {
|
|
510
|
-
reject(err);
|
|
511
|
-
});
|
|
512
|
-
}, 0);
|
|
513
|
-
});
|
|
514
|
-
return this.#currentBulkResponse;
|
|
515
|
-
}
|
|
516
|
-
};
|
|
517
|
-
|
|
518
|
-
// src/calls/util/calls-service.ts
|
|
519
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/plugins/plugin-thread/src/calls/util/calls-service.ts";
|
|
520
|
-
var NETWORK_TIMEOUT = 5e3;
|
|
521
|
-
var CallsServicePeer = class extends Resource2 {
|
|
522
|
-
history = new HistoryCache(100);
|
|
523
|
-
_persistentLifecycle = new PersistentLifecycle({
|
|
524
|
-
start: () => this._startSession(),
|
|
525
|
-
stop: (session) => this._stopSession(session)
|
|
526
|
-
});
|
|
527
|
-
_config;
|
|
528
|
-
taskScheduler = new FIFOScheduler();
|
|
529
|
-
pushTrackDispatcher = new BulkRequestDispatcher(32);
|
|
530
|
-
pullTrackDispatcher = new BulkRequestDispatcher(32);
|
|
531
|
-
closeTrackDispatcher = new BulkRequestDispatcher(32);
|
|
532
|
-
constructor(config) {
|
|
533
|
-
super();
|
|
534
|
-
this._config = config;
|
|
535
|
-
}
|
|
536
|
-
async _open(ctx) {
|
|
537
|
-
await this._persistentLifecycle.open(ctx);
|
|
538
|
-
}
|
|
539
|
-
async _close() {
|
|
540
|
-
await this._persistentLifecycle.close();
|
|
541
|
-
}
|
|
542
|
-
get session() {
|
|
543
|
-
return this._persistentLifecycle.state;
|
|
544
|
-
}
|
|
545
|
-
async _startSession() {
|
|
546
|
-
const peerConnection = await this._createRtcConnection();
|
|
547
|
-
const sessionId = await this._initiateCallSession();
|
|
548
|
-
return {
|
|
549
|
-
sessionId,
|
|
550
|
-
peerConnection
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
async _stopSession(session) {
|
|
554
|
-
session.peerConnection.close();
|
|
555
|
-
}
|
|
556
|
-
async _createRtcConnection() {
|
|
557
|
-
const peerConnection = new RTCPeerConnection({
|
|
558
|
-
iceServers: this._config.iceServers,
|
|
559
|
-
bundlePolicy: "max-bundle"
|
|
560
|
-
});
|
|
561
|
-
peerConnection.addEventListener("connectionstatechange", () => {
|
|
562
|
-
if (peerConnection.connectionState === "failed" || peerConnection.connectionState === "closed") {
|
|
563
|
-
log2.info("calls connection failed", {
|
|
564
|
-
state: peerConnection.connectionState
|
|
565
|
-
}, {
|
|
566
|
-
F: __dxlog_file3,
|
|
567
|
-
L: 121,
|
|
568
|
-
S: this,
|
|
569
|
-
C: (f, a) => f(...a)
|
|
570
|
-
});
|
|
571
|
-
void this._persistentLifecycle.scheduleRestart();
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
let iceTimeout = -1;
|
|
575
|
-
peerConnection.addEventListener("iceconnectionstatechange", () => {
|
|
576
|
-
clearTimeout(iceTimeout);
|
|
577
|
-
if (peerConnection.iceConnectionState === "failed" || peerConnection.iceConnectionState === "closed") {
|
|
578
|
-
log2.info("calls connection to ICEs failed", {
|
|
579
|
-
state: peerConnection.iceConnectionState
|
|
580
|
-
}, {
|
|
581
|
-
F: __dxlog_file3,
|
|
582
|
-
L: 130,
|
|
583
|
-
S: this,
|
|
584
|
-
C: (f, a) => f(...a)
|
|
585
|
-
});
|
|
586
|
-
void this._persistentLifecycle.scheduleRestart();
|
|
587
|
-
} else if (peerConnection.iceConnectionState === "disconnected") {
|
|
588
|
-
const timeoutSeconds = 7;
|
|
589
|
-
iceTimeout = window.setTimeout(() => {
|
|
590
|
-
if (peerConnection.iceConnectionState === "connected") {
|
|
591
|
-
log2.info("calls iceConnectionState is connected", void 0, {
|
|
592
|
-
F: __dxlog_file3,
|
|
593
|
-
L: 139,
|
|
594
|
-
S: this,
|
|
595
|
-
C: (f, a) => f(...a)
|
|
596
|
-
});
|
|
597
|
-
return;
|
|
598
|
-
}
|
|
599
|
-
log2.info("calls iceConnectionState timed out", {
|
|
600
|
-
state: peerConnection.iceConnectionState,
|
|
601
|
-
timeoutSeconds
|
|
602
|
-
}, {
|
|
603
|
-
F: __dxlog_file3,
|
|
604
|
-
L: 143,
|
|
605
|
-
S: this,
|
|
606
|
-
C: (f, a) => f(...a)
|
|
607
|
-
});
|
|
608
|
-
void this._persistentLifecycle.scheduleRestart();
|
|
609
|
-
}, timeoutSeconds * 1e3);
|
|
610
|
-
}
|
|
611
|
-
});
|
|
612
|
-
return peerConnection;
|
|
613
|
-
}
|
|
614
|
-
async _initiateCallSession() {
|
|
615
|
-
log2("creating new session", void 0, {
|
|
616
|
-
F: __dxlog_file3,
|
|
617
|
-
L: 153,
|
|
618
|
-
S: this,
|
|
619
|
-
C: (f, a) => f(...a)
|
|
620
|
-
});
|
|
621
|
-
const { sessionId } = await this._fetch("/sessions/new?SESSION", {
|
|
622
|
-
method: "POST"
|
|
623
|
-
});
|
|
624
|
-
return sessionId;
|
|
625
|
-
}
|
|
626
|
-
async _fetch(relativePath, requestInit) {
|
|
627
|
-
this.history.push({
|
|
628
|
-
endpoint: relativePath,
|
|
629
|
-
type: "request",
|
|
630
|
-
time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
631
|
-
method: requestInit?.method ?? "GET",
|
|
632
|
-
body: requestInit?.body
|
|
633
|
-
});
|
|
634
|
-
const response = await fetch(`${this._config.apiBase}${relativePath}`, {
|
|
635
|
-
...requestInit,
|
|
636
|
-
redirect: "manual"
|
|
637
|
-
});
|
|
638
|
-
if (response.status >= 400) {
|
|
639
|
-
log2.error("error while fetching from Calls service", {
|
|
640
|
-
status: response.status,
|
|
641
|
-
text: await response.text()
|
|
642
|
-
}, {
|
|
643
|
-
F: __dxlog_file3,
|
|
644
|
-
L: 169,
|
|
645
|
-
S: this,
|
|
646
|
-
C: (f, a) => f(...a)
|
|
647
|
-
});
|
|
648
|
-
throw new Error("Error while fetching from Calls service");
|
|
649
|
-
}
|
|
650
|
-
try {
|
|
651
|
-
const data = await response.clone().json();
|
|
652
|
-
this.history.push({
|
|
653
|
-
endpoint: relativePath,
|
|
654
|
-
type: "response",
|
|
655
|
-
time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
656
|
-
status: response.status,
|
|
657
|
-
json: data
|
|
658
|
-
});
|
|
659
|
-
if (data.errorCode) {
|
|
660
|
-
throw new Error(data.errorDescription);
|
|
661
|
-
}
|
|
662
|
-
return data;
|
|
663
|
-
} catch (error) {
|
|
664
|
-
const text = await response.text();
|
|
665
|
-
this.history.push({
|
|
666
|
-
endpoint: relativePath,
|
|
667
|
-
type: "response",
|
|
668
|
-
time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
669
|
-
status: response.status,
|
|
670
|
-
text
|
|
671
|
-
});
|
|
672
|
-
log2.error("Error parsing response from Calls service", {
|
|
673
|
-
error,
|
|
674
|
-
text,
|
|
675
|
-
status: response.status
|
|
676
|
-
}, {
|
|
677
|
-
F: __dxlog_file3,
|
|
678
|
-
L: 196,
|
|
679
|
-
S: this,
|
|
680
|
-
C: (f, a) => f(...a)
|
|
681
|
-
});
|
|
682
|
-
throw error;
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
async _pushTrackInBulk({ ctx, peerConnection, transceiver, sessionId, trackName }) {
|
|
686
|
-
log2.verbose("pushing track ", trackName, {
|
|
687
|
-
F: __dxlog_file3,
|
|
688
|
-
L: 218,
|
|
689
|
-
S: this,
|
|
690
|
-
C: (f, a) => f(...a)
|
|
691
|
-
});
|
|
692
|
-
const pushedTrackPromise = this.pushTrackDispatcher.doBulkRequest({
|
|
693
|
-
trackName,
|
|
694
|
-
transceiver
|
|
695
|
-
}, (tracks) => this.taskScheduler.schedule(async () => {
|
|
696
|
-
const offer = await peerConnection.createOffer();
|
|
697
|
-
offer.sdp = offer.sdp?.replace("useinbandfec=1", "usedtx=1;useinbandfec=1");
|
|
698
|
-
await peerConnection.setLocalDescription(offer);
|
|
699
|
-
const response = await this._fetch(`/sessions/${sessionId}/tracks/new?PUSHING`, {
|
|
700
|
-
method: "POST",
|
|
701
|
-
body: JSON.stringify({
|
|
702
|
-
sessionDescription: {
|
|
703
|
-
sdp: offer.sdp,
|
|
704
|
-
type: "offer"
|
|
705
|
-
},
|
|
706
|
-
tracks: tracks.map(({ trackName: trackName2, transceiver: transceiver2 }) => ({
|
|
707
|
-
trackName: trackName2,
|
|
708
|
-
mid: transceiver2.mid,
|
|
709
|
-
location: "local"
|
|
710
|
-
}))
|
|
711
|
-
})
|
|
712
|
-
});
|
|
713
|
-
invariant3(response.tracks !== void 0, void 0, {
|
|
714
|
-
F: __dxlog_file3,
|
|
715
|
-
L: 243,
|
|
716
|
-
S: this,
|
|
717
|
-
A: [
|
|
718
|
-
"response.tracks !== undefined",
|
|
719
|
-
""
|
|
720
|
-
]
|
|
721
|
-
});
|
|
722
|
-
if (!response.errorCode) {
|
|
723
|
-
await peerConnection.setRemoteDescription(new RTCSessionDescription(response.sessionDescription));
|
|
724
|
-
await peerConnectionIsConnected(peerConnection);
|
|
725
|
-
}
|
|
726
|
-
return {
|
|
727
|
-
tracks: response.tracks
|
|
728
|
-
};
|
|
729
|
-
})).then(async ({ tracks }) => {
|
|
730
|
-
const trackData = tracks.find((t) => t.mid === transceiver.mid);
|
|
731
|
-
if (trackData) {
|
|
732
|
-
return {
|
|
733
|
-
...trackData,
|
|
734
|
-
sessionId,
|
|
735
|
-
location: "remote"
|
|
736
|
-
};
|
|
737
|
-
} else {
|
|
738
|
-
log2.error("missing track data", void 0, {
|
|
739
|
-
F: __dxlog_file3,
|
|
740
|
-
L: 267,
|
|
741
|
-
S: this,
|
|
742
|
-
C: (f, a) => f(...a)
|
|
743
|
-
});
|
|
744
|
-
}
|
|
745
|
-
});
|
|
746
|
-
const onDispose = async () => {
|
|
747
|
-
if (transceiver.mid) {
|
|
748
|
-
await this._closeTrackInBulk(peerConnection, transceiver.mid, sessionId);
|
|
749
|
-
}
|
|
750
|
-
};
|
|
751
|
-
ctx?.onDispose(async () => await onDispose());
|
|
752
|
-
this._ctx.onDispose(() => onDispose());
|
|
753
|
-
return pushedTrackPromise;
|
|
754
|
-
}
|
|
755
|
-
async pushTrack({ track, encodings = [], ctx, previousTrack }) {
|
|
756
|
-
await this.waitUntilOpen();
|
|
757
|
-
invariant3(this.session, void 0, {
|
|
758
|
-
F: __dxlog_file3,
|
|
759
|
-
L: 295,
|
|
760
|
-
S: this,
|
|
761
|
-
A: [
|
|
762
|
-
"this.session",
|
|
763
|
-
""
|
|
764
|
-
]
|
|
765
|
-
});
|
|
766
|
-
log2("trying to push track", {
|
|
767
|
-
track,
|
|
768
|
-
previousTrack,
|
|
769
|
-
encodings
|
|
770
|
-
}, {
|
|
771
|
-
F: __dxlog_file3,
|
|
772
|
-
L: 296,
|
|
773
|
-
S: this,
|
|
774
|
-
C: (f, a) => f(...a)
|
|
775
|
-
});
|
|
776
|
-
if (previousTrack) {
|
|
777
|
-
const transceiver2 = this.session.peerConnection.getTransceivers().find((t) => t.mid === previousTrack.mid);
|
|
778
|
-
if (transceiver2?.sender.track === track) {
|
|
779
|
-
log2.verbose("track already pushed", {
|
|
780
|
-
track,
|
|
781
|
-
previousTrack,
|
|
782
|
-
transceiver: transceiver2
|
|
783
|
-
}, {
|
|
784
|
-
F: __dxlog_file3,
|
|
785
|
-
L: 300,
|
|
786
|
-
S: this,
|
|
787
|
-
C: (f, a) => f(...a)
|
|
788
|
-
});
|
|
789
|
-
return previousTrack;
|
|
790
|
-
} else if (transceiver2) {
|
|
791
|
-
log2.verbose("replacing track", {
|
|
792
|
-
track,
|
|
793
|
-
previousTrack,
|
|
794
|
-
transceiver: transceiver2
|
|
795
|
-
}, {
|
|
796
|
-
F: __dxlog_file3,
|
|
797
|
-
L: 303,
|
|
798
|
-
S: this,
|
|
799
|
-
C: (f, a) => f(...a)
|
|
800
|
-
});
|
|
801
|
-
transceiver2.sender.replaceTrack(track).catch((err) => log2.catch(err, void 0, {
|
|
802
|
-
F: __dxlog_file3,
|
|
803
|
-
L: 304,
|
|
804
|
-
S: this,
|
|
805
|
-
C: (f, a) => f(...a)
|
|
806
|
-
}));
|
|
807
|
-
return previousTrack;
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
invariant3(track, void 0, {
|
|
811
|
-
F: __dxlog_file3,
|
|
812
|
-
L: 308,
|
|
813
|
-
S: this,
|
|
814
|
-
A: [
|
|
815
|
-
"track",
|
|
816
|
-
""
|
|
817
|
-
]
|
|
818
|
-
});
|
|
819
|
-
const stableId = crypto.randomUUID();
|
|
820
|
-
const transceiver = this.session.peerConnection.addTransceiver(track, {
|
|
821
|
-
direction: "sendonly"
|
|
822
|
-
});
|
|
823
|
-
log2.verbose("creating transceiver", void 0, {
|
|
824
|
-
F: __dxlog_file3,
|
|
825
|
-
L: 313,
|
|
826
|
-
S: this,
|
|
827
|
-
C: (f, a) => f(...a)
|
|
828
|
-
});
|
|
829
|
-
const pushedTrackData = await this._pushTrackInBulk({
|
|
830
|
-
ctx,
|
|
831
|
-
peerConnection: this.session.peerConnection,
|
|
832
|
-
transceiver,
|
|
833
|
-
sessionId: this.session.sessionId,
|
|
834
|
-
trackName: stableId
|
|
835
|
-
});
|
|
836
|
-
invariant3(pushedTrackData, void 0, {
|
|
837
|
-
F: __dxlog_file3,
|
|
838
|
-
L: 322,
|
|
839
|
-
S: this,
|
|
840
|
-
A: [
|
|
841
|
-
"pushedTrackData",
|
|
842
|
-
""
|
|
843
|
-
]
|
|
844
|
-
});
|
|
845
|
-
const parameters = transceiver.sender.getParameters();
|
|
846
|
-
encodings.forEach((encoding, i) => {
|
|
847
|
-
const existing = parameters.encodings[i];
|
|
848
|
-
parameters.encodings[i] = {
|
|
849
|
-
...existing,
|
|
850
|
-
...encoding
|
|
851
|
-
};
|
|
852
|
-
});
|
|
853
|
-
transceiver.sender.setParameters(parameters).catch((err) => log2.catch(err, void 0, {
|
|
854
|
-
F: __dxlog_file3,
|
|
855
|
-
L: 329,
|
|
856
|
-
S: this,
|
|
857
|
-
C: (f, a) => f(...a)
|
|
858
|
-
}));
|
|
859
|
-
return pushedTrackData;
|
|
860
|
-
}
|
|
861
|
-
// TODO(mykola): Add retry logic if the tracks fails to pull.
|
|
862
|
-
async _pullTrackInBulk({ peerConnection, sessionId, trackData, ctx }) {
|
|
863
|
-
let mid = "";
|
|
864
|
-
log2("pulling track", {
|
|
865
|
-
trackName: trackData.trackName
|
|
866
|
-
}, {
|
|
867
|
-
F: __dxlog_file3,
|
|
868
|
-
L: 347,
|
|
869
|
-
S: this,
|
|
870
|
-
C: (f, a) => f(...a)
|
|
871
|
-
});
|
|
872
|
-
const pulledTrackPromise = this.pullTrackDispatcher.doBulkRequest(trackData, (tracks) => this.taskScheduler.schedule(async () => {
|
|
873
|
-
const newTrackResponse = await this._fetch(`/sessions/${sessionId}/tracks/new?PULLING`, {
|
|
874
|
-
method: "POST",
|
|
875
|
-
body: JSON.stringify({
|
|
876
|
-
tracks
|
|
877
|
-
})
|
|
878
|
-
});
|
|
879
|
-
if (newTrackResponse.errorCode) {
|
|
880
|
-
throw new Error(newTrackResponse.errorDescription);
|
|
881
|
-
}
|
|
882
|
-
invariant3(newTrackResponse.tracks, void 0, {
|
|
883
|
-
F: __dxlog_file3,
|
|
884
|
-
L: 360,
|
|
885
|
-
S: this,
|
|
886
|
-
A: [
|
|
887
|
-
"newTrackResponse.tracks",
|
|
888
|
-
""
|
|
889
|
-
]
|
|
890
|
-
});
|
|
891
|
-
const trackMap = tracks.reduce((acc, track) => {
|
|
892
|
-
const pulledTrackData = newTrackResponse.tracks?.find((t) => t.trackName === track.trackName && t.sessionId === track.sessionId);
|
|
893
|
-
if (pulledTrackData && pulledTrackData.mid) {
|
|
894
|
-
acc.set(track.trackName, {
|
|
895
|
-
mid: pulledTrackData.mid,
|
|
896
|
-
resolvedTrack: resolveTrack(peerConnection, (t) => t.mid === pulledTrackData.mid)
|
|
897
|
-
});
|
|
898
|
-
}
|
|
899
|
-
return acc;
|
|
900
|
-
}, /* @__PURE__ */ new Map());
|
|
901
|
-
if (newTrackResponse.requiresImmediateRenegotiation) {
|
|
902
|
-
await peerConnection.setRemoteDescription(new RTCSessionDescription(newTrackResponse.sessionDescription));
|
|
903
|
-
const answer = await peerConnection.createAnswer();
|
|
904
|
-
await peerConnection.setLocalDescription(answer);
|
|
905
|
-
const renegotiationResponse = await this._fetch(`/sessions/${sessionId}/renegotiate`, {
|
|
906
|
-
method: "PUT",
|
|
907
|
-
body: JSON.stringify({
|
|
908
|
-
sessionDescription: {
|
|
909
|
-
type: "answer",
|
|
910
|
-
sdp: peerConnection.currentLocalDescription?.sdp
|
|
911
|
-
}
|
|
912
|
-
})
|
|
913
|
-
});
|
|
914
|
-
if (renegotiationResponse.errorCode) {
|
|
915
|
-
throw new Error(renegotiationResponse.errorDescription);
|
|
916
|
-
} else {
|
|
917
|
-
await peerConnectionIsConnected(peerConnection);
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
return {
|
|
921
|
-
trackMap
|
|
922
|
-
};
|
|
923
|
-
})).then(({ trackMap }) => {
|
|
924
|
-
const trackInfo = trackMap.get(trackData.trackName);
|
|
925
|
-
if (trackInfo) {
|
|
926
|
-
return trackInfo.resolvedTrack.then((track) => {
|
|
927
|
-
mid = trackInfo.mid;
|
|
928
|
-
return track;
|
|
929
|
-
}).catch((err) => log2.catch(err, void 0, {
|
|
930
|
-
F: __dxlog_file3,
|
|
931
|
-
L: 412,
|
|
932
|
-
S: this,
|
|
933
|
-
C: (f, a) => f(...a)
|
|
934
|
-
}));
|
|
935
|
-
} else {
|
|
936
|
-
log2.info("missing track info", {
|
|
937
|
-
trackData,
|
|
938
|
-
availableTracks: Array.from(trackMap.keys())
|
|
939
|
-
}, {
|
|
940
|
-
F: __dxlog_file3,
|
|
941
|
-
L: 414,
|
|
942
|
-
S: this,
|
|
943
|
-
C: (f, a) => f(...a)
|
|
944
|
-
});
|
|
945
|
-
}
|
|
946
|
-
});
|
|
947
|
-
const onDispose = async () => {
|
|
948
|
-
if (mid) {
|
|
949
|
-
log2("closing pulled track ", trackData.trackName, {
|
|
950
|
-
F: __dxlog_file3,
|
|
951
|
-
L: 420,
|
|
952
|
-
S: this,
|
|
953
|
-
C: (f, a) => f(...a)
|
|
954
|
-
});
|
|
955
|
-
await this._closeTrackInBulk(peerConnection, mid, sessionId);
|
|
956
|
-
mid = "";
|
|
957
|
-
}
|
|
958
|
-
};
|
|
959
|
-
this._ctx.onDispose(() => onDispose());
|
|
960
|
-
ctx?.onDispose(() => onDispose());
|
|
961
|
-
return pulledTrackPromise;
|
|
962
|
-
}
|
|
963
|
-
async pullTrack({ ctx, trackData }) {
|
|
964
|
-
await this.waitUntilOpen();
|
|
965
|
-
invariant3(this.session, void 0, {
|
|
966
|
-
F: __dxlog_file3,
|
|
967
|
-
L: 441,
|
|
968
|
-
S: this,
|
|
969
|
-
A: [
|
|
970
|
-
"this.session",
|
|
971
|
-
""
|
|
972
|
-
]
|
|
973
|
-
});
|
|
974
|
-
const session = this.session;
|
|
975
|
-
return this._pullTrackInBulk({
|
|
976
|
-
peerConnection: session.peerConnection,
|
|
977
|
-
sessionId: session.sessionId,
|
|
978
|
-
trackData,
|
|
979
|
-
ctx
|
|
980
|
-
});
|
|
981
|
-
}
|
|
982
|
-
async _closeTrackInBulk(peerConnection, mid, sessionId) {
|
|
983
|
-
const transceiver = peerConnection.getTransceivers().find((t) => t.mid === mid);
|
|
984
|
-
if (peerConnection.connectionState !== "connected" || transceiver === void 0) {
|
|
985
|
-
return;
|
|
986
|
-
}
|
|
987
|
-
await this.closeTrackDispatcher.doBulkRequest({
|
|
988
|
-
mid
|
|
989
|
-
}, (mids) => this.taskScheduler.schedule(async () => {
|
|
990
|
-
transceiver.stop();
|
|
991
|
-
const activeTransceivers = peerConnection.getTransceivers().filter((t) => t.mid !== mid && t.direction !== "stopped");
|
|
992
|
-
let requestBody;
|
|
993
|
-
if (activeTransceivers.length > 0) {
|
|
994
|
-
const offer = await peerConnection.createOffer();
|
|
995
|
-
await peerConnection.setLocalDescription(offer);
|
|
996
|
-
requestBody = {
|
|
997
|
-
tracks: mids,
|
|
998
|
-
sessionDescription: {
|
|
999
|
-
sdp: peerConnection.localDescription?.sdp,
|
|
1000
|
-
type: "offer"
|
|
1001
|
-
},
|
|
1002
|
-
force: false
|
|
1003
|
-
};
|
|
1004
|
-
} else {
|
|
1005
|
-
requestBody = {
|
|
1006
|
-
tracks: mids,
|
|
1007
|
-
force: true
|
|
1008
|
-
};
|
|
1009
|
-
}
|
|
1010
|
-
const response = await this._fetch(`/sessions/${sessionId}/tracks/close`, {
|
|
1011
|
-
method: "PUT",
|
|
1012
|
-
body: JSON.stringify(requestBody)
|
|
1013
|
-
});
|
|
1014
|
-
if (requestBody.sessionDescription) {
|
|
1015
|
-
await peerConnection.setRemoteDescription(new RTCSessionDescription(response.sessionDescription));
|
|
1016
|
-
}
|
|
1017
|
-
}));
|
|
1018
|
-
}
|
|
1019
|
-
};
|
|
1020
|
-
var resolveTrack = async (peerConnection, compare, timeout = NETWORK_TIMEOUT) => new Promise((resolve, reject) => {
|
|
1021
|
-
setTimeout(reject, timeout);
|
|
1022
|
-
const handler = () => {
|
|
1023
|
-
const transceiver = peerConnection.getTransceivers().find(compare);
|
|
1024
|
-
if (transceiver) {
|
|
1025
|
-
resolve(transceiver.receiver.track);
|
|
1026
|
-
peerConnection.removeEventListener("track", handler);
|
|
1027
|
-
}
|
|
1028
|
-
};
|
|
1029
|
-
peerConnection.addEventListener("track", handler);
|
|
1030
|
-
});
|
|
1031
|
-
var peerConnectionIsConnected = async (peerConnection) => {
|
|
1032
|
-
if (peerConnection.connectionState !== "connected") {
|
|
1033
|
-
const connected = new Promise((resolve, reject) => {
|
|
1034
|
-
const timeout = setTimeout(() => {
|
|
1035
|
-
peerConnection.removeEventListener("connectionstatechange", connectionStateChangeHandler);
|
|
1036
|
-
reject(new Error("Connection timeout"));
|
|
1037
|
-
}, NETWORK_TIMEOUT);
|
|
1038
|
-
const connectionStateChangeHandler = () => {
|
|
1039
|
-
if (peerConnection.connectionState === "connected") {
|
|
1040
|
-
peerConnection.removeEventListener("connectionstatechange", connectionStateChangeHandler);
|
|
1041
|
-
clearTimeout(timeout);
|
|
1042
|
-
resolve(void 0);
|
|
1043
|
-
}
|
|
1044
|
-
};
|
|
1045
|
-
peerConnection.addEventListener("connectionstatechange", connectionStateChangeHandler);
|
|
1046
|
-
});
|
|
1047
|
-
await connected;
|
|
1048
|
-
}
|
|
1049
|
-
};
|
|
1050
|
-
|
|
1051
|
-
// src/calls/util/media.ts
|
|
1052
|
-
import { log as log3 } from "@dxos/log";
|
|
1053
|
-
var __dxlog_file4 = "/__w/dxos/dxos/packages/plugins/plugin-thread/src/calls/util/media.ts";
|
|
1054
|
-
var getUserMediaTrack = async (kind, constraints = {}, deviceList) => {
|
|
1055
|
-
deviceList ??= (await getDeviceList()).filter((device) => device.kind === kind);
|
|
1056
|
-
const firstDevice = deviceList[0];
|
|
1057
|
-
if (!firstDevice) {
|
|
1058
|
-
throw new Error("No devices found");
|
|
1059
|
-
}
|
|
1060
|
-
return acquireTrack(firstDevice, constraints);
|
|
1061
|
-
};
|
|
1062
|
-
var acquireTrack = async (device, constraints) => {
|
|
1063
|
-
const { deviceId, label } = device;
|
|
1064
|
-
log3.info(`requesting ${label}`, void 0, {
|
|
1065
|
-
F: __dxlog_file4,
|
|
1066
|
-
L: 23,
|
|
1067
|
-
S: void 0,
|
|
1068
|
-
C: (f, a) => f(...a)
|
|
1069
|
-
});
|
|
1070
|
-
const mediaStream = await navigator.mediaDevices.getUserMedia(device.kind === "videoinput" ? {
|
|
1071
|
-
video: {
|
|
1072
|
-
...constraints,
|
|
1073
|
-
deviceId
|
|
1074
|
-
}
|
|
1075
|
-
} : {
|
|
1076
|
-
audio: {
|
|
1077
|
-
...constraints,
|
|
1078
|
-
deviceId
|
|
1079
|
-
}
|
|
1080
|
-
});
|
|
1081
|
-
return device.kind === "videoinput" ? mediaStream.getVideoTracks()[0] : mediaStream.getAudioTracks()[0];
|
|
1082
|
-
};
|
|
1083
|
-
var getDeviceList = () => navigator.mediaDevices.enumerateDevices();
|
|
1084
|
-
var SCREENSHARE_CONSTRAINTS = {
|
|
1085
|
-
video: {
|
|
1086
|
-
width: {
|
|
1087
|
-
max: 1920
|
|
1088
|
-
},
|
|
1089
|
-
height: {
|
|
1090
|
-
max: 1080
|
|
1091
|
-
},
|
|
1092
|
-
frameRate: {
|
|
1093
|
-
max: 10
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
};
|
|
1097
|
-
var getScreenshare = async ({ contentHint }) => {
|
|
1098
|
-
const ms = await navigator.mediaDevices.getDisplayMedia(SCREENSHARE_CONSTRAINTS);
|
|
1099
|
-
ms.getVideoTracks().forEach((track) => {
|
|
1100
|
-
if (contentHint && "contentHint" in track) {
|
|
1101
|
-
track.contentHint = contentHint;
|
|
1102
|
-
}
|
|
1103
|
-
});
|
|
1104
|
-
return ms;
|
|
1105
|
-
};
|
|
1106
|
-
|
|
1107
|
-
// src/calls/speaking-monitor.ts
|
|
1108
|
-
import { DeferredTask as DeferredTask2, Event as Event2, sleep } from "@dxos/async";
|
|
1109
|
-
import { Resource as Resource3 } from "@dxos/context";
|
|
1110
|
-
var NOT_SPEAKING_AFTER = 500;
|
|
1111
|
-
var START_SPEAKING_THRESHOLD = 0.05;
|
|
1112
|
-
var CONTINUE_SPEAKING_THRESHOLD = 0.02;
|
|
1113
|
-
var MIN_EVENT_INTERVAL = 100;
|
|
1114
|
-
var SpeakingMonitor = class extends Resource3 {
|
|
1115
|
-
_mediaStreamTrack;
|
|
1116
|
-
/**
|
|
1117
|
-
* Event that is emitted when the user starts or stops speaking.
|
|
1118
|
-
* It is debounced to prevent rapid state changes.
|
|
1119
|
-
*/
|
|
1120
|
-
speakingChanged = new Event2();
|
|
1121
|
-
/**
|
|
1122
|
-
* Real state of the user speaking.
|
|
1123
|
-
*/
|
|
1124
|
-
_isSpeaking = false;
|
|
1125
|
-
_lastEventTime = 0;
|
|
1126
|
-
_deferredUpdate;
|
|
1127
|
-
constructor(_mediaStreamTrack) {
|
|
1128
|
-
super(), this._mediaStreamTrack = _mediaStreamTrack;
|
|
1129
|
-
}
|
|
1130
|
-
get isSpeaking() {
|
|
1131
|
-
return this._isSpeaking;
|
|
1132
|
-
}
|
|
1133
|
-
async _open() {
|
|
1134
|
-
this._deferredUpdate = new DeferredTask2(this._ctx, async () => this._emitSpeakingChanged());
|
|
1135
|
-
let timeout;
|
|
1136
|
-
const cleanup = monitorAudioLevel({
|
|
1137
|
-
mediaStreamTrack: this._mediaStreamTrack,
|
|
1138
|
-
onMeasure: (vol) => {
|
|
1139
|
-
const audioLevelAboveThreshold = vol > (this._isSpeaking ? CONTINUE_SPEAKING_THRESHOLD : START_SPEAKING_THRESHOLD);
|
|
1140
|
-
if (audioLevelAboveThreshold) {
|
|
1141
|
-
clearTimeout(timeout);
|
|
1142
|
-
timeout = void 0;
|
|
1143
|
-
if (!this._isSpeaking) {
|
|
1144
|
-
this._isSpeaking = true;
|
|
1145
|
-
this._deferredUpdate?.schedule();
|
|
1146
|
-
}
|
|
1147
|
-
} else if (timeout === void 0) {
|
|
1148
|
-
timeout = setTimeout(() => {
|
|
1149
|
-
this._isSpeaking = false;
|
|
1150
|
-
timeout = void 0;
|
|
1151
|
-
this._deferredUpdate?.schedule();
|
|
1152
|
-
}, NOT_SPEAKING_AFTER);
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
|
-
});
|
|
1156
|
-
this._ctx.onDispose(() => {
|
|
1157
|
-
cleanup();
|
|
1158
|
-
clearTimeout(timeout);
|
|
1159
|
-
});
|
|
1160
|
-
}
|
|
1161
|
-
/**
|
|
1162
|
-
* Emits the speaking changed event with debouncing based on timing.
|
|
1163
|
-
*/
|
|
1164
|
-
async _emitSpeakingChanged() {
|
|
1165
|
-
const timeSinceLastEvent = Date.now() - this._lastEventTime;
|
|
1166
|
-
const timeToNextEvent = MIN_EVENT_INTERVAL - timeSinceLastEvent;
|
|
1167
|
-
if (timeToNextEvent > 0) {
|
|
1168
|
-
await sleep(timeToNextEvent);
|
|
1169
|
-
}
|
|
1170
|
-
this._lastEventTime = Date.now();
|
|
1171
|
-
this.speakingChanged.emit(this._isSpeaking);
|
|
1172
|
-
}
|
|
1173
|
-
};
|
|
1174
|
-
|
|
1175
|
-
// src/calls/media-manager.ts
|
|
1176
|
-
import { DeferredTask as DeferredTask3, Event as Event3, sleep as sleep2, synchronized as synchronized2 } from "@dxos/async";
|
|
1177
|
-
import { Resource as Resource4, cancelWithContext } from "@dxos/context";
|
|
1178
|
-
import { invariant as invariant4 } from "@dxos/invariant";
|
|
1179
|
-
import { log as log4 } from "@dxos/log";
|
|
1180
|
-
function _ts_decorate2(decorators, target, key, desc) {
|
|
1181
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1182
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1183
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1184
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1185
|
-
}
|
|
1186
|
-
var __dxlog_file5 = "/__w/dxos/dxos/packages/plugins/plugin-thread/src/calls/media-manager.ts";
|
|
1187
|
-
var VIDEO_WIDTH = 1280;
|
|
1188
|
-
var VIDEO_HEIGHT = 720;
|
|
1189
|
-
var MAX_WEB_CAM_FRAMERATE = 24;
|
|
1190
|
-
var MAX_WEB_CAM_BITRATE = 12e5;
|
|
1191
|
-
var RETRY_INTERVAL = 100;
|
|
1192
|
-
var USE_INAUDIBLE_AUDIO = true;
|
|
1193
|
-
var MediaManager = class extends Resource4 {
|
|
1194
|
-
stateUpdated = new Event3();
|
|
1195
|
-
_state = {
|
|
1196
|
-
pulledVideoStreams: {},
|
|
1197
|
-
pulledAudioTracks: {}
|
|
1198
|
-
};
|
|
1199
|
-
_speakingMonitor = void 0;
|
|
1200
|
-
_trackToReconcile = [];
|
|
1201
|
-
_blackCanvasStreamTrack = void 0;
|
|
1202
|
-
_inaudibleAudioStreamTrack = void 0;
|
|
1203
|
-
_pushTracksTask = void 0;
|
|
1204
|
-
_pullTracksTask = void 0;
|
|
1205
|
-
get isSpeaking() {
|
|
1206
|
-
return this._speakingMonitor?.isSpeaking;
|
|
1207
|
-
}
|
|
1208
|
-
/**
|
|
1209
|
-
* @internal
|
|
1210
|
-
*/
|
|
1211
|
-
_getState() {
|
|
1212
|
-
return this._state;
|
|
1213
|
-
}
|
|
1214
|
-
async _open() {
|
|
1215
|
-
this._blackCanvasStreamTrack = await createBlackCanvasStreamTrack({
|
|
1216
|
-
ctx: this._ctx,
|
|
1217
|
-
width: VIDEO_WIDTH,
|
|
1218
|
-
height: VIDEO_HEIGHT
|
|
1219
|
-
});
|
|
1220
|
-
this._state.videoTrack = this._blackCanvasStreamTrack;
|
|
1221
|
-
this._state.videoStream = new MediaStream();
|
|
1222
|
-
this._state.videoStream.addTrack(this._state.videoTrack);
|
|
1223
|
-
if (USE_INAUDIBLE_AUDIO) {
|
|
1224
|
-
this._inaudibleAudioStreamTrack = await createInaudibleAudioStreamTrack({
|
|
1225
|
-
ctx: this._ctx
|
|
1226
|
-
});
|
|
1227
|
-
this._state.audioTrack = this._inaudibleAudioStreamTrack;
|
|
1228
|
-
}
|
|
1229
|
-
this._pushTracksTask = new DeferredTask3(this._ctx, async () => {
|
|
1230
|
-
await this._pushTracks();
|
|
1231
|
-
});
|
|
1232
|
-
this._pullTracksTask = new DeferredTask3(this._ctx, async () => {
|
|
1233
|
-
await this._reconcilePulledMedia();
|
|
1234
|
-
});
|
|
1235
|
-
}
|
|
1236
|
-
async _close() {
|
|
1237
|
-
void this._speakingMonitor?.close();
|
|
1238
|
-
this._state.videoTrack && this._state.videoStream?.removeTrack(this._state.videoTrack);
|
|
1239
|
-
this._state.audioTrack?.stop();
|
|
1240
|
-
this._state.videoTrack?.stop();
|
|
1241
|
-
this._state.screenshareTrack?.stop();
|
|
1242
|
-
this._pushTracksTask = void 0;
|
|
1243
|
-
this._pullTracksTask = void 0;
|
|
1244
|
-
}
|
|
1245
|
-
async join(serviceConfig) {
|
|
1246
|
-
this._state.peer = new CallsServicePeer(serviceConfig);
|
|
1247
|
-
await this._state.peer.open();
|
|
1248
|
-
this._pushTracksTask.schedule();
|
|
1249
|
-
}
|
|
1250
|
-
async leave() {
|
|
1251
|
-
await Promise.all(Object.values(this._state.pulledAudioTracks).map(({ ctx }) => ctx.dispose()));
|
|
1252
|
-
await Promise.all(Object.values(this._state.pulledVideoStreams).map(({ ctx }) => ctx.dispose()));
|
|
1253
|
-
this._trackToReconcile = [];
|
|
1254
|
-
await this._state.peer?.close();
|
|
1255
|
-
this._state.peer = void 0;
|
|
1256
|
-
this._state.pushedVideoTrack = void 0;
|
|
1257
|
-
this._state.pushedAudioTrack = void 0;
|
|
1258
|
-
this._state.pushedScreenshareTrack = void 0;
|
|
1259
|
-
this._state.pulledAudioTracks = {};
|
|
1260
|
-
this._state.pulledVideoStreams = {};
|
|
1261
|
-
}
|
|
1262
|
-
async turnVideoOn() {
|
|
1263
|
-
this._state.videoStream.removeTrack(this._state.videoTrack);
|
|
1264
|
-
this._state.videoTrack = await getUserMediaTrack("videoinput", {
|
|
1265
|
-
width: VIDEO_WIDTH,
|
|
1266
|
-
height: VIDEO_HEIGHT
|
|
1267
|
-
});
|
|
1268
|
-
this._state.videoStream.addTrack(this._state.videoTrack);
|
|
1269
|
-
this._state.videoEnabled = true;
|
|
1270
|
-
this.stateUpdated.emit(this._state);
|
|
1271
|
-
this._pushTracksTask.schedule();
|
|
1272
|
-
}
|
|
1273
|
-
async turnVideoOff() {
|
|
1274
|
-
if (this._state.videoTrack !== this._blackCanvasStreamTrack) {
|
|
1275
|
-
this._state.videoStream.removeTrack(this._state.videoTrack);
|
|
1276
|
-
this._state.videoTrack?.stop();
|
|
1277
|
-
this._state.videoTrack = this._blackCanvasStreamTrack;
|
|
1278
|
-
this._state.videoStream.addTrack(this._state.videoTrack);
|
|
1279
|
-
}
|
|
1280
|
-
this._state.videoEnabled = false;
|
|
1281
|
-
this.stateUpdated.emit(this._state);
|
|
1282
|
-
this._pushTracksTask.schedule();
|
|
1283
|
-
}
|
|
1284
|
-
// TODO(mykola): Change to `setAudioEnabled(enabled: boolean)`.
|
|
1285
|
-
async turnAudioOn() {
|
|
1286
|
-
void this._speakingMonitor?.close();
|
|
1287
|
-
this._state.audioEnabled = true;
|
|
1288
|
-
this._state.audioTrack = await getUserMediaTrack("audioinput", {
|
|
1289
|
-
echoCancellation: true,
|
|
1290
|
-
noiseSuppression: true,
|
|
1291
|
-
autoGainControl: true,
|
|
1292
|
-
sampleRate: 16e3
|
|
1293
|
-
});
|
|
1294
|
-
this.stateUpdated.emit(this._state);
|
|
1295
|
-
this._pushTracksTask.schedule();
|
|
1296
|
-
this._speakingMonitor = new SpeakingMonitor(this._state.audioTrack);
|
|
1297
|
-
this._speakingMonitor.speakingChanged.on(this._ctx, () => this.stateUpdated.emit(this._state));
|
|
1298
|
-
void this._speakingMonitor.open();
|
|
1299
|
-
}
|
|
1300
|
-
async turnAudioOff() {
|
|
1301
|
-
void this._speakingMonitor?.close();
|
|
1302
|
-
this._speakingMonitor = void 0;
|
|
1303
|
-
this._state.audioEnabled = false;
|
|
1304
|
-
if (USE_INAUDIBLE_AUDIO && this._state.audioTrack !== this._inaudibleAudioStreamTrack) {
|
|
1305
|
-
this._state.audioTrack?.stop();
|
|
1306
|
-
this._state.audioTrack = this._inaudibleAudioStreamTrack;
|
|
1307
|
-
} else {
|
|
1308
|
-
this._state.audioTrack?.stop();
|
|
1309
|
-
this._state.audioTrack = void 0;
|
|
1310
|
-
}
|
|
1311
|
-
this.stateUpdated.emit(this._state);
|
|
1312
|
-
this._pushTracksTask.schedule();
|
|
1313
|
-
}
|
|
1314
|
-
async turnScreenshareOn() {
|
|
1315
|
-
const ms = await getScreenshare({
|
|
1316
|
-
contentHint: "text"
|
|
1317
|
-
});
|
|
1318
|
-
this._state.screenshareVideoStream = ms;
|
|
1319
|
-
this._state.screenshareTrack = ms.getVideoTracks()[0];
|
|
1320
|
-
this._state.screenshareEnabled = true;
|
|
1321
|
-
this.stateUpdated.emit(this._state);
|
|
1322
|
-
this._pushTracksTask.schedule();
|
|
1323
|
-
}
|
|
1324
|
-
async turnScreenshareOff() {
|
|
1325
|
-
this._state.screenshareEnabled = false;
|
|
1326
|
-
this._state.screenshareTrack?.stop();
|
|
1327
|
-
this._state.screenshareTrack = void 0;
|
|
1328
|
-
this.stateUpdated.emit(this._state);
|
|
1329
|
-
this._pushTracksTask.schedule();
|
|
1330
|
-
}
|
|
1331
|
-
/**
|
|
1332
|
-
* @internal
|
|
1333
|
-
*/
|
|
1334
|
-
_schedulePullTracks(tracks) {
|
|
1335
|
-
if (!tracks || this._trackToReconcile.every((name) => tracks.includes(name)) && this._trackToReconcile.length === tracks.length) {
|
|
1336
|
-
return;
|
|
1337
|
-
}
|
|
1338
|
-
this._trackToReconcile = tracks;
|
|
1339
|
-
this._pullTracksTask.schedule();
|
|
1340
|
-
}
|
|
1341
|
-
async _reconcilePulledMedia() {
|
|
1342
|
-
log4("reconciling tracks", void 0, {
|
|
1343
|
-
F: __dxlog_file5,
|
|
1344
|
-
L: 229,
|
|
1345
|
-
S: this,
|
|
1346
|
-
C: (f, a) => f(...a)
|
|
1347
|
-
});
|
|
1348
|
-
await cancelWithContext(this._ctx, sleep2(800));
|
|
1349
|
-
const trackNames = this._trackToReconcile;
|
|
1350
|
-
const tracksToPull = trackNames.filter((name) => !this._state.pulledAudioTracks[name] && !this._state.pulledVideoStreams[name]);
|
|
1351
|
-
const audioTracksToClose = Object.entries(this._state.pulledAudioTracks).filter(([key]) => !trackNames.some((name) => name === key));
|
|
1352
|
-
const videoStreamsToClose = Object.entries(this._state.pulledVideoStreams).filter(([key]) => !trackNames.some((name) => name === key));
|
|
1353
|
-
log4("reconciling tracks", {
|
|
1354
|
-
trackNames,
|
|
1355
|
-
tracksToPull,
|
|
1356
|
-
videoStreamsToClose,
|
|
1357
|
-
audioTracksToClose,
|
|
1358
|
-
currentAudioTracks: Object.keys(this._state.pulledAudioTracks),
|
|
1359
|
-
currentVideoStreams: Object.keys(this._state.pulledVideoStreams)
|
|
1360
|
-
}, {
|
|
1361
|
-
F: __dxlog_file5,
|
|
1362
|
-
L: 247,
|
|
1363
|
-
S: this,
|
|
1364
|
-
C: (f, a) => f(...a)
|
|
1365
|
-
});
|
|
1366
|
-
const pullResults = await Promise.all(tracksToPull.map((name) => this._pullTrack(name)));
|
|
1367
|
-
await Promise.all([
|
|
1368
|
-
...audioTracksToClose,
|
|
1369
|
-
...videoStreamsToClose
|
|
1370
|
-
].map(([_, { ctx }]) => ctx.dispose()));
|
|
1371
|
-
log4("reconciled tracks", {
|
|
1372
|
-
currentAudioTracks: Object.keys(this._state.pulledAudioTracks),
|
|
1373
|
-
currentVideoStreams: Object.keys(this._state.pulledVideoStreams)
|
|
1374
|
-
}, {
|
|
1375
|
-
F: __dxlog_file5,
|
|
1376
|
-
L: 262,
|
|
1377
|
-
S: this,
|
|
1378
|
-
C: (f, a) => f(...a)
|
|
1379
|
-
});
|
|
1380
|
-
this.stateUpdated.emit(this._state);
|
|
1381
|
-
if (pullResults.some(({ shouldRetry }) => shouldRetry)) {
|
|
1382
|
-
await cancelWithContext(this._ctx, sleep2(RETRY_INTERVAL));
|
|
1383
|
-
log4.info("retrying pull tracks", {
|
|
1384
|
-
tracksToPull
|
|
1385
|
-
}, {
|
|
1386
|
-
F: __dxlog_file5,
|
|
1387
|
-
L: 270,
|
|
1388
|
-
S: this,
|
|
1389
|
-
C: (f, a) => f(...a)
|
|
1390
|
-
});
|
|
1391
|
-
invariant4(this._pullTracksTask, void 0, {
|
|
1392
|
-
F: __dxlog_file5,
|
|
1393
|
-
L: 271,
|
|
1394
|
-
S: this,
|
|
1395
|
-
A: [
|
|
1396
|
-
"this._pullTracksTask",
|
|
1397
|
-
""
|
|
1398
|
-
]
|
|
1399
|
-
});
|
|
1400
|
-
this._pullTracksTask.schedule();
|
|
1401
|
-
}
|
|
1402
|
-
}
|
|
1403
|
-
async _pushTracks() {
|
|
1404
|
-
if (!this._state.peer?.isOpen) {
|
|
1405
|
-
return;
|
|
1406
|
-
}
|
|
1407
|
-
let updated = false;
|
|
1408
|
-
const [pushVideoResult, pushAudioResult, pushScreenshareResult] = await Promise.all([
|
|
1409
|
-
this._maybePushTrack(this._state.videoTrack, this._state.pushedVideoTrack, [
|
|
1410
|
-
{
|
|
1411
|
-
maxFramerate: MAX_WEB_CAM_FRAMERATE,
|
|
1412
|
-
maxBitrate: MAX_WEB_CAM_BITRATE
|
|
1413
|
-
}
|
|
1414
|
-
]),
|
|
1415
|
-
this._maybePushTrack(this._state.audioTrack, this._state.pushedAudioTrack, [
|
|
1416
|
-
{
|
|
1417
|
-
networkPriority: "high"
|
|
1418
|
-
}
|
|
1419
|
-
]),
|
|
1420
|
-
this._maybePushTrack(this._state.screenshareTrack, this._state.pushedScreenshareTrack)
|
|
1421
|
-
]);
|
|
1422
|
-
if (pushVideoResult.track !== this._state.pushedVideoTrack) {
|
|
1423
|
-
this._state.pushedVideoTrack = pushVideoResult.track;
|
|
1424
|
-
updated = true;
|
|
1425
|
-
}
|
|
1426
|
-
if (pushAudioResult.track !== this._state.pushedAudioTrack) {
|
|
1427
|
-
this._state.pushedAudioTrack = pushAudioResult.track;
|
|
1428
|
-
updated = true;
|
|
1429
|
-
}
|
|
1430
|
-
if (pushScreenshareResult.track !== this._state.pushedScreenshareTrack) {
|
|
1431
|
-
this._state.pushedScreenshareTrack = pushScreenshareResult.track;
|
|
1432
|
-
updated = true;
|
|
1433
|
-
}
|
|
1434
|
-
const shouldRetry = pushVideoResult.shouldRetry || pushAudioResult.shouldRetry || pushScreenshareResult.shouldRetry;
|
|
1435
|
-
if (updated) {
|
|
1436
|
-
this.stateUpdated.emit(this._state);
|
|
1437
|
-
}
|
|
1438
|
-
if (shouldRetry) {
|
|
1439
|
-
await cancelWithContext(this._ctx, sleep2(RETRY_INTERVAL));
|
|
1440
|
-
log4.info("retrying push tracks", {
|
|
1441
|
-
pushVideoResult,
|
|
1442
|
-
pushAudioResult,
|
|
1443
|
-
pushScreenshareResult
|
|
1444
|
-
}, {
|
|
1445
|
-
F: __dxlog_file5,
|
|
1446
|
-
L: 310,
|
|
1447
|
-
S: this,
|
|
1448
|
-
C: (f, a) => f(...a)
|
|
1449
|
-
});
|
|
1450
|
-
invariant4(this._pushTracksTask, void 0, {
|
|
1451
|
-
F: __dxlog_file5,
|
|
1452
|
-
L: 311,
|
|
1453
|
-
S: this,
|
|
1454
|
-
A: [
|
|
1455
|
-
"this._pushTracksTask",
|
|
1456
|
-
""
|
|
1457
|
-
]
|
|
1458
|
-
});
|
|
1459
|
-
this._pushTracksTask.schedule();
|
|
1460
|
-
}
|
|
1461
|
-
}
|
|
1462
|
-
async _pullTrack(name) {
|
|
1463
|
-
const ctx = this._ctx.derive();
|
|
1464
|
-
try {
|
|
1465
|
-
const trackData = TrackNameCodec.decode(name);
|
|
1466
|
-
const track = await this._state.peer.pullTrack({
|
|
1467
|
-
trackData: {
|
|
1468
|
-
...trackData,
|
|
1469
|
-
mid: void 0
|
|
1470
|
-
},
|
|
1471
|
-
ctx
|
|
1472
|
-
});
|
|
1473
|
-
if (track?.readyState === "ended") {
|
|
1474
|
-
throw new Error("Pulled track ended immediately");
|
|
1475
|
-
}
|
|
1476
|
-
switch (track?.kind) {
|
|
1477
|
-
case "audio": {
|
|
1478
|
-
this._state.pulledAudioTracks[name] = {
|
|
1479
|
-
track,
|
|
1480
|
-
ctx
|
|
1481
|
-
};
|
|
1482
|
-
ctx.onDispose(() => delete this._state.pulledAudioTracks[name]);
|
|
1483
|
-
return {
|
|
1484
|
-
shouldRetry: false
|
|
1485
|
-
};
|
|
1486
|
-
}
|
|
1487
|
-
case "video": {
|
|
1488
|
-
const mediaStream = new MediaStream();
|
|
1489
|
-
mediaStream.addTrack(track);
|
|
1490
|
-
this._state.pulledVideoStreams[name] = {
|
|
1491
|
-
stream: mediaStream,
|
|
1492
|
-
ctx
|
|
1493
|
-
};
|
|
1494
|
-
ctx.onDispose(() => {
|
|
1495
|
-
mediaStream.removeTrack(track);
|
|
1496
|
-
track.stop();
|
|
1497
|
-
delete this._state.pulledVideoStreams[name];
|
|
1498
|
-
});
|
|
1499
|
-
return {
|
|
1500
|
-
shouldRetry: false
|
|
1501
|
-
};
|
|
1502
|
-
}
|
|
1503
|
-
default:
|
|
1504
|
-
throw new Error(`Invalid track kind: ${track?.kind}`);
|
|
1505
|
-
}
|
|
1506
|
-
} catch (err) {
|
|
1507
|
-
log4.info("failed to pull track", {
|
|
1508
|
-
err,
|
|
1509
|
-
name
|
|
1510
|
-
}, {
|
|
1511
|
-
F: __dxlog_file5,
|
|
1512
|
-
L: 347,
|
|
1513
|
-
S: this,
|
|
1514
|
-
C: (f, a) => f(...a)
|
|
1515
|
-
});
|
|
1516
|
-
void ctx.dispose();
|
|
1517
|
-
return {
|
|
1518
|
-
shouldRetry: true
|
|
1519
|
-
};
|
|
1520
|
-
}
|
|
1521
|
-
}
|
|
1522
|
-
async _maybePushTrack(track, previousTrack, encodings) {
|
|
1523
|
-
if (!track && !previousTrack) {
|
|
1524
|
-
return {
|
|
1525
|
-
track: void 0
|
|
1526
|
-
};
|
|
1527
|
-
}
|
|
1528
|
-
const ctx = this._ctx.derive();
|
|
1529
|
-
try {
|
|
1530
|
-
return {
|
|
1531
|
-
track: await this._state.peer.pushTrack({
|
|
1532
|
-
ctx,
|
|
1533
|
-
track: track ?? null,
|
|
1534
|
-
previousTrack,
|
|
1535
|
-
encodings
|
|
1536
|
-
})
|
|
1537
|
-
};
|
|
1538
|
-
} catch (err) {
|
|
1539
|
-
log4.info("failed to push track", {
|
|
1540
|
-
err,
|
|
1541
|
-
track,
|
|
1542
|
-
previousTrack,
|
|
1543
|
-
encodings
|
|
1544
|
-
}, {
|
|
1545
|
-
F: __dxlog_file5,
|
|
1546
|
-
L: 373,
|
|
1547
|
-
S: this,
|
|
1548
|
-
C: (f, a) => f(...a)
|
|
1549
|
-
});
|
|
1550
|
-
void ctx.dispose();
|
|
1551
|
-
return {
|
|
1552
|
-
shouldRetry: true
|
|
1553
|
-
};
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
1556
|
-
};
|
|
1557
|
-
_ts_decorate2([
|
|
1558
|
-
synchronized2
|
|
1559
|
-
], MediaManager.prototype, "join", null);
|
|
1560
|
-
_ts_decorate2([
|
|
1561
|
-
synchronized2
|
|
1562
|
-
], MediaManager.prototype, "leave", null);
|
|
1563
|
-
|
|
1564
|
-
// src/calls/call-manager.ts
|
|
1565
|
-
import { Atom } from "@effect-atom/atom-react";
|
|
1566
|
-
import { Event as Event4, synchronized as synchronized3 } from "@dxos/async";
|
|
1567
|
-
import { Resource as Resource5 } from "@dxos/context";
|
|
1568
|
-
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1569
|
-
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
1570
|
-
function _ts_decorate3(decorators, target, key, desc) {
|
|
1571
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1572
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1573
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1574
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1575
|
-
}
|
|
1576
|
-
var __dxlog_file6 = "/__w/dxos/dxos/packages/plugins/plugin-thread/src/calls/call-manager.ts";
|
|
1577
|
-
var CallManager = class extends Resource5 {
|
|
1578
|
-
_client;
|
|
1579
|
-
_registry;
|
|
1580
|
-
callStateUpdated = new Event4();
|
|
1581
|
-
// TODO(wittjosiah): Consolidate isSpeaking into the MediaState type.
|
|
1582
|
-
mediaStateUpdated = new Event4();
|
|
1583
|
-
left = new Event4();
|
|
1584
|
-
/**
|
|
1585
|
-
* Atom-based state. Updated via `_updateState()`.
|
|
1586
|
-
* CAUTION: Do not change directly.
|
|
1587
|
-
*/
|
|
1588
|
-
_stateAtom = Atom.make({
|
|
1589
|
-
call: {},
|
|
1590
|
-
media: {
|
|
1591
|
-
pulledAudioTracks: {},
|
|
1592
|
-
pulledVideoStreams: {}
|
|
1593
|
-
}
|
|
1594
|
-
});
|
|
1595
|
-
// Derived atoms for reactive subscriptions.
|
|
1596
|
-
_roomIdAtom = Atom.make((get) => get(this._stateAtom).call.roomId);
|
|
1597
|
-
_raisedHandAtom = Atom.make((get) => get(this._stateAtom).call.raisedHand ?? false);
|
|
1598
|
-
_speakingAtom = Atom.make((get) => get(this._stateAtom).call.speaking ?? false);
|
|
1599
|
-
_joinedAtom = Atom.make((get) => get(this._stateAtom).call.joined ?? false);
|
|
1600
|
-
_selfAtom = Atom.make((get) => get(this._stateAtom).call.self ?? {});
|
|
1601
|
-
_tracksAtom = Atom.make((get) => get(this._stateAtom).call.tracks ?? {});
|
|
1602
|
-
_usersAtom = Atom.make((get) => get(this._stateAtom).call.users ?? []);
|
|
1603
|
-
_mediaAtom = Atom.make((get) => get(this._stateAtom).media);
|
|
1604
|
-
_audioTracksToPlayAtom = Atom.make((get) => {
|
|
1605
|
-
const state = get(this._stateAtom);
|
|
1606
|
-
return (state.call.users ?? []).map((user) => user.tracks?.audioEnabled ? user.tracks?.audio : void 0).filter(isNonNullable2).map((track) => state.media.pulledAudioTracks[track]?.track).filter(isNonNullable2);
|
|
1607
|
-
});
|
|
1608
|
-
_videoStreamAtomFamily = Atom.family((name) => Atom.make((get) => get(this._stateAtom).media.pulledVideoStreams[name]?.stream));
|
|
1609
|
-
_activityAtomFamily = Atom.family((key) => Atom.make((get) => get(this._stateAtom).call.activities?.[key]));
|
|
1610
|
-
_swarmSynchronizer;
|
|
1611
|
-
_mediaManager;
|
|
1612
|
-
//
|
|
1613
|
-
// Derived atoms for reactive UI subscriptions.
|
|
1614
|
-
//
|
|
1615
|
-
/** Derived atom for roomId. */
|
|
1616
|
-
get roomIdAtom() {
|
|
1617
|
-
return this._roomIdAtom;
|
|
1618
|
-
}
|
|
1619
|
-
/** Derived atom for raisedHand. */
|
|
1620
|
-
get raisedHandAtom() {
|
|
1621
|
-
return this._raisedHandAtom;
|
|
1622
|
-
}
|
|
1623
|
-
/** Derived atom for speaking. */
|
|
1624
|
-
get speakingAtom() {
|
|
1625
|
-
return this._speakingAtom;
|
|
1626
|
-
}
|
|
1627
|
-
/** Derived atom for joined. */
|
|
1628
|
-
get joinedAtom() {
|
|
1629
|
-
return this._joinedAtom;
|
|
1630
|
-
}
|
|
1631
|
-
/** Derived atom for self. */
|
|
1632
|
-
get selfAtom() {
|
|
1633
|
-
return this._selfAtom;
|
|
1634
|
-
}
|
|
1635
|
-
/** Derived atom for tracks. */
|
|
1636
|
-
get tracksAtom() {
|
|
1637
|
-
return this._tracksAtom;
|
|
1638
|
-
}
|
|
1639
|
-
/** Derived atom for users. */
|
|
1640
|
-
get usersAtom() {
|
|
1641
|
-
return this._usersAtom;
|
|
1642
|
-
}
|
|
1643
|
-
/** Derived atom for media. */
|
|
1644
|
-
get mediaAtom() {
|
|
1645
|
-
return this._mediaAtom;
|
|
1646
|
-
}
|
|
1647
|
-
/** Derived atom for audioTracksToPlay. */
|
|
1648
|
-
get audioTracksToPlayAtom() {
|
|
1649
|
-
return this._audioTracksToPlayAtom;
|
|
1650
|
-
}
|
|
1651
|
-
/** Returns the full state atom for reactive subscriptions. */
|
|
1652
|
-
get stateAtom() {
|
|
1653
|
-
return this._stateAtom;
|
|
1654
|
-
}
|
|
1655
|
-
/** Returns a derived atom for a video stream by name. */
|
|
1656
|
-
videoStreamAtom(name) {
|
|
1657
|
-
return this._videoStreamAtomFamily(name);
|
|
1658
|
-
}
|
|
1659
|
-
/** Returns a derived atom for an activity by key. */
|
|
1660
|
-
activityAtom(key) {
|
|
1661
|
-
return this._activityAtomFamily(key);
|
|
1662
|
-
}
|
|
1663
|
-
setRoomId(roomId) {
|
|
1664
|
-
this._swarmSynchronizer._setRoomId(roomId);
|
|
1665
|
-
}
|
|
1666
|
-
setSpeaking(speaking) {
|
|
1667
|
-
this._swarmSynchronizer.setSpeaking(speaking);
|
|
1668
|
-
}
|
|
1669
|
-
setRaisedHand(raisedHand) {
|
|
1670
|
-
this._swarmSynchronizer.setRaisedHand(raisedHand);
|
|
1671
|
-
}
|
|
1672
|
-
setActivity(key, payload) {
|
|
1673
|
-
this._swarmSynchronizer.setActivity(key, payload);
|
|
1674
|
-
}
|
|
1675
|
-
turnAudioOn() {
|
|
1676
|
-
return this._mediaManager.turnAudioOn();
|
|
1677
|
-
}
|
|
1678
|
-
turnAudioOff() {
|
|
1679
|
-
return this._mediaManager.turnAudioOff();
|
|
1680
|
-
}
|
|
1681
|
-
turnVideoOn() {
|
|
1682
|
-
return this._mediaManager.turnVideoOn();
|
|
1683
|
-
}
|
|
1684
|
-
turnVideoOff() {
|
|
1685
|
-
return this._mediaManager.turnVideoOff();
|
|
1686
|
-
}
|
|
1687
|
-
turnScreenshareOn() {
|
|
1688
|
-
return this._mediaManager.turnScreenshareOn();
|
|
1689
|
-
}
|
|
1690
|
-
turnScreenshareOff() {
|
|
1691
|
-
return this._mediaManager.turnScreenshareOff();
|
|
1692
|
-
}
|
|
1693
|
-
// TODO(burdon): Can this be mocked?
|
|
1694
|
-
constructor(_client, _registry) {
|
|
1695
|
-
super(), this._client = _client, this._registry = _registry;
|
|
1696
|
-
this._client.config.getOrThrow("runtime.services.edge.url");
|
|
1697
|
-
const networkService = this._client.services.services.NetworkService;
|
|
1698
|
-
invariant5(networkService, "network service not found", {
|
|
1699
|
-
F: __dxlog_file6,
|
|
1700
|
-
L: 180,
|
|
1701
|
-
S: this,
|
|
1702
|
-
A: [
|
|
1703
|
-
"networkService",
|
|
1704
|
-
"'network service not found'"
|
|
1705
|
-
]
|
|
1706
|
-
});
|
|
1707
|
-
this._swarmSynchronizer = new CallSwarmSynchronizer({
|
|
1708
|
-
networkService
|
|
1709
|
-
});
|
|
1710
|
-
this._mediaManager = new MediaManager();
|
|
1711
|
-
}
|
|
1712
|
-
async _open() {
|
|
1713
|
-
await this._mediaManager.open();
|
|
1714
|
-
await this._swarmSynchronizer.open();
|
|
1715
|
-
const subscription = this._client.halo.identity.subscribe((identity) => {
|
|
1716
|
-
if (identity) {
|
|
1717
|
-
this._swarmSynchronizer._setIdentity(identity);
|
|
1718
|
-
}
|
|
1719
|
-
if (this._client.halo.device) {
|
|
1720
|
-
this._swarmSynchronizer._setDevice(this._client.halo.device);
|
|
1721
|
-
}
|
|
1722
|
-
});
|
|
1723
|
-
this._ctx.onDispose(() => subscription.unsubscribe());
|
|
1724
|
-
this._swarmSynchronizer.stateUpdated.on(this._ctx, (state) => this._onCallStateUpdated(state));
|
|
1725
|
-
this._mediaManager.stateUpdated.on(this._ctx, (state) => this._onMediaStateUpdated(state));
|
|
1726
|
-
}
|
|
1727
|
-
async _close() {
|
|
1728
|
-
await this._swarmSynchronizer.leave();
|
|
1729
|
-
await this._swarmSynchronizer.close();
|
|
1730
|
-
await this._mediaManager.close();
|
|
1731
|
-
}
|
|
1732
|
-
async peek(roomId) {
|
|
1733
|
-
const peers = await this._swarmSynchronizer.querySwarm(roomId);
|
|
1734
|
-
return peers.length;
|
|
1735
|
-
}
|
|
1736
|
-
// TODO(mykola): Reconcile with _swarmSynchronizer.state.joined.
|
|
1737
|
-
async join() {
|
|
1738
|
-
this._swarmSynchronizer.setJoined(true);
|
|
1739
|
-
await this._swarmSynchronizer.join();
|
|
1740
|
-
await this._mediaManager.join({
|
|
1741
|
-
iceServers: this._client.config.get("runtime.services.ice"),
|
|
1742
|
-
apiBase: `${CALLS_URL}/api/calls`
|
|
1743
|
-
});
|
|
1744
|
-
}
|
|
1745
|
-
async leave() {
|
|
1746
|
-
this._swarmSynchronizer.setJoined(false);
|
|
1747
|
-
await this._swarmSynchronizer.leave();
|
|
1748
|
-
await this._mediaManager.leave();
|
|
1749
|
-
const roomId = this._registry.get(this._roomIdAtom);
|
|
1750
|
-
roomId && this.left.emit(roomId);
|
|
1751
|
-
}
|
|
1752
|
-
_onCallStateUpdated(state) {
|
|
1753
|
-
const tracksToPull = state.users?.filter((user) => user.joined && user.id !== state.self.id)?.flatMap((user) => [
|
|
1754
|
-
user.tracks?.video,
|
|
1755
|
-
user.tracks?.audio,
|
|
1756
|
-
user.tracks?.screenshare
|
|
1757
|
-
]).filter(isNonNullable2);
|
|
1758
|
-
this._mediaManager._schedulePullTracks(tracksToPull);
|
|
1759
|
-
this.callStateUpdated.emit(state);
|
|
1760
|
-
this._updateState();
|
|
1761
|
-
}
|
|
1762
|
-
_onMediaStateUpdated(state) {
|
|
1763
|
-
this._swarmSynchronizer.setTracks({
|
|
1764
|
-
video: state.pushedVideoTrack ? TrackNameCodec.encode(state.pushedVideoTrack) : void 0,
|
|
1765
|
-
audio: state.pushedAudioTrack ? TrackNameCodec.encode(state.pushedAudioTrack) : void 0,
|
|
1766
|
-
screenshare: state.pushedScreenshareTrack ? TrackNameCodec.encode(state.pushedScreenshareTrack) : void 0,
|
|
1767
|
-
videoEnabled: state.videoEnabled,
|
|
1768
|
-
audioEnabled: state.audioEnabled,
|
|
1769
|
-
screenshareEnabled: state.screenshareEnabled
|
|
1770
|
-
});
|
|
1771
|
-
const isSpeaking = this._mediaManager.isSpeaking ?? false;
|
|
1772
|
-
this._swarmSynchronizer.setSpeaking(isSpeaking);
|
|
1773
|
-
this.mediaStateUpdated.emit([
|
|
1774
|
-
state,
|
|
1775
|
-
isSpeaking
|
|
1776
|
-
]);
|
|
1777
|
-
this._updateState();
|
|
1778
|
-
}
|
|
1779
|
-
/**
|
|
1780
|
-
* Only this method is allowed to change state.
|
|
1781
|
-
*/
|
|
1782
|
-
_updateState() {
|
|
1783
|
-
this._registry.set(this._stateAtom, {
|
|
1784
|
-
call: this._swarmSynchronizer._getState(),
|
|
1785
|
-
media: this._mediaManager._getState()
|
|
1786
|
-
});
|
|
1787
|
-
}
|
|
1788
|
-
};
|
|
1789
|
-
_ts_decorate3([
|
|
1790
|
-
synchronized3
|
|
1791
|
-
], CallManager.prototype, "join", null);
|
|
1792
|
-
_ts_decorate3([
|
|
1793
|
-
synchronized3
|
|
1794
|
-
], CallManager.prototype, "leave", null);
|
|
1795
|
-
|
|
1796
|
-
export {
|
|
1797
|
-
CALLS_URL,
|
|
1798
|
-
codec,
|
|
1799
|
-
TrackNameCodec,
|
|
1800
|
-
CallSwarmSynchronizer,
|
|
1801
|
-
monitorAudioLevel,
|
|
1802
|
-
CallsServicePeer,
|
|
1803
|
-
getUserMediaTrack,
|
|
1804
|
-
getDeviceList,
|
|
1805
|
-
getScreenshare,
|
|
1806
|
-
SpeakingMonitor,
|
|
1807
|
-
MediaManager,
|
|
1808
|
-
CallManager
|
|
1809
|
-
};
|
|
1810
|
-
//# sourceMappingURL=chunk-ERK254BS.mjs.map
|