@jini-ai/ui 0.7.3-next.2 → 0.7.4
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 +7 -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 +5 -1
- package/dist/features/charts/table.js +4 -4
- 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/shadcn/checkbox-field.js +1 -1
- package/dist/features/interactive-ui/providers/shadcn/data-table.js +3 -3
- package/dist/features/interactive-ui/providers/shadcn/radio-group-field.js +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/fields.js +1 -2
- 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/Icon.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 +66 -9
- 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,19 @@
|
|
|
1
|
+
import type { FindQueryClock } from './find-query-scheduler.js';
|
|
2
|
+
/**
|
|
3
|
+
* The timing slice the find hooks drive: the clock their focus-reclaim window is measured on, the
|
|
4
|
+
* animation frames their per-frame reclaim runs on, and the timers behind both the deferred blur
|
|
5
|
+
* reclaim and the typing-settle scheduler. Injected so a test can step every one of them by hand;
|
|
6
|
+
* {@link liveFindClock} is the real browser wiring.
|
|
7
|
+
*/
|
|
8
|
+
export interface FindFocusClock extends FindQueryClock {
|
|
9
|
+
now: () => number;
|
|
10
|
+
requestFrame: (input: {
|
|
11
|
+
callback: () => void;
|
|
12
|
+
}) => number;
|
|
13
|
+
cancelFrame: (input: {
|
|
14
|
+
frame: number;
|
|
15
|
+
}) => void;
|
|
16
|
+
}
|
|
17
|
+
/** The window's own `performance`, animation-frame and timer functions. @complexity O(1). */
|
|
18
|
+
export declare const liveFindClock: FindFocusClock;
|
|
19
|
+
//# sourceMappingURL=find-focus-clock.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The window's own `performance`, animation-frame and timer functions. @complexity O(1). */
|
|
2
|
+
export const liveFindClock = {
|
|
3
|
+
now: () => performance.now(),
|
|
4
|
+
requestFrame: ({ callback }) => requestAnimationFrame(callback),
|
|
5
|
+
cancelFrame: ({ frame }) => cancelAnimationFrame(frame),
|
|
6
|
+
schedule: ({ callback, delay }, _options = {}) => setTimeout(callback, delay),
|
|
7
|
+
cancel: ({ timer }, _options = {}) => clearTimeout(timer),
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=find-focus-clock.js.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Puts focus back in the find input after ANY reported find result — every one of them means
|
|
3
|
+
* Chromium just moved keyboard focus somewhere else.
|
|
4
|
+
*
|
|
5
|
+
* `TextFinder::FindInternal` runs unconditionally on a match, whichever frame it is in:
|
|
6
|
+
* `ClearFocusedElement()` on the frame that was searched, then `SetFocusedFrame()` onto it. For a
|
|
7
|
+
* top-level match that blurs the find input, which lives in the same document. For a guest match
|
|
8
|
+
* it does the same to the GUEST frame, which — because a focused text input always holds a
|
|
9
|
+
* selection (a caret is one) — takes keyboard focus away from the host input the identical way.
|
|
10
|
+
* There is no way to keep focus through the search either way; it has to be restored after.
|
|
11
|
+
* Without this the bar accepts exactly one character and Enter reaches nobody.
|
|
12
|
+
*
|
|
13
|
+
* **`blur()` first, then `focus()` — a bare `focus()` is a no-op exactly when it matters.** After a
|
|
14
|
+
* guest match the host input is STILL this document's `activeElement` and `document.hasFocus()` is
|
|
15
|
+
* still `true`: Chromium moved the BROWSER's keyboard routing into the guest without telling this
|
|
16
|
+
* frame. `focus()` on an element Blink already considers focused changes nothing, so the browser
|
|
17
|
+
* never hears that this frame wants the keys back, and every later OS keystroke lands in the guest.
|
|
18
|
+
* Measured live with real OS keystrokes (the host's live find verifier's native-key phase):
|
|
19
|
+
* typing "the" left "t" in the bar; a `blur()`+`focus()` between keys let every one land. Playwright's
|
|
20
|
+
* `keyboard.type` never saw it — CDP delivers keys to the page it targets, not to wherever the
|
|
21
|
+
* browser's focus routing points — which is why the live verifier passed while the app was broken.
|
|
22
|
+
*
|
|
23
|
+
* The `blur()` fires this input's own `blur` event synchronously, which `useFindInputBinding`'s blur
|
|
24
|
+
* listener would otherwise read as another Chromium theft and answer with ANOTHER restore — a
|
|
25
|
+
* blur/focus loop for the whole {@link FIND_FOCUS_RECLAIM_MS} window. `restoring` is raised for
|
|
26
|
+
* exactly the duration of that `blur()` so the listener can ignore it.
|
|
27
|
+
*
|
|
28
|
+
* Not keyed on which target was asked, because that and where the result reports come apart: a
|
|
29
|
+
* guest's find is rerouted to the window's own find manager once that manager exists, and only
|
|
30
|
+
* then does the window report instead of the guest. Both sources took focus, so both call this —
|
|
31
|
+
* see {@link subscribeToFindResults}'s `onReported`.
|
|
32
|
+
*
|
|
33
|
+
* @complexity O(1).
|
|
34
|
+
*/
|
|
35
|
+
export declare function restoreFindInputFocus({ input }: {
|
|
36
|
+
input: {
|
|
37
|
+
blur(): void;
|
|
38
|
+
focus(): void;
|
|
39
|
+
} | null;
|
|
40
|
+
}, { restoring }?: {
|
|
41
|
+
restoring?: {
|
|
42
|
+
current: boolean;
|
|
43
|
+
};
|
|
44
|
+
}): void;
|
|
45
|
+
/** How long after ISSUING a find a blur on the find input is treated as Chromium's own focus
|
|
46
|
+
* theft rather than the user genuinely clicking away — see {@link shouldReclaimFindFocus}. */
|
|
47
|
+
export declare const FIND_FOCUS_RECLAIM_MS = 1000;
|
|
48
|
+
/**
|
|
49
|
+
* Whether a blur on the find input, while the bar is `open`, should be undone because it is
|
|
50
|
+
* almost certainly Chromium's `ClearFocusedElement`/`SetFocusedFrame` reaction to a find this file
|
|
51
|
+
* just issued — not the user clicking away. `false` once {@link FIND_FOCUS_RECLAIM_MS} has passed
|
|
52
|
+
* since the last issued find (a genuine click-away has to stick), `false` when no find has been
|
|
53
|
+
* issued yet (`lastFindAt: null`), and `false` when the bar is already closed.
|
|
54
|
+
*
|
|
55
|
+
* @complexity O(1).
|
|
56
|
+
*/
|
|
57
|
+
export declare function shouldReclaimFindFocus(input: {
|
|
58
|
+
open: boolean;
|
|
59
|
+
lastFindAt: number | null;
|
|
60
|
+
now: number;
|
|
61
|
+
}): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Whether `useFindFocusReclaim`'s per-frame reclaim should restore focus again on this animation frame.
|
|
64
|
+
*
|
|
65
|
+
* **Why every frame, and not just once per result.** Measured live with real OS keystrokes: the
|
|
66
|
+
* guest takes the keys the moment it selects its FIRST match, but its `found-in-page` only arrives
|
|
67
|
+
* once it has finished COUNTING every match — 100-600ms later on a real admin page. A key typed in
|
|
68
|
+
* that gap reaches the find input's `keydown` but its text is inserted into the guest instead, and
|
|
69
|
+
* nothing at all — no `blur`, no `focusout`, no `document.hasFocus()` change, no main-process
|
|
70
|
+
* `focus` event — fires on the host when the theft happens, so there is no signal to react to. The
|
|
71
|
+
* only thing that closes the gap is re-asserting focus on every frame from the moment a find is
|
|
72
|
+
* issued until it reports.
|
|
73
|
+
*
|
|
74
|
+
* `false` once the find has reported (`awaitingReport` — the report's own restore takes over),
|
|
75
|
+
* outside {@link shouldReclaimFindFocus}'s window, and during IME composition (`composing`): a
|
|
76
|
+
* `blur()` ends a composition, so reclaiming mid-composition would make the bar untypeable in any
|
|
77
|
+
* input method that composes.
|
|
78
|
+
*
|
|
79
|
+
* @complexity O(1).
|
|
80
|
+
*/
|
|
81
|
+
export declare function shouldKeepReclaimingFindFocus(input: {
|
|
82
|
+
open: boolean;
|
|
83
|
+
lastFindAt: number | null;
|
|
84
|
+
now: number;
|
|
85
|
+
awaitingReport: boolean;
|
|
86
|
+
composing: boolean;
|
|
87
|
+
}): boolean;
|
|
88
|
+
//# sourceMappingURL=find-input-focus.d.ts.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Puts focus back in the find input after ANY reported find result — every one of them means
|
|
3
|
+
* Chromium just moved keyboard focus somewhere else.
|
|
4
|
+
*
|
|
5
|
+
* `TextFinder::FindInternal` runs unconditionally on a match, whichever frame it is in:
|
|
6
|
+
* `ClearFocusedElement()` on the frame that was searched, then `SetFocusedFrame()` onto it. For a
|
|
7
|
+
* top-level match that blurs the find input, which lives in the same document. For a guest match
|
|
8
|
+
* it does the same to the GUEST frame, which — because a focused text input always holds a
|
|
9
|
+
* selection (a caret is one) — takes keyboard focus away from the host input the identical way.
|
|
10
|
+
* There is no way to keep focus through the search either way; it has to be restored after.
|
|
11
|
+
* Without this the bar accepts exactly one character and Enter reaches nobody.
|
|
12
|
+
*
|
|
13
|
+
* **`blur()` first, then `focus()` — a bare `focus()` is a no-op exactly when it matters.** After a
|
|
14
|
+
* guest match the host input is STILL this document's `activeElement` and `document.hasFocus()` is
|
|
15
|
+
* still `true`: Chromium moved the BROWSER's keyboard routing into the guest without telling this
|
|
16
|
+
* frame. `focus()` on an element Blink already considers focused changes nothing, so the browser
|
|
17
|
+
* never hears that this frame wants the keys back, and every later OS keystroke lands in the guest.
|
|
18
|
+
* Measured live with real OS keystrokes (the host's live find verifier's native-key phase):
|
|
19
|
+
* typing "the" left "t" in the bar; a `blur()`+`focus()` between keys let every one land. Playwright's
|
|
20
|
+
* `keyboard.type` never saw it — CDP delivers keys to the page it targets, not to wherever the
|
|
21
|
+
* browser's focus routing points — which is why the live verifier passed while the app was broken.
|
|
22
|
+
*
|
|
23
|
+
* The `blur()` fires this input's own `blur` event synchronously, which `useFindInputBinding`'s blur
|
|
24
|
+
* listener would otherwise read as another Chromium theft and answer with ANOTHER restore — a
|
|
25
|
+
* blur/focus loop for the whole {@link FIND_FOCUS_RECLAIM_MS} window. `restoring` is raised for
|
|
26
|
+
* exactly the duration of that `blur()` so the listener can ignore it.
|
|
27
|
+
*
|
|
28
|
+
* Not keyed on which target was asked, because that and where the result reports come apart: a
|
|
29
|
+
* guest's find is rerouted to the window's own find manager once that manager exists, and only
|
|
30
|
+
* then does the window report instead of the guest. Both sources took focus, so both call this —
|
|
31
|
+
* see {@link subscribeToFindResults}'s `onReported`.
|
|
32
|
+
*
|
|
33
|
+
* @complexity O(1).
|
|
34
|
+
*/
|
|
35
|
+
export function restoreFindInputFocus({ input }, { restoring = { current: false } } = {}) {
|
|
36
|
+
if (!input)
|
|
37
|
+
return;
|
|
38
|
+
restoring.current = true;
|
|
39
|
+
try {
|
|
40
|
+
input.blur();
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
restoring.current = false;
|
|
44
|
+
}
|
|
45
|
+
input.focus();
|
|
46
|
+
}
|
|
47
|
+
/** How long after ISSUING a find a blur on the find input is treated as Chromium's own focus
|
|
48
|
+
* theft rather than the user genuinely clicking away — see {@link shouldReclaimFindFocus}. */
|
|
49
|
+
export const FIND_FOCUS_RECLAIM_MS = 1000;
|
|
50
|
+
/**
|
|
51
|
+
* Whether a blur on the find input, while the bar is `open`, should be undone because it is
|
|
52
|
+
* almost certainly Chromium's `ClearFocusedElement`/`SetFocusedFrame` reaction to a find this file
|
|
53
|
+
* just issued — not the user clicking away. `false` once {@link FIND_FOCUS_RECLAIM_MS} has passed
|
|
54
|
+
* since the last issued find (a genuine click-away has to stick), `false` when no find has been
|
|
55
|
+
* issued yet (`lastFindAt: null`), and `false` when the bar is already closed.
|
|
56
|
+
*
|
|
57
|
+
* @complexity O(1).
|
|
58
|
+
*/
|
|
59
|
+
export function shouldReclaimFindFocus(input) {
|
|
60
|
+
if (!input.open || input.lastFindAt === null)
|
|
61
|
+
return false;
|
|
62
|
+
return input.now - input.lastFindAt < FIND_FOCUS_RECLAIM_MS;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Whether `useFindFocusReclaim`'s per-frame reclaim should restore focus again on this animation frame.
|
|
66
|
+
*
|
|
67
|
+
* **Why every frame, and not just once per result.** Measured live with real OS keystrokes: the
|
|
68
|
+
* guest takes the keys the moment it selects its FIRST match, but its `found-in-page` only arrives
|
|
69
|
+
* once it has finished COUNTING every match — 100-600ms later on a real admin page. A key typed in
|
|
70
|
+
* that gap reaches the find input's `keydown` but its text is inserted into the guest instead, and
|
|
71
|
+
* nothing at all — no `blur`, no `focusout`, no `document.hasFocus()` change, no main-process
|
|
72
|
+
* `focus` event — fires on the host when the theft happens, so there is no signal to react to. The
|
|
73
|
+
* only thing that closes the gap is re-asserting focus on every frame from the moment a find is
|
|
74
|
+
* issued until it reports.
|
|
75
|
+
*
|
|
76
|
+
* `false` once the find has reported (`awaitingReport` — the report's own restore takes over),
|
|
77
|
+
* outside {@link shouldReclaimFindFocus}'s window, and during IME composition (`composing`): a
|
|
78
|
+
* `blur()` ends a composition, so reclaiming mid-composition would make the bar untypeable in any
|
|
79
|
+
* input method that composes.
|
|
80
|
+
*
|
|
81
|
+
* @complexity O(1).
|
|
82
|
+
*/
|
|
83
|
+
export function shouldKeepReclaimingFindFocus(input) {
|
|
84
|
+
if (!input.awaitingReport || input.composing)
|
|
85
|
+
return false;
|
|
86
|
+
return shouldReclaimFindFocus(input);
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=find-input-focus.js.map
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { FindInPageResult } from '@jini-ai/core/contracts/find-in-page';
|
|
2
|
+
/** The slice of the DOM `Selection` API this file drives — see {@link runFind}. A fake of it is
|
|
3
|
+
* what tests pass. */
|
|
4
|
+
export type AnchorSelection = Pick<Selection, 'removeAllRanges'>;
|
|
5
|
+
/**
|
|
6
|
+
* This window's own document selection, or `null` where there is no DOM at all (this package's
|
|
7
|
+
* tests run on bare node — see this file's header). Only the top-level target needs it; a
|
|
8
|
+
* `<webview>` guest searches its OWN document, whose selection this one cannot touch.
|
|
9
|
+
*
|
|
10
|
+
* @complexity O(1).
|
|
11
|
+
*/
|
|
12
|
+
export declare function liveAnchorSelection(): AnchorSelection | null;
|
|
13
|
+
/** What a guest's `found-in-page` event carries. */
|
|
14
|
+
export interface FindableGuestFoundEvent {
|
|
15
|
+
readonly result: FindInPageResult;
|
|
16
|
+
}
|
|
17
|
+
/** The slice of Electron's `<webview>` this file drives, declared structurally so this package needs
|
|
18
|
+
* no Electron types; a real `<webview>` element satisfies it. A fake of it is what tests pass. */
|
|
19
|
+
export interface FindableGuest {
|
|
20
|
+
findInPage(text: string, options?: {
|
|
21
|
+
forward?: boolean;
|
|
22
|
+
findNext?: boolean;
|
|
23
|
+
}): unknown;
|
|
24
|
+
stopFindInPage(action: 'clearSelection' | 'keepSelection' | 'activateSelection'): void;
|
|
25
|
+
addEventListener(event: 'found-in-page', listener: (event: FindableGuestFoundEvent) => void): void;
|
|
26
|
+
removeEventListener(event: 'found-in-page', listener: (event: FindableGuestFoundEvent) => void): void;
|
|
27
|
+
}
|
|
28
|
+
/** The host's find bridge to the window's own top-level page (its preload bridge, absent outside a
|
|
29
|
+
* real desktop window). The host owns the channel names behind it. */
|
|
30
|
+
export interface FindBridge {
|
|
31
|
+
/** The app menu's Find (Cmd+F) fired. Returns an unsubscribe. */
|
|
32
|
+
onFindToggle: (required: {
|
|
33
|
+
listener: () => void;
|
|
34
|
+
}, options?: {}) => () => void;
|
|
35
|
+
findInPage: (query: {
|
|
36
|
+
text: string;
|
|
37
|
+
forward: boolean;
|
|
38
|
+
findNext: boolean;
|
|
39
|
+
}) => unknown;
|
|
40
|
+
stopFindInPage: () => unknown;
|
|
41
|
+
/** Every result the window's own `webContents` reports. Returns an unsubscribe. */
|
|
42
|
+
onFindResult: (required: {
|
|
43
|
+
listener: (result: FindInPageResult) => void;
|
|
44
|
+
}, options?: {}) => () => void;
|
|
45
|
+
}
|
|
46
|
+
/** Which surface a search should run against right now. */
|
|
47
|
+
export type FindTarget = {
|
|
48
|
+
kind: 'guest';
|
|
49
|
+
element: FindableGuest;
|
|
50
|
+
} | {
|
|
51
|
+
kind: 'top';
|
|
52
|
+
} | {
|
|
53
|
+
kind: 'none';
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Decides {@link FindTarget}: the visible project tab's guest when one is on screen and its element
|
|
57
|
+
* has actually mounted, otherwise the window's own top-level page — as long as a bridge exists to
|
|
58
|
+
* reach it (never true outside a real desktop window). `'none'` only when neither is available,
|
|
59
|
+
* which callers treat as an inert no-op rather than an error.
|
|
60
|
+
*
|
|
61
|
+
* @complexity O(1) — one `Map.get`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function resolveFindTarget(input: {
|
|
64
|
+
activeGuestId: string | null;
|
|
65
|
+
guests: ReadonlyMap<string, FindableGuest>;
|
|
66
|
+
bridge: FindBridge | undefined;
|
|
67
|
+
}): FindTarget;
|
|
68
|
+
/**
|
|
69
|
+
* Runs one `findInPage` request against `target`. A guest not yet attached throws from every
|
|
70
|
+
* method (as every other guest call does) — swallowed here because there is
|
|
71
|
+
* nothing to recover: the next query change or keypress tries again against whatever is mounted by
|
|
72
|
+
* then.
|
|
73
|
+
*
|
|
74
|
+
* **The top-level target must have NO document selection when Chromium reads it, so the search
|
|
75
|
+
* ANCHORS on the previous match instead of the find bar itself.** The find bar's input lives in
|
|
76
|
+
* the very document that target searches, so a caret sitting in it IS this frame's selection, and
|
|
77
|
+
* Chromium's find takes a live selection as the search's anchor. Left in place, every search
|
|
78
|
+
* re-resolved from the find bar's own position in the DOM instead of advancing past the previous
|
|
79
|
+
* match, so Enter appeared to do nothing. Clearing the selection ourselves first leaves Chromium
|
|
80
|
+
* continuing from the previous match instead. This is NOT what causes the focus loss — that is
|
|
81
|
+
* `ClearFocusedElement()`/`SetFocusedFrame()`, which Chromium runs unconditionally on every match
|
|
82
|
+
* regardless of any selection; see this file's header and {@link restoreFindInputFocus}. Only the
|
|
83
|
+
* `top` target needs the selection clear: a guest searches its own document, which this one's
|
|
84
|
+
* selection has no bearing on.
|
|
85
|
+
*
|
|
86
|
+
* @param input.options.findNext Electron's own meaning, not the button's: `true` begins a NEW session
|
|
87
|
+
* (pass it for a query CHANGE), `false` is a follow-up within the current one (pass it for
|
|
88
|
+
* Enter/Shift+Enter). See this file's own header.
|
|
89
|
+
* @param options.selection this window's own selection; defaults to the live one, so no call site can
|
|
90
|
+
* forget it. Tests pass a fake to assert it is cleared BEFORE the search, which is the whole
|
|
91
|
+
* point — a selection still standing when Chromium reads it is the bug.
|
|
92
|
+
* @complexity O(1) beyond Chromium's own search cost.
|
|
93
|
+
*/
|
|
94
|
+
export declare function runFind({ target, bridge, text, options }: {
|
|
95
|
+
target: FindTarget;
|
|
96
|
+
bridge: FindBridge | undefined;
|
|
97
|
+
text: string;
|
|
98
|
+
options: {
|
|
99
|
+
forward: boolean;
|
|
100
|
+
findNext: boolean;
|
|
101
|
+
};
|
|
102
|
+
}, { selection }?: {
|
|
103
|
+
selection?: AnchorSelection | null;
|
|
104
|
+
}): void;
|
|
105
|
+
/**
|
|
106
|
+
* Stops any in-flight search on `target` and clears its highlights. Same not-attached-yet tolerance
|
|
107
|
+
* as {@link runFind}.
|
|
108
|
+
*
|
|
109
|
+
* @complexity O(1).
|
|
110
|
+
*/
|
|
111
|
+
export declare function stopFind({ target, bridge }: {
|
|
112
|
+
target: FindTarget;
|
|
113
|
+
bridge: FindBridge | undefined;
|
|
114
|
+
}, _options?: Record<string, never>): void;
|
|
115
|
+
/**
|
|
116
|
+
* Subscribes to every source that could report the search running against `target`, and hands back
|
|
117
|
+
* one unsubscribe for all of them.
|
|
118
|
+
*
|
|
119
|
+
* The WINDOW's own results are subscribed for every target, not just `top`: Chromium serves a
|
|
120
|
+
* guest's find from the window's find manager once that manager exists, and then the guest's own
|
|
121
|
+
* `found-in-page` never fires (see this file's header). A guest target subscribes to BOTH, because
|
|
122
|
+
* which one reports is Chromium's choice and not observable from here.
|
|
123
|
+
*
|
|
124
|
+
* @param input.handlers.onResult every reported result, whichever source carried it.
|
|
125
|
+
* @param input.handlers.onReported called first, for EVERY reported result whichever source carried
|
|
126
|
+
* it — Chromium moves keyboard focus for a guest match exactly as it does for a top-level one
|
|
127
|
+
* (`ClearFocusedElement`/`SetFocusedFrame`), so both sources need the same restore. See
|
|
128
|
+
* {@link restoreFindInputFocus}.
|
|
129
|
+
* @complexity O(1); at most two listeners, both removed by the returned cleanup.
|
|
130
|
+
*/
|
|
131
|
+
export declare function subscribeToFindResults({ target, bridge, handlers }: {
|
|
132
|
+
target: FindTarget;
|
|
133
|
+
bridge: FindBridge | undefined;
|
|
134
|
+
handlers: {
|
|
135
|
+
onResult: (input: {
|
|
136
|
+
result: FindInPageResult;
|
|
137
|
+
}) => void;
|
|
138
|
+
onReported: () => void;
|
|
139
|
+
};
|
|
140
|
+
}, _options?: Record<string, never>): () => void;
|
|
141
|
+
//# sourceMappingURL=find-target.d.ts.map
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Routing a find-in-page search to whichever surface is actually on screen, and collecting
|
|
3
|
+
* the match counter ("3 of 17") that surface reports back.
|
|
4
|
+
*
|
|
5
|
+
* **Two different targets, two different mechanisms.** When an embedded `<webview>` guest is the
|
|
6
|
+
* visible surface, it is the target, and Electron's `WebviewTag` exposes `findInPage`/
|
|
7
|
+
* `stopFindInPage` and a `found-in-page` event directly on that DOM element — no IPC needed, the
|
|
8
|
+
* renderer already holds the node (the host registers it through `useFindBarState`'s
|
|
9
|
+
* `registerGuest`). When no guest is on screen, there is no such element for the window's OWN
|
|
10
|
+
* top-level content — `webContents` is main-process-only — so that target goes through the host's
|
|
11
|
+
* {@link FindBridge} instead. {@link resolveFindTarget} is the one place that decides which.
|
|
12
|
+
*
|
|
13
|
+
* **The top-level target searches the document the find bar is IN, so the bar's own caret is in the
|
|
14
|
+
* way as a search ANCHOR — not, it turns out, as the cause of the focus loss below.** Chromium
|
|
15
|
+
* anchors a find on the frame's live selection when there is one; with a caret sitting in the find
|
|
16
|
+
* input, every search re-anchored on the bar's own position instead of advancing past the previous
|
|
17
|
+
* match, so Enter appeared to do nothing. {@link runFind} clears the selection itself, first.
|
|
18
|
+
*
|
|
19
|
+
* **Every match steals keyboard focus, and that is `TextFinder::FindInternal`'s own doing, not a
|
|
20
|
+
* side effect of clearing the selection.** Chromium's finder runs `ClearFocusedElement()` then
|
|
21
|
+
* `SetFocusedFrame()` on the searched frame unconditionally, on every match, whichever target. For
|
|
22
|
+
* a top-level match that blurs the find input, which lives in the very document being searched. For
|
|
23
|
+
* a guest match it moves keyboard focus into the GUEST frame instead — same mechanism, same result:
|
|
24
|
+
* the host input loses focus. {@link restoreFindInputFocus} restores it after.
|
|
25
|
+
*
|
|
26
|
+
* **A guest's find does not always stay in the guest, and that is Chromium's doing, not ours.**
|
|
27
|
+
* `WebContents::GetFindRequestManager` walks UP the outer-WebContents chain and reuses the first
|
|
28
|
+
* manager it finds. A `<webview>` guest is an inner WebContents of the window, so the moment the
|
|
29
|
+
* window itself has run one find, every later guest find is served by the WINDOW's manager instead
|
|
30
|
+
* of the guest's own. Measured, not assumed: with a cold window the guest reports `1 of 98` on its
|
|
31
|
+
* own `found-in-page` and the window reports nothing; after a single `webContents.findInPage` on the
|
|
32
|
+
* window, the identical guest find reports on the WINDOW and the guest's event never fires. Nothing
|
|
33
|
+
* in the renderer can opt out, so this file tolerates both: {@link runFind} clears this frame's
|
|
34
|
+
* selection for either target, results are subscribed from both sources whenever a guest is the
|
|
35
|
+
* target, and focus is restored for EVERY reported result regardless of which source carried it —
|
|
36
|
+
* see {@link subscribeToFindResults}'s `onReported`.
|
|
37
|
+
*
|
|
38
|
+
* **`findNext`'s meaning is Electron's own, and it reads backwards.** `true` begins a NEW search
|
|
39
|
+
* session (the right value for a fresh or changed query); `false` is a follow-up within the current
|
|
40
|
+
* session (the right value for stepping to the next/previous match). See {@link runFind}.
|
|
41
|
+
*/
|
|
42
|
+
import { orFallbackSync } from '@jini-ai/core/errors/idioms';
|
|
43
|
+
/**
|
|
44
|
+
* This window's own document selection, or `null` where there is no DOM at all (this package's
|
|
45
|
+
* tests run on bare node — see this file's header). Only the top-level target needs it; a
|
|
46
|
+
* `<webview>` guest searches its OWN document, whose selection this one cannot touch.
|
|
47
|
+
*
|
|
48
|
+
* @complexity O(1).
|
|
49
|
+
*/
|
|
50
|
+
export function liveAnchorSelection() {
|
|
51
|
+
return typeof document === 'undefined' ? null : document.getSelection();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Decides {@link FindTarget}: the visible project tab's guest when one is on screen and its element
|
|
55
|
+
* has actually mounted, otherwise the window's own top-level page — as long as a bridge exists to
|
|
56
|
+
* reach it (never true outside a real desktop window). `'none'` only when neither is available,
|
|
57
|
+
* which callers treat as an inert no-op rather than an error.
|
|
58
|
+
*
|
|
59
|
+
* @complexity O(1) — one `Map.get`.
|
|
60
|
+
*/
|
|
61
|
+
export function resolveFindTarget(input) {
|
|
62
|
+
if (input.activeGuestId !== null) {
|
|
63
|
+
const element = input.guests.get(input.activeGuestId);
|
|
64
|
+
if (element)
|
|
65
|
+
return { kind: 'guest', element };
|
|
66
|
+
}
|
|
67
|
+
return input.bridge ? { kind: 'top' } : { kind: 'none' };
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Runs one `findInPage` request against `target`. A guest not yet attached throws from every
|
|
71
|
+
* method (as every other guest call does) — swallowed here because there is
|
|
72
|
+
* nothing to recover: the next query change or keypress tries again against whatever is mounted by
|
|
73
|
+
* then.
|
|
74
|
+
*
|
|
75
|
+
* **The top-level target must have NO document selection when Chromium reads it, so the search
|
|
76
|
+
* ANCHORS on the previous match instead of the find bar itself.** The find bar's input lives in
|
|
77
|
+
* the very document that target searches, so a caret sitting in it IS this frame's selection, and
|
|
78
|
+
* Chromium's find takes a live selection as the search's anchor. Left in place, every search
|
|
79
|
+
* re-resolved from the find bar's own position in the DOM instead of advancing past the previous
|
|
80
|
+
* match, so Enter appeared to do nothing. Clearing the selection ourselves first leaves Chromium
|
|
81
|
+
* continuing from the previous match instead. This is NOT what causes the focus loss — that is
|
|
82
|
+
* `ClearFocusedElement()`/`SetFocusedFrame()`, which Chromium runs unconditionally on every match
|
|
83
|
+
* regardless of any selection; see this file's header and {@link restoreFindInputFocus}. Only the
|
|
84
|
+
* `top` target needs the selection clear: a guest searches its own document, which this one's
|
|
85
|
+
* selection has no bearing on.
|
|
86
|
+
*
|
|
87
|
+
* @param input.options.findNext Electron's own meaning, not the button's: `true` begins a NEW session
|
|
88
|
+
* (pass it for a query CHANGE), `false` is a follow-up within the current one (pass it for
|
|
89
|
+
* Enter/Shift+Enter). See this file's own header.
|
|
90
|
+
* @param options.selection this window's own selection; defaults to the live one, so no call site can
|
|
91
|
+
* forget it. Tests pass a fake to assert it is cleared BEFORE the search, which is the whole
|
|
92
|
+
* point — a selection still standing when Chromium reads it is the bug.
|
|
93
|
+
* @complexity O(1) beyond Chromium's own search cost.
|
|
94
|
+
*/
|
|
95
|
+
export function runFind({ target, bridge, text, options }, { selection = liveAnchorSelection() } = {}) {
|
|
96
|
+
// Cleared before EITHER target's search, and only when one is actually issued. For `top` it is
|
|
97
|
+
// this frame's own search anchor (below). For a guest it is insurance that costs nothing:
|
|
98
|
+
// Chromium reroutes a guest's find to the WINDOW's find manager once that manager exists (see
|
|
99
|
+
// this file's header), and a rerouted search reads this frame's selection as its anchor after
|
|
100
|
+
// all. When it is not rerouted, the guest searches its own document and this clearing is inert.
|
|
101
|
+
if (target.kind === 'guest') {
|
|
102
|
+
selection?.removeAllRanges();
|
|
103
|
+
// Not attached yet — nothing to recover; see this function's own doc.
|
|
104
|
+
orFallbackSync({ work: () => target.element.findInPage(text, options), fallback: undefined, step: 'find in a guest not yet attached' });
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (target.kind === 'top' && bridge) {
|
|
108
|
+
selection?.removeAllRanges();
|
|
109
|
+
void bridge.findInPage({ text, ...options });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Stops any in-flight search on `target` and clears its highlights. Same not-attached-yet tolerance
|
|
114
|
+
* as {@link runFind}.
|
|
115
|
+
*
|
|
116
|
+
* @complexity O(1).
|
|
117
|
+
*/
|
|
118
|
+
export function stopFind({ target, bridge }, _options = {}) {
|
|
119
|
+
if (target.kind === 'guest') {
|
|
120
|
+
// Not attached yet — nothing to stop.
|
|
121
|
+
orFallbackSync({ work: () => target.element.stopFindInPage('clearSelection'), fallback: undefined, step: 'stop find in a guest not yet attached' });
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (target.kind === 'top')
|
|
125
|
+
void bridge?.stopFindInPage();
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Subscribes to every source that could report the search running against `target`, and hands back
|
|
129
|
+
* one unsubscribe for all of them.
|
|
130
|
+
*
|
|
131
|
+
* The WINDOW's own results are subscribed for every target, not just `top`: Chromium serves a
|
|
132
|
+
* guest's find from the window's find manager once that manager exists, and then the guest's own
|
|
133
|
+
* `found-in-page` never fires (see this file's header). A guest target subscribes to BOTH, because
|
|
134
|
+
* which one reports is Chromium's choice and not observable from here.
|
|
135
|
+
*
|
|
136
|
+
* @param input.handlers.onResult every reported result, whichever source carried it.
|
|
137
|
+
* @param input.handlers.onReported called first, for EVERY reported result whichever source carried
|
|
138
|
+
* it — Chromium moves keyboard focus for a guest match exactly as it does for a top-level one
|
|
139
|
+
* (`ClearFocusedElement`/`SetFocusedFrame`), so both sources need the same restore. See
|
|
140
|
+
* {@link restoreFindInputFocus}.
|
|
141
|
+
* @complexity O(1); at most two listeners, both removed by the returned cleanup.
|
|
142
|
+
*/
|
|
143
|
+
export function subscribeToFindResults({ target, bridge, handlers }, _options = {}) {
|
|
144
|
+
const unsubscribeWindow = bridge?.onFindResult({ listener: (result) => {
|
|
145
|
+
handlers.onReported();
|
|
146
|
+
handlers.onResult({ result });
|
|
147
|
+
} });
|
|
148
|
+
if (target.kind !== 'guest')
|
|
149
|
+
return () => unsubscribeWindow?.();
|
|
150
|
+
const onFound = (event) => {
|
|
151
|
+
handlers.onReported();
|
|
152
|
+
handlers.onResult({ result: event.result });
|
|
153
|
+
};
|
|
154
|
+
target.element.addEventListener('found-in-page', onFound);
|
|
155
|
+
return () => {
|
|
156
|
+
target.element.removeEventListener('found-in-page', onFound);
|
|
157
|
+
unsubscribeWindow?.();
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=find-target.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { createFindQueryScheduler, FIND_QUERY_SETTLE_MS, type FindQueryClock } from './find-query-scheduler.js';
|
|
2
|
+
export { findBarReducer, formatFindMatchCount, initialFindBarState, shouldCloseOnGuestChange, type FindBarAction, type FindBarState, type FindMatchCountLabels, } from './find-bar-state.js';
|
|
3
|
+
export { liveFindClock, type FindFocusClock } from './find-focus-clock.js';
|
|
4
|
+
export { FIND_FOCUS_RECLAIM_MS, restoreFindInputFocus, shouldKeepReclaimingFindFocus, shouldReclaimFindFocus } from './find-input-focus.js';
|
|
5
|
+
export { liveAnchorSelection, resolveFindTarget, runFind, stopFind, subscribeToFindResults, type AnchorSelection, type FindableGuest, type FindableGuestFoundEvent, type FindBridge, type FindTarget, } from './find-target.js';
|
|
6
|
+
export { useFindBarState, type UseFindBarStateOptions } from './use-find-bar-state.hooks.js';
|
|
7
|
+
export { useFindFocusReclaim } from './use-find-focus-reclaim.hooks.js';
|
|
8
|
+
export { useFindBarEffects } from './use-find-bar-effects.hooks.js';
|
|
9
|
+
export { useFindInputBinding } from './use-find-input-binding.hooks.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { createFindQueryScheduler, FIND_QUERY_SETTLE_MS } from './find-query-scheduler.js';
|
|
2
|
+
export { findBarReducer, formatFindMatchCount, initialFindBarState, shouldCloseOnGuestChange, } from './find-bar-state.js';
|
|
3
|
+
export { liveFindClock } from './find-focus-clock.js';
|
|
4
|
+
export { FIND_FOCUS_RECLAIM_MS, restoreFindInputFocus, shouldKeepReclaimingFindFocus, shouldReclaimFindFocus } from './find-input-focus.js';
|
|
5
|
+
export { liveAnchorSelection, resolveFindTarget, runFind, stopFind, subscribeToFindResults, } from './find-target.js';
|
|
6
|
+
export { useFindBarState } from './use-find-bar-state.hooks.js';
|
|
7
|
+
export { useFindFocusReclaim } from './use-find-focus-reclaim.hooks.js';
|
|
8
|
+
export { useFindBarEffects } from './use-find-bar-effects.hooks.js';
|
|
9
|
+
export { useFindInputBinding } from './use-find-input-binding.hooks.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type FindBridge } from './find-target.js';
|
|
2
|
+
import type { useFindBarState } from './use-find-bar-state.hooks.js';
|
|
3
|
+
import type { useFindFocusReclaim } from './use-find-focus-reclaim.hooks.js';
|
|
4
|
+
/**
|
|
5
|
+
* The find bar's effects: opening on the bridge's Cmd+F, focusing the input on every open, the result
|
|
6
|
+
* subscription, the typing-settled search, and closing when the visible surface changes.
|
|
7
|
+
*
|
|
8
|
+
* @complexity O(1) per effect run, beyond `runFind`/`stopFind`'s own cost.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useFindBarEffects({ bridge, dispatch, state, inputElement, restoringFocus, target, awaitingReport, composing, activeGuestId, queryScheduler, cancelReclaimFrame, issueFind, guests, }: Pick<ReturnType<typeof useFindBarState>, "dispatch" | "state" | "inputElement" | "restoringFocus" | "target" | "awaitingReport" | "composing" | "queryScheduler" | "guests"> & Pick<ReturnType<typeof useFindFocusReclaim>, "cancelReclaimFrame" | "issueFind"> & {
|
|
11
|
+
activeGuestId: string | null;
|
|
12
|
+
bridge: FindBridge | undefined;
|
|
13
|
+
}, _optional?: {}): void;
|
|
14
|
+
//# sourceMappingURL=use-find-bar-effects.hooks.d.ts.map
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { resolveFindTarget, stopFind, subscribeToFindResults } from './find-target.js';
|
|
3
|
+
import { restoreFindInputFocus } from './find-input-focus.js';
|
|
4
|
+
import { shouldCloseOnGuestChange } from './find-bar-state.js';
|
|
5
|
+
/**
|
|
6
|
+
* The find bar's effects: opening on the bridge's Cmd+F, focusing the input on every open, the result
|
|
7
|
+
* subscription, the typing-settled search, and closing when the visible surface changes.
|
|
8
|
+
*
|
|
9
|
+
* @complexity O(1) per effect run, beyond `runFind`/`stopFind`'s own cost.
|
|
10
|
+
*/
|
|
11
|
+
export function useFindBarEffects({ bridge, dispatch, state, inputElement, restoringFocus, target, awaitingReport, composing, activeGuestId, queryScheduler, cancelReclaimFrame, issueFind, guests, }, _optional = {}) {
|
|
12
|
+
// The app menu's Find (Cmd+F): open (or, if already open, bump `focusNonce` so the effect below
|
|
13
|
+
// refocuses even though `open` itself does not change).
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!bridge)
|
|
16
|
+
return undefined;
|
|
17
|
+
return bridge.onFindToggle({ listener: () => dispatch({ type: 'toggle' }) });
|
|
18
|
+
}, [bridge]);
|
|
19
|
+
// Focuses and selects the input every time the bar opens OR is re-summoned while already open —
|
|
20
|
+
// matching Chrome's own Cmd+F, which reselects the existing query for a fast re-type.
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (!state.open)
|
|
23
|
+
return;
|
|
24
|
+
// blur()+focus(), not a bare focus(): Cmd+F pressed while typing in the guest leaves the browser
|
|
25
|
+
// routing keys into the guest, and on a re-summon the input is already this document's
|
|
26
|
+
// activeElement — a bare focus() is then a no-op the browser never hears about. See
|
|
27
|
+
// {@link restoreFindInputFocus}.
|
|
28
|
+
restoreFindInputFocus({ input: inputElement.current }, { restoring: restoringFocus });
|
|
29
|
+
inputElement.current?.select();
|
|
30
|
+
}, [state.open, state.focusNonce]);
|
|
31
|
+
// Subscribes to results from whichever target is live, only while the bar is open — an empty
|
|
32
|
+
// query never subscribes at all (see the early return), matching `runFind`'s own stop-not-search.
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!state.open || state.query === '')
|
|
35
|
+
return undefined;
|
|
36
|
+
return subscribeToFindResults({ target, bridge, handlers: {
|
|
37
|
+
onReported: () => {
|
|
38
|
+
awaitingReport.current = false;
|
|
39
|
+
if (!composing.current)
|
|
40
|
+
restoreFindInputFocus({ input: inputElement.current }, { restoring: restoringFocus });
|
|
41
|
+
},
|
|
42
|
+
onResult: ({ result }) => dispatch({ type: 'result', result }),
|
|
43
|
+
} });
|
|
44
|
+
// `target` is a fresh object every render (`resolveFindTarget` builds one), so this depends on
|
|
45
|
+
// its STABLE identity components instead — the guest map is a ref (never itself a dependency
|
|
46
|
+
// trigger) and `activeGuestId` is what actually changes which entry it names.
|
|
47
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: depends on target's stable inputs (activeGuestId, bridge), not the fresh `target` object itself — see the comment above.
|
|
48
|
+
}, [state.open, state.query === '', activeGuestId, bridge]);
|
|
49
|
+
// A query change — including the FIRST non-empty character — is a NEW search session
|
|
50
|
+
// (`findNext: true`, per `find-target.ts`'s header); clearing back to '' stops it instead of searching
|
|
51
|
+
// for nothing.
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
queryScheduler.cancel();
|
|
54
|
+
if (!state.open)
|
|
55
|
+
return undefined;
|
|
56
|
+
if (state.query === '') {
|
|
57
|
+
awaitingReport.current = false;
|
|
58
|
+
cancelReclaimFrame();
|
|
59
|
+
stopFind({ target, bridge });
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const run = () => {
|
|
63
|
+
// Blurring during an IME composition would discard the text still being composed.
|
|
64
|
+
if (composing.current) {
|
|
65
|
+
queryScheduler.schedule({ run });
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
issueFind(state.query, { forward: true, findNext: true });
|
|
69
|
+
};
|
|
70
|
+
queryScheduler.schedule({ run });
|
|
71
|
+
return () => queryScheduler.cancel();
|
|
72
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: depends on target's stable inputs (activeGuestId), not the fresh `target`/`bridge` objects themselves.
|
|
73
|
+
}, [state.query, state.open, activeGuestId]);
|
|
74
|
+
// Closes (and clears the OUTGOING surface's own highlights) on a tab switch while the bar is
|
|
75
|
+
// open — known rough edge until now: switching tabs left the bar open, still showing the
|
|
76
|
+
// previous tab's stale query/count, and never cleared that tab's own highlight because nothing
|
|
77
|
+
// called `stopFind` for it once it went off screen. Mirrors the identical class of problem
|
|
78
|
+
// a collapse-on-workspace-change rule solves. `previousGuestIdRef` — not `target` — resolves the OUTGOING guest: by the
|
|
79
|
+
// time this effect runs post-commit, `activeGuestId` (and therefore `target`) already point at
|
|
80
|
+
// the NEW surface.
|
|
81
|
+
const previousGuestIdRef = useRef(activeGuestId);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (shouldCloseOnGuestChange({ previousGuestId: previousGuestIdRef.current, activeGuestId, open: state.open })) {
|
|
84
|
+
const outgoing = resolveFindTarget({ activeGuestId: previousGuestIdRef.current, guests, bridge });
|
|
85
|
+
stopFind({ target: outgoing, bridge });
|
|
86
|
+
dispatch({ type: 'close' });
|
|
87
|
+
}
|
|
88
|
+
previousGuestIdRef.current = activeGuestId;
|
|
89
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: keys on activeGuestId's stable identity only, matching this file's other target-derived effects above.
|
|
90
|
+
}, [activeGuestId]);
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=use-find-bar-effects.hooks.js.map
|