@opengeni/react 1.0.1 → 1.0.2-canary.37191796234001
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/README.md +651 -21
- package/dist/accounts.d.ts +64 -0
- package/dist/accounts.js +822 -0
- package/dist/accounts.js.map +1 -0
- package/dist/approvals.d.ts +2 -1
- package/dist/artifacts-document.js +3 -2
- package/dist/artifacts-presentation.js +3 -2
- package/dist/artifacts-spreadsheet.js +2 -2
- package/dist/artifacts.d.ts +4 -1
- package/dist/artifacts.js +518 -42
- package/dist/artifacts.js.map +1 -1
- package/dist/browser-viewer-GTR5XQ7X.js +16 -0
- package/dist/capability-catalog-row.d.ts +20 -0
- package/dist/capability-logo-fallback.d.ts +3 -0
- package/dist/chat-interactive-block-UGBTNB3L.js +11 -0
- package/dist/chat-interactive-block-UGBTNB3L.js.map +1 -0
- package/dist/{chunk-5UQPNLIO.js → chunk-23J2ZNXT.js} +4117 -3896
- package/dist/chunk-23J2ZNXT.js.map +1 -0
- package/dist/chunk-447JLCBU.js +209 -0
- package/dist/chunk-447JLCBU.js.map +1 -0
- package/dist/chunk-4RVYOY4O.js +379 -0
- package/dist/chunk-4RVYOY4O.js.map +1 -0
- package/dist/chunk-5CVXZA3Y.js +292 -0
- package/dist/chunk-5CVXZA3Y.js.map +1 -0
- package/dist/chunk-5J4FOW6Q.js +108 -0
- package/dist/chunk-5J4FOW6Q.js.map +1 -0
- package/dist/chunk-A2PI6UMY.js +41 -0
- package/dist/chunk-A2PI6UMY.js.map +1 -0
- package/dist/{chunk-7WCLAEFV.js → chunk-A4UJB2MM.js} +37 -27
- package/dist/chunk-A4UJB2MM.js.map +1 -0
- package/dist/chunk-B3V6TG77.js +41 -0
- package/dist/chunk-B3V6TG77.js.map +1 -0
- package/dist/chunk-BRM6FVZA.js +302 -0
- package/dist/chunk-BRM6FVZA.js.map +1 -0
- package/dist/chunk-C5X5AJXK.js +182 -0
- package/dist/chunk-C5X5AJXK.js.map +1 -0
- package/dist/chunk-CR7U7HAR.js +453 -0
- package/dist/chunk-CR7U7HAR.js.map +1 -0
- package/dist/{chunk-R3AZOAB5.js → chunk-DYWBUX5Q.js} +29 -123
- package/dist/chunk-DYWBUX5Q.js.map +1 -0
- package/dist/chunk-E3G7SAYZ.js +3124 -0
- package/dist/chunk-E3G7SAYZ.js.map +1 -0
- package/dist/chunk-ELCE5SXV.js +359 -0
- package/dist/chunk-ELCE5SXV.js.map +1 -0
- package/dist/chunk-ERGYJIBB.js +21 -0
- package/dist/chunk-ERGYJIBB.js.map +1 -0
- package/dist/chunk-FFA2OVOV.js +319 -0
- package/dist/chunk-FFA2OVOV.js.map +1 -0
- package/dist/chunk-FZCP527Y.js +116 -0
- package/dist/chunk-FZCP527Y.js.map +1 -0
- package/dist/chunk-GIMRELBW.js +14 -0
- package/dist/chunk-GIMRELBW.js.map +1 -0
- package/dist/{chunk-6KLX2RH5.js → chunk-H2NJQORO.js} +1069 -79
- package/dist/chunk-H2NJQORO.js.map +1 -0
- package/dist/chunk-I7IWRQLN.js +1608 -0
- package/dist/chunk-I7IWRQLN.js.map +1 -0
- package/dist/{chunk-HA46CYQK.js → chunk-IQUCRAT7.js} +792 -537
- package/dist/chunk-IQUCRAT7.js.map +1 -0
- package/dist/chunk-IWIDV7SB.js +1 -0
- package/dist/chunk-IWIDV7SB.js.map +1 -0
- package/dist/chunk-J2QWVSQY.js +312 -0
- package/dist/chunk-J2QWVSQY.js.map +1 -0
- package/dist/chunk-JFNEV4LU.js +2733 -0
- package/dist/chunk-JFNEV4LU.js.map +1 -0
- package/dist/chunk-JT4JW7BC.js +54 -0
- package/dist/chunk-JT4JW7BC.js.map +1 -0
- package/dist/chunk-K3HQAKQX.js +24 -0
- package/dist/chunk-K3HQAKQX.js.map +1 -0
- package/dist/{chunk-C5ZPSSS5.js → chunk-NEXLLTP4.js} +2 -1
- package/dist/{chunk-C5ZPSSS5.js.map → chunk-NEXLLTP4.js.map} +1 -1
- package/dist/chunk-NZUI76EM.js +371 -0
- package/dist/chunk-NZUI76EM.js.map +1 -0
- package/dist/{chunk-PEI6RANI.js → chunk-PNY3JKBJ.js} +309 -74
- package/dist/chunk-PNY3JKBJ.js.map +1 -0
- package/dist/{chunk-IGC6A2ZI.js → chunk-Q5QBEZIQ.js} +777 -246
- package/dist/chunk-Q5QBEZIQ.js.map +1 -0
- package/dist/chunk-RHREZ7BO.js +11 -0
- package/dist/chunk-RHREZ7BO.js.map +1 -0
- package/dist/chunk-SCOTPE2I.js +589 -0
- package/dist/chunk-SCOTPE2I.js.map +1 -0
- package/dist/{chunk-B6WPZSTT.js → chunk-SJZDKVW2.js} +1331 -1163
- package/dist/chunk-SJZDKVW2.js.map +1 -0
- package/dist/chunk-TMJRG4YC.js +12803 -0
- package/dist/chunk-TMJRG4YC.js.map +1 -0
- package/dist/chunk-TMYGL6X5.js +742 -0
- package/dist/chunk-TMYGL6X5.js.map +1 -0
- package/dist/chunk-UGLEYEMP.js +33 -0
- package/dist/chunk-UGLEYEMP.js.map +1 -0
- package/dist/chunk-UK4TINKT.js +27 -0
- package/dist/chunk-UK4TINKT.js.map +1 -0
- package/dist/chunk-UTRTG6LH.js +220 -0
- package/dist/chunk-UTRTG6LH.js.map +1 -0
- package/dist/chunk-WEHMPOXK.js +39 -0
- package/dist/chunk-WEHMPOXK.js.map +1 -0
- package/dist/chunk-WRHIZYZF.js +988 -0
- package/dist/chunk-WRHIZYZF.js.map +1 -0
- package/dist/{chunk-HUIKIDM5.js → chunk-WUISZ3WU.js} +223 -115
- package/dist/chunk-WUISZ3WU.js.map +1 -0
- package/dist/chunk-XCHWDJ22.js +107 -0
- package/dist/chunk-XCHWDJ22.js.map +1 -0
- package/dist/chunk-XOAMRDDK.js +481 -0
- package/dist/chunk-XOAMRDDK.js.map +1 -0
- package/dist/chunk-XUW2UWQM.js +299 -0
- package/dist/chunk-XUW2UWQM.js.map +1 -0
- package/dist/{chunk-KCGXPP5V.js → chunk-Y2PRMYLC.js} +11 -6
- package/dist/chunk-Y2PRMYLC.js.map +1 -0
- package/dist/chunk-YBXQDQFX.js +1772 -0
- package/dist/chunk-YBXQDQFX.js.map +1 -0
- package/dist/{chunk-KZ73RL76.js → chunk-YQEAA6LT.js} +7 -3
- package/dist/chunk-YQEAA6LT.js.map +1 -0
- package/dist/chunk-YV4L3ILF.js +9 -0
- package/dist/chunk-YV4L3ILF.js.map +1 -0
- package/dist/{chunk-LLOLUHVG.js → chunk-YWFG7ZX7.js} +1358 -2746
- package/dist/chunk-YWFG7ZX7.js.map +1 -0
- package/dist/chunk-ZYRGEKWS.js +216 -0
- package/dist/chunk-ZYRGEKWS.js.map +1 -0
- package/dist/client.d.ts +7 -4
- package/dist/clipboard.js +1 -0
- package/dist/commands/types.d.ts +2 -0
- package/dist/components/anthropic-mark.d.ts +3 -0
- package/dist/components/approval-surface.d.ts +15 -0
- package/dist/components/artifacts/artifact-chrome.d.ts +120 -0
- package/dist/components/artifacts/artifact-sandbox.d.ts +27 -0
- package/dist/components/artifacts/artifact-surface.d.ts +3 -1
- package/dist/components/artifacts/chat-interactive-block.d.ts +29 -0
- package/dist/components/artifacts/deferred-chat-media.d.ts +15 -0
- package/dist/components/artifacts/document-editor.d.ts +4 -2
- package/dist/components/artifacts/editable-artifact-ui.d.ts +2 -1
- package/dist/components/artifacts/editable-artifact-view.d.ts +46 -0
- package/dist/components/artifacts/editable-document.d.ts +1 -1
- package/dist/components/artifacts/editable-presentation.d.ts +2 -2
- package/dist/components/artifacts/editable-spreadsheet.d.ts +2 -1
- package/dist/components/artifacts/index.d.ts +8 -1
- package/dist/components/artifacts/inline-html-document.d.ts +2 -0
- package/dist/components/artifacts/latest-task-runner.d.ts +15 -0
- package/dist/components/artifacts/presentation-editor.d.ts +6 -2
- package/dist/components/artifacts/published-html-artifact-frame.d.ts +48 -3
- package/dist/components/artifacts/session-artifact-viewer.d.ts +39 -0
- package/dist/components/artifacts/site-view.d.ts +23 -0
- package/dist/components/artifacts/spreadsheet-general-display.d.ts +24 -0
- package/dist/components/artifacts/visualization-assets.gen.d.ts +2 -0
- package/dist/components/browser-select-control.d.ts +16 -0
- package/dist/components/browser-viewer.d.ts +10 -1
- package/dist/components/chat-composer.d.ts +21 -3
- package/dist/components/child-session-link.d.ts +5 -0
- package/dist/components/claude-mark.d.ts +3 -0
- package/dist/components/code-editor.d.ts +1 -4
- package/dist/components/composer.d.ts +45 -4
- package/dist/components/computer-viewer.d.ts +4 -1
- package/dist/components/copy-button.d.ts +3 -1
- package/dist/components/desktop-viewer.d.ts +1 -1
- package/dist/components/enrollment-consent.d.ts +6 -3
- package/dist/components/file-browser.d.ts +10 -1
- package/dist/components/fleet-tile.d.ts +2 -2
- package/dist/components/grok-mark.d.ts +26 -0
- package/dist/components/human-input-form.d.ts +21 -2
- package/dist/components/human-input-surface.d.ts +6 -3
- package/dist/components/machine-card.d.ts +4 -1
- package/dist/components/machines/machine-detail.d.ts +4 -1
- package/dist/components/machines/machine-operation-policy.d.ts +11 -0
- package/dist/components/machines-dashboard.d.ts +3 -1
- package/dist/components/markdown-table-layout.d.ts +12 -0
- package/dist/components/markdown.d.ts +47 -3
- package/dist/components/message-timeline.d.ts +72 -9
- package/dist/components/model-mark.d.ts +29 -0
- package/dist/components/model-policy-picker-menu.d.ts +9 -0
- package/dist/components/model-policy-picker.d.ts +62 -13
- package/dist/components/open-geni-chat.d.ts +55 -0
- package/dist/components/open-geni-links.d.ts +68 -0
- package/dist/components/openrouter-mark.d.ts +6 -0
- package/dist/components/pierre-file.d.ts +1 -1
- package/dist/components/preview-loading.d.ts +2 -0
- package/dist/components/queue-item-content.d.ts +9 -0
- package/dist/components/sandbox-files.d.ts +13 -2
- package/dist/components/sandbox-workspace.d.ts +43 -3
- package/dist/components/session-capability-frame.d.ts +35 -0
- package/dist/components/session-chrome.d.ts +66 -8
- package/dist/components/session-commands-panel.d.ts +6 -0
- package/dist/components/session-commands.d.ts +6 -0
- package/dist/components/session-connection-request.d.ts +8 -0
- package/dist/components/session-conversation.d.ts +86 -0
- package/dist/components/session-list.d.ts +36 -0
- package/dist/components/session-mcp-capability-card.d.ts +41 -0
- package/dist/components/timeline-anchor.d.ts +24 -0
- package/dist/components/timeline-annotation-chrome.d.ts +25 -0
- package/dist/components/timeline-annotation-layout.d.ts +42 -0
- package/dist/components/timeline-annotation-markers.d.ts +8 -0
- package/dist/components/timeline-annotation-reveal-context.d.ts +4 -0
- package/dist/components/timeline-annotation-shared.d.ts +31 -0
- package/dist/components/timeline-annotations-dialog.d.ts +3 -2
- package/dist/components/timeline-annotations.d.ts +13 -3
- package/dist/components/timeline-reading-progress.d.ts +11 -0
- package/dist/components/timeline-search.d.ts +34 -0
- package/dist/components/timeline-settlement.d.ts +16 -0
- package/dist/components/tip-follow.d.ts +16 -0
- package/dist/components/usage-limit-notice.d.ts +49 -0
- package/dist/components/usage-member-list.d.ts +91 -0
- package/dist/components/usage-meter.d.ts +73 -0
- package/dist/components/use-viewer-menu-dismiss.d.ts +2 -0
- package/dist/components/user-message-body.d.ts +10 -1
- package/dist/components/workspace-dock.d.ts +6 -2
- package/dist/composer.d.ts +5 -4
- package/dist/composer.js +15 -9
- package/dist/computer-viewer-ENHVAZ2Q.js +19 -0
- package/dist/computer-viewer-ENHVAZ2Q.js.map +1 -0
- package/dist/connect-account-identity.d.ts +8 -0
- package/dist/connect-accounts.d.ts +15 -0
- package/dist/connect-chooser.d.ts +18 -0
- package/dist/connect-panel.d.ts +18 -0
- package/dist/connect-setup.d.ts +16 -0
- package/dist/connect.d.ts +21 -0
- package/dist/connect.js +2129 -0
- package/dist/connect.js.map +1 -0
- package/dist/connection-catalog.d.ts +38 -0
- package/dist/connection-discovery.d.ts +12 -0
- package/dist/connection-installed.d.ts +17 -0
- package/dist/connection-logo.d.ts +9 -0
- package/dist/connection-service-logo.d.ts +8 -0
- package/dist/connection-service-presentation.d.ts +13 -0
- package/dist/connection-skeleton.d.ts +5 -0
- package/dist/connection-type-picker.d.ts +6 -0
- package/dist/conversation-timeline.d.ts +5 -0
- package/dist/desktop.d.ts +7 -0
- package/dist/desktop.js +26 -0
- package/dist/desktop.js.map +1 -0
- package/dist/device-authorization.d.ts +23 -0
- package/dist/diffs.d.ts +8 -0
- package/dist/diffs.js +14 -0
- package/dist/diffs.js.map +1 -0
- package/dist/discovery-cache.d.ts +5 -0
- package/dist/editor.d.ts +7 -0
- package/dist/editor.js +21 -0
- package/dist/editor.js.map +1 -0
- package/dist/embedded-session-client.d.ts +23 -0
- package/dist/file-node-visibility.d.ts +15 -0
- package/dist/{fleet-decision-row-GGCAT4E4.js → fleet-decision-row-YZ3ZKWMM.js} +2 -1
- package/dist/fleet-decision-row-YZ3ZKWMM.js.map +1 -0
- package/dist/hooks/channel-cache.d.ts +23 -0
- package/dist/hooks/latest-question.d.ts +25 -0
- package/dist/hooks/shared-machines-list.d.ts +14 -0
- package/dist/hooks/use-attached-browsers.d.ts +2 -1
- package/dist/hooks/use-browser-frame-stream.d.ts +1 -1
- package/dist/hooks/use-browser-session.d.ts +12 -1
- package/dist/hooks/use-channels.d.ts +1 -0
- package/dist/hooks/use-codex-accounts.d.ts +25 -7
- package/dist/hooks/use-composer.d.ts +45 -9
- package/dist/hooks/use-computer-frame-stream.d.ts +1 -1
- package/dist/hooks/use-computer-input-posture.d.ts +13 -0
- package/dist/hooks/use-computer-session.d.ts +2 -0
- package/dist/hooks/use-connect.d.ts +22 -0
- package/dist/hooks/use-desktop-stream.d.ts +1 -1
- package/dist/hooks/use-file-attachments.d.ts +21 -2
- package/dist/hooks/use-machine-chip.d.ts +3 -3
- package/dist/hooks/use-machines.d.ts +19 -1
- package/dist/hooks/use-sandbox-files.d.ts +5 -1
- package/dist/hooks/use-session-background-commands.d.ts +14 -0
- package/dist/hooks/use-session-events.d.ts +30 -8
- package/dist/hooks/use-session-lineage.d.ts +4 -0
- package/dist/hooks/use-session-mcp-approval-policy.d.ts +2 -2
- package/dist/hooks/use-session.d.ts +6 -0
- package/dist/hooks/use-turn-queue.d.ts +12 -0
- package/dist/hooks/use-usage.d.ts +40 -0
- package/dist/hooks/use-workspace-edit.d.ts +4 -0
- package/dist/hooks/use-workspace-sessions.d.ts +27 -5
- package/dist/human-input.d.ts +3 -1
- package/dist/identity-link-accounts.d.ts +11 -0
- package/dist/identity-link-consent.d.ts +18 -0
- package/dist/index.d.ts +60 -17
- package/dist/index.js +2237 -6200
- package/dist/index.js.map +1 -1
- package/dist/interaction.d.ts +1 -1
- package/dist/interaction.js +35 -184
- package/dist/interaction.js.map +1 -1
- package/dist/latest-question-755OW5DS.js +117 -0
- package/dist/latest-question-755OW5DS.js.map +1 -0
- package/dist/lib/error-message.d.ts +7 -0
- package/dist/lib/format.d.ts +36 -2
- package/dist/lib/host-theme.d.ts +70 -0
- package/dist/lib/interaction-errors.d.ts +6 -0
- package/dist/lib/menu-styles.d.ts +22 -0
- package/dist/lib/pierre-diffs-loader.d.ts +20 -0
- package/dist/lib/workbench-peers.d.ts +36 -0
- package/dist/lib/xterm-theme.d.ts +7 -5
- package/dist/machines.d.ts +4 -2
- package/dist/machines.js +14 -4
- package/dist/markdown-table-layout-QXSLK4BY.js +106 -0
- package/dist/markdown-table-layout-QXSLK4BY.js.map +1 -0
- package/dist/mcp-connection-status.d.ts +14 -0
- package/dist/model-policy-picker-menu-PWRI7R2X.js +14 -0
- package/dist/model-policy-picker-menu-PWRI7R2X.js.map +1 -0
- package/dist/model-policy.d.ts +19 -3
- package/dist/model-policy.js +9 -1
- package/dist/older-history.d.ts +30 -0
- package/dist/platform-activity-row-627BFZ46.js +182 -0
- package/dist/platform-activity-row-627BFZ46.js.map +1 -0
- package/dist/plugin-details.d.ts +14 -0
- package/dist/plugin-discovery.d.ts +25 -0
- package/dist/provider.d.ts +13 -1
- package/dist/{queue-surface-implementation-2KVJTYXH.js → queue-surface-implementation-ZHFI5JBP.js} +131 -44
- package/dist/queue-surface-implementation-ZHFI5JBP.js.map +1 -0
- package/dist/realtime/realtime-control.d.ts +6 -3
- package/dist/realtime.js +133 -74
- package/dist/realtime.js.map +1 -1
- package/dist/sandbox-files-BBC47SLD.js +20 -0
- package/dist/sandbox-files-BBC47SLD.js.map +1 -0
- package/dist/session-auth-recommendation.d.ts +5 -0
- package/dist/session-capability-policy.d.ts +12 -0
- package/dist/session-ui.d.ts +30 -2
- package/dist/session-ui.js +85 -7
- package/dist/session-ui.js.map +1 -1
- package/dist/session.d.ts +8 -2
- package/dist/session.js +30 -19
- package/dist/sites-ui.d.ts +34 -0
- package/dist/sites.d.ts +3 -0
- package/dist/sites.js +11 -0
- package/dist/sites.js.map +1 -0
- package/dist/skill-discovery.d.ts +47 -0
- package/dist/terminal.d.ts +8 -0
- package/dist/terminal.js +31 -0
- package/dist/terminal.js.map +1 -0
- package/dist/timeline/activity-rail.d.ts +11 -2
- package/dist/timeline/allowance-exhausted-row.d.ts +24 -0
- package/dist/timeline/compaction-copy.d.ts +10 -0
- package/dist/timeline/entrance.d.ts +13 -1
- package/dist/timeline/genie-loading.d.ts +34 -0
- package/dist/timeline/index.d.ts +6 -2
- package/dist/timeline/knowledge-receipt.d.ts +17 -0
- package/dist/timeline/platform-activity-row.d.ts +14 -0
- package/dist/timeline/presented-image.d.ts +6 -0
- package/dist/timeline/projection.d.ts +31 -2
- package/dist/timeline/registry.d.ts +2 -0
- package/dist/timeline/retained-image.d.ts +18 -0
- package/dist/timeline/rolling-activity.d.ts +11 -0
- package/dist/timeline/screenshot-lightbox.d.ts +16 -1
- package/dist/timeline/shared.d.ts +8 -3
- package/dist/timeline/startup-preference.d.ts +3 -0
- package/dist/timeline/startup-timings.d.ts +4 -0
- package/dist/timeline/tool-display-name.d.ts +2 -1
- package/dist/timeline/turn-summary.d.ts +32 -3
- package/dist/timeline/types.d.ts +141 -7
- package/dist/timeline-annotation-markers-GNDHTGBD.js +165 -0
- package/dist/timeline-annotation-markers-GNDHTGBD.js.map +1 -0
- package/dist/timeline-annotation-selection-DMLMM2TX.js +241 -0
- package/dist/timeline-annotation-selection-DMLMM2TX.js.map +1 -0
- package/dist/timeline-annotations-dialog-ELRDBHTS.js +273 -0
- package/dist/timeline-annotations-dialog-ELRDBHTS.js.map +1 -0
- package/dist/types/machines.d.ts +2 -2
- package/dist/usage/allowance-copy.d.ts +25 -0
- package/dist/usage/summary.d.ts +35 -0
- package/dist/usage.d.ts +13 -0
- package/dist/usage.js +1074 -0
- package/dist/usage.js.map +1 -0
- package/package.json +44 -4
- package/src/accounts.tsx +1072 -0
- package/src/approvals.ts +8 -1
- package/src/artifacts.ts +42 -0
- package/src/assets/README.md +8 -0
- package/src/assets/gmail.ico +0 -0
- package/src/assets/outlook.ico +0 -0
- package/src/capability-catalog-row.tsx +94 -0
- package/src/capability-logo-fallback.ts +22 -0
- package/src/client.ts +22 -13
- package/src/commands/registry.ts +18 -15
- package/src/commands/types.ts +2 -0
- package/src/components/anthropic-mark.tsx +10 -0
- package/src/components/approval-surface.tsx +171 -37
- package/src/components/artifacts/artifact-chrome.tsx +413 -0
- package/src/components/artifacts/artifact-sandbox.tsx +185 -0
- package/src/components/artifacts/artifact-surface.tsx +39 -19
- package/src/components/artifacts/chat-interactive-block.tsx +260 -0
- package/src/components/artifacts/deferred-chat-media.tsx +67 -0
- package/src/components/artifacts/document-editor.tsx +141 -16
- package/src/components/artifacts/editable-artifact-ui.tsx +4 -2
- package/src/components/artifacts/editable-artifact-view.tsx +187 -0
- package/src/components/artifacts/editable-artifact-workbench.tsx +5 -2
- package/src/components/artifacts/editable-document.tsx +37 -36
- package/src/components/artifacts/editable-presentation.tsx +36 -18
- package/src/components/artifacts/editable-spreadsheet.tsx +5 -2
- package/src/components/artifacts/index.ts +44 -0
- package/src/components/artifacts/inline-html-document.ts +24 -0
- package/src/components/artifacts/latest-task-runner.ts +49 -0
- package/src/components/artifacts/presentation-editor.tsx +323 -67
- package/src/components/artifacts/published-html-artifact-frame.tsx +338 -5
- package/src/components/artifacts/session-artifact-viewer.tsx +376 -0
- package/src/components/artifacts/site-view.tsx +116 -0
- package/src/components/artifacts/spreadsheet-canvas.ts +5 -10
- package/src/components/artifacts/spreadsheet-general-display.ts +43 -0
- package/src/components/artifacts/spreadsheet-grid.tsx +12 -13
- package/src/components/artifacts/visualization-assets/base.css +1015 -0
- package/src/components/artifacts/visualization-assets/helpers.html +349 -0
- package/src/components/artifacts/visualization-assets.gen.ts +3 -0
- package/src/components/browser-select-control.tsx +312 -0
- package/src/components/browser-viewer.tsx +1054 -314
- package/src/components/chat-composer.tsx +131 -85
- package/src/components/child-session-link.tsx +27 -0
- package/src/components/claude-mark.tsx +10 -0
- package/src/components/code-editor.tsx +13 -16
- package/src/components/composer-transcription-control.tsx +7 -5
- package/src/components/composer.tsx +376 -49
- package/src/components/computer-viewer.tsx +1041 -329
- package/src/components/copy-button.tsx +13 -5
- package/src/components/desktop-viewer.tsx +1 -1
- package/src/components/enrollment-consent.tsx +65 -7
- package/src/components/enrollment-device-flow.tsx +1 -1
- package/src/components/file-browser.tsx +158 -34
- package/src/components/fleet-tile.tsx +8 -16
- package/src/components/generated-video-player.tsx +4 -2
- package/src/components/grok-mark.tsx +33 -0
- package/src/components/human-input-form.tsx +455 -114
- package/src/components/human-input-surface.tsx +18 -7
- package/src/components/interaction-intervention-banner.tsx +2 -2
- package/src/components/machine-card.tsx +119 -4
- package/src/components/machine-dock-bar.tsx +1 -1
- package/src/components/machine-input-display.ts +23 -2
- package/src/components/machines/machine-detail.tsx +52 -2
- package/src/components/machines/machine-operation-policy.tsx +179 -0
- package/src/components/machines-dashboard.tsx +8 -17
- package/src/components/markdown-table-layout.ts +132 -0
- package/src/components/markdown.tsx +473 -44
- package/src/components/message-timeline.tsx +2498 -663
- package/src/components/model-mark.tsx +90 -0
- package/src/components/model-picker.tsx +15 -4
- package/src/components/model-policy-picker-menu.tsx +424 -0
- package/src/components/model-policy-picker.tsx +337 -381
- package/src/components/open-geni-chat.tsx +319 -0
- package/src/components/open-geni-links.tsx +179 -0
- package/src/components/openrouter-mark.tsx +13 -0
- package/src/components/pierre-diff.tsx +41 -16
- package/src/components/pierre-file.tsx +36 -11
- package/src/components/preview-loading.tsx +154 -0
- package/src/components/queue-item-content.ts +14 -0
- package/src/components/queue-surface-implementation.tsx +132 -42
- package/src/components/queue-surface-state.tsx +3 -1
- package/src/components/sandbox-files.tsx +267 -35
- package/src/components/sandbox-terminal.tsx +48 -11
- package/src/components/sandbox-workspace.tsx +337 -135
- package/src/components/session-capability-frame.tsx +192 -0
- package/src/components/session-chrome.tsx +1027 -328
- package/src/components/session-commands-panel.tsx +126 -0
- package/src/components/session-commands.tsx +18 -0
- package/src/components/session-connection-request.tsx +97 -0
- package/src/components/session-conversation.tsx +512 -0
- package/src/components/session-list.tsx +250 -0
- package/src/components/session-mcp-capability-card.tsx +680 -0
- package/src/components/session-status.tsx +1 -1
- package/src/components/timeline-anchor.tsx +119 -0
- package/src/components/timeline-annotation-chrome.tsx +196 -0
- package/src/components/timeline-annotation-layout.ts +268 -0
- package/src/components/timeline-annotation-markers.tsx +185 -0
- package/src/components/timeline-annotation-reveal-context.ts +9 -0
- package/src/components/timeline-annotation-selection.tsx +106 -54
- package/src/components/timeline-annotation-shared.ts +245 -0
- package/src/components/timeline-annotations-dialog.tsx +185 -128
- package/src/components/timeline-annotations.tsx +189 -45
- package/src/components/timeline-reading-progress.ts +80 -0
- package/src/components/timeline-search.tsx +168 -0
- package/src/components/timeline-settlement.ts +60 -0
- package/src/components/tip-follow.ts +70 -7
- package/src/components/tooltip.tsx +38 -5
- package/src/components/usage-limit-notice.tsx +179 -0
- package/src/components/usage-member-list.tsx +792 -0
- package/src/components/usage-meter.tsx +382 -0
- package/src/components/use-viewer-menu-dismiss.ts +33 -0
- package/src/components/user-message-body.tsx +194 -49
- package/src/components/workspace-dock.tsx +141 -175
- package/src/composer.ts +6 -1
- package/src/connect-account-identity.tsx +34 -0
- package/src/connect-accounts.tsx +233 -0
- package/src/connect-chooser.tsx +336 -0
- package/src/connect-panel.tsx +99 -0
- package/src/connect-setup.tsx +307 -0
- package/src/connect.ts +60 -0
- package/src/connection-assets.d.ts +4 -0
- package/src/connection-catalog.tsx +162 -0
- package/src/connection-discovery.tsx +235 -0
- package/src/connection-installed.tsx +51 -0
- package/src/connection-logo.tsx +37 -0
- package/src/connection-service-logo.tsx +55 -0
- package/src/connection-service-presentation.ts +46 -0
- package/src/connection-skeleton.tsx +16 -0
- package/src/connection-type-picker.tsx +36 -0
- package/src/conversation-timeline.ts +92 -0
- package/src/desktop.ts +24 -0
- package/src/device-authorization.tsx +98 -0
- package/src/diffs.ts +16 -0
- package/src/discovery-cache.ts +42 -0
- package/src/editor.ts +13 -0
- package/src/embedded-session-client.ts +104 -0
- package/src/file-node-visibility.ts +66 -0
- package/src/hooks/channel-cache.ts +104 -0
- package/src/hooks/internal.ts +3 -2
- package/src/hooks/latest-question.ts +164 -0
- package/src/hooks/shared-machines-list.ts +239 -0
- package/src/hooks/use-attached-browsers.ts +5 -1
- package/src/hooks/use-available-models.ts +20 -14
- package/src/hooks/use-browser-frame-stream.ts +25 -3
- package/src/hooks/use-browser-session.ts +271 -71
- package/src/hooks/use-browser-sessions.ts +7 -1
- package/src/hooks/use-channels.ts +32 -10
- package/src/hooks/use-codex-accounts.ts +78 -21
- package/src/hooks/use-composer.ts +1034 -320
- package/src/hooks/use-computer-frame-stream.ts +39 -16
- package/src/hooks/use-computer-input-posture.ts +94 -0
- package/src/hooks/use-computer-session.ts +110 -32
- package/src/hooks/use-computer-sessions.ts +8 -1
- package/src/hooks/use-connect.ts +23 -0
- package/src/hooks/use-desktop-stream.ts +19 -28
- package/src/hooks/use-file-attachments.ts +118 -10
- package/src/hooks/use-goal.ts +36 -9
- package/src/hooks/use-human-input.ts +31 -4
- package/src/hooks/use-last-started-turn-policy.ts +15 -13
- package/src/hooks/use-machine-chip.ts +23 -6
- package/src/hooks/use-machines.ts +104 -6
- package/src/hooks/use-sandbox-files.ts +253 -150
- package/src/hooks/use-sandbox-git.ts +58 -29
- package/src/hooks/use-session-background-commands.ts +67 -0
- package/src/hooks/use-session-capabilities.ts +21 -2
- package/src/hooks/use-session-events.ts +759 -433
- package/src/hooks/use-session-lineage.ts +28 -6
- package/src/hooks/use-session-mcp-approval-policy.ts +13 -5
- package/src/hooks/use-session.ts +75 -16
- package/src/hooks/use-slash-commands.ts +6 -11
- package/src/hooks/use-turn-queue.ts +113 -13
- package/src/hooks/use-usage.ts +100 -0
- package/src/hooks/use-voice-input.ts +12 -1
- package/src/hooks/use-workspace-capture.ts +3 -2
- package/src/hooks/use-workspace-edit.ts +23 -5
- package/src/hooks/use-workspace-sessions.ts +99 -11
- package/src/human-input.ts +12 -1
- package/src/identity-link-accounts.tsx +148 -0
- package/src/identity-link-consent.tsx +192 -0
- package/src/index.ts +157 -12
- package/src/interaction.ts +1 -0
- package/src/lib/error-message.ts +37 -0
- package/src/lib/format.ts +150 -14
- package/src/lib/host-theme.ts +511 -0
- package/src/lib/interaction-errors.ts +33 -0
- package/src/lib/menu-styles.ts +44 -0
- package/src/lib/pierre-diffs-loader.ts +53 -0
- package/src/lib/workbench-peers.ts +62 -0
- package/src/lib/xterm-theme.ts +23 -21
- package/src/machines.ts +9 -1
- package/src/mcp-connection-status.ts +35 -0
- package/src/model-policy.ts +223 -69
- package/src/older-history.ts +87 -0
- package/src/plugin-details.tsx +185 -0
- package/src/plugin-discovery.tsx +196 -0
- package/src/provider.tsx +55 -14
- package/src/realtime/dropdown-menu.tsx +19 -12
- package/src/realtime/realtime-control.tsx +133 -46
- package/src/session-auth-recommendation.ts +48 -0
- package/src/session-capability-policy.ts +83 -0
- package/src/session-context.ts +1 -0
- package/src/session-ui.ts +66 -2
- package/src/session.ts +18 -1
- package/src/sites-ui.tsx +402 -0
- package/src/sites.ts +3 -0
- package/src/skill-discovery.tsx +208 -0
- package/src/terminal.ts +26 -0
- package/src/timeline/activity-rail.tsx +171 -80
- package/src/timeline/allowance-exhausted-row.tsx +86 -0
- package/src/timeline/compaction-copy.ts +42 -0
- package/src/timeline/entrance.tsx +28 -3
- package/src/timeline/fleet-decision-projection.ts +2 -1
- package/src/timeline/fleet-decision-row.tsx +1 -0
- package/src/timeline/genie-loading.tsx +136 -0
- package/src/timeline/index.ts +11 -0
- package/src/timeline/knowledge-receipt.tsx +100 -0
- package/src/timeline/parsers.ts +2 -2
- package/src/timeline/platform-activity-row.tsx +216 -0
- package/src/timeline/presented-image.ts +49 -0
- package/src/timeline/projection.ts +1600 -84
- package/src/timeline/registry.ts +15 -3
- package/src/timeline/retained-image.ts +97 -0
- package/src/timeline/rolling-activity.tsx +92 -0
- package/src/timeline/screenshot-lightbox.tsx +115 -17
- package/src/timeline/shared.tsx +47 -15
- package/src/timeline/startup-preference.ts +33 -0
- package/src/timeline/startup-timings.tsx +145 -0
- package/src/timeline/tool-display-name.ts +8 -6
- package/src/timeline/tool-renderers.tsx +497 -128
- package/src/timeline/turn-summary.tsx +208 -44
- package/src/timeline/types.ts +186 -7
- package/src/types/machines.ts +10 -0
- package/src/usage/allowance-copy.ts +64 -0
- package/src/usage/summary.ts +93 -0
- package/src/usage.ts +50 -0
- package/styles/compiled.css +2098 -757
- package/styles/connect.css +284 -0
- package/styles/connect.d.ts +1 -0
- package/styles/effective-tokens.css +1 -0
- package/styles/index.css +201 -9
- package/styles/responsive.css +27 -1
- package/styles/session-capability.css +44 -0
- package/styles/tokens.css +135 -65
- package/dist/chunk-5UQPNLIO.js.map +0 -1
- package/dist/chunk-6KLX2RH5.js.map +0 -1
- package/dist/chunk-7WCLAEFV.js.map +0 -1
- package/dist/chunk-B6WPZSTT.js.map +0 -1
- package/dist/chunk-FK6VG4LL.js +0 -90
- package/dist/chunk-FK6VG4LL.js.map +0 -1
- package/dist/chunk-HA46CYQK.js.map +0 -1
- package/dist/chunk-HUIKIDM5.js.map +0 -1
- package/dist/chunk-IGC6A2ZI.js.map +0 -1
- package/dist/chunk-KCGXPP5V.js.map +0 -1
- package/dist/chunk-KZ73RL76.js.map +0 -1
- package/dist/chunk-LAKLF4PA.js +0 -141
- package/dist/chunk-LAKLF4PA.js.map +0 -1
- package/dist/chunk-LLOLUHVG.js.map +0 -1
- package/dist/chunk-MKPIAGVL.js +0 -465
- package/dist/chunk-MKPIAGVL.js.map +0 -1
- package/dist/chunk-PEI6RANI.js.map +0 -1
- package/dist/chunk-R3AZOAB5.js.map +0 -1
- package/dist/chunk-WSK7G5LE.js +0 -170
- package/dist/chunk-WSK7G5LE.js.map +0 -1
- package/dist/chunk-XBZWOM2K.js +0 -218
- package/dist/chunk-XBZWOM2K.js.map +0 -1
- package/dist/chunk-Y7OEDUJ5.js +0 -8810
- package/dist/chunk-Y7OEDUJ5.js.map +0 -1
- package/dist/fleet-decision-row-GGCAT4E4.js.map +0 -1
- package/dist/hooks/use-packs.d.ts +0 -32
- package/dist/interactive-workbench-viewers-TOHBXJEE.js +0 -15
- package/dist/queue-surface-implementation-2KVJTYXH.js.map +0 -1
- package/dist/timeline-annotation-selection-3L7LHGG2.js +0 -187
- package/dist/timeline-annotation-selection-3L7LHGG2.js.map +0 -1
- package/dist/timeline-annotations-dialog-U7EVLR75.js +0 -196
- package/dist/timeline-annotations-dialog-U7EVLR75.js.map +0 -1
- package/src/hooks/use-packs.ts +0 -157
- /package/dist/{interactive-workbench-viewers-TOHBXJEE.js.map → browser-viewer-GTR5XQ7X.js.map} +0 -0
package/dist/accounts.js
ADDED
|
@@ -0,0 +1,822 @@
|
|
|
1
|
+
// src/accounts.tsx
|
|
2
|
+
import {
|
|
3
|
+
createContext,
|
|
4
|
+
useCallback,
|
|
5
|
+
useContext,
|
|
6
|
+
useEffect,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef,
|
|
9
|
+
useState
|
|
10
|
+
} from "react";
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
12
|
+
var BrowserAccountsContext = createContext(null);
|
|
13
|
+
var DEFAULT_CHANNEL = "opengeni:browser-account-epoch:v1";
|
|
14
|
+
var CROSS_TAB_ACTOR_HOLD_MS = 3e4;
|
|
15
|
+
async function yieldToCrossTabActorHold() {
|
|
16
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
17
|
+
}
|
|
18
|
+
function operationId() {
|
|
19
|
+
return crypto.randomUUID();
|
|
20
|
+
}
|
|
21
|
+
function sameActor(left, right) {
|
|
22
|
+
return left?.generation === right?.generation && left?.actorEpoch === right?.actorEpoch && left?.selectedSlotId === right?.selectedSlotId && left?.state === right?.state;
|
|
23
|
+
}
|
|
24
|
+
function sameSelectedActor(left, right) {
|
|
25
|
+
return left !== null && right !== null && left.actorEpoch === right.actorEpoch && left.selectedSlotId === right.selectedSlotId && left.state === right.state;
|
|
26
|
+
}
|
|
27
|
+
function compareCounter(left, right) {
|
|
28
|
+
const leftValue = BigInt(left);
|
|
29
|
+
const rightValue = BigInt(right);
|
|
30
|
+
return leftValue < rightValue ? -1 : leftValue > rightValue ? 1 : 0;
|
|
31
|
+
}
|
|
32
|
+
function isOlderProjection(candidate, current) {
|
|
33
|
+
const epoch = compareCounter(candidate.actorEpoch, current.actorEpoch);
|
|
34
|
+
return epoch < 0 || epoch === 0 && compareCounter(candidate.generation, current.generation) < 0;
|
|
35
|
+
}
|
|
36
|
+
function accountError(error) {
|
|
37
|
+
return error instanceof Error ? error : new Error("Browser account operation failed");
|
|
38
|
+
}
|
|
39
|
+
function supersededOperationError() {
|
|
40
|
+
const error = new Error("Browser account operation was superseded by an actor change");
|
|
41
|
+
error.name = "AbortError";
|
|
42
|
+
return error;
|
|
43
|
+
}
|
|
44
|
+
function errorCode(error) {
|
|
45
|
+
if (!error || typeof error !== "object") return null;
|
|
46
|
+
const code = error.code;
|
|
47
|
+
return typeof code === "string" ? code : null;
|
|
48
|
+
}
|
|
49
|
+
function needsReconciliation(error) {
|
|
50
|
+
return (/* @__PURE__ */ new Set(["actor_change_required", "generation_conflict", "operation_outcome_unknown"])).has(
|
|
51
|
+
errorCode(error) ?? ""
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
function BrowserAccountsProvider({
|
|
55
|
+
client,
|
|
56
|
+
onActorTransition,
|
|
57
|
+
children,
|
|
58
|
+
broadcastChannelName = DEFAULT_CHANNEL,
|
|
59
|
+
bootstrapLegacySession = false
|
|
60
|
+
}) {
|
|
61
|
+
const [projection, setProjection] = useState(null);
|
|
62
|
+
const [phase, setPhase] = useState("loading");
|
|
63
|
+
const [blockers, setBlockers] = useState([]);
|
|
64
|
+
const [error, setError] = useState(null);
|
|
65
|
+
const [transaction, setTransaction] = useState(null);
|
|
66
|
+
const projectionRef = useRef(projection);
|
|
67
|
+
const transactionRef = useRef(transaction);
|
|
68
|
+
const blockerInspectorsRef = useRef(/* @__PURE__ */ new Map());
|
|
69
|
+
const pendingRef = useRef(null);
|
|
70
|
+
const transactionTargetSlotIdRef = useRef(null);
|
|
71
|
+
const beginOperationRef = useRef(null);
|
|
72
|
+
const bootstrapOperationRef = useRef(null);
|
|
73
|
+
const completionOperationRef = useRef(null);
|
|
74
|
+
const cancelOperationRef = useRef(null);
|
|
75
|
+
const pendingCommitSequenceRef = useRef(null);
|
|
76
|
+
const pendingServerMutationSequenceRef = useRef(null);
|
|
77
|
+
const invalidatedDuringPendingCommitRef = useRef(false);
|
|
78
|
+
const sequenceRef = useRef(0);
|
|
79
|
+
const transitionAbortRef = useRef(null);
|
|
80
|
+
const channelRef = useRef(null);
|
|
81
|
+
const crossTabActorHoldsRef = useRef(/* @__PURE__ */ new Map());
|
|
82
|
+
projectionRef.current = projection;
|
|
83
|
+
transactionRef.current = transaction;
|
|
84
|
+
const inspectBlockers = useCallback(() => {
|
|
85
|
+
const current = [...blockerInspectorsRef.current.entries()].map(([id, inspect]) => {
|
|
86
|
+
const blocker = inspect();
|
|
87
|
+
return blocker ? { ...blocker, id } : null;
|
|
88
|
+
}).filter((value2) => value2 !== null).sort((left, right) => left.id.localeCompare(right.id));
|
|
89
|
+
setBlockers(current);
|
|
90
|
+
return current;
|
|
91
|
+
}, []);
|
|
92
|
+
const publishActorHint = useCallback((next) => {
|
|
93
|
+
if (!next) return;
|
|
94
|
+
channelRef.current?.postMessage({
|
|
95
|
+
type: "actor-epoch-changed",
|
|
96
|
+
generation: next.generation,
|
|
97
|
+
actorEpoch: next.actorEpoch
|
|
98
|
+
});
|
|
99
|
+
}, []);
|
|
100
|
+
const publishActorHold = useCallback(
|
|
101
|
+
(transitionId, current) => {
|
|
102
|
+
channelRef.current?.postMessage({
|
|
103
|
+
type: "actor-transition-pending",
|
|
104
|
+
transitionId,
|
|
105
|
+
generation: current.generation,
|
|
106
|
+
actorEpoch: current.actorEpoch
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
[]
|
|
110
|
+
);
|
|
111
|
+
const publishActorRelease = useCallback((transitionId) => {
|
|
112
|
+
channelRef.current?.postMessage({
|
|
113
|
+
type: "actor-transition-released",
|
|
114
|
+
transitionId
|
|
115
|
+
});
|
|
116
|
+
}, []);
|
|
117
|
+
const clearLoginTransactionState = useCallback(() => {
|
|
118
|
+
transactionRef.current = null;
|
|
119
|
+
beginOperationRef.current = null;
|
|
120
|
+
completionOperationRef.current = null;
|
|
121
|
+
cancelOperationRef.current = null;
|
|
122
|
+
transactionTargetSlotIdRef.current = null;
|
|
123
|
+
setTransaction(null);
|
|
124
|
+
}, []);
|
|
125
|
+
const settleActorTransition = useCallback(
|
|
126
|
+
async (kind, from, accepted, sequence, publish, authorityResetConfirmed = false, initiatingSurfaceFenced = false) => {
|
|
127
|
+
let source = from;
|
|
128
|
+
let target = accepted;
|
|
129
|
+
if (!authorityResetConfirmed && from && target && isOlderProjection(target, from)) {
|
|
130
|
+
target = await client.getSessionSet();
|
|
131
|
+
if (sequenceRef.current !== sequence) return null;
|
|
132
|
+
if (isOlderProjection(target, from)) {
|
|
133
|
+
throw new Error("Browser account response regressed the accepted actor epoch");
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (!initiatingSurfaceFenced && sameSelectedActor(source, target)) {
|
|
137
|
+
setProjection(target);
|
|
138
|
+
setPhase("ready");
|
|
139
|
+
setError(null);
|
|
140
|
+
return target;
|
|
141
|
+
}
|
|
142
|
+
while (true) {
|
|
143
|
+
transitionAbortRef.current?.abort();
|
|
144
|
+
const controller = new AbortController();
|
|
145
|
+
transitionAbortRef.current = controller;
|
|
146
|
+
if (publish) publishActorHint(target);
|
|
147
|
+
setPhase("loading");
|
|
148
|
+
await onActorTransition({
|
|
149
|
+
kind,
|
|
150
|
+
from: initiatingSurfaceFenced ? null : source,
|
|
151
|
+
to: target,
|
|
152
|
+
signal: controller.signal
|
|
153
|
+
});
|
|
154
|
+
initiatingSurfaceFenced = false;
|
|
155
|
+
if (controller.signal.aborted || sequenceRef.current !== sequence) return null;
|
|
156
|
+
if (!target) {
|
|
157
|
+
setProjection(null);
|
|
158
|
+
setPhase("ready");
|
|
159
|
+
setError(null);
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
const confirmed = await client.reconcileSessionSetAuthority();
|
|
163
|
+
if (controller.signal.aborted || sequenceRef.current !== sequence) return null;
|
|
164
|
+
if (sameActor(target, confirmed) || sameSelectedActor(target, confirmed)) {
|
|
165
|
+
setProjection(confirmed);
|
|
166
|
+
setPhase("ready");
|
|
167
|
+
setError(null);
|
|
168
|
+
return confirmed;
|
|
169
|
+
}
|
|
170
|
+
source = target;
|
|
171
|
+
target = confirmed;
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
[client, onActorTransition, publishActorHint]
|
|
175
|
+
);
|
|
176
|
+
const reconcile = useCallback(
|
|
177
|
+
async (kind, publish = false) => {
|
|
178
|
+
const sequence = ++sequenceRef.current;
|
|
179
|
+
const before = projectionRef.current;
|
|
180
|
+
setPhase("loading");
|
|
181
|
+
let first = await client.reconcileSessionSetAuthority();
|
|
182
|
+
if (sequenceRef.current !== sequence) return null;
|
|
183
|
+
if (bootstrapLegacySession && first.mode === "dual" && first.selectedSlotId === null && first.slots.length === 0) {
|
|
184
|
+
const bootstrapOperation = bootstrapOperationRef.current?.generation === first.generation ? bootstrapOperationRef.current.operationId : operationId();
|
|
185
|
+
bootstrapOperationRef.current = {
|
|
186
|
+
generation: first.generation,
|
|
187
|
+
operationId: bootstrapOperation
|
|
188
|
+
};
|
|
189
|
+
try {
|
|
190
|
+
first = await client.bootstrapSessionSet({
|
|
191
|
+
operationId: bootstrapOperation,
|
|
192
|
+
expectedGeneration: first.generation
|
|
193
|
+
});
|
|
194
|
+
bootstrapOperationRef.current = null;
|
|
195
|
+
} catch (caught) {
|
|
196
|
+
if (!needsReconciliation(caught)) throw caught;
|
|
197
|
+
const reconciled = await client.getSessionSet();
|
|
198
|
+
if (sequenceRef.current !== sequence) return null;
|
|
199
|
+
if (reconciled.selectedSlotId === null || reconciled.slots.length === 0) throw caught;
|
|
200
|
+
first = reconciled;
|
|
201
|
+
bootstrapOperationRef.current = null;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (sameActor(before, first) || sameSelectedActor(before, first)) {
|
|
205
|
+
setProjection(first);
|
|
206
|
+
setPhase("ready");
|
|
207
|
+
setError(null);
|
|
208
|
+
return first;
|
|
209
|
+
}
|
|
210
|
+
if (kind === "cross_tab") clearLoginTransactionState();
|
|
211
|
+
return await settleActorTransition(kind, before, first, sequence, publish, true);
|
|
212
|
+
},
|
|
213
|
+
[bootstrapLegacySession, clearLoginTransactionState, client, settleActorTransition]
|
|
214
|
+
);
|
|
215
|
+
const fail = useCallback(
|
|
216
|
+
async (caught, kind) => {
|
|
217
|
+
const nextError = accountError(caught);
|
|
218
|
+
if (needsReconciliation(caught)) {
|
|
219
|
+
try {
|
|
220
|
+
await reconcile(kind);
|
|
221
|
+
} catch {
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
setError(nextError);
|
|
225
|
+
setPhase("recoverable_error");
|
|
226
|
+
throw nextError;
|
|
227
|
+
},
|
|
228
|
+
[reconcile]
|
|
229
|
+
);
|
|
230
|
+
const executePending = useCallback(
|
|
231
|
+
async (pending) => {
|
|
232
|
+
const blocked = inspectBlockers();
|
|
233
|
+
if (blocked.length > 0) {
|
|
234
|
+
pendingRef.current = pending;
|
|
235
|
+
setPhase("blocked");
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
const current = projectionRef.current;
|
|
239
|
+
if (!current) throw new Error("Browser session set is not loaded");
|
|
240
|
+
const expectedGeneration = pending.expectedGeneration ?? current.generation;
|
|
241
|
+
pending.expectedGeneration = expectedGeneration;
|
|
242
|
+
const sequence = ++sequenceRef.current;
|
|
243
|
+
pendingCommitSequenceRef.current = sequence;
|
|
244
|
+
pendingServerMutationSequenceRef.current = null;
|
|
245
|
+
invalidatedDuringPendingCommitRef.current = false;
|
|
246
|
+
pendingRef.current = pending;
|
|
247
|
+
setPhase("committing");
|
|
248
|
+
setError(null);
|
|
249
|
+
const changesActor = pending.changesActor(current);
|
|
250
|
+
let initiatingActorFenced = false;
|
|
251
|
+
try {
|
|
252
|
+
if (changesActor) {
|
|
253
|
+
publishActorHold(pending.operationId, current);
|
|
254
|
+
transitionAbortRef.current?.abort();
|
|
255
|
+
const controller = new AbortController();
|
|
256
|
+
transitionAbortRef.current = controller;
|
|
257
|
+
projectionRef.current = null;
|
|
258
|
+
setProjection(null);
|
|
259
|
+
setPhase("loading");
|
|
260
|
+
initiatingActorFenced = true;
|
|
261
|
+
await onActorTransition({
|
|
262
|
+
kind: pending.kind,
|
|
263
|
+
from: current,
|
|
264
|
+
to: null,
|
|
265
|
+
signal: controller.signal
|
|
266
|
+
});
|
|
267
|
+
if (controller.signal.aborted || sequenceRef.current !== sequence) return false;
|
|
268
|
+
await yieldToCrossTabActorHold();
|
|
269
|
+
if (controller.signal.aborted || sequenceRef.current !== sequence) return false;
|
|
270
|
+
}
|
|
271
|
+
pendingServerMutationSequenceRef.current = sequence;
|
|
272
|
+
let accepted;
|
|
273
|
+
try {
|
|
274
|
+
accepted = await pending.execute(expectedGeneration);
|
|
275
|
+
} catch (caught) {
|
|
276
|
+
if (errorCode(caught) !== "operation_outcome_unknown") throw caught;
|
|
277
|
+
accepted = await pending.execute(expectedGeneration);
|
|
278
|
+
}
|
|
279
|
+
if (sequenceRef.current !== sequence) return false;
|
|
280
|
+
let authorityResetConfirmed = pending.kind === "logout_all";
|
|
281
|
+
if (invalidatedDuringPendingCommitRef.current) {
|
|
282
|
+
accepted = await client.reconcileSessionSetAuthority();
|
|
283
|
+
authorityResetConfirmed = true;
|
|
284
|
+
if (sequenceRef.current !== sequence) return false;
|
|
285
|
+
}
|
|
286
|
+
pendingRef.current = null;
|
|
287
|
+
if (pendingServerMutationSequenceRef.current === sequence) {
|
|
288
|
+
pendingServerMutationSequenceRef.current = null;
|
|
289
|
+
}
|
|
290
|
+
if (pendingCommitSequenceRef.current === sequence) {
|
|
291
|
+
pendingCommitSequenceRef.current = null;
|
|
292
|
+
invalidatedDuringPendingCommitRef.current = false;
|
|
293
|
+
}
|
|
294
|
+
if (!initiatingActorFenced && !authorityResetConfirmed && sameSelectedActor(current, accepted)) {
|
|
295
|
+
setProjection(accepted);
|
|
296
|
+
setPhase("ready");
|
|
297
|
+
setError(null);
|
|
298
|
+
} else {
|
|
299
|
+
await settleActorTransition(
|
|
300
|
+
pending.kind,
|
|
301
|
+
current,
|
|
302
|
+
accepted,
|
|
303
|
+
sequence,
|
|
304
|
+
true,
|
|
305
|
+
authorityResetConfirmed,
|
|
306
|
+
initiatingActorFenced
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
return true;
|
|
310
|
+
} catch (caught) {
|
|
311
|
+
if (initiatingActorFenced) {
|
|
312
|
+
let authorityRestored = false;
|
|
313
|
+
try {
|
|
314
|
+
const restored = await client.reconcileSessionSetAuthority();
|
|
315
|
+
if (sequenceRef.current !== sequence) return false;
|
|
316
|
+
await settleActorTransition(
|
|
317
|
+
pending.kind,
|
|
318
|
+
current,
|
|
319
|
+
restored,
|
|
320
|
+
sequence,
|
|
321
|
+
false,
|
|
322
|
+
true,
|
|
323
|
+
true
|
|
324
|
+
);
|
|
325
|
+
if (sequenceRef.current !== sequence) return false;
|
|
326
|
+
authorityRestored = true;
|
|
327
|
+
} catch {
|
|
328
|
+
}
|
|
329
|
+
if (authorityRestored) {
|
|
330
|
+
const restoredError = accountError(caught);
|
|
331
|
+
setError(restoredError);
|
|
332
|
+
setPhase("recoverable_error");
|
|
333
|
+
throw restoredError;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return await fail(caught, pending.kind);
|
|
337
|
+
} finally {
|
|
338
|
+
if (changesActor) publishActorRelease(pending.operationId);
|
|
339
|
+
if (pendingServerMutationSequenceRef.current === sequence) {
|
|
340
|
+
pendingServerMutationSequenceRef.current = null;
|
|
341
|
+
}
|
|
342
|
+
if (pendingCommitSequenceRef.current === sequence) {
|
|
343
|
+
pendingCommitSequenceRef.current = null;
|
|
344
|
+
invalidatedDuringPendingCommitRef.current = false;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
[
|
|
349
|
+
client,
|
|
350
|
+
fail,
|
|
351
|
+
inspectBlockers,
|
|
352
|
+
onActorTransition,
|
|
353
|
+
publishActorHold,
|
|
354
|
+
publishActorRelease,
|
|
355
|
+
settleActorTransition
|
|
356
|
+
]
|
|
357
|
+
);
|
|
358
|
+
const refresh = useCallback(async () => {
|
|
359
|
+
try {
|
|
360
|
+
return await reconcile("cross_tab");
|
|
361
|
+
} catch (caught) {
|
|
362
|
+
const nextError = accountError(caught);
|
|
363
|
+
setError(nextError);
|
|
364
|
+
setPhase("recoverable_error");
|
|
365
|
+
throw nextError;
|
|
366
|
+
}
|
|
367
|
+
}, [reconcile]);
|
|
368
|
+
const beginNeutralActorInvalidation = useCallback(
|
|
369
|
+
async (before) => {
|
|
370
|
+
transitionAbortRef.current?.abort();
|
|
371
|
+
const controller = new AbortController();
|
|
372
|
+
transitionAbortRef.current = controller;
|
|
373
|
+
projectionRef.current = null;
|
|
374
|
+
setProjection(null);
|
|
375
|
+
clearLoginTransactionState();
|
|
376
|
+
setPhase("loading");
|
|
377
|
+
setError(null);
|
|
378
|
+
await onActorTransition({
|
|
379
|
+
kind: "cross_tab",
|
|
380
|
+
from: before,
|
|
381
|
+
to: null,
|
|
382
|
+
signal: controller.signal
|
|
383
|
+
});
|
|
384
|
+
return controller;
|
|
385
|
+
},
|
|
386
|
+
[clearLoginTransactionState, onActorTransition]
|
|
387
|
+
);
|
|
388
|
+
const invalidateActor = useCallback(async () => {
|
|
389
|
+
const pendingCommitSequence = pendingCommitSequenceRef.current;
|
|
390
|
+
if (pendingCommitSequence !== null && pendingServerMutationSequenceRef.current === pendingCommitSequence) {
|
|
391
|
+
invalidatedDuringPendingCommitRef.current = true;
|
|
392
|
+
await beginNeutralActorInvalidation(projectionRef.current);
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
if (pendingCommitSequence !== null) {
|
|
396
|
+
pendingCommitSequenceRef.current = null;
|
|
397
|
+
pendingServerMutationSequenceRef.current = null;
|
|
398
|
+
invalidatedDuringPendingCommitRef.current = false;
|
|
399
|
+
pendingRef.current = null;
|
|
400
|
+
}
|
|
401
|
+
const sequence = ++sequenceRef.current;
|
|
402
|
+
const before = projectionRef.current;
|
|
403
|
+
try {
|
|
404
|
+
const neutral = await beginNeutralActorInvalidation(before);
|
|
405
|
+
if (neutral.signal.aborted || sequenceRef.current !== sequence) return null;
|
|
406
|
+
const accepted = await client.reconcileSessionSetAuthority();
|
|
407
|
+
if (sequenceRef.current !== sequence) return null;
|
|
408
|
+
return await settleActorTransition("cross_tab", before, accepted, sequence, false, true);
|
|
409
|
+
} catch (caught) {
|
|
410
|
+
if (sequenceRef.current !== sequence) return null;
|
|
411
|
+
const nextError = accountError(caught);
|
|
412
|
+
setError(nextError);
|
|
413
|
+
setPhase("recoverable_error");
|
|
414
|
+
throw nextError;
|
|
415
|
+
}
|
|
416
|
+
}, [beginNeutralActorInvalidation, client, settleActorTransition]);
|
|
417
|
+
const registerTransitionBlocker = useCallback((id, inspect) => {
|
|
418
|
+
if (!id.trim()) throw new Error("Browser account transition blocker id is required");
|
|
419
|
+
blockerInspectorsRef.current.set(id, inspect);
|
|
420
|
+
return () => {
|
|
421
|
+
if (blockerInspectorsRef.current.get(id) === inspect) {
|
|
422
|
+
blockerInspectorsRef.current.delete(id);
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
}, []);
|
|
426
|
+
const continueTransition = useCallback(async () => {
|
|
427
|
+
const pending = pendingRef.current;
|
|
428
|
+
return pending ? await executePending(pending) : false;
|
|
429
|
+
}, [executePending]);
|
|
430
|
+
const cancelPendingTransition = useCallback(() => {
|
|
431
|
+
pendingRef.current = null;
|
|
432
|
+
setBlockers([]);
|
|
433
|
+
setPhase(projectionRef.current ? "ready" : "loading");
|
|
434
|
+
}, []);
|
|
435
|
+
const beginLogin = useCallback(
|
|
436
|
+
async (kind, slotId, returnIntent) => {
|
|
437
|
+
const current = projectionRef.current;
|
|
438
|
+
if (!current) throw new Error("Browser session set is not loaded");
|
|
439
|
+
if (kind === "reauth" && slotId === current.selectedSlotId && inspectBlockers().length > 0) {
|
|
440
|
+
setPhase("blocked");
|
|
441
|
+
throw new Error("Settle account transition blockers before re-authenticating");
|
|
442
|
+
}
|
|
443
|
+
const sequence = ++sequenceRef.current;
|
|
444
|
+
setPhase("committing");
|
|
445
|
+
setError(null);
|
|
446
|
+
const signature = JSON.stringify([
|
|
447
|
+
kind,
|
|
448
|
+
slotId ?? null,
|
|
449
|
+
returnIntent ?? null,
|
|
450
|
+
current.generation
|
|
451
|
+
]);
|
|
452
|
+
const beginOperation = beginOperationRef.current?.signature === signature ? beginOperationRef.current.operationId : operationId();
|
|
453
|
+
beginOperationRef.current = { signature, operationId: beginOperation };
|
|
454
|
+
let next;
|
|
455
|
+
try {
|
|
456
|
+
next = await client.beginLoginTransaction({
|
|
457
|
+
operationId: beginOperation,
|
|
458
|
+
expectedGeneration: current.generation,
|
|
459
|
+
kind,
|
|
460
|
+
...slotId ? { slotId } : {},
|
|
461
|
+
...returnIntent ? { returnIntent } : {}
|
|
462
|
+
});
|
|
463
|
+
} catch (caught) {
|
|
464
|
+
if (sequenceRef.current !== sequence) {
|
|
465
|
+
if (beginOperationRef.current?.operationId === beginOperation) {
|
|
466
|
+
beginOperationRef.current = null;
|
|
467
|
+
}
|
|
468
|
+
throw supersededOperationError();
|
|
469
|
+
}
|
|
470
|
+
return await fail(caught, kind);
|
|
471
|
+
}
|
|
472
|
+
if (sequenceRef.current !== sequence) {
|
|
473
|
+
if (beginOperationRef.current?.operationId === beginOperation) {
|
|
474
|
+
beginOperationRef.current = null;
|
|
475
|
+
}
|
|
476
|
+
throw supersededOperationError();
|
|
477
|
+
}
|
|
478
|
+
beginOperationRef.current = null;
|
|
479
|
+
transactionTargetSlotIdRef.current = slotId ?? null;
|
|
480
|
+
completionOperationRef.current = null;
|
|
481
|
+
cancelOperationRef.current = null;
|
|
482
|
+
setTransaction(next);
|
|
483
|
+
setPhase("ready");
|
|
484
|
+
return next;
|
|
485
|
+
},
|
|
486
|
+
[client, fail, inspectBlockers]
|
|
487
|
+
);
|
|
488
|
+
const beginAdd = useCallback(
|
|
489
|
+
async (returnIntent) => await beginLogin("add", void 0, returnIntent),
|
|
490
|
+
[beginLogin]
|
|
491
|
+
);
|
|
492
|
+
const beginReauth = useCallback(
|
|
493
|
+
async (slotId, returnIntent) => await beginLogin("reauth", slotId, returnIntent),
|
|
494
|
+
[beginLogin]
|
|
495
|
+
);
|
|
496
|
+
const completeEmailPassword = useCallback(
|
|
497
|
+
async (input) => {
|
|
498
|
+
const current = projectionRef.current;
|
|
499
|
+
const activeTransaction = transactionRef.current;
|
|
500
|
+
if (!current || !activeTransaction) throw new Error("No browser login transaction is active");
|
|
501
|
+
const selectedReauth = activeTransaction.kind === "reauth" && transactionTargetSlotIdRef.current !== null && transactionTargetSlotIdRef.current === current.selectedSlotId;
|
|
502
|
+
if (selectedReauth && inspectBlockers().length > 0) {
|
|
503
|
+
setPhase("blocked");
|
|
504
|
+
return false;
|
|
505
|
+
}
|
|
506
|
+
const sequence = ++sequenceRef.current;
|
|
507
|
+
setPhase("committing");
|
|
508
|
+
setError(null);
|
|
509
|
+
const completionOperation = completionOperationRef.current ?? {
|
|
510
|
+
operationId: operationId(),
|
|
511
|
+
expectedGeneration: current.generation
|
|
512
|
+
};
|
|
513
|
+
completionOperationRef.current = completionOperation;
|
|
514
|
+
try {
|
|
515
|
+
const completed = await client.completeEmailPasswordTransaction({
|
|
516
|
+
operationId: completionOperation.operationId,
|
|
517
|
+
expectedGeneration: completionOperation.expectedGeneration,
|
|
518
|
+
transactionId: activeTransaction.id,
|
|
519
|
+
email: input.email,
|
|
520
|
+
password: input.password
|
|
521
|
+
});
|
|
522
|
+
if (sequenceRef.current !== sequence) return false;
|
|
523
|
+
completionOperationRef.current = null;
|
|
524
|
+
cancelOperationRef.current = null;
|
|
525
|
+
transactionTargetSlotIdRef.current = null;
|
|
526
|
+
setTransaction(null);
|
|
527
|
+
const actorChanged = completed.projection.actorEpoch !== current.actorEpoch;
|
|
528
|
+
if (actorChanged) {
|
|
529
|
+
await settleActorTransition(
|
|
530
|
+
activeTransaction.kind,
|
|
531
|
+
current,
|
|
532
|
+
completed.projection,
|
|
533
|
+
sequence,
|
|
534
|
+
true
|
|
535
|
+
);
|
|
536
|
+
} else {
|
|
537
|
+
setProjection(completed.projection);
|
|
538
|
+
setPhase("ready");
|
|
539
|
+
}
|
|
540
|
+
return true;
|
|
541
|
+
} catch (caught) {
|
|
542
|
+
return await fail(caught, activeTransaction.kind);
|
|
543
|
+
}
|
|
544
|
+
},
|
|
545
|
+
[client, fail, inspectBlockers, settleActorTransition]
|
|
546
|
+
);
|
|
547
|
+
const settleExternalLoginTransaction = useCallback(
|
|
548
|
+
async (transactionId) => {
|
|
549
|
+
const activeTransaction = transactionRef.current;
|
|
550
|
+
if (!activeTransaction || activeTransaction.id !== transactionId) return false;
|
|
551
|
+
try {
|
|
552
|
+
await reconcile(activeTransaction.kind, true);
|
|
553
|
+
if (transactionRef.current?.id !== transactionId) return false;
|
|
554
|
+
completionOperationRef.current = null;
|
|
555
|
+
cancelOperationRef.current = null;
|
|
556
|
+
transactionTargetSlotIdRef.current = null;
|
|
557
|
+
setTransaction(null);
|
|
558
|
+
return true;
|
|
559
|
+
} catch (caught) {
|
|
560
|
+
const nextError = accountError(caught);
|
|
561
|
+
setError(nextError);
|
|
562
|
+
setPhase("recoverable_error");
|
|
563
|
+
throw nextError;
|
|
564
|
+
}
|
|
565
|
+
},
|
|
566
|
+
[reconcile]
|
|
567
|
+
);
|
|
568
|
+
const cancelLoginTransaction = useCallback(async () => {
|
|
569
|
+
const current = projectionRef.current;
|
|
570
|
+
const activeTransaction = transactionRef.current;
|
|
571
|
+
if (!current || !activeTransaction) return;
|
|
572
|
+
const sequence = ++sequenceRef.current;
|
|
573
|
+
setPhase("committing");
|
|
574
|
+
const cancelOperation = cancelOperationRef.current ?? {
|
|
575
|
+
operationId: operationId(),
|
|
576
|
+
expectedGeneration: current.generation
|
|
577
|
+
};
|
|
578
|
+
cancelOperationRef.current = cancelOperation;
|
|
579
|
+
let next;
|
|
580
|
+
try {
|
|
581
|
+
next = await client.cancelLoginTransaction({
|
|
582
|
+
operationId: cancelOperation.operationId,
|
|
583
|
+
expectedGeneration: cancelOperation.expectedGeneration,
|
|
584
|
+
transactionId: activeTransaction.id
|
|
585
|
+
});
|
|
586
|
+
} catch (caught) {
|
|
587
|
+
if (sequenceRef.current !== sequence) {
|
|
588
|
+
if (cancelOperationRef.current?.operationId === cancelOperation.operationId) {
|
|
589
|
+
cancelOperationRef.current = null;
|
|
590
|
+
}
|
|
591
|
+
throw supersededOperationError();
|
|
592
|
+
}
|
|
593
|
+
await fail(caught, activeTransaction.kind);
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
if (sequenceRef.current !== sequence) {
|
|
597
|
+
if (cancelOperationRef.current?.operationId === cancelOperation.operationId) {
|
|
598
|
+
cancelOperationRef.current = null;
|
|
599
|
+
}
|
|
600
|
+
throw supersededOperationError();
|
|
601
|
+
}
|
|
602
|
+
clearLoginTransactionState();
|
|
603
|
+
setProjection(next);
|
|
604
|
+
setPhase("ready");
|
|
605
|
+
setError(null);
|
|
606
|
+
}, [clearLoginTransactionState, client, fail]);
|
|
607
|
+
const selectSlot = useCallback(
|
|
608
|
+
async (slotId) => {
|
|
609
|
+
const id = operationId();
|
|
610
|
+
return await executePending({
|
|
611
|
+
kind: "select",
|
|
612
|
+
operationId: id,
|
|
613
|
+
expectedGeneration: null,
|
|
614
|
+
changesActor: (current) => current.selectedSlotId !== slotId,
|
|
615
|
+
execute: async (expectedGeneration) => await client.selectLoginSlot({
|
|
616
|
+
operationId: id,
|
|
617
|
+
expectedGeneration,
|
|
618
|
+
slotId
|
|
619
|
+
})
|
|
620
|
+
});
|
|
621
|
+
},
|
|
622
|
+
[client, executePending]
|
|
623
|
+
);
|
|
624
|
+
const logoutSlot = useCallback(
|
|
625
|
+
async (slotId, replacementSlotId) => {
|
|
626
|
+
const id = operationId();
|
|
627
|
+
return await executePending({
|
|
628
|
+
kind: "logout_one",
|
|
629
|
+
operationId: id,
|
|
630
|
+
expectedGeneration: null,
|
|
631
|
+
changesActor: (current) => current.selectedSlotId === slotId,
|
|
632
|
+
execute: async (expectedGeneration) => await client.logoutLoginSlot({
|
|
633
|
+
operationId: id,
|
|
634
|
+
expectedGeneration,
|
|
635
|
+
slotId,
|
|
636
|
+
replacementSlotId
|
|
637
|
+
})
|
|
638
|
+
});
|
|
639
|
+
},
|
|
640
|
+
[client, executePending]
|
|
641
|
+
);
|
|
642
|
+
const logoutAll = useCallback(async () => {
|
|
643
|
+
const id = operationId();
|
|
644
|
+
return await executePending({
|
|
645
|
+
kind: "logout_all",
|
|
646
|
+
operationId: id,
|
|
647
|
+
expectedGeneration: null,
|
|
648
|
+
// Logout-all always rotates the browser-set authority, even when the set
|
|
649
|
+
// is neutral but still contains slots. Peers must therefore enter the
|
|
650
|
+
// same precommit hold and reconciliation boundary unconditionally.
|
|
651
|
+
changesActor: () => true,
|
|
652
|
+
execute: async (expectedGeneration) => {
|
|
653
|
+
await client.logoutSessionSet({ operationId: id, expectedGeneration });
|
|
654
|
+
return await client.getSessionSet();
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
}, [client, executePending]);
|
|
658
|
+
const resolveDeepLink = useCallback(
|
|
659
|
+
async (path) => await client.resolveDeepLink({ path }),
|
|
660
|
+
[client]
|
|
661
|
+
);
|
|
662
|
+
useEffect(() => {
|
|
663
|
+
const sequence = sequenceRef;
|
|
664
|
+
const transitionAbort = transitionAbortRef;
|
|
665
|
+
void refresh().catch((caught) => {
|
|
666
|
+
setError(accountError(caught));
|
|
667
|
+
setPhase("recoverable_error");
|
|
668
|
+
});
|
|
669
|
+
return () => {
|
|
670
|
+
++sequence.current;
|
|
671
|
+
transitionAbort.current?.abort();
|
|
672
|
+
};
|
|
673
|
+
}, [client, refresh]);
|
|
674
|
+
useEffect(() => {
|
|
675
|
+
if (!broadcastChannelName || typeof BroadcastChannel === "undefined") return;
|
|
676
|
+
const channel = new BroadcastChannel(broadcastChannelName);
|
|
677
|
+
const actorHolds = crossTabActorHoldsRef.current;
|
|
678
|
+
channelRef.current = channel;
|
|
679
|
+
channel.onmessage = (event) => {
|
|
680
|
+
const value2 = event.data;
|
|
681
|
+
if (!value2 || typeof value2 !== "object") return;
|
|
682
|
+
const hint = value2;
|
|
683
|
+
if (hint.type === "actor-transition-pending") {
|
|
684
|
+
if (typeof hint.transitionId !== "string" || !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(
|
|
685
|
+
hint.transitionId
|
|
686
|
+
) || typeof hint.actorEpoch !== "string" || typeof hint.generation !== "string" || crossTabActorHoldsRef.current.has(hint.transitionId)) {
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
const current = projectionRef.current;
|
|
690
|
+
if (current && (current.actorEpoch !== hint.actorEpoch || current.generation !== hint.generation)) {
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
if (!current && crossTabActorHoldsRef.current.size === 0) return;
|
|
694
|
+
const firstHold = crossTabActorHoldsRef.current.size === 0;
|
|
695
|
+
const timeout = setTimeout(() => {
|
|
696
|
+
if (!crossTabActorHoldsRef.current.delete(hint.transitionId)) return;
|
|
697
|
+
if (crossTabActorHoldsRef.current.size === 0) {
|
|
698
|
+
void invalidateActor().catch(() => void 0);
|
|
699
|
+
}
|
|
700
|
+
}, CROSS_TAB_ACTOR_HOLD_MS);
|
|
701
|
+
crossTabActorHoldsRef.current.set(hint.transitionId, timeout);
|
|
702
|
+
if (firstHold) {
|
|
703
|
+
if (pendingCommitSequenceRef.current !== null) {
|
|
704
|
+
invalidatedDuringPendingCommitRef.current = true;
|
|
705
|
+
} else {
|
|
706
|
+
++sequenceRef.current;
|
|
707
|
+
}
|
|
708
|
+
void beginNeutralActorInvalidation(current).catch(() => void 0);
|
|
709
|
+
}
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
if (hint.type === "actor-transition-released") {
|
|
713
|
+
if (typeof hint.transitionId !== "string") return;
|
|
714
|
+
const timeout = crossTabActorHoldsRef.current.get(hint.transitionId);
|
|
715
|
+
if (timeout === void 0) return;
|
|
716
|
+
clearTimeout(timeout);
|
|
717
|
+
crossTabActorHoldsRef.current.delete(hint.transitionId);
|
|
718
|
+
if (crossTabActorHoldsRef.current.size === 0) {
|
|
719
|
+
void invalidateActor().catch(() => void 0);
|
|
720
|
+
}
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
if (hint.type !== "actor-epoch-changed" || typeof hint.actorEpoch !== "string" || typeof hint.generation !== "string" || hint.actorEpoch === projectionRef.current?.actorEpoch && hint.generation === projectionRef.current?.generation) {
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
for (const timeout of crossTabActorHoldsRef.current.values()) clearTimeout(timeout);
|
|
727
|
+
crossTabActorHoldsRef.current.clear();
|
|
728
|
+
void invalidateActor().catch(() => void 0);
|
|
729
|
+
};
|
|
730
|
+
return () => {
|
|
731
|
+
for (const timeout of actorHolds.values()) clearTimeout(timeout);
|
|
732
|
+
actorHolds.clear();
|
|
733
|
+
channel.close();
|
|
734
|
+
if (channelRef.current === channel) channelRef.current = null;
|
|
735
|
+
};
|
|
736
|
+
}, [beginNeutralActorInvalidation, broadcastChannelName, invalidateActor]);
|
|
737
|
+
const value = useMemo(
|
|
738
|
+
() => ({
|
|
739
|
+
projection,
|
|
740
|
+
phase,
|
|
741
|
+
blockers,
|
|
742
|
+
error,
|
|
743
|
+
transaction,
|
|
744
|
+
hasPendingTransition: pendingRef.current !== null,
|
|
745
|
+
refresh,
|
|
746
|
+
invalidateActor,
|
|
747
|
+
registerTransitionBlocker,
|
|
748
|
+
continueTransition,
|
|
749
|
+
cancelPendingTransition,
|
|
750
|
+
beginAdd,
|
|
751
|
+
beginReauth,
|
|
752
|
+
completeEmailPassword,
|
|
753
|
+
settleExternalLoginTransaction,
|
|
754
|
+
cancelLoginTransaction,
|
|
755
|
+
selectSlot,
|
|
756
|
+
logoutSlot,
|
|
757
|
+
logoutAll,
|
|
758
|
+
resolveDeepLink
|
|
759
|
+
}),
|
|
760
|
+
[
|
|
761
|
+
projection,
|
|
762
|
+
phase,
|
|
763
|
+
blockers,
|
|
764
|
+
error,
|
|
765
|
+
transaction,
|
|
766
|
+
refresh,
|
|
767
|
+
invalidateActor,
|
|
768
|
+
registerTransitionBlocker,
|
|
769
|
+
continueTransition,
|
|
770
|
+
cancelPendingTransition,
|
|
771
|
+
beginAdd,
|
|
772
|
+
beginReauth,
|
|
773
|
+
completeEmailPassword,
|
|
774
|
+
settleExternalLoginTransaction,
|
|
775
|
+
cancelLoginTransaction,
|
|
776
|
+
selectSlot,
|
|
777
|
+
logoutSlot,
|
|
778
|
+
logoutAll,
|
|
779
|
+
resolveDeepLink
|
|
780
|
+
]
|
|
781
|
+
);
|
|
782
|
+
return /* @__PURE__ */ jsx(BrowserAccountsContext.Provider, { value, children });
|
|
783
|
+
}
|
|
784
|
+
function useBrowserAccounts() {
|
|
785
|
+
const context = useContext(BrowserAccountsContext);
|
|
786
|
+
if (!context) {
|
|
787
|
+
throw new Error(
|
|
788
|
+
"@opengeni/react/accounts: wrap the tree in <BrowserAccountsProvider> before using account hooks"
|
|
789
|
+
);
|
|
790
|
+
}
|
|
791
|
+
return context;
|
|
792
|
+
}
|
|
793
|
+
function useOptionalBrowserAccounts() {
|
|
794
|
+
return useContext(BrowserAccountsContext);
|
|
795
|
+
}
|
|
796
|
+
function useBrowserAccountTransitionBlocker(id, inspect) {
|
|
797
|
+
const { registerTransitionBlocker } = useBrowserAccounts();
|
|
798
|
+
const inspectRef = useRef(inspect);
|
|
799
|
+
inspectRef.current = inspect;
|
|
800
|
+
useEffect(
|
|
801
|
+
() => registerTransitionBlocker(id, () => inspectRef.current()),
|
|
802
|
+
[id, registerTransitionBlocker]
|
|
803
|
+
);
|
|
804
|
+
}
|
|
805
|
+
function useOptionalBrowserAccountTransitionBlocker(id, inspect) {
|
|
806
|
+
const context = useContext(BrowserAccountsContext);
|
|
807
|
+
const registerTransitionBlocker = context?.registerTransitionBlocker;
|
|
808
|
+
const inspectRef = useRef(inspect);
|
|
809
|
+
inspectRef.current = inspect;
|
|
810
|
+
useEffect(() => {
|
|
811
|
+
if (!registerTransitionBlocker) return;
|
|
812
|
+
return registerTransitionBlocker(id, () => inspectRef.current());
|
|
813
|
+
}, [id, registerTransitionBlocker]);
|
|
814
|
+
}
|
|
815
|
+
export {
|
|
816
|
+
BrowserAccountsProvider,
|
|
817
|
+
useBrowserAccountTransitionBlocker,
|
|
818
|
+
useBrowserAccounts,
|
|
819
|
+
useOptionalBrowserAccountTransitionBlocker,
|
|
820
|
+
useOptionalBrowserAccounts
|
|
821
|
+
};
|
|
822
|
+
//# sourceMappingURL=accounts.js.map
|