@orangecharts/wrun-chart-host 0.1.0 → 0.3.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 +39 -6
- package/dist/constants/common.constants.d.ts +15 -0
- package/dist/constants/common.constants.js +23 -0
- package/dist/constants/data-source.constants.d.ts +1 -0
- package/dist/constants/data-source.constants.js +1 -0
- package/dist/constants/economic.constants.d.ts +39 -0
- package/dist/constants/economic.constants.js +77 -0
- package/dist/constants/etf-covered-coins.constants.d.ts +1 -0
- package/dist/constants/etf-covered-coins.constants.js +9 -0
- package/dist/constants/feature-flags.constants.d.ts +60 -0
- package/dist/constants/feature-flags.constants.js +308 -0
- package/dist/constants/feature-limits.constants.d.ts +134 -0
- package/dist/constants/feature-limits.constants.js +155 -0
- package/dist/constants/marketCapabilities.constants.d.ts +87 -0
- package/dist/constants/marketCapabilities.constants.js +213 -0
- package/dist/constants/option-venues.constants.d.ts +100 -0
- package/dist/constants/option-venues.constants.js +167 -0
- package/dist/constants/overlay-data.constants.d.ts +53 -0
- package/dist/constants/overlay-data.constants.js +80 -0
- package/dist/constants/pane-grid.constants.d.ts +15 -0
- package/dist/constants/pane-grid.constants.js +17 -0
- package/dist/constants/venue-presets.constants.d.ts +10 -0
- package/dist/constants/venue-presets.constants.js +22 -0
- package/dist/enums/chart.enum.d.ts +68 -0
- package/dist/enums/chart.enum.js +70 -0
- package/dist/helpers/data.helpers.d.ts +2 -0
- package/dist/helpers/data.helpers.js +14 -0
- package/dist/host-env.d.ts +161 -5
- package/dist/host-ports.types.d.ts +446 -0
- package/dist/host-ports.types.js +1 -0
- package/dist/index.d.ts +131 -0
- package/dist/index.js +131 -0
- package/dist/indicators/controls/technical-script/technical-script-input-rendering.d.ts +86 -0
- package/dist/indicators/controls/technical-script/technical-script-input-rendering.js +179 -0
- package/dist/interfaces/asset-venue.interface.d.ts +91 -0
- package/dist/interfaces/asset-venue.interface.js +1 -0
- package/dist/interfaces/cancel-reason.interface.d.ts +24 -0
- package/dist/interfaces/cancel-reason.interface.js +2 -0
- package/dist/interfaces/catalog-display.interface.d.ts +3 -0
- package/dist/interfaces/catalog-display.interface.js +1 -0
- package/dist/interfaces/cme-realtime.interface.d.ts +251 -0
- package/dist/interfaces/cme-realtime.interface.js +46 -0
- package/dist/interfaces/feed.interface.d.ts +80 -0
- package/dist/interfaces/feed.interface.js +7 -0
- package/dist/interfaces/market-kind.interface.d.ts +8 -0
- package/dist/interfaces/market-kind.interface.js +1 -0
- package/dist/interfaces/opra-realtime.interface.d.ts +224 -0
- package/dist/interfaces/opra-realtime.interface.js +105 -0
- package/dist/interfaces/option-instrument.interface.d.ts +32 -0
- package/dist/interfaces/option-instrument.interface.js +1 -0
- package/dist/interfaces/options-chain-scope.interface.d.ts +29 -0
- package/dist/interfaces/options-chain-scope.interface.js +7 -0
- package/dist/interfaces/prediction-market.interface.d.ts +88 -0
- package/dist/interfaces/prediction-market.interface.js +8 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +5 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +185 -0
- package/dist/kscript-data/controls/live-trades-merge.util.js +357 -0
- package/dist/settings-templates/frvp-fields.d.ts +27 -0
- package/dist/settings-templates/frvp-fields.js +108 -0
- package/dist/settings-templates/index.d.ts +119 -0
- package/dist/settings-templates/index.js +442 -0
- package/dist/settings-templates/indicator-fields.d.ts +56 -0
- package/dist/settings-templates/indicator-fields.js +793 -0
- package/dist/settings-templates/tool-rules.d.ts +59 -0
- package/dist/settings-templates/tool-rules.js +49 -0
- package/dist/settings-templates/tool-tables.generated.d.ts +2 -0
- package/dist/settings-templates/tool-tables.generated.js +1668 -0
- package/dist/utility/blk-market.util.d.ts +5 -0
- package/dist/utility/blk-market.util.js +12 -0
- package/dist/utility/chart/chart-load-phase.util.d.ts +32 -0
- package/dist/utility/chart/chart-load-phase.util.js +78 -0
- package/dist/utility/chart/cme-cache-context.util.d.ts +108 -0
- package/dist/utility/chart/cme-cache-context.util.js +166 -0
- package/dist/utility/chart/cme-session-bucket.util.d.ts +82 -0
- package/dist/utility/chart/cme-session-bucket.util.js +343 -0
- package/dist/utility/chart/cme-trade-calendar.util.d.ts +26 -0
- package/dist/utility/chart/cme-trade-calendar.util.js +147 -0
- package/dist/utility/chart/continuous-contracts.util.d.ts +138 -0
- package/dist/utility/chart/continuous-contracts.util.js +374 -0
- package/dist/utility/chart/feed-interval.util.d.ts +119 -0
- package/dist/utility/chart/feed-interval.util.js +321 -0
- package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +110 -0
- package/dist/utility/chart/fetch-dedupe-policy.util.js +407 -0
- package/dist/utility/chart/footprint-band.util.d.ts +76 -0
- package/dist/utility/chart/footprint-band.util.js +205 -0
- package/dist/utility/chart/footprint-cell-identity.util.d.ts +82 -0
- package/dist/utility/chart/footprint-cell-identity.util.js +346 -0
- package/dist/utility/chart/formula-calendar.util.d.ts +27 -0
- package/dist/utility/chart/formula-calendar.util.js +59 -0
- package/dist/utility/chart/history-wall.util.d.ts +67 -0
- package/dist/utility/chart/history-wall.util.js +87 -0
- package/dist/utility/chart/index-mode.util.d.ts +66 -0
- package/dist/utility/chart/index-mode.util.js +360 -0
- package/dist/utility/chart/indicator-coverage-planner.util.d.ts +217 -0
- package/dist/utility/chart/indicator-coverage-planner.util.js +443 -0
- package/dist/utility/chart/indicator-coverage-state.util.d.ts +33 -0
- package/dist/utility/chart/indicator-coverage-state.util.js +110 -0
- package/dist/utility/chart/indicator-gap-detector.util.d.ts +127 -0
- package/dist/utility/chart/indicator-gap-detector.util.js +260 -0
- package/dist/utility/chart/indicator-gap-repair.util.d.ts +88 -0
- package/dist/utility/chart/indicator-gap-repair.util.js +177 -0
- package/dist/utility/chart/indicator-inflight-registry.util.d.ts +26 -0
- package/dist/utility/chart/indicator-inflight-registry.util.js +254 -0
- package/dist/utility/chart/interval-registry.util.d.ts +23 -0
- package/dist/utility/chart/interval-registry.util.js +83 -0
- package/dist/utility/chart/kscript-main-grid-stages.util.d.ts +21 -0
- package/dist/utility/chart/kscript-main-grid-stages.util.js +332 -0
- package/dist/utility/chart/legacy-exchange.leaf.d.ts +11 -0
- package/dist/utility/chart/legacy-exchange.leaf.js +43 -0
- package/dist/utility/chart/live-bucket.util.d.ts +66 -0
- package/dist/utility/chart/live-bucket.util.js +165 -0
- package/dist/utility/chart/market-session-schedule.util.d.ts +91 -0
- package/dist/utility/chart/market-session-schedule.util.js +337 -0
- package/dist/utility/chart/marketKind.util.d.ts +181 -0
- package/dist/utility/chart/marketKind.util.js +371 -0
- package/dist/utility/chart/om-panel.util.js +6 -0
- package/dist/utility/chart/om-widget.util.d.ts +4 -0
- package/dist/utility/chart/opra-read-access.leaf.d.ts +26 -0
- package/dist/utility/chart/opra-read-access.leaf.js +25 -0
- package/dist/utility/chart/prediction-identity.util.d.ts +159 -0
- package/dist/utility/chart/prediction-identity.util.js +236 -0
- package/dist/utility/chart/rth-session.util.d.ts +352 -0
- package/dist/utility/chart/rth-session.util.js +926 -0
- package/dist/utility/chart/titan-constants.pin.d.ts +43 -0
- package/dist/utility/chart/titan-constants.pin.js +50 -0
- package/dist/utility/chart/us-equities-session.util.d.ts +127 -0
- package/dist/utility/chart/us-equities-session.util.js +251 -0
- package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +100 -0
- package/dist/utility/chart/wrun-bar-session-facts.util.js +354 -0
- package/dist/utility/chart/wrun-run-result.util.js +10 -0
- package/dist/utility/chart/wrun-wire-ref.util.d.ts +23 -0
- package/dist/utility/chart/wrun-wire-ref.util.js +16 -0
- package/dist/utility/common/safe-math-eval.d.ts +18 -0
- package/dist/utility/common/safe-math-eval.js +160 -0
- package/dist/utility/common/time.util.d.ts +134 -0
- package/dist/utility/common/time.util.js +428 -0
- package/dist/utility/common/transformations.util.d.ts +126 -0
- package/dist/utility/common/transformations.util.js +711 -0
- package/dist/utility/common/visible-timeout.util.d.ts +17 -0
- package/dist/utility/common/visible-timeout.util.js +75 -0
- package/dist/utility/exchange-normalization.util.d.ts +8 -0
- package/dist/utility/exchange-normalization.util.js +32 -0
- package/dist/utility/intl-locale.util.d.ts +2 -0
- package/dist/utility/intl-locale.util.js +28 -0
- package/dist/utility/number-format.util.d.ts +14 -1
- package/dist/utility/number-format.util.js +50 -19
- package/dist/utility/options/option-symbol.util.d.ts +28 -0
- package/dist/utility/options/option-symbol.util.js +176 -0
- package/dist/utility/options/option-trade-units.util.d.ts +190 -0
- package/dist/utility/options/option-trade-units.util.js +283 -0
- package/dist/utility/options/option-venue.util.d.ts +75 -0
- package/dist/utility/options/option-venue.util.js +85 -0
- package/dist/utility/pool-symbol.leaf.d.ts +34 -0
- package/dist/utility/pool-symbol.leaf.js +95 -0
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +109 -0
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +302 -0
- package/dist/utility/symbol-selection/contract-expiry.util.d.ts +39 -0
- package/dist/utility/symbol-selection/contract-expiry.util.js +111 -0
- package/dist/utility/v2/gate-plane.util.d.ts +58 -0
- package/dist/utility/v2/gate-plane.util.js +99 -0
- package/dist/utility/v2/gate-session-latch.util.d.ts +22 -0
- package/dist/utility/v2/gate-session-latch.util.js +34 -0
- package/dist/utility/watchlist/import/tradingview-symbols.leaf.d.ts +76 -0
- package/dist/utility/watchlist/import/tradingview-symbols.leaf.js +221 -0
- package/dist/utility/wrun/sources/host-grid-landing.d.ts +15 -0
- package/dist/utility/wrun/sources/host-grid-landing.js +26 -0
- package/dist/utility/wrun/sources/lanes/bitfinex_funding.d.ts +27 -0
- package/dist/utility/wrun/sources/lanes/bitfinex_funding.js +85 -0
- package/dist/utility/wrun/sources/lanes/economic.d.ts +27 -0
- package/dist/utility/wrun/sources/lanes/economic.js +79 -0
- package/dist/utility/wrun/sources/lanes/etf_holdings.d.ts +35 -0
- package/dist/utility/wrun/sources/lanes/etf_holdings.js +165 -0
- package/dist/utility/wrun/sources/lanes/etf_premium.d.ts +19 -0
- package/dist/utility/wrun/sources/lanes/etf_premium.js +114 -0
- package/dist/utility/wrun/sources/lanes/ethena_positions.d.ts +30 -0
- package/dist/utility/wrun/sources/lanes/ethena_positions.js +51 -0
- package/dist/utility/wrun/sources/lanes/index.d.ts +2 -0
- package/dist/utility/wrun/sources/lanes/index.js +32 -0
- package/dist/utility/wrun/sources/lanes/long_short_ratio.d.ts +17 -0
- package/dist/utility/wrun/sources/lanes/long_short_ratio.js +47 -0
- package/dist/utility/wrun/sources/lanes/option_daily.d.ts +30 -0
- package/dist/utility/wrun/sources/lanes/option_daily.js +53 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +23 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.js +20 -0
- package/dist/utility/wrun/sources/lanes/options_flow.d.ts +50 -0
- package/dist/utility/wrun/sources/lanes/options_flow.js +155 -0
- package/dist/utility/wrun/sources/lanes/options_oi.d.ts +29 -0
- package/dist/utility/wrun/sources/lanes/options_oi.js +59 -0
- package/dist/utility/wrun/sources/lanes/options_volume.d.ts +38 -0
- package/dist/utility/wrun/sources/lanes/options_volume.js +63 -0
- package/dist/utility/wrun/sources/lanes/series.d.ts +67 -0
- package/dist/utility/wrun/sources/lanes/series.js +321 -0
- package/dist/utility/wrun/sources/lanes/token_supply.d.ts +30 -0
- package/dist/utility/wrun/sources/lanes/token_supply.js +145 -0
- package/dist/utility/wrun/sources/lanes/treasury_balance.d.ts +25 -0
- package/dist/utility/wrun/sources/lanes/treasury_balance.js +47 -0
- package/dist/utility/wrun/sources/lanes/volatility_index.d.ts +21 -0
- package/dist/utility/wrun/sources/lanes/volatility_index.js +11 -0
- package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +196 -0
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +446 -0
- package/dist/utility/wrun/sources/registry.d.ts +21 -0
- package/dist/utility/wrun/sources/registry.js +207 -0
- package/dist/utility/wrun/sources/row-lane-registry.d.ts +28 -0
- package/dist/utility/wrun/sources/row-lane-registry.js +230 -0
- package/dist/utility/wrun/sources/row-lanes/index.d.ts +2 -0
- package/dist/utility/wrun/sources/row-lanes/index.js +12 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +2 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +38 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +6 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +70 -0
- package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +4 -0
- package/dist/utility/wrun/sources/row-lanes/option_prints.js +191 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +13 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +137 -0
- package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +38 -0
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +150 -0
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +275 -0
- package/dist/utility/wrun/sources/wrun-poll-lane.types.js +26 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +224 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +394 -0
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +283 -0
- package/dist/utility/wrun/sources/wrun-row-lane.types.js +16 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +205 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +469 -0
- package/dist/utility/wrun/wrun-browser-sources.leaf.d.ts +28 -0
- package/dist/utility/wrun/wrun-browser-sources.leaf.js +66 -0
- package/dist/utility/wrun/wrun-cloud-record.util.d.ts +65 -0
- package/dist/utility/wrun/wrun-cloud-record.util.js +121 -0
- package/dist/utility/wrun/wrun-color-settings.util.js +1 -1
- package/dist/utility/wrun/wrun-daily-lane.util.d.ts +95 -0
- package/dist/utility/wrun/wrun-daily-lane.util.js +297 -0
- package/dist/utility/wrun/wrun-deadline.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-deadline.util.js +82 -0
- package/dist/utility/wrun/wrun-etf-flow-lane.util.d.ts +94 -0
- package/dist/utility/wrun/wrun-etf-flow-lane.util.js +224 -0
- package/dist/utility/wrun/wrun-etf-funds.util.d.ts +82 -0
- package/dist/utility/wrun/wrun-etf-funds.util.js +242 -0
- package/dist/utility/wrun/wrun-failure-cause.d.ts +39 -0
- package/dist/utility/wrun/wrun-failure-cause.js +94 -0
- package/dist/utility/wrun/wrun-frames.d.ts +28 -3
- package/dist/utility/wrun/wrun-frames.js +132 -52
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +167 -4
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +47 -2
- package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +5 -2
- package/dist/utility/wrun/wrun-hosted-wire.util.js +4 -2
- package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +22 -0
- package/dist/utility/wrun/wrun-lane-refusal.leaf.js +32 -0
- package/dist/utility/wrun/wrun-lane-warmup.util.d.ts +18 -0
- package/dist/utility/wrun/wrun-lane-warmup.util.js +112 -0
- package/dist/utility/wrun/wrun-leg-close.util.d.ts +57 -0
- package/dist/utility/wrun/wrun-leg-close.util.js +187 -0
- package/dist/utility/wrun/wrun-leg-fetch.util.d.ts +144 -0
- package/dist/utility/wrun/wrun-leg-fetch.util.js +212 -0
- package/dist/utility/wrun/wrun-leg-stream-classes.d.ts +73 -0
- package/dist/utility/wrun/wrun-leg-stream-classes.js +86 -0
- package/dist/utility/wrun/wrun-levels-child.util.d.ts +101 -6
- package/dist/utility/wrun/wrun-levels-child.util.js +335 -157
- package/dist/utility/wrun/wrun-memory-clamp.util.d.ts +33 -0
- package/dist/utility/wrun/wrun-memory-clamp.util.js +146 -0
- package/dist/utility/wrun/wrun-odds-template-market.util.d.ts +51 -0
- package/dist/utility/wrun/wrun-odds-template-market.util.js +251 -0
- package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +65 -0
- package/dist/utility/wrun/wrun-opra-flow.leaf.js +94 -0
- package/dist/utility/wrun/wrun-opra-lane.util.d.ts +47 -0
- package/dist/utility/wrun/wrun-opra-lane.util.js +58 -0
- package/dist/utility/wrun/wrun-opra-stats.leaf.d.ts +30 -0
- package/dist/utility/wrun/wrun-opra-stats.leaf.js +96 -0
- package/dist/utility/wrun/wrun-opra-underlying.util.d.ts +12 -0
- package/dist/utility/wrun/wrun-opra-underlying.util.js +1 -0
- package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +142 -0
- package/dist/utility/wrun/wrun-option-contract-flow.util.js +451 -0
- package/dist/utility/wrun/wrun-option-knobs.util.d.ts +43 -0
- package/dist/utility/wrun/wrun-option-knobs.util.js +81 -0
- package/dist/utility/wrun/wrun-option-prints.util.d.ts +144 -0
- package/dist/utility/wrun/wrun-option-prints.util.js +356 -0
- package/dist/utility/wrun/wrun-option-summary-lane.util.d.ts +102 -0
- package/dist/utility/wrun/wrun-option-summary-lane.util.js +143 -0
- package/dist/utility/wrun/wrun-options-chain.util.d.ts +308 -0
- package/dist/utility/wrun/wrun-options-chain.util.js +502 -0
- package/dist/utility/wrun/wrun-overlay-identity.util.d.ts +9 -4
- package/dist/utility/wrun/wrun-overlay-identity.util.js +16 -6
- package/dist/utility/wrun/wrun-pack.util.d.ts +6 -2
- package/dist/utility/wrun/wrun-pack.util.js +13 -3
- package/dist/utility/wrun/wrun-param-map.util.d.ts +298 -0
- package/dist/utility/wrun/wrun-param-map.util.js +581 -0
- package/dist/utility/wrun/wrun-param-values.util.d.ts +8 -0
- package/dist/utility/wrun/wrun-param-values.util.js +8 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +149 -0
- package/dist/utility/wrun/wrun-pin-spelling.util.js +523 -0
- package/dist/utility/wrun/wrun-pin-venues.util.d.ts +116 -0
- package/dist/utility/wrun/wrun-pin-venues.util.js +320 -0
- package/dist/utility/wrun/wrun-pinned-interval.util.d.ts +20 -0
- package/dist/utility/wrun/wrun-pinned-interval.util.js +47 -0
- package/dist/utility/wrun/wrun-present-bits.util.d.ts +37 -0
- package/dist/utility/wrun/wrun-present-bits.util.js +73 -0
- package/dist/utility/wrun/wrun-protocol-pending.util.d.ts +33 -0
- package/dist/utility/wrun/wrun-protocol-pending.util.js +57 -0
- package/dist/utility/wrun/wrun-refusal.util.d.ts +95 -7
- package/dist/utility/wrun/wrun-refusal.util.js +314 -18
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +1 -14
- package/dist/utility/wrun/wrun-registry-errors.util.js +0 -16
- package/dist/utility/wrun/wrun-render-select.util.js +1 -0
- package/dist/utility/wrun/wrun-row-market.util.d.ts +29 -0
- package/dist/utility/wrun/wrun-row-market.util.js +92 -0
- package/dist/utility/wrun/wrun-row-source.d.ts +158 -0
- package/dist/utility/wrun/wrun-row-source.js +75 -0
- package/dist/utility/wrun/wrun-run-health.util.d.ts +155 -0
- package/dist/utility/wrun/wrun-run-health.util.js +273 -0
- package/dist/utility/wrun/wrun-socket-row-source.d.ts +439 -0
- package/dist/utility/wrun/wrun-socket-row-source.js +1689 -0
- package/dist/utility/wrun/wrun-socket-session-losses.util.d.ts +18 -0
- package/dist/utility/wrun/wrun-socket-session-losses.util.js +25 -0
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +911 -0
- package/dist/utility/wrun/wrun-source-rows.util.js +2597 -0
- package/dist/utility/wrun/wrun-symbol-code.util.d.ts +32 -0
- package/dist/utility/wrun/wrun-symbol-code.util.js +56 -0
- package/dist/utility/wrun/wrun-tape-source.util.d.ts +82 -0
- package/dist/utility/wrun/wrun-tape-source.util.js +151 -0
- package/dist/utility/wrun/wrun-tier-grid.util.d.ts +137 -0
- package/dist/utility/wrun/wrun-tier-grid.util.js +279 -0
- package/dist/utility/wrun/wrun-trades-lane.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-trades-lane.util.js +58 -0
- package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +41 -0
- package/dist/utility/wrun/wrun-volume-profile-lane.util.js +66 -0
- package/dist/utility/wrun-display-name.util.d.ts +33 -0
- package/dist/utility/wrun-display-name.util.js +64 -0
- package/dist/workers/constants/kscript-transport-codes.d.ts +15 -0
- package/dist/workers/constants/kscript-transport-codes.js +15 -0
- package/dist/workers/constants/socket-slots.d.ts +574 -0
- package/dist/workers/constants/socket-slots.js +539 -0
- package/dist/workers/utils/number.worker.util.d.ts +5 -0
- package/dist/workers/utils/number.worker.util.js +10 -0
- package/dist/workers/utils/time.worker.util.d.ts +12 -0
- package/dist/workers/utils/time.worker.util.js +24 -0
- package/dist/workers/utils/volume-profile.worker.util.d.ts +200 -0
- package/dist/workers/utils/volume-profile.worker.util.js +631 -0
- package/package.json +10 -4
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { MIN_ROWS_FOR_MEDIAN } from './indicator-gap-detector.util.js';
|
|
2
|
+
const INDICATOR_GAP_REPAIR_TYPES = new Set([
|
|
3
|
+
'AGGREGATED_CUMULATIVE_VOLUME_DELTA',
|
|
4
|
+
'AGGREGATED_FUNDING_RATE',
|
|
5
|
+
'AGGREGATED_OPEN_INTEREST',
|
|
6
|
+
'CUMULATIVE_VOLUME_DELTA',
|
|
7
|
+
// 2026-07-27 incident: excluded here (and from the recovery allowlist), a
|
|
8
|
+
// pan-back CVD_BY_SIZE hole was never scanned after the waves settled and
|
|
9
|
+
// rendered as a flat bridge; see INDICATOR_GAP_RECOVERY_ALLOWLIST.
|
|
10
|
+
'CVD_BY_SIZE',
|
|
11
|
+
// 2026-07-27 QA report, same chunks-missing class as CVD_BY_SIZE: pan-back
|
|
12
|
+
// CVD_FLOW_DOMINANCE holes were never scanned after the waves settled
|
|
13
|
+
// because the type was in neither self-heal set; see
|
|
14
|
+
// INDICATOR_GAP_RECOVERY_ALLOWLIST for the full rationale (including why it
|
|
15
|
+
// stays out of the render allowlist).
|
|
16
|
+
'CVD_FLOW_DOMINANCE',
|
|
17
|
+
'FUNDING_RATE',
|
|
18
|
+
'LONG_SHORT_RATIO',
|
|
19
|
+
'OPEN_INTEREST',
|
|
20
|
+
'ORDERBOOK_DEPTH',
|
|
21
|
+
'SECTOR_FUNDING_RATE',
|
|
22
|
+
'SECTOR_OPEN_INTEREST',
|
|
23
|
+
'VOLUME_DELTA',
|
|
24
|
+
]);
|
|
25
|
+
const GAP_THRESHOLD_MULTIPLIER = 1.5;
|
|
26
|
+
const VIEWPORT_REPAIR_PADDING_MULTIPLIER = 1;
|
|
27
|
+
const VIEWPORT_REPAIR_MIN_PADDING_BARS = 500;
|
|
28
|
+
export function isIndicatorGapRepairType(indicatorType) {
|
|
29
|
+
return !!indicatorType && INDICATOR_GAP_REPAIR_TYPES.has(indicatorType);
|
|
30
|
+
}
|
|
31
|
+
function uniqueSortedRowsInRange(rows, fromMs, toMs) {
|
|
32
|
+
if (!rows?.length)
|
|
33
|
+
return [];
|
|
34
|
+
const sorted = rows
|
|
35
|
+
.filter((row) => Array.isArray(row) && Number.isFinite(row[0]) && row[0] >= fromMs && row[0] <= toMs)
|
|
36
|
+
.sort((a, b) => a[0] - b[0]);
|
|
37
|
+
const unique = [];
|
|
38
|
+
let lastTs;
|
|
39
|
+
for (const row of sorted) {
|
|
40
|
+
if (row[0] === lastTs)
|
|
41
|
+
continue;
|
|
42
|
+
unique.push(row);
|
|
43
|
+
lastTs = row[0];
|
|
44
|
+
}
|
|
45
|
+
return unique;
|
|
46
|
+
}
|
|
47
|
+
function median(values) {
|
|
48
|
+
if (!values.length)
|
|
49
|
+
return undefined;
|
|
50
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
51
|
+
const middle = Math.floor(sorted.length / 2);
|
|
52
|
+
return sorted.length % 2 === 0 ? (sorted[middle - 1] + sorted[middle]) / 2 : sorted[middle];
|
|
53
|
+
}
|
|
54
|
+
function hasMainBarsBetween(mainRows, fromMs, toMs) {
|
|
55
|
+
return mainRows.some((row) => row[0] > fromMs && row[0] < toMs);
|
|
56
|
+
}
|
|
57
|
+
function pushGap(gaps, mainRows, fromMs, toMs, thresholdMs) {
|
|
58
|
+
if (toMs - fromMs <= thresholdMs)
|
|
59
|
+
return;
|
|
60
|
+
if (!hasMainBarsBetween(mainRows, fromMs, toMs))
|
|
61
|
+
return;
|
|
62
|
+
gaps.push({ fromMs, toMs });
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Find indicator holes that are inconsistent with both the loaded main series
|
|
66
|
+
* and the indicator's own cadence. Funding-like indicators can naturally be
|
|
67
|
+
* sparse on a 1h chart, so the threshold is based on the overlay median delta
|
|
68
|
+
* when enough rows exist, with the chart interval as the fallback.
|
|
69
|
+
*/
|
|
70
|
+
export function findIndicatorDataGaps(indicatorRows, mainRows, intervalMs) {
|
|
71
|
+
if (!mainRows?.length || mainRows.length < 2 || intervalMs <= 0)
|
|
72
|
+
return [];
|
|
73
|
+
const sortedMainRows = uniqueSortedRowsInRange(mainRows, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY);
|
|
74
|
+
if (sortedMainRows.length < 2)
|
|
75
|
+
return [];
|
|
76
|
+
const mainStartMs = sortedMainRows[0][0];
|
|
77
|
+
const mainEndMs = sortedMainRows[sortedMainRows.length - 1][0];
|
|
78
|
+
if (mainEndMs <= mainStartMs)
|
|
79
|
+
return [];
|
|
80
|
+
const sortedIndicatorRows = uniqueSortedRowsInRange(indicatorRows, mainStartMs, mainEndMs);
|
|
81
|
+
if (sortedIndicatorRows.length === 0) {
|
|
82
|
+
return [{ fromMs: mainStartMs, toMs: mainEndMs }];
|
|
83
|
+
}
|
|
84
|
+
const deltas = [];
|
|
85
|
+
for (let i = 1; i < sortedIndicatorRows.length; i++) {
|
|
86
|
+
const delta = sortedIndicatorRows[i][0] - sortedIndicatorRows[i - 1][0];
|
|
87
|
+
if (delta > 0)
|
|
88
|
+
deltas.push(delta);
|
|
89
|
+
}
|
|
90
|
+
const medianDelta = median(deltas);
|
|
91
|
+
const cadenceMs = Math.max(intervalMs, medianDelta ?? intervalMs);
|
|
92
|
+
const thresholdMs = cadenceMs * GAP_THRESHOLD_MULTIPLIER;
|
|
93
|
+
const gaps = [];
|
|
94
|
+
pushGap(gaps, sortedMainRows, mainStartMs, sortedIndicatorRows[0][0], thresholdMs);
|
|
95
|
+
for (let i = 1; i < sortedIndicatorRows.length; i++) {
|
|
96
|
+
pushGap(gaps, sortedMainRows, sortedIndicatorRows[i - 1][0], sortedIndicatorRows[i][0], thresholdMs);
|
|
97
|
+
}
|
|
98
|
+
pushGap(gaps, sortedMainRows, sortedIndicatorRows[sortedIndicatorRows.length - 1][0], mainEndMs, thresholdMs);
|
|
99
|
+
return gaps;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Range-independent half of the covered-repair verdict: the series-sized
|
|
103
|
+
* sorts and the detector run happen ONCE per (overlayRows, mainRows)
|
|
104
|
+
* snapshot; `coveredRepairRangeVouched` then answers per range in O(gaps).
|
|
105
|
+
* Returns null whenever the detector cannot judge (the guard's fail-open
|
|
106
|
+
* classes), so callers fail open exactly as before.
|
|
107
|
+
*/
|
|
108
|
+
export function prepareCoveredRepairRangeVerdict(input) {
|
|
109
|
+
const { overlayRows, mainRows, intervalMs } = input;
|
|
110
|
+
if (!(intervalMs > 0))
|
|
111
|
+
return null;
|
|
112
|
+
if (!overlayRows?.length)
|
|
113
|
+
return null;
|
|
114
|
+
if (!mainRows || mainRows.length < 2)
|
|
115
|
+
return null;
|
|
116
|
+
const mainFirstTs = mainRows[0]?.[0];
|
|
117
|
+
const mainLastTs = mainRows[mainRows.length - 1]?.[0];
|
|
118
|
+
if (!Number.isFinite(mainFirstTs) || !Number.isFinite(mainLastTs))
|
|
119
|
+
return null;
|
|
120
|
+
if (uniqueSortedRowsInRange(overlayRows, mainFirstTs, mainLastTs).length < MIN_ROWS_FOR_MEDIAN)
|
|
121
|
+
return null;
|
|
122
|
+
return {
|
|
123
|
+
mainFirstTs: mainFirstTs,
|
|
124
|
+
mainLastTs: mainLastTs,
|
|
125
|
+
gaps: findIndicatorDataGaps(overlayRows, mainRows, intervalMs),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Per-range half: bounds inside the judged main span AND no detected gap
|
|
130
|
+
* intersecting. A range reaching outside the loaded main span fails open
|
|
131
|
+
* (a cluster-scan history extension wants rows the chart does not hold yet)
|
|
132
|
+
* UNLESS `clampToMainSpan`: an overlay whose apply keeps only rows with a
|
|
133
|
+
* main bar (the reconcile coverage class `depth`) can never be covered
|
|
134
|
+
* outside the main span, so the judged range is cut to it and the part
|
|
135
|
+
* outside counts as served by construction. Without the clamp the
|
|
136
|
+
* planner's bucket-floored head chunk (2026-09-18 dump: 143 bars older than
|
|
137
|
+
* the chart's first candle) was re-bought and re-committed on every
|
|
138
|
+
* gap-recovery round until the attempt cap, each commit repainting the pane.
|
|
139
|
+
*/
|
|
140
|
+
export function coveredRepairRangeVouched(prep, fromSec, periodSec, options = {}) {
|
|
141
|
+
if (!(fromSec > 0) || !(periodSec > 0))
|
|
142
|
+
return false;
|
|
143
|
+
let fromMs = fromSec * 1000;
|
|
144
|
+
let toMs = (fromSec + periodSec) * 1000;
|
|
145
|
+
if (options.clampToMainSpan === true) {
|
|
146
|
+
fromMs = Math.max(fromMs, prep.mainFirstTs);
|
|
147
|
+
toMs = Math.min(toMs, prep.mainLastTs);
|
|
148
|
+
if (fromMs >= toMs)
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
if (fromMs < prep.mainFirstTs || toMs > prep.mainLastTs)
|
|
152
|
+
return false;
|
|
153
|
+
return !prep.gaps.some((gap) => gap.fromMs < toMs && gap.toMs > fromMs);
|
|
154
|
+
}
|
|
155
|
+
export function shouldSkipCoveredRepairRangeFetch(input) {
|
|
156
|
+
const prep = prepareCoveredRepairRangeVerdict(input);
|
|
157
|
+
if (!prep)
|
|
158
|
+
return false;
|
|
159
|
+
return coveredRepairRangeVouched(prep, input.fromSec, input.periodSec, { clampToMainSpan: input.clampToMainSpan });
|
|
160
|
+
}
|
|
161
|
+
export function clampIndicatorGapToViewportCushion(gap, viewportStartMs, viewportEndMs, intervalMs) {
|
|
162
|
+
if (!Number.isFinite(gap.fromMs) ||
|
|
163
|
+
!Number.isFinite(gap.toMs) ||
|
|
164
|
+
!Number.isFinite(viewportStartMs) ||
|
|
165
|
+
!Number.isFinite(viewportEndMs) ||
|
|
166
|
+
!Number.isFinite(intervalMs) ||
|
|
167
|
+
gap.fromMs >= gap.toMs ||
|
|
168
|
+
viewportStartMs >= viewportEndMs ||
|
|
169
|
+
intervalMs <= 0) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
const viewportSpanMs = viewportEndMs - viewportStartMs;
|
|
173
|
+
const paddingMs = Math.max(viewportSpanMs * VIEWPORT_REPAIR_PADDING_MULTIPLIER, intervalMs * VIEWPORT_REPAIR_MIN_PADDING_BARS);
|
|
174
|
+
const fromMs = Math.max(gap.fromMs, viewportStartMs - paddingMs);
|
|
175
|
+
const toMs = Math.min(gap.toMs, viewportEndMs + paddingMs);
|
|
176
|
+
return fromMs < toMs ? { fromMs, toMs } : null;
|
|
177
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type IndicatorInflightProfile = 'protected' | 'plain';
|
|
2
|
+
export interface IndicatorInflightRange {
|
|
3
|
+
startMs: number;
|
|
4
|
+
endMs: number;
|
|
5
|
+
}
|
|
6
|
+
export type IndicatorInflightRunner = (range: IndicatorInflightRange) => Promise<unknown> | unknown;
|
|
7
|
+
export type IndicatorInflightScheduleStatus = 'ignored-invalid' | 'scheduled' | 'updated-pending' | 'started-max-defer' | 'covered-by-inflight' | 'queued-after-inflight';
|
|
8
|
+
export interface IndicatorInflightScheduleResult {
|
|
9
|
+
key: string;
|
|
10
|
+
status: IndicatorInflightScheduleStatus;
|
|
11
|
+
range: IndicatorInflightRange;
|
|
12
|
+
inFlightRange?: IndicatorInflightRange;
|
|
13
|
+
/** Settles when this request's range has been covered (see module doc). */
|
|
14
|
+
completion: Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export interface IndicatorInflightScheduleOptions {
|
|
17
|
+
profile?: IndicatorInflightProfile;
|
|
18
|
+
settleMs?: number;
|
|
19
|
+
maxDeferMs?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare function __setIndicatorInflightClockForTests(fn: (() => number) | null): void;
|
|
22
|
+
export declare function scheduleIndicatorInflightFetch(chartIndex: number, overlayId: string, range: IndicatorInflightRange, runner: IndicatorInflightRunner, options?: IndicatorInflightScheduleOptions): IndicatorInflightScheduleResult;
|
|
23
|
+
export declare function hasPendingIndicatorInflight(chartIndex?: number, profile?: IndicatorInflightProfile): boolean;
|
|
24
|
+
export declare function clearIndicatorInflight(chartIndex: number, overlayId?: string, profile?: IndicatorInflightProfile): void;
|
|
25
|
+
export declare function clearAllIndicatorInflight(profile?: IndicatorInflightProfile): void;
|
|
26
|
+
export declare function __getPendingIndicatorInflightCountForTests(profile?: IndicatorInflightProfile): number;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ONE in-flight range registry for indicator history fetches (fan-out
|
|
3
|
+
* unification P2). The mechanism is the protected kScript lazy-refetch
|
|
4
|
+
* scheduler's, generalized: per-overlay single flight with settle/max-defer
|
|
5
|
+
* timers, union-not-replace coalescing, covered-by-inflight dedupe, and
|
|
6
|
+
* re-arm when a completed run does not contain the ranges queued behind it.
|
|
7
|
+
* protected-kscript-lazy-refetch.util.ts remains as a thin profile shim so
|
|
8
|
+
* its status golden and its call sites are unchanged.
|
|
9
|
+
*
|
|
10
|
+
* Profiles:
|
|
11
|
+
* - 'protected': settle 600 / max-defer 3000 (unchanged timing); entries
|
|
12
|
+
* participate in chart load-phase tracking (boot spinners wait on them).
|
|
13
|
+
* - 'plain': settle 0 / max-defer 0, i.e. the runner starts immediately when
|
|
14
|
+
* the overlay is idle; the registry only removes concurrent same-overlay
|
|
15
|
+
* duplicates. Plain entries are INVISIBLE to load-phase tracking.
|
|
16
|
+
*
|
|
17
|
+
* Completion: schedule() also returns a promise that settles when the
|
|
18
|
+
* requested range has been covered by a finished run (the current one for
|
|
19
|
+
* covered-by-inflight, the re-armed union run for queued work). It RESOLVES
|
|
20
|
+
* even when the runner throws (the fetch paths own their error handling and
|
|
21
|
+
* diagnostics; callers that need error visibility keep it inside their
|
|
22
|
+
* runner) and when the entry is cleared, so pacing awaits can never hang on
|
|
23
|
+
* teardown.
|
|
24
|
+
*
|
|
25
|
+
* Coalescing must UNION, not replace: two producers share one overlay key
|
|
26
|
+
* (the lazy wave requests the full loaded span; gap repair requests a narrow
|
|
27
|
+
* missing range), and replacing would let the later narrow request shrink a
|
|
28
|
+
* pending full-span recompute. A covering span is always a valid protected
|
|
29
|
+
* request — the server computes supersets safely, never subsets.
|
|
30
|
+
*/
|
|
31
|
+
import { notifyChartLoadPhaseInputChanged } from './chart-load-phase.util.js';
|
|
32
|
+
const PROFILE_DEFAULTS = {
|
|
33
|
+
protected: { settleMs: 600, maxDeferMs: 3000 },
|
|
34
|
+
plain: { settleMs: 0, maxDeferMs: 0 },
|
|
35
|
+
};
|
|
36
|
+
function createDeferred() {
|
|
37
|
+
let resolve;
|
|
38
|
+
const promise = new Promise((res) => {
|
|
39
|
+
resolve = res;
|
|
40
|
+
});
|
|
41
|
+
return { promise, resolve };
|
|
42
|
+
}
|
|
43
|
+
const entriesByKey = new Map();
|
|
44
|
+
let nowFn = () => Date.now();
|
|
45
|
+
export function __setIndicatorInflightClockForTests(fn) {
|
|
46
|
+
nowFn = fn ?? (() => Date.now());
|
|
47
|
+
}
|
|
48
|
+
function indicatorInflightKey(chartIndex, overlayId) {
|
|
49
|
+
return `${chartIndex}:${overlayId}`;
|
|
50
|
+
}
|
|
51
|
+
function cloneRange(range) {
|
|
52
|
+
return { startMs: range.startMs, endMs: range.endMs };
|
|
53
|
+
}
|
|
54
|
+
function isValidRange(range) {
|
|
55
|
+
return Number.isFinite(range.startMs) && Number.isFinite(range.endMs) && range.startMs < range.endMs;
|
|
56
|
+
}
|
|
57
|
+
function containsRange(outer, inner) {
|
|
58
|
+
return outer.startMs <= inner.startMs && outer.endMs >= inner.endMs;
|
|
59
|
+
}
|
|
60
|
+
function unionRange(a, b) {
|
|
61
|
+
if (!a)
|
|
62
|
+
return cloneRange(b);
|
|
63
|
+
return { startMs: Math.min(a.startMs, b.startMs), endMs: Math.max(a.endMs, b.endMs) };
|
|
64
|
+
}
|
|
65
|
+
function clearEntryTimer(entry) {
|
|
66
|
+
if (entry.timer !== null) {
|
|
67
|
+
clearTimeout(entry.timer);
|
|
68
|
+
entry.timer = null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Load-phase tracking watches protected entries only (boot spinners). */
|
|
72
|
+
function notifyEntryChanged(entry) {
|
|
73
|
+
if (entry.profile === 'protected') {
|
|
74
|
+
notifyChartLoadPhaseInputChanged(entry.chartIndex);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function resolveEntryDeferreds(entry) {
|
|
78
|
+
entry.inFlightDeferred?.resolve();
|
|
79
|
+
entry.inFlightDeferred = undefined;
|
|
80
|
+
entry.desiredDeferred?.resolve();
|
|
81
|
+
entry.desiredDeferred = undefined;
|
|
82
|
+
}
|
|
83
|
+
function startEntry(entry) {
|
|
84
|
+
clearEntryTimer(entry);
|
|
85
|
+
const range = entry.desiredRange;
|
|
86
|
+
if (!range || entry.inFlightRange)
|
|
87
|
+
return;
|
|
88
|
+
entry.desiredRange = undefined;
|
|
89
|
+
entry.inFlightRange = cloneRange(range);
|
|
90
|
+
entry.inFlightDeferred = entry.desiredDeferred;
|
|
91
|
+
entry.desiredDeferred = undefined;
|
|
92
|
+
notifyEntryChanged(entry);
|
|
93
|
+
void Promise.resolve()
|
|
94
|
+
.then(() => entry.runner(cloneRange(range)))
|
|
95
|
+
.catch(() => {
|
|
96
|
+
// The fetch paths already own user-visible errors and retry
|
|
97
|
+
// diagnostics. This registry only prevents the promise from becoming an
|
|
98
|
+
// unhandled rejection and lets future requests re-arm normally.
|
|
99
|
+
})
|
|
100
|
+
.finally(() => {
|
|
101
|
+
const completedDeferred = entry.inFlightDeferred;
|
|
102
|
+
if (entriesByKey.get(entry.key) !== entry) {
|
|
103
|
+
// Replaced or cleared mid-flight; the clear already resolved (or a
|
|
104
|
+
// replacement owns) the other deferreds, but this run's awaiters must
|
|
105
|
+
// never hang.
|
|
106
|
+
completedDeferred?.resolve();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const completedRange = entry.inFlightRange;
|
|
110
|
+
entry.inFlightRange = undefined;
|
|
111
|
+
entry.inFlightDeferred = undefined;
|
|
112
|
+
const desiredRange = entry.desiredRange;
|
|
113
|
+
if (completedRange && desiredRange && !containsRange(completedRange, desiredRange)) {
|
|
114
|
+
completedDeferred?.resolve();
|
|
115
|
+
entry.firstDeferredAt = nowFn();
|
|
116
|
+
armEntryTimer(entry, entry.settleMs);
|
|
117
|
+
notifyEntryChanged(entry);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
// Drained (any queued range was contained in the completed run, so its
|
|
121
|
+
// awaiters are covered too).
|
|
122
|
+
entriesByKey.delete(entry.key);
|
|
123
|
+
completedDeferred?.resolve();
|
|
124
|
+
resolveEntryDeferreds(entry);
|
|
125
|
+
notifyEntryChanged(entry);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function armEntryTimer(entry, delayMs) {
|
|
129
|
+
clearEntryTimer(entry);
|
|
130
|
+
entry.timer = setTimeout(() => startEntry(entry), Math.max(0, delayMs));
|
|
131
|
+
}
|
|
132
|
+
export function scheduleIndicatorInflightFetch(chartIndex, overlayId, range, runner, options = {}) {
|
|
133
|
+
const key = indicatorInflightKey(chartIndex, overlayId);
|
|
134
|
+
const normalizedRange = cloneRange(range);
|
|
135
|
+
if (!isValidRange(normalizedRange)) {
|
|
136
|
+
return { key, status: 'ignored-invalid', range: normalizedRange, completion: Promise.resolve() };
|
|
137
|
+
}
|
|
138
|
+
const profile = options.profile ?? 'protected';
|
|
139
|
+
const defaults = PROFILE_DEFAULTS[profile];
|
|
140
|
+
const settleMs = Math.max(0, options.settleMs ?? defaults.settleMs);
|
|
141
|
+
const maxDeferMs = Math.max(settleMs, options.maxDeferMs ?? defaults.maxDeferMs);
|
|
142
|
+
let entry = entriesByKey.get(key);
|
|
143
|
+
const hadEntry = Boolean(entry);
|
|
144
|
+
if (!entry) {
|
|
145
|
+
entry = {
|
|
146
|
+
key,
|
|
147
|
+
chartIndex,
|
|
148
|
+
overlayId,
|
|
149
|
+
profile,
|
|
150
|
+
desiredRange: normalizedRange,
|
|
151
|
+
runner,
|
|
152
|
+
timer: null,
|
|
153
|
+
firstDeferredAt: nowFn(),
|
|
154
|
+
settleMs,
|
|
155
|
+
maxDeferMs,
|
|
156
|
+
};
|
|
157
|
+
entriesByKey.set(key, entry);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
entry.runner = runner;
|
|
161
|
+
entry.profile = profile;
|
|
162
|
+
entry.settleMs = settleMs;
|
|
163
|
+
entry.maxDeferMs = maxDeferMs;
|
|
164
|
+
}
|
|
165
|
+
if (entry.inFlightRange) {
|
|
166
|
+
if (containsRange(entry.inFlightRange, normalizedRange)) {
|
|
167
|
+
return {
|
|
168
|
+
key,
|
|
169
|
+
status: 'covered-by-inflight',
|
|
170
|
+
range: normalizedRange,
|
|
171
|
+
inFlightRange: cloneRange(entry.inFlightRange),
|
|
172
|
+
completion: (entry.inFlightDeferred ??= createDeferred()).promise,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
entry.desiredRange = unionRange(entry.desiredRange, normalizedRange);
|
|
176
|
+
entry.desiredDeferred ??= createDeferred();
|
|
177
|
+
notifyEntryChanged(entry);
|
|
178
|
+
return {
|
|
179
|
+
key,
|
|
180
|
+
status: 'queued-after-inflight',
|
|
181
|
+
range: cloneRange(entry.desiredRange),
|
|
182
|
+
inFlightRange: cloneRange(entry.inFlightRange),
|
|
183
|
+
completion: entry.desiredDeferred.promise,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
const status = hadEntry ? 'updated-pending' : 'scheduled';
|
|
187
|
+
entry.desiredRange = unionRange(entry.desiredRange, normalizedRange);
|
|
188
|
+
entry.desiredDeferred ??= createDeferred();
|
|
189
|
+
const completion = entry.desiredDeferred.promise;
|
|
190
|
+
if (!entry.timer) {
|
|
191
|
+
entry.firstDeferredAt = nowFn();
|
|
192
|
+
}
|
|
193
|
+
if (nowFn() - entry.firstDeferredAt >= entry.maxDeferMs) {
|
|
194
|
+
startEntry(entry);
|
|
195
|
+
return { key, status: 'started-max-defer', range: normalizedRange, completion };
|
|
196
|
+
}
|
|
197
|
+
armEntryTimer(entry, entry.settleMs);
|
|
198
|
+
notifyEntryChanged(entry);
|
|
199
|
+
return { key, status, range: normalizedRange, completion };
|
|
200
|
+
}
|
|
201
|
+
export function hasPendingIndicatorInflight(chartIndex, profile) {
|
|
202
|
+
for (const entry of entriesByKey.values()) {
|
|
203
|
+
if (chartIndex !== undefined && entry.chartIndex !== chartIndex)
|
|
204
|
+
continue;
|
|
205
|
+
if (profile !== undefined && entry.profile !== profile)
|
|
206
|
+
continue;
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
export function clearIndicatorInflight(chartIndex, overlayId, profile) {
|
|
212
|
+
const notifyChartIndexes = new Set();
|
|
213
|
+
for (const [key, entry] of entriesByKey) {
|
|
214
|
+
if (entry.chartIndex !== chartIndex)
|
|
215
|
+
continue;
|
|
216
|
+
if (overlayId !== undefined && entry.overlayId !== overlayId)
|
|
217
|
+
continue;
|
|
218
|
+
if (profile !== undefined && entry.profile !== profile)
|
|
219
|
+
continue;
|
|
220
|
+
clearEntryTimer(entry);
|
|
221
|
+
entriesByKey.delete(key);
|
|
222
|
+
resolveEntryDeferreds(entry);
|
|
223
|
+
if (entry.profile === 'protected')
|
|
224
|
+
notifyChartIndexes.add(entry.chartIndex);
|
|
225
|
+
}
|
|
226
|
+
for (const notifyChartIndex of notifyChartIndexes) {
|
|
227
|
+
notifyChartLoadPhaseInputChanged(notifyChartIndex);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
export function clearAllIndicatorInflight(profile) {
|
|
231
|
+
const notifyChartIndexes = new Set();
|
|
232
|
+
for (const [key, entry] of entriesByKey) {
|
|
233
|
+
if (profile !== undefined && entry.profile !== profile)
|
|
234
|
+
continue;
|
|
235
|
+
clearEntryTimer(entry);
|
|
236
|
+
entriesByKey.delete(key);
|
|
237
|
+
resolveEntryDeferreds(entry);
|
|
238
|
+
if (entry.profile === 'protected')
|
|
239
|
+
notifyChartIndexes.add(entry.chartIndex);
|
|
240
|
+
}
|
|
241
|
+
for (const notifyChartIndex of notifyChartIndexes) {
|
|
242
|
+
notifyChartLoadPhaseInputChanged(notifyChartIndex);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
export function __getPendingIndicatorInflightCountForTests(profile) {
|
|
246
|
+
if (profile === undefined)
|
|
247
|
+
return entriesByKey.size;
|
|
248
|
+
let count = 0;
|
|
249
|
+
for (const entry of entriesByKey.values()) {
|
|
250
|
+
if (entry.profile === profile)
|
|
251
|
+
count++;
|
|
252
|
+
}
|
|
253
|
+
return count;
|
|
254
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one resolver between chart interval labels, their wire enum
|
|
3
|
+
* (`AggregationInterval`) and their millisecond length. Pure and worker-safe.
|
|
4
|
+
*
|
|
5
|
+
* Standard and custom labels each map to their own wire interval, so a chart
|
|
6
|
+
* requests exactly the interval it shows. The custom labels (the closed
|
|
7
|
+
* `CUSTOM_INTERVALS` set) are served by the gateway rolling up a finer
|
|
8
|
+
* materialized tier (tsdb-gateway !2146-!2149) and go out like any standard
|
|
9
|
+
* label, with no sentinel. An unmapped label falls back to MINUTE
|
|
10
|
+
* (`grpcIntervalOf`), so a label missing here would paint 1m candles.
|
|
11
|
+
*/
|
|
12
|
+
import { AggregationInterval } from '@orangecharts/orange-v2-pb-common';
|
|
13
|
+
export { CUSTOM_INTERVALS, EXTENDED_INTERVALS, intervalLabelForMs, intervalMs, isCustomInterval, isExtendedInterval, standardIntervalAtOrBelow, standardIntervalMsAtOrBelow, type CustomInterval, type ExtendedInterval, } from './interval-ladder.util.js';
|
|
14
|
+
/** The wire interval for a standard or custom label, `undefined` for anything else. */
|
|
15
|
+
export declare function lookupGrpcInterval(label: unknown): AggregationInterval | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* `lookupGrpcInterval` with MINUTE for a missing label: worker payloads that
|
|
18
|
+
* legitimately omit their tf keep the default they always had. An unknown
|
|
19
|
+
* label string warns once, so the fallback is visible.
|
|
20
|
+
*/
|
|
21
|
+
export declare function grpcIntervalOf(label: unknown): AggregationInterval;
|
|
22
|
+
/** True for the rungs shorter than a minute (1s 5s 15s 30s): one Plus gate, one venue rule, served where 1s is. */
|
|
23
|
+
export declare function isSubMinuteInterval(label: unknown): boolean;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one resolver between chart interval labels, their wire enum
|
|
3
|
+
* (`AggregationInterval`) and their millisecond length. Pure and worker-safe.
|
|
4
|
+
*
|
|
5
|
+
* Standard and custom labels each map to their own wire interval, so a chart
|
|
6
|
+
* requests exactly the interval it shows. The custom labels (the closed
|
|
7
|
+
* `CUSTOM_INTERVALS` set) are served by the gateway rolling up a finer
|
|
8
|
+
* materialized tier (tsdb-gateway !2146-!2149) and go out like any standard
|
|
9
|
+
* label, with no sentinel. An unmapped label falls back to MINUTE
|
|
10
|
+
* (`grpcIntervalOf`), so a label missing here would paint 1m candles.
|
|
11
|
+
*/
|
|
12
|
+
import { AggregationInterval } from '@orangecharts/orange-v2-pb-common';
|
|
13
|
+
import { intervalMs } from './interval-ladder.util.js';
|
|
14
|
+
// The label half (the labels, their lengths and the tuning ladder) is the pure leaf's (interval-ladder.util); its
|
|
15
|
+
// importers keep this path.
|
|
16
|
+
export { CUSTOM_INTERVALS, EXTENDED_INTERVALS, intervalLabelForMs, intervalMs, isCustomInterval, isExtendedInterval, standardIntervalAtOrBelow, standardIntervalMsAtOrBelow, } from './interval-ladder.util.js';
|
|
17
|
+
// Every label's wire interval, keyed by the leaf's label unions: a label the leaf declares without a wire interval
|
|
18
|
+
// here (or one here the leaf does not declare) fails the compile. The classic ladder first, then the custom presets
|
|
19
|
+
// and the extended rungs, each in the leaf's order (the reversed length map reads the labels in this order).
|
|
20
|
+
const STANDARD_INTERVAL_WIRE = {
|
|
21
|
+
'1m': AggregationInterval.MINUTE,
|
|
22
|
+
'5m': AggregationInterval.FIVE_MINUTES,
|
|
23
|
+
'15m': AggregationInterval.FIFTEEN_MINUTES,
|
|
24
|
+
'1h': AggregationInterval.HOUR,
|
|
25
|
+
'4h': AggregationInterval.FOUR_HOURS,
|
|
26
|
+
'1d': AggregationInterval.DAY,
|
|
27
|
+
'1w': AggregationInterval.WEEK,
|
|
28
|
+
'1s': AggregationInterval.SECOND,
|
|
29
|
+
'30m': AggregationInterval.THIRTY_MINUTES,
|
|
30
|
+
'1M': AggregationInterval.MONTH,
|
|
31
|
+
'3M': AggregationInterval.QUARTER_YEAR,
|
|
32
|
+
'1Y': AggregationInterval.YEAR,
|
|
33
|
+
};
|
|
34
|
+
const CUSTOM_INTERVAL_WIRE = {
|
|
35
|
+
'2m': AggregationInterval.TWO_MINUTES,
|
|
36
|
+
'3m': AggregationInterval.THREE_MINUTES,
|
|
37
|
+
'10m': AggregationInterval.TEN_MINUTES,
|
|
38
|
+
'45m': AggregationInterval.FORTY_FIVE_MINUTES,
|
|
39
|
+
'2h': AggregationInterval.TWO_HOURS,
|
|
40
|
+
'6h': AggregationInterval.SIX_HOURS,
|
|
41
|
+
'8h': AggregationInterval.EIGHT_HOURS,
|
|
42
|
+
'12h': AggregationInterval.TWELVE_HOURS,
|
|
43
|
+
'3d': AggregationInterval.THREE_DAYS,
|
|
44
|
+
};
|
|
45
|
+
const EXTENDED_INTERVAL_WIRE = {
|
|
46
|
+
'5s': AggregationInterval.FIVE_SECONDS,
|
|
47
|
+
'15s': AggregationInterval.FIFTEEN_SECONDS,
|
|
48
|
+
'30s': AggregationInterval.THIRTY_SECONDS,
|
|
49
|
+
'6M': AggregationInterval.HALF_YEAR,
|
|
50
|
+
};
|
|
51
|
+
const GRPC_INTERVAL_BY_LABEL = {
|
|
52
|
+
...STANDARD_INTERVAL_WIRE,
|
|
53
|
+
...CUSTOM_INTERVAL_WIRE,
|
|
54
|
+
...EXTENDED_INTERVAL_WIRE,
|
|
55
|
+
};
|
|
56
|
+
const hasOwn = (record, key) => Object.prototype.hasOwnProperty.call(record, key);
|
|
57
|
+
/** The wire interval for a standard or custom label, `undefined` for anything else. */
|
|
58
|
+
export function lookupGrpcInterval(label) {
|
|
59
|
+
if (typeof label !== 'string')
|
|
60
|
+
return undefined;
|
|
61
|
+
return hasOwn(GRPC_INTERVAL_BY_LABEL, label) ? GRPC_INTERVAL_BY_LABEL[label] : undefined;
|
|
62
|
+
}
|
|
63
|
+
const warnedUnknownLabels = new Set();
|
|
64
|
+
/**
|
|
65
|
+
* `lookupGrpcInterval` with MINUTE for a missing label: worker payloads that
|
|
66
|
+
* legitimately omit their tf keep the default they always had. An unknown
|
|
67
|
+
* label string warns once, so the fallback is visible.
|
|
68
|
+
*/
|
|
69
|
+
export function grpcIntervalOf(label) {
|
|
70
|
+
const interval = lookupGrpcInterval(label);
|
|
71
|
+
if (interval !== undefined)
|
|
72
|
+
return interval;
|
|
73
|
+
if (typeof label === 'string' && !warnedUnknownLabels.has(label)) {
|
|
74
|
+
warnedUnknownLabels.add(label);
|
|
75
|
+
console.warn(`[interval-registry] Unknown interval "${label}"; requesting 1m.`);
|
|
76
|
+
}
|
|
77
|
+
return AggregationInterval.MINUTE;
|
|
78
|
+
}
|
|
79
|
+
/** True for the rungs shorter than a minute (1s 5s 15s 30s): one Plus gate, one venue rule, served where 1s is. */
|
|
80
|
+
export function isSubMinuteInterval(label) {
|
|
81
|
+
const ms = intervalMs(label);
|
|
82
|
+
return ms !== undefined && lookupGrpcInterval(label) !== undefined && ms < 60_000;
|
|
83
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** The chart the stages read: its overlays (`metadata`), the main bars among them. A structural copy of
|
|
2
|
+
* kscript-drawings.util.ts `KScriptDrawingsChart` (the adapter's chart target extends it): that module loads a store,
|
|
3
|
+
* so this leaf may not import it, not even its types. */
|
|
4
|
+
type KScriptDrawingsChart = {
|
|
5
|
+
metadata?: unknown[];
|
|
6
|
+
updateDrawings?(overlayId: string, drawings: unknown[]): void;
|
|
7
|
+
getDrawingRenderSets?: () => unknown[];
|
|
8
|
+
};
|
|
9
|
+
declare function plotTypeOf(container: Record<string, unknown>): string | undefined;
|
|
10
|
+
declare function finiteRowTime(row: unknown): number | null;
|
|
11
|
+
declare function outputTreeHasMainIndexAlignedPlot(output: unknown, seen?: WeakSet<object>): boolean;
|
|
12
|
+
declare function mainChartMetaForKScript(tc: KScriptDrawingsChart): Record<string, unknown> | null;
|
|
13
|
+
declare function mainChartRowsForKScriptIndexAlignment(tc: KScriptDrawingsChart): unknown[];
|
|
14
|
+
declare function mainChartTimesForKScriptIndexAlignment(tc: KScriptDrawingsChart): number[];
|
|
15
|
+
declare function alignRowsToMainChartIndex(rows: unknown, mainTimes: number[], options?: {
|
|
16
|
+
force?: boolean;
|
|
17
|
+
}): unknown;
|
|
18
|
+
declare function shouldAlignOutputRowsToMainChartIndex(output: Record<string, unknown>): boolean;
|
|
19
|
+
declare function alignKScriptIndexDecoratorsToMainChart(runResult: unknown, tc: KScriptDrawingsChart): unknown;
|
|
20
|
+
declare function padContinuousKScriptOutputGapsOnMainGrid(runResult: unknown, tc: KScriptDrawingsChart): unknown;
|
|
21
|
+
export { alignKScriptIndexDecoratorsToMainChart, padContinuousKScriptOutputGapsOnMainGrid, alignRowsToMainChartIndex, finiteRowTime, mainChartMetaForKScript, mainChartRowsForKScriptIndexAlignment, mainChartTimesForKScriptIndexAlignment, outputTreeHasMainIndexAlignedPlot, plotTypeOf, shouldAlignOutputRowsToMainChartIndex, };
|