gloomberb 0.7.5 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -6
- package/package.json +2 -3
- package/src/api-client/auth.ts +167 -0
- package/src/api-client/chat.ts +116 -0
- package/src/api-client/data.ts +177 -0
- package/src/api-client/errors.ts +28 -0
- package/src/api-client/index.test.ts +675 -0
- package/src/api-client/index.ts +384 -0
- package/src/api-client/normalizers.ts +61 -0
- package/src/api-client/paths.ts +173 -0
- package/src/api-client/request.ts +124 -0
- package/src/api-client/socket.ts +483 -0
- package/src/api-client/types.ts +490 -0
- package/src/app/app-bootstrap-state.test.ts +157 -0
- package/src/app/app-bootstrap-state.ts +134 -0
- package/src/app/global-shortcuts.test.tsx +166 -0
- package/src/app/global-shortcuts.ts +126 -0
- package/src/app/pane-runtime/index.tsx +297 -0
- package/src/app/pane-runtime/layout-placement.ts +73 -0
- package/src/app/pane-runtime/pane-settings-runtime.tsx +67 -0
- package/src/app/pane-runtime/pane-template-runtime.ts +110 -0
- package/src/app/pane-runtime/plugin-bindings.ts +231 -0
- package/src/app/pane-runtime/ticker-inspector-runtime.ts +167 -0
- package/src/app/pane-runtime/ticker-open-runtime.ts +144 -0
- package/src/app/pane-template-dialog-wizard.tsx +52 -0
- package/src/app/runtime/broker-import.ts +109 -0
- package/src/app/runtime/desktop-menu.ts +74 -0
- package/src/app/runtime/plugin-bindings.ts +246 -0
- package/src/app/runtime/startup.ts +126 -0
- package/src/app/runtime/ticker-refresh.ts +249 -0
- package/src/app/runtime/update.ts +86 -0
- package/src/app.tsx +107 -1487
- package/src/brokers/broker-portfolio-sync.ts +186 -0
- package/src/brokers/broker-ticker-sync.ts +141 -0
- package/src/brokers/profile-form.ts +2 -2
- package/src/brokers/remote-broker-adapter.ts +3 -2
- package/src/brokers/sync-broker-instance.test.ts +140 -0
- package/src/brokers/sync-broker-instance.ts +60 -181
- package/src/capabilities/types.ts +4 -4
- package/src/cli/commands/search.ts +1 -1
- package/src/cli/commands/ticker.ts +3 -3
- package/src/cli/context.ts +1 -1
- package/src/cli/desktop-pane-shot.ts +305 -0
- package/src/cli/helpers.ts +1 -1
- package/src/cli/index.ts +34 -0
- package/src/cli/pane-functions/catalog.ts +243 -0
- package/src/cli/pane-functions/data.ts +78 -0
- package/src/cli/pane-functions/discovery.ts +113 -0
- package/src/cli/pane-functions/index.test.ts +114 -0
- package/src/cli/pane-functions/index.ts +112 -0
- package/src/cli/pane-functions/options.ts +249 -0
- package/src/cli/pane-functions/report.ts +180 -0
- package/src/cli/pane-functions/resolver.ts +96 -0
- package/src/cli/pane-functions/screenshot.ts +113 -0
- package/src/cli/registry.ts +3 -2
- package/src/cli/ticker-resolution.ts +1 -1
- package/src/cli.test.ts +1 -1
- package/src/components/chart/bar-chart-renderer.test.ts +53 -0
- package/src/components/chart/bar-chart-renderer.ts +190 -0
- package/src/components/chart/comparison/data.test.ts +105 -0
- package/src/components/chart/comparison/data.ts +279 -0
- package/src/components/chart/comparison/renderer.test.ts +187 -0
- package/src/components/chart/comparison/renderer.ts +283 -0
- package/src/components/chart/comparison/scene.ts +178 -0
- package/src/components/chart/comparison-stock-chart/axis-width.ts +99 -0
- package/src/components/chart/comparison-stock-chart/canvas.ts +148 -0
- package/src/components/chart/comparison-stock-chart/controls.ts +252 -0
- package/src/components/chart/comparison-stock-chart/helpers.ts +133 -0
- package/src/components/chart/comparison-stock-chart/interactions.ts +202 -0
- package/src/components/chart/comparison-stock-chart/layout-metrics.ts +62 -0
- package/src/components/chart/comparison-stock-chart/layout.tsx +155 -0
- package/src/components/chart/comparison-stock-chart/legend.tsx +73 -0
- package/src/components/chart/comparison-stock-chart/native-surfaces.ts +89 -0
- package/src/components/chart/comparison-stock-chart/render-data.ts +198 -0
- package/src/components/chart/comparison-stock-chart/render-output.ts +145 -0
- package/src/components/chart/comparison-stock-chart/selection-runtime.ts +111 -0
- package/src/components/chart/comparison-stock-chart/sources.ts +47 -0
- package/src/components/chart/comparison-stock-chart/surface-runtime.ts +159 -0
- package/src/components/chart/comparison-stock-chart/toolbar.tsx +107 -0
- package/src/components/chart/comparison-stock-chart/types.ts +22 -0
- package/src/components/chart/comparison-stock-chart/view.tsx +524 -0
- package/src/components/chart/comparison-stock-chart/viewport-runtime.ts +239 -0
- package/src/components/chart/comparison-stock-chart.tsx +12 -2028
- package/src/components/chart/core/axis-format.ts +147 -0
- package/src/components/chart/core/axis-measure.ts +33 -0
- package/src/components/chart/core/controller.test.ts +157 -0
- package/src/components/chart/core/controller.ts +349 -0
- package/src/components/chart/core/data.ts +94 -0
- package/src/components/chart/core/date-window.ts +392 -0
- package/src/components/chart/core/index.test.ts +1007 -0
- package/src/components/chart/core/indicator-selector.tsx +75 -0
- package/src/components/chart/core/keyboard.ts +15 -0
- package/src/components/chart/core/palette.ts +60 -0
- package/src/components/chart/core/pane-settings.test.ts +25 -0
- package/src/components/chart/core/pane-settings.ts +82 -0
- package/src/components/chart/core/pointer.ts +292 -0
- package/src/components/chart/core/projection.ts +333 -0
- package/src/components/chart/core/render-utils.ts +4 -0
- package/src/components/chart/core/renderer.ts +249 -0
- package/src/components/chart/core/resolution.test.ts +99 -0
- package/src/components/chart/core/resolution.ts +380 -0
- package/src/components/chart/core/scene.ts +180 -0
- package/src/components/chart/core/scroll.test.ts +70 -0
- package/src/components/chart/core/scroll.ts +104 -0
- package/src/components/chart/core/time-axis.ts +330 -0
- package/src/components/chart/core/types.ts +124 -0
- package/src/components/chart/core/viewport.test.ts +29 -0
- package/src/components/chart/core/viewport.ts +51 -0
- package/src/components/chart/core/window-viewport.test.ts +69 -0
- package/src/components/chart/core/window-viewport.ts +162 -0
- package/src/components/chart/display-cursor.ts +153 -0
- package/src/components/chart/market-session.ts +1 -1
- package/src/components/chart/multi-line/renderer.test.ts +83 -0
- package/src/components/chart/multi-line/renderer.ts +160 -0
- package/src/components/chart/multi-line/scene.ts +188 -0
- package/src/components/chart/native/canvas-bitmaps.ts +140 -0
- package/src/components/chart/native/chart-rasterizer.ts +18 -865
- package/src/components/chart/native/kitty/adapter.ts +9 -0
- package/src/components/chart/native/kitty/index.test.ts +752 -0
- package/src/components/chart/native/kitty/manager.ts +142 -0
- package/src/components/chart/native/kitty/support.ts +70 -0
- package/src/components/chart/native/raster/comparison-chart.ts +162 -0
- package/src/components/chart/native/raster/crosshair.ts +51 -0
- package/src/components/chart/native/raster/layout.ts +136 -0
- package/src/components/chart/native/raster/placement.ts +132 -0
- package/src/components/chart/native/raster/price-chart.ts +244 -0
- package/src/components/chart/native/raster/primitives.ts +154 -0
- package/src/components/chart/native/raster/types.ts +41 -0
- package/src/components/chart/native/renderer-selection.ts +81 -1
- package/src/components/chart/native/surface/hooks.ts +137 -0
- package/src/components/chart/native/surface/manager.ts +225 -0
- package/src/components/chart/native/surface/rendering.ts +211 -0
- package/src/components/chart/native/surface/sync.ts +34 -0
- package/src/components/chart/native/surface/visibility.ts +48 -0
- package/src/components/chart/price-axis-labels.tsx +4 -4
- package/src/components/chart/rendering/chart-draw.ts +270 -0
- package/src/components/chart/rendering/geometry.ts +95 -0
- package/src/components/chart/rendering/pixel-buffer.ts +267 -0
- package/src/components/chart/scatter-chart-renderer.test.ts +31 -0
- package/src/components/chart/scatter-chart-renderer.ts +223 -0
- package/src/components/chart/static/bar-chart-surface.tsx +85 -0
- package/src/components/chart/static/chart/bitmap.ts +50 -0
- package/src/components/chart/static/chart/surface.test.tsx +51 -0
- package/src/components/chart/static/chart/surface.tsx +181 -0
- package/src/components/chart/static/multi-line-chart-surface.tsx +180 -0
- package/src/components/chart/static/scatter-chart-surface.tsx +83 -0
- package/src/components/chart/stock-chart/auto.ts +216 -0
- package/src/components/chart/stock-chart/axis-width.ts +146 -0
- package/src/components/chart/stock-chart/bitmaps.ts +22 -0
- package/src/components/chart/stock-chart/canvas.ts +202 -0
- package/src/components/chart/stock-chart/controls.tsx +149 -0
- package/src/components/chart/stock-chart/cursor.ts +60 -0
- package/src/components/chart/stock-chart/data-runtime.ts +129 -0
- package/src/components/chart/stock-chart/footer.ts +248 -0
- package/src/components/chart/stock-chart/geometry.ts +160 -0
- package/src/components/chart/stock-chart/index.test.ts +500 -0
- package/src/components/chart/stock-chart/index.tsx +29 -0
- package/src/components/chart/stock-chart/indicators.ts +226 -0
- package/src/components/chart/stock-chart/interaction-runtime.ts +44 -0
- package/src/components/chart/stock-chart/interactions.ts +300 -0
- package/src/components/chart/stock-chart/keyboard.ts +373 -0
- package/src/components/chart/stock-chart/layout-metrics.ts +62 -0
- package/src/components/chart/stock-chart/layout.tsx +177 -0
- package/src/components/chart/stock-chart/native-surfaces.ts +121 -0
- package/src/components/chart/stock-chart/presentation.ts +67 -0
- package/src/components/chart/stock-chart/renderer-switch.test.tsx +263 -0
- package/src/components/chart/stock-chart/rendering/bounds.ts +116 -0
- package/src/components/chart/stock-chart/rendering/candidates.ts +145 -0
- package/src/components/chart/stock-chart/rendering/data.ts +370 -0
- package/src/components/chart/stock-chart/rendering/invalidation.ts +68 -0
- package/src/components/chart/stock-chart/rendering/output.ts +304 -0
- package/src/components/chart/stock-chart/rendering/planning.ts +122 -0
- package/src/components/chart/stock-chart/rendering/projection.test.tsx +98 -0
- package/src/components/chart/stock-chart/rendering/projection.ts +112 -0
- package/src/components/chart/stock-chart/rendering/state.test.ts +70 -0
- package/src/components/chart/stock-chart/rendering/state.ts +283 -0
- package/src/components/chart/stock-chart/requests.ts +337 -0
- package/src/components/chart/stock-chart/resolution-support.ts +96 -0
- package/src/components/chart/stock-chart/resolved/runtime.ts +289 -0
- package/src/components/chart/stock-chart/resolved.tsx +345 -0
- package/src/components/chart/stock-chart/settings.ts +77 -0
- package/src/components/chart/stock-chart/surface-runtime.ts +62 -0
- package/src/components/chart/stock-chart/types.ts +25 -0
- package/src/components/chart/stock-chart/view.tsx +155 -0
- package/src/components/chart/stock-chart/viewport/effects.ts +296 -0
- package/src/components/chart/stock-chart/viewport/index.ts +144 -0
- package/src/components/chart/stock-chart/viewport/runtime.ts +375 -0
- package/src/components/chart/time-axis-label.tsx +4 -3
- package/src/components/command-bar/action-runtime.ts +326 -0
- package/src/components/command-bar/commands/collection.ts +214 -0
- package/src/components/command-bar/commands/direct/index.ts +266 -0
- package/src/components/command-bar/commands/direct/runtime.ts +168 -0
- package/src/components/command-bar/commands/plugin/actions.ts +171 -0
- package/src/components/command-bar/commands/plugin/items.ts +166 -0
- package/src/components/command-bar/commands/registry.ts +263 -0
- package/src/components/command-bar/helpers.test.ts +13 -21
- package/src/components/command-bar/helpers.ts +51 -272
- package/src/components/command-bar/keyboard-handlers.ts +306 -0
- package/src/components/command-bar/keyboard-shortcuts.ts +204 -0
- package/src/components/command-bar/layout-items/current-layout.ts +120 -0
- package/src/components/command-bar/layout-items/focused-pane.ts +143 -0
- package/src/components/command-bar/layout-items/types.ts +25 -0
- package/src/components/command-bar/layout-items/window-mode.ts +72 -0
- package/src/components/command-bar/layout-items.ts +93 -0
- package/src/components/command-bar/list/model.ts +81 -0
- package/src/components/command-bar/list/navigation.ts +125 -0
- package/src/components/command-bar/list/view.tsx +316 -0
- package/src/components/command-bar/multi-select-picker.tsx +219 -0
- package/src/components/command-bar/multi-select-runtime.ts +91 -0
- package/src/components/command-bar/pane-actions.ts +124 -0
- package/src/components/command-bar/pane-settings.ts +227 -0
- package/src/components/command-bar/pane-templates/items.ts +203 -0
- package/src/components/command-bar/pane-templates/workflow-route.ts +81 -0
- package/src/components/command-bar/pane-templates/workflow.ts +282 -0
- package/src/components/command-bar/panel/body.tsx +311 -0
- package/src/components/command-bar/panel/index.tsx +196 -0
- package/src/components/command-bar/panel/layout.ts +117 -0
- package/src/components/command-bar/panel/runtime.ts +280 -0
- package/src/components/command-bar/panel/state.ts +138 -0
- package/src/components/command-bar/panel/types.ts +78 -0
- package/src/components/command-bar/picker-activation.ts +126 -0
- package/src/components/command-bar/routes/root/command-items.ts +176 -0
- package/src/components/command-bar/routes/root/provider-search.ts +200 -0
- package/src/components/command-bar/routes/root/results.ts +233 -0
- package/src/components/command-bar/routes/root/runtime.ts +315 -0
- package/src/components/command-bar/routes/root/selection.ts +228 -0
- package/src/components/command-bar/routes/root/shortcut-feedback.ts +108 -0
- package/src/components/command-bar/routes/root/shortcut-items.ts +159 -0
- package/src/components/command-bar/routes/root/shortcuts.test.ts +151 -0
- package/src/components/command-bar/routes/root/shortcuts.ts +188 -0
- package/src/components/command-bar/routes/ticker-search/actions.ts +142 -0
- package/src/components/command-bar/routes/ticker-search/results.ts +94 -0
- package/src/components/command-bar/routes/ticker-search/route.ts +151 -0
- package/src/components/command-bar/routing/actions.ts +299 -0
- package/src/components/command-bar/routing/confirm.ts +91 -0
- package/src/components/command-bar/routing/effects.ts +82 -0
- package/src/components/command-bar/routing/launch-request.ts +59 -0
- package/src/components/command-bar/routing/list-state.ts +242 -0
- package/src/components/command-bar/routing/navigation-state.ts +147 -0
- package/src/components/command-bar/selection-runtime.ts +291 -0
- package/src/components/command-bar/surface/environment.ts +124 -0
- package/src/components/command-bar/surface/index.test.tsx +864 -0
- package/src/components/command-bar/surface/index.tsx +344 -0
- package/src/components/command-bar/surface/pane.test.tsx +703 -0
- package/src/components/command-bar/surface/portfolio.test.tsx +452 -0
- package/src/components/command-bar/surface/test-harness.tsx +403 -0
- package/src/components/command-bar/theme-preview.ts +84 -0
- package/src/components/command-bar/view-model.test.ts +3 -3
- package/src/components/command-bar/view-model.ts +7 -6
- package/src/components/command-bar/workflow/alert.ts +164 -0
- package/src/components/command-bar/workflow/body.tsx +179 -0
- package/src/components/command-bar/workflow/broker.ts +158 -0
- package/src/components/command-bar/workflow/builtin.ts +134 -0
- package/src/components/command-bar/workflow/collection-actions.ts +257 -0
- package/src/components/command-bar/workflow/coordinator.ts +193 -0
- package/src/components/command-bar/workflow/field-row.tsx +214 -0
- package/src/components/command-bar/workflow/fields.ts +230 -0
- package/src/components/command-bar/workflow/ops.test.ts +197 -0
- package/src/components/command-bar/workflow/ops.ts +268 -0
- package/src/components/command-bar/workflow/route-actions.ts +232 -0
- package/src/components/command-bar/workflow/route-builder.ts +56 -0
- package/src/components/command-bar/workflow/runtime.ts +234 -0
- package/src/components/command-bar/workflow/submit.ts +213 -0
- package/src/components/command-bar/workflow/tickers.ts +214 -0
- package/src/components/command-bar/workflow/types.ts +127 -0
- package/src/components/data-table/stack-view.test.tsx +218 -0
- package/src/components/data-table/stack-view.tsx +59 -0
- package/src/components/data-table/view.test.tsx +254 -0
- package/src/components/data-table/view.tsx +306 -0
- package/src/components/feed-data-table/stack-view.test.tsx +148 -0
- package/src/components/feed-data-table/stack-view.tsx +359 -0
- package/src/components/index.ts +14 -14
- package/src/components/input-search-bar.tsx +94 -0
- package/src/components/layout/detached-pane-shell.tsx +22 -16
- package/src/components/layout/floating-pane.tsx +19 -24
- package/src/components/layout/header.tsx +9 -21
- package/src/components/layout/pane/content.test.tsx +64 -0
- package/src/components/layout/pane/content.tsx +44 -0
- package/src/components/layout/pane/cycle-order.test.ts +30 -0
- package/src/components/layout/pane/cycle-order.ts +32 -0
- package/src/components/layout/pane/footer/index.test.tsx +131 -0
- package/src/components/layout/pane/footer/index.tsx +246 -0
- package/src/components/layout/pane/footer/model.ts +99 -0
- package/src/components/layout/pane/footer/registration.tsx +114 -0
- package/src/components/layout/pane/frame.tsx +55 -0
- package/src/components/layout/pane/header.test.tsx +39 -0
- package/src/components/layout/pane/header.tsx +252 -0
- package/src/components/layout/pane/index.tsx +105 -0
- package/src/components/layout/pane/keyboard-scroll.test.tsx +146 -0
- package/src/components/layout/pane/sizing.ts +66 -0
- package/src/components/layout/pane/title.ts +38 -0
- package/src/components/layout/shell/action-menu-overlay.tsx +72 -0
- package/src/components/layout/shell/active-drag.ts +221 -0
- package/src/components/layout/shell/chrome.ts +8 -0
- package/src/components/layout/shell/drag/index.ts +432 -0
- package/src/components/layout/shell/drag/overlays.tsx +78 -0
- package/src/components/layout/shell/drag/runtime.ts +264 -0
- package/src/components/layout/shell/index.test.tsx +788 -0
- package/src/components/layout/shell/index.tsx +451 -0
- package/src/components/layout/shell/layout-state.ts +97 -0
- package/src/components/layout/shell/menu.ts +152 -0
- package/src/components/layout/shell/native/pointer-runtime.ts +184 -0
- package/src/components/layout/shell/native/surfaces.ts +127 -0
- package/src/components/layout/shell/native/window-state.ts +208 -0
- package/src/components/layout/shell/pane/actions.ts +129 -0
- package/src/components/layout/shell/pane/layers.tsx +234 -0
- package/src/components/layout/shell/pane/management-shortcuts.ts +114 -0
- package/src/components/layout/shell/shortcuts.ts +47 -0
- package/src/components/layout/shell/terminal-pointer-runtime.ts +326 -0
- package/src/components/layout/shell/window-mode/index.ts +253 -0
- package/src/components/layout/shell/window-mode/overlays.tsx +208 -0
- package/src/components/layout/status-bar.test.tsx +1 -101
- package/src/components/layout/status-bar.tsx +1 -1
- package/src/components/layout/window-edit/mode.test.ts +55 -0
- package/src/components/layout/window-edit/mode.ts +422 -0
- package/src/components/layout/window-edit/presentation.ts +123 -0
- package/src/components/layout/window-edit/status.tsx +101 -0
- package/src/components/markdown-text.tsx +3 -3
- package/src/components/onboarding/onboarding-steps.tsx +248 -0
- package/src/components/onboarding/onboarding-wizard.tsx +97 -1035
- package/src/components/onboarding/portfolio-step/broker-fields-panel.tsx +144 -0
- package/src/components/onboarding/portfolio-step/broker-setup-panel.tsx +97 -0
- package/src/components/onboarding/portfolio-step/broker-sync-panel.tsx +42 -0
- package/src/components/onboarding/portfolio-step/choose-panel.tsx +42 -0
- package/src/components/onboarding/portfolio-step/index.tsx +70 -0
- package/src/components/onboarding/portfolio-step/manual-name-panel.tsx +62 -0
- package/src/components/onboarding/portfolio-step/types.ts +25 -0
- package/src/components/onboarding/portfolio-step/utils.ts +15 -0
- package/src/components/onboarding/wizard-broker-sync.ts +230 -0
- package/src/components/onboarding/wizard-keyboard.ts +264 -0
- package/src/components/onboarding/wizard-model.ts +21 -0
- package/src/components/pane-settings-dialog/desktop.tsx +315 -0
- package/src/components/pane-settings-dialog/field-dialogs.tsx +213 -0
- package/src/components/pane-settings-dialog/tui.tsx +73 -0
- package/src/components/pane-settings-dialog/value.ts +36 -0
- package/src/components/pane-settings-dialog.tsx +18 -622
- package/src/components/pane-template-wizard.tsx +1 -1
- package/src/components/price-selector-dialog.tsx +2 -2
- package/src/components/price-sparkline/bitmap.ts +150 -0
- package/src/components/price-sparkline/index.ts +46 -0
- package/src/components/price-sparkline/model.ts +119 -0
- package/src/components/price-sparkline/view.tsx +214 -0
- package/src/components/quote-flash.ts +103 -0
- package/src/components/speedometer-gauge/desktop.tsx +151 -0
- package/src/components/speedometer-gauge/index.tsx +44 -0
- package/src/components/speedometer-gauge/model.ts +60 -0
- package/src/components/speedometer-gauge/terminal.tsx +261 -0
- package/src/components/ticker/badge/format.ts +42 -0
- package/src/components/ticker/badge/index.tsx +100 -0
- package/src/components/ticker/badge/list.tsx +57 -0
- package/src/components/ticker/badge/text.test.tsx +223 -0
- package/src/components/ticker/badge/text.tsx +156 -0
- package/src/components/ticker/list-table-view.tsx +297 -0
- package/src/components/ticker/list-table.test.tsx +177 -0
- package/src/components/toggle-list.tsx +1 -1
- package/src/components/ui/data-table/index.tsx +26 -0
- package/src/components/ui/data-table/opentui/index.tsx +467 -0
- package/src/components/ui/data-table/opentui/model.test.ts +47 -0
- package/src/components/ui/data-table/opentui/model.ts +66 -0
- package/src/components/ui/data-table/types.ts +81 -0
- package/src/components/ui/index.ts +1 -3
- package/src/components/ui/multi-select/dialog.tsx +336 -0
- package/src/components/ui/native-select.tsx +1 -1
- package/src/components/ui/shortcut-hint.tsx +1 -1
- package/src/components/ui/tabs.tsx +11 -5
- package/src/components/ui/toggle.tsx +1 -1
- package/src/components/ui/ui.test.tsx +3 -75
- package/src/components/use-external-link-footer.ts +1 -1
- package/src/core/app-services.ts +3 -0
- package/src/core/state/app/layout-reducer.ts +196 -0
- package/src/core/state/app/layout.ts +406 -0
- package/src/core/state/app/state.ts +340 -0
- package/src/core/state/app/types.ts +116 -0
- package/src/core/state/session-persistence.ts +1 -1
- package/src/data/app-persistence.ts +1 -1
- package/src/data/config/layout.ts +227 -0
- package/src/data/config/store/index.test.ts +500 -0
- package/src/data/config/store/index.ts +64 -0
- package/src/data/config/store/node.ts +101 -0
- package/src/data/config/store/normalize.ts +403 -0
- package/src/data/plugin-state-store.ts +3 -3
- package/src/data/resource-store.ts +3 -3
- package/src/data/session-store.ts +3 -3
- package/src/data/sqlite/cache.test.ts +151 -0
- package/src/data/sqlite/database.ts +68 -0
- package/src/data/sqlite/json.ts +16 -0
- package/src/data/sqlite/retry.test.ts +63 -0
- package/src/data/ticker-repository.ts +1 -1
- package/src/data/ticker-store.ts +2 -2
- package/src/market-data/coordinator/auxiliary.ts +252 -0
- package/src/market-data/coordinator/chart.ts +141 -0
- package/src/market-data/coordinator/entries.ts +129 -0
- package/src/market-data/coordinator/events.ts +74 -0
- package/src/market-data/coordinator/financials.ts +281 -0
- package/src/market-data/coordinator/index.test.ts +840 -0
- package/src/market-data/coordinator/index.ts +388 -0
- package/src/market-data/coordinator/quotes.ts +329 -0
- package/src/market-data/coordinator/subscriptions.test.ts +209 -0
- package/src/market-data/hooks.test.tsx +42 -1
- package/src/market-data/hooks.tsx +83 -18
- package/src/market-data/market/format.test.ts +109 -0
- package/src/market-data/market/format.ts +293 -0
- package/src/market-data/market/freshness.ts +140 -0
- package/src/market-data/market/status.ts +112 -0
- package/src/market-data/quotes/contributions.ts +194 -0
- package/src/market-data/quotes/freshness.test.ts +150 -0
- package/src/market-data/quotes/freshness.ts +36 -0
- package/src/market-data/quotes/resolution.test.ts +277 -0
- package/src/market-data/quotes/resolution.ts +468 -0
- package/src/market-data/quotes/time.test.ts +34 -0
- package/src/market-data/quotes/time.ts +59 -0
- package/src/market-data/request-types.ts +10 -3
- package/src/market-data/result-types.ts +3 -3
- package/src/market-data/selectors.ts +2 -2
- package/src/news/aggregator.ts +29 -219
- package/src/news/news-model.ts +208 -0
- package/src/news/ticker-symbols.ts +1 -1
- package/src/news/types.ts +3 -3
- package/src/plugins/builtin/account-management/footer.ts +39 -0
- package/src/plugins/builtin/account-management/form-components.tsx +162 -0
- package/src/plugins/builtin/account-management/keyboard.ts +90 -0
- package/src/plugins/builtin/account-management/model.ts +97 -0
- package/src/plugins/builtin/account-management/pane.tsx +389 -0
- package/src/plugins/builtin/account-management/password-dialog.tsx +125 -0
- package/src/plugins/builtin/ai/ask-ai-detail-tab.tsx +6 -6
- package/src/plugins/builtin/ai/ask-ai.test.tsx +305 -0
- package/src/plugins/builtin/ai/index.tsx +4 -4
- package/src/plugins/builtin/ai/providers.ts +1 -1
- package/src/plugins/builtin/ai/runner.ts +1 -0
- package/src/plugins/builtin/ai/screener/action-bar.tsx +58 -0
- package/src/plugins/builtin/ai/screener/contract.test.ts +117 -0
- package/src/plugins/builtin/ai/screener/contract.ts +174 -0
- package/src/plugins/builtin/ai/screener/editor-runtime.ts +110 -0
- package/src/plugins/builtin/ai/screener/editor.tsx +125 -0
- package/src/plugins/builtin/ai/screener/footer.ts +93 -0
- package/src/plugins/builtin/ai/screener/keyboard.ts +90 -0
- package/src/plugins/builtin/ai/screener/market-runtime.ts +99 -0
- package/src/plugins/builtin/ai/screener/model.ts +107 -0
- package/src/plugins/builtin/ai/screener/pane.test.tsx +348 -0
- package/src/plugins/builtin/ai/screener/pane.tsx +412 -0
- package/src/plugins/builtin/ai/screener/results-view.tsx +169 -0
- package/src/plugins/builtin/ai/screener/results.ts +139 -0
- package/src/plugins/builtin/ai/screener/runner.ts +144 -0
- package/src/plugins/builtin/ai/screener/tabs-bar.tsx +65 -0
- package/src/plugins/builtin/ai/settings.ts +3 -3
- package/src/plugins/builtin/ai/ticker-context.ts +1 -1
- package/src/plugins/builtin/alerts/command.ts +86 -0
- package/src/plugins/builtin/alerts/constants.ts +3 -0
- package/src/plugins/builtin/alerts/format.ts +68 -0
- package/src/plugins/builtin/alerts/index.test.tsx +5 -4
- package/src/plugins/builtin/alerts/index.tsx +18 -473
- package/src/plugins/builtin/alerts/pane.tsx +304 -0
- package/src/plugins/builtin/alerts/quotes.ts +57 -0
- package/src/plugins/builtin/alerts/storage.ts +20 -0
- package/src/plugins/builtin/analytics/broker-performance.ts +142 -0
- package/src/plugins/builtin/analytics/display.ts +44 -0
- package/src/plugins/builtin/analytics/index.test.tsx +144 -5
- package/src/plugins/builtin/analytics/index.tsx +108 -468
- package/src/plugins/builtin/analytics/metrics.ts +1 -1
- package/src/plugins/builtin/analytics/pane-model.ts +297 -0
- package/src/plugins/builtin/analytics/portfolio-selection.ts +10 -0
- package/src/plugins/builtin/analytics/sector-model.ts +172 -0
- package/src/plugins/builtin/analytics/view.tsx +207 -0
- package/src/plugins/builtin/broker-manager/detail.tsx +232 -0
- package/src/plugins/builtin/broker-manager/footer.ts +62 -0
- package/src/plugins/builtin/broker-manager/index.test.tsx +3 -3
- package/src/plugins/builtin/broker-manager/index.tsx +125 -527
- package/src/plugins/builtin/broker-manager/keyboard.ts +104 -0
- package/src/plugins/builtin/broker-manager/model.test.ts +39 -1
- package/src/plugins/builtin/broker-manager/model.ts +14 -8
- package/src/plugins/builtin/broker-manager/pane-actions.tsx +181 -0
- package/src/plugins/builtin/broker-manager/table.ts +86 -0
- package/src/plugins/builtin/buildout/cells.tsx +203 -0
- package/src/plugins/builtin/buildout/data-runtime.ts +238 -0
- package/src/plugins/builtin/buildout/detail/company.tsx +219 -0
- package/src/plugins/builtin/buildout/detail/index.tsx +105 -0
- package/src/plugins/builtin/buildout/detail/intel.tsx +61 -0
- package/src/plugins/builtin/buildout/detail/satellite-images.tsx +80 -0
- package/src/plugins/builtin/buildout/detail/site.tsx +142 -0
- package/src/plugins/builtin/buildout/detail/ui.tsx +355 -0
- package/src/plugins/builtin/buildout/detail/values.ts +67 -0
- package/src/plugins/builtin/buildout/format.ts +163 -0
- package/src/plugins/builtin/buildout/model/index.ts +135 -0
- package/src/plugins/builtin/buildout/model/normalizers.ts +396 -0
- package/src/plugins/builtin/buildout/model/types.ts +318 -0
- package/src/plugins/builtin/buildout/pane/header.tsx +55 -0
- package/src/plugins/builtin/buildout/pane/index.tsx +405 -0
- package/src/plugins/builtin/buildout/pane/status.tsx +84 -0
- package/src/plugins/builtin/buildout/table-model.ts +367 -0
- package/src/plugins/builtin/changelog/index.tsx +370 -0
- package/src/plugins/builtin/chat/channels.ts +157 -0
- package/src/plugins/builtin/chat/chat.test.tsx +1048 -0
- package/src/plugins/builtin/chat/composer-commands.test.ts +30 -0
- package/src/plugins/builtin/chat/composer-commands.ts +34 -0
- package/src/plugins/builtin/chat/content/channel-navigation.ts +157 -0
- package/src/plugins/builtin/chat/content/composer-runtime.ts +251 -0
- package/src/plugins/builtin/chat/content/composer.tsx +148 -0
- package/src/plugins/builtin/chat/content/index.tsx +407 -0
- package/src/plugins/builtin/chat/content/layout-metrics.ts +72 -0
- package/src/plugins/builtin/chat/content/scroll.ts +278 -0
- package/src/plugins/builtin/chat/content/selection-runtime.ts +66 -0
- package/src/plugins/builtin/chat/content/shortcuts.ts +212 -0
- package/src/plugins/builtin/chat/content/snapshot.ts +154 -0
- package/src/plugins/builtin/chat/content/transcript.tsx +155 -0
- package/src/plugins/builtin/chat/content/types.ts +26 -0
- package/src/plugins/builtin/chat/content/user-map.ts +21 -0
- package/src/plugins/builtin/chat/controller/channel-actions.ts +87 -0
- package/src/plugins/builtin/chat/controller/channels.ts +159 -0
- package/src/plugins/builtin/chat/controller/connections.ts +90 -0
- package/src/plugins/builtin/chat/controller/draft-sync.ts +41 -0
- package/src/plugins/builtin/chat/controller/fetch.ts +83 -0
- package/src/plugins/builtin/chat/controller/index.ts +488 -0
- package/src/plugins/builtin/chat/controller/lifecycle.ts +141 -0
- package/src/plugins/builtin/chat/controller/message-loading.ts +97 -0
- package/src/plugins/builtin/chat/controller/messages.ts +173 -0
- package/src/plugins/builtin/chat/controller/notifications.ts +56 -0
- package/src/plugins/builtin/chat/controller/persistence.ts +166 -0
- package/src/plugins/builtin/chat/controller/realtime.ts +91 -0
- package/src/plugins/builtin/chat/controller/send.ts +89 -0
- package/src/plugins/builtin/chat/controller/session-runtime.ts +156 -0
- package/src/plugins/builtin/chat/controller/session.ts +39 -0
- package/src/plugins/builtin/chat/controller/state.ts +162 -0
- package/src/plugins/builtin/chat/controller/storage.ts +136 -0
- package/src/plugins/builtin/chat/controller/utils.ts +75 -0
- package/src/plugins/builtin/chat/controller/view.ts +96 -0
- package/src/plugins/builtin/chat/controller.test.ts +1302 -0
- package/src/plugins/builtin/chat/index.tsx +4 -0
- package/src/plugins/builtin/chat/layout.ts +330 -0
- package/src/plugins/builtin/chat/message/action-chip.tsx +38 -0
- package/src/plugins/builtin/chat/message/desktop.tsx +158 -0
- package/src/plugins/builtin/chat/message/inline-tokens.tsx +118 -0
- package/src/plugins/builtin/chat/message/profile-popover.tsx +72 -0
- package/src/plugins/builtin/chat/message/render-state.ts +67 -0
- package/src/plugins/builtin/chat/message/terminal.tsx +132 -0
- package/src/plugins/builtin/chat/message/types.ts +18 -0
- package/src/plugins/builtin/chat/pane.tsx +100 -0
- package/src/plugins/builtin/chat/profile-popover.ts +49 -0
- package/src/plugins/builtin/chat/sidebar.test.tsx +455 -0
- package/src/plugins/builtin/chat/sidebar.tsx +296 -0
- package/src/plugins/builtin/chat/status-widget.tsx +103 -0
- package/src/plugins/builtin/chat/test-harness.tsx +212 -0
- package/src/plugins/builtin/cloud/auth-actions.tsx +72 -0
- package/src/plugins/builtin/cloud/auth-commands.ts +115 -0
- package/src/plugins/builtin/cloud/index.tsx +11 -0
- package/src/plugins/builtin/cloud/plugin.tsx +185 -0
- package/src/plugins/builtin/cloud-tweets/footer.ts +40 -0
- package/src/plugins/builtin/cloud-tweets/index.ts +1 -0
- package/src/plugins/builtin/cloud-tweets/keyboard.ts +65 -0
- package/src/plugins/builtin/cloud-tweets/model.ts +257 -0
- package/src/plugins/builtin/cloud-tweets/pane.tsx +318 -0
- package/src/plugins/builtin/cloud-tweets/registration.ts +87 -0
- package/src/plugins/builtin/cloud-tweets/search-bar.tsx +49 -0
- package/src/plugins/builtin/cloud-tweets/table.tsx +331 -0
- package/src/plugins/builtin/comparison-chart/index.test.tsx +645 -0
- package/src/plugins/builtin/comparison-chart/index.tsx +194 -0
- package/src/plugins/builtin/congress-trades/detail.tsx +154 -0
- package/src/plugins/builtin/congress-trades/footer.ts +67 -0
- package/src/plugins/builtin/congress-trades/keyboard.ts +112 -0
- package/src/plugins/builtin/congress-trades/model.ts +224 -0
- package/src/plugins/builtin/congress-trades/pane.tsx +331 -0
- package/src/plugins/builtin/congress-trades/table.tsx +84 -0
- package/src/plugins/builtin/correlation/compute.ts +0 -7
- package/src/plugins/builtin/correlation/index.test.tsx +5 -5
- package/src/plugins/builtin/correlation/index.tsx +36 -208
- package/src/plugins/builtin/correlation/matrix/model.ts +155 -0
- package/src/plugins/builtin/correlation/matrix/symbol-cell.tsx +56 -0
- package/src/plugins/builtin/correlation/relationship/controls.tsx +53 -0
- package/src/plugins/builtin/correlation/relationship/history.ts +72 -0
- package/src/plugins/builtin/correlation/relationship/model.ts +279 -0
- package/src/plugins/builtin/correlation/relationship/pane.tsx +359 -0
- package/src/plugins/builtin/correlation/relationship/view-model.ts +120 -0
- package/src/plugins/builtin/correlation/settings.ts +6 -6
- package/src/plugins/builtin/debug/index.tsx +365 -0
- package/src/plugins/builtin/earnings/data/cache.test.ts +94 -0
- package/src/plugins/builtin/earnings/data/cache.ts +145 -0
- package/src/plugins/builtin/earnings/data/data.test.ts +90 -0
- package/src/plugins/builtin/earnings/data/data.ts +115 -0
- package/src/plugins/builtin/earnings/index.test.ts +12 -0
- package/src/plugins/builtin/earnings/index.tsx +74 -266
- package/src/plugins/builtin/earnings/model.ts +82 -0
- package/src/plugins/builtin/earnings/table.ts +206 -0
- package/src/plugins/builtin/econ/calendar-model.test.ts +48 -0
- package/src/plugins/builtin/econ/calendar-model.ts +217 -0
- package/src/plugins/builtin/econ/calendar-source.ts +1 -1
- package/src/plugins/builtin/econ/detail-view.tsx +319 -0
- package/src/plugins/builtin/econ/fred-cache.test.ts +58 -0
- package/src/plugins/builtin/econ/fred-cache.ts +106 -0
- package/src/plugins/builtin/econ/fred-series-map.ts +0 -4
- package/src/plugins/builtin/econ/index.tsx +46 -474
- package/src/plugins/builtin/fear-greed/cache.test.ts +75 -0
- package/src/plugins/builtin/fear-greed/cache.ts +142 -0
- package/src/plugins/builtin/fear-greed/charts.tsx +305 -0
- package/src/plugins/builtin/fear-greed/data.test.ts +72 -0
- package/src/plugins/builtin/fear-greed/data.ts +370 -0
- package/src/plugins/builtin/fear-greed/format.ts +96 -0
- package/src/plugins/builtin/fear-greed/index.tsx +13 -555
- package/src/plugins/builtin/fear-greed/pane.tsx +169 -0
- package/src/plugins/builtin/fx-matrix/index.tsx +1 -1
- package/src/plugins/builtin/fx-matrix/pairs.ts +0 -22
- package/src/plugins/builtin/help/components.tsx +92 -0
- package/src/plugins/builtin/help/index.test.tsx +167 -0
- package/src/plugins/builtin/help/index.tsx +256 -0
- package/src/plugins/builtin/help/shortcut-model.ts +145 -0
- package/src/plugins/builtin/holders/format.ts +44 -0
- package/src/plugins/builtin/holders/index.test.ts +2 -76
- package/src/plugins/builtin/holders/index.tsx +3 -959
- package/src/plugins/builtin/holders/pane.tsx +331 -0
- package/src/plugins/builtin/holders/table-model.ts +84 -0
- package/src/plugins/builtin/holders/thirteenf-match.ts +76 -0
- package/src/plugins/builtin/holders/treemap-layout.ts +231 -0
- package/src/plugins/builtin/holders/treemap.tsx +318 -0
- package/src/plugins/builtin/holders/types.ts +51 -0
- package/src/plugins/builtin/insider/index.tsx +5 -5
- package/src/plugins/builtin/layout-manager/index.tsx +247 -0
- package/src/plugins/builtin/market-movers/index.tsx +44 -282
- package/src/plugins/builtin/market-movers/model.ts +146 -0
- package/src/plugins/builtin/market-movers/screener.test.ts +31 -1
- package/src/plugins/builtin/market-movers/screener.ts +106 -12
- package/src/plugins/builtin/market-movers/table.ts +95 -0
- package/src/plugins/builtin/news/index.tsx +194 -0
- package/src/plugins/builtin/news/wire/breaking/notifications.test.ts +98 -0
- package/src/plugins/builtin/news/wire/breaking/notifications.ts +110 -0
- package/src/plugins/builtin/news/wire/breaking/pane.test.tsx +156 -0
- package/src/plugins/builtin/news/wire/breaking/pane.tsx +68 -0
- package/src/plugins/builtin/news/wire/categories.ts +114 -0
- package/src/plugins/builtin/news/wire/default-feeds.ts +3 -0
- package/src/plugins/builtin/news/wire/feed-config.test.ts +90 -0
- package/src/plugins/builtin/news/wire/feed-config.ts +216 -0
- package/src/plugins/builtin/news/wire/index.tsx +129 -0
- package/src/plugins/builtin/news/wire/industry-pane.tsx +126 -0
- package/src/plugins/builtin/news/wire/news/detail-view.tsx +306 -0
- package/src/plugins/builtin/news/wire/news/footer.ts +77 -0
- package/src/plugins/builtin/news/wire/news/preset-pane.tsx +98 -0
- package/src/plugins/builtin/news/wire/news/query-presets.ts +40 -0
- package/src/plugins/builtin/news/wire/news/table.test.tsx +157 -0
- package/src/plugins/builtin/news/wire/news/table.tsx +270 -0
- package/src/plugins/builtin/news/wire/persisted-articles.ts +98 -0
- package/src/plugins/builtin/news/wire/read-state.ts +76 -0
- package/src/plugins/builtin/news/wire/rss/parser.test.ts +116 -0
- package/src/plugins/builtin/news/wire/rss/parser.ts +213 -0
- package/src/plugins/builtin/news/wire/rss/source.test.ts +104 -0
- package/src/plugins/builtin/news/wire/rss/source.ts +181 -0
- package/src/plugins/builtin/notes/index.tsx +49 -0
- package/src/plugins/builtin/notes/markdown-note-preview.tsx +39 -0
- package/src/plugins/builtin/notes/model.ts +36 -0
- package/src/plugins/builtin/notes/quick-notes-pane.tsx +334 -0
- package/src/plugins/builtin/notes/text-state.ts +11 -0
- package/src/plugins/builtin/notes/ticker-notes-tab.tsx +112 -0
- package/src/plugins/builtin/options/index.tsx +44 -0
- package/src/plugins/builtin/options/table.ts +209 -0
- package/src/plugins/builtin/options/types.ts +33 -0
- package/src/plugins/builtin/options/view.test.tsx +185 -0
- package/src/plugins/builtin/options/view.tsx +264 -0
- package/src/plugins/builtin/plugin-groups.ts +25 -5
- package/src/plugins/builtin/portfolio-list/account-metrics.test.ts +50 -0
- package/src/plugins/builtin/portfolio-list/account-metrics.ts +46 -0
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +224 -0
- package/src/plugins/builtin/portfolio-list/cli/render.ts +203 -0
- package/src/plugins/builtin/portfolio-list/cli/shared.ts +21 -0
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +224 -0
- package/src/plugins/builtin/portfolio-list/column-values.ts +284 -0
- package/src/plugins/builtin/portfolio-list/command-bar.ts +1 -1
- package/src/plugins/builtin/portfolio-list/header.tsx +7 -98
- package/src/plugins/builtin/portfolio-list/index.test.ts +133 -0
- package/src/plugins/builtin/portfolio-list/index.tsx +2 -1
- package/src/plugins/builtin/portfolio-list/metrics.test.ts +242 -0
- package/src/plugins/builtin/portfolio-list/metrics.ts +5 -462
- package/src/plugins/builtin/portfolio-list/pane/data.ts +171 -0
- package/src/plugins/builtin/portfolio-list/pane/index.test.tsx +1267 -0
- package/src/plugins/builtin/portfolio-list/pane/index.tsx +385 -0
- package/src/plugins/builtin/portfolio-list/pane/streaming.ts +159 -0
- package/src/plugins/builtin/portfolio-list/position-metrics.ts +123 -0
- package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +326 -0
- package/src/plugins/builtin/portfolio-list/quick-add/resolution.ts +135 -0
- package/src/plugins/builtin/portfolio-list/settings.ts +5 -3
- package/src/plugins/builtin/portfolio-list/summary/index.test.ts +126 -0
- package/src/plugins/builtin/portfolio-list/summary/index.tsx +392 -0
- package/src/plugins/builtin/portfolio-list/summary/totals.ts +86 -0
- package/src/plugins/builtin/portfolio-list/table.tsx +1 -1
- package/src/plugins/builtin/portfolio-list/use-throttled-cursor-symbol.ts +1 -1
- package/src/plugins/builtin/research/analyst-pane.tsx +383 -0
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +413 -0
- package/src/plugins/builtin/research/index.test.ts +248 -2
- package/src/plugins/builtin/research/index.tsx +30 -760
- package/src/plugins/builtin/research/relative-valuation-pane.tsx +189 -0
- package/src/plugins/builtin/sec/filing-display.tsx +84 -0
- package/src/plugins/builtin/sec/index.tsx +342 -0
- package/src/plugins/builtin/sectors/index.tsx +27 -234
- package/src/plugins/builtin/sectors/sector-data.ts +0 -2
- package/src/plugins/builtin/sectors/sector-model.ts +221 -0
- package/src/plugins/builtin/shared/table-pane.ts +31 -0
- package/src/plugins/builtin/shared/ticker-request.ts +70 -0
- package/src/plugins/builtin/shared/ticker-surface.test.ts +57 -0
- package/src/plugins/builtin/shared/ticker-surface.ts +113 -0
- package/src/plugins/builtin/thirteenf/api.test.ts +58 -0
- package/src/plugins/builtin/thirteenf/api.ts +375 -0
- package/src/plugins/builtin/thirteenf/data.test.ts +95 -0
- package/src/plugins/builtin/thirteenf/data.ts +210 -0
- package/src/plugins/builtin/thirteenf/format.ts +55 -0
- package/src/plugins/builtin/thirteenf/index.tsx +80 -0
- package/src/plugins/builtin/thirteenf/model.test.ts +156 -0
- package/src/plugins/builtin/thirteenf/model.ts +618 -0
- package/src/plugins/builtin/thirteenf/pane.test.tsx +328 -0
- package/src/plugins/builtin/thirteenf/pane.tsx +826 -0
- package/src/plugins/builtin/thirteenf/table.ts +212 -0
- package/src/plugins/builtin/thirteenf/types.ts +187 -0
- package/src/plugins/builtin/ticker-detail/chart-pane.tsx +91 -0
- package/src/plugins/builtin/ticker-detail/chart-tab-switch.test.tsx +282 -0
- package/src/plugins/builtin/ticker-detail/chart-tab.tsx +3 -5
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph/content.tsx +158 -0
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph/data.ts +62 -0
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph/model.ts +234 -0
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph/settings.ts +44 -0
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph/types.ts +51 -0
- package/src/plugins/builtin/ticker-detail/data-panes/fundamental-graph.tsx +135 -0
- package/src/plugins/builtin/ticker-detail/data-panes/historical-prices.tsx +192 -0
- package/src/plugins/builtin/ticker-detail/data-panes/provider-search.tsx +172 -0
- package/src/plugins/builtin/ticker-detail/data-panes.test.ts +110 -0
- package/src/plugins/builtin/ticker-detail/financials/aggregation.ts +203 -0
- package/src/plugins/builtin/ticker-detail/financials/model.test.ts +84 -0
- package/src/plugins/builtin/ticker-detail/financials/model.ts +364 -0
- package/src/plugins/builtin/ticker-detail/financials/pane.tsx +27 -0
- package/src/plugins/builtin/ticker-detail/financials/schema.ts +392 -0
- package/src/plugins/builtin/ticker-detail/financials/tab.tsx +438 -0
- package/src/plugins/builtin/ticker-detail/index.test.tsx +780 -0
- package/src/plugins/builtin/ticker-detail/index.tsx +174 -17
- package/src/plugins/builtin/ticker-detail/overview/components.tsx +240 -0
- package/src/plugins/builtin/ticker-detail/overview/model.ts +168 -0
- package/src/plugins/builtin/ticker-detail/overview/pane.tsx +14 -0
- package/src/plugins/builtin/ticker-detail/overview/types.ts +17 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +27 -392
- package/src/plugins/builtin/ticker-detail/pane.tsx +24 -136
- package/src/plugins/builtin/ticker-detail/quote-monitor/card.tsx +330 -0
- package/src/plugins/builtin/ticker-detail/quote-monitor/index.test.tsx +292 -0
- package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +180 -0
- package/src/plugins/builtin/ticker-detail/settings.ts +39 -33
- package/src/plugins/builtin/world-indices/footer.ts +28 -0
- package/src/plugins/builtin/world-indices/index.tsx +25 -218
- package/src/plugins/builtin/world-indices/model.ts +120 -0
- package/src/plugins/builtin/world-indices/table.tsx +96 -0
- package/src/plugins/builtin/yahoo/index.ts +72 -0
- package/src/plugins/builtin/yield-curve/index.tsx +5 -5
- package/src/plugins/builtin/yield-curve/treasury-data.ts +1 -1
- package/src/plugins/catalog-ui.ts +7 -9
- package/src/plugins/catalog.ts +1 -1
- package/src/plugins/ibkr/account-cache.ts +2 -10
- package/src/plugins/ibkr/broker-adapter.ts +10 -4
- package/src/plugins/ibkr/config.ts +5 -24
- package/src/plugins/ibkr/dialogs.tsx +0 -1
- package/src/plugins/ibkr/flex/index.test.ts +236 -0
- package/src/plugins/ibkr/flex/index.ts +337 -0
- package/src/plugins/ibkr/flex/statement-client.ts +181 -0
- package/src/plugins/ibkr/gateway/account-loaders.ts +266 -0
- package/src/plugins/ibkr/gateway/account-summary.ts +163 -0
- package/src/plugins/ibkr/gateway/client-lock.ts +154 -0
- package/src/plugins/ibkr/gateway/connection-events.ts +114 -0
- package/src/plugins/ibkr/gateway/connection.ts +152 -0
- package/src/plugins/ibkr/gateway/contracts.ts +132 -0
- package/src/plugins/ibkr/gateway/fundamentals.ts +83 -0
- package/src/plugins/ibkr/gateway/helpers.ts +33 -0
- package/src/plugins/ibkr/gateway/history-requests.ts +158 -0
- package/src/plugins/ibkr/gateway/history.ts +120 -0
- package/src/plugins/ibkr/gateway/instrument-lookup.ts +117 -0
- package/src/plugins/ibkr/gateway/market-data.ts +338 -0
- package/src/plugins/ibkr/gateway/order-execution.ts +218 -0
- package/src/plugins/ibkr/gateway/orders.ts +63 -0
- package/src/plugins/ibkr/gateway/price-normalization.test.ts +44 -0
- package/src/plugins/ibkr/gateway/price-normalization.ts +50 -0
- package/src/plugins/ibkr/gateway/quote-stream-controller.ts +203 -0
- package/src/plugins/ibkr/gateway/quote-stream.ts +171 -0
- package/src/plugins/ibkr/gateway/selection.ts +51 -0
- package/src/plugins/ibkr/gateway/service/index.test.ts +614 -0
- package/src/plugins/ibkr/gateway/service/index.ts +432 -0
- package/src/plugins/ibkr/gateway/service/lifecycle.ts +191 -0
- package/src/plugins/ibkr/gateway/service/manager.ts +52 -0
- package/src/plugins/ibkr/gateway/service/market-data.ts +48 -0
- package/src/plugins/ibkr/gateway/service/native.ts +543 -0
- package/src/plugins/ibkr/gateway/timeouts.ts +13 -0
- package/src/plugins/ibkr/gateway/types.ts +27 -0
- package/src/plugins/ibkr/hash.ts +8 -0
- package/src/plugins/ibkr/index.test.tsx +1 -12
- package/src/plugins/ibkr/index.tsx +8 -9
- package/src/plugins/ibkr/instance-selection.test.ts +2 -2
- package/src/plugins/ibkr/instance-selection.ts +1 -1
- package/src/plugins/ibkr/portfolio-performance.test.ts +32 -0
- package/src/plugins/ibkr/portfolio-performance.ts +129 -0
- package/src/plugins/ibkr/trade/badge.tsx +28 -0
- package/src/plugins/ibkr/trade/dialogs.tsx +44 -0
- package/src/plugins/ibkr/trade/preview-panel.tsx +130 -0
- package/src/plugins/ibkr/trade/tab/actions.tsx +443 -0
- package/src/plugins/ibkr/trade/tab/field-editors.tsx +79 -0
- package/src/plugins/ibkr/trade/tab/footer.ts +67 -0
- package/src/plugins/ibkr/trade/tab/header.tsx +167 -0
- package/src/plugins/ibkr/trade/tab/index.test.tsx +178 -0
- package/src/plugins/ibkr/trade/tab/index.tsx +302 -0
- package/src/plugins/ibkr/trade/tab/model.ts +159 -0
- package/src/plugins/ibkr/trade/tab/order-request.ts +64 -0
- package/src/plugins/ibkr/trade/tab/shortcuts.ts +89 -0
- package/src/plugins/ibkr/trade/tab/state-sync.ts +86 -0
- package/src/plugins/ibkr/trade/ticket-panel.tsx +301 -0
- package/src/plugins/ibkr/trade/utils.test.ts +175 -0
- package/src/plugins/ibkr/trade/utils.ts +150 -0
- package/src/plugins/ibkr/trading/pane-view.tsx +175 -0
- package/src/plugins/ibkr/trading/pane.tsx +332 -0
- package/src/plugins/ibkr/trading/state.test.ts +109 -0
- package/src/plugins/ibkr/trading/state.ts +335 -0
- package/src/plugins/pane-manager/dock-tree.ts +282 -0
- package/src/plugins/pane-manager/docking.ts +202 -0
- package/src/plugins/pane-manager/floating-actions.ts +158 -0
- package/src/plugins/pane-manager/floating.ts +76 -0
- package/src/plugins/pane-manager/gridlock-inference.ts +126 -0
- package/src/plugins/pane-manager/gridlock.ts +34 -0
- package/src/plugins/pane-manager/layout-state.ts +160 -0
- package/src/plugins/pane-manager/queries.ts +75 -0
- package/src/plugins/pane-manager/types.ts +24 -0
- package/src/plugins/pane-manager.test.ts +79 -4
- package/src/plugins/pane-manager.ts +57 -1061
- package/src/plugins/prediction-markets/chart.test.tsx +2 -2
- package/src/plugins/prediction-markets/controller/catalog.ts +317 -0
- package/src/plugins/prediction-markets/controller/data.ts +171 -0
- package/src/plugins/prediction-markets/controller/detail.ts +243 -0
- package/src/plugins/prediction-markets/controller/effects.ts +253 -0
- package/src/plugins/prediction-markets/controller/index.ts +374 -0
- package/src/plugins/prediction-markets/controller/keyboard.ts +220 -0
- package/src/plugins/prediction-markets/controller/live-updates.ts +85 -0
- package/src/plugins/prediction-markets/controller/selection.ts +59 -0
- package/src/plugins/prediction-markets/controller/status.ts +104 -0
- package/src/plugins/prediction-markets/detail/outcomes.tsx +1 -1
- package/src/plugins/prediction-markets/metrics.ts +4 -14
- package/src/plugins/prediction-markets/navigation.ts +0 -13
- package/src/plugins/prediction-markets/pane.test.tsx +2 -198
- package/src/plugins/prediction-markets/plugin.test.tsx +2 -2
- package/src/plugins/prediction-markets/services/fetch.ts +1 -5
- package/src/plugins/prediction-markets/services/kalshi/adapter.ts +299 -0
- package/src/plugins/prediction-markets/services/kalshi/normalize.ts +209 -0
- package/src/plugins/prediction-markets/services/kalshi/types.ts +89 -0
- package/src/plugins/prediction-markets/services/polymarket/adapter.ts +134 -0
- package/src/plugins/prediction-markets/services/polymarket/detail.ts +307 -0
- package/src/plugins/prediction-markets/services/polymarket/normalize.ts +239 -0
- package/src/plugins/prediction-markets/services/polymarket/types.ts +66 -0
- package/src/plugins/prediction-markets/services/polymarket/ws.ts +128 -0
- package/src/plugins/prediction-markets/test-helpers.tsx +12 -76
- package/src/plugins/prediction-markets/types.ts +2 -2
- package/src/plugins/registry/context-menu.ts +36 -0
- package/src/plugins/registry/context.ts +196 -0
- package/src/plugins/registry/contributions.ts +174 -0
- package/src/plugins/registry/index.test.ts +362 -0
- package/src/plugins/registry/index.ts +474 -0
- package/src/plugins/registry/pane-settings.ts +105 -0
- package/src/plugins/registry/plugin-state.ts +123 -0
- package/src/plugins/registry/shared.ts +34 -0
- package/src/plugins/registry/slots.ts +70 -0
- package/src/plugins/runtime/context.tsx +115 -0
- package/src/plugins/runtime/index.test.tsx +328 -0
- package/src/plugins/runtime/index.tsx +111 -0
- package/src/plugins/runtime/state.ts +275 -0
- package/src/plugins/ticker-navigation.test.ts +23 -2
- package/src/plugins/ticker-navigation.ts +9 -3
- package/src/react/input.test.ts +29 -0
- package/src/react/input.ts +9 -0
- package/src/renderers/electrobun/bun/application-menu/click.test.ts +50 -0
- package/src/renderers/electrobun/bun/application-menu/click.ts +58 -0
- package/src/renderers/electrobun/bun/application-menu/index.ts +123 -0
- package/src/renderers/electrobun/bun/context-menu/click.test.ts +67 -0
- package/src/renderers/electrobun/bun/context-menu/normalize.test.ts +52 -0
- package/src/renderers/electrobun/bun/context-menu/normalize.ts +67 -0
- package/src/renderers/electrobun/bun/core-capabilities.ts +3 -0
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +163 -0
- package/src/renderers/electrobun/bun/desktop/capability-bridge.ts +93 -0
- package/src/renderers/electrobun/bun/desktop/detached-windows.ts +263 -0
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +114 -0
- package/src/renderers/electrobun/bun/desktop/http-fetch.ts +56 -0
- package/src/renderers/electrobun/bun/desktop/initialization.ts +139 -0
- package/src/renderers/electrobun/bun/desktop/plugin-state.ts +92 -0
- package/src/renderers/electrobun/bun/desktop/relaunch.ts +48 -0
- package/src/renderers/electrobun/bun/desktop/rpc-registry.ts +43 -0
- package/src/renderers/electrobun/bun/desktop/state-broadcaster.ts +76 -0
- package/src/renderers/electrobun/bun/desktop/update.ts +162 -0
- package/src/renderers/electrobun/bun/desktop/window-events.ts +49 -0
- package/src/renderers/electrobun/bun/desktop/workspace/index.test.ts +63 -0
- package/src/renderers/electrobun/bun/desktop/workspace/index.ts +180 -0
- package/src/renderers/electrobun/bun/desktop/workspace/requests.ts +97 -0
- package/src/renderers/electrobun/bun/index.ts +165 -1001
- package/src/renderers/electrobun/bun/tui-entry.ts +6 -0
- package/src/renderers/electrobun/bun/window/focus.ts +37 -0
- package/src/renderers/electrobun/bun/window/frame.test.ts +40 -0
- package/src/renderers/electrobun/shared/protocol.ts +1 -1
- package/src/renderers/electrobun/view/app-services.ts +4 -375
- package/src/renderers/electrobun/view/build-assets.ts +117 -0
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +398 -0
- package/src/renderers/electrobun/view/config-host.ts +1 -1
- package/src/renderers/electrobun/view/context-menu.test.ts +10 -4
- package/src/renderers/electrobun/view/context-menu.ts +1 -1
- package/src/renderers/electrobun/view/data-table/dom.ts +211 -0
- package/src/renderers/electrobun/view/data-table/index.tsx +358 -0
- package/src/renderers/electrobun/view/data-table/row.tsx +335 -0
- package/src/renderers/electrobun/view/desktop/control-styles.ts +77 -0
- package/src/renderers/electrobun/view/desktop/controls.tsx +421 -0
- package/src/renderers/electrobun/view/desktop/list-view.tsx +200 -0
- package/src/renderers/electrobun/view/desktop/window/bridge.ts +70 -0
- package/src/renderers/electrobun/view/desktop/window/snapshot.test.ts +57 -0
- package/src/renderers/electrobun/view/desktop/window/snapshot.ts +41 -0
- package/src/renderers/electrobun/view/fatal-screen.tsx +2 -2
- package/src/renderers/electrobun/view/host/box.tsx +160 -0
- package/src/renderers/electrobun/view/host/chart-surface.tsx +142 -0
- package/src/renderers/electrobun/view/host/input.tsx +294 -0
- package/src/renderers/electrobun/view/host/mouse.ts +139 -0
- package/src/renderers/electrobun/view/host/native.ts +49 -0
- package/src/renderers/electrobun/view/host/scroll-box.tsx +276 -0
- package/src/renderers/electrobun/view/host/style.ts +124 -0
- package/src/renderers/electrobun/view/host/tabs.tsx +255 -0
- package/src/renderers/electrobun/view/host/text.tsx +121 -0
- package/src/renderers/electrobun/view/http-fetch.ts +1 -1
- package/src/renderers/electrobun/view/input-host.tsx +12 -1
- package/src/renderers/electrobun/view/main.tsx +8 -3
- package/src/renderers/electrobun/view/native-stubs/backend-rpc.ts +59 -0
- package/src/renderers/electrobun/view/native-stubs/chart/kitty-support.ts +9 -0
- package/src/renderers/electrobun/view/remote/asset-data-client.ts +201 -0
- package/src/renderers/electrobun/view/remote/persistence.ts +158 -0
- package/src/renderers/electrobun/view/remote/ticker-repository.ts +26 -0
- package/src/renderers/electrobun/view/styles.css +43 -0
- package/src/renderers/electrobun/view/ui-host.tsx +22 -1469
- package/src/renderers/opentui/chart-surface.tsx +4 -5
- package/src/renderers/opentui/host.tsx +30 -4
- package/src/renderers/opentui/image/loader.test.ts +25 -0
- package/src/renderers/opentui/image/loader.ts +105 -0
- package/src/renderers/opentui/image/surface.tsx +266 -0
- package/src/renderers/opentui/input-host.tsx +12 -1
- package/src/renderers/opentui/start.tsx +2 -2
- package/src/renderers/opentui/test-utils.tsx +2 -2
- package/src/renderers/opentui/ui-host.tsx +1 -1
- package/src/sources/gloomberb-cloud/index.test.ts +660 -0
- package/src/sources/gloomberb-cloud/index.ts +444 -0
- package/src/sources/gloomberb-cloud/news.ts +127 -0
- package/src/sources/gloomberb-cloud/normalizers.ts +354 -0
- package/src/sources/provider-errors.ts +8 -2
- package/src/sources/provider-router/batches.ts +170 -0
- package/src/sources/provider-router/brokers.ts +114 -0
- package/src/sources/provider-router/cache.ts +171 -0
- package/src/sources/provider-router/cached-financials.test.ts +498 -0
- package/src/sources/provider-router/document-routes.ts +153 -0
- package/src/sources/provider-router/financial-routes.ts +225 -0
- package/src/sources/provider-router/financials.ts +259 -0
- package/src/sources/provider-router/history.test.ts +383 -0
- package/src/sources/provider-router/history.ts +448 -0
- package/src/sources/provider-router/index.test.ts +1438 -0
- package/src/sources/provider-router/index.ts +389 -0
- package/src/sources/provider-router/news.ts +36 -0
- package/src/sources/provider-router/primary.ts +164 -0
- package/src/sources/provider-router/route-types.ts +34 -0
- package/src/sources/provider-router/routing.ts +58 -0
- package/src/sources/provider-router/search.ts +183 -0
- package/src/sources/provider-router/sources.ts +55 -0
- package/src/sources/provider-router/streaming.ts +92 -0
- package/src/sources/provider-router/supplemental.ts +373 -0
- package/src/sources/provider-router/test-support.ts +136 -0
- package/src/sources/sec-edgar/content.ts +211 -0
- package/src/sources/sec-edgar.ts +9 -217
- package/src/sources/yahoo-finance/financials.ts +339 -0
- package/src/sources/yahoo-finance/history.ts +106 -0
- package/src/sources/yahoo-finance/http.ts +100 -0
- package/src/sources/yahoo-finance/mappers.ts +409 -0
- package/src/sources/yahoo-finance/options.ts +134 -0
- package/src/sources/yahoo-finance/quote-summary.ts +210 -0
- package/src/sources/yahoo-finance/requests.ts +192 -0
- package/src/sources/yahoo-finance/snapshots.ts +236 -0
- package/src/sources/yahoo-finance/symbols.ts +102 -0
- package/src/sources/yahoo-finance/types.ts +167 -0
- package/src/sources/yahoo-finance.test.ts +116 -12
- package/src/sources/yahoo-finance.ts +115 -1408
- package/src/state/app/activity.test.ts +41 -0
- package/src/state/app/activity.ts +106 -0
- package/src/state/app/bootstrap.test.ts +498 -0
- package/src/state/app/bootstrap.ts +412 -0
- package/src/state/app/context/index.test.ts +564 -0
- package/src/state/app/context/index.test.tsx +193 -0
- package/src/state/app/context/index.tsx +476 -0
- package/src/state/app/context/selector.test.tsx +291 -0
- package/src/state/config-save-scheduler.ts +2 -6
- package/src/state/hooks/inline-tickers.test.tsx +123 -0
- package/src/state/hooks/inline-tickers.ts +212 -0
- package/src/state/hooks/quote-streaming.test.ts +31 -0
- package/src/state/hooks/quote-streaming.test.tsx +70 -0
- package/src/state/hooks/quote-streaming.ts +92 -0
- package/src/state/hooks/session-snapshot.ts +99 -0
- package/src/state/pane-scroll-registry.tsx +1 -1
- package/src/state/selectors-ui.ts +1 -1
- package/src/state/selectors.ts +1 -1
- package/src/test-support/plugin-persistence.ts +112 -0
- package/src/test-support/plugin-runtime.ts +2 -1
- package/src/theme/colors.ts +23 -9
- package/src/theme/themes.test.ts +15 -0
- package/src/tickers/list.test.ts +16 -0
- package/src/tickers/open-target.ts +77 -0
- package/src/tickers/search/index.test.ts +252 -0
- package/src/tickers/search/index.ts +367 -0
- package/src/tickers/search/ranking.ts +387 -0
- package/src/tickers/search/result.ts +27 -0
- package/src/tickers/search/types.ts +41 -0
- package/src/tickers/search/upsert.ts +91 -0
- package/src/tickers/tokenizer.test.ts +31 -0
- package/src/tickers/tokenizer.ts +37 -0
- package/src/types/broker.ts +12 -4
- package/src/types/config.ts +42 -23
- package/src/types/context-menu.ts +1 -1
- package/src/types/data-provider.ts +2 -2
- package/src/types/desktop-window.ts +1 -1
- package/src/types/financials.ts +109 -4
- package/src/types/news-source.ts +0 -1
- package/src/types/persistence.ts +1 -1
- package/src/types/plugin.ts +37 -21
- package/src/types/ticker.ts +1 -0
- package/src/types/trading.ts +23 -1
- package/src/ui/context-menu.tsx +6 -5
- package/src/ui/dialog.tsx +6 -3
- package/src/ui/host.tsx +10 -10
- package/src/ui/index.tsx +14 -33
- package/src/updater/github-releases.test.ts +41 -0
- package/src/updater/github-releases.ts +73 -0
- package/src/updater.test.ts +21 -0
- package/src/updater.ts +10 -3
- package/src/utils/back-navigation.ts +2 -2
- package/src/utils/cli-output.ts +4 -4
- package/src/utils/currency-units.test.ts +23 -1
- package/src/utils/currency-units.ts +56 -0
- package/src/utils/datetime-format.ts +40 -0
- package/src/utils/dom-screenshot.ts +2 -2
- package/src/utils/double-escape-close.ts +1 -1
- package/src/utils/exchanges.ts +2 -2
- package/src/utils/format.ts +0 -7
- package/src/utils/fuzzy-search.ts +1 -1
- package/src/utils/inline-content-tokenizer.test.ts +11 -2
- package/src/utils/inline-content-tokenizer.ts +33 -12
- package/src/utils/keyboard.ts +1 -1
- package/src/utils/link-tokenizer.ts +2 -2
- package/src/utils/options.ts +1 -1
- package/src/utils/price-history.test.ts +20 -0
- package/src/utils/price-history.ts +24 -2
- package/src/utils/relative-time.ts +8 -0
- package/src/utils/selection-clipboard.ts +1 -1
- package/src/utils/shortcut-labels.ts +2 -2
- package/src/utils/sort-values.ts +17 -0
- package/src/utils/terminal-input-reset.ts +1 -1
- package/src/utils/text-wrap.ts +20 -0
- package/src/version.ts +1 -1
- package/src/components/chart/chart-controller.test.ts +0 -110
- package/src/components/chart/chart-controller.ts +0 -650
- package/src/components/chart/chart-data.ts +0 -350
- package/src/components/chart/chart-indicator-selector.tsx +0 -75
- package/src/components/chart/chart-pane-settings.ts +0 -37
- package/src/components/chart/chart-renderer.ts +0 -1562
- package/src/components/chart/chart-resolution.test.ts +0 -87
- package/src/components/chart/chart-resolution.ts +0 -405
- package/src/components/chart/chart-scroll.test.ts +0 -70
- package/src/components/chart/chart-scroll.ts +0 -104
- package/src/components/chart/chart-types.ts +0 -119
- package/src/components/chart/chart-viewport.test.ts +0 -29
- package/src/components/chart/chart-viewport.ts +0 -50
- package/src/components/chart/chart.test.ts +0 -922
- package/src/components/chart/comparison-chart-data.test.ts +0 -105
- package/src/components/chart/comparison-chart-data.ts +0 -292
- package/src/components/chart/comparison-chart-renderer.test.ts +0 -187
- package/src/components/chart/comparison-chart-renderer.ts +0 -437
- package/src/components/chart/native/kitty-adapter.ts +0 -9
- package/src/components/chart/native/kitty-manager.ts +0 -142
- package/src/components/chart/native/kitty-support.ts +0 -71
- package/src/components/chart/native/kitty.test.ts +0 -728
- package/src/components/chart/native/surface-manager.ts +0 -225
- package/src/components/chart/native/surface-sync.ts +0 -34
- package/src/components/chart/native/surface-visibility.ts +0 -48
- package/src/components/chart/static-chart-surface.test.tsx +0 -51
- package/src/components/chart/static-chart-surface.tsx +0 -217
- package/src/components/chart/stock-chart-renderer-switch.test.tsx +0 -1323
- package/src/components/chart/stock-chart.test.ts +0 -330
- package/src/components/chart/stock-chart.tsx +0 -4148
- package/src/components/command-bar/__snapshots__/command-bar.test.tsx.snap +0 -109
- package/src/components/command-bar/command-bar.test.tsx +0 -3244
- package/src/components/command-bar/command-bar.tsx +0 -5886
- package/src/components/command-bar/command-registry.ts +0 -267
- package/src/components/command-bar/confirm-body.tsx +0 -51
- package/src/components/command-bar/list-model.ts +0 -80
- package/src/components/command-bar/pane-template-display.ts +0 -8
- package/src/components/command-bar/root-shortcuts.ts +0 -188
- package/src/components/command-bar/workflow-ops.test.ts +0 -144
- package/src/components/command-bar/workflow-ops.ts +0 -459
- package/src/components/command-bar/workflow-types.ts +0 -127
- package/src/components/data-table-stack-view.test.tsx +0 -241
- package/src/components/data-table-stack-view.tsx +0 -59
- package/src/components/data-table-view.test.tsx +0 -211
- package/src/components/data-table-view.tsx +0 -244
- package/src/components/feed-data-table-stack-view.test.tsx +0 -225
- package/src/components/feed-data-table-stack-view.tsx +0 -359
- package/src/components/layout/pane-content.test.tsx +0 -64
- package/src/components/layout/pane-content.tsx +0 -44
- package/src/components/layout/pane-cycle-order.test.ts +0 -30
- package/src/components/layout/pane-cycle-order.ts +0 -32
- package/src/components/layout/pane-footer.test.tsx +0 -195
- package/src/components/layout/pane-footer.tsx +0 -432
- package/src/components/layout/pane-header.test.tsx +0 -39
- package/src/components/layout/pane-header.tsx +0 -248
- package/src/components/layout/pane-keyboard-scroll.test.tsx +0 -226
- package/src/components/layout/pane-sizing.ts +0 -34
- package/src/components/layout/pane-title.ts +0 -38
- package/src/components/layout/pane.tsx +0 -129
- package/src/components/layout/shell.test.tsx +0 -1453
- package/src/components/layout/shell.tsx +0 -1960
- package/src/components/price-sparkline-view.tsx +0 -463
- package/src/components/price-sparkline.ts +0 -46
- package/src/components/speedometer-gauge.test.tsx +0 -45
- package/src/components/speedometer-gauge.tsx +0 -562
- package/src/components/ticker-badge-list.tsx +0 -53
- package/src/components/ticker-badge-text.test.tsx +0 -253
- package/src/components/ticker-badge-text.tsx +0 -113
- package/src/components/ticker-badge.tsx +0 -109
- package/src/components/ticker-list-table-view.tsx +0 -233
- package/src/components/ticker-list-table.test.tsx +0 -210
- package/src/components/ticker-list-table.tsx +0 -458
- package/src/components/ui/data-table.tsx +0 -522
- package/src/components/ui/multi-select-dialog.tsx +0 -336
- package/src/core/state/app-state.ts +0 -1009
- package/src/data/config-layout.ts +0 -225
- package/src/data/config-store-node.ts +0 -478
- package/src/data/config-store.test.ts +0 -481
- package/src/data/config-store.ts +0 -64
- package/src/data/sqlite-cache.test.ts +0 -151
- package/src/data/sqlite-database.ts +0 -68
- package/src/data/sqlite-json.ts +0 -16
- package/src/data/sqlite-retry.test.ts +0 -63
- package/src/market-data/coordinator-subscriptions.test.ts +0 -209
- package/src/market-data/coordinator.test.ts +0 -830
- package/src/market-data/coordinator.ts +0 -1155
- package/src/plugins/builtin/ai/screener-contract.test.ts +0 -117
- package/src/plugins/builtin/ai/screener-contract.ts +0 -174
- package/src/plugins/builtin/ai/screener-pane.test.tsx +0 -348
- package/src/plugins/builtin/ai/screener-pane.tsx +0 -1118
- package/src/plugins/builtin/ai/utils.ts +0 -1
- package/src/plugins/builtin/ask-ai.test.tsx +0 -348
- package/src/plugins/builtin/chat-controller.test.ts +0 -1376
- package/src/plugins/builtin/chat-controller.ts +0 -1248
- package/src/plugins/builtin/chat.test.tsx +0 -2245
- package/src/plugins/builtin/chat.tsx +0 -2267
- package/src/plugins/builtin/cloud-auth-actions.tsx +0 -72
- package/src/plugins/builtin/cloud-tweets.tsx +0 -896
- package/src/plugins/builtin/comparison-chart.test.tsx +0 -532
- package/src/plugins/builtin/comparison-chart.tsx +0 -194
- package/src/plugins/builtin/debug.tsx +0 -365
- package/src/plugins/builtin/earnings/earnings-cache.test.ts +0 -181
- package/src/plugins/builtin/earnings/earnings-cache.ts +0 -145
- package/src/plugins/builtin/earnings/earnings-data.test.ts +0 -90
- package/src/plugins/builtin/earnings/earnings-data.ts +0 -115
- package/src/plugins/builtin/fear-greed/fear-greed-data.test.ts +0 -72
- package/src/plugins/builtin/fear-greed/fear-greed-data.ts +0 -366
- package/src/plugins/builtin/help.test.tsx +0 -166
- package/src/plugins/builtin/help.tsx +0 -450
- package/src/plugins/builtin/layout-manager.tsx +0 -247
- package/src/plugins/builtin/manual-entry.tsx +0 -25
- package/src/plugins/builtin/news-wire/breaking-notifications.test.ts +0 -98
- package/src/plugins/builtin/news-wire/breaking-notifications.ts +0 -110
- package/src/plugins/builtin/news-wire/breaking-pane.test.tsx +0 -156
- package/src/plugins/builtin/news-wire/breaking-pane.tsx +0 -68
- package/src/plugins/builtin/news-wire/categories.ts +0 -114
- package/src/plugins/builtin/news-wire/default-feeds.ts +0 -3
- package/src/plugins/builtin/news-wire/feed-config.test.ts +0 -90
- package/src/plugins/builtin/news-wire/feed-config.ts +0 -216
- package/src/plugins/builtin/news-wire/index.tsx +0 -129
- package/src/plugins/builtin/news-wire/industry-pane.tsx +0 -126
- package/src/plugins/builtin/news-wire/news-detail-view.tsx +0 -299
- package/src/plugins/builtin/news-wire/news-footer.ts +0 -28
- package/src/plugins/builtin/news-wire/news-preset-pane.tsx +0 -98
- package/src/plugins/builtin/news-wire/news-query-presets.ts +0 -40
- package/src/plugins/builtin/news-wire/news-table.test.tsx +0 -206
- package/src/plugins/builtin/news-wire/news-table.tsx +0 -296
- package/src/plugins/builtin/news-wire/persisted-articles.ts +0 -98
- package/src/plugins/builtin/news-wire/read-state.ts +0 -76
- package/src/plugins/builtin/news-wire/rss-parser.test.ts +0 -184
- package/src/plugins/builtin/news-wire/rss-parser.ts +0 -213
- package/src/plugins/builtin/news-wire/rss-source.test.ts +0 -159
- package/src/plugins/builtin/news-wire/rss-source.ts +0 -181
- package/src/plugins/builtin/news.tsx +0 -194
- package/src/plugins/builtin/notes.tsx +0 -561
- package/src/plugins/builtin/options.test.tsx +0 -241
- package/src/plugins/builtin/options.tsx +0 -542
- package/src/plugins/builtin/portfolio-list/cli/commands.ts +0 -657
- package/src/plugins/builtin/portfolio-list/pane.tsx +0 -724
- package/src/plugins/builtin/portfolio-list/quick-add.tsx +0 -422
- package/src/plugins/builtin/portfolio-list/summary.tsx +0 -275
- package/src/plugins/builtin/portfolio-list.test.ts +0 -133
- package/src/plugins/builtin/portfolio-list.test.tsx +0 -1535
- package/src/plugins/builtin/portfolio-metrics.test.ts +0 -236
- package/src/plugins/builtin/quote-monitor.test.tsx +0 -222
- package/src/plugins/builtin/sec-filing-display.tsx +0 -84
- package/src/plugins/builtin/sec.tsx +0 -342
- package/src/plugins/builtin/ticker-detail/financials-tab.tsx +0 -461
- package/src/plugins/builtin/ticker-detail/quote-monitor.tsx +0 -479
- package/src/plugins/builtin/ticker-detail-chart-tab-switch.test.tsx +0 -269
- package/src/plugins/builtin/ticker-detail.test.tsx +0 -888
- package/src/plugins/builtin/ticker-surface.ts +0 -68
- package/src/plugins/builtin/yahoo.ts +0 -72
- package/src/plugins/catalog-ui.test.ts +0 -24
- package/src/plugins/ibkr/__snapshots__/trade-tab.test.tsx.snap +0 -35
- package/src/plugins/ibkr/flex.test.ts +0 -162
- package/src/plugins/ibkr/flex.ts +0 -371
- package/src/plugins/ibkr/gateway-helpers.ts +0 -33
- package/src/plugins/ibkr/gateway-selection.ts +0 -51
- package/src/plugins/ibkr/gateway-service-native.ts +0 -2377
- package/src/plugins/ibkr/gateway-service.test.ts +0 -584
- package/src/plugins/ibkr/gateway-service.ts +0 -433
- package/src/plugins/ibkr/gateway-types.ts +0 -27
- package/src/plugins/ibkr/price-normalization.test.ts +0 -33
- package/src/plugins/ibkr/price-normalization.ts +0 -60
- package/src/plugins/ibkr/trade-badge.tsx +0 -28
- package/src/plugins/ibkr/trade-tab.test.tsx +0 -276
- package/src/plugins/ibkr/trade-tab.tsx +0 -1117
- package/src/plugins/ibkr/trade-utils.test.ts +0 -175
- package/src/plugins/ibkr/trade-utils.ts +0 -150
- package/src/plugins/ibkr/trading-pane.tsx +0 -474
- package/src/plugins/ibkr/trading-state.test.ts +0 -109
- package/src/plugins/ibkr/trading-state.ts +0 -339
- package/src/plugins/plugin-runtime.test.tsx +0 -323
- package/src/plugins/plugin-runtime.tsx +0 -433
- package/src/plugins/prediction-markets/controller-data.ts +0 -785
- package/src/plugins/prediction-markets/controller.ts +0 -659
- package/src/plugins/prediction-markets/services/kalshi-adapter.ts +0 -572
- package/src/plugins/prediction-markets/services/polymarket-adapter.ts +0 -696
- package/src/plugins/prediction-markets/services/polymarket-ws.ts +0 -128
- package/src/plugins/registry.test.ts +0 -362
- package/src/plugins/registry.ts +0 -854
- package/src/renderers/electrobun/bun/application-menu-click.test.ts +0 -50
- package/src/renderers/electrobun/bun/application-menu-click.ts +0 -58
- package/src/renderers/electrobun/bun/application-menu.ts +0 -123
- package/src/renderers/electrobun/bun/context-menu-click.test.ts +0 -67
- package/src/renderers/electrobun/bun/context-menu-normalize.test.ts +0 -52
- package/src/renderers/electrobun/bun/context-menu-normalize.ts +0 -67
- package/src/renderers/electrobun/bun/desktop-workspace.test.ts +0 -63
- package/src/renderers/electrobun/bun/desktop-workspace.ts +0 -180
- package/src/renderers/electrobun/bun/window-focus.ts +0 -37
- package/src/renderers/electrobun/bun/window-frame.test.ts +0 -40
- package/src/renderers/electrobun/view/data-table.tsx +0 -810
- package/src/renderers/electrobun/view/desktop-controls.tsx +0 -673
- package/src/renderers/electrobun/view/desktop-window-bridge.ts +0 -70
- package/src/renderers/electrobun/view/desktop-window-snapshot.test.ts +0 -57
- package/src/renderers/electrobun/view/desktop-window-snapshot.ts +0 -41
- package/src/renderers/electrobun/view/native-stubs/chart-kitty-support.ts +0 -9
- package/src/renderers/opentui/image-loader.test.ts +0 -25
- package/src/renderers/opentui/image-loader.ts +0 -105
- package/src/renderers/opentui/image-surface.tsx +0 -266
- package/src/sources/gloomberb-cloud.test.ts +0 -637
- package/src/sources/gloomberb-cloud.ts +0 -828
- package/src/sources/provider-router.test.ts +0 -2600
- package/src/sources/provider-router.ts +0 -2231
- package/src/state/app-activity.test.ts +0 -41
- package/src/state/app-activity.ts +0 -106
- package/src/state/app-bootstrap.test.ts +0 -498
- package/src/state/app-bootstrap.ts +0 -411
- package/src/state/app-context-selector.test.tsx +0 -369
- package/src/state/app-context.test.ts +0 -670
- package/src/state/app-context.test.tsx +0 -193
- package/src/state/app-context.tsx +0 -485
- package/src/state/use-inline-tickers.test.tsx +0 -73
- package/src/state/use-inline-tickers.ts +0 -188
- package/src/state/use-quote-streaming.test.ts +0 -31
- package/src/state/use-quote-streaming.test.tsx +0 -70
- package/src/state/use-quote-streaming.ts +0 -92
- package/src/state/use-session-snapshot.ts +0 -99
- package/src/utils/api-client.test.ts +0 -603
- package/src/utils/api-client.ts +0 -1379
- package/src/utils/market-format.test.ts +0 -109
- package/src/utils/market-format.ts +0 -299
- package/src/utils/market-status.ts +0 -141
- package/src/utils/quote-freshness.test.ts +0 -150
- package/src/utils/quote-freshness.ts +0 -145
- package/src/utils/quote-resolution.test.ts +0 -277
- package/src/utils/quote-resolution.ts +0 -642
- package/src/utils/quote-time.test.ts +0 -34
- package/src/utils/quote-time.ts +0 -59
- package/src/utils/ticker-list.test.ts +0 -16
- package/src/utils/ticker-search.test.ts +0 -227
- package/src/utils/ticker-search.ts +0 -926
- package/src/utils/ticker-tokenizer.test.ts +0 -31
- package/src/utils/ticker-tokenizer.ts +0 -37
- /package/src/components/chart/native/{kitty-protocol.ts → kitty/protocol.ts} +0 -0
- /package/src/components/ui/{multi-select.ts → multi-select/index.ts} +0 -0
- /package/src/data/{sqlite-retry.ts → sqlite/retry.ts} +0 -0
- /package/src/plugins/builtin/{news-wire → news/wire}/hash.ts +0 -0
- /package/src/plugins/builtin/{news-wire → news/wire}/read-state.test.ts +0 -0
- /package/src/plugins/builtin/{notes-files.ts → notes/files.ts} +0 -0
- /package/src/renderers/electrobun/bun/{context-menu-click.ts → context-menu/click.ts} +0 -0
- /package/src/renderers/electrobun/bun/{window-frame.ts → window/frame.ts} +0 -0
- /package/src/renderers/electrobun/view/native-stubs/{chart-surface-manager.ts → chart/surface-manager.ts} +0 -0
- /package/src/renderers/electrobun/view/native-stubs/{chart-surface-sync.ts → chart/surface-sync.ts} +0 -0
- /package/src/{utils/ticker-list.ts → tickers/list.ts} +0 -0
- /package/src/{utils/ticker-metadata.ts → tickers/metadata.ts} +0 -0
|
@@ -1,2039 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useShortcut } from "../../react/input";
|
|
5
|
-
import { memo, useEffect, useMemo, useRef, useState } from "react";
|
|
6
|
-
import { useChartQueries } from "../../market-data/hooks";
|
|
7
|
-
import { buildChartKey } from "../../market-data/selectors";
|
|
8
|
-
import { useAppSelector, usePaneSettingValue } from "../../state/app-context";
|
|
9
|
-
import { usePaneFooter, type PaneHint } from "../layout/pane-footer";
|
|
10
|
-
import { blendHex, colors, getComparisonSeriesColor } from "../../theme/colors";
|
|
11
|
-
import { useThemeColors } from "../../theme/theme-context";
|
|
12
|
-
import type { BrokerContractRef } from "../../types/instrument";
|
|
13
|
-
import type { PricePoint } from "../../types/financials";
|
|
14
|
-
import { formatPercentRaw } from "../../utils/format";
|
|
15
|
-
import { formatMarketPriceWithCurrency } from "../../utils/market-format";
|
|
16
|
-
import { getSharedMarketData } from "../../plugins/registry";
|
|
17
|
-
import {
|
|
18
|
-
applyComparisonZoomAroundAnchor,
|
|
19
|
-
getMaxComparisonPanOffset,
|
|
20
|
-
getVisibleComparisonWindow,
|
|
21
|
-
projectComparisonChartData,
|
|
22
|
-
} from "./comparison-chart-data";
|
|
23
|
-
import { usePersistChartControlSelection } from "./chart-pane-settings";
|
|
24
|
-
import {
|
|
25
|
-
applyBufferedPanExpansion,
|
|
26
|
-
consumeScrollPanMovement,
|
|
27
|
-
getKeyboardPanCellCount,
|
|
28
|
-
resolveDragPanOffset,
|
|
29
|
-
} from "./chart-scroll";
|
|
30
|
-
import {
|
|
31
|
-
buildVisibleDateWindow,
|
|
32
|
-
clearActivePreset,
|
|
33
|
-
needsCanonicalPresetViewportReset,
|
|
34
|
-
resolveChartBodyState,
|
|
35
|
-
resolveCanonicalPresetViewport,
|
|
36
|
-
resolvePresetSelection,
|
|
37
|
-
resolvePresetRangeViewport,
|
|
38
|
-
resolveResolutionSelection,
|
|
39
|
-
resolveStoredChartSelection,
|
|
40
|
-
resolveVisibleActivePreset,
|
|
41
|
-
} from "./chart-controller";
|
|
42
|
-
import {
|
|
43
|
-
buildChartResolutionSupportMap,
|
|
44
|
-
clampTimeRangeToMaxRange,
|
|
45
|
-
DEFAULT_COMPARISON_CHART_RANGE_PRESET,
|
|
46
|
-
DEFAULT_COMPARISON_CHART_RESOLUTION,
|
|
47
|
-
DEFAULT_VISIBLE_MANUAL_CHART_RESOLUTIONS,
|
|
48
|
-
getChartResolutionLabel,
|
|
49
|
-
getNextBufferRange,
|
|
50
|
-
getPresetResolution,
|
|
51
|
-
getSupportMaxRange,
|
|
52
|
-
isRangePresetSupported,
|
|
53
|
-
intersectChartResolutionSupport,
|
|
54
|
-
normalizeChartResolutionSupport,
|
|
55
|
-
sortChartResolutions,
|
|
56
|
-
type ChartResolutionSupport,
|
|
57
|
-
} from "./chart-resolution";
|
|
58
|
-
import { RIGHT_EDGE_ANCHOR_RATIO, resolveAnchoredChartZoom } from "./chart-viewport";
|
|
59
|
-
import {
|
|
60
|
-
buildComparisonChartScene,
|
|
61
|
-
formatComparisonCursorAxisValue,
|
|
62
|
-
renderComparisonChart,
|
|
63
|
-
} from "./comparison-chart-renderer";
|
|
64
|
-
import {
|
|
65
|
-
CELL_CURSOR_SNAP_DISTANCE,
|
|
66
|
-
sameCursorPosition,
|
|
67
|
-
stepCursorTowards,
|
|
68
|
-
type ChartCursorMotionKind,
|
|
69
|
-
} from "./cursor-motion";
|
|
70
|
-
import {
|
|
71
|
-
COMPARISON_RENDER_MODES,
|
|
72
|
-
TIME_RANGES,
|
|
73
|
-
type ChartAxisMode,
|
|
74
|
-
type ChartRendererPreference,
|
|
75
|
-
type ChartResolution,
|
|
76
|
-
type ComparisonChartRenderMode,
|
|
77
|
-
type ComparisonChartViewState,
|
|
78
|
-
type ResolvedChartRenderer,
|
|
79
|
-
type TimeRange,
|
|
80
|
-
} from "./chart-types";
|
|
81
|
-
import {
|
|
82
|
-
computeBitmapSize,
|
|
83
|
-
renderNativeComparisonChartBase,
|
|
84
|
-
renderNativeCrosshairOverlay,
|
|
85
|
-
type CellRect,
|
|
86
|
-
type NativeChartBitmap,
|
|
87
|
-
type NativeCrosshairOverlay,
|
|
88
|
-
} from "./native/chart-rasterizer";
|
|
89
|
-
import { ensureKittySupport, getCachedKittySupport } from "./native/kitty-support";
|
|
90
|
-
import { resolveChartRendererState } from "./native/renderer-selection";
|
|
91
|
-
import { getNativeSurfaceManager } from "./native/surface-manager";
|
|
92
|
-
import { syncCachedNativeSurface } from "./native/surface-sync";
|
|
93
|
-
import {
|
|
94
|
-
getRenderableCellRect,
|
|
95
|
-
resolveNativeSurfaceVisibleRect,
|
|
96
|
-
type NativeSurfaceRenderableNode,
|
|
97
|
-
} from "./native/surface-visibility";
|
|
98
|
-
import { resolveChartAxisWidth, type StyledContent } from "./chart-renderer";
|
|
99
|
-
import { TimeAxisLabel } from "./time-axis-label";
|
|
100
|
-
import { PriceAxisLabels } from "./price-axis-labels";
|
|
101
|
-
import { getChartMarketSessionKey, resolveChartMarketSession } from "./market-session";
|
|
1
|
+
import { MemoizedComparisonStockChartView } from "./comparison-stock-chart/view";
|
|
2
|
+
import { useComparisonChartSymbolSources } from "./comparison-stock-chart/sources";
|
|
3
|
+
import type { ComparisonStockChartProps } from "./comparison-stock-chart/types";
|
|
102
4
|
|
|
103
|
-
|
|
104
|
-
area: "A",
|
|
105
|
-
line: "L",
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
interface ComparisonStockChartProps {
|
|
109
|
-
paneId: string;
|
|
110
|
-
width: number;
|
|
111
|
-
height: number;
|
|
112
|
-
focused: boolean;
|
|
113
|
-
symbols: string[];
|
|
114
|
-
axisMode: ChartAxisMode;
|
|
115
|
-
onOpenSymbol: (symbol: string) => void;
|
|
116
|
-
onEditTickers?: () => void;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
interface ComparisonChartSymbolSource {
|
|
120
|
-
symbol: string;
|
|
121
|
-
currency: string | undefined;
|
|
122
|
-
exchange: string;
|
|
123
|
-
brokerId: string | undefined;
|
|
124
|
-
brokerInstanceId: string | undefined;
|
|
125
|
-
instrument: BrokerContractRef | null;
|
|
126
|
-
priceHistory: PricePoint[];
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
interface ComparisonStockChartViewProps extends ComparisonStockChartProps {
|
|
130
|
-
defaultRenderMode: string | undefined;
|
|
131
|
-
preferredRenderer: ChartRendererPreference;
|
|
132
|
-
symbolSources: ComparisonChartSymbolSource[];
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
interface DragState {
|
|
136
|
-
startGlobalX: number;
|
|
137
|
-
startPanOffset: number;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
type PendingExpansionAction =
|
|
141
|
-
| { kind: "zoom-out"; targetVisibleCount: number; anchorRatio: number }
|
|
142
|
-
| { kind: "pan-left"; targetPanOffset: number }
|
|
143
|
-
| null;
|
|
144
|
-
|
|
145
|
-
interface ChartMouseEvent {
|
|
146
|
-
x: number;
|
|
147
|
-
y: number;
|
|
148
|
-
pixelX?: number;
|
|
149
|
-
pixelY?: number;
|
|
150
|
-
stopPropagation?: () => void;
|
|
151
|
-
preventDefault?: () => void;
|
|
152
|
-
modifiers: {
|
|
153
|
-
shift: boolean;
|
|
154
|
-
alt: boolean;
|
|
155
|
-
ctrl: boolean;
|
|
156
|
-
};
|
|
157
|
-
scroll?: {
|
|
158
|
-
direction: "up" | "down" | "left" | "right";
|
|
159
|
-
delta: number;
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
interface LocalPlotPointer {
|
|
164
|
-
cellX: number;
|
|
165
|
-
cellY: number;
|
|
166
|
-
pixelX: number | null;
|
|
167
|
-
pixelY: number | null;
|
|
168
|
-
hasPixelPrecision: boolean;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
interface DisplayCursorState {
|
|
172
|
-
cellX: number | null;
|
|
173
|
-
cellY: number | null;
|
|
174
|
-
pixelX: number | null;
|
|
175
|
-
pixelY: number | null;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const EMPTY_DISPLAY_CURSOR: DisplayCursorState = {
|
|
179
|
-
cellX: null,
|
|
180
|
-
cellY: null,
|
|
181
|
-
pixelX: null,
|
|
182
|
-
pixelY: null,
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
const PIXEL_CURSOR_SNAP_DISTANCE = 0.5;
|
|
186
|
-
const globalAnimationFrame = globalThis as typeof globalThis & {
|
|
187
|
-
requestAnimationFrame?: (callback: (timestamp: number) => void) => number;
|
|
188
|
-
cancelAnimationFrame?: (handle: number) => void;
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
function clamp(value: number, min: number, max: number): number {
|
|
192
|
-
return Math.max(min, Math.min(max, value));
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function requestAnimationFrameSafe(callback: (timestamp: number) => void): number {
|
|
196
|
-
if (typeof globalAnimationFrame.requestAnimationFrame === "function") {
|
|
197
|
-
return globalAnimationFrame.requestAnimationFrame(callback);
|
|
198
|
-
}
|
|
199
|
-
return globalThis.setTimeout(() => callback(Date.now()), 16) as unknown as number;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
function cancelAnimationFrameSafe(handle: number) {
|
|
203
|
-
if (typeof globalAnimationFrame.cancelAnimationFrame === "function") {
|
|
204
|
-
globalAnimationFrame.cancelAnimationFrame(handle);
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
clearTimeout(handle);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function getRendererCellMetrics(renderer: Pick<CliRenderer, "resolution" | "terminalWidth" | "terminalHeight">) {
|
|
211
|
-
if (!renderer.resolution) return null;
|
|
212
|
-
const cellWidth = renderer.resolution.width / Math.max(renderer.terminalWidth, 1);
|
|
213
|
-
const cellHeight = renderer.resolution.height / Math.max(renderer.terminalHeight, 1);
|
|
214
|
-
if (!(cellWidth > 0) || !(cellHeight > 0)) return null;
|
|
215
|
-
return { cellWidth, cellHeight };
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function getRenderablePixelSize(
|
|
219
|
-
renderable: Pick<RenderableNode, "width" | "height"> | null,
|
|
220
|
-
renderer: Pick<CliRenderer, "resolution" | "terminalWidth" | "terminalHeight">,
|
|
221
|
-
) {
|
|
222
|
-
const metrics = getRendererCellMetrics(renderer);
|
|
223
|
-
if (!renderable || !metrics) return null;
|
|
224
|
-
return {
|
|
225
|
-
pixelWidth: Math.max(renderable.width * metrics.cellWidth, 1),
|
|
226
|
-
pixelHeight: Math.max(renderable.height * metrics.cellHeight, 1),
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
function projectCellCursorToLocalPixels(
|
|
231
|
-
cellX: number,
|
|
232
|
-
cellY: number,
|
|
233
|
-
renderable: Pick<RenderableNode, "width" | "height"> | null,
|
|
234
|
-
renderer: Pick<CliRenderer, "resolution" | "terminalWidth" | "terminalHeight">,
|
|
235
|
-
): { pixelX: number; pixelY: number } | null {
|
|
236
|
-
const pixelSize = getRenderablePixelSize(renderable, renderer);
|
|
237
|
-
if (!renderable || !pixelSize) return null;
|
|
238
|
-
|
|
239
|
-
return {
|
|
240
|
-
pixelX: renderable.width <= 1
|
|
241
|
-
? 0
|
|
242
|
-
: clamp(
|
|
243
|
-
(cellX / Math.max(renderable.width - 1, 1)) * Math.max(pixelSize.pixelWidth - 1, 0),
|
|
244
|
-
0,
|
|
245
|
-
Math.max(pixelSize.pixelWidth - 1, 0),
|
|
246
|
-
),
|
|
247
|
-
pixelY: renderable.height <= 1
|
|
248
|
-
? 0
|
|
249
|
-
: clamp(
|
|
250
|
-
(cellY / Math.max(renderable.height - 1, 1)) * Math.max(pixelSize.pixelHeight - 1, 0),
|
|
251
|
-
0,
|
|
252
|
-
Math.max(pixelSize.pixelHeight - 1, 0),
|
|
253
|
-
),
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
function scaleLocalPixelCoordinate(value: number | null, sourceExtent: number, targetExtent: number): number | null {
|
|
258
|
-
if (value === null) return null;
|
|
259
|
-
if (targetExtent <= 1) return 0;
|
|
260
|
-
if (!(sourceExtent > 1)) {
|
|
261
|
-
return clamp(value, 0, Math.max(targetExtent - 1, 0));
|
|
262
|
-
}
|
|
263
|
-
return clamp(
|
|
264
|
-
(value / Math.max(sourceExtent - 1, 1)) * Math.max(targetExtent - 1, 0),
|
|
265
|
-
0,
|
|
266
|
-
Math.max(targetExtent - 1, 0),
|
|
267
|
-
);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function toCursorPosition(x: number | null, y: number | null) {
|
|
271
|
-
return { x, y };
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
function sameDisplayCursorState(
|
|
275
|
-
left: DisplayCursorState,
|
|
276
|
-
right: DisplayCursorState,
|
|
277
|
-
cellEpsilon = 0,
|
|
278
|
-
pixelEpsilon = 0,
|
|
279
|
-
): boolean {
|
|
280
|
-
return sameCursorPosition(toCursorPosition(left.cellX, left.cellY), toCursorPosition(right.cellX, right.cellY), cellEpsilon)
|
|
281
|
-
&& sameCursorPosition(toCursorPosition(left.pixelX, left.pixelY), toCursorPosition(right.pixelX, right.pixelY), pixelEpsilon);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function buildDisplayCursorState(
|
|
285
|
-
cellX: number | null,
|
|
286
|
-
cellY: number | null,
|
|
287
|
-
renderable: BoxRenderable | null,
|
|
288
|
-
renderer: Pick<CliRenderer, "resolution" | "terminalWidth" | "terminalHeight">,
|
|
289
|
-
pixelX: number | null = null,
|
|
290
|
-
pixelY: number | null = null,
|
|
291
|
-
): DisplayCursorState {
|
|
292
|
-
if (cellX === null || cellY === null) return EMPTY_DISPLAY_CURSOR;
|
|
293
|
-
if (pixelX !== null && pixelY !== null) {
|
|
294
|
-
return { cellX, cellY, pixelX, pixelY };
|
|
295
|
-
}
|
|
296
|
-
const derivedPixels = projectCellCursorToLocalPixels(cellX, cellY, renderable, renderer);
|
|
297
|
-
return {
|
|
298
|
-
cellX,
|
|
299
|
-
cellY,
|
|
300
|
-
pixelX: derivedPixels?.pixelX ?? null,
|
|
301
|
-
pixelY: derivedPixels?.pixelY ?? null,
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
function getLocalPlotPointer(
|
|
306
|
-
event: ChartMouseEvent,
|
|
307
|
-
renderable: BoxRenderable | null,
|
|
308
|
-
renderer: Pick<CliRenderer, "resolution" | "terminalWidth" | "terminalHeight">,
|
|
309
|
-
): LocalPlotPointer | null {
|
|
310
|
-
if (!renderable) return null;
|
|
311
|
-
|
|
312
|
-
const localCellX = event.x - renderable.x;
|
|
313
|
-
const localCellY = event.y - renderable.y;
|
|
314
|
-
if (localCellX < 0 || localCellX >= renderable.width || localCellY < 0 || localCellY >= renderable.height) {
|
|
315
|
-
return null;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
const metrics = getRendererCellMetrics(renderer);
|
|
319
|
-
if (event.pixelX === undefined || event.pixelY === undefined || !metrics) {
|
|
320
|
-
return {
|
|
321
|
-
cellX: localCellX,
|
|
322
|
-
cellY: localCellY,
|
|
323
|
-
pixelX: null,
|
|
324
|
-
pixelY: null,
|
|
325
|
-
hasPixelPrecision: false,
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
const pixelLeft = renderable.x * metrics.cellWidth;
|
|
330
|
-
const pixelTop = renderable.y * metrics.cellHeight;
|
|
331
|
-
const pixelWidth = renderable.width * metrics.cellWidth;
|
|
332
|
-
const pixelHeight = renderable.height * metrics.cellHeight;
|
|
333
|
-
const localPixelX = event.pixelX - pixelLeft;
|
|
334
|
-
const localPixelY = event.pixelY - pixelTop;
|
|
335
|
-
|
|
336
|
-
if (localPixelX < 0 || localPixelY < 0 || localPixelX > pixelWidth || localPixelY > pixelHeight) {
|
|
337
|
-
return {
|
|
338
|
-
cellX: localCellX,
|
|
339
|
-
cellY: localCellY,
|
|
340
|
-
pixelX: null,
|
|
341
|
-
pixelY: null,
|
|
342
|
-
hasPixelPrecision: false,
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
return {
|
|
347
|
-
cellX: renderable.width <= 1
|
|
348
|
-
? 0
|
|
349
|
-
: clamp(
|
|
350
|
-
(localPixelX / Math.max(pixelWidth - 1, 1)) * Math.max(renderable.width - 1, 0),
|
|
351
|
-
0,
|
|
352
|
-
Math.max(renderable.width - 1, 0),
|
|
353
|
-
),
|
|
354
|
-
cellY: renderable.height <= 1
|
|
355
|
-
? 0
|
|
356
|
-
: clamp(
|
|
357
|
-
(localPixelY / Math.max(pixelHeight - 1, 1)) * Math.max(renderable.height - 1, 0),
|
|
358
|
-
0,
|
|
359
|
-
Math.max(renderable.height - 1, 0),
|
|
360
|
-
),
|
|
361
|
-
pixelX: clamp(localPixelX, 0, Math.max(pixelWidth - 1, 0)),
|
|
362
|
-
pixelY: clamp(localPixelY, 0, Math.max(pixelHeight - 1, 0)),
|
|
363
|
-
hasPixelPrecision: true,
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
function getGlobalMouseX(
|
|
368
|
-
event: ChartMouseEvent,
|
|
369
|
-
renderer: Pick<CliRenderer, "resolution" | "terminalWidth" | "terminalHeight">,
|
|
370
|
-
): number {
|
|
371
|
-
const metrics = getRendererCellMetrics(renderer);
|
|
372
|
-
if (event.pixelX === undefined || !metrics) return event.x;
|
|
373
|
-
return event.pixelX / metrics.cellWidth;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
function resolveCursorMotionKind(
|
|
377
|
-
event: ChartMouseEvent,
|
|
378
|
-
renderer: Pick<CliRenderer, "resolution" | "terminalWidth" | "terminalHeight">,
|
|
379
|
-
): ChartCursorMotionKind {
|
|
380
|
-
return event.pixelX !== undefined && event.pixelY !== undefined && getRendererCellMetrics(renderer)
|
|
381
|
-
? "pixel"
|
|
382
|
-
: "cell";
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
function buildBlankPlotLines(width: number, height: number): string[] {
|
|
386
|
-
return Array.from({ length: height }, () => " ".repeat(width));
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
function buildComparisonNativeBitmapKey(
|
|
390
|
-
symbolCount: number,
|
|
391
|
-
projection: ReturnType<typeof projectComparisonChartData>,
|
|
392
|
-
selectedSymbol: string | null,
|
|
393
|
-
pixelWidth: number,
|
|
394
|
-
pixelHeight: number,
|
|
395
|
-
paletteKey: string,
|
|
396
|
-
marketSessionKey: string,
|
|
397
|
-
): string {
|
|
398
|
-
const fingerprint = projection.series
|
|
399
|
-
.map((series) => [
|
|
400
|
-
series.symbol,
|
|
401
|
-
series.color,
|
|
402
|
-
series.fillColor,
|
|
403
|
-
...series.points.map((point) => {
|
|
404
|
-
const timestamp = point.date.getTime();
|
|
405
|
-
return `${timestamp}:${point.value ?? "null"}:${point.rawValue ?? "null"}`;
|
|
406
|
-
}),
|
|
407
|
-
].join("|"))
|
|
408
|
-
.join("::");
|
|
409
|
-
return [
|
|
410
|
-
symbolCount,
|
|
411
|
-
projection.effectiveMode,
|
|
412
|
-
projection.effectiveAxisMode,
|
|
413
|
-
selectedSymbol ?? "",
|
|
414
|
-
pixelWidth,
|
|
415
|
-
pixelHeight,
|
|
416
|
-
paletteKey,
|
|
417
|
-
marketSessionKey,
|
|
418
|
-
fingerprint,
|
|
419
|
-
].join("::");
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
function buildNativeCrosshairBitmapKey(
|
|
423
|
-
pixelWidth: number,
|
|
424
|
-
pixelHeight: number,
|
|
425
|
-
chartHeight: number,
|
|
426
|
-
chartRows: number,
|
|
427
|
-
crosshairColor: string,
|
|
428
|
-
pixelX: number | null,
|
|
429
|
-
pixelY: number | null,
|
|
430
|
-
): string {
|
|
431
|
-
const cursorKey = pixelX === null || pixelY === null
|
|
432
|
-
? "cursor:none"
|
|
433
|
-
: `cursor:${pixelX.toFixed(3)}:${pixelY.toFixed(3)}`;
|
|
434
|
-
return [pixelWidth, pixelHeight, chartHeight, chartRows, crosshairColor, cursorKey].join("::");
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
function getLegendColumns(width: number): number {
|
|
438
|
-
if (width >= 110) return 3;
|
|
439
|
-
if (width >= 72) return 2;
|
|
440
|
-
return 1;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
function clipText(text: string, width: number): string {
|
|
444
|
-
if (width <= 0) return "";
|
|
445
|
-
if (text.length <= width) return text.padEnd(width);
|
|
446
|
-
if (width <= 3) return text.slice(0, width);
|
|
447
|
-
return `${text.slice(0, width - 3)}...`;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
function formatLegendSummary(
|
|
451
|
-
symbol: string,
|
|
452
|
-
rawValue: number | null,
|
|
453
|
-
baseValue: number | null,
|
|
454
|
-
currency: string,
|
|
455
|
-
priceRange: number | undefined,
|
|
456
|
-
): string {
|
|
457
|
-
if (rawValue === null) return `${symbol} waiting`;
|
|
458
|
-
const price = formatMarketPriceWithCurrency(rawValue, currency, {
|
|
459
|
-
minimumFractionDigits: 2,
|
|
460
|
-
precisionOffset: 1,
|
|
461
|
-
priceRange,
|
|
462
|
-
});
|
|
463
|
-
if (baseValue === null || baseValue === 0) return `${symbol} ${price}`;
|
|
464
|
-
return `${symbol} ${price} ${formatPercentRaw(((rawValue - baseValue) / baseValue) * 100)}`;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
function getInitialComparisonMode(mode: string | undefined): ComparisonChartRenderMode {
|
|
468
|
-
return mode === "line" ? "line" : "area";
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
function getComparisonPlotColumn(index: number, pointCount: number, width: number): number {
|
|
472
|
-
if (pointCount <= 1 || width <= 1) return 0;
|
|
473
|
-
return Math.round((index / (pointCount - 1)) * Math.max(width - 1, 0));
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
function resolveSelectionCursorX(cellX: number, pointCount: number, width: number): number | null {
|
|
477
|
-
if (pointCount <= 0 || width <= 0) return null;
|
|
478
|
-
|
|
479
|
-
let bestIndex = pointCount - 1;
|
|
480
|
-
let bestDistance = Number.POSITIVE_INFINITY;
|
|
481
|
-
for (let index = 0; index < pointCount; index += 1) {
|
|
482
|
-
const pointColumn = getComparisonPlotColumn(index, pointCount, width);
|
|
483
|
-
const distance = Math.abs(pointColumn - cellX);
|
|
484
|
-
if (distance <= bestDistance) {
|
|
485
|
-
bestDistance = distance;
|
|
486
|
-
bestIndex = index;
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
return getComparisonPlotColumn(bestIndex, pointCount, width);
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
function resolveSelectionCursor(
|
|
494
|
-
pointer: LocalPlotPointer,
|
|
495
|
-
pointCount: number,
|
|
496
|
-
width: number,
|
|
497
|
-
): { cursorX: number | null; cursorY: number | null } {
|
|
498
|
-
if (!pointer.hasPixelPrecision) {
|
|
499
|
-
return {
|
|
500
|
-
cursorX: pointer.cellX,
|
|
501
|
-
cursorY: pointer.cellY,
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
return {
|
|
506
|
-
cursorX: resolveSelectionCursorX(pointer.cellX, pointCount, width),
|
|
507
|
-
cursorY: null,
|
|
508
|
-
};
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
function getUniqueSortedSeriesDates(series: Array<{ points: PricePoint[] }>): Date[] {
|
|
512
|
-
const byTimestamp = new Map<number, Date>();
|
|
513
|
-
for (const entry of series) {
|
|
514
|
-
for (const point of entry.points) {
|
|
515
|
-
const date = point.date instanceof Date ? point.date : new Date(point.date);
|
|
516
|
-
const timestamp = date.getTime();
|
|
517
|
-
if (!Number.isNaN(timestamp)) {
|
|
518
|
-
byTimestamp.set(timestamp, date);
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
return [...byTimestamp.entries()]
|
|
523
|
-
.sort((left, right) => left[0] - right[0])
|
|
524
|
-
.map(([, date]) => date);
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
function ComparisonStockChartView({
|
|
528
|
-
paneId,
|
|
529
|
-
width,
|
|
530
|
-
height,
|
|
531
|
-
focused,
|
|
532
|
-
symbols,
|
|
533
|
-
axisMode,
|
|
534
|
-
defaultRenderMode,
|
|
535
|
-
preferredRenderer,
|
|
536
|
-
symbolSources,
|
|
537
|
-
onOpenSymbol,
|
|
538
|
-
onEditTickers,
|
|
539
|
-
}: ComparisonStockChartViewProps) {
|
|
540
|
-
useThemeColors();
|
|
541
|
-
const renderer = useNativeRenderer();
|
|
542
|
-
const { canvasCharts, cellWidthPx = 8, cellHeightPx = 18, pixelRatio = 1 } = useUiCapabilities();
|
|
543
|
-
const nativeSurfaceManager = useMemo(() => getNativeSurfaceManager(renderer), [renderer]);
|
|
544
|
-
const [storedRangePreset] = usePaneSettingValue("rangePreset", DEFAULT_COMPARISON_CHART_RANGE_PRESET);
|
|
545
|
-
const [storedResolution] = usePaneSettingValue<ChartResolution>("chartResolution", DEFAULT_COMPARISON_CHART_RESOLUTION);
|
|
546
|
-
const persistChartControls = usePersistChartControlSelection("rangePreset");
|
|
547
|
-
const [viewState, setViewState] = useState<ComparisonChartViewState>({
|
|
548
|
-
presetRange: storedRangePreset,
|
|
549
|
-
bufferRange: storedRangePreset,
|
|
550
|
-
activePreset: storedRangePreset,
|
|
551
|
-
resolution: storedResolution,
|
|
552
|
-
panOffset: 0,
|
|
553
|
-
zoomLevel: 1,
|
|
554
|
-
cursorX: null,
|
|
555
|
-
cursorY: null,
|
|
556
|
-
renderMode: getInitialComparisonMode(defaultRenderMode),
|
|
557
|
-
selectedSymbol: symbols[0] ?? null,
|
|
558
|
-
});
|
|
559
|
-
const [resolutionSupport, setResolutionSupport] = useState<ChartResolutionSupport[] | null>(null);
|
|
560
|
-
const supportMap = useMemo(() => buildChartResolutionSupportMap(resolutionSupport ?? []), [resolutionSupport]);
|
|
561
|
-
const [kittySupport, setKittySupport] = useState<boolean | null>(() => getCachedKittySupport(renderer));
|
|
562
|
-
const [displayCursor, setDisplayCursor] = useState<DisplayCursorState>(EMPTY_DISPLAY_CURSOR);
|
|
563
|
-
const [canvasBaseBitmapState, setCanvasBaseBitmapState] = useState<{ key: string; bitmap: NativeChartBitmap } | null>(null);
|
|
564
|
-
const plotRef = useRef<BoxRenderable | null>(null);
|
|
565
|
-
const nativeBaseSurfaceIdRef = useRef(`comparison-chart-surface:${paneId}:base`);
|
|
566
|
-
const nativeCrosshairSurfaceIdRef = useRef(`comparison-chart-surface:${paneId}:crosshair`);
|
|
567
|
-
const dragRef = useRef<DragState | null>(null);
|
|
568
|
-
const lastNativeGeometryRef = useRef<{ rect: CellRect; visibleRect: CellRect | null } | null>(null);
|
|
569
|
-
const lastNativeBaseBitmapRef = useRef<{ key: string; bitmap: NativeChartBitmap } | null>(null);
|
|
570
|
-
const lastNativeCrosshairBitmapRef = useRef<{ key: string; bitmap: NativeChartBitmap } | null>(null);
|
|
571
|
-
const lastCanvasBaseBitmapRef = useRef<{ key: string; bitmap: NativeChartBitmap } | null>(null);
|
|
572
|
-
const displayCursorRef = useRef<DisplayCursorState>(EMPTY_DISPLAY_CURSOR);
|
|
573
|
-
const targetCursorRef = useRef<DisplayCursorState>(EMPTY_DISPLAY_CURSOR);
|
|
574
|
-
const mouseCrosshairDisabledRef = useRef(false);
|
|
575
|
-
const cursorMotionKindRef = useRef<ChartCursorMotionKind>("discrete");
|
|
576
|
-
const animationFrameRef = useRef<number | null>(null);
|
|
577
|
-
const lastAppliedStoredSelectionKeyRef = useRef<string | null>(null);
|
|
578
|
-
const pendingCanonicalResetRef = useRef(1);
|
|
579
|
-
const appliedCanonicalResetRef = useRef(0);
|
|
580
|
-
const pendingExpansionRef = useRef<PendingExpansionAction>(null);
|
|
581
|
-
const scrollPanCellRemainderRef = useRef(0);
|
|
582
|
-
|
|
583
|
-
const axisSectionWidthBudget = 11;
|
|
584
|
-
const axisRightPadding = 1;
|
|
585
|
-
const minimumAxisWidth = axisMode === "percent" ? 5 : 4;
|
|
586
|
-
const axisGap = axisSectionWidthBudget > 0 ? 1 : 0;
|
|
587
|
-
const headerRows = 0;
|
|
588
|
-
const controlRows = 2;
|
|
589
|
-
const timeAxisRows = 1;
|
|
590
|
-
const helpRows = 0;
|
|
591
|
-
const legendColumns = getLegendColumns(width);
|
|
592
|
-
const legendNeededRows = symbols.length > 0 ? Math.ceil(symbols.length / legendColumns) : 0;
|
|
593
|
-
const legendRows = legendNeededRows > 0
|
|
594
|
-
? Math.min(4, Math.max(Math.min(height - (headerRows + controlRows + timeAxisRows + helpRows + 4), legendNeededRows), 1))
|
|
595
|
-
: 0;
|
|
596
|
-
const chartHeight = Math.max(height - headerRows - controlRows - timeAxisRows - helpRows - legendRows, 4);
|
|
597
|
-
const minChartWidth = 20;
|
|
598
|
-
const measurementChartWidth = Math.max(width - axisSectionWidthBudget - axisGap, minChartWidth);
|
|
599
|
-
const legendItemWidth = Math.max(Math.floor((width - Math.max(legendColumns - 1, 0)) / legendColumns), 20);
|
|
600
|
-
const chartColors = useMemo(() => ({
|
|
601
|
-
bgColor: colors.bg,
|
|
602
|
-
gridColor: blendHex(colors.bg, colors.border, 0.55),
|
|
603
|
-
crosshairColor: colors.borderFocused,
|
|
604
|
-
preMarketBgColor: blendHex(colors.bg, "#1d4ed8", 0.18),
|
|
605
|
-
postMarketBgColor: blendHex(colors.bg, "#b45309", 0.18),
|
|
606
|
-
}), [colors.bg, colors.border, colors.borderFocused]);
|
|
607
|
-
const marketSession = useMemo(() => resolveChartMarketSession(symbolSources.map((source) => ({
|
|
608
|
-
exchange: source.exchange,
|
|
609
|
-
primaryExchange: source.instrument?.primaryExchange,
|
|
610
|
-
currency: source.currency,
|
|
611
|
-
assetCategory: source.instrument?.secType,
|
|
612
|
-
}))), [symbolSources]);
|
|
613
|
-
const marketSessionKey = useMemo(() => getChartMarketSessionKey(marketSession), [marketSession]);
|
|
614
|
-
|
|
615
|
-
const setSelectedSymbol = (symbol: string) => {
|
|
616
|
-
setViewState((current) => (
|
|
617
|
-
current.selectedSymbol === symbol
|
|
618
|
-
? current
|
|
619
|
-
: { ...current, selectedSymbol: symbol }
|
|
620
|
-
));
|
|
621
|
-
};
|
|
622
|
-
|
|
623
|
-
const marketDataProvider = getSharedMarketData();
|
|
624
|
-
const capabilityDescriptor = useMemo(() => {
|
|
625
|
-
const sources = symbolSources.map((source) => ({
|
|
626
|
-
symbol: source.symbol,
|
|
627
|
-
exchange: source.exchange,
|
|
628
|
-
brokerId: source.brokerId,
|
|
629
|
-
brokerInstanceId: source.brokerInstanceId,
|
|
630
|
-
instrument: source.instrument,
|
|
631
|
-
}));
|
|
632
|
-
return {
|
|
633
|
-
key: sources.map((source) => [
|
|
634
|
-
source.symbol,
|
|
635
|
-
source.exchange,
|
|
636
|
-
source.brokerId ?? "",
|
|
637
|
-
source.brokerInstanceId ?? "",
|
|
638
|
-
source.instrument?.conId ?? "",
|
|
639
|
-
source.instrument?.localSymbol ?? "",
|
|
640
|
-
source.instrument?.symbol ?? "",
|
|
641
|
-
].join(":")).join("|"),
|
|
642
|
-
sources,
|
|
643
|
-
};
|
|
644
|
-
}, [symbolSources]);
|
|
645
|
-
const effectiveResolutionSupport = useMemo<ChartResolutionSupport[]>(() => (
|
|
646
|
-
resolutionSupport ?? DEFAULT_VISIBLE_MANUAL_CHART_RESOLUTIONS.map((resolution) => ({ resolution, maxRange: "ALL" as const }))
|
|
647
|
-
), [resolutionSupport]);
|
|
648
|
-
const selectionSupportMap = useMemo(
|
|
649
|
-
() => buildChartResolutionSupportMap(effectiveResolutionSupport),
|
|
650
|
-
[effectiveResolutionSupport],
|
|
651
|
-
);
|
|
652
|
-
|
|
653
|
-
useEffect(() => {
|
|
654
|
-
if (symbols.includes(viewState.selectedSymbol ?? "")) return;
|
|
655
|
-
setViewState((current) => ({
|
|
656
|
-
...current,
|
|
657
|
-
selectedSymbol: symbols[0] ?? null,
|
|
658
|
-
}));
|
|
659
|
-
}, [symbols, viewState.selectedSymbol]);
|
|
660
|
-
|
|
661
|
-
useEffect(() => {
|
|
662
|
-
const storedSelectionKey = `${storedRangePreset}:${storedResolution}`;
|
|
663
|
-
if (lastAppliedStoredSelectionKeyRef.current === storedSelectionKey) return;
|
|
664
|
-
|
|
665
|
-
lastAppliedStoredSelectionKeyRef.current = storedSelectionKey;
|
|
666
|
-
pendingCanonicalResetRef.current += 1;
|
|
667
|
-
setViewState((current) => (
|
|
668
|
-
storedResolution === "auto"
|
|
669
|
-
? resolveStoredChartSelection(current, storedRangePreset, storedResolution, selectionSupportMap)
|
|
670
|
-
: resolvePresetSelection(
|
|
671
|
-
{
|
|
672
|
-
...current,
|
|
673
|
-
resolution: storedResolution,
|
|
674
|
-
},
|
|
675
|
-
storedRangePreset,
|
|
676
|
-
getSupportMaxRange(selectionSupportMap, storedResolution),
|
|
677
|
-
)
|
|
678
|
-
));
|
|
679
|
-
updateDisplayCursorTarget(EMPTY_DISPLAY_CURSOR, "discrete");
|
|
680
|
-
}, [selectionSupportMap, storedRangePreset, storedResolution]);
|
|
681
|
-
|
|
682
|
-
const commitDisplayCursor = (next: DisplayCursorState) => {
|
|
683
|
-
displayCursorRef.current = next;
|
|
684
|
-
setDisplayCursor((current) => (sameDisplayCursorState(current, next) ? current : next));
|
|
685
|
-
};
|
|
686
|
-
|
|
687
|
-
const stopDisplayCursorAnimation = () => {
|
|
688
|
-
if (animationFrameRef.current !== null) {
|
|
689
|
-
cancelAnimationFrameSafe(animationFrameRef.current);
|
|
690
|
-
animationFrameRef.current = null;
|
|
691
|
-
}
|
|
692
|
-
};
|
|
693
|
-
|
|
694
|
-
const startDisplayCursorAnimation = () => {
|
|
695
|
-
if (animationFrameRef.current !== null) return;
|
|
696
|
-
|
|
697
|
-
const tick = () => {
|
|
698
|
-
animationFrameRef.current = null;
|
|
699
|
-
const target = targetCursorRef.current;
|
|
700
|
-
|
|
701
|
-
if (cursorMotionKindRef.current !== "cell") {
|
|
702
|
-
commitDisplayCursor(target);
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
const currentCell = toCursorPosition(displayCursorRef.current.cellX, displayCursorRef.current.cellY);
|
|
707
|
-
const targetCell = toCursorPosition(target.cellX, target.cellY);
|
|
708
|
-
const currentPixel = toCursorPosition(displayCursorRef.current.pixelX, displayCursorRef.current.pixelY);
|
|
709
|
-
const targetPixel = toCursorPosition(target.pixelX, target.pixelY);
|
|
710
|
-
const cellStep = stepCursorTowards(currentCell, targetCell);
|
|
711
|
-
const pixelStep = stepCursorTowards(currentPixel, targetPixel, undefined, PIXEL_CURSOR_SNAP_DISTANCE);
|
|
712
|
-
const next: DisplayCursorState = {
|
|
713
|
-
cellX: cellStep.next.x,
|
|
714
|
-
cellY: cellStep.next.y,
|
|
715
|
-
pixelX: pixelStep.next.x,
|
|
716
|
-
pixelY: pixelStep.next.y,
|
|
717
|
-
};
|
|
718
|
-
const settled = cellStep.settled && pixelStep.settled;
|
|
719
|
-
commitDisplayCursor(next);
|
|
720
|
-
if (!settled) {
|
|
721
|
-
animationFrameRef.current = requestAnimationFrameSafe(tick);
|
|
722
|
-
}
|
|
723
|
-
};
|
|
724
|
-
|
|
725
|
-
animationFrameRef.current = requestAnimationFrameSafe(tick);
|
|
726
|
-
};
|
|
727
|
-
|
|
728
|
-
const updateDisplayCursorTarget = (next: DisplayCursorState, motionKind: ChartCursorMotionKind) => {
|
|
729
|
-
cursorMotionKindRef.current = motionKind;
|
|
730
|
-
targetCursorRef.current = next;
|
|
731
|
-
|
|
732
|
-
if (motionKind !== "cell" || next.cellX === null || next.cellY === null) {
|
|
733
|
-
stopDisplayCursorAnimation();
|
|
734
|
-
commitDisplayCursor(next);
|
|
735
|
-
return;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
if (displayCursorRef.current.cellX === null || displayCursorRef.current.cellY === null) {
|
|
739
|
-
commitDisplayCursor(next);
|
|
740
|
-
return;
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
if (sameDisplayCursorState(displayCursorRef.current, next, CELL_CURSOR_SNAP_DISTANCE, PIXEL_CURSOR_SNAP_DISTANCE)) {
|
|
744
|
-
stopDisplayCursorAnimation();
|
|
745
|
-
commitDisplayCursor(next);
|
|
746
|
-
return;
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
startDisplayCursorAnimation();
|
|
750
|
-
};
|
|
751
|
-
|
|
752
|
-
useEffect(() => (
|
|
753
|
-
() => {
|
|
754
|
-
stopDisplayCursorAnimation();
|
|
755
|
-
lastNativeBaseBitmapRef.current = null;
|
|
756
|
-
lastNativeCrosshairBitmapRef.current = null;
|
|
757
|
-
nativeSurfaceManager.removeSurface(nativeBaseSurfaceIdRef.current);
|
|
758
|
-
nativeSurfaceManager.removeSurface(nativeCrosshairSurfaceIdRef.current);
|
|
759
|
-
}
|
|
760
|
-
), [nativeSurfaceManager]);
|
|
761
|
-
|
|
762
|
-
useEffect(() => {
|
|
763
|
-
const provider = marketDataProvider;
|
|
764
|
-
if ((!provider?.getChartResolutionSupport && !provider?.getChartResolutionCapabilities) || capabilityDescriptor.sources.length === 0) {
|
|
765
|
-
setResolutionSupport(null);
|
|
766
|
-
return;
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
let cancelled = false;
|
|
770
|
-
setResolutionSupport(null);
|
|
771
|
-
Promise.all(capabilityDescriptor.sources.map(async (source) => {
|
|
772
|
-
try {
|
|
773
|
-
const support = provider.getChartResolutionSupport
|
|
774
|
-
? await provider.getChartResolutionSupport(
|
|
775
|
-
source.symbol,
|
|
776
|
-
source.exchange,
|
|
777
|
-
{
|
|
778
|
-
brokerId: source.brokerId,
|
|
779
|
-
brokerInstanceId: source.brokerInstanceId,
|
|
780
|
-
instrument: source.instrument ?? null,
|
|
781
|
-
},
|
|
782
|
-
)
|
|
783
|
-
: normalizeChartResolutionSupport(
|
|
784
|
-
(await provider.getChartResolutionCapabilities?.(
|
|
785
|
-
source.symbol,
|
|
786
|
-
source.exchange,
|
|
787
|
-
{
|
|
788
|
-
brokerId: source.brokerId,
|
|
789
|
-
brokerInstanceId: source.brokerInstanceId,
|
|
790
|
-
instrument: source.instrument ?? null,
|
|
791
|
-
},
|
|
792
|
-
) ?? []).map((resolution) => ({ resolution, maxRange: "ALL" })),
|
|
793
|
-
);
|
|
794
|
-
return support;
|
|
795
|
-
} catch {
|
|
796
|
-
return null;
|
|
797
|
-
}
|
|
798
|
-
})).then((supportSets) => {
|
|
799
|
-
if (!cancelled) {
|
|
800
|
-
setResolutionSupport(
|
|
801
|
-
supportSets.some((support) => support === null)
|
|
802
|
-
? null
|
|
803
|
-
: intersectChartResolutionSupport(supportSets.filter((support): support is ChartResolutionSupport[] => support !== null)),
|
|
804
|
-
);
|
|
805
|
-
}
|
|
806
|
-
}).catch(() => {
|
|
807
|
-
if (!cancelled) {
|
|
808
|
-
setResolutionSupport(null);
|
|
809
|
-
}
|
|
810
|
-
});
|
|
811
|
-
|
|
812
|
-
return () => {
|
|
813
|
-
cancelled = true;
|
|
814
|
-
};
|
|
815
|
-
}, [capabilityDescriptor.key, marketDataProvider]);
|
|
816
|
-
const availableManualResolutions = resolutionSupport?.map((entry) => entry.resolution) ?? DEFAULT_VISIBLE_MANUAL_CHART_RESOLUTIONS;
|
|
817
|
-
const effectiveResolution: ChartResolution = viewState.resolution !== "auto"
|
|
818
|
-
&& resolutionSupport !== null
|
|
819
|
-
&& !supportMap.has(viewState.resolution)
|
|
820
|
-
? "auto"
|
|
821
|
-
: viewState.resolution;
|
|
822
|
-
const resolutionChips = useMemo(
|
|
823
|
-
() => sortChartResolutions(["auto", ...availableManualResolutions] as ChartResolution[]),
|
|
824
|
-
[availableManualResolutions],
|
|
825
|
-
);
|
|
826
|
-
const chartRequests = useMemo(() => (
|
|
827
|
-
symbolSources.map((source) => ({
|
|
828
|
-
instrument: {
|
|
829
|
-
symbol: source.symbol,
|
|
830
|
-
exchange: source.exchange,
|
|
831
|
-
brokerId: source.brokerId,
|
|
832
|
-
brokerInstanceId: source.brokerInstanceId,
|
|
833
|
-
instrument: source.instrument,
|
|
834
|
-
},
|
|
835
|
-
bufferRange: viewState.bufferRange,
|
|
836
|
-
granularity: effectiveResolution === "auto" ? "range" as const : "resolution" as const,
|
|
837
|
-
resolution: effectiveResolution === "auto" ? undefined : effectiveResolution,
|
|
838
|
-
}))
|
|
839
|
-
), [effectiveResolution, symbolSources, viewState.bufferRange]);
|
|
840
|
-
const chartEntries = useChartQueries(chartRequests);
|
|
841
|
-
const entryStates = useMemo(() => chartRequests.map((request) => (
|
|
842
|
-
resolveChartBodyState(chartEntries.get(buildChartKey(request)), (value) => Array.isArray(value) && value.length > 0, "No chart data yet.")
|
|
843
|
-
)), [chartEntries, chartRequests]);
|
|
844
|
-
const hasSeriesData = entryStates.some((state) => !!state.data?.length);
|
|
845
|
-
const isBlockingBody = entryStates.some((state) => state.blocking) || (chartRequests.length > 0 && entryStates.length !== chartRequests.length);
|
|
846
|
-
const bodyMessage = hasSeriesData
|
|
847
|
-
? null
|
|
848
|
-
: entryStates.find((state) => state.errorMessage)?.errorMessage
|
|
849
|
-
?? entryStates.find((state) => state.emptyMessage)?.emptyMessage
|
|
850
|
-
?? null;
|
|
851
|
-
const isUpdating = !isBlockingBody && entryStates.some((state) => state.updating);
|
|
852
|
-
const series = useMemo(() => symbolSources.map((source, index) => {
|
|
853
|
-
const request = chartRequests[index];
|
|
854
|
-
const history = request ? (chartEntries.get(buildChartKey(request))?.data ?? []) : [];
|
|
855
|
-
const color = getComparisonSeriesColor(index);
|
|
856
|
-
return {
|
|
857
|
-
symbol: source.symbol,
|
|
858
|
-
color,
|
|
859
|
-
fillColor: blendHex(colors.bg, color, 0.22),
|
|
860
|
-
currency: source.currency,
|
|
861
|
-
points: history,
|
|
862
|
-
};
|
|
863
|
-
}), [chartEntries, chartRequests, colors.bg, symbolSources]);
|
|
864
|
-
const axisWidth = useMemo(() => {
|
|
865
|
-
const measureAxisWidth = (targetWidth: number) => {
|
|
866
|
-
const measuredProjection = projectComparisonChartData(series, targetWidth, viewState, axisMode);
|
|
867
|
-
const measuredResult = renderComparisonChart(measuredProjection, {
|
|
868
|
-
width: targetWidth,
|
|
869
|
-
height: chartHeight,
|
|
870
|
-
cursorX: null,
|
|
871
|
-
cursorY: null,
|
|
872
|
-
selectedSymbol: viewState.selectedSymbol,
|
|
873
|
-
colors: chartColors,
|
|
874
|
-
});
|
|
875
|
-
const measuredScene = buildComparisonChartScene(measuredProjection, {
|
|
876
|
-
width: targetWidth,
|
|
877
|
-
height: chartHeight,
|
|
878
|
-
cursorX: null,
|
|
879
|
-
cursorY: null,
|
|
880
|
-
selectedSymbol: viewState.selectedSymbol,
|
|
881
|
-
colors: chartColors,
|
|
882
|
-
});
|
|
883
|
-
const cursorSamples = measuredScene
|
|
884
|
-
? [
|
|
885
|
-
formatComparisonCursorAxisValue(
|
|
886
|
-
measuredScene.min,
|
|
887
|
-
measuredProjection.effectiveAxisMode,
|
|
888
|
-
measuredResult.priceRange ?? undefined,
|
|
889
|
-
),
|
|
890
|
-
formatComparisonCursorAxisValue(
|
|
891
|
-
measuredScene.max,
|
|
892
|
-
measuredProjection.effectiveAxisMode,
|
|
893
|
-
measuredResult.priceRange ?? undefined,
|
|
894
|
-
),
|
|
895
|
-
]
|
|
896
|
-
: [];
|
|
897
|
-
|
|
898
|
-
return resolveChartAxisWidth(
|
|
899
|
-
[...measuredResult.axisLabels.map((entry) => entry.label), ...cursorSamples],
|
|
900
|
-
minimumAxisWidth,
|
|
901
|
-
Math.max(axisSectionWidthBudget - axisRightPadding, minimumAxisWidth),
|
|
902
|
-
);
|
|
903
|
-
};
|
|
904
|
-
|
|
905
|
-
const firstPassWidth = measureAxisWidth(measurementChartWidth);
|
|
906
|
-
const refinedChartWidth = Math.max(width - firstPassWidth - axisRightPadding - axisGap, minChartWidth);
|
|
907
|
-
return refinedChartWidth === measurementChartWidth ? firstPassWidth : measureAxisWidth(refinedChartWidth);
|
|
908
|
-
}, [
|
|
909
|
-
axisGap,
|
|
910
|
-
axisMode,
|
|
911
|
-
axisRightPadding,
|
|
912
|
-
axisSectionWidthBudget,
|
|
913
|
-
chartColors,
|
|
914
|
-
chartHeight,
|
|
915
|
-
measurementChartWidth,
|
|
916
|
-
minChartWidth,
|
|
917
|
-
minimumAxisWidth,
|
|
918
|
-
series,
|
|
919
|
-
viewState.panOffset,
|
|
920
|
-
viewState.renderMode,
|
|
921
|
-
viewState.selectedSymbol,
|
|
922
|
-
viewState.zoomLevel,
|
|
923
|
-
width,
|
|
924
|
-
]);
|
|
925
|
-
const axisSectionWidth = axisWidth + axisRightPadding;
|
|
926
|
-
const chartWidth = Math.max(width - axisSectionWidth - axisGap, minChartWidth);
|
|
927
|
-
const seriesDates = useMemo(() => getUniqueSortedSeriesDates(series), [series]);
|
|
928
|
-
const visibleDateWindow = useMemo(() => buildVisibleDateWindow(seriesDates, viewState.panOffset, viewState.zoomLevel), [seriesDates, viewState.panOffset, viewState.zoomLevel]);
|
|
929
|
-
const activePreset = resolveVisibleActivePreset(seriesDates, {
|
|
930
|
-
presetRange: viewState.presetRange,
|
|
931
|
-
activePreset: viewState.activePreset,
|
|
932
|
-
panOffset: viewState.panOffset,
|
|
933
|
-
zoomLevel: viewState.zoomLevel,
|
|
934
|
-
resolution: effectiveResolution,
|
|
935
|
-
});
|
|
936
|
-
|
|
937
|
-
useEffect(() => {
|
|
938
|
-
if (seriesDates.length === 0) return;
|
|
939
|
-
const hasPendingCanonicalReset = appliedCanonicalResetRef.current < pendingCanonicalResetRef.current;
|
|
940
|
-
const shouldReconcileActivePreset = !hasPendingCanonicalReset
|
|
941
|
-
&& needsCanonicalPresetViewportReset(seriesDates, viewState);
|
|
942
|
-
if (hasPendingCanonicalReset || shouldReconcileActivePreset) {
|
|
943
|
-
if (hasPendingCanonicalReset) {
|
|
944
|
-
appliedCanonicalResetRef.current = pendingCanonicalResetRef.current;
|
|
945
|
-
}
|
|
946
|
-
setViewState((current) => (
|
|
947
|
-
hasPendingCanonicalReset
|
|
948
|
-
? resolvePresetRangeViewport(current, seriesDates)
|
|
949
|
-
: resolveCanonicalPresetViewport(current, seriesDates)
|
|
950
|
-
));
|
|
951
|
-
return;
|
|
952
|
-
}
|
|
953
|
-
if (!pendingExpansionRef.current) return;
|
|
954
|
-
const pendingExpansion = pendingExpansionRef.current;
|
|
955
|
-
pendingExpansionRef.current = null;
|
|
956
|
-
setViewState((current) => {
|
|
957
|
-
if (pendingExpansion.kind === "zoom-out") {
|
|
958
|
-
const nextVisibleCount = Math.min(seriesDates.length, Math.max(pendingExpansion.targetVisibleCount, 1));
|
|
959
|
-
return {
|
|
960
|
-
...current,
|
|
961
|
-
...resolveAnchoredChartZoom(seriesDates.length, 1, 0, seriesDates.length / nextVisibleCount, pendingExpansion.anchorRatio),
|
|
962
|
-
};
|
|
963
|
-
}
|
|
964
|
-
return {
|
|
965
|
-
...current,
|
|
966
|
-
panOffset: clamp(pendingExpansion.targetPanOffset, 0, getMaxComparisonPanOffset(series, current.zoomLevel)),
|
|
967
|
-
};
|
|
968
|
-
});
|
|
969
|
-
}, [
|
|
970
|
-
series,
|
|
971
|
-
seriesDates,
|
|
972
|
-
viewState.activePreset,
|
|
973
|
-
viewState.panOffset,
|
|
974
|
-
viewState.presetRange,
|
|
975
|
-
viewState.zoomLevel,
|
|
976
|
-
]);
|
|
977
|
-
|
|
978
|
-
useEffect(() => {
|
|
979
|
-
const refreshSupport = () => setKittySupport(getCachedKittySupport(renderer));
|
|
980
|
-
refreshSupport();
|
|
981
|
-
renderer.on("capabilities", refreshSupport);
|
|
982
|
-
return () => {
|
|
983
|
-
renderer.off("capabilities", refreshSupport);
|
|
984
|
-
};
|
|
985
|
-
}, [renderer]);
|
|
986
|
-
|
|
987
|
-
useEffect(() => {
|
|
988
|
-
let cancelled = false;
|
|
989
|
-
const known = getCachedKittySupport(renderer);
|
|
990
|
-
setKittySupport(known);
|
|
991
|
-
if (preferredRenderer === "braille" || known !== null) return;
|
|
992
|
-
ensureKittySupport(renderer).then((supported) => {
|
|
993
|
-
if (!cancelled) setKittySupport(supported);
|
|
994
|
-
}).catch(() => {
|
|
995
|
-
if (!cancelled) setKittySupport(false);
|
|
996
|
-
});
|
|
997
|
-
return () => {
|
|
998
|
-
cancelled = true;
|
|
999
|
-
};
|
|
1000
|
-
}, [preferredRenderer, renderer]);
|
|
1001
|
-
|
|
1002
|
-
const expandBufferRange = (action: PendingExpansionAction): boolean => {
|
|
1003
|
-
const nextCandidate = getNextBufferRange(viewState.bufferRange);
|
|
1004
|
-
const nextBufferRange = effectiveResolution === "auto"
|
|
1005
|
-
? nextCandidate
|
|
1006
|
-
: clampTimeRangeToMaxRange(nextCandidate, supportMap.get(effectiveResolution) ?? viewState.bufferRange);
|
|
1007
|
-
if (nextBufferRange === viewState.bufferRange) return false;
|
|
1008
|
-
pendingExpansionRef.current = action;
|
|
1009
|
-
setViewState((current) => applyBufferedPanExpansion(current, nextBufferRange));
|
|
1010
|
-
return true;
|
|
1011
|
-
};
|
|
1012
|
-
|
|
1013
|
-
const setRangePreset = (range: TimeRange) => {
|
|
1014
|
-
if (!isRangePresetSupported(range, effectiveResolutionSupport)) return;
|
|
1015
|
-
const supportMaxRange = getSupportMaxRange(effectiveResolutionSupport, getPresetResolution(range));
|
|
1016
|
-
persistChartControls(range, getPresetResolution(range));
|
|
1017
|
-
pendingCanonicalResetRef.current += 1;
|
|
1018
|
-
updateDisplayCursorTarget(EMPTY_DISPLAY_CURSOR, "discrete");
|
|
1019
|
-
setViewState((current) => resolvePresetSelection(current, range, supportMaxRange));
|
|
1020
|
-
};
|
|
1021
|
-
|
|
1022
|
-
const setResolution = (resolution: ChartResolution) => {
|
|
1023
|
-
if (resolution !== "auto" && !availableManualResolutions.includes(resolution)) return;
|
|
1024
|
-
const nextState = resolveResolutionSelection(viewState, resolution, supportMap, visibleDateWindow);
|
|
1025
|
-
if (!nextState) return;
|
|
1026
|
-
pendingCanonicalResetRef.current += 1;
|
|
1027
|
-
persistChartControls(nextState.presetRange, resolution);
|
|
1028
|
-
updateDisplayCursorTarget(EMPTY_DISPLAY_CURSOR, "discrete");
|
|
1029
|
-
setViewState(nextState);
|
|
1030
|
-
};
|
|
1031
|
-
|
|
1032
|
-
const projectionViewState = useMemo(() => ({
|
|
1033
|
-
panOffset: viewState.panOffset,
|
|
1034
|
-
zoomLevel: viewState.zoomLevel,
|
|
1035
|
-
renderMode: viewState.renderMode,
|
|
1036
|
-
}), [viewState.panOffset, viewState.renderMode, viewState.zoomLevel]);
|
|
1037
|
-
|
|
1038
|
-
const visibleWindow = useMemo(() => (
|
|
1039
|
-
getVisibleComparisonWindow(series, projectionViewState)
|
|
1040
|
-
), [projectionViewState, series]);
|
|
1041
|
-
|
|
1042
|
-
const projection = useMemo(() => (
|
|
1043
|
-
projectComparisonChartData(series, chartWidth, projectionViewState, axisMode)
|
|
1044
|
-
), [axisMode, chartWidth, projectionViewState, series]);
|
|
1045
|
-
|
|
1046
|
-
const cursorX = viewState.cursorX !== null ? clamp(viewState.cursorX, 0, chartWidth - 1) : null;
|
|
1047
|
-
const cursorY = viewState.cursorY !== null ? clamp(viewState.cursorY, 0, chartHeight - 1) : null;
|
|
1048
|
-
const displayCursorX = displayCursor.cellX !== null ? clamp(displayCursor.cellX, 0, chartWidth - 1) : null;
|
|
1049
|
-
const displayCursorY = displayCursor.cellY !== null ? clamp(displayCursor.cellY, 0, chartHeight - 1) : null;
|
|
1050
|
-
|
|
1051
|
-
const commitSelectionCursor = (next: { cursorX: number | null; cursorY: number | null }) => {
|
|
1052
|
-
setViewState((current) => (
|
|
1053
|
-
current.cursorX === next.cursorX && current.cursorY === next.cursorY
|
|
1054
|
-
? current
|
|
1055
|
-
: { ...current, cursorX: next.cursorX, cursorY: next.cursorY }
|
|
1056
|
-
));
|
|
1057
|
-
};
|
|
1058
|
-
|
|
1059
|
-
const selectSymbolByOffset = (offset: number) => {
|
|
1060
|
-
setViewState((current) => {
|
|
1061
|
-
const currentIndex = Math.max(symbols.indexOf(current.selectedSymbol ?? symbols[0] ?? ""), 0);
|
|
1062
|
-
return {
|
|
1063
|
-
...current,
|
|
1064
|
-
selectedSymbol: symbols[clamp(currentIndex + offset, 0, symbols.length - 1)] ?? current.selectedSymbol,
|
|
1065
|
-
};
|
|
1066
|
-
});
|
|
1067
|
-
};
|
|
1068
|
-
|
|
1069
|
-
useEffect(() => {
|
|
1070
|
-
const remapCursor = (cursor: DisplayCursorState) => buildDisplayCursorState(
|
|
1071
|
-
cursor.cellX,
|
|
1072
|
-
cursor.cellY,
|
|
1073
|
-
plotRef.current,
|
|
1074
|
-
renderer,
|
|
1075
|
-
);
|
|
1076
|
-
const nextDisplay = remapCursor(displayCursorRef.current);
|
|
1077
|
-
const nextTarget = remapCursor(targetCursorRef.current);
|
|
1078
|
-
displayCursorRef.current = nextDisplay;
|
|
1079
|
-
targetCursorRef.current = nextTarget;
|
|
1080
|
-
setDisplayCursor((current) => (sameDisplayCursorState(current, nextDisplay) ? current : nextDisplay));
|
|
1081
|
-
}, [chartHeight, chartWidth, renderer.resolution?.height, renderer.resolution?.width]);
|
|
1082
|
-
|
|
1083
|
-
useEffect(() => {
|
|
1084
|
-
if (cursorMotionKindRef.current === "pixel") return;
|
|
1085
|
-
updateDisplayCursorTarget(
|
|
1086
|
-
buildDisplayCursorState(cursorX, cursorY, plotRef.current, renderer),
|
|
1087
|
-
cursorMotionKindRef.current,
|
|
1088
|
-
);
|
|
1089
|
-
}, [cursorX, cursorY, renderer]);
|
|
1090
|
-
|
|
1091
|
-
const rendererState = resolveChartRendererState(preferredRenderer, kittySupport, renderer.resolution);
|
|
1092
|
-
const effectiveRenderer: ResolvedChartRenderer = rendererState.renderer;
|
|
1093
|
-
const useCanvasChart = canvasCharts && effectiveRenderer !== "kitty";
|
|
1094
|
-
const showNativeUnavailable = rendererState.nativeUnavailable && !useCanvasChart;
|
|
1095
|
-
|
|
1096
|
-
const staticScene = useMemo(() => buildComparisonChartScene(projection, {
|
|
1097
|
-
width: chartWidth,
|
|
1098
|
-
height: chartHeight,
|
|
1099
|
-
cursorX: null,
|
|
1100
|
-
cursorY: null,
|
|
1101
|
-
selectedSymbol: viewState.selectedSymbol,
|
|
1102
|
-
colors: chartColors,
|
|
1103
|
-
marketSession,
|
|
1104
|
-
}), [chartColors, chartHeight, chartWidth, marketSession, projection, viewState.selectedSymbol]);
|
|
1105
|
-
const displayScene = useMemo(() => buildComparisonChartScene(projection, {
|
|
1106
|
-
width: chartWidth,
|
|
1107
|
-
height: chartHeight,
|
|
1108
|
-
cursorX: displayCursorX,
|
|
1109
|
-
cursorY: displayCursorY,
|
|
1110
|
-
selectedSymbol: viewState.selectedSymbol,
|
|
1111
|
-
colors: chartColors,
|
|
1112
|
-
marketSession,
|
|
1113
|
-
}), [chartColors, chartHeight, chartWidth, displayCursorX, displayCursorY, marketSession, projection, viewState.selectedSymbol]);
|
|
1114
|
-
|
|
1115
|
-
const staticResult = useMemo(() => renderComparisonChart(projection, {
|
|
1116
|
-
width: chartWidth,
|
|
1117
|
-
height: chartHeight,
|
|
1118
|
-
cursorX: null,
|
|
1119
|
-
cursorY: null,
|
|
1120
|
-
selectedSymbol: viewState.selectedSymbol,
|
|
1121
|
-
colors: chartColors,
|
|
1122
|
-
marketSession,
|
|
1123
|
-
}), [chartColors, chartHeight, chartWidth, marketSession, projection, viewState.selectedSymbol]);
|
|
1124
|
-
|
|
1125
|
-
const interactiveResult = useMemo(() => (
|
|
1126
|
-
effectiveRenderer === "kitty" || useCanvasChart
|
|
1127
|
-
? null
|
|
1128
|
-
: renderComparisonChart(projection, {
|
|
1129
|
-
width: chartWidth,
|
|
1130
|
-
height: chartHeight,
|
|
1131
|
-
cursorX: displayCursorX,
|
|
1132
|
-
cursorY: displayCursorY,
|
|
1133
|
-
selectedSymbol: viewState.selectedSymbol,
|
|
1134
|
-
colors: chartColors,
|
|
1135
|
-
marketSession,
|
|
1136
|
-
})
|
|
1137
|
-
), [chartColors, chartHeight, chartWidth, displayCursorX, displayCursorY, effectiveRenderer, marketSession, projection, useCanvasChart, viewState.selectedSymbol]);
|
|
1138
|
-
|
|
1139
|
-
const result = effectiveRenderer === "kitty" || useCanvasChart ? staticResult : interactiveResult!;
|
|
1140
|
-
const timeAxisLabel = result.timeLabels || staticResult.timeLabels;
|
|
1141
|
-
const footerHints = useMemo<PaneHint[]>(() => {
|
|
1142
|
-
const zoomIn = () => {
|
|
1143
|
-
setViewState((current) => applyComparisonZoomAroundAnchor(
|
|
1144
|
-
clearActivePreset(current),
|
|
1145
|
-
current.zoomLevel * 1.5,
|
|
1146
|
-
RIGHT_EDGE_ANCHOR_RATIO,
|
|
1147
|
-
series,
|
|
1148
|
-
));
|
|
1149
|
-
};
|
|
1150
|
-
const resetView = () => {
|
|
1151
|
-
pendingCanonicalResetRef.current += 1;
|
|
1152
|
-
updateDisplayCursorTarget(EMPTY_DISPLAY_CURSOR, "discrete");
|
|
1153
|
-
setViewState((current) => ({
|
|
1154
|
-
...(resolveResolutionSelection(current, effectiveResolution, supportMap, visibleDateWindow) ?? current),
|
|
1155
|
-
panOffset: 0,
|
|
1156
|
-
zoomLevel: 1,
|
|
1157
|
-
cursorX: null,
|
|
1158
|
-
cursorY: null,
|
|
1159
|
-
}));
|
|
1160
|
-
};
|
|
1161
|
-
const cycleRange = () => {
|
|
1162
|
-
const currentIndex = TIME_RANGES.indexOf(viewState.presetRange);
|
|
1163
|
-
setRangePreset(TIME_RANGES[(currentIndex + 1) % TIME_RANGES.length] ?? TIME_RANGES[0]!);
|
|
1164
|
-
};
|
|
1165
|
-
|
|
1166
|
-
return [
|
|
1167
|
-
...(onEditTickers ? [{
|
|
1168
|
-
id: "tickers",
|
|
1169
|
-
key: "t",
|
|
1170
|
-
label: "ickers",
|
|
1171
|
-
onPress: onEditTickers,
|
|
1172
|
-
}] : []),
|
|
1173
|
-
{
|
|
1174
|
-
id: "mode",
|
|
1175
|
-
key: "m",
|
|
1176
|
-
label: "ode",
|
|
1177
|
-
onPress: () => setViewState((current) => ({
|
|
1178
|
-
...current,
|
|
1179
|
-
renderMode: current.renderMode === "line" ? "area" : "line",
|
|
1180
|
-
})),
|
|
1181
|
-
},
|
|
1182
|
-
{
|
|
1183
|
-
id: "resolution",
|
|
1184
|
-
key: "r",
|
|
1185
|
-
label: "es",
|
|
1186
|
-
onPress: () => {
|
|
1187
|
-
const currentIndex = resolutionChips.indexOf(effectiveResolution);
|
|
1188
|
-
const nextResolution = resolutionChips[(currentIndex + 1) % resolutionChips.length] ?? "auto";
|
|
1189
|
-
setResolution(nextResolution);
|
|
1190
|
-
},
|
|
1191
|
-
},
|
|
1192
|
-
{ id: "zoom", key: "+/-", label: "zoom", onPress: zoomIn },
|
|
1193
|
-
{ id: "reset", key: "0", label: "reset", onPress: resetView },
|
|
1194
|
-
...(width >= 72 ? [{ id: "range", key: "1-7", label: "range", onPress: cycleRange }] : []),
|
|
1195
|
-
];
|
|
1196
|
-
}, [effectiveResolution, onEditTickers, resolutionChips, series, supportMap, viewState.presetRange, visibleDateWindow, width]);
|
|
1197
|
-
|
|
1198
|
-
usePaneFooter("comparison-chart", () => ({
|
|
1199
|
-
order: 10,
|
|
1200
|
-
hints: footerHints,
|
|
1201
|
-
}), [footerHints]);
|
|
1202
|
-
|
|
1203
|
-
const nativeCrosshair = useMemo<NativeCrosshairOverlay | null>(() => {
|
|
1204
|
-
if (displayCursor.cellX === null || displayCursor.cellY === null) return null;
|
|
1205
|
-
return {
|
|
1206
|
-
width: chartWidth,
|
|
1207
|
-
height: chartHeight,
|
|
1208
|
-
chartRows: chartHeight,
|
|
1209
|
-
pixelX: displayCursor.pixelX,
|
|
1210
|
-
pixelY: displayCursor.pixelY,
|
|
1211
|
-
colors: {
|
|
1212
|
-
crosshairColor: chartColors.crosshairColor,
|
|
1213
|
-
},
|
|
1214
|
-
};
|
|
1215
|
-
}, [chartColors.crosshairColor, chartHeight, chartWidth, displayCursor]);
|
|
1216
|
-
const blankPlotLines = useMemo(() => buildBlankPlotLines(chartWidth, chartHeight), [chartHeight, chartWidth]);
|
|
1217
|
-
|
|
1218
|
-
useEffect(() => {
|
|
1219
|
-
if (effectiveRenderer === "kitty") return;
|
|
1220
|
-
lastNativeBaseBitmapRef.current = null;
|
|
1221
|
-
lastNativeCrosshairBitmapRef.current = null;
|
|
1222
|
-
nativeSurfaceManager.removeSurface(nativeBaseSurfaceIdRef.current);
|
|
1223
|
-
nativeSurfaceManager.removeSurface(nativeCrosshairSurfaceIdRef.current);
|
|
1224
|
-
lastNativeGeometryRef.current = null;
|
|
1225
|
-
}, [effectiveRenderer, nativeSurfaceManager]);
|
|
1226
|
-
|
|
1227
|
-
useEffect(() => {
|
|
1228
|
-
if (effectiveRenderer !== "kitty" || !rendererState.nativeReady || !plotRef.current) return;
|
|
1229
|
-
const plot = plotRef.current;
|
|
1230
|
-
let mountTimer: ReturnType<typeof setTimeout> | null = null;
|
|
1231
|
-
|
|
1232
|
-
const syncPlacement = () => {
|
|
1233
|
-
if (effectiveRenderer !== "kitty" || !rendererState.nativeReady || !plotRef.current) return;
|
|
1234
|
-
const plot = plotRef.current as NativeSurfaceRenderableNode;
|
|
1235
|
-
const rect = getRenderableCellRect(plot);
|
|
1236
|
-
const visibleRect = resolveNativeSurfaceVisibleRect(plot, renderer.terminalWidth, renderer.terminalHeight);
|
|
1237
|
-
const previous = lastNativeGeometryRef.current;
|
|
1238
|
-
if (previous
|
|
1239
|
-
&& previous.rect.x === rect.x
|
|
1240
|
-
&& previous.rect.y === rect.y
|
|
1241
|
-
&& previous.rect.width === rect.width
|
|
1242
|
-
&& previous.rect.height === rect.height
|
|
1243
|
-
&& previous.visibleRect?.x === visibleRect?.x
|
|
1244
|
-
&& previous.visibleRect?.y === visibleRect?.y
|
|
1245
|
-
&& previous.visibleRect?.width === visibleRect?.width
|
|
1246
|
-
&& previous.visibleRect?.height === visibleRect?.height) {
|
|
1247
|
-
return;
|
|
1248
|
-
}
|
|
1249
|
-
lastNativeGeometryRef.current = { rect, visibleRect };
|
|
1250
|
-
const geometry = {
|
|
1251
|
-
paneId,
|
|
1252
|
-
rect,
|
|
1253
|
-
visibleRect,
|
|
1254
|
-
};
|
|
1255
|
-
syncCachedNativeSurface(
|
|
1256
|
-
nativeSurfaceManager,
|
|
1257
|
-
nativeBaseSurfaceIdRef.current,
|
|
1258
|
-
geometry,
|
|
1259
|
-
lastNativeBaseBitmapRef.current,
|
|
1260
|
-
);
|
|
1261
|
-
syncCachedNativeSurface(
|
|
1262
|
-
nativeSurfaceManager,
|
|
1263
|
-
nativeCrosshairSurfaceIdRef.current,
|
|
1264
|
-
geometry,
|
|
1265
|
-
lastNativeCrosshairBitmapRef.current,
|
|
1266
|
-
);
|
|
1267
|
-
};
|
|
1268
|
-
|
|
1269
|
-
plot.onLifecyclePass = syncPlacement;
|
|
1270
|
-
renderer.registerLifecyclePass(plot);
|
|
1271
|
-
syncPlacement();
|
|
1272
|
-
mountTimer = setTimeout(() => {
|
|
1273
|
-
syncPlacement();
|
|
1274
|
-
renderer.requestRender();
|
|
1275
|
-
}, 0);
|
|
1276
|
-
return () => {
|
|
1277
|
-
if (mountTimer) clearTimeout(mountTimer);
|
|
1278
|
-
plot.onLifecyclePass = null;
|
|
1279
|
-
renderer.unregisterLifecyclePass(plot);
|
|
1280
|
-
lastNativeGeometryRef.current = null;
|
|
1281
|
-
};
|
|
1282
|
-
}, [effectiveRenderer, nativeSurfaceManager, paneId, renderer, rendererState.nativeReady]);
|
|
1283
|
-
|
|
1284
|
-
useEffect(() => {
|
|
1285
|
-
if (effectiveRenderer !== "kitty" || !rendererState.nativeReady || !renderer.resolution || !plotRef.current || !staticScene) {
|
|
1286
|
-
lastNativeBaseBitmapRef.current = null;
|
|
1287
|
-
nativeSurfaceManager.removeSurface(nativeBaseSurfaceIdRef.current);
|
|
1288
|
-
return;
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
const plot = plotRef.current as NativeSurfaceRenderableNode;
|
|
1292
|
-
const plotRect = getRenderableCellRect(plot);
|
|
1293
|
-
const visibleRect = resolveNativeSurfaceVisibleRect(plot, renderer.terminalWidth, renderer.terminalHeight);
|
|
1294
|
-
const bitmapSize = computeBitmapSize(plotRect, renderer.resolution, renderer.terminalWidth, renderer.terminalHeight);
|
|
1295
|
-
const bitmapKey = buildComparisonNativeBitmapKey(
|
|
1296
|
-
symbols.length,
|
|
1297
|
-
projection,
|
|
1298
|
-
viewState.selectedSymbol,
|
|
1299
|
-
bitmapSize.pixelWidth,
|
|
1300
|
-
bitmapSize.pixelHeight,
|
|
1301
|
-
[
|
|
1302
|
-
chartColors.bgColor,
|
|
1303
|
-
chartColors.gridColor,
|
|
1304
|
-
chartColors.crosshairColor,
|
|
1305
|
-
chartColors.preMarketBgColor,
|
|
1306
|
-
chartColors.postMarketBgColor,
|
|
1307
|
-
].join(","),
|
|
1308
|
-
marketSessionKey,
|
|
1309
|
-
);
|
|
1310
|
-
const cachedBitmap = lastNativeBaseBitmapRef.current?.key === bitmapKey
|
|
1311
|
-
? lastNativeBaseBitmapRef.current.bitmap
|
|
1312
|
-
: null;
|
|
1313
|
-
const bitmap = cachedBitmap ?? renderNativeComparisonChartBase(staticScene, bitmapSize.pixelWidth, bitmapSize.pixelHeight);
|
|
1314
|
-
if (!cachedBitmap) {
|
|
1315
|
-
lastNativeBaseBitmapRef.current = { key: bitmapKey, bitmap };
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
if (!visibleRect) {
|
|
1319
|
-
nativeSurfaceManager.removeSurface(nativeBaseSurfaceIdRef.current);
|
|
1320
|
-
return;
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
nativeSurfaceManager.upsertSurface({
|
|
1324
|
-
id: nativeBaseSurfaceIdRef.current,
|
|
1325
|
-
paneId,
|
|
1326
|
-
rect: plotRect,
|
|
1327
|
-
visibleRect,
|
|
1328
|
-
bitmap,
|
|
1329
|
-
bitmapKey,
|
|
1330
|
-
});
|
|
1331
|
-
if (!cachedBitmap) {
|
|
1332
|
-
renderer.requestRender();
|
|
1333
|
-
}
|
|
1334
|
-
}, [
|
|
1335
|
-
chartColors.bgColor,
|
|
1336
|
-
chartColors.crosshairColor,
|
|
1337
|
-
chartColors.gridColor,
|
|
1338
|
-
chartColors.postMarketBgColor,
|
|
1339
|
-
chartColors.preMarketBgColor,
|
|
1340
|
-
effectiveRenderer,
|
|
1341
|
-
marketSessionKey,
|
|
1342
|
-
nativeSurfaceManager,
|
|
1343
|
-
paneId,
|
|
1344
|
-
projection,
|
|
1345
|
-
renderer,
|
|
1346
|
-
rendererState.nativeReady,
|
|
1347
|
-
staticScene,
|
|
1348
|
-
symbols.length,
|
|
1349
|
-
viewState.selectedSymbol,
|
|
1350
|
-
]);
|
|
1351
|
-
|
|
1352
|
-
useEffect(() => {
|
|
1353
|
-
if (effectiveRenderer !== "kitty" || !rendererState.nativeReady || !renderer.resolution || !plotRef.current || !nativeCrosshair) {
|
|
1354
|
-
lastNativeCrosshairBitmapRef.current = null;
|
|
1355
|
-
nativeSurfaceManager.removeSurface(nativeCrosshairSurfaceIdRef.current);
|
|
1356
|
-
return;
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1359
|
-
const plot = plotRef.current as NativeSurfaceRenderableNode;
|
|
1360
|
-
const plotRect = getRenderableCellRect(plot);
|
|
1361
|
-
const visibleRect = resolveNativeSurfaceVisibleRect(plot, renderer.terminalWidth, renderer.terminalHeight);
|
|
1362
|
-
const bitmapSize = computeBitmapSize(plotRect, renderer.resolution, renderer.terminalWidth, renderer.terminalHeight);
|
|
1363
|
-
const renderablePixelSize = getRenderablePixelSize(plotRef.current, renderer);
|
|
1364
|
-
const overlayPixelX = scaleLocalPixelCoordinate(
|
|
1365
|
-
nativeCrosshair.pixelX,
|
|
1366
|
-
renderablePixelSize?.pixelWidth ?? bitmapSize.pixelWidth,
|
|
1367
|
-
bitmapSize.pixelWidth,
|
|
1368
|
-
);
|
|
1369
|
-
const overlayPixelY = scaleLocalPixelCoordinate(
|
|
1370
|
-
nativeCrosshair.pixelY,
|
|
1371
|
-
renderablePixelSize?.pixelHeight ?? bitmapSize.pixelHeight,
|
|
1372
|
-
bitmapSize.pixelHeight,
|
|
1373
|
-
);
|
|
1374
|
-
|
|
1375
|
-
if (overlayPixelX === null || overlayPixelY === null) {
|
|
1376
|
-
lastNativeCrosshairBitmapRef.current = null;
|
|
1377
|
-
nativeSurfaceManager.removeSurface(nativeCrosshairSurfaceIdRef.current);
|
|
1378
|
-
return;
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
const overlay = {
|
|
1382
|
-
...nativeCrosshair,
|
|
1383
|
-
pixelX: overlayPixelX,
|
|
1384
|
-
pixelY: overlayPixelY,
|
|
1385
|
-
};
|
|
1386
|
-
const bitmapKey = buildNativeCrosshairBitmapKey(
|
|
1387
|
-
bitmapSize.pixelWidth,
|
|
1388
|
-
bitmapSize.pixelHeight,
|
|
1389
|
-
overlay.height,
|
|
1390
|
-
overlay.chartRows,
|
|
1391
|
-
overlay.colors.crosshairColor,
|
|
1392
|
-
overlay.pixelX,
|
|
1393
|
-
overlay.pixelY,
|
|
1394
|
-
);
|
|
1395
|
-
const cachedBitmap = lastNativeCrosshairBitmapRef.current?.key === bitmapKey
|
|
1396
|
-
? lastNativeCrosshairBitmapRef.current.bitmap
|
|
1397
|
-
: null;
|
|
1398
|
-
const bitmap = cachedBitmap ?? renderNativeCrosshairOverlay(overlay, bitmapSize.pixelWidth, bitmapSize.pixelHeight);
|
|
1399
|
-
if (!cachedBitmap) {
|
|
1400
|
-
lastNativeCrosshairBitmapRef.current = { key: bitmapKey, bitmap };
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
if (!visibleRect) {
|
|
1404
|
-
nativeSurfaceManager.removeSurface(nativeCrosshairSurfaceIdRef.current);
|
|
1405
|
-
return;
|
|
1406
|
-
}
|
|
1407
|
-
|
|
1408
|
-
nativeSurfaceManager.upsertSurface({
|
|
1409
|
-
id: nativeCrosshairSurfaceIdRef.current,
|
|
1410
|
-
paneId,
|
|
1411
|
-
rect: plotRect,
|
|
1412
|
-
visibleRect,
|
|
1413
|
-
bitmap,
|
|
1414
|
-
bitmapKey,
|
|
1415
|
-
});
|
|
1416
|
-
}, [
|
|
1417
|
-
effectiveRenderer,
|
|
1418
|
-
nativeCrosshair,
|
|
1419
|
-
nativeSurfaceManager,
|
|
1420
|
-
paneId,
|
|
1421
|
-
renderer,
|
|
1422
|
-
rendererState.nativeReady,
|
|
1423
|
-
]);
|
|
1424
|
-
|
|
1425
|
-
useShortcut((event) => {
|
|
1426
|
-
if (!focused || symbols.length === 0) return;
|
|
1427
|
-
|
|
1428
|
-
switch (event.name) {
|
|
1429
|
-
case "=":
|
|
1430
|
-
case "+":
|
|
1431
|
-
setViewState((current) => applyComparisonZoomAroundAnchor(
|
|
1432
|
-
clearActivePreset(current),
|
|
1433
|
-
current.zoomLevel * 1.5,
|
|
1434
|
-
RIGHT_EDGE_ANCHOR_RATIO,
|
|
1435
|
-
series,
|
|
1436
|
-
));
|
|
1437
|
-
return;
|
|
1438
|
-
case "-":
|
|
1439
|
-
case "_":
|
|
1440
|
-
if (viewState.zoomLevel <= 1.001 && expandBufferRange({
|
|
1441
|
-
kind: "zoom-out",
|
|
1442
|
-
targetVisibleCount: Math.round(seriesDates.length * 1.5),
|
|
1443
|
-
anchorRatio: RIGHT_EDGE_ANCHOR_RATIO,
|
|
1444
|
-
})) {
|
|
1445
|
-
return;
|
|
1446
|
-
}
|
|
1447
|
-
setViewState((current) => applyComparisonZoomAroundAnchor(
|
|
1448
|
-
clearActivePreset(current),
|
|
1449
|
-
current.zoomLevel / 1.5,
|
|
1450
|
-
RIGHT_EDGE_ANCHOR_RATIO,
|
|
1451
|
-
series,
|
|
1452
|
-
));
|
|
1453
|
-
return;
|
|
1454
|
-
case "0":
|
|
1455
|
-
pendingCanonicalResetRef.current += 1;
|
|
1456
|
-
updateDisplayCursorTarget(EMPTY_DISPLAY_CURSOR, "discrete");
|
|
1457
|
-
setViewState((current) => ({
|
|
1458
|
-
...(resolveResolutionSelection(current, effectiveResolution, supportMap, visibleDateWindow) ?? current),
|
|
1459
|
-
panOffset: 0,
|
|
1460
|
-
zoomLevel: 1,
|
|
1461
|
-
cursorX: null,
|
|
1462
|
-
cursorY: null,
|
|
1463
|
-
}));
|
|
1464
|
-
return;
|
|
1465
|
-
case "a": {
|
|
1466
|
-
const panStep = getKeyboardPanCellCount(chartWidth);
|
|
1467
|
-
if (viewState.panOffset >= getMaxComparisonPanOffset(series, viewState.zoomLevel) && expandBufferRange({
|
|
1468
|
-
kind: "pan-left",
|
|
1469
|
-
targetPanOffset: viewState.panOffset + panStep,
|
|
1470
|
-
})) {
|
|
1471
|
-
return;
|
|
1472
|
-
}
|
|
1473
|
-
setViewState((current) => ({
|
|
1474
|
-
...clearActivePreset(current),
|
|
1475
|
-
panOffset: clamp(current.panOffset + panStep, 0, getMaxComparisonPanOffset(series, current.zoomLevel)),
|
|
1476
|
-
}));
|
|
1477
|
-
return;
|
|
1478
|
-
}
|
|
1479
|
-
case "d": {
|
|
1480
|
-
const panStep = getKeyboardPanCellCount(chartWidth);
|
|
1481
|
-
setViewState((current) => ({
|
|
1482
|
-
...clearActivePreset(current),
|
|
1483
|
-
panOffset: clamp(current.panOffset - panStep, 0, getMaxComparisonPanOffset(series, current.zoomLevel)),
|
|
1484
|
-
}));
|
|
1485
|
-
return;
|
|
1486
|
-
}
|
|
1487
|
-
case "m":
|
|
1488
|
-
setViewState((current) => ({
|
|
1489
|
-
...current,
|
|
1490
|
-
renderMode: current.renderMode === "line" ? "area" : "line",
|
|
1491
|
-
}));
|
|
1492
|
-
return;
|
|
1493
|
-
case "r": {
|
|
1494
|
-
const currentIndex = resolutionChips.indexOf(effectiveResolution);
|
|
1495
|
-
const nextResolution = resolutionChips[(currentIndex + 1) % resolutionChips.length] ?? "auto";
|
|
1496
|
-
setResolution(nextResolution);
|
|
1497
|
-
return;
|
|
1498
|
-
}
|
|
1499
|
-
case "t":
|
|
1500
|
-
onEditTickers?.();
|
|
1501
|
-
return;
|
|
1502
|
-
case "escape":
|
|
1503
|
-
mouseCrosshairDisabledRef.current = true;
|
|
1504
|
-
updateDisplayCursorTarget(EMPTY_DISPLAY_CURSOR, "discrete");
|
|
1505
|
-
setViewState((current) => ({ ...current, cursorX: null, cursorY: null }));
|
|
1506
|
-
return;
|
|
1507
|
-
case "enter":
|
|
1508
|
-
case "return":
|
|
1509
|
-
if (viewState.selectedSymbol) onOpenSymbol(viewState.selectedSymbol);
|
|
1510
|
-
return;
|
|
1511
|
-
case "left":
|
|
1512
|
-
case "h":
|
|
1513
|
-
selectSymbolByOffset(-1);
|
|
1514
|
-
return;
|
|
1515
|
-
case "right":
|
|
1516
|
-
case "l":
|
|
1517
|
-
selectSymbolByOffset(1);
|
|
1518
|
-
return;
|
|
1519
|
-
case "up":
|
|
1520
|
-
case "k":
|
|
1521
|
-
selectSymbolByOffset(-legendColumns);
|
|
1522
|
-
return;
|
|
1523
|
-
case "down":
|
|
1524
|
-
case "j":
|
|
1525
|
-
selectSymbolByOffset(legendColumns);
|
|
1526
|
-
return;
|
|
1527
|
-
}
|
|
1528
|
-
|
|
1529
|
-
if (event.name >= "1" && event.name <= "7") {
|
|
1530
|
-
const index = parseInt(event.name, 10) - 1;
|
|
1531
|
-
if (index < TIME_RANGES.length) {
|
|
1532
|
-
setRangePreset(TIME_RANGES[index]!);
|
|
1533
|
-
}
|
|
1534
|
-
}
|
|
1535
|
-
});
|
|
1536
|
-
|
|
1537
|
-
const handlePlotMove = (event: ChartMouseEvent) => {
|
|
1538
|
-
if (mouseCrosshairDisabledRef.current) return;
|
|
1539
|
-
const localPointer = getLocalPlotPointer(event, plotRef.current, renderer);
|
|
1540
|
-
if (!localPointer) return;
|
|
1541
|
-
const selectionCursor = resolveSelectionCursor(localPointer, projection.dates.length, chartWidth);
|
|
1542
|
-
updateDisplayCursorTarget(
|
|
1543
|
-
buildDisplayCursorState(
|
|
1544
|
-
localPointer.cellX,
|
|
1545
|
-
localPointer.cellY,
|
|
1546
|
-
plotRef.current,
|
|
1547
|
-
renderer,
|
|
1548
|
-
localPointer.pixelX,
|
|
1549
|
-
localPointer.pixelY,
|
|
1550
|
-
),
|
|
1551
|
-
resolveCursorMotionKind(event, renderer),
|
|
1552
|
-
);
|
|
1553
|
-
commitSelectionCursor(selectionCursor);
|
|
1554
|
-
};
|
|
1555
|
-
|
|
1556
|
-
const handlePlotDown = (event: ChartMouseEvent) => {
|
|
1557
|
-
mouseCrosshairDisabledRef.current = false;
|
|
1558
|
-
const localPointer = getLocalPlotPointer(event, plotRef.current, renderer);
|
|
1559
|
-
if (!localPointer) return;
|
|
1560
|
-
const selectionCursor = resolveSelectionCursor(localPointer, projection.dates.length, chartWidth);
|
|
1561
|
-
updateDisplayCursorTarget(
|
|
1562
|
-
buildDisplayCursorState(
|
|
1563
|
-
localPointer.cellX,
|
|
1564
|
-
localPointer.cellY,
|
|
1565
|
-
plotRef.current,
|
|
1566
|
-
renderer,
|
|
1567
|
-
localPointer.pixelX,
|
|
1568
|
-
localPointer.pixelY,
|
|
1569
|
-
),
|
|
1570
|
-
resolveCursorMotionKind(event, renderer),
|
|
1571
|
-
);
|
|
1572
|
-
dragRef.current = {
|
|
1573
|
-
startGlobalX: getGlobalMouseX(event, renderer),
|
|
1574
|
-
startPanOffset: viewState.panOffset,
|
|
1575
|
-
};
|
|
1576
|
-
commitSelectionCursor(selectionCursor);
|
|
1577
|
-
};
|
|
1578
|
-
|
|
1579
|
-
const handlePlotDrag = (event: ChartMouseEvent) => {
|
|
1580
|
-
if (mouseCrosshairDisabledRef.current && !dragRef.current) return;
|
|
1581
|
-
const localPointer = getLocalPlotPointer(event, plotRef.current, renderer);
|
|
1582
|
-
if (localPointer) {
|
|
1583
|
-
const selectionCursor = resolveSelectionCursor(localPointer, projection.dates.length, chartWidth);
|
|
1584
|
-
updateDisplayCursorTarget(
|
|
1585
|
-
buildDisplayCursorState(
|
|
1586
|
-
localPointer.cellX,
|
|
1587
|
-
localPointer.cellY,
|
|
1588
|
-
plotRef.current,
|
|
1589
|
-
renderer,
|
|
1590
|
-
localPointer.pixelX,
|
|
1591
|
-
localPointer.pixelY,
|
|
1592
|
-
),
|
|
1593
|
-
resolveCursorMotionKind(event, renderer),
|
|
1594
|
-
);
|
|
1595
|
-
commitSelectionCursor(selectionCursor);
|
|
1596
|
-
}
|
|
1597
|
-
if (!dragRef.current) return;
|
|
1598
|
-
|
|
1599
|
-
const deltaCells = getGlobalMouseX(event, renderer) - dragRef.current.startGlobalX;
|
|
1600
|
-
const nextPan = resolveDragPanOffset(
|
|
1601
|
-
dragRef.current.startPanOffset,
|
|
1602
|
-
deltaCells,
|
|
1603
|
-
chartWidth,
|
|
1604
|
-
visibleWindow.dates.length,
|
|
1605
|
-
visibleWindow.totalDates - visibleWindow.dates.length,
|
|
1606
|
-
);
|
|
1607
|
-
setViewState((current) => ({ ...clearActivePreset(current), panOffset: nextPan }));
|
|
1608
|
-
};
|
|
1609
|
-
|
|
1610
|
-
const handlePlotScroll = (event: ChartMouseEvent) => {
|
|
1611
|
-
event.stopPropagation?.();
|
|
1612
|
-
event.preventDefault?.();
|
|
1613
|
-
const direction = event.scroll?.direction;
|
|
1614
|
-
if (!direction) return;
|
|
1615
|
-
const scrollPan = consumeScrollPanMovement(
|
|
1616
|
-
chartWidth,
|
|
1617
|
-
event.scroll?.delta,
|
|
1618
|
-
direction,
|
|
1619
|
-
scrollPanCellRemainderRef.current,
|
|
1620
|
-
);
|
|
1621
|
-
scrollPanCellRemainderRef.current = scrollPan.remainder;
|
|
1622
|
-
const scrollPanCells = scrollPan.cells;
|
|
1623
|
-
|
|
1624
|
-
const localPointer = getLocalPlotPointer(event, plotRef.current, renderer);
|
|
1625
|
-
|
|
1626
|
-
if (localPointer) {
|
|
1627
|
-
const selectionCursor = resolveSelectionCursor(localPointer, projection.dates.length, chartWidth);
|
|
1628
|
-
updateDisplayCursorTarget(
|
|
1629
|
-
buildDisplayCursorState(
|
|
1630
|
-
localPointer.cellX,
|
|
1631
|
-
localPointer.cellY,
|
|
1632
|
-
plotRef.current,
|
|
1633
|
-
renderer,
|
|
1634
|
-
localPointer.pixelX,
|
|
1635
|
-
localPointer.pixelY,
|
|
1636
|
-
),
|
|
1637
|
-
resolveCursorMotionKind(event, renderer),
|
|
1638
|
-
);
|
|
1639
|
-
commitSelectionCursor(selectionCursor);
|
|
1640
|
-
}
|
|
1641
|
-
|
|
1642
|
-
if (scrollPanCells === 0) return;
|
|
1643
|
-
|
|
1644
|
-
const targetPanOffset = viewState.panOffset + scrollPanCells;
|
|
1645
|
-
if (scrollPanCells > 0 && viewState.panOffset >= getMaxComparisonPanOffset(series, viewState.zoomLevel) && expandBufferRange({
|
|
1646
|
-
kind: "pan-left",
|
|
1647
|
-
targetPanOffset,
|
|
1648
|
-
})) {
|
|
1649
|
-
return;
|
|
1650
|
-
}
|
|
1651
|
-
setViewState((current) => ({
|
|
1652
|
-
...clearActivePreset(current),
|
|
1653
|
-
panOffset: clamp(
|
|
1654
|
-
current.panOffset + scrollPanCells,
|
|
1655
|
-
0,
|
|
1656
|
-
getMaxComparisonPanOffset(series, current.zoomLevel),
|
|
1657
|
-
),
|
|
1658
|
-
}));
|
|
1659
|
-
};
|
|
1660
|
-
|
|
1661
|
-
if (symbols.length === 0) {
|
|
1662
|
-
return <Text fg={colors.textDim}>No comparison tickers configured.</Text>;
|
|
1663
|
-
}
|
|
1664
|
-
|
|
1665
|
-
const hasChartData = series.some((entry) => entry.points.length > 0);
|
|
1666
|
-
const hasDisplayCursor = displayCursorX !== null && displayCursorY !== null;
|
|
1667
|
-
const cursorScene = hasDisplayCursor ? displayScene : staticScene;
|
|
1668
|
-
const legendActiveIndex = hasChartData
|
|
1669
|
-
? cursorScene?.activeIdx ?? staticScene?.activeIdx ?? null
|
|
1670
|
-
: null;
|
|
1671
|
-
const visiblePriceRange = result.priceRange ?? staticResult.priceRange ?? undefined;
|
|
1672
|
-
const axisLabels = new Map(staticResult.axisLabels.map((entry) => [entry.row, entry.label]));
|
|
1673
|
-
const cursorRow = useCanvasChart ? cursorScene?.cursorRow ?? null : result.cursorRow;
|
|
1674
|
-
const crosshairValue = useCanvasChart ? cursorScene?.crosshairValue ?? null : result.crosshairValue;
|
|
1675
|
-
const cursorAxisLabel = cursorRow !== null && crosshairValue !== null
|
|
1676
|
-
? formatComparisonCursorAxisValue(
|
|
1677
|
-
crosshairValue,
|
|
1678
|
-
projection.effectiveAxisMode,
|
|
1679
|
-
visiblePriceRange,
|
|
1680
|
-
)
|
|
1681
|
-
: null;
|
|
1682
|
-
const cursorTimeAxisColumn = hasDisplayCursor ? displayScene?.cursorColumn ?? null : null;
|
|
1683
|
-
const cursorTimeAxisDate = hasDisplayCursor ? displayScene?.activeDate ?? null : null;
|
|
1684
|
-
|
|
1685
|
-
const canvasBitmapSize = useMemo(() => {
|
|
1686
|
-
if (!canvasCharts) return null;
|
|
1687
|
-
const resolutionScale = Math.max(1, pixelRatio);
|
|
1688
|
-
return {
|
|
1689
|
-
pixelWidth: Math.max(1, Math.round(chartWidth * cellWidthPx * resolutionScale)),
|
|
1690
|
-
pixelHeight: Math.max(1, Math.round(chartHeight * cellHeightPx * resolutionScale)),
|
|
1691
|
-
};
|
|
1692
|
-
}, [canvasCharts, cellHeightPx, cellWidthPx, chartHeight, chartWidth, pixelRatio]);
|
|
1693
|
-
|
|
1694
|
-
const canvasProjection = useMemo(() => (
|
|
1695
|
-
canvasBitmapSize
|
|
1696
|
-
? projectComparisonChartData(
|
|
1697
|
-
series,
|
|
1698
|
-
Math.max(chartWidth, canvasBitmapSize.pixelWidth),
|
|
1699
|
-
projectionViewState,
|
|
1700
|
-
axisMode,
|
|
1701
|
-
)
|
|
1702
|
-
: null
|
|
1703
|
-
), [axisMode, canvasBitmapSize, chartWidth, projectionViewState, series]);
|
|
1704
|
-
|
|
1705
|
-
const canvasBaseScene = useMemo(() => (
|
|
1706
|
-
canvasProjection
|
|
1707
|
-
? buildComparisonChartScene(canvasProjection, {
|
|
1708
|
-
width: Math.max(chartWidth, canvasBitmapSize?.pixelWidth ?? chartWidth),
|
|
1709
|
-
height: chartHeight,
|
|
1710
|
-
cursorX: null,
|
|
1711
|
-
cursorY: null,
|
|
1712
|
-
selectedSymbol: viewState.selectedSymbol,
|
|
1713
|
-
colors: chartColors,
|
|
1714
|
-
marketSession,
|
|
1715
|
-
})
|
|
1716
|
-
: null
|
|
1717
|
-
), [canvasBitmapSize?.pixelWidth, canvasProjection, chartColors, chartHeight, chartWidth, marketSession, viewState.selectedSymbol]);
|
|
1718
|
-
|
|
1719
|
-
const canvasBaseBitmapKey = useMemo(() => {
|
|
1720
|
-
if (!canvasBitmapSize || !canvasProjection || !hasChartData || isBlockingBody || bodyMessage) return null;
|
|
1721
|
-
return buildComparisonNativeBitmapKey(
|
|
1722
|
-
symbols.length,
|
|
1723
|
-
canvasProjection,
|
|
1724
|
-
viewState.selectedSymbol,
|
|
1725
|
-
canvasBitmapSize.pixelWidth,
|
|
1726
|
-
canvasBitmapSize.pixelHeight,
|
|
1727
|
-
[
|
|
1728
|
-
chartColors.bgColor,
|
|
1729
|
-
chartColors.gridColor,
|
|
1730
|
-
chartColors.crosshairColor,
|
|
1731
|
-
chartColors.preMarketBgColor,
|
|
1732
|
-
chartColors.postMarketBgColor,
|
|
1733
|
-
].join(","),
|
|
1734
|
-
marketSessionKey,
|
|
1735
|
-
);
|
|
1736
|
-
}, [
|
|
1737
|
-
bodyMessage,
|
|
1738
|
-
canvasBitmapSize,
|
|
1739
|
-
canvasProjection,
|
|
1740
|
-
chartColors.bgColor,
|
|
1741
|
-
chartColors.crosshairColor,
|
|
1742
|
-
chartColors.gridColor,
|
|
1743
|
-
chartColors.postMarketBgColor,
|
|
1744
|
-
chartColors.preMarketBgColor,
|
|
1745
|
-
hasChartData,
|
|
1746
|
-
isBlockingBody,
|
|
1747
|
-
marketSessionKey,
|
|
1748
|
-
symbols.length,
|
|
1749
|
-
viewState.selectedSymbol,
|
|
1750
|
-
]);
|
|
1751
|
-
|
|
1752
|
-
const canvasBaseBitmap = useMemo<NativeChartBitmap | null>(() => {
|
|
1753
|
-
return canvasBaseBitmapKey && canvasBaseBitmapState?.key === canvasBaseBitmapKey
|
|
1754
|
-
? canvasBaseBitmapState.bitmap
|
|
1755
|
-
: null;
|
|
1756
|
-
}, [canvasBaseBitmapKey, canvasBaseBitmapState]);
|
|
1757
|
-
|
|
1758
|
-
const visibleCanvasBaseBitmap = useMemo<NativeChartBitmap | null>(() => {
|
|
1759
|
-
if (canvasBaseBitmap) return canvasBaseBitmap;
|
|
1760
|
-
if (!canvasBaseBitmapKey || !canvasBitmapSize || !canvasBaseBitmapState) return null;
|
|
1761
|
-
return canvasBaseBitmapState.bitmap.width === canvasBitmapSize.pixelWidth
|
|
1762
|
-
&& canvasBaseBitmapState.bitmap.height === canvasBitmapSize.pixelHeight
|
|
1763
|
-
? canvasBaseBitmapState.bitmap
|
|
1764
|
-
: null;
|
|
1765
|
-
}, [canvasBaseBitmap, canvasBaseBitmapKey, canvasBaseBitmapState, canvasBitmapSize]);
|
|
1766
|
-
|
|
1767
|
-
useEffect(() => {
|
|
1768
|
-
if (!canvasBitmapSize || !canvasBaseBitmapKey || !canvasBaseScene) {
|
|
1769
|
-
lastCanvasBaseBitmapRef.current = null;
|
|
1770
|
-
setCanvasBaseBitmapState((current) => (current === null ? current : null));
|
|
1771
|
-
return;
|
|
1772
|
-
}
|
|
1773
|
-
|
|
1774
|
-
const cachedBitmap = lastCanvasBaseBitmapRef.current?.key === canvasBaseBitmapKey
|
|
1775
|
-
? lastCanvasBaseBitmapRef.current.bitmap
|
|
1776
|
-
: null;
|
|
1777
|
-
if (cachedBitmap) {
|
|
1778
|
-
setCanvasBaseBitmapState((current) => (
|
|
1779
|
-
current?.key === canvasBaseBitmapKey ? current : { key: canvasBaseBitmapKey, bitmap: cachedBitmap }
|
|
1780
|
-
));
|
|
1781
|
-
return;
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1784
|
-
let cancelled = false;
|
|
1785
|
-
const frame = requestAnimationFrameSafe(() => {
|
|
1786
|
-
const bitmap = renderNativeComparisonChartBase(canvasBaseScene, canvasBitmapSize.pixelWidth, canvasBitmapSize.pixelHeight);
|
|
1787
|
-
if (cancelled) return;
|
|
1788
|
-
lastCanvasBaseBitmapRef.current = { key: canvasBaseBitmapKey, bitmap };
|
|
1789
|
-
setCanvasBaseBitmapState((current) => (
|
|
1790
|
-
current?.key === canvasBaseBitmapKey ? current : { key: canvasBaseBitmapKey, bitmap }
|
|
1791
|
-
));
|
|
1792
|
-
});
|
|
1793
|
-
|
|
1794
|
-
return () => {
|
|
1795
|
-
cancelled = true;
|
|
1796
|
-
cancelAnimationFrameSafe(frame);
|
|
1797
|
-
};
|
|
1798
|
-
}, [canvasBaseBitmapKey, canvasBaseScene, canvasBitmapSize]);
|
|
1799
|
-
|
|
1800
|
-
const canvasCrosshair = useMemo(() => {
|
|
1801
|
-
if (!canvasBitmapSize || !visibleCanvasBaseBitmap || !nativeCrosshair) return null;
|
|
1802
|
-
const renderablePixelSize = getRenderablePixelSize(plotRef.current, renderer);
|
|
1803
|
-
const overlayPixelX = scaleLocalPixelCoordinate(
|
|
1804
|
-
nativeCrosshair.pixelX,
|
|
1805
|
-
renderablePixelSize?.pixelWidth ?? canvasBitmapSize.pixelWidth,
|
|
1806
|
-
canvasBitmapSize.pixelWidth,
|
|
1807
|
-
);
|
|
1808
|
-
const overlayPixelY = scaleLocalPixelCoordinate(
|
|
1809
|
-
nativeCrosshair.pixelY,
|
|
1810
|
-
renderablePixelSize?.pixelHeight ?? canvasBitmapSize.pixelHeight,
|
|
1811
|
-
canvasBitmapSize.pixelHeight,
|
|
1812
|
-
);
|
|
1813
|
-
if (overlayPixelX === null || overlayPixelY === null) return null;
|
|
1814
|
-
return {
|
|
1815
|
-
pixelX: overlayPixelX,
|
|
1816
|
-
pixelY: overlayPixelY,
|
|
1817
|
-
color: nativeCrosshair.colors.crosshairColor,
|
|
1818
|
-
};
|
|
1819
|
-
}, [canvasBitmapSize, nativeCrosshair, renderer, visibleCanvasBaseBitmap]);
|
|
1820
|
-
|
|
1821
|
-
const plotBitmaps = useMemo(() => {
|
|
1822
|
-
if (!visibleCanvasBaseBitmap) return null;
|
|
1823
|
-
return [visibleCanvasBaseBitmap];
|
|
1824
|
-
}, [visibleCanvasBaseBitmap]);
|
|
1825
|
-
|
|
1826
|
-
const plotLines: Array<string | StyledContent> = effectiveRenderer === "kitty"
|
|
1827
|
-
? blankPlotLines
|
|
1828
|
-
: result.lines;
|
|
1829
|
-
const plotContent = plotBitmaps || (useCanvasChart && canvasBaseBitmapKey)
|
|
1830
|
-
? null
|
|
1831
|
-
: plotLines.map((line, index) => (
|
|
1832
|
-
<Text key={index} content={line as unknown as string} />
|
|
1833
|
-
));
|
|
1834
|
-
|
|
1835
|
-
const plotBox = (
|
|
1836
|
-
<ChartSurface
|
|
1837
|
-
ref={plotRef}
|
|
1838
|
-
width={chartWidth}
|
|
1839
|
-
height={chartHeight}
|
|
1840
|
-
flexDirection="column"
|
|
1841
|
-
bitmaps={plotBitmaps}
|
|
1842
|
-
crosshair={canvasCrosshair}
|
|
1843
|
-
onMouseMove={hasChartData && !isBlockingBody && !bodyMessage ? handlePlotMove : undefined}
|
|
1844
|
-
onMouseDown={hasChartData && !isBlockingBody && !bodyMessage ? handlePlotDown : undefined}
|
|
1845
|
-
onMouseUp={hasChartData && !isBlockingBody && !bodyMessage ? () => { dragRef.current = null; } : undefined}
|
|
1846
|
-
onMouseDrag={hasChartData && !isBlockingBody && !bodyMessage ? handlePlotDrag : undefined}
|
|
1847
|
-
onMouseDragEnd={hasChartData && !isBlockingBody && !bodyMessage ? () => { dragRef.current = null; } : undefined}
|
|
1848
|
-
onMouseScroll={hasChartData && !isBlockingBody && !bodyMessage ? handlePlotScroll : undefined}
|
|
1849
|
-
>
|
|
1850
|
-
{isBlockingBody
|
|
1851
|
-
? (
|
|
1852
|
-
<Box flexGrow={1} alignItems="center" justifyContent="center">
|
|
1853
|
-
<Text fg={colors.textDim}>Loading chart...</Text>
|
|
1854
|
-
</Box>
|
|
1855
|
-
)
|
|
1856
|
-
: bodyMessage
|
|
1857
|
-
? (
|
|
1858
|
-
<Box flexGrow={1} alignItems="center" justifyContent="center">
|
|
1859
|
-
<Text fg={colors.textDim}>{bodyMessage}</Text>
|
|
1860
|
-
</Box>
|
|
1861
|
-
)
|
|
1862
|
-
: plotContent}
|
|
1863
|
-
</ChartSurface>
|
|
1864
|
-
);
|
|
1865
|
-
|
|
1866
|
-
const axisBox = (
|
|
1867
|
-
<PriceAxisLabels
|
|
1868
|
-
axisLabels={axisLabels}
|
|
1869
|
-
axisWidth={axisWidth}
|
|
1870
|
-
axisSectionWidth={axisSectionWidth}
|
|
1871
|
-
height={chartHeight}
|
|
1872
|
-
cursorRow={cursorRow}
|
|
1873
|
-
cursorPixelY={hasDisplayCursor ? displayCursor.pixelY : null}
|
|
1874
|
-
cursorLabel={cursorAxisLabel}
|
|
1875
|
-
cursorColor={chartColors.crosshairColor}
|
|
1876
|
-
/>
|
|
1877
|
-
);
|
|
1878
|
-
|
|
1879
|
-
const legendRowsData = Array.from({ length: Math.ceil(symbols.length / legendColumns) }, (_, rowIndex) => (
|
|
1880
|
-
symbols.slice(rowIndex * legendColumns, rowIndex * legendColumns + legendColumns)
|
|
1881
|
-
));
|
|
1882
|
-
|
|
1883
|
-
return (
|
|
1884
|
-
<Box
|
|
1885
|
-
flexDirection="column"
|
|
1886
|
-
flexGrow={1}
|
|
1887
|
-
onMouseScroll={hasChartData && !isBlockingBody && !bodyMessage ? handlePlotScroll : undefined}
|
|
1888
|
-
>
|
|
1889
|
-
<Box flexDirection="row" height={1}>
|
|
1890
|
-
<Box flexDirection="row" gap={1}>
|
|
1891
|
-
{TIME_RANGES.map((range, index) => (
|
|
1892
|
-
<Text
|
|
1893
|
-
key={range}
|
|
1894
|
-
fg={activePreset === range ? colors.textBright : (isRangePresetSupported(range, availableManualResolutions) ? colors.textDim : colors.textMuted)}
|
|
1895
|
-
attributes={activePreset === range ? TextAttributes.BOLD : 0}
|
|
1896
|
-
onMouseDown={() => {
|
|
1897
|
-
if (isRangePresetSupported(range, availableManualResolutions)) {
|
|
1898
|
-
setRangePreset(range);
|
|
1899
|
-
}
|
|
1900
|
-
}}
|
|
1901
|
-
>
|
|
1902
|
-
{`${index + 1}:${range}`}
|
|
1903
|
-
</Text>
|
|
1904
|
-
))}
|
|
1905
|
-
</Box>
|
|
1906
|
-
</Box>
|
|
1907
|
-
|
|
1908
|
-
<Box flexDirection="row" height={1}>
|
|
1909
|
-
<Box flexDirection="row" gap={1}>
|
|
1910
|
-
{resolutionChips.map((resolution) => (
|
|
1911
|
-
<Text
|
|
1912
|
-
key={resolution}
|
|
1913
|
-
fg={effectiveResolution === resolution ? colors.textBright : colors.textDim}
|
|
1914
|
-
attributes={effectiveResolution === resolution ? TextAttributes.BOLD : 0}
|
|
1915
|
-
onMouseDown={() => setResolution(resolution)}
|
|
1916
|
-
>
|
|
1917
|
-
{getChartResolutionLabel(resolution)}
|
|
1918
|
-
</Text>
|
|
1919
|
-
))}
|
|
1920
|
-
{isUpdating && (
|
|
1921
|
-
<Text fg={colors.textDim}>updating</Text>
|
|
1922
|
-
)}
|
|
1923
|
-
</Box>
|
|
1924
|
-
<Box flexGrow={1} />
|
|
1925
|
-
<Box flexDirection="row" gap={1}>
|
|
1926
|
-
{COMPARISON_RENDER_MODES.map((mode) => (
|
|
1927
|
-
<Text
|
|
1928
|
-
key={mode}
|
|
1929
|
-
fg={viewState.renderMode === mode ? colors.textBright : colors.textDim}
|
|
1930
|
-
attributes={viewState.renderMode === mode ? TextAttributes.BOLD : 0}
|
|
1931
|
-
onMouseDown={() => setViewState((current) => ({ ...current, renderMode: mode }))}
|
|
1932
|
-
>
|
|
1933
|
-
{MODE_CHIPS[mode]}
|
|
1934
|
-
</Text>
|
|
1935
|
-
))}
|
|
1936
|
-
{projection.warning && (
|
|
1937
|
-
<Text fg={colors.textDim}>{projection.warning}</Text>
|
|
1938
|
-
)}
|
|
1939
|
-
{showNativeUnavailable && (
|
|
1940
|
-
<Text fg={colors.textDim}>native unavailable</Text>
|
|
1941
|
-
)}
|
|
1942
|
-
</Box>
|
|
1943
|
-
</Box>
|
|
1944
|
-
|
|
1945
|
-
<Box
|
|
1946
|
-
flexDirection="row"
|
|
1947
|
-
height={chartHeight}
|
|
1948
|
-
gap={axisGap}
|
|
1949
|
-
onMouseScroll={hasChartData && !isBlockingBody && !bodyMessage ? handlePlotScroll : undefined}
|
|
1950
|
-
>
|
|
1951
|
-
{plotBox}
|
|
1952
|
-
{axisBox}
|
|
1953
|
-
</Box>
|
|
1954
|
-
|
|
1955
|
-
<Box height={timeAxisRows}>
|
|
1956
|
-
<TimeAxisLabel
|
|
1957
|
-
timeLabels={timeAxisLabel}
|
|
1958
|
-
width={chartWidth}
|
|
1959
|
-
cursorColumn={cursorTimeAxisColumn}
|
|
1960
|
-
cursorPixelX={hasDisplayCursor ? displayCursor.pixelX : null}
|
|
1961
|
-
cursorDate={cursorTimeAxisDate}
|
|
1962
|
-
dates={visibleWindow.dates}
|
|
1963
|
-
cursorColor={chartColors.crosshairColor}
|
|
1964
|
-
/>
|
|
1965
|
-
</Box>
|
|
1966
|
-
|
|
1967
|
-
{legendRows > 0 && (
|
|
1968
|
-
<ScrollBox height={legendRows} scrollY>
|
|
1969
|
-
<Box flexDirection="column">
|
|
1970
|
-
{legendRowsData.map((legendRow, rowIndex) => (
|
|
1971
|
-
<Box key={`legend-row:${rowIndex}`} flexDirection="row" gap={1}>
|
|
1972
|
-
{legendRow.map((symbol) => {
|
|
1973
|
-
const item = projection.series.find((entry) => entry.symbol === symbol) ?? null;
|
|
1974
|
-
const isSelected = viewState.selectedSymbol === symbol;
|
|
1975
|
-
const activeRaw = legendActiveIndex !== null
|
|
1976
|
-
? item?.points[legendActiveIndex]?.rawValue ?? null
|
|
1977
|
-
: item?.latestRawValue ?? null;
|
|
1978
|
-
const currency = item?.currency ?? "USD";
|
|
1979
|
-
const summary = formatLegendSummary(symbol, activeRaw, item?.baseValue ?? null, currency, visiblePriceRange);
|
|
1980
|
-
|
|
1981
|
-
return (
|
|
1982
|
-
<Box
|
|
1983
|
-
key={symbol}
|
|
1984
|
-
width={legendItemWidth}
|
|
1985
|
-
backgroundColor={isSelected ? blendHex(colors.panel, colors.borderFocused, 0.18) : colors.panel}
|
|
1986
|
-
onMouseMove={() => setSelectedSymbol(symbol)}
|
|
1987
|
-
onMouseDown={() => {
|
|
1988
|
-
setSelectedSymbol(symbol);
|
|
1989
|
-
onOpenSymbol(symbol);
|
|
1990
|
-
}}
|
|
1991
|
-
>
|
|
1992
|
-
<Text fg={item?.color ?? colors.textDim} attributes={isSelected ? TextAttributes.BOLD : 0}>
|
|
1993
|
-
{clipText(`${isSelected ? ">" : " "} ${summary}`, legendItemWidth)}
|
|
1994
|
-
</Text>
|
|
1995
|
-
</Box>
|
|
1996
|
-
);
|
|
1997
|
-
})}
|
|
1998
|
-
</Box>
|
|
1999
|
-
))}
|
|
2000
|
-
</Box>
|
|
2001
|
-
</ScrollBox>
|
|
2002
|
-
)}
|
|
2003
|
-
|
|
2004
|
-
</Box>
|
|
2005
|
-
);
|
|
2006
|
-
}
|
|
2007
|
-
|
|
2008
|
-
const MemoizedComparisonStockChartView = memo(ComparisonStockChartView);
|
|
5
|
+
export type { ComparisonStockChartProps } from "./comparison-stock-chart/types";
|
|
2009
6
|
|
|
2010
7
|
export function ComparisonStockChart(props: ComparisonStockChartProps) {
|
|
2011
|
-
const
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
const ticker = tickers.get(symbol) ?? null;
|
|
2018
|
-
const financial = financials.get(symbol) ?? null;
|
|
2019
|
-
const instrument = ticker?.metadata.broker_contracts?.[0] ?? null;
|
|
2020
|
-
return {
|
|
2021
|
-
symbol,
|
|
2022
|
-
currency: financial?.quote?.currency ?? ticker?.metadata.currency,
|
|
2023
|
-
exchange: ticker?.metadata.exchange ?? "",
|
|
2024
|
-
brokerId: instrument?.brokerId,
|
|
2025
|
-
brokerInstanceId: instrument?.brokerInstanceId,
|
|
2026
|
-
instrument,
|
|
2027
|
-
priceHistory: financial?.priceHistory ?? [],
|
|
2028
|
-
};
|
|
2029
|
-
}), [financials, stableSymbols, tickers]);
|
|
8
|
+
const {
|
|
9
|
+
defaultRenderMode,
|
|
10
|
+
preferredRenderer,
|
|
11
|
+
stableSymbols,
|
|
12
|
+
symbolSources,
|
|
13
|
+
} = useComparisonChartSymbolSources(props.symbols);
|
|
2030
14
|
|
|
2031
15
|
return (
|
|
2032
16
|
<MemoizedComparisonStockChartView
|
|
2033
17
|
{...props}
|
|
2034
18
|
symbols={stableSymbols}
|
|
2035
|
-
defaultRenderMode={
|
|
2036
|
-
preferredRenderer={
|
|
19
|
+
defaultRenderMode={defaultRenderMode}
|
|
20
|
+
preferredRenderer={preferredRenderer}
|
|
2037
21
|
symbolSources={symbolSources}
|
|
2038
22
|
/>
|
|
2039
23
|
);
|