@nivaro/react 0.2.53 → 0.2.55
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/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +99 -98
- package/dist/index.d.ts +452 -4
- package/dist/index.js +644 -618
- package/dist/layout-editor.d.ts +252 -2
- package/dist/shared/components/BackgroundRunOffer.js +117 -0
- package/dist/shared/components/BroadcastView.js +214 -213
- package/dist/shared/components/CollectionBrowserView.js +2592 -2695
- package/dist/shared/components/FormWhatsNew.js +60 -0
- package/dist/shared/components/ItemEditForm.js +3968 -3618
- package/dist/shared/components/JobsTray.js +100 -55
- package/dist/shared/components/MyWorkView.js +91 -89
- package/dist/shared/components/NotificationBell.js +80 -79
- package/dist/shared/components/ProfileView.js +568 -520
- package/dist/shared/components/RecordCompare.js +254 -0
- package/dist/shared/components/RecordReadView.js +598 -543
- package/dist/shared/components/ReportView.js +578 -543
- package/dist/shared/components/RowPresence.js +91 -0
- package/dist/shared/components/TipLayer.js +27 -27
- package/dist/shared/components/WidgetSlot.js +474 -458
- package/dist/shared/components/ai/AiAnalyticsView.js +16 -6
- package/dist/shared/components/ai/AskPanel.js +139 -119
- package/dist/shared/components/ai/FirstWeekCard.js +126 -0
- package/dist/shared/components/bulk/BulkFieldUpdate.js +289 -0
- package/dist/shared/components/bulk/bulk-field-options.js +45 -0
- package/dist/shared/components/charts/CumulativeFlowChart.js +176 -0
- package/dist/shared/components/chat/ChannelArchive.js +326 -0
- package/dist/shared/components/chat/ChannelExtras.js +141 -121
- package/dist/shared/components/chat/ChatAnalyticsView.js +112 -110
- package/dist/shared/components/chat/ChatPanel.js +1695 -1733
- package/dist/shared/components/chat/Composer.js +357 -303
- package/dist/shared/components/chat/MessageActions.js +92 -0
- package/dist/shared/components/chat/MessageFormat.js +290 -264
- package/dist/shared/components/chat/OutboxBubbles.js +146 -0
- package/dist/shared/components/chat/RequestIdCard.js +135 -0
- package/dist/shared/components/chat/RoomHeaderMenu.js +202 -0
- package/dist/shared/components/chat/RoomParts.js +213 -274
- package/dist/shared/components/chat/ScreenClip.js +184 -0
- package/dist/shared/components/chat/chat-core.js +402 -483
- package/dist/shared/components/chat/chat-drafts.js +59 -0
- package/dist/shared/components/chat/chat-emoji.js +348 -0
- package/dist/shared/components/chat/chat-local-time.js +41 -0
- package/dist/shared/components/chat/chat-outbox.js +303 -0
- package/dist/shared/components/chat/chat-window.js +163 -0
- package/dist/shared/components/chat/huddle/HuddleControls.js +143 -0
- package/dist/shared/components/chat/huddle/HuddleStage.js +164 -0
- package/dist/shared/components/chat/huddle/huddle-store.js +342 -0
- package/dist/shared/components/chat/huddle/useHuddle.js +58 -0
- package/dist/shared/components/help-videos/api.js +80 -67
- package/dist/shared/components/help-videos/editor/DetailsTab.js +147 -130
- package/dist/shared/components/item-edit/CatalogPickerField.js +113 -112
- package/dist/shared/components/item-edit/ChangeReasonDialog.js +13 -13
- package/dist/shared/components/item-edit/FieldAffordances.js +9 -8
- package/dist/shared/components/item-edit/FieldRenderer.js +248 -245
- package/dist/shared/components/item-edit/FieldRow.js +382 -320
- package/dist/shared/components/item-edit/FormHelpVideoButton.js +59 -0
- package/dist/shared/components/item-edit/GroupSection.js +786 -639
- package/dist/shared/components/item-edit/HeaderTools.js +59 -56
- package/dist/shared/components/item-edit/InlineTableField.js +3 -1
- package/dist/shared/components/item-edit/LayoutContentBlock.js +47 -24
- package/dist/shared/components/item-edit/RelationCombobox.js +186 -176
- package/dist/shared/components/item-edit/entry/EntryStrip.js +54 -0
- package/dist/shared/components/item-edit/entry/entry-keys.js +27 -0
- package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +70 -0
- package/dist/shared/components/item-edit/entry/useEntryMode.js +59 -0
- package/dist/shared/components/item-edit/form-structure-ui.js +105 -0
- package/dist/shared/components/item-edit/lazy-sections.js +36 -0
- package/dist/shared/components/item-edit/lock-why.js +94 -0
- package/dist/shared/components/item-edit/picker-miss.js +26 -0
- package/dist/shared/components/item-edit/placement-behaviour.js +196 -0
- package/dist/shared/components/item-edit/useFormUsageBeacon.js +65 -0
- package/dist/shared/components/layout-editor/AddPanel.js +226 -151
- package/dist/shared/components/layout-editor/ArrangeButton.js +34 -0
- package/dist/shared/components/layout-editor/AutoArrange.js +86 -0
- package/dist/shared/components/layout-editor/CanvasCompare.js +79 -0
- package/dist/shared/components/layout-editor/ChangeNote.js +147 -0
- package/dist/shared/components/layout-editor/CollabParts.js +175 -0
- package/dist/shared/components/layout-editor/DesignNode.js +311 -116
- package/dist/shared/components/layout-editor/EditorCanvas.js +30 -26
- package/dist/shared/components/layout-editor/EditorTopBar.js +463 -175
- package/dist/shared/components/layout-editor/FindReplace.js +188 -0
- package/dist/shared/components/layout-editor/FormMapButton.js +141 -0
- package/dist/shared/components/layout-editor/HistoryPanel.js +250 -109
- package/dist/shared/components/layout-editor/LayoutEditor.js +1196 -305
- package/dist/shared/components/layout-editor/LayoutsRail.js +94 -67
- package/dist/shared/components/layout-editor/NoteMarker.js +38 -0
- package/dist/shared/components/layout-editor/PlacementsTable.js +187 -0
- package/dist/shared/components/layout-editor/RestorePiece.js +143 -0
- package/dist/shared/components/layout-editor/ScheduleChange.js +106 -0
- package/dist/shared/components/layout-editor/SessionHistory.js +84 -0
- package/dist/shared/components/layout-editor/StagedChip.js +22 -0
- package/dist/shared/components/layout-editor/StructureMenu.js +464 -0
- package/dist/shared/components/layout-editor/UnsavedConfirm.js +103 -0
- package/dist/shared/components/layout-editor/ai/AiToolsButton.js +625 -0
- package/dist/shared/components/layout-editor/ai/ChangeCheck.js +153 -0
- package/dist/shared/components/layout-editor/ai/ai-tools-api.js +80 -0
- package/dist/shared/components/layout-editor/ai/assist-ops.js +38 -0
- package/dist/shared/components/layout-editor/ai/autofill-ops.js +73 -0
- package/dist/shared/components/layout-editor/ai/canvas-capture.js +41 -0
- package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +271 -0
- package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +182 -0
- package/dist/shared/components/layout-editor/ai-forms/MeaningSuggestions.js +109 -0
- package/dist/shared/components/layout-editor/ai-forms/SlimPanel.js +170 -0
- package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +40 -0
- package/dist/shared/components/layout-editor/ai-forms/pending.js +25 -0
- package/dist/shared/components/layout-editor/ai-forms/plan.js +263 -0
- package/dist/shared/components/layout-editor/ai-rules/AiAskPopover.js +160 -0
- package/dist/shared/components/layout-editor/ai-rules/CascadeWriter.js +175 -0
- package/dist/shared/components/layout-editor/ai-rules/FieldRuleWriter.js +97 -0
- package/dist/shared/components/layout-editor/ai-rules/RuleWriter.js +94 -0
- package/dist/shared/components/layout-editor/ai-rules/ValidationSuggest.js +153 -0
- package/dist/shared/components/layout-editor/ai-rules/api.js +6 -0
- package/dist/shared/components/layout-editor/ai-text/AiTextTools.js +383 -0
- package/dist/shared/components/layout-editor/ai-text/text-ops.js +125 -0
- package/dist/shared/components/layout-editor/assist/AskPanel.js +278 -0
- package/dist/shared/components/layout-editor/assist/ExplainDiff.js +93 -0
- package/dist/shared/components/layout-editor/assist/ProposalsButton.js +150 -0
- package/dist/shared/components/layout-editor/assist/assist-api.js +63 -0
- package/dist/shared/components/layout-editor/assist/jump.js +142 -0
- package/dist/shared/components/layout-editor/assist/settings-index.js +118 -0
- package/dist/shared/components/layout-editor/auto-arrange.js +101 -0
- package/dist/shared/components/layout-editor/bulk/BulkChangesButton.js +221 -0
- package/dist/shared/components/layout-editor/bulk/BulkRun.js +237 -0
- package/dist/shared/components/layout-editor/bulk/MacrosPanel.js +230 -0
- package/dist/shared/components/layout-editor/bulk/bulk-api.js +65 -0
- package/dist/shared/components/layout-editor/bulk/field-labels.js +22 -0
- package/dist/shared/components/layout-editor/bulk/macro-record.js +142 -0
- package/dist/shared/components/layout-editor/bulk/useMacroRecorder.js +65 -0
- package/dist/shared/components/layout-editor/bundle-to-active.js +1 -0
- package/dist/shared/components/layout-editor/canvas-diff.js +157 -0
- package/dist/shared/components/layout-editor/collab/FormFollowShare.js +388 -0
- package/dist/shared/components/layout-editor/collab/collab-api.js +80 -0
- package/dist/shared/components/layout-editor/commands/CommandPalette.js +221 -0
- package/dist/shared/components/layout-editor/commands/intents.js +214 -0
- package/dist/shared/components/layout-editor/commands/parse.js +242 -0
- package/dist/shared/components/layout-editor/design-context.js +26 -6
- package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +181 -164
- package/dist/shared/components/layout-editor/dnd/collision.js +25 -23
- package/dist/shared/components/layout-editor/dnd/node.js +69 -57
- package/dist/shared/components/layout-editor/dnd/rail-drop.js +56 -0
- package/dist/shared/components/layout-editor/draft-recovery.js +131 -0
- package/dist/shared/components/layout-editor/editor-notes.js +78 -0
- package/dist/shared/components/layout-editor/editors/swap-config.js +1 -0
- package/dist/shared/components/layout-editor/entry/PlacementPresets.js +149 -0
- package/dist/shared/components/layout-editor/entry/entry-editor-context.js +10 -0
- package/dist/shared/components/layout-editor/entry/presets.js +71 -0
- package/dist/shared/components/layout-editor/entry/tab-order.js +110 -0
- package/dist/shared/components/layout-editor/entry/theme-preview.js +37 -0
- package/dist/shared/components/layout-editor/explain/CanvasRules.js +142 -0
- package/dist/shared/components/layout-editor/explain/default-ghosts.js +81 -0
- package/dist/shared/components/layout-editor/explain/driver-hover.js +62 -0
- package/dist/shared/components/layout-editor/explain/field-sources.js +246 -0
- package/dist/shared/components/layout-editor/explain/rule-graph.js +215 -0
- package/dist/shared/components/layout-editor/explain/use-explain.js +132 -0
- package/dist/shared/components/layout-editor/field-zones.js +116 -0
- package/dist/shared/components/layout-editor/form-map.js +138 -0
- package/dist/shared/components/layout-editor/grid-guides.js +142 -0
- package/dist/shared/components/layout-editor/history-api.js +87 -0
- package/dist/shared/components/layout-editor/inheritance.js +55 -0
- package/dist/shared/components/layout-editor/inspect/inspect-api.js +66 -0
- package/dist/shared/components/layout-editor/inspect/picker-preview.js +48 -0
- package/dist/shared/components/layout-editor/inspect/width-fit.js +87 -0
- package/dist/shared/components/layout-editor/inspector/AiFillSetting.js +85 -0
- package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +402 -0
- package/dist/shared/components/layout-editor/inspector/Breadcrumb.js +36 -0
- package/dist/shared/components/layout-editor/inspector/BulkInspector.js +179 -0
- package/dist/shared/components/layout-editor/inspector/ColumnFit.js +112 -0
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +291 -141
- package/dist/shared/components/layout-editor/inspector/HelpTab.js +174 -0
- package/dist/shared/components/layout-editor/inspector/Inspector.js +282 -180
- package/dist/shared/components/layout-editor/inspector/LookTab.js +166 -109
- package/dist/shared/components/layout-editor/inspector/OverrideNotice.js +61 -0
- package/dist/shared/components/layout-editor/inspector/PickerMisses.js +129 -0
- package/dist/shared/components/layout-editor/inspector/PickerPreview.js +134 -0
- package/dist/shared/components/layout-editor/inspector/PickerTab.js +146 -118
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +162 -111
- package/dist/shared/components/layout-editor/inspector/Translations.js +156 -0
- package/dist/shared/components/layout-editor/inspector/kit.js +71 -70
- package/dist/shared/components/layout-editor/inspector/tab-request.js +21 -0
- package/dist/shared/components/layout-editor/is-typing.js +9 -0
- package/dist/shared/components/layout-editor/keyboard-move.js +66 -0
- package/dist/shared/components/layout-editor/lint/LintPanel.js +190 -0
- package/dist/shared/components/layout-editor/lint/lint-api.js +52 -0
- package/dist/shared/components/layout-editor/load-error.js +37 -0
- package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +305 -0
- package/dist/shared/components/layout-editor/matrix/MatrixGrid.js +181 -0
- package/dist/shared/components/layout-editor/matrix/RoleSectionMatrix.js +147 -0
- package/dist/shared/components/layout-editor/matrix/matrix-api.js +48 -0
- package/dist/shared/components/layout-editor/matrix/role-matrix.js +36 -0
- package/dist/shared/components/layout-editor/matrix/state-matrix.js +145 -0
- package/dist/shared/components/layout-editor/nav/FindPanel.js +109 -0
- package/dist/shared/components/layout-editor/nav/NavTools.js +114 -0
- package/dist/shared/components/layout-editor/nav/OutlinePanel.js +228 -0
- package/dist/shared/components/layout-editor/nav/ShortcutSheet.js +31 -0
- package/dist/shared/components/layout-editor/nav/find.js +20 -0
- package/dist/shared/components/layout-editor/nav/tree.js +142 -0
- package/dist/shared/components/layout-editor/nav/useEditorNav.js +101 -0
- package/dist/shared/components/layout-editor/nav/view-prefs.js +34 -0
- package/dist/shared/components/layout-editor/ops/ChangeRequestsPanel.js +143 -0
- package/dist/shared/components/layout-editor/ops/DependencyDiagram.js +179 -0
- package/dist/shared/components/layout-editor/ops/LayoutOpsBlocks.js +92 -0
- package/dist/shared/components/layout-editor/ops/PromotePanel.js +287 -0
- package/dist/shared/components/layout-editor/ops/ops-api.js +122 -0
- package/dist/shared/components/layout-editor/outputs/OutputsButton.js +254 -0
- package/dist/shared/components/layout-editor/outputs/help-sheet.js +154 -0
- package/dist/shared/components/layout-editor/outputs/output-api.js +61 -0
- package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -3
- package/dist/shared/components/layout-editor/overview/describe-conditions.js +24 -14
- package/dist/shared/components/layout-editor/overview/overview-api.js +105 -88
- package/dist/shared/components/layout-editor/overview/purpose.js +15 -13
- package/dist/shared/components/layout-editor/panel-style.js +8 -7
- package/dist/shared/components/layout-editor/parity-keys.json.js +4 -0
- package/dist/shared/components/layout-editor/pin.js +25 -0
- package/dist/shared/components/layout-editor/presence.js +111 -0
- package/dist/shared/components/layout-editor/preview/PreviewModes.js +224 -0
- package/dist/shared/components/layout-editor/preview/PreviewPanes.js +262 -0
- package/dist/shared/components/layout-editor/preview/preview-api.js +57 -0
- package/dist/shared/components/layout-editor/preview/preview-model.js +157 -0
- package/dist/shared/components/layout-editor/restore-piece.js +192 -0
- package/dist/shared/components/layout-editor/reuse/FieldMapStep.js +70 -0
- package/dist/shared/components/layout-editor/reuse/FormMoreMenu.js +127 -0
- package/dist/shared/components/layout-editor/reuse/LibraryRows.js +150 -0
- package/dist/shared/components/layout-editor/reuse/NewFormStart.js +20 -0
- package/dist/shared/components/layout-editor/reuse/SectionReuseActions.js +291 -0
- package/dist/shared/components/layout-editor/reuse/field-match.js +77 -0
- package/dist/shared/components/layout-editor/reuse/reuse-api.js +73 -0
- package/dist/shared/components/layout-editor/reuse/seed.js +13 -0
- package/dist/shared/components/layout-editor/reuse/useFormFromRecord.js +43 -0
- package/dist/shared/components/layout-editor/reuse/useRailCopy.js +34 -0
- package/dist/shared/components/layout-editor/section-structure.js +241 -0
- package/dist/shared/components/layout-editor/settings/EntrySection.js +296 -0
- package/dist/shared/components/layout-editor/settings/FormSettings.js +125 -103
- package/dist/shared/components/layout-editor/settings/InheritanceSection.js +1 -1
- package/dist/shared/components/layout-editor/settings/ResolveSettings.js +255 -0
- package/dist/shared/components/layout-editor/settings/ToolsSection.js +215 -105
- package/dist/shared/components/layout-editor/settings/WhoSection.js +139 -100
- package/dist/shared/components/layout-editor/settings/controls.js +8 -8
- package/dist/shared/components/layout-editor/settings/settings-registry.js +142 -21
- package/dist/shared/components/layout-editor/shortcuts.js +88 -0
- package/dist/shared/components/layout-editor/show-when.js +35 -0
- package/dist/shared/components/layout-editor/slot-names.js +4 -3
- package/dist/shared/components/layout-editor/staged-api.js +64 -0
- package/dist/shared/components/layout-editor/structure-ops.js +403 -0
- package/dist/shared/components/layout-editor/testing/CostLimitSetting.js +42 -0
- package/dist/shared/components/layout-editor/testing/TestingPanels.js +556 -0
- package/dist/shared/components/layout-editor/testing/testing-api.js +67 -0
- package/dist/shared/components/layout-editor/testing/testing-model.js +406 -0
- package/dist/shared/components/layout-editor/testing/use-record-check.js +44 -0
- package/dist/shared/components/layout-editor/toolbar-kit.js +242 -0
- package/dist/shared/components/layout-editor/unsaved-marks.js +72 -0
- package/dist/shared/components/layout-editor/usage/AbTestSection.js +355 -0
- package/dist/shared/components/layout-editor/usage/FillChip.js +27 -0
- package/dist/shared/components/layout-editor/usage/UsagePanel.js +232 -0
- package/dist/shared/components/layout-editor/usage/ab-api.js +86 -0
- package/dist/shared/components/layout-editor/usage/suggest-collapse.js +32 -0
- package/dist/shared/components/layout-editor/usage/suggest-sections.js +55 -0
- package/dist/shared/components/layout-editor/usage/usage-api.js +104 -0
- package/dist/shared/components/layout-editor/useLayoutDraft.js +573 -306
- package/dist/shared/components/notifications/NotificationAnalyticsView.js +148 -77
- package/dist/shared/components/panels/ErpFailureBanner.js +18 -17
- package/dist/shared/components/panels/ExternalRequestsChip.js +63 -62
- package/dist/shared/components/pipeline/PipelineEditorView.js +106 -104
- package/dist/shared/components/profile/AgentsPanel.js +479 -0
- package/dist/shared/components/queue/QueueWorklist.js +1026 -1040
- package/dist/shared/components/support/SuggestFormChange.js +143 -0
- package/dist/shared/components/support/SupportAnalytics.js +171 -0
- package/dist/shared/components/support/SupportView.js +75 -73
- package/dist/shared/lib/ai-fill.js +37 -0
- package/dist/shared/lib/background-runs.js +150 -0
- package/dist/shared/lib/delivery-ack.js +9 -0
- package/dist/shared/lib/entry-badge-style.js +13 -0
- package/dist/shared/lib/entry-config.js +71 -0
- package/dist/shared/lib/form-sections.js +64 -0
- package/dist/shared/lib/form-structure.js +99 -0
- package/dist/shared/lib/form-usage-beacon.js +133 -0
- package/dist/shared/lib/jobs-tray.js +25 -23
- package/dist/shared/lib/keyset-pager.js +37 -0
- package/dist/shared/lib/layout-i18n.js +66 -0
- package/dist/shared/lib/layout-lint.js +490 -0
- package/dist/shared/lib/layout-ops.js +116 -110
- package/dist/shared/lib/layout-resolve.js +113 -0
- package/dist/shared/lib/placement-behaviour.js +144 -0
- package/dist/shared/lib/prefetch.js +149 -0
- package/dist/shared/lib/presence-hooks.js +199 -0
- package/dist/shared/lib/record-outbox.js +82 -81
- package/dist/shared/lib/replay-socket.js +93 -0
- package/dist/shared/lib/request-gate.js +51 -50
- package/dist/shared/lib/room-gaps.js +96 -0
- package/dist/shared/lib/screenshot.js +54 -28
- package/dist/shared/lib/search-log.js +27 -0
- package/dist/shared/lib/socket-realtime.js +101 -80
- package/dist/shared/lib/visible-when.js +34 -0
- package/dist/shared/lib/worker-socket.js +200 -0
- package/package.json +1 -1
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { jsxs as d, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { X as f, Headphones as x, MicOff as b, ScreenShare as g, Maximize2 as k } from "lucide-react";
|
|
3
|
+
import { useState as v, useEffect as h, useRef as N } from "react";
|
|
4
|
+
import { cn as p } from "../../../lib/utils.js";
|
|
5
|
+
import { formatElapsed as y } from "./huddle-store.js";
|
|
6
|
+
function u({
|
|
7
|
+
stream: a,
|
|
8
|
+
label: r,
|
|
9
|
+
mirror: n
|
|
10
|
+
}) {
|
|
11
|
+
const s = N(null);
|
|
12
|
+
return h(() => {
|
|
13
|
+
const e = s.current;
|
|
14
|
+
if (e)
|
|
15
|
+
return e.srcObject = a, e.play().catch(() => null), () => {
|
|
16
|
+
e.srcObject = null;
|
|
17
|
+
};
|
|
18
|
+
}, [a]), /* @__PURE__ */ d(
|
|
19
|
+
"div",
|
|
20
|
+
{
|
|
21
|
+
className: p(
|
|
22
|
+
"group relative overflow-hidden rounded-lg bg-[#0f172a]",
|
|
23
|
+
n ? "max-h-[120px]" : "max-h-[280px]"
|
|
24
|
+
),
|
|
25
|
+
"data-huddle-screen": n ? "mine" : "peer",
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ t("video", { ref: s, muted: !0, playsInline: !0, className: "mx-auto block max-h-[inherit] w-auto" }),
|
|
28
|
+
/* @__PURE__ */ t("span", { className: "absolute bottom-1.5 left-2 rounded bg-black/55 px-1.5 py-0.5 text-[10.5px] font-medium text-white", children: r }),
|
|
29
|
+
!n && /* @__PURE__ */ t(
|
|
30
|
+
"button",
|
|
31
|
+
{
|
|
32
|
+
type: "button",
|
|
33
|
+
onClick: () => {
|
|
34
|
+
var e, o;
|
|
35
|
+
return void ((o = (e = s.current) == null ? void 0 : e.requestFullscreen) == null ? void 0 : o.call(e));
|
|
36
|
+
},
|
|
37
|
+
className: "absolute right-1.5 top-1.5 flex h-6 w-6 items-center justify-center rounded bg-black/55 text-white opacity-0 transition-opacity focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan group-hover:opacity-100",
|
|
38
|
+
"aria-label": "View the shared screen full size",
|
|
39
|
+
"data-tip": "Full screen",
|
|
40
|
+
children: /* @__PURE__ */ t(k, { className: "h-3.5 w-3.5", strokeWidth: 2 })
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
function w({ since: a }) {
|
|
48
|
+
const [, r] = v(0);
|
|
49
|
+
return h(() => {
|
|
50
|
+
const n = setInterval(() => r((s) => s + 1), 1e3);
|
|
51
|
+
return () => clearInterval(n);
|
|
52
|
+
}, []), a ? /* @__PURE__ */ t("span", { className: "tabular-nums text-slate-500 dark:text-slate-400", "data-huddle-elapsed": !0, children: y(Date.now() - a) }) : null;
|
|
53
|
+
}
|
|
54
|
+
function m({
|
|
55
|
+
id: a,
|
|
56
|
+
name: r,
|
|
57
|
+
muted: n,
|
|
58
|
+
screen: s,
|
|
59
|
+
connection: e,
|
|
60
|
+
renderAvatar: o
|
|
61
|
+
}) {
|
|
62
|
+
const l = e === "new" || e === "connecting";
|
|
63
|
+
return /* @__PURE__ */ d(
|
|
64
|
+
"span",
|
|
65
|
+
{
|
|
66
|
+
className: p(
|
|
67
|
+
"inline-flex h-6 items-center gap-1 rounded-full bg-slate-100 pl-0.5 pr-2 text-[11px] text-slate-700 dark:bg-muted dark:text-slate-200",
|
|
68
|
+
l && "opacity-60",
|
|
69
|
+
e === "failed" && "text-red-600 dark:text-red-300"
|
|
70
|
+
),
|
|
71
|
+
"data-tip": e === "failed" ? `${r ?? "Someone"} — connection failed` : l ? `${r ?? "Someone"} — connecting` : void 0,
|
|
72
|
+
"data-huddle-person": a,
|
|
73
|
+
children: [
|
|
74
|
+
/* @__PURE__ */ t("span", { style: { lineHeight: 0 }, children: o(a, r) }),
|
|
75
|
+
/* @__PURE__ */ t("span", { className: "max-w-[120px] truncate", children: r ?? "Someone" }),
|
|
76
|
+
n && /* @__PURE__ */ t(b, { className: "h-3 w-3 text-slate-400", strokeWidth: 2, "aria-label": "muted" }),
|
|
77
|
+
s && /* @__PURE__ */ t(g, { className: "h-3 w-3 text-nvr-cyan", strokeWidth: 2, "aria-label": "sharing" })
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
function O({
|
|
83
|
+
room: a,
|
|
84
|
+
me: r,
|
|
85
|
+
huddle: n,
|
|
86
|
+
renderAvatar: s
|
|
87
|
+
}) {
|
|
88
|
+
const { state: e, inThis: o } = n;
|
|
89
|
+
if (e.status === "error" && (e.room === a || !e.room))
|
|
90
|
+
return /* @__PURE__ */ d(
|
|
91
|
+
"div",
|
|
92
|
+
{
|
|
93
|
+
className: "flex items-center gap-2 border-b border-red-200 bg-red-50 px-3 py-1.5 text-[11.5px] text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-200",
|
|
94
|
+
role: "alert",
|
|
95
|
+
"data-huddle-error": !0,
|
|
96
|
+
children: [
|
|
97
|
+
/* @__PURE__ */ t("span", { className: "min-w-0 flex-1", children: e.error }),
|
|
98
|
+
/* @__PURE__ */ t(
|
|
99
|
+
"button",
|
|
100
|
+
{
|
|
101
|
+
type: "button",
|
|
102
|
+
onClick: n.clearError,
|
|
103
|
+
className: "flex h-5 w-5 items-center justify-center rounded hover:bg-red-100 dark:hover:bg-red-500/20",
|
|
104
|
+
"aria-label": "Dismiss",
|
|
105
|
+
children: /* @__PURE__ */ t(f, { className: "h-3 w-3", strokeWidth: 2 })
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
if (!o) return null;
|
|
112
|
+
const l = e.peers.find((i) => i.video), c = e.status === "joining";
|
|
113
|
+
return /* @__PURE__ */ d(
|
|
114
|
+
"div",
|
|
115
|
+
{
|
|
116
|
+
className: "shrink-0 border-b border-slate-200 bg-slate-50 px-3 py-1.5 dark:border-border dark:bg-background motion-safe:animate-in motion-safe:fade-in motion-safe:duration-200",
|
|
117
|
+
"data-huddle-stage": !0,
|
|
118
|
+
children: [
|
|
119
|
+
/* @__PURE__ */ d("div", { className: "flex flex-wrap items-center gap-1.5 text-[11px]", children: [
|
|
120
|
+
/* @__PURE__ */ d("span", { className: "inline-flex items-center gap-1 font-medium text-slate-700 dark:text-slate-200", children: [
|
|
121
|
+
/* @__PURE__ */ t(x, { className: "h-3.5 w-3.5 text-nvr-cyan", strokeWidth: 2 }),
|
|
122
|
+
c ? "Connecting…" : "Huddle"
|
|
123
|
+
] }),
|
|
124
|
+
!c && /* @__PURE__ */ t(w, { since: e.startedAt }),
|
|
125
|
+
/* @__PURE__ */ t("span", { className: "mx-0.5 h-3 w-px bg-slate-200 dark:bg-border", "aria-hidden": !0 }),
|
|
126
|
+
r && /* @__PURE__ */ t(
|
|
127
|
+
m,
|
|
128
|
+
{
|
|
129
|
+
id: r.id,
|
|
130
|
+
name: r.name,
|
|
131
|
+
muted: e.muted,
|
|
132
|
+
screen: e.sharing,
|
|
133
|
+
renderAvatar: s
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
e.peers.map((i) => /* @__PURE__ */ t(
|
|
137
|
+
m,
|
|
138
|
+
{
|
|
139
|
+
id: i.user,
|
|
140
|
+
name: i.name,
|
|
141
|
+
muted: i.muted,
|
|
142
|
+
screen: i.screen,
|
|
143
|
+
connection: i.connection,
|
|
144
|
+
renderAvatar: s
|
|
145
|
+
},
|
|
146
|
+
i.socket
|
|
147
|
+
)),
|
|
148
|
+
!c && e.peers.length === 0 && /* @__PURE__ */ t("span", { className: "text-slate-500 dark:text-slate-400", children: "Only you so far — people in the room see a Join button." })
|
|
149
|
+
] }),
|
|
150
|
+
(l == null ? void 0 : l.video) && /* @__PURE__ */ t("div", { className: "mt-1.5", children: /* @__PURE__ */ t(
|
|
151
|
+
u,
|
|
152
|
+
{
|
|
153
|
+
stream: l.video,
|
|
154
|
+
label: `${l.name ?? "Someone"}'s screen`
|
|
155
|
+
}
|
|
156
|
+
) }),
|
|
157
|
+
e.sharing && e.localScreen && /* @__PURE__ */ t("div", { className: "mt-1.5", children: /* @__PURE__ */ t(u, { stream: e.localScreen, label: "You are sharing your screen", mirror: !0 }) })
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
export {
|
|
163
|
+
O as HuddleStage
|
|
164
|
+
};
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
var g = Object.defineProperty;
|
|
2
|
+
var v = (r, t, s) => t in r ? g(r, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[t] = s;
|
|
3
|
+
var c = (r, t, s) => v(r, typeof t != "symbol" ? t + "" : t, s);
|
|
4
|
+
const u = {
|
|
5
|
+
room: null,
|
|
6
|
+
status: "idle",
|
|
7
|
+
error: null,
|
|
8
|
+
self: null,
|
|
9
|
+
muted: !1,
|
|
10
|
+
sharing: !1,
|
|
11
|
+
localScreen: null,
|
|
12
|
+
startedAt: null,
|
|
13
|
+
peers: []
|
|
14
|
+
}, S = 15e3;
|
|
15
|
+
function k(r, t) {
|
|
16
|
+
return r < t;
|
|
17
|
+
}
|
|
18
|
+
function p(r, t, s) {
|
|
19
|
+
const e = [];
|
|
20
|
+
for (const i of t) {
|
|
21
|
+
if (i.socket === s) continue;
|
|
22
|
+
const n = r.find((o) => o.socket === i.socket);
|
|
23
|
+
e.push(
|
|
24
|
+
n ? { ...n, name: i.name, muted: i.muted, screen: i.screen, user: i.user, since: i.since } : { ...i, audio: null, video: null, connection: "new" }
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
return e;
|
|
28
|
+
}
|
|
29
|
+
function M(r) {
|
|
30
|
+
const t = r.map((s) => s.name || "Someone");
|
|
31
|
+
return t.length === 0 ? "" : t.length === 1 ? t[0] : t.length === 2 ? `${t[0]} and ${t[1]}` : `${t[0]}, ${t[1]} and ${t.length - 2} other${t.length - 2 === 1 ? "" : "s"}`;
|
|
32
|
+
}
|
|
33
|
+
function T(r) {
|
|
34
|
+
const t = Math.max(0, Math.floor(r / 1e3)), s = Math.floor(t / 60), e = Math.floor(s / 60), i = String(s % 60).padStart(2, "0"), n = String(t % 60).padStart(2, "0");
|
|
35
|
+
return e ? `${e}:${i}:${n}` : `${s}:${n}`;
|
|
36
|
+
}
|
|
37
|
+
class w {
|
|
38
|
+
constructor() {
|
|
39
|
+
c(this, "state", u);
|
|
40
|
+
c(this, "listeners", /* @__PURE__ */ new Set());
|
|
41
|
+
/** Who is in each room's huddle (rooms I am NOT in too) — from the server's broadcasts. */
|
|
42
|
+
c(this, "rosters", /* @__PURE__ */ new Map());
|
|
43
|
+
c(this, "rosterListeners", /* @__PURE__ */ new Set());
|
|
44
|
+
c(this, "transport", null);
|
|
45
|
+
c(this, "offs", []);
|
|
46
|
+
c(this, "links", /* @__PURE__ */ new Map());
|
|
47
|
+
c(this, "mic", null);
|
|
48
|
+
/** The last /ice answer, per room: TURN credentials are minted for the room being joined. */
|
|
49
|
+
c(this, "ice", null);
|
|
50
|
+
c(this, "fetchIce", null);
|
|
51
|
+
c(this, "ping", null);
|
|
52
|
+
/** One hidden <audio> per peer, owned here so sound survives any room view unmounting. */
|
|
53
|
+
c(this, "audio", /* @__PURE__ */ new Map());
|
|
54
|
+
// ── React plumbing ────────────────────────────────────────────────────────
|
|
55
|
+
c(this, "subscribe", (t) => (this.listeners.add(t), () => {
|
|
56
|
+
this.listeners.delete(t);
|
|
57
|
+
}));
|
|
58
|
+
c(this, "getSnapshot", () => this.state);
|
|
59
|
+
c(this, "subscribeRosters", (t) => (this.rosterListeners.add(t), () => {
|
|
60
|
+
this.rosterListeners.delete(t);
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
roster(t) {
|
|
64
|
+
return this.rosters.get(t);
|
|
65
|
+
}
|
|
66
|
+
set(t) {
|
|
67
|
+
this.state = { ...this.state, ...t };
|
|
68
|
+
for (const s of this.listeners) s();
|
|
69
|
+
}
|
|
70
|
+
setRoster(t, s) {
|
|
71
|
+
this.rosters.set(t, s);
|
|
72
|
+
for (const e of this.rosterListeners) e();
|
|
73
|
+
}
|
|
74
|
+
/** A REST read of a room's roster (the first paint, before any broadcast). */
|
|
75
|
+
seedRoster(t, s) {
|
|
76
|
+
this.rosters.has(t) || this.setRoster(t, s);
|
|
77
|
+
}
|
|
78
|
+
// ── Transport ─────────────────────────────────────────────────────────────
|
|
79
|
+
/** Bind the host's socket adapter once; later calls with the same adapter are no-ops. */
|
|
80
|
+
attach(t, s) {
|
|
81
|
+
if (this.fetchIce = s, this.transport !== t) {
|
|
82
|
+
for (const e of this.offs) e();
|
|
83
|
+
this.transport = t, this.offs = [
|
|
84
|
+
t.on("huddle:peers", (e) => this.onPeers(e)),
|
|
85
|
+
t.on(
|
|
86
|
+
"huddle:joined",
|
|
87
|
+
(e) => this.onJoined(e)
|
|
88
|
+
),
|
|
89
|
+
t.on("huddle:signal", (e) => void this.onSignal(e)),
|
|
90
|
+
t.on(
|
|
91
|
+
"huddle:denied",
|
|
92
|
+
(e) => this.onDenied(e)
|
|
93
|
+
),
|
|
94
|
+
// A reconnect is a new server socket: join again and rebuild every link.
|
|
95
|
+
t.on("auth:ok", () => {
|
|
96
|
+
var e;
|
|
97
|
+
this.state.room && this.state.status === "live" && ((e = this.transport) == null || e.emit("huddle:join", { room: this.state.room }));
|
|
98
|
+
})
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async iceServers(t) {
|
|
103
|
+
if (!this.fetchIce) return [];
|
|
104
|
+
const s = this.ice ? Math.min(this.ice.cfg.ttl_s, 3600) * 1e3 * 0.8 : 0;
|
|
105
|
+
return (!this.ice || this.ice.room !== t || Date.now() - this.ice.at > s) && (this.ice = { room: t, at: Date.now(), cfg: await this.fetchIce(t) }), this.ice.cfg.iceServers;
|
|
106
|
+
}
|
|
107
|
+
// ── Join / leave ──────────────────────────────────────────────────────────
|
|
108
|
+
async join(t) {
|
|
109
|
+
if (!this.transport) return;
|
|
110
|
+
const s = this.state.status === "joining" || this.state.status === "live";
|
|
111
|
+
if (!(this.state.room === t && s)) {
|
|
112
|
+
this.state.room && s && this.leave(), this.set({ room: t, status: "joining", error: null, startedAt: null });
|
|
113
|
+
try {
|
|
114
|
+
this.mic = await navigator.mediaDevices.getUserMedia({
|
|
115
|
+
audio: { echoCancellation: !0, noiseSuppression: !0, autoGainControl: !0 }
|
|
116
|
+
});
|
|
117
|
+
} catch (e) {
|
|
118
|
+
const i = e == null ? void 0 : e.name;
|
|
119
|
+
this.set({
|
|
120
|
+
status: "error",
|
|
121
|
+
error: i === "NotAllowedError" ? "Microphone access was refused. Allow it in the browser and try again." : i === "NotFoundError" ? "No microphone was found." : "The microphone could not be started."
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
for (const e of this.mic.getAudioTracks()) e.enabled = !this.state.muted;
|
|
126
|
+
await this.iceServers(t).catch(() => null), this.transport.emit("huddle:join", { room: t });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
leave() {
|
|
130
|
+
var s;
|
|
131
|
+
const t = this.state.room;
|
|
132
|
+
t && ((s = this.transport) == null || s.emit("huddle:leave", { room: t })), this.teardown();
|
|
133
|
+
}
|
|
134
|
+
teardown() {
|
|
135
|
+
var t, s;
|
|
136
|
+
this.ping && clearInterval(this.ping), this.ping = null;
|
|
137
|
+
for (const [e, i] of this.links)
|
|
138
|
+
i.pc.close(), this.dropAudio(e);
|
|
139
|
+
this.links.clear();
|
|
140
|
+
for (const e of ((t = this.mic) == null ? void 0 : t.getTracks()) ?? []) e.stop();
|
|
141
|
+
this.mic = null;
|
|
142
|
+
for (const e of ((s = this.state.localScreen) == null ? void 0 : s.getTracks()) ?? []) e.stop();
|
|
143
|
+
this.set({ ...u, muted: this.state.muted });
|
|
144
|
+
}
|
|
145
|
+
onJoined(t) {
|
|
146
|
+
var i;
|
|
147
|
+
if (t.room !== this.state.room) return;
|
|
148
|
+
if (this.state.self && this.state.self !== t.self) {
|
|
149
|
+
for (const [n, o] of this.links)
|
|
150
|
+
o.pc.close(), this.dropAudio(n);
|
|
151
|
+
this.links.clear();
|
|
152
|
+
}
|
|
153
|
+
const s = p([], t.peers, t.self), e = Math.min(Date.now(), ...t.peers.map((n) => n.since).filter(Boolean));
|
|
154
|
+
this.set({ status: "live", self: t.self, peers: s, startedAt: e, error: null });
|
|
155
|
+
for (const n of s) this.link(n.socket);
|
|
156
|
+
this.ping && clearInterval(this.ping), this.ping = setInterval(() => {
|
|
157
|
+
var n;
|
|
158
|
+
this.state.room && ((n = this.transport) == null || n.emit("huddle:ping", { room: this.state.room }));
|
|
159
|
+
}, S), (this.state.muted || this.state.sharing) && ((i = this.transport) == null || i.emit("huddle:state", {
|
|
160
|
+
room: t.room,
|
|
161
|
+
muted: this.state.muted,
|
|
162
|
+
screen: this.state.sharing
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
onPeers(t) {
|
|
166
|
+
var i;
|
|
167
|
+
if (this.setRoster(t.room, t.peers), t.room !== this.state.room || this.state.status !== "live") return;
|
|
168
|
+
const s = this.state.self, e = p(this.state.peers, t.peers, s);
|
|
169
|
+
for (const [n, o] of this.links)
|
|
170
|
+
e.some((l) => l.socket === n) || (o.pc.close(), this.links.delete(n), this.dropAudio(n));
|
|
171
|
+
for (const n of e) {
|
|
172
|
+
const o = this.links.get(n.socket);
|
|
173
|
+
if (!(!o || n.audio || n.video))
|
|
174
|
+
for (const l of o.pc.getReceivers()) {
|
|
175
|
+
if (((i = l.track) == null ? void 0 : i.readyState) !== "live") continue;
|
|
176
|
+
const d = new MediaStream([l.track]);
|
|
177
|
+
l.track.kind === "video" ? n.video = d : n.audio = d;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
this.set({ peers: e });
|
|
181
|
+
for (const n of e) this.links.has(n.socket) || this.link(n.socket);
|
|
182
|
+
}
|
|
183
|
+
onDenied(t) {
|
|
184
|
+
if (t.room && t.room !== this.state.room) return;
|
|
185
|
+
const s = {
|
|
186
|
+
full: "This huddle is full.",
|
|
187
|
+
"no-access": "You no longer have access to this room.",
|
|
188
|
+
off: "Huddles are turned off on this instance.",
|
|
189
|
+
"no-dm": "Huddles run in channels and record rooms.",
|
|
190
|
+
"not-signed-in": "Sign in again to join.",
|
|
191
|
+
unavailable: "The huddle service is unavailable right now."
|
|
192
|
+
};
|
|
193
|
+
this.teardown(), this.set({
|
|
194
|
+
status: "error",
|
|
195
|
+
error: s[t.reason] ?? "Could not join the huddle.",
|
|
196
|
+
room: t.room
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
clearError() {
|
|
200
|
+
this.state.status === "error" && this.set({ ...u, muted: this.state.muted });
|
|
201
|
+
}
|
|
202
|
+
// ── Peer links ────────────────────────────────────────────────────────────
|
|
203
|
+
updatePeer(t, s) {
|
|
204
|
+
this.set({
|
|
205
|
+
peers: this.state.peers.map((e) => e.socket === t ? { ...e, ...s } : e)
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
async link(t) {
|
|
209
|
+
var f, m;
|
|
210
|
+
const s = this.links.get(t);
|
|
211
|
+
if (s) return s;
|
|
212
|
+
const e = this.state.self, i = this.state.room;
|
|
213
|
+
if (!e || !i || !this.transport) return null;
|
|
214
|
+
const n = await this.iceServers(i).catch(() => []);
|
|
215
|
+
if (this.links.has(t)) return this.links.get(t) ?? null;
|
|
216
|
+
const o = new RTCPeerConnection({ iceServers: n }), l = {
|
|
217
|
+
pc: o,
|
|
218
|
+
polite: k(e, t),
|
|
219
|
+
makingOffer: !1,
|
|
220
|
+
ignoreOffer: !1,
|
|
221
|
+
screenSender: null,
|
|
222
|
+
queue: Promise.resolve()
|
|
223
|
+
};
|
|
224
|
+
this.links.set(t, l);
|
|
225
|
+
for (const a of ((f = this.mic) == null ? void 0 : f.getAudioTracks()) ?? []) o.addTrack(a, this.mic);
|
|
226
|
+
const d = (m = this.state.localScreen) == null ? void 0 : m.getVideoTracks()[0];
|
|
227
|
+
return d && this.state.localScreen && (l.screenSender = o.addTrack(d, this.state.localScreen)), o.onnegotiationneeded = async () => {
|
|
228
|
+
try {
|
|
229
|
+
l.makingOffer = !0, await o.setLocalDescription(), this.signal(t, { description: o.localDescription });
|
|
230
|
+
} catch {
|
|
231
|
+
} finally {
|
|
232
|
+
l.makingOffer = !1;
|
|
233
|
+
}
|
|
234
|
+
}, o.onicecandidate = (a) => {
|
|
235
|
+
a.candidate && this.signal(t, { candidate: a.candidate.toJSON() });
|
|
236
|
+
}, o.ontrack = (a) => {
|
|
237
|
+
const h = a.streams[0] ?? new MediaStream([a.track]);
|
|
238
|
+
a.track.kind === "video" ? (this.updatePeer(t, { video: h }), a.track.onended = () => this.updatePeer(t, { video: null }), a.track.onmute = () => this.updatePeer(t, { video: null }), a.track.onunmute = () => this.updatePeer(t, { video: h })) : (this.updatePeer(t, { audio: h }), this.playAudio(t, h));
|
|
239
|
+
}, o.onconnectionstatechange = () => {
|
|
240
|
+
var h;
|
|
241
|
+
const a = o.connectionState;
|
|
242
|
+
this.updatePeer(t, {
|
|
243
|
+
connection: a === "connected" ? "connected" : a === "failed" || a === "closed" ? "failed" : "connecting"
|
|
244
|
+
}), a === "failed" && ((h = o.restartIce) == null || h.call(o));
|
|
245
|
+
}, l;
|
|
246
|
+
}
|
|
247
|
+
playAudio(t, s) {
|
|
248
|
+
if (typeof document > "u") return;
|
|
249
|
+
let e = this.audio.get(t);
|
|
250
|
+
e || (e = document.createElement("audio"), e.autoplay = !0, e.setAttribute("data-huddle-audio", t), e.style.display = "none", document.body.appendChild(e), this.audio.set(t, e)), e.srcObject = s, e.play().catch(() => null);
|
|
251
|
+
}
|
|
252
|
+
dropAudio(t) {
|
|
253
|
+
const s = this.audio.get(t);
|
|
254
|
+
s && (s.srcObject = null, s.remove(), this.audio.delete(t));
|
|
255
|
+
}
|
|
256
|
+
signal(t, s) {
|
|
257
|
+
var e;
|
|
258
|
+
this.state.room && ((e = this.transport) == null || e.emit("huddle:signal", { room: this.state.room, to: t, data: s }));
|
|
259
|
+
}
|
|
260
|
+
async onSignal(t) {
|
|
261
|
+
if (t.room !== this.state.room || this.state.status !== "live") return;
|
|
262
|
+
const s = await this.link(t.from);
|
|
263
|
+
if (s)
|
|
264
|
+
return s.queue = s.queue.then(() => this.applySignal(s, t)).catch(() => {
|
|
265
|
+
}), s.queue;
|
|
266
|
+
}
|
|
267
|
+
async applySignal(t, s) {
|
|
268
|
+
const { pc: e } = t;
|
|
269
|
+
if (e.signalingState !== "closed")
|
|
270
|
+
try {
|
|
271
|
+
if (s.data.description) {
|
|
272
|
+
const i = s.data.description, n = i.type === "offer" && (t.makingOffer || e.signalingState !== "stable");
|
|
273
|
+
if (t.ignoreOffer = !t.polite && n, t.ignoreOffer) return;
|
|
274
|
+
await e.setRemoteDescription(i), i.type === "offer" && (await e.setLocalDescription(), this.signal(s.from, { description: e.localDescription }));
|
|
275
|
+
} else if (s.data.candidate)
|
|
276
|
+
try {
|
|
277
|
+
await e.addIceCandidate(s.data.candidate);
|
|
278
|
+
} catch (i) {
|
|
279
|
+
if (!t.ignoreOffer) throw i;
|
|
280
|
+
}
|
|
281
|
+
} catch {
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
// ── Controls ──────────────────────────────────────────────────────────────
|
|
285
|
+
setMuted(t) {
|
|
286
|
+
var s, e;
|
|
287
|
+
for (const i of ((s = this.mic) == null ? void 0 : s.getAudioTracks()) ?? []) i.enabled = !t;
|
|
288
|
+
this.set({ muted: t }), this.state.room && this.state.status === "live" && ((e = this.transport) == null || e.emit("huddle:state", { room: this.state.room, muted: t }));
|
|
289
|
+
}
|
|
290
|
+
async startShare() {
|
|
291
|
+
var e;
|
|
292
|
+
if (this.state.status !== "live" || this.state.sharing) return;
|
|
293
|
+
let t;
|
|
294
|
+
try {
|
|
295
|
+
t = await navigator.mediaDevices.getDisplayMedia({
|
|
296
|
+
video: { frameRate: 15, width: { ideal: 1920 }, height: { ideal: 1080 } },
|
|
297
|
+
audio: !1
|
|
298
|
+
});
|
|
299
|
+
} catch {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const s = t.getVideoTracks()[0];
|
|
303
|
+
if (s) {
|
|
304
|
+
s.onended = () => this.stopShare();
|
|
305
|
+
for (const [, i] of this.links) i.screenSender = i.pc.addTrack(s, t);
|
|
306
|
+
this.set({ sharing: !0, localScreen: t }), (e = this.transport) == null || e.emit("huddle:state", { room: this.state.room, screen: !0 });
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
stopShare() {
|
|
310
|
+
var t, s;
|
|
311
|
+
if (this.state.sharing) {
|
|
312
|
+
for (const e of ((t = this.state.localScreen) == null ? void 0 : t.getTracks()) ?? []) e.stop();
|
|
313
|
+
for (const [, e] of this.links)
|
|
314
|
+
if (e.screenSender) {
|
|
315
|
+
try {
|
|
316
|
+
e.pc.removeTrack(e.screenSender);
|
|
317
|
+
} catch {
|
|
318
|
+
}
|
|
319
|
+
e.screenSender = null;
|
|
320
|
+
}
|
|
321
|
+
this.set({ sharing: !1, localScreen: null }), this.state.room && this.state.status === "live" && ((s = this.transport) == null || s.emit("huddle:state", { room: this.state.room, screen: !1 }));
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
const D = new w();
|
|
326
|
+
function b() {
|
|
327
|
+
if (typeof navigator > "u" || typeof window > "u")
|
|
328
|
+
return { audio: !1, screen: !1 };
|
|
329
|
+
const r = navigator.mediaDevices;
|
|
330
|
+
return {
|
|
331
|
+
audio: !!(r != null && r.getUserMedia) && typeof RTCPeerConnection < "u",
|
|
332
|
+
screen: !!(r != null && r.getDisplayMedia)
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
export {
|
|
336
|
+
T as formatElapsed,
|
|
337
|
+
D as huddleStore,
|
|
338
|
+
b as huddleSupport,
|
|
339
|
+
p as mergeRoster,
|
|
340
|
+
M as peerSummary,
|
|
341
|
+
k as politeFor
|
|
342
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useQuery as f } from "@tanstack/react-query";
|
|
2
|
+
import { useMemo as E, useCallback as x, useEffect as m, useSyncExternalStore as v } from "react";
|
|
3
|
+
import { useNivaroClient as M } from "../../../context.js";
|
|
4
|
+
import { get as b } from "../../../lib/commands.js";
|
|
5
|
+
import { useOptionalRealtime as T } from "../../../lib/realtime.js";
|
|
6
|
+
import { huddleSupport as j, huddleStore as t } from "./huddle-store.js";
|
|
7
|
+
const l = [];
|
|
8
|
+
function R(e) {
|
|
9
|
+
const a = T(), c = M(), n = E(j, []), d = !!a && n.audio && !!e, o = x(
|
|
10
|
+
(u) => c.request(b("/chat/huddle/ice", u ? { room: u } : {})).then((q) => q.data),
|
|
11
|
+
[c]
|
|
12
|
+
), { data: r } = f({
|
|
13
|
+
queryKey: ["nvr-huddle-ice"],
|
|
14
|
+
queryFn: () => o(),
|
|
15
|
+
enabled: d,
|
|
16
|
+
staleTime: 5 * 6e4
|
|
17
|
+
}), p = d && (r == null ? void 0 : r.enabled) !== !1;
|
|
18
|
+
m(() => {
|
|
19
|
+
a && n.audio && t.attach(a, o);
|
|
20
|
+
}, [a, n.audio, o]);
|
|
21
|
+
const s = v(t.subscribe, t.getSnapshot), { data: i } = f({
|
|
22
|
+
queryKey: ["nvr-huddle-presence", e],
|
|
23
|
+
queryFn: () => c.request(
|
|
24
|
+
b("/chat/huddle/presence", { room: e })
|
|
25
|
+
).then((u) => u.data.peers),
|
|
26
|
+
enabled: p,
|
|
27
|
+
staleTime: 2e4,
|
|
28
|
+
refetchInterval: 6e4
|
|
29
|
+
});
|
|
30
|
+
m(() => {
|
|
31
|
+
e && i && t.seedRoster(e, i);
|
|
32
|
+
}, [e, i]);
|
|
33
|
+
const g = v(
|
|
34
|
+
t.subscribeRosters,
|
|
35
|
+
() => e ? t.roster(e) ?? i ?? l : l,
|
|
36
|
+
() => l
|
|
37
|
+
), h = s.status === "joining" || s.status === "live", y = !!e && s.room === e && h, S = !!s.room && s.room !== e && h;
|
|
38
|
+
return {
|
|
39
|
+
support: n,
|
|
40
|
+
enabled: p,
|
|
41
|
+
state: s,
|
|
42
|
+
/** Everyone in this room's huddle (me included when I am in). */
|
|
43
|
+
roster: g,
|
|
44
|
+
inThis: y,
|
|
45
|
+
inOther: S,
|
|
46
|
+
maxParticipants: (r == null ? void 0 : r.max_participants) ?? 8,
|
|
47
|
+
join: () => {
|
|
48
|
+
e && t.join(e);
|
|
49
|
+
},
|
|
50
|
+
leave: () => t.leave(),
|
|
51
|
+
toggleMute: () => t.setMuted(!s.muted),
|
|
52
|
+
toggleShare: () => s.sharing ? t.stopShare() : void t.startShare(),
|
|
53
|
+
clearError: () => t.clearError()
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
R as useHuddle
|
|
58
|
+
};
|