@jini-ai/ui 0.7.3-next.1 → 0.7.3-next.3
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/CHANGELOG.md +9 -0
- package/README.md +3 -3
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.js +2 -0
- package/dist/browser/mount-renderer.d.ts +33 -0
- package/dist/browser/mount-renderer.js +14 -0
- package/dist/browser/useDismissibleDropdown.d.ts +50 -0
- package/dist/browser/useDismissibleDropdown.js +49 -0
- package/dist/core.d.ts +4 -4
- package/dist/core.js +4 -1
- package/dist/features/admin-widgets/components/InfoTip.js +5 -5
- package/dist/features/admin-widgets/components/InfoTip.rules.d.ts +1 -1
- package/dist/features/admin-widgets/components/InfoTip.rules.js +1 -1
- package/dist/features/admin-widgets/components/SeeMore/SeeMore.js +3 -3
- package/dist/features/admin-widgets/components/Select/Select.js +7 -7
- package/dist/features/app-shell/SiteToast.d.ts +24 -0
- package/dist/features/app-shell/SiteToast.js +9 -0
- package/dist/features/app-shell/copyable-details.d.ts +12 -0
- package/dist/features/app-shell/copyable-details.js +17 -0
- package/dist/features/app-shell/expanded-mode.d.ts +76 -0
- package/dist/features/app-shell/expanded-mode.js +70 -0
- package/dist/features/app-shell/index.d.ts +8 -0
- package/dist/features/app-shell/index.js +8 -0
- package/dist/features/app-shell/use-delete-confirmation.hooks.d.ts +48 -0
- package/dist/features/app-shell/use-delete-confirmation.hooks.js +57 -0
- package/dist/features/app-shell/use-expanded-mode.hooks.d.ts +19 -0
- package/dist/features/app-shell/use-expanded-mode.hooks.js +39 -0
- package/dist/features/app-shell/use-site-toast.hooks.d.ts +56 -0
- package/dist/features/app-shell/use-site-toast.hooks.js +44 -0
- package/dist/features/app-shell/use-theme-preference.hooks.d.ts +30 -0
- package/dist/features/app-shell/use-theme-preference.hooks.js +42 -0
- package/dist/features/app-version/use-app-version.d.ts +53 -0
- package/dist/features/app-version/use-app-version.js +42 -0
- package/dist/features/asset-grid/react/components/AssetGrid.d.ts +1 -1
- package/dist/features/asset-grid/react/components/AssetGrid.js +1 -1
- package/dist/features/asset-grid/react/components/DeleteConfirmDialog.d.ts +1 -1
- package/dist/features/asset-grid/react/components/DeleteConfirmDialog.js +1 -1
- package/dist/features/asset-tree-browser/react/components/AssetTreeBrowser.d.ts +2 -2
- package/dist/features/asset-tree-browser/react/components/AssetTreeBrowser.js +1 -1
- package/dist/features/asset-tree-browser/react/components/FilePreviewPane.d.ts +1 -1
- package/dist/features/browser-chrome/react/components/BrowserViewportControls.d.ts +1 -1
- package/dist/features/browser-chrome/react/components/BrowserViewportControls.js +1 -1
- package/dist/features/charts/catalog-manifests.js +1 -1
- package/dist/features/charts/contract.d.ts +1 -1
- package/dist/features/charts/contract.js +1 -1
- package/dist/features/charts/registry.js +1 -1
- package/dist/features/charts/table.js +4 -4
- package/dist/features/charts/wire.d.ts +1 -1
- package/dist/features/charts/wire.js +1 -1
- package/dist/features/command-palette/index.d.ts +1 -0
- package/dist/features/command-palette/index.js +1 -0
- package/dist/features/command-palette/react/components/CommandPalette.d.ts +9 -9
- package/dist/features/command-palette/react/components/CommandPalette.hooks.js +28 -1
- package/dist/features/command-palette/react/components/CommandPalette.js +3 -5
- package/dist/features/connectors/ConnectorsBrowser.d.ts +1 -1
- package/dist/features/connectors/ConnectorsBrowser.js +2 -2
- package/dist/features/connectors/components/ConnectorCard.hooks.js +2 -2
- package/dist/features/connectors/components/ConnectorCard.js +4 -4
- package/dist/features/connectors/components/ConnectorDetailDrawer.d.ts +1 -1
- package/dist/features/connectors/components/ConnectorDetailDrawer.js +7 -7
- package/dist/features/connectors/components/ConnectorGrid.js +1 -1
- package/dist/features/connectors/components/ConnectorLogo.js +1 -1
- package/dist/features/connectors/components/ConnectorSearchBar.js +1 -1
- package/dist/features/connectors/components/ProviderTabBar.js +1 -1
- package/dist/features/execution/claude/env-fields.d.ts +1 -1
- package/dist/features/execution/codex/env-fields.d.ts +1 -1
- package/dist/features/execution/constants.d.ts +2 -2
- package/dist/features/execution/constants.js +1 -1
- package/dist/features/execution/dependencies.d.ts +2 -3
- package/dist/features/execution/http-adapter.d.ts +2 -3
- package/dist/features/execution/index.d.ts +0 -2
- package/dist/features/execution/react/components/AgentCliEnvFields.d.ts +1 -1
- package/dist/features/execution/react/components/AgentDiagnosticRow.d.ts +1 -1
- package/dist/features/execution/react/components/AgentDiagnosticRow.js +3 -1
- package/dist/features/execution/react/components/ByokProviderForm.d.ts +10 -2
- package/dist/features/execution/react/components/ByokProviderForm.hooks.d.ts +2 -2
- package/dist/features/execution/react/components/ByokProviderForm.js +15 -4
- package/dist/features/execution/react/components/ExecutionTab.d.ts +2 -3
- package/dist/features/execution/react/components/ExecutionTab.hooks.d.ts +14 -4
- package/dist/features/execution/react/components/ExecutionTab.hooks.js +66 -9
- package/dist/features/execution/react/components/ExecutionTab.js +27 -10
- package/dist/features/execution/react/components/LocalCliAgentCard.d.ts +4 -4
- package/dist/features/execution/react/components/LocalCliAgentList.d.ts +4 -4
- package/dist/features/execution/react/components/LocalCliAgentList.hooks.d.ts +3 -3
- package/dist/features/execution/react/components/LocalCliAgentSettings.d.ts +2 -2
- package/dist/features/execution/react/components/ProviderChipGroup.d.ts +1 -1
- package/dist/features/execution/react/components/SearchableModelSelect.d.ts +1 -1
- package/dist/features/execution/react/hooks/use-byok-field-validation.hooks.d.ts +2 -2
- package/dist/features/execution/react/hooks/use-execution-credential.hooks.d.ts +1 -1
- package/dist/features/execution/react/hooks/useExecutionTab.d.ts +2 -3
- package/dist/features/execution/react/hooks/useLocalCliAgentCard.d.ts +4 -4
- package/dist/features/execution/react/hooks/useLocalCliAgentList.d.ts +4 -4
- package/dist/features/execution/react/hooks/useReasoningControl.d.ts +3 -3
- package/dist/features/execution/rules.d.ts +6 -6
- package/dist/features/execution/rules.js +1 -1
- package/dist/features/external-mcp/react/components/ExternalMcpTab.js +4 -4
- package/dist/features/file-dropzone/react/components/FileDropzone.d.ts +1 -1
- package/dist/features/file-dropzone/react/components/FileDropzone.js +1 -1
- package/dist/features/find/find-bar-state.d.ts +58 -0
- package/dist/features/find/find-bar-state.js +45 -0
- package/dist/features/find/find-focus-clock.d.ts +19 -0
- package/dist/features/find/find-focus-clock.js +9 -0
- package/dist/features/find/find-input-focus.d.ts +88 -0
- package/dist/features/find/find-input-focus.js +88 -0
- package/dist/features/find/find-target.d.ts +141 -0
- package/dist/features/find/find-target.js +160 -0
- package/dist/features/find/index.d.ts +10 -0
- package/dist/features/find/index.js +10 -0
- package/dist/features/find/use-find-bar-effects.hooks.d.ts +14 -0
- package/dist/features/find/use-find-bar-effects.hooks.js +92 -0
- package/dist/features/find/use-find-bar-state.hooks.d.ts +43 -0
- package/dist/features/find/use-find-bar-state.hooks.js +49 -0
- package/dist/features/find/use-find-focus-reclaim.hooks.d.ts +21 -0
- package/dist/features/find/use-find-focus-reclaim.hooks.js +64 -0
- package/dist/features/find/use-find-input-binding.hooks.d.ts +18 -0
- package/dist/features/find/use-find-input-binding.hooks.js +76 -0
- package/dist/features/find-bar/FindBar.d.ts +41 -0
- package/dist/features/find-bar/FindBar.js +31 -0
- package/dist/features/find-bar/index.d.ts +2 -0
- package/dist/features/find-bar/index.js +2 -0
- package/dist/features/folder-path-drop/index.d.ts +3 -1
- package/dist/features/folder-path-drop/index.js +1 -0
- package/dist/features/folder-path-drop/react/hooks/useClassifiedPathDrop.d.ts +50 -0
- package/dist/features/folder-path-drop/react/hooks/useClassifiedPathDrop.js +50 -0
- package/dist/features/folder-path-drop/types.d.ts +14 -0
- package/dist/features/i18n/context.d.ts +1 -1
- package/dist/features/i18n/context.js +1 -1
- package/dist/features/iframe-pool/react/dom-sync.d.ts +13 -3
- package/dist/features/iframe-pool/react/dom-sync.js +7 -7
- package/dist/features/import-handoff/use-import-handoff.d.ts +38 -0
- package/dist/features/import-handoff/use-import-handoff.js +40 -0
- package/dist/features/integrations/rules.js +39 -41
- package/dist/features/interactive-ui/interactive-ui.css +1 -1
- package/dist/features/interactive-ui/providers/native/data-table.js +1 -1
- package/dist/features/interactive-ui/providers/native/data-table.manifest.d.ts +1 -1
- package/dist/features/interactive-ui/providers/native/data-table.manifest.js +1 -1
- package/dist/features/interactive-ui/providers/shadcn/action-button.manifest.d.ts +1 -1
- package/dist/features/interactive-ui/providers/shadcn/action-button.manifest.js +1 -1
- package/dist/features/interactive-ui/providers/shadcn/checkbox-field.js +1 -1
- package/dist/features/interactive-ui/providers/shadcn/checkbox-field.manifest.d.ts +1 -1
- package/dist/features/interactive-ui/providers/shadcn/checkbox-field.manifest.js +1 -1
- package/dist/features/interactive-ui/providers/shadcn/content-card.manifest.d.ts +1 -1
- package/dist/features/interactive-ui/providers/shadcn/content-card.manifest.js +1 -1
- package/dist/features/interactive-ui/providers/shadcn/data-table.js +3 -3
- package/dist/features/interactive-ui/providers/shadcn/data-table.manifest.d.ts +1 -1
- package/dist/features/interactive-ui/providers/shadcn/data-table.manifest.js +1 -1
- package/dist/features/interactive-ui/providers/shadcn/radio-group-field.js +1 -1
- package/dist/features/interactive-ui/providers/shadcn/radio-group-field.manifest.d.ts +1 -1
- package/dist/features/interactive-ui/providers/shadcn/radio-group-field.manifest.js +1 -1
- package/dist/features/interactive-ui/providers/shadcn/select-field.manifest.d.ts +1 -1
- package/dist/features/interactive-ui/providers/shadcn/select-field.manifest.js +1 -1
- package/dist/features/interactive-ui/providers/shadcn/text-input-field.manifest.d.ts +1 -1
- package/dist/features/interactive-ui/providers/shadcn/text-input-field.manifest.js +1 -1
- package/dist/features/interactive-ui/types.d.ts +1 -1
- package/dist/features/live-views/index.d.ts +6 -0
- package/dist/features/live-views/index.js +6 -0
- package/dist/features/live-views/use-live-views.d.ts +31 -0
- package/dist/features/live-views/use-live-views.js +88 -0
- package/dist/features/live-views/use-site-view-preference.d.ts +33 -0
- package/dist/features/live-views/use-site-view-preference.js +32 -0
- package/dist/features/live-views/use-webview-load-failure.d.ts +90 -0
- package/dist/features/live-views/use-webview-load-failure.js +122 -0
- package/dist/features/mcp-ui/credential-card.d.ts +1 -0
- package/dist/features/mcp-ui/credential-card.js +1 -1
- package/dist/features/mcp-ui/surfaces/tool-approval.d.ts +10 -0
- package/dist/features/mcp-ui/surfaces/tool-approval.js +15 -0
- package/dist/features/media-providers/dependencies.d.ts +7 -1
- package/dist/features/media-providers/dependencies.js +43 -0
- package/dist/features/media-providers/index.d.ts +2 -2
- package/dist/features/media-providers/index.js +1 -1
- package/dist/features/media-providers/ports.d.ts +39 -5
- package/dist/features/media-providers/react/components/MediaProvidersTab.d.ts +4 -3
- package/dist/features/media-providers/react/components/MediaProvidersTab.js +1 -1
- package/dist/features/media-providers/react/hooks/useMediaProvidersTab.d.ts +3 -2
- package/dist/features/media-providers/react/hooks/useMediaProvidersTab.js +41 -3
- package/dist/features/memory/react/components/MemoryConnectedPanel.js +2 -2
- package/dist/features/memory/react/components/MemoryEntryCard.js +1 -1
- package/dist/features/memory/react/components/MemoryHooksPanel.js +2 -2
- package/dist/features/memory/react/components/MemoryList.js +2 -2
- package/dist/features/memory/react/components/MemorySettingsPanel.js +2 -2
- package/dist/features/memory/react/components/MemorySuggestionPanel.js +1 -1
- package/dist/features/memory/react/hooks/useMemoryConnectors.hooks.js +3 -3
- package/dist/features/memory/react/hooks/useMemoryConnectors.rules.d.ts +4 -1
- package/dist/features/memory/react/hooks/useMemoryConnectors.rules.js +1 -1
- package/dist/features/memory/react/render-markdown.js +1 -1
- package/dist/features/nav-availability/nav-availability.d.ts +18 -0
- package/dist/features/nav-availability/nav-availability.js +12 -0
- package/dist/features/number-stepper/NumberStepper.d.ts +39 -0
- package/dist/features/number-stepper/NumberStepper.js +16 -0
- package/dist/features/number-stepper/index.d.ts +5 -0
- package/dist/features/number-stepper/index.js +5 -0
- package/dist/features/number-stepper/number-stepper.d.ts +34 -0
- package/dist/features/number-stepper/number-stepper.js +32 -0
- package/dist/features/number-stepper/use-number-stepper.hooks.d.ts +20 -0
- package/dist/features/number-stepper/use-number-stepper.hooks.js +29 -0
- package/dist/features/number-stepper/use-optimistic-number-setting.hooks.d.ts +36 -0
- package/dist/features/number-stepper/use-optimistic-number-setting.hooks.js +25 -0
- package/dist/features/panel-kit/ErrorNotice.js +8 -1
- package/dist/features/panel-kit/helpers/standing-draft-local-backup.d.ts +1 -1
- package/dist/features/panel-kit/helpers/standing-draft-recovery-message.d.ts +1 -1
- package/dist/features/panel-kit/hooks/use-standing-draft-autosave.hooks.d.ts +1 -37
- package/dist/features/panel-kit/hooks/use-standing-draft-recovery.hooks.d.ts +2 -1
- package/dist/features/panel-kit/hooks/use-standing-draft-state.hooks.d.ts +2 -1
- package/dist/features/panel-kit/hooks/use-standing-draft-writes.hooks.d.ts +2 -1
- package/dist/features/panel-kit/index.d.ts +2 -1
- package/dist/features/privacy/react/components/PrivacyTab.d.ts +1 -1
- package/dist/features/privacy/react/components/PrivacyTab.js +1 -1
- package/dist/features/progress-card/components/ProgressCard.d.ts +1 -1
- package/dist/features/progress-card/components/ProgressCard.js +1 -1
- package/dist/features/resource-dashboard/react/components/ResourceBoard.d.ts +1 -1
- package/dist/features/resource-dashboard/react/components/ResourceBoardToolbar.d.ts +1 -1
- package/dist/features/resource-dashboard/react/components/ResourceBoardToolbar.js +1 -1
- package/dist/features/resource-dashboard/react/components/ResourceCardParts.d.ts +1 -1
- package/dist/features/resource-dashboard/react/components/ResourceCardParts.js +7 -2
- package/dist/features/resource-dashboard/react/components/ResourceRowListView.d.ts +1 -1
- package/dist/features/resource-dashboard/react/components/ResourceRowListView.js +1 -1
- package/dist/features/resource-dashboard/react/components/ResourceRunHistoryList.d.ts +1 -1
- package/dist/features/resource-dashboard/react/components/ResourceRunHistoryList.js +1 -1
- package/dist/features/resource-dashboard/react/components/StatusPill.d.ts +1 -1
- package/dist/features/resource-dashboard/react/components/StatusPill.js +1 -1
- package/dist/features/resource-dashboard/react/hooks/useResourceBoard.js +6 -1
- package/dist/features/resource-monitor/ResourceTable.d.ts +67 -0
- package/dist/features/resource-monitor/ResourceTable.js +25 -0
- package/dist/features/resource-monitor/index.d.ts +4 -0
- package/dist/features/resource-monitor/index.js +4 -0
- package/dist/features/resource-monitor/resource-stop.d.ts +16 -0
- package/dist/features/resource-monitor/resource-stop.js +11 -0
- package/dist/features/resource-monitor/use-resource-readings.hooks.d.ts +44 -0
- package/dist/features/resource-monitor/use-resource-readings.hooks.js +91 -0
- package/dist/features/settings/dialog/styles/settings-dialog.css +251 -251
- package/dist/features/site-card/index.d.ts +4 -1
- package/dist/features/site-card/index.js +3 -0
- package/dist/features/site-card/use-created-site-return.hooks.d.ts +36 -0
- package/dist/features/site-card/use-created-site-return.hooks.js +43 -0
- package/dist/features/site-card/use-site-card-preview.hooks.d.ts +39 -0
- package/dist/features/site-card/use-site-card-preview.hooks.js +31 -0
- package/dist/features/site-card/use-site-list-prefs.hooks.d.ts +29 -8
- package/dist/features/site-card/use-site-list-prefs.hooks.js +56 -9
- package/dist/features/site-card/use-site-preview.hooks.d.ts +67 -0
- package/dist/features/site-card/use-site-preview.hooks.js +94 -0
- package/dist/features/sketch-editor/react/components/SketchEditor.d.ts +2 -2
- package/dist/features/sketch-editor/react/components/SketchEditor.js +1 -1
- package/dist/features/skills/react/components/SkillRow.js +1 -1
- package/dist/features/source-config-list/react/components/SourceConfigAddForm.js +2 -2
- package/dist/features/source-config-list/react/components/SourceConfigField.js +1 -1
- package/dist/features/source-config-list/react/components/SourceConfigItemCard.js +5 -5
- package/dist/features/source-config-list/react/components/SourceConfigList.d.ts +1 -1
- package/dist/features/source-config-list/react/components/SourceConfigList.js +1 -1
- package/dist/features/source-config-list/react/components/SourceConfigListView.js +3 -3
- package/dist/features/source-config-list/react/components/SourceConfigTestControl.d.ts +1 -1
- package/dist/features/source-config-list/react/components/SourceConfigTestControl.js +1 -1
- package/dist/features/tab-launcher-menu/react/components/TabLauncherMenu.d.ts +1 -1
- package/dist/features/tab-launcher-menu/react/components/TabLauncherMenu.js +1 -1
- package/dist/features/tab-strip/react/components/TabBar.js +2 -2
- package/dist/features/tab-strip/react/components/TabStrip.d.ts +1 -1
- package/dist/features/tab-strip/react/components/TabStrip.js +1 -1
- package/dist/features/tab-strip/scrollable.js +0 -2
- package/dist/features/tabbed-dialog/react/components/TabbedDialog.d.ts +1 -1
- package/dist/features/tabbed-dialog/react/components/TabbedDialog.js +1 -1
- package/dist/features/version-manager/react/components/VersionManagerModal.d.ts +1 -1
- package/dist/features/version-manager/react/components/VersionManagerModal.js +1 -1
- package/dist/features/viewer-shell/react/components/CommentSidePanel.d.ts +2 -2
- package/dist/features/viewer-shell/react/components/CommentSidePanel.js +1 -1
- package/dist/features/viewer-shell/react/components/MarkdownSplitPane.d.ts +1 -1
- package/dist/features/viewer-shell/react/components/MarkdownSplitPane.js +1 -1
- package/dist/features/viewer-shell/react/components/SegmentedToggle.d.ts +1 -1
- package/dist/features/viewer-shell/react/components/SegmentedToggle.js +1 -1
- package/dist/features/viewer-shell/react/components/ViewportSwitcher.d.ts +1 -1
- package/dist/features/viewer-shell/react/components/ViewportSwitcher.js +1 -1
- package/dist/features/viewer-shell/react/components/ViewportToggleGroup.d.ts +1 -1
- package/dist/features/viewer-shell/react/components/ViewportToggleGroup.js +1 -1
- package/dist/features/zoom/use-zoom.d.ts +141 -0
- package/dist/features/zoom/use-zoom.js +204 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/react/components/ComponentKitPreview.d.ts +1 -1
- package/dist/react/components/ComponentKitPreview.js +1 -1
- package/dist/react/components/CustomSelect.js +1 -1
- package/dist/react/components/ExportDiagnosticsButton.d.ts +6 -2
- package/dist/react/components/ExportDiagnosticsButton.js +3 -3
- package/dist/react/components/FileImportPanel.js +1 -1
- package/dist/react/components/IconFrame.d.ts +15 -0
- package/dist/react/components/IconFrame.js +11 -0
- package/dist/react/components/ImportChoice.js +1 -1
- package/dist/react/components/Notice.js +1 -1
- package/dist/react/components/OnboardingDropdown.js +1 -1
- package/dist/react/components/PaletteTweaks.js +1 -1
- package/dist/react/components/TooltipLayer.d.ts +13 -3
- package/dist/react/components/TooltipLayer.js +12 -12
- package/dist/react/mcp-ui/host-message-source.d.ts +3 -1
- package/dist/react/mcp-ui/host-message-source.js +1 -1
- package/dist/react/testing.js +3 -1
- package/dist/renderers/annotation-canvas/rules.js +30 -27
- package/dist/renderers/react/components/ArtifactView.js +1 -1
- package/dist/renderers/renderers/markdown.d.ts +3 -1
- package/dist/renderers/renderers/markdown.js +2 -2
- package/dist/styles/admin.css +54 -54
- package/dist/utils/zip.js +43 -36
- package/package.json +70 -13
- package/dist/features/execution/ports.d.ts +0 -71
- package/dist/features/execution/ports.js +0 -2
- package/dist/features/execution/types.d.ts +0 -472
- package/dist/features/execution/types.js +0 -2
- package/dist/react/components/CustomSelectMarkup.d.ts +0 -27
- package/dist/react/components/CustomSelectMarkup.js +0 -35
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ParkedView, type LiveGuest } from './live-views.js';
|
|
2
|
+
import type { useSiteViewPreference as UseSiteViewPreference, LiveViewBounds, LiveViewPreferenceBridge } from './use-site-view-preference.js';
|
|
3
|
+
export interface LiveViews {
|
|
4
|
+
/** Whether this tab may mount its guest: the focused tab always may. */
|
|
5
|
+
isLive: (input: {
|
|
6
|
+
id: string;
|
|
7
|
+
}) => boolean;
|
|
8
|
+
/** Each released tab's last route and scroll, for its next mount. */
|
|
9
|
+
parked: Readonly<Record<string, ParkedView>>;
|
|
10
|
+
/** The guest each tab mounted, so a probe can reach it. Stable across renders. */
|
|
11
|
+
registerGuest: (id: string, node: LiveGuest | null) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Owns which open tabs keep their guest. `focusedId` is the tab on screen, `null` outside the tabs
|
|
15
|
+
* screen (every tab hidden, the last one focused still the most recent).
|
|
16
|
+
* @param required.useSiteViewPreference the host's binding of the limit-preference hook (`useSiteViewPreference` from this package).
|
|
17
|
+
* @param required.getBridge the host's bridge lookup for the limit preference (stable function).
|
|
18
|
+
* @param required.bounds the limit's range and default (module-level constant).
|
|
19
|
+
* @param required.probe the host's release probe script, run in each hidden guest.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useLiveViews({ openIds, focusedId, useSiteViewPreference, getBridge, bounds, probe }: {
|
|
22
|
+
openIds: readonly string[];
|
|
23
|
+
focusedId: string | null;
|
|
24
|
+
useSiteViewPreference: typeof UseSiteViewPreference;
|
|
25
|
+
getBridge: () => LiveViewPreferenceBridge | undefined;
|
|
26
|
+
bounds: LiveViewBounds;
|
|
27
|
+
probe: string;
|
|
28
|
+
}, { timeoutMs }?: {
|
|
29
|
+
timeoutMs?: number;
|
|
30
|
+
}): LiveViews;
|
|
31
|
+
//# sourceMappingURL=use-live-views.d.ts.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Live views: how many open tabs keep a running `<webview>` guest at once.
|
|
3
|
+
*
|
|
4
|
+
* Every guest is a whole Chromium renderer process plus the site's own bundle, so ten open tabs
|
|
5
|
+
* used to mean ten of them, nine hidden. The limit (the host's "loaded sites" setting) is SOFT: the
|
|
6
|
+
* tab on screen always mounts its guest, and only then does this hook look for a hidden one to
|
|
7
|
+
* release, least recently focused first. A guest is released only when it agrees to be.
|
|
8
|
+
*
|
|
9
|
+
* **The release probe.** The host's probe script, run through `webview.executeJavaScript`,
|
|
10
|
+
* dispatches a cancelable `beforeunload` and a cancelable `jini:release-check` on the guest's
|
|
11
|
+
* `window`, then reads whether either was prevented. `beforeunload` is what every editor's dirty
|
|
12
|
+
* guard already answers, so a post with unsaved edits keeps its guest without any new code;
|
|
13
|
+
* `jini:release-check` is the composer's and chat pane's own event (flush the draft, veto during an
|
|
14
|
+
* upload, unresolved send or running reply) and the host's route allowlist. Neither is prevented →
|
|
15
|
+
* the guest's route and scroll come back in the same answer and the guest is unmounted. A guest
|
|
16
|
+
* that throws, rejects or never answers is KEPT: a release is optional, discarding someone's work
|
|
17
|
+
* is not.
|
|
18
|
+
*
|
|
19
|
+
* If every hidden guest vetoes, the shell simply stays over the limit; the next focus change, tab
|
|
20
|
+
* close or limit change tries again. There is no queue, no reservation and no polling.
|
|
21
|
+
*/
|
|
22
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
23
|
+
import { liveViewOrder, releaseCandidates, releaseExcessViews, RELEASE_PROBE_TIMEOUT_MS } from './live-views.js';
|
|
24
|
+
function sameIds({ a, b }, _options = {}) {
|
|
25
|
+
return a.length === b.length && a.every((id, index) => id === b[index]);
|
|
26
|
+
}
|
|
27
|
+
/** Records a focus change and drops closed tabs, parked routes included; the same state if neither. */
|
|
28
|
+
function syncLiveViews({ state, focusedId, openIds }, _options = {}) {
|
|
29
|
+
const order = liveViewOrder({ order: state.order, focusedId, openIds });
|
|
30
|
+
const open = new Set(openIds);
|
|
31
|
+
const stale = Object.keys(state.parked).filter((id) => !open.has(id));
|
|
32
|
+
if (sameIds({ a: order, b: state.order }) && stale.length === 0)
|
|
33
|
+
return state;
|
|
34
|
+
const parked = Object.fromEntries(Object.entries(state.parked).filter(([id]) => open.has(id)));
|
|
35
|
+
return { order, parked };
|
|
36
|
+
}
|
|
37
|
+
function applyReleases({ state, released }, _options = {}) {
|
|
38
|
+
if (released.length === 0)
|
|
39
|
+
return state;
|
|
40
|
+
const gone = new Set(released.map(({ id }) => id));
|
|
41
|
+
const parked = { ...state.parked };
|
|
42
|
+
// No guest, no route: keep whatever an earlier release recorded rather than forgetting it.
|
|
43
|
+
for (const entry of released)
|
|
44
|
+
if (entry.parked !== null)
|
|
45
|
+
parked[entry.id] = entry.parked;
|
|
46
|
+
return { order: state.order.filter((id) => !gone.has(id)), parked };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Owns which open tabs keep their guest. `focusedId` is the tab on screen, `null` outside the tabs
|
|
50
|
+
* screen (every tab hidden, the last one focused still the most recent).
|
|
51
|
+
* @param required.useSiteViewPreference the host's binding of the limit-preference hook (`useSiteViewPreference` from this package).
|
|
52
|
+
* @param required.getBridge the host's bridge lookup for the limit preference (stable function).
|
|
53
|
+
* @param required.bounds the limit's range and default (module-level constant).
|
|
54
|
+
* @param required.probe the host's release probe script, run in each hidden guest.
|
|
55
|
+
*/
|
|
56
|
+
export function useLiveViews({ openIds, focusedId, useSiteViewPreference, getBridge, bounds, probe }, { timeoutMs = RELEASE_PROBE_TIMEOUT_MS } = {}) {
|
|
57
|
+
const [state, setState] = useState({ order: [], parked: {} });
|
|
58
|
+
const { value: limit } = useSiteViewPreference({ getBridge, bounds });
|
|
59
|
+
const guests = useRef(new Map());
|
|
60
|
+
const registerGuest = useCallback((id, node) => {
|
|
61
|
+
if (node === null)
|
|
62
|
+
guests.current.delete(id);
|
|
63
|
+
else
|
|
64
|
+
guests.current.set(id, node);
|
|
65
|
+
}, []);
|
|
66
|
+
// Keys, not arrays: the site list is a new array on every poll, and that alone is no change.
|
|
67
|
+
const openKey = JSON.stringify(openIds);
|
|
68
|
+
const order = liveViewOrder({ order: state.order, focusedId, openIds });
|
|
69
|
+
const orderKey = JSON.stringify(order);
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
const ids = JSON.parse(openKey);
|
|
72
|
+
setState((current) => syncLiveViews({ state: current, focusedId, openIds: ids }));
|
|
73
|
+
}, [focusedId, openKey]);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
// A newer focus, close or limit cancels this pass; its answers would be about a stale order.
|
|
76
|
+
let active = true;
|
|
77
|
+
const { candidates, excess } = releaseCandidates({ order: JSON.parse(orderKey), focusedId, limit });
|
|
78
|
+
if (excess === 0)
|
|
79
|
+
return undefined;
|
|
80
|
+
void releaseExcessViews({ candidates, excess, script: probe, guestOf: ({ id }) => guests.current.get(id) ?? null }, { timeoutMs }).then((released) => {
|
|
81
|
+
if (active)
|
|
82
|
+
setState((current) => applyReleases({ state: current, released }));
|
|
83
|
+
});
|
|
84
|
+
return () => { active = false; };
|
|
85
|
+
}, [orderKey, focusedId, limit, timeoutMs, probe]);
|
|
86
|
+
return { isLive: ({ id }) => order.includes(id), parked: state.parked, registerGuest };
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=use-live-views.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** The host's allowed range for the live-view limit, and the shipped default. */
|
|
2
|
+
export interface LiveViewBounds {
|
|
3
|
+
readonly min: number;
|
|
4
|
+
readonly max: number;
|
|
5
|
+
readonly fallback: number;
|
|
6
|
+
}
|
|
7
|
+
/** The preload bridge slice this hook drives; either method may be missing on an older preload. */
|
|
8
|
+
export interface LiveViewPreferenceBridge {
|
|
9
|
+
getMaximumLiveSiteViews?(): Promise<unknown>;
|
|
10
|
+
onMaximumLiveSiteViewsChanged?(required: {
|
|
11
|
+
listener: (saved: unknown) => void;
|
|
12
|
+
}): () => void;
|
|
13
|
+
}
|
|
14
|
+
/** A positive saved whole number clamped to `bounds`, otherwise the shipped default. */
|
|
15
|
+
export declare function liveViewLimit({ value, bounds }: {
|
|
16
|
+
value: unknown;
|
|
17
|
+
bounds: LiveViewBounds;
|
|
18
|
+
}, _options?: {}): number;
|
|
19
|
+
/**
|
|
20
|
+
* A change event or local save supersedes the initial IPC snapshot. O(1) per update.
|
|
21
|
+
* @param required.getBridge the host's bridge lookup; pass a stable function.
|
|
22
|
+
* @param required.bounds the host's range and default; pass a module-level constant.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useSiteViewPreference({ getBridge, bounds }: {
|
|
25
|
+
getBridge: () => LiveViewPreferenceBridge | undefined;
|
|
26
|
+
bounds: LiveViewBounds;
|
|
27
|
+
}, _options?: {}): {
|
|
28
|
+
value: number;
|
|
29
|
+
setValue: ({ next }: {
|
|
30
|
+
next: number;
|
|
31
|
+
}) => void;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=use-site-view-preference.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** One ordering owner for the "live views" menu preference consumed by settings and live-view admission. */
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
/** A positive saved whole number clamped to `bounds`, otherwise the shipped default. */
|
|
4
|
+
export function liveViewLimit({ value, bounds }, _options = {}) {
|
|
5
|
+
return typeof value === 'number' && Number.isInteger(value) && value > 0
|
|
6
|
+
? Math.min(bounds.max, Math.max(bounds.min, value)) : bounds.fallback;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A change event or local save supersedes the initial IPC snapshot. O(1) per update.
|
|
10
|
+
* @param required.getBridge the host's bridge lookup; pass a stable function.
|
|
11
|
+
* @param required.bounds the host's range and default; pass a module-level constant.
|
|
12
|
+
*/
|
|
13
|
+
export function useSiteViewPreference({ getBridge, bounds }, _options = {}) {
|
|
14
|
+
const [value, setValue] = useState(bounds.fallback);
|
|
15
|
+
const [ordering] = useState(() => ({ changed: false }));
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const bridge = getBridge();
|
|
18
|
+
let active = true;
|
|
19
|
+
ordering.changed = false;
|
|
20
|
+
void bridge?.getMaximumLiveSiteViews?.().then(saved => { if (active && !ordering.changed)
|
|
21
|
+
setValue(liveViewLimit({ value: saved, bounds })); }, () => undefined);
|
|
22
|
+
const off = bridge?.onMaximumLiveSiteViewsChanged?.({ listener: saved => {
|
|
23
|
+
if (!active)
|
|
24
|
+
return;
|
|
25
|
+
ordering.changed = true;
|
|
26
|
+
setValue(liveViewLimit({ value: saved, bounds }));
|
|
27
|
+
} });
|
|
28
|
+
return () => { active = false; off?.(); };
|
|
29
|
+
}, [getBridge, bounds, ordering]);
|
|
30
|
+
return { value, setValue: ({ next }) => { ordering.changed = true; setValue(next); } };
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=use-site-view-preference.js.map
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/** The fields of Electron's `did-fail-load` event this hook reads. */
|
|
2
|
+
export interface LoadFailureEvent {
|
|
3
|
+
readonly isMainFrame: boolean;
|
|
4
|
+
readonly errorCode: number;
|
|
5
|
+
}
|
|
6
|
+
/** The slice of Electron's `<webview>` this hook listens to. Structural, so this browser package
|
|
7
|
+
* never imports Electron; a real `<webview>` satisfies it, and the hook hands back the caller's
|
|
8
|
+
* own element type `G` for listeners that need more of it. */
|
|
9
|
+
export interface LoadFailureGuest {
|
|
10
|
+
addEventListener(type: 'did-fail-load', listener: (event: LoadFailureEvent) => void): void;
|
|
11
|
+
addEventListener(type: 'did-finish-load', listener: () => void): void;
|
|
12
|
+
removeEventListener(type: 'did-fail-load', listener: (event: LoadFailureEvent) => void): void;
|
|
13
|
+
removeEventListener(type: 'did-finish-load', listener: () => void): void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Detects a guest that is alive-but-not-answering, and tells apart the two different ways that
|
|
17
|
+
* can happen — `failed`, a FACT: `did-fail-load` fired on the `<webview>`'s main frame with a
|
|
18
|
+
* real error, as opposed to a normal in-flight navigation being cancelled. `stalled`, a GUESS:
|
|
19
|
+
* neither `did-fail-load` nor `did-finish-load` showed up at all within `STALL_TIMEOUT_MS`, which
|
|
20
|
+
* means exactly nothing — Chromium never told this hook anything either way, and the guest may
|
|
21
|
+
* still be about to answer on its own. The host's workspace view treats the two accordingly: `failed`
|
|
22
|
+
* swaps the guest out outright, the same way a stopped project does, because there is nothing left
|
|
23
|
+
* to wait for. `stalled` only lays a recovery panel over the still-loading guest, because there
|
|
24
|
+
* might be.
|
|
25
|
+
*
|
|
26
|
+
* Two Electron quirks make `isMainFrame`/`errorCode` filtering load-bearing rather than optional.
|
|
27
|
+
* `did-fail-load` fires for sub-resources too — a missing favicon, a failed XHR inside the admin —
|
|
28
|
+
* and `isMainFrame` is what tells those apart from the guest itself being unreachable. It also
|
|
29
|
+
* fires with `errorCode === -3` (`ABORTED`) on completely ordinary navigations: the view toggle
|
|
30
|
+
* and the reload button both cancel whatever load was already in flight, and Chromium reports that
|
|
31
|
+
* cancellation exactly the way it reports a real failure. Counting either as a failure would swap
|
|
32
|
+
* a perfectly good admin for an error panel on every ordinary click.
|
|
33
|
+
*
|
|
34
|
+
* `STALL_TIMEOUT_MS` is this hook's own ceiling on "still loading, no verdict yet" — ported
|
|
35
|
+
* unchanged from the original host's own measurement of a freshly created project's slowest real
|
|
36
|
+
* first admin request (see that host's own history for the live numbers): comfortably past how long a
|
|
37
|
+
* local admin normally takes to answer, comfortably short of leaving the operator staring at a
|
|
38
|
+
* blank pane for the rest of the session.
|
|
39
|
+
*
|
|
40
|
+
* `resetKey` is the host workspace's load reset key (reload nonce, view, soft loads), not read
|
|
41
|
+
* here for its value — only for when it changes. A recovery remount replaces the guest (new DOM
|
|
42
|
+
* node, so listeners must move with it), while a view switch or a soft load (`reload()`,
|
|
43
|
+
* `loadURL()`) renavigates the same node; all of them deserve a clean slate, since
|
|
44
|
+
* without one a single transient failure would pin the recovery panel in place even after the
|
|
45
|
+
* operator's next click plainly asked for another try. The same reset also re-arms the stall timer,
|
|
46
|
+
* which is what lets the recovery panel's own "Start site" retry get a second, fresh judgment.
|
|
47
|
+
*
|
|
48
|
+
* **The guest arrives through `guestRef`, a callback ref, and that is the D-03 fix.** This used to
|
|
49
|
+
* take a `RefObject` and depend on `[webviewRef, resetKey]`. A ref OBJECT is stable for the
|
|
50
|
+
* component's whole life, and the host's workspace view renders the `<webview>` only when
|
|
51
|
+
* `running && !failed` — so on the two ordinary paths that mount a guest (a stopped tab whose 4 s
|
|
52
|
+
* poll flips to `running`, and the failure panel's own retry) neither dependency changed, the
|
|
53
|
+
* effect never re-ran, and NO listener and no stall timer were ever installed on the node actually
|
|
54
|
+
* on screen. Only "Reload while healthy" — where `key` remounts the guest in the same commit the
|
|
55
|
+
* effect follows — attached them, which is the path that needs recovery least. The hook was right
|
|
56
|
+
* in form and wrong in binding: its own doc said the listeners "must move with" the node, and
|
|
57
|
+
* nothing in its inputs changed when the node appeared. Holding the node in STATE makes it a
|
|
58
|
+
* dependency that really does change on attach, so the effect's lifetime IS the node's.
|
|
59
|
+
*
|
|
60
|
+
* The failure reset is deliberately a SECOND effect keyed on `resetKey` alone. Folding it back into the
|
|
61
|
+
* node-keyed effect looks tidier and reintroduces a worse bug: `failed` going true unmounts the
|
|
62
|
+
* guest, which fires `guestRef(null)`, which would re-run a combined effect and clear the very
|
|
63
|
+
* flag that unmounted it — the guest remounts, fails again, and the panel flickers forever.
|
|
64
|
+
*
|
|
65
|
+
* **`loaded` is the third flag, added alongside `failed`/`stalled` for the same reason those two
|
|
66
|
+
* exist: "the guest is mounted" is not "the admin is on screen".** Before it, a fresh guest gave
|
|
67
|
+
* the operator nothing to look at from the moment it mounted until either `did-finish-load` swapped
|
|
68
|
+
* in real content or `STALL_TIMEOUT_MS` ran out and guessed something was wrong — a blank pane for
|
|
69
|
+
* up to 8 seconds on every ordinary open, indistinguishable from a hang. `loaded` is what a caller
|
|
70
|
+
* checks to show its OWN "still loading" state in that window, instead of leaving it silent.
|
|
71
|
+
* `true` only once `did-finish-load` has actually fired for the CURRENT `resetKey`; it resets to
|
|
72
|
+
* `false` in lockstep with `failed`/`stalled` so a remount, a view switch, or a soft load all start
|
|
73
|
+
* from "not loaded yet" rather than carrying over a previous navigation's finished state.
|
|
74
|
+
*
|
|
75
|
+
* @returns `guestRef` alongside the three flags — the caller MUST put it on the `<webview>`; there
|
|
76
|
+
* is no other way for this hook to see the node. `guest` is that node, for the host workspace's
|
|
77
|
+
* history listeners, which need the same lifetime and cannot take a second ref on one element.
|
|
78
|
+
*/
|
|
79
|
+
export declare function useWebviewLoadFailure<G extends LoadFailureGuest = LoadFailureGuest>({ resetKey }: {
|
|
80
|
+
resetKey: unknown;
|
|
81
|
+
}, { timers }?: {
|
|
82
|
+
timers?: Pick<Window, 'setTimeout' | 'clearTimeout'>;
|
|
83
|
+
}): {
|
|
84
|
+
failed: boolean;
|
|
85
|
+
stalled: boolean;
|
|
86
|
+
loaded: boolean;
|
|
87
|
+
guest: G | null;
|
|
88
|
+
guestRef: (node: G | null) => void;
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=use-webview-load-failure.d.ts.map
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Telling a guest `<webview>` that failed apart from one that stalled or loaded. Split out of
|
|
3
|
+
* the host's app hooks barrel (which still re-exports it) with no behaviour change.
|
|
4
|
+
*/
|
|
5
|
+
import { useEffect, useState } from 'react';
|
|
6
|
+
/**
|
|
7
|
+
* Detects a guest that is alive-but-not-answering, and tells apart the two different ways that
|
|
8
|
+
* can happen — `failed`, a FACT: `did-fail-load` fired on the `<webview>`'s main frame with a
|
|
9
|
+
* real error, as opposed to a normal in-flight navigation being cancelled. `stalled`, a GUESS:
|
|
10
|
+
* neither `did-fail-load` nor `did-finish-load` showed up at all within `STALL_TIMEOUT_MS`, which
|
|
11
|
+
* means exactly nothing — Chromium never told this hook anything either way, and the guest may
|
|
12
|
+
* still be about to answer on its own. The host's workspace view treats the two accordingly: `failed`
|
|
13
|
+
* swaps the guest out outright, the same way a stopped project does, because there is nothing left
|
|
14
|
+
* to wait for. `stalled` only lays a recovery panel over the still-loading guest, because there
|
|
15
|
+
* might be.
|
|
16
|
+
*
|
|
17
|
+
* Two Electron quirks make `isMainFrame`/`errorCode` filtering load-bearing rather than optional.
|
|
18
|
+
* `did-fail-load` fires for sub-resources too — a missing favicon, a failed XHR inside the admin —
|
|
19
|
+
* and `isMainFrame` is what tells those apart from the guest itself being unreachable. It also
|
|
20
|
+
* fires with `errorCode === -3` (`ABORTED`) on completely ordinary navigations: the view toggle
|
|
21
|
+
* and the reload button both cancel whatever load was already in flight, and Chromium reports that
|
|
22
|
+
* cancellation exactly the way it reports a real failure. Counting either as a failure would swap
|
|
23
|
+
* a perfectly good admin for an error panel on every ordinary click.
|
|
24
|
+
*
|
|
25
|
+
* `STALL_TIMEOUT_MS` is this hook's own ceiling on "still loading, no verdict yet" — ported
|
|
26
|
+
* unchanged from the original host's own measurement of a freshly created project's slowest real
|
|
27
|
+
* first admin request (see that host's own history for the live numbers): comfortably past how long a
|
|
28
|
+
* local admin normally takes to answer, comfortably short of leaving the operator staring at a
|
|
29
|
+
* blank pane for the rest of the session.
|
|
30
|
+
*
|
|
31
|
+
* `resetKey` is the host workspace's load reset key (reload nonce, view, soft loads), not read
|
|
32
|
+
* here for its value — only for when it changes. A recovery remount replaces the guest (new DOM
|
|
33
|
+
* node, so listeners must move with it), while a view switch or a soft load (`reload()`,
|
|
34
|
+
* `loadURL()`) renavigates the same node; all of them deserve a clean slate, since
|
|
35
|
+
* without one a single transient failure would pin the recovery panel in place even after the
|
|
36
|
+
* operator's next click plainly asked for another try. The same reset also re-arms the stall timer,
|
|
37
|
+
* which is what lets the recovery panel's own "Start site" retry get a second, fresh judgment.
|
|
38
|
+
*
|
|
39
|
+
* **The guest arrives through `guestRef`, a callback ref, and that is the D-03 fix.** This used to
|
|
40
|
+
* take a `RefObject` and depend on `[webviewRef, resetKey]`. A ref OBJECT is stable for the
|
|
41
|
+
* component's whole life, and the host's workspace view renders the `<webview>` only when
|
|
42
|
+
* `running && !failed` — so on the two ordinary paths that mount a guest (a stopped tab whose 4 s
|
|
43
|
+
* poll flips to `running`, and the failure panel's own retry) neither dependency changed, the
|
|
44
|
+
* effect never re-ran, and NO listener and no stall timer were ever installed on the node actually
|
|
45
|
+
* on screen. Only "Reload while healthy" — where `key` remounts the guest in the same commit the
|
|
46
|
+
* effect follows — attached them, which is the path that needs recovery least. The hook was right
|
|
47
|
+
* in form and wrong in binding: its own doc said the listeners "must move with" the node, and
|
|
48
|
+
* nothing in its inputs changed when the node appeared. Holding the node in STATE makes it a
|
|
49
|
+
* dependency that really does change on attach, so the effect's lifetime IS the node's.
|
|
50
|
+
*
|
|
51
|
+
* The failure reset is deliberately a SECOND effect keyed on `resetKey` alone. Folding it back into the
|
|
52
|
+
* node-keyed effect looks tidier and reintroduces a worse bug: `failed` going true unmounts the
|
|
53
|
+
* guest, which fires `guestRef(null)`, which would re-run a combined effect and clear the very
|
|
54
|
+
* flag that unmounted it — the guest remounts, fails again, and the panel flickers forever.
|
|
55
|
+
*
|
|
56
|
+
* **`loaded` is the third flag, added alongside `failed`/`stalled` for the same reason those two
|
|
57
|
+
* exist: "the guest is mounted" is not "the admin is on screen".** Before it, a fresh guest gave
|
|
58
|
+
* the operator nothing to look at from the moment it mounted until either `did-finish-load` swapped
|
|
59
|
+
* in real content or `STALL_TIMEOUT_MS` ran out and guessed something was wrong — a blank pane for
|
|
60
|
+
* up to 8 seconds on every ordinary open, indistinguishable from a hang. `loaded` is what a caller
|
|
61
|
+
* checks to show its OWN "still loading" state in that window, instead of leaving it silent.
|
|
62
|
+
* `true` only once `did-finish-load` has actually fired for the CURRENT `resetKey`; it resets to
|
|
63
|
+
* `false` in lockstep with `failed`/`stalled` so a remount, a view switch, or a soft load all start
|
|
64
|
+
* from "not loaded yet" rather than carrying over a previous navigation's finished state.
|
|
65
|
+
*
|
|
66
|
+
* @returns `guestRef` alongside the three flags — the caller MUST put it on the `<webview>`; there
|
|
67
|
+
* is no other way for this hook to see the node. `guest` is that node, for the host workspace's
|
|
68
|
+
* history listeners, which need the same lifetime and cannot take a second ref on one element.
|
|
69
|
+
*/
|
|
70
|
+
export function useWebviewLoadFailure({ resetKey }, { timers = window } = {}) {
|
|
71
|
+
const [failed, setFailed] = useState(false);
|
|
72
|
+
const [stalled, setStalled] = useState(false);
|
|
73
|
+
const [loaded, setLoaded] = useState(false);
|
|
74
|
+
const [guest, setGuest] = useState(null);
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
// Not read for its value — only for when it changes. `resetKey` is what makes reload and a
|
|
77
|
+
// view switch a clean slate rather than a permanent black mark; without a genuine reference
|
|
78
|
+
// to it here, Biome's exhaustive-deps rule reads the dependency as dead weight and asks to
|
|
79
|
+
// drop it, which would drop the reset along with it.
|
|
80
|
+
resetKey;
|
|
81
|
+
setLoaded(false);
|
|
82
|
+
setFailed(false);
|
|
83
|
+
setStalled(false);
|
|
84
|
+
}, [resetKey]);
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (guest === null)
|
|
87
|
+
return undefined;
|
|
88
|
+
// A stopped site can remount a guest without changing resetKey. Reset only on attach:
|
|
89
|
+
// detaching a failed guest must keep the recovery panel's failure flag intact.
|
|
90
|
+
setLoaded(false);
|
|
91
|
+
setStalled(false);
|
|
92
|
+
const STALL_TIMEOUT_MS = 8000;
|
|
93
|
+
const stallTimer = timers.setTimeout(() => setStalled(true), STALL_TIMEOUT_MS);
|
|
94
|
+
const onFailLoad = (event) => {
|
|
95
|
+
if (!event.isMainFrame || event.errorCode === -3)
|
|
96
|
+
return;
|
|
97
|
+
timers.clearTimeout(stallTimer);
|
|
98
|
+
// A fact arriving after a guess: the guess was wrong (or overtaken), so withdraw it rather
|
|
99
|
+
// than leave both true and ask the host's workspace view to decide which one wins.
|
|
100
|
+
setStalled(false);
|
|
101
|
+
setFailed(true);
|
|
102
|
+
};
|
|
103
|
+
const onFinishLoad = () => {
|
|
104
|
+
timers.clearTimeout(stallTimer);
|
|
105
|
+
setFailed(false);
|
|
106
|
+
setStalled(false);
|
|
107
|
+
setLoaded(true);
|
|
108
|
+
};
|
|
109
|
+
guest.addEventListener('did-fail-load', onFailLoad);
|
|
110
|
+
guest.addEventListener('did-finish-load', onFinishLoad);
|
|
111
|
+
return () => {
|
|
112
|
+
timers.clearTimeout(stallTimer);
|
|
113
|
+
guest.removeEventListener('did-fail-load', onFailLoad);
|
|
114
|
+
guest.removeEventListener('did-finish-load', onFinishLoad);
|
|
115
|
+
};
|
|
116
|
+
// `resetKey` as well as the node: a VIEW switch or a soft load navigates the guest that is
|
|
117
|
+
// already mounted, so the node is unchanged and only this re-arms the stall timer for the new
|
|
118
|
+
// navigation. A recovery remount changes both (`key` remounts the element).
|
|
119
|
+
}, [guest, resetKey, timers]);
|
|
120
|
+
return { failed, stalled, loaded, guest, guestRef: setGuest };
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=use-webview-load-failure.js.map
|
|
@@ -22,6 +22,7 @@ export declare function buildPluginCredentialForm({ card, app }: {
|
|
|
22
22
|
}, _optional?: {}): SecretCardForm & {
|
|
23
23
|
preferredFrameSize: readonly [string, string];
|
|
24
24
|
description: string;
|
|
25
|
+
details: NonNullable<SecretCardForm['details']>;
|
|
25
26
|
};
|
|
26
27
|
/** Apply plugin copy to an existing domain form, preserving its fields, update and blank-token rules.
|
|
27
28
|
* Domain stores remain authoritative for connection validation. @complexity O(f) form fields.
|
|
@@ -30,7 +30,7 @@ export function applyPluginCredentialCard({ card, form, app }, _options = {}) {
|
|
|
30
30
|
if (!card)
|
|
31
31
|
return form;
|
|
32
32
|
const pluginForm = buildPluginCredentialForm({ card, app });
|
|
33
|
-
return { ...form, title: pluginForm.title, description: form.description ? `${card.intro ?? ""} ${form.description}`.trim() : pluginForm.description, details: [...(form.details ?? []), ...
|
|
33
|
+
return { ...form, title: pluginForm.title, description: form.description ? `${card.intro ?? ""} ${form.description}`.trim() : pluginForm.description, details: [...(form.details ?? []), ...pluginForm.details],
|
|
34
34
|
fields: form.fields.map(field => field.kind === "string" && field.name === "token" && field.secret ? { ...field, ...(card.keyHint === undefined ? {} : { hint: card.keyHint }) } : field) };
|
|
35
35
|
}
|
|
36
36
|
/** API rows have a fixed label; domain owners choose their own connection identity. */
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { HumanConfirmSpec } from '@jini-ai/core/contracts/site/human-confirm';
|
|
2
|
+
import type { SurfaceDetail } from '@jini-ai/core/contracts/cards';
|
|
1
3
|
import { type ToolDescriptor } from '@jini-ai/core';
|
|
2
4
|
type ApprovalText = (required: {
|
|
3
5
|
key: string;
|
|
@@ -17,5 +19,13 @@ export declare function toolApprovalPresentation({ descriptor }: {
|
|
|
17
19
|
confirmLabel: string;
|
|
18
20
|
labels: Readonly<Record<string, string>>;
|
|
19
21
|
};
|
|
22
|
+
/** Shared operator-language presentation for policy approvals and domain-owned tool plans. */
|
|
23
|
+
export declare function toolApprovalConfirmation({ descriptor, input, locale, details, danger }: {
|
|
24
|
+
descriptor: Parameters<typeof toolApprovalPresentation>[0]['descriptor'];
|
|
25
|
+
input: unknown;
|
|
26
|
+
locale: string;
|
|
27
|
+
details?: readonly SurfaceDetail[];
|
|
28
|
+
danger?: boolean;
|
|
29
|
+
}, _options?: {}): HumanConfirmSpec;
|
|
20
30
|
export {};
|
|
21
31
|
//# sourceMappingURL=tool-approval.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { approvalText } from '@jini-ai/core/contracts/site/approval-i18n';
|
|
1
2
|
import { isNonArrayRecord } from '@jini-ai/core';
|
|
2
3
|
import { surfaceDetailLabel } from './structured-details.js';
|
|
3
4
|
function nonBlank({ value }, _options = {}) {
|
|
@@ -39,4 +40,18 @@ export function toolApprovalPresentation({ descriptor }, { text }) {
|
|
|
39
40
|
labels: schemaLabels({ schema: descriptor.inputSchema }, { text }),
|
|
40
41
|
};
|
|
41
42
|
}
|
|
43
|
+
/** Shared operator-language presentation for policy approvals and domain-owned tool plans. */
|
|
44
|
+
export function toolApprovalConfirmation({ descriptor, input, locale, details = [], danger = false }, _options = {}) {
|
|
45
|
+
const toolId = descriptor.id;
|
|
46
|
+
const presentation = toolApprovalPresentation({ descriptor }, { text: ({ key }) => approvalText({ locale, key }) });
|
|
47
|
+
return {
|
|
48
|
+
toolId, errorCode: 'TOOL_APPROVAL', title: presentation.title,
|
|
49
|
+
...(presentation.summary ? { description: presentation.summary } : {}), details, danger,
|
|
50
|
+
detailDisclosure: { label: approvalText({ locale, key: 'Details' }), details: [
|
|
51
|
+
{ label: approvalText({ locale, key: 'Input' }), value: input ?? {}, labels: presentation.labels,
|
|
52
|
+
description: `${approvalText({ locale, key: 'Technical name' })}: ${toolId}` },
|
|
53
|
+
] },
|
|
54
|
+
confirmLabel: presentation.confirmLabel, cancelLabel: approvalText({ locale, key: 'Cancel' }),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
42
57
|
//# sourceMappingURL=tool-approval.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MediaProvidersPort } from './ports.js';
|
|
1
|
+
import type { MediaProviderRowsPort, MediaProvidersPort } from './ports.js';
|
|
2
2
|
import type { MediaProviderMap } from './types.js';
|
|
3
3
|
export interface FakeMediaProvidersPortOptions {
|
|
4
4
|
/** Seed daemon-held providers. Defaults to an empty map — REACHED, manages
|
|
@@ -24,4 +24,10 @@ export interface FakeMediaProvidersPortOptions {
|
|
|
24
24
|
* endpoints.
|
|
25
25
|
*/
|
|
26
26
|
export declare function createFakeMediaProvidersPort(options?: FakeMediaProvidersPortOptions): MediaProvidersPort;
|
|
27
|
+
/**
|
|
28
|
+
* The per-provider twin of {@link createFakeMediaProvidersPort}, with the same options: a patch
|
|
29
|
+
* merges into one entry and a removal drops one entry, so a test can prove another provider was
|
|
30
|
+
* left alone. `saveError` rejects both writes without persisting.
|
|
31
|
+
*/
|
|
32
|
+
export declare function createFakeMediaProviderRowsPort(options?: FakeMediaProvidersPortOptions): MediaProviderRowsPort;
|
|
27
33
|
//# sourceMappingURL=dependencies.d.ts.map
|
|
@@ -27,4 +27,47 @@ export function createFakeMediaProvidersPort(options = {}) {
|
|
|
27
27
|
},
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* The per-provider twin of {@link createFakeMediaProvidersPort}, with the same options: a patch
|
|
32
|
+
* merges into one entry and a removal drops one entry, so a test can prove another provider was
|
|
33
|
+
* left alone. `saveError` rejects both writes without persisting.
|
|
34
|
+
*/
|
|
35
|
+
export function createFakeMediaProviderRowsPort(options = {}) {
|
|
36
|
+
let providers = { ...(options.providers ?? {}) };
|
|
37
|
+
const latencyMs = options.latencyMs ?? 0;
|
|
38
|
+
const delay = fakeLatencyDelay({}, { latencyMs });
|
|
39
|
+
const write = (apply) => {
|
|
40
|
+
if (options.saveError)
|
|
41
|
+
return Promise.reject(new Error(options.saveError));
|
|
42
|
+
apply();
|
|
43
|
+
return delay({ value: { ...providers } });
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
fetchMediaProviders() {
|
|
47
|
+
if (options.unreachable)
|
|
48
|
+
return delay({ value: null });
|
|
49
|
+
return delay({ value: { ...providers } });
|
|
50
|
+
},
|
|
51
|
+
applyProviderChanges({ removes, patches }, _optional = {}) {
|
|
52
|
+
return write(() => {
|
|
53
|
+
const next = { ...providers };
|
|
54
|
+
for (const providerId of removes)
|
|
55
|
+
delete next[providerId];
|
|
56
|
+
for (const { providerId, fields } of patches)
|
|
57
|
+
next[providerId] = { ...next[providerId], ...fields };
|
|
58
|
+
providers = next;
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
patchProvider({ providerId, fields }) {
|
|
62
|
+
return write(() => {
|
|
63
|
+
providers = { ...providers, [providerId]: { ...providers[providerId], ...fields } };
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
removeProvider({ providerId }) {
|
|
67
|
+
return write(() => {
|
|
68
|
+
providers = Object.fromEntries(Object.entries(providers).filter(([id]) => id !== providerId));
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
30
73
|
//# sourceMappingURL=dependencies.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { DEFAULT_MEDIA_PROVIDER_CATALOG } from './constants.js';
|
|
2
|
-
export { createFakeMediaProvidersPort, type FakeMediaProvidersPortOptions } from './dependencies.js';
|
|
3
|
-
export type { MediaProvidersPort, MediaProviderCatalogPolicy } from './ports.js';
|
|
2
|
+
export { createFakeMediaProviderRowsPort, createFakeMediaProvidersPort, type FakeMediaProvidersPortOptions } from './dependencies.js';
|
|
3
|
+
export type { AnyMediaProvidersPort, MediaProviderFields, MediaProviderRowsPort, MediaProvidersPort, MediaProviderCatalogPolicy } from './ports.js';
|
|
4
4
|
export { hasAnyConfiguredProvider, hasRecoverableFields, isEntryEmpty, isEntryPresent, isMarkerOnlyEntry, maskedKeyLabel, mergeDaemonProviders, resolveProviderBaseUrl, shouldSyncLocalProvidersToDaemon, sortProvidersByConfigured, isProviderBaseUrlInvalid, invalidBaseUrlProviderIds, } from './rules.js';
|
|
5
5
|
export type { MediaProviderCredentials, MediaProviderMap, MediaProviderOption, MediaProvidersLoadState, MediaProvidersSaveState, } from './types.js';
|
|
6
6
|
export { useMediaProvidersTab } from './react/hooks/useMediaProvidersTab.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { DEFAULT_MEDIA_PROVIDER_CATALOG } from './constants.js';
|
|
2
|
-
export { createFakeMediaProvidersPort } from './dependencies.js';
|
|
2
|
+
export { createFakeMediaProviderRowsPort, createFakeMediaProvidersPort } from './dependencies.js';
|
|
3
3
|
export { hasAnyConfiguredProvider, hasRecoverableFields, isEntryEmpty, isEntryPresent, isMarkerOnlyEntry, maskedKeyLabel, mergeDaemonProviders, resolveProviderBaseUrl, shouldSyncLocalProvidersToDaemon, sortProvidersByConfigured, isProviderBaseUrlInvalid, invalidBaseUrlProviderIds, } from './rules.js';
|
|
4
4
|
export { useMediaProvidersTab } from './react/hooks/useMediaProvidersTab.js';
|
|
5
5
|
export { MediaProvidersTab } from './react/components/MediaProvidersTab.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Catalog policy is UI-owned; the shared contract lives once in core. */
|
|
2
2
|
export type { MediaProviderCatalogPolicy } from '@jini-ai/core';
|
|
3
|
-
import type { MediaProviderMap } from './types.js';
|
|
3
|
+
import type { MediaProviderCredentials, MediaProviderMap } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* The daemon-side transport this tab needs: reading the server's current
|
|
6
6
|
* provider credentials and persisting the operator's local edits back to it.
|
|
@@ -43,11 +43,45 @@ export interface MediaProvidersPort {
|
|
|
43
43
|
* build each payload when it is sent rather than when it is queued
|
|
44
44
|
* (`useMediaProvidersTab`'s `persist`/`flushNow` is the reference).
|
|
45
45
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
46
|
+
* Serialization only orders THIS tab's writes. A whole map from a tab opened
|
|
47
|
+
* earlier still omits a key another window saved since, and omission deletes.
|
|
48
|
+
* A host keeps this shape only if it can make the write conditional on what
|
|
49
|
+
* the tab last read (its last-read revision) and refuse a stale one; otherwise
|
|
50
|
+
* it implements {@link MediaProviderRowsPort} instead, which never needs one.
|
|
50
51
|
*/
|
|
51
52
|
saveMediaProviders(providers: MediaProviderMap): Promise<MediaProviderMap>;
|
|
52
53
|
}
|
|
54
|
+
/** The operator-editable fields of one provider; server markers never travel back. An omitted `apiKey` keeps the stored key. */
|
|
55
|
+
export type MediaProviderFields = Pick<MediaProviderCredentials, 'apiKey' | 'baseUrl' | 'model'>;
|
|
56
|
+
/**
|
|
57
|
+
* The per-provider alternative to {@link MediaProvidersPort}: the same read, and one write per
|
|
58
|
+
* provider instead of a whole-map replace. A save sends only the provider that changed and a
|
|
59
|
+
* removal names the provider it removes, so another window's write to a different provider can
|
|
60
|
+
* never be undone by this tab, and deletion is never inferred from a provider's absence.
|
|
61
|
+
*
|
|
62
|
+
* Both writes REJECT on failure and resolve the server's authoritative map afterward (markers only),
|
|
63
|
+
* like `saveMediaProviders`. `useMediaProvidersTab` still issues one write at a time.
|
|
64
|
+
*/
|
|
65
|
+
export interface MediaProviderRowsPort {
|
|
66
|
+
/** Same contract as {@link MediaProvidersPort.fetchMediaProviders}, including `null` for unreachable. */
|
|
67
|
+
fetchMediaProviders(): Promise<MediaProviderMap | null>;
|
|
68
|
+
applyProviderChanges(required: {
|
|
69
|
+
removes: readonly string[];
|
|
70
|
+
patches: readonly {
|
|
71
|
+
providerId: string;
|
|
72
|
+
fields: MediaProviderFields;
|
|
73
|
+
}[];
|
|
74
|
+
}, optional?: Record<string, never>): Promise<MediaProviderMap>;
|
|
75
|
+
/** Merges `fields` into one provider's stored credentials; no other provider is touched. */
|
|
76
|
+
patchProvider(required: {
|
|
77
|
+
providerId: string;
|
|
78
|
+
fields: MediaProviderFields;
|
|
79
|
+
}, optional?: Record<string, never>): Promise<MediaProviderMap>;
|
|
80
|
+
/** Deletes exactly one provider's stored credentials. */
|
|
81
|
+
removeProvider(required: {
|
|
82
|
+
providerId: string;
|
|
83
|
+
}, optional?: Record<string, never>): Promise<MediaProviderMap>;
|
|
84
|
+
}
|
|
85
|
+
/** Either transport the media-providers tab can drive. */
|
|
86
|
+
export type AnyMediaProvidersPort = MediaProvidersPort | MediaProviderRowsPort;
|
|
53
87
|
//# sourceMappingURL=ports.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useT } from '../../../i18n/index.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AnyMediaProvidersPort, MediaProviderCatalogPolicy } from '../../ports.js';
|
|
3
3
|
import type { MediaProviderMap, MediaProviderOption } from '../../types.js';
|
|
4
4
|
import { useMediaProvidersTab } from '../hooks/useMediaProvidersTab.js';
|
|
5
5
|
import { useMediaProviderKeyVisibility } from './MediaProvidersTab.hooks.js';
|
|
@@ -34,7 +34,8 @@ export interface MediaProvidersTabLabels {
|
|
|
34
34
|
saveErrorLabel?: string;
|
|
35
35
|
}
|
|
36
36
|
export interface MediaProvidersTabProps {
|
|
37
|
-
|
|
37
|
+
/** A whole-map `MediaProvidersPort` or a per-provider `MediaProviderRowsPort`. */
|
|
38
|
+
port: AnyMediaProvidersPort;
|
|
38
39
|
/** Host-owned provider catalog and its matching identity policy. */
|
|
39
40
|
catalog: readonly MediaProviderOption[];
|
|
40
41
|
catalogPolicy: MediaProviderCatalogPolicy;
|
|
@@ -51,7 +52,7 @@ export interface MediaProvidersTabProps {
|
|
|
51
52
|
* provider's own catalog id via `buildAgentListHandles`. */
|
|
52
53
|
agentHandle?: string;
|
|
53
54
|
useTHook?: typeof useT;
|
|
54
|
-
useMediaProvidersTabHook
|
|
55
|
+
useMediaProvidersTabHook: typeof useMediaProvidersTab;
|
|
55
56
|
useMediaProviderKeyVisibilityHook?: typeof useMediaProviderKeyVisibility;
|
|
56
57
|
}
|
|
57
58
|
/**
|