gloomberb 0.10.1 → 0.10.2
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/package.json +8 -1
- package/src/api-client/auth.ts +1 -0
- package/src/api-client/index.test.ts +359 -108
- package/src/api-client/index.ts +24 -13
- package/src/api-client/socket.ts +70 -35
- package/src/api-client/types.ts +1 -1
- package/src/app/language-observer.test.tsx +82 -0
- package/src/app/language-observer.tsx +13 -0
- package/src/app/pane-runtime/index.tsx +2 -2
- package/src/app/pane-runtime/pane-settings-runtime.tsx +2 -2
- package/src/app/pane-runtime/pane-template-runtime.ts +2 -2
- package/src/app/pane-runtime/plugin-bindings.ts +2 -2
- package/src/app/pane-runtime/ticker-open-runtime.ts +2 -2
- package/src/app/runtime/broker-import.ts +2 -2
- package/src/app/runtime/plugin-bindings.ts +2 -2
- package/src/app/runtime/startup.ts +2 -2
- package/src/app.tsx +16 -7
- package/src/brokers/account-cache.ts +6 -6
- package/src/brokers/broker-ticker-sync.ts +3 -3
- package/src/brokers/remote-broker-adapter.ts +2 -2
- package/src/brokers/sync-broker-instance.ts +5 -6
- package/src/cli/commands/api.ts +3 -6
- package/src/cli/commands/automation.ts +7 -15
- package/src/cli/commands/market.ts +26 -61
- package/src/cli/commands/overview.ts +34 -45
- package/src/cli/commands/search.ts +25 -27
- package/src/cli/commands/system.ts +27 -57
- package/src/cli/commands/ticker.ts +62 -63
- package/src/cli/context.test.ts +63 -0
- package/src/cli/context.ts +15 -1
- package/src/cli/index.ts +1 -1
- package/src/cli/pane-functions/data.ts +2 -19
- package/src/cli/pane-functions/index.ts +26 -25
- package/src/cli/pane-functions/report.ts +1 -1
- package/src/cli/pane-functions/screenshot.ts +3 -3
- package/src/cli/scoped-context.ts +41 -0
- package/src/components/chart/composite/composite-chart.test.tsx +615 -18
- package/src/components/chart/composite/composite-chart.tsx +179 -79
- package/src/components/chart/composite/format.test.ts +20 -7
- package/src/components/chart/composite/index.ts +0 -21
- package/src/components/chart/composite/interactions.test.ts +90 -3
- package/src/components/chart/composite/interactions.ts +189 -24
- package/src/components/chart/composite/price-series.ts +0 -2
- package/src/components/chart/composite/rasterizer.ts +10 -9
- package/src/components/chart/composite/renderers.test.ts +108 -2
- package/src/components/chart/composite/scene.test.ts +36 -0
- package/src/components/chart/composite/scene.ts +5 -2
- package/src/components/chart/composite/text-renderer.ts +37 -25
- package/src/components/chart/composite/time-axis.test.ts +243 -0
- package/src/components/chart/composite/time-axis.ts +608 -0
- package/src/components/chart/composite/types.ts +12 -1
- package/src/components/chart/core/data.ts +2 -159
- package/src/components/chart/core/date-window.ts +6 -225
- package/src/components/chart/core/palette.ts +1 -12
- package/src/components/chart/core/pointer.ts +0 -142
- package/src/components/chart/core/types.ts +1 -58
- package/src/components/chart/cursor-motion.ts +2 -4
- package/src/components/chart/indicators/types.ts +0 -9
- package/src/components/chart/market-session.ts +0 -11
- package/src/components/chart/native/kitty/protocol.ts +1 -1
- package/src/components/chart/native/raster/layout.ts +3 -10
- package/src/components/chart/static/chart/axis-overlays.test.tsx +64 -0
- package/src/components/chart/static/chart/axis-overlays.tsx +59 -14
- package/src/components/chart/static/chart/surface.tsx +1 -2
- package/src/components/command-bar/action-runtime.ts +2 -2
- package/src/components/command-bar/commands/direct/index.ts +1 -1
- package/src/components/command-bar/panel/body.tsx +2 -2
- package/src/components/command-bar/panel/index.tsx +11 -9
- package/src/components/command-bar/routes/ticker-search/actions.ts +2 -2
- package/src/components/command-bar/surface/index.tsx +2 -2
- package/src/components/command-bar/workflow/body.tsx +3 -3
- package/src/components/command-bar/workflow/collection-actions.ts +2 -2
- package/src/components/command-bar/workflow/coordinator.ts +2 -2
- package/src/components/command-bar/workflow/field-row.tsx +25 -11
- package/src/components/command-bar/workflow/tickers.ts +2 -2
- package/src/components/feed-data-table/stack-view.test.tsx +28 -36
- package/src/components/feed-data-table/stack-view.tsx +3 -1
- package/src/components/layout/detached-pane-shell.tsx +6 -6
- package/src/components/layout/header.tsx +13 -9
- package/src/components/layout/pane/content.test.tsx +42 -3
- package/src/components/layout/pane/content.tsx +3 -1
- package/src/components/layout/pane/footer/index.test.tsx +45 -2
- package/src/components/layout/pane/footer/registration.tsx +3 -1
- package/src/components/layout/shell/index.tsx +1 -2
- package/src/components/layout/shell/native/surfaces.ts +1 -1
- package/src/components/layout/shell/native/window-state.ts +1 -1
- package/src/components/layout/status-bar.tsx +12 -8
- package/src/components/layout/window-controls.tsx +8 -6
- package/src/components/onboarding/onboarding-wizard.tsx +3 -1
- package/src/components/pane-settings-dialog/desktop.tsx +0 -2
- package/src/components/pane-settings-dialog.tsx +0 -2
- package/src/components/pane-template-wizard.tsx +10 -9
- package/src/components/price-performance.tsx +2 -113
- package/src/components/price-sparkline/model.ts +15 -17
- package/src/components/price-sparkline/view.tsx +8 -7
- package/src/components/speedometer-gauge/desktop.tsx +2 -1
- package/src/components/speedometer-gauge/index.tsx +0 -2
- package/src/components/speedometer-gauge/terminal.tsx +24 -5
- package/src/components/ticker/badge/index.tsx +1 -18
- package/src/components/ui/data-table/opentui/index.tsx +3 -3
- package/src/components/ui/frame.tsx +1 -2
- package/src/components/ui/page-stack-view.test.tsx +126 -0
- package/src/components/ui/page-stack-view.tsx +24 -12
- package/src/components/ui/tabs.tsx +7 -3
- package/src/components/ui/ui.test.tsx +23 -2
- package/src/components/use-external-link-footer.ts +4 -2
- package/src/core/app-service-ports.ts +46 -0
- package/src/core/app-services.test.ts +66 -0
- package/src/core/app-services.ts +17 -15
- package/src/data/config/chart-settings.ts +3 -10
- package/src/data/config/store/index.test.ts +99 -2
- package/src/data/config/store/migrations.ts +278 -0
- package/src/data/config/store/normalize.ts +44 -186
- package/src/data/resource-store.ts +73 -12
- package/src/data/sqlite/cache.test.ts +104 -15
- package/src/i18n/index.test.ts +17 -0
- package/src/i18n/index.ts +23 -6
- package/src/i18n/ja.ts +13 -0
- package/src/i18n/ko.ts +13 -0
- package/src/i18n/react.ts +6 -0
- package/src/i18n/zh-cn.ts +13 -0
- package/src/i18n/zh-tw.ts +13 -0
- package/src/market-data/coordinator/auxiliary.ts +7 -3
- package/src/market-data/coordinator/chart.ts +1 -1
- package/src/market-data/coordinator/index.test.ts +26 -0
- package/src/market-data/coordinator/index.ts +11 -5
- package/src/market-data/coordinator/quotes.ts +4 -40
- package/src/market-data/coordinator/subscriptions.test.ts +89 -1
- package/src/market-data/hooks.tsx +47 -1
- package/src/market-data/market/status.ts +6 -6
- package/src/market-data/performance.ts +1 -1
- package/src/market-data/quote-subscription-target.test.ts +37 -0
- package/src/market-data/quote-subscription-target.ts +60 -0
- package/src/market-data/quotes/freshness.ts +1 -0
- package/src/market-data/quotes/resolution.ts +4 -0
- package/src/market-data/request-types.ts +3 -3
- package/src/news/aggregator.test.ts +97 -1
- package/src/news/aggregator.ts +100 -57
- package/src/news/hooks.test.tsx +64 -0
- package/src/news/hooks.ts +18 -25
- package/src/plugins/builtin/account-management/footer.ts +4 -2
- package/src/plugins/builtin/account-management/pane.tsx +9 -4
- package/src/plugins/builtin/ai/agent-history.ts +11 -7
- package/src/plugins/builtin/ai/ask-ai-detail-tab.tsx +0 -5
- package/src/plugins/builtin/ai/ask-ai.test.tsx +3 -4
- package/src/plugins/builtin/ai/index.test.ts +2 -2
- package/src/plugins/builtin/ai/index.tsx +10 -11
- package/src/plugins/builtin/ai/pane-settings.ts +1 -1
- package/src/plugins/builtin/ai/pi/runtime.ts +6 -5
- package/src/plugins/builtin/ai/providers.ts +1 -9
- package/src/plugins/builtin/ai/runner.ts +0 -6
- package/src/plugins/builtin/ai/screener/footer.ts +4 -1
- package/src/plugins/builtin/ai/screener/pane.test.tsx +9 -9
- package/src/plugins/builtin/ai/workspace/model.ts +2 -27
- package/src/plugins/builtin/ai/workspace/pane.tsx +2 -2
- package/src/plugins/builtin/analytics/metrics.ts +1 -7
- package/src/plugins/builtin/broker-manager/detail.tsx +3 -2
- package/src/plugins/builtin/broker-manager/index.tsx +4 -2
- package/src/plugins/builtin/chart-composer/editor/controller.ts +643 -0
- package/src/plugins/builtin/chart-composer/editor/desktop-view.tsx +134 -0
- package/src/plugins/builtin/chart-composer/editor/model.test.ts +85 -0
- package/src/plugins/builtin/chart-composer/editor/model.ts +292 -0
- package/src/plugins/builtin/chart-composer/editor/opentui-view.tsx +108 -0
- package/src/plugins/builtin/chart-composer/editor.tsx +65 -947
- package/src/plugins/builtin/chart-composer/index.tsx +0 -6
- package/src/plugins/builtin/chart-composer/pane.tsx +69 -36
- package/src/plugins/builtin/chart-composer/presets.ts +1 -19
- package/src/plugins/builtin/chart-composer/settings.ts +1 -1
- package/src/plugins/builtin/chat/content/composer-runtime.ts +1 -1
- package/src/plugins/builtin/chat/content/shortcuts.ts +0 -1
- package/src/plugins/builtin/chat/controller/fetch.ts +8 -2
- package/src/plugins/builtin/chat/controller/persistence.ts +2 -0
- package/src/plugins/builtin/chat/controller/session.test.ts +25 -0
- package/src/plugins/builtin/chat/controller/session.ts +2 -0
- package/src/plugins/builtin/chat/controller/state.ts +7 -0
- package/src/plugins/builtin/chat/controller.test.ts +73 -20
- package/src/plugins/builtin/chat/message/desktop.tsx +2 -0
- package/src/plugins/builtin/cloud-tweets/footer.ts +9 -28
- package/src/plugins/builtin/cloud-tweets/pane.tsx +0 -5
- package/src/plugins/builtin/cloud-tweets/table.tsx +12 -17
- package/src/plugins/builtin/correlation/compute.ts +4 -10
- package/src/plugins/builtin/econ/index.tsx +17 -19
- package/src/plugins/builtin/holders/types.ts +0 -1
- package/src/plugins/builtin/insider/index.tsx +6 -31
- package/src/plugins/builtin/news/index.tsx +5 -7
- package/src/plugins/builtin/news/wire/breaking/pane.test.tsx +6 -8
- package/src/plugins/builtin/news/wire/news/footer.ts +10 -11
- package/src/plugins/builtin/news/wire/read-state.test.ts +7 -0
- package/src/plugins/builtin/news/wire/read-state.ts +18 -28
- package/src/plugins/builtin/news/wire/rss/parser.ts +1 -11
- package/src/plugins/builtin/options/footer.test.ts +115 -0
- package/src/plugins/builtin/options/footer.ts +110 -0
- package/src/plugins/builtin/options/live-quotes.test.ts +238 -0
- package/src/plugins/builtin/options/live-quotes.ts +147 -0
- package/src/plugins/builtin/options/view.test.tsx +71 -1
- package/src/plugins/builtin/options/view.tsx +39 -24
- package/src/plugins/builtin/portfolio-list/cli/portfolio-command.ts +103 -117
- package/src/plugins/builtin/portfolio-list/cli/render.ts +11 -5
- package/src/plugins/builtin/portfolio-list/cli/watchlist-command.ts +120 -135
- package/src/plugins/builtin/portfolio-list/header.tsx +9 -4
- package/src/plugins/builtin/portfolio-list/quick-add/index.tsx +6 -1
- package/src/plugins/builtin/portfolio-list/quick-add/resolution.ts +4 -2
- package/src/plugins/builtin/research/corporate-actions-pane.tsx +24 -52
- package/src/plugins/builtin/sec/filing-content.test.ts +41 -0
- package/src/plugins/builtin/sec/filing-content.ts +94 -0
- package/src/plugins/builtin/sec/index.tsx +21 -104
- package/src/plugins/builtin/sectors/sector-model.ts +1 -7
- package/src/plugins/builtin/shared/cloud-upgrade.ts +1 -0
- package/src/plugins/builtin/shared/pane-footer.ts +82 -0
- package/src/plugins/builtin/shared/read-state.ts +64 -3
- package/src/plugins/builtin/substack/read-state.ts +16 -41
- package/src/plugins/builtin/thirteenf/pane.tsx +24 -73
- package/src/plugins/builtin/ticker-detail/quote-monitor/index.tsx +10 -10
- package/src/plugins/builtin/yield-curve/index.tsx +11 -9
- package/src/plugins/ibkr/dialogs.tsx +3 -3
- package/src/plugins/ibkr/gateway/fundamentals.ts +1 -1
- package/src/plugins/ibkr/gateway/history-requests.ts +2 -2
- package/src/plugins/ibkr/gateway/history.ts +2 -2
- package/src/plugins/ibkr/gateway/selection.ts +2 -2
- package/src/plugins/ibkr/gateway/service/index.ts +2 -2
- package/src/plugins/ibkr/gateway/service/native.ts +2 -2
- package/src/plugins/plugin-persistence.ts +3 -4
- package/src/plugins/prediction-markets/controller/keyboard.ts +1 -1
- package/src/plugins/prediction-markets/controller/live-updates.ts +6 -5
- package/src/plugins/prediction-markets/detail/book.tsx +2 -2
- package/src/plugins/prediction-markets/detail/outcomes.tsx +3 -1
- package/src/plugins/prediction-markets/detail/pane.tsx +3 -1
- package/src/plugins/prediction-markets/detail/trades.tsx +3 -3
- package/src/plugins/registry/context.ts +3 -4
- package/src/plugins/registry/index.ts +5 -6
- package/src/react/input.test.ts +126 -3
- package/src/react/input.ts +120 -1
- package/src/remote/app-host.tsx +2 -13
- package/src/renderers/electrobun/bun/desktop/backend-requests.ts +44 -60
- package/src/renderers/electrobun/bun/desktop/capability-bridge.ts +15 -13
- package/src/renderers/electrobun/bun/desktop/host-requests.ts +26 -22
- package/src/renderers/electrobun/bun/desktop/http-fetch.ts +5 -1
- package/src/renderers/electrobun/bun/desktop/initialization.ts +11 -6
- package/src/renderers/electrobun/bun/desktop/media.ts +5 -3
- package/src/renderers/electrobun/bun/desktop/plugin-state.ts +21 -22
- package/src/renderers/electrobun/bun/desktop/window-controls.ts +3 -1
- package/src/renderers/electrobun/bun/desktop/workspace/requests.ts +18 -18
- package/src/renderers/electrobun/bun/index.ts +123 -83
- package/src/renderers/electrobun/shared/protocol.ts +146 -7
- package/src/renderers/electrobun/view/app-services.ts +5 -8
- package/src/renderers/electrobun/view/backend-rpc.ts +18 -8
- package/src/renderers/electrobun/view/broker-remote-client.ts +2 -2
- package/src/renderers/electrobun/view/cli-pane-shot-entry.tsx +5 -22
- package/src/renderers/electrobun/view/config-host.ts +1 -1
- package/src/renderers/electrobun/view/context-menu.ts +1 -17
- package/src/renderers/electrobun/view/data-table/index.tsx +0 -1
- package/src/renderers/electrobun/view/data-table/row.tsx +0 -4
- package/src/renderers/electrobun/view/desktop/control-styles.ts +37 -34
- package/src/renderers/electrobun/view/desktop/controls.tsx +36 -33
- package/src/renderers/electrobun/view/desktop/list-view.tsx +15 -12
- package/src/renderers/electrobun/view/desktop/popover.tsx +2 -3
- package/src/renderers/electrobun/view/dialog-host.tsx +2 -3
- package/src/renderers/electrobun/view/fatal-screen.tsx +0 -1
- package/src/renderers/electrobun/view/host/box.tsx +0 -1
- package/src/renderers/electrobun/view/host/chart-surface.tsx +0 -1
- package/src/renderers/electrobun/view/host/input.tsx +0 -1
- package/src/renderers/electrobun/view/host/media-surface.tsx +0 -1
- package/src/renderers/electrobun/view/host/native.ts +0 -1
- package/src/renderers/electrobun/view/host/scroll-box.tsx +0 -1
- package/src/renderers/electrobun/view/host/tabs.tsx +0 -1
- package/src/renderers/electrobun/view/host/text.tsx +0 -1
- package/src/renderers/electrobun/view/http-fetch.ts +3 -11
- package/src/renderers/electrobun/view/input-host.tsx +10 -53
- package/src/renderers/electrobun/view/key-event.ts +0 -1
- package/src/renderers/electrobun/view/main.tsx +3 -3
- package/src/renderers/electrobun/view/native-renderer.ts +0 -1
- package/src/renderers/electrobun/view/native-stubs/backend-rpc.ts +13 -1
- package/src/renderers/electrobun/view/remote/asset-data-client.ts +6 -44
- package/src/renderers/electrobun/view/remote/persistence.ts +6 -2
- package/src/renderers/electrobun/view/remote/quote-subscription-registry.test.ts +86 -0
- package/src/renderers/electrobun/view/remote/quote-subscription-registry.ts +72 -0
- package/src/renderers/electrobun/view/remote/ticker-repository.ts +2 -2
- package/src/renderers/electrobun/view/toast-host.tsx +0 -1
- package/src/renderers/electrobun/view/ui-host.tsx +1 -2
- package/src/renderers/electrobun/view/update-host.ts +1 -1
- package/src/renderers/opentui/chart-surface.tsx +2 -1
- package/src/renderers/opentui/dialog-host.tsx +20 -4
- package/src/renderers/opentui/image/loader.ts +12 -2
- package/src/renderers/opentui/input-host.tsx +7 -49
- package/src/renderers/opentui/start.tsx +2 -0
- package/src/sources/gloomberb-cloud/history-quality.ts +44 -0
- package/src/sources/gloomberb-cloud/index.test.ts +173 -0
- package/src/sources/gloomberb-cloud/index.ts +42 -20
- package/src/sources/gloomberb-cloud/normalizers.ts +9 -3
- package/src/sources/provider-router/cache.ts +1 -1
- package/src/sources/provider-router/document-routes.ts +10 -5
- package/src/sources/provider-router/financials.test.ts +14 -0
- package/src/sources/provider-router/financials.ts +6 -1
- package/src/sources/provider-router/history.test.ts +163 -1
- package/src/sources/provider-router/history.ts +278 -347
- package/src/sources/provider-router/index.ts +2 -2
- package/src/sources/provider-router/routing.test.ts +39 -0
- package/src/sources/provider-router/routing.ts +24 -11
- package/src/sources/provider-router/supplemental.ts +37 -17
- package/src/sources/sec-edgar/content.ts +2 -12
- package/src/sources/sec-edgar.ts +2 -13
- package/src/sources/yahoo-finance/history.ts +2 -2
- package/src/sources/yahoo-finance/options.ts +5 -0
- package/src/sources/yahoo-finance.ts +2 -2
- package/src/state/app/bootstrap.ts +2 -2
- package/src/state/app/context/index.tsx +2 -2
- package/src/state/hooks/quote-streaming.ts +66 -1
- package/src/state/hooks/session-snapshot.ts +2 -2
- package/src/state/selectors.ts +0 -9
- package/src/sync/controller.test.ts +98 -0
- package/src/sync/controller.ts +29 -5
- package/src/sync/react.ts +2 -2
- package/src/sync/types.ts +2 -2
- package/src/theme/colors.test.ts +10 -0
- package/src/theme/colors.ts +75 -78
- package/src/theme/theme-context.test.tsx +67 -0
- package/src/theme/theme-context.tsx +9 -5
- package/src/tickers/open-target.ts +2 -2
- package/src/tickers/search/upsert.ts +2 -2
- package/src/time-series/alignment.ts +0 -7
- package/src/time-series/chart-data.ts +145 -0
- package/src/time-series/date-window.ts +44 -0
- package/src/time-series/history-window.ts +21 -0
- package/src/time-series/hooks.test.ts +59 -0
- package/src/time-series/hooks.ts +33 -12
- package/src/time-series/market-resolution.ts +2 -2
- package/src/time-series/market.ts +1 -1
- package/src/time-series/range.ts +9 -0
- package/src/{components/chart/core → time-series}/resolution.ts +3 -102
- package/src/time-series/resolve.test.ts +203 -1
- package/src/time-series/resolve.ts +96 -18
- package/src/time-series/spec-studies.test.ts +15 -0
- package/src/time-series/spec.ts +2 -2
- package/src/time-series/studies.ts +5 -2
- package/src/time-series/types.ts +3 -1
- package/src/time-series/use-chart-resolution.test.tsx +358 -0
- package/src/time-series/use-chart-resolution.ts +46 -4
- package/src/types/broker.ts +2 -2
- package/src/types/data-provider.ts +3 -3
- package/src/types/financials.ts +12 -0
- package/src/types/plugin.ts +2 -2
- package/src/ui/context-menu.tsx +3 -2
- package/src/ui/dialog.tsx +2 -2
- package/src/utils/html-entities.ts +3 -5
- package/src/utils/main-thread-monitor.ts +1 -1
- package/src/utils/price-history.ts +5 -5
- package/src/version.ts +3 -1
- package/src/components/chart/core/viewport.test.ts +0 -8
- package/src/components/chart/core/viewport.ts +0 -24
- package/src/time-series/index.ts +0 -14
- /package/src/{components/chart/core → time-series}/resolution.test.ts +0 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import type { CompositeChartScene } from "./types";
|
|
3
|
+
import {
|
|
4
|
+
buildCompositeTimeAxisLayout,
|
|
5
|
+
buildCompositeViewportTimeAxisLayout,
|
|
6
|
+
type CompositeTimeAxisLayout,
|
|
7
|
+
} from "./time-axis";
|
|
8
|
+
|
|
9
|
+
function viewport(start: string, end: string, width: number): CompositeTimeAxisLayout {
|
|
10
|
+
return buildCompositeViewportTimeAxisLayout({
|
|
11
|
+
start: new Date(start),
|
|
12
|
+
end: new Date(end),
|
|
13
|
+
}, width);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function expectValidLayout(layout: CompositeTimeAxisLayout, width: number): void {
|
|
17
|
+
expect(layout.text).toHaveLength(width);
|
|
18
|
+
layout.ticks.forEach((tick, index) => {
|
|
19
|
+
expect(tick.start).toBeGreaterThanOrEqual(0);
|
|
20
|
+
expect(tick.end).toBeLessThan(width);
|
|
21
|
+
expect(tick.end).toBeGreaterThanOrEqual(tick.start);
|
|
22
|
+
expect(layout.text.slice(tick.start, tick.end + 1)).toBe(tick.label);
|
|
23
|
+
if (index > 0) {
|
|
24
|
+
expect(tick.start).toBeGreaterThan(layout.ticks[index - 1]!.end);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function marketScene(
|
|
30
|
+
dates: string[],
|
|
31
|
+
dateRatios: number[],
|
|
32
|
+
): CompositeChartScene {
|
|
33
|
+
const timestamps = dates.map((date) => Date.parse(date));
|
|
34
|
+
const startTime = timestamps[0]!;
|
|
35
|
+
const endTime = timestamps.at(-1)!;
|
|
36
|
+
return {
|
|
37
|
+
width: 80,
|
|
38
|
+
height: 10,
|
|
39
|
+
startTime,
|
|
40
|
+
endTime,
|
|
41
|
+
timeScale: {
|
|
42
|
+
kind: "market",
|
|
43
|
+
startTime,
|
|
44
|
+
endTime,
|
|
45
|
+
anchorSeriesId: "price",
|
|
46
|
+
cadenceMs: 24 * 60 * 60 * 1_000,
|
|
47
|
+
anchors: timestamps.map((timestamp, index) => ({
|
|
48
|
+
timestamp,
|
|
49
|
+
position: index,
|
|
50
|
+
})),
|
|
51
|
+
startPosition: 0,
|
|
52
|
+
endPosition: Math.max(timestamps.length - 1, 1),
|
|
53
|
+
},
|
|
54
|
+
dates: timestamps.map((timestamp) => new Date(timestamp)),
|
|
55
|
+
dateRatios,
|
|
56
|
+
panels: [],
|
|
57
|
+
cursorDate: null,
|
|
58
|
+
cursorXRatio: null,
|
|
59
|
+
cursorValues: [],
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
describe("adaptive composite time axis", () => {
|
|
64
|
+
test("increases intraday density with width while keeping concise UTC clock labels", () => {
|
|
65
|
+
const narrow = viewport(
|
|
66
|
+
"2026-07-29T09:30:00.000Z",
|
|
67
|
+
"2026-07-29T16:00:00.000Z",
|
|
68
|
+
40,
|
|
69
|
+
);
|
|
70
|
+
const medium = viewport(
|
|
71
|
+
"2026-07-29T09:30:00.000Z",
|
|
72
|
+
"2026-07-29T16:00:00.000Z",
|
|
73
|
+
80,
|
|
74
|
+
);
|
|
75
|
+
const wide = viewport(
|
|
76
|
+
"2026-07-29T09:30:00.000Z",
|
|
77
|
+
"2026-07-29T16:00:00.000Z",
|
|
78
|
+
165,
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
expect(narrow.text).toContain("09:30 UTC");
|
|
82
|
+
expect(narrow.text).toContain("16:00 UTC");
|
|
83
|
+
expect(narrow.text).not.toContain("2026-07-29");
|
|
84
|
+
expect(medium.ticks.length).toBeGreaterThan(narrow.ticks.length);
|
|
85
|
+
expect(wide.ticks.length).toBeGreaterThan(medium.ticks.length);
|
|
86
|
+
expectValidLayout(narrow, 40);
|
|
87
|
+
expectValidLayout(medium, 80);
|
|
88
|
+
expectValidLayout(wide, 165);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("uses day, month, and year context appropriate to the visible span", () => {
|
|
92
|
+
const month = viewport(
|
|
93
|
+
"2026-06-29T00:00:00.000Z",
|
|
94
|
+
"2026-07-29T00:00:00.000Z",
|
|
95
|
+
80,
|
|
96
|
+
);
|
|
97
|
+
const year = viewport(
|
|
98
|
+
"2025-07-29T00:00:00.000Z",
|
|
99
|
+
"2026-07-29T00:00:00.000Z",
|
|
100
|
+
80,
|
|
101
|
+
);
|
|
102
|
+
const multiyear = viewport(
|
|
103
|
+
"2021-07-29T00:00:00.000Z",
|
|
104
|
+
"2026-07-29T00:00:00.000Z",
|
|
105
|
+
40,
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
expect(month.text).toContain("Jun 29");
|
|
109
|
+
expect(month.text).toContain("Jul 29");
|
|
110
|
+
expect(month.text).not.toContain("2026-06-29");
|
|
111
|
+
expect(month.ticks.length).toBeGreaterThan(3);
|
|
112
|
+
expect(year.text).toContain("Jul 29 2025");
|
|
113
|
+
expect(year.text).toContain("Jan 2026");
|
|
114
|
+
expect(year.text).toContain("Jul 29 2026");
|
|
115
|
+
expect(year.ticks.length).toBeGreaterThan(3);
|
|
116
|
+
expect(multiyear.text).toContain("2021");
|
|
117
|
+
expect(multiyear.text).toContain("2026");
|
|
118
|
+
expect(multiyear.text).not.toContain("Jul 29");
|
|
119
|
+
expectValidLayout(month, 80);
|
|
120
|
+
expectValidLayout(year, 80);
|
|
121
|
+
expectValidLayout(multiyear, 40);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test("gives a wide NBIS-length chart useful bimonthly density", () => {
|
|
125
|
+
const narrow = viewport(
|
|
126
|
+
"2024-10-21T00:00:00.000Z",
|
|
127
|
+
"2026-07-29T00:00:00.000Z",
|
|
128
|
+
40,
|
|
129
|
+
);
|
|
130
|
+
const wide = viewport(
|
|
131
|
+
"2024-10-21T00:00:00.000Z",
|
|
132
|
+
"2026-07-29T00:00:00.000Z",
|
|
133
|
+
165,
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
expect(narrow.ticks.length).toBeGreaterThanOrEqual(2);
|
|
137
|
+
expect(wide.ticks.length).toBeGreaterThanOrEqual(8);
|
|
138
|
+
expect(wide.ticks.length).toBeGreaterThan(narrow.ticks.length);
|
|
139
|
+
expect(wide.text).toContain("Oct 21 2024");
|
|
140
|
+
expect(wide.text).toContain("Jan 2025");
|
|
141
|
+
expect(wide.text).toContain("Jan 2026");
|
|
142
|
+
expect(wide.text).toContain("Jul 29 2026");
|
|
143
|
+
expectValidLayout(narrow, 40);
|
|
144
|
+
expectValidLayout(wide, 165);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test("keeps very narrow layouts in bounds without overlapping labels", () => {
|
|
148
|
+
for (const width of [18, 24]) {
|
|
149
|
+
const layout = viewport(
|
|
150
|
+
"2024-10-21T00:00:00.000Z",
|
|
151
|
+
"2026-07-29T00:00:00.000Z",
|
|
152
|
+
width,
|
|
153
|
+
);
|
|
154
|
+
expect(layout.ticks.length).toBeGreaterThanOrEqual(2);
|
|
155
|
+
expectValidLayout(layout, width);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test("snaps calendar boundaries to supplied market ratios instead of inventing weekend ticks", () => {
|
|
160
|
+
const scene = marketScene([
|
|
161
|
+
"2025-01-03T00:00:00.000Z",
|
|
162
|
+
"2025-01-06T00:00:00.000Z",
|
|
163
|
+
"2025-01-07T00:00:00.000Z",
|
|
164
|
+
], [0, 0.25, 1]);
|
|
165
|
+
const layout = buildCompositeTimeAxisLayout(scene, 80);
|
|
166
|
+
const monday = layout.ticks.find((tick) => (
|
|
167
|
+
tick.timestamp === Date.parse("2025-01-06T00:00:00.000Z")
|
|
168
|
+
));
|
|
169
|
+
|
|
170
|
+
expect(monday?.ratio).toBe(0.25);
|
|
171
|
+
expect(monday?.start).toBeLessThan(30);
|
|
172
|
+
expect(layout.ticks.some((tick) => tick.label.includes("4"))).toBe(false);
|
|
173
|
+
expect(layout.ticks.some((tick) => tick.label.includes("5"))).toBe(false);
|
|
174
|
+
expectValidLayout(layout, 80);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test("keeps the final month tick and an exact viewport endpoint distinct", () => {
|
|
178
|
+
const layout = viewport(
|
|
179
|
+
"2025-11-03T00:00:00.000Z",
|
|
180
|
+
"2026-07-29T00:00:00.000Z",
|
|
181
|
+
217,
|
|
182
|
+
);
|
|
183
|
+
const july = layout.ticks.find((tick) => (
|
|
184
|
+
tick.timestamp === Date.parse("2026-07-01T00:00:00.000Z")
|
|
185
|
+
));
|
|
186
|
+
const endpoint = layout.ticks.at(-1);
|
|
187
|
+
|
|
188
|
+
expect(july?.label).toBe("Jul");
|
|
189
|
+
expect(july?.ratio).toBeCloseTo(240 / 268);
|
|
190
|
+
expect(endpoint).toMatchObject({
|
|
191
|
+
timestamp: Date.parse("2026-07-29T00:00:00.000Z"),
|
|
192
|
+
ratio: 1,
|
|
193
|
+
label: "Jul 29 2026",
|
|
194
|
+
});
|
|
195
|
+
expectValidLayout(layout, 217);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
test("keeps viewport edges distinct from market observations between those edges", () => {
|
|
199
|
+
const scene = marketScene([
|
|
200
|
+
"2025-01-03T10:00:00.000Z",
|
|
201
|
+
"2025-01-03T16:00:00.000Z",
|
|
202
|
+
], [0.25, 0.9]);
|
|
203
|
+
scene.startTime = Date.parse("2025-01-03T09:30:00.000Z");
|
|
204
|
+
scene.endTime = Date.parse("2025-01-03T16:30:00.000Z");
|
|
205
|
+
const layout = buildCompositeTimeAxisLayout(scene, 80);
|
|
206
|
+
const tenOClock = layout.ticks.find((tick) => (
|
|
207
|
+
tick.timestamp === Date.parse("2025-01-03T10:00:00.000Z")
|
|
208
|
+
));
|
|
209
|
+
|
|
210
|
+
expect(layout.ticks[0]?.timestamp).toBe(scene.startTime);
|
|
211
|
+
expect(layout.ticks[0]?.ratio).toBe(0);
|
|
212
|
+
expect(tenOClock?.ratio).toBe(0.25);
|
|
213
|
+
expect(layout.ticks.at(-1)?.timestamp).toBe(scene.endTime);
|
|
214
|
+
expect(layout.ticks.at(-1)?.ratio).toBe(1);
|
|
215
|
+
expectValidLayout(layout, 80);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
test("compacts cross-year endpoints before dropping either side", () => {
|
|
219
|
+
const layout = viewport(
|
|
220
|
+
"2025-12-31T23:30:00.000Z",
|
|
221
|
+
"2026-01-01T00:30:00.000Z",
|
|
222
|
+
30,
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
expect(layout.text).toContain("Dec 31 23:30");
|
|
226
|
+
expect(layout.text).toContain("Jan 1 00:30");
|
|
227
|
+
expect(layout.ticks).toHaveLength(2);
|
|
228
|
+
expectValidLayout(layout, 30);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
test("keeps fixed UTC progression across a local daylight-saving transition", () => {
|
|
232
|
+
const layout = viewport(
|
|
233
|
+
"2025-03-30T00:30:00.000Z",
|
|
234
|
+
"2025-03-30T04:30:00.000Z",
|
|
235
|
+
165,
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
expect(layout.text).toContain("01:00");
|
|
239
|
+
expect(layout.text).toContain("02:00");
|
|
240
|
+
expect(layout.text).toContain("03:00");
|
|
241
|
+
expectValidLayout(layout, 165);
|
|
242
|
+
});
|
|
243
|
+
});
|