@orangecharts/wrun-chart-host 0.2.0 → 0.4.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 +22 -8
- 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/scriptEditor/builtin-script-snippets.d.ts +133 -0
- package/dist/constants/scriptEditor/builtin-script-snippets.js +451 -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 +163 -5
- package/dist/host-ports.types.d.ts +431 -0
- package/dist/host-ports.types.js +1 -0
- package/dist/index.d.ts +138 -0
- package/dist/index.js +138 -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/date-labelled-interval.leaf.d.ts +15 -0
- package/dist/utility/chart/date-labelled-interval.leaf.js +19 -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/indicator-run-interval.util.d.ts +130 -0
- package/dist/utility/chart/indicator-run-interval.util.js +268 -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/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/window-geometry.leaf.d.ts +119 -0
- package/dist/utility/chart/window-geometry.leaf.js +391 -0
- package/dist/utility/chart/window-owner.leaf.d.ts +19 -0
- package/dist/utility/chart/window-owner.leaf.js +24 -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-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/html-escape.leaf.d.ts +11 -0
- package/dist/utility/html-escape.leaf.js +20 -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 +58 -0
- package/dist/utility/wrun/sources/lanes/option_daily.js +111 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +27 -0
- package/dist/utility/wrun/sources/lanes/option_stats_10m.js +21 -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 +215 -0
- package/dist/utility/wrun/sources/opra-option-lanes.util.js +477 -0
- package/dist/utility/wrun/sources/registry.d.ts +21 -0
- package/dist/utility/wrun/sources/registry.js +237 -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 +55 -0
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +126 -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 +62 -0
- package/dist/utility/wrun/sources/row-lanes/option_strikes.js +147 -0
- package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +70 -0
- package/dist/utility/wrun/sources/row-lanes/option_surface.js +144 -0
- package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +309 -0
- package/dist/utility/wrun/sources/wrun-poll-lane.types.js +26 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +350 -0
- package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +576 -0
- package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +275 -0
- package/dist/utility/wrun/sources/wrun-row-lane.types.js +16 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +207 -0
- package/dist/utility/wrun/sources/wrun-row-lanes.util.js +450 -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-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-frames.d.ts +20 -1
- package/dist/utility/wrun/wrun-frames.js +103 -49
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +27 -0
- 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 +49 -0
- package/dist/utility/wrun/wrun-opra-stats.leaf.js +115 -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-panel-mount.lazy.d.ts +10 -0
- package/dist/utility/wrun/wrun-panel-mount.lazy.js +68 -0
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +377 -0
- package/dist/utility/wrun/wrun-panel-mount.util.js +2251 -0
- 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-pause-dim.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-pause-dim.util.js +153 -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-plot-gate.types.d.ts +23 -0
- package/dist/utility/wrun/wrun-plot-gate.types.js +7 -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 +41 -1
- package/dist/utility/wrun/wrun-refusal.util.js +69 -2
- 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-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-run-interval-projection.types.d.ts +14 -0
- package/dist/utility/wrun/wrun-run-interval-projection.types.js +1 -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-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,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cloud record of a registry Indicator across the lane line (WRUN-PARITY-PLAN U15, U16).
|
|
3
|
+
*
|
|
4
|
+
* A cloud Indicator is the registry record the browser lane mounts (the registry loader builds both
|
|
5
|
+
* through one mount, its rows through the browser lane's own `buildWrunScriptInputs` over the full
|
|
6
|
+
* sheet), with its row source chosen by one field: `wrunRunTarget: 'cloud'` selects the socket row
|
|
7
|
+
* source (wrun-row-source-factory.ts). No protected flag and no wire identity ride the record, so no
|
|
8
|
+
* protected-kScript branch ever reads it. This leaf holds the reads that still cross the line:
|
|
9
|
+
*
|
|
10
|
+
* - `wrunCloudRecordOf`, the migration on read: a record persisted for the protected pipeline before
|
|
11
|
+
* lane parity wave 3 (the protected flag and the wire identity `wrunRef`; a marketplace mount
|
|
12
|
+
* carries `wrunRef` alone) is read as the cloud record it is: the engine copy and the document row
|
|
13
|
+
* take that shape at its first read (the registry loader's `adoptWrunHostedRecord`). During the
|
|
14
|
+
* rollout the PERSISTED row keeps the protected flag, the capability slug and `wrunRef` beside
|
|
15
|
+
* that shape, so a build from before wave 3 (production while INT soaks, a revert) still runs it
|
|
16
|
+
* hosted: the egress projection (wrun-cloud-row-compat.util), removed once every deployment reads
|
|
17
|
+
* `wrunRunTarget`, whose inverse takes them off again where the store installs a document.
|
|
18
|
+
* - `wrunSocketPayloadSettings`, the payload view: the socket row source's default transport builds
|
|
19
|
+
* its createScript payload through the one protected payload builder (the technical-script
|
|
20
|
+
* control), which reads the wire identity and the protected discriminator off this view, never off
|
|
21
|
+
* the record.
|
|
22
|
+
* - `wrunCustomScriptSlug`, the capability's slug for a tuple.
|
|
23
|
+
* - `wrunSheetPositionOf`, the pane side a sheet declares (the registry loader's `packagePosition`
|
|
24
|
+
* read loosely), for a sheet the loader did not download (a persisted copy, a cloud batch's).
|
|
25
|
+
*
|
|
26
|
+
* A near-leaf (the identity leaf only), so the loader, the factory and the catalog read one
|
|
27
|
+
* definition.
|
|
28
|
+
*/
|
|
29
|
+
import { wrunRegistryRefOf, wrunRegistrySlugFor } from './wrun-overlay-identity.util.js';
|
|
30
|
+
/** `wrun-<package>-<version>` with every non-alphanumeric run collapsed to `-`,
|
|
31
|
+
* byte-identical to tharamine's wrunCustomScriptSlug. Lossy on purpose (the
|
|
32
|
+
* registry's publish door refuses colliding coordinates). */
|
|
33
|
+
export function wrunCustomScriptSlug(packageId, version) {
|
|
34
|
+
return `wrun-${`${packageId}-${version}`.replace(/[^a-zA-Z0-9]+/g, '-')}`;
|
|
35
|
+
}
|
|
36
|
+
function isRecord(value) {
|
|
37
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
38
|
+
}
|
|
39
|
+
function hasPackageName(ref) {
|
|
40
|
+
return isRecord(ref) && typeof ref.package === 'string' && ref.package !== '';
|
|
41
|
+
}
|
|
42
|
+
/** A sheet's chart placement, the registry loader's `packagePosition` read loosely (a record's persisted
|
|
43
|
+
* copy may be trimmed or malformed, a cloud batch's sheet is the cloud's): a declared `overlay` wins; a
|
|
44
|
+
* strategy homes on price; a plotted, non-inset output on the `overlay` panel homes on price; otherwise
|
|
45
|
+
* the primary output's panel decides. */
|
|
46
|
+
export function wrunSheetPositionOf(sheet) {
|
|
47
|
+
const read = sheet ?? {};
|
|
48
|
+
if (read.overlay === 'offchart')
|
|
49
|
+
return 'offchart';
|
|
50
|
+
if (read.overlay === 'onchart')
|
|
51
|
+
return 'onchart';
|
|
52
|
+
if (read.strategy !== undefined)
|
|
53
|
+
return 'onchart';
|
|
54
|
+
const outputs = Array.isArray(read.outputs)
|
|
55
|
+
? read.outputs
|
|
56
|
+
: [];
|
|
57
|
+
if (outputs.some((output) => output?.plot !== '' && output?.plot !== 'inset' && output?.panel === 'overlay')) {
|
|
58
|
+
return 'onchart';
|
|
59
|
+
}
|
|
60
|
+
return outputs[0]?.panel === 'lower' ? 'offchart' : 'onchart';
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A record persisted for the protected pipeline before lane parity wave 3, read as the cloud record
|
|
64
|
+
* it is (the migration on read): its wire identity becomes the registry identity (a marketplace mount
|
|
65
|
+
* carried none; one it carried stays, its pane side kept), the slug is the registry's, the row source
|
|
66
|
+
* the cloud's, and the protected flag goes. Every other key rides as persisted. The pane side is the
|
|
67
|
+
* one the record carried, else its persisted sheet's (wrunSheetPositionOf); a record with neither (a
|
|
68
|
+
* marketplace mount) leaves it undecided, so the control mounts it on the price pane and the first
|
|
69
|
+
* batch's delivered sheet decides it, instead of a side guessed here being persisted for good. What
|
|
70
|
+
* else a registry identity naming the same tuple carried (the source mode a mount with the version doc
|
|
71
|
+
* in hand stamped, read by wrunOverlayEditable) stays: a cloud row persisted during the rollout carries
|
|
72
|
+
* `wrunRef` too (wrun-cloud-row-compat.util), and one that reaches the chart past the store's entry (a
|
|
73
|
+
* collab add, a paste) is read here. Undefined for a record that carries no wire identity (nothing to
|
|
74
|
+
* read again).
|
|
75
|
+
*/
|
|
76
|
+
export function wrunCloudRecordOf(settings) {
|
|
77
|
+
if (!isRecord(settings))
|
|
78
|
+
return undefined;
|
|
79
|
+
const { isProtectedScript: _protected, wrunRef, ...record } = settings;
|
|
80
|
+
if (!hasPackageName(wrunRef))
|
|
81
|
+
return undefined;
|
|
82
|
+
const packageName = wrunRef.package;
|
|
83
|
+
const version = typeof wrunRef.version === 'string' ? wrunRef.version : '';
|
|
84
|
+
const kept = isRecord(record.wrunRegistryRef) ? record.wrunRegistryRef : undefined;
|
|
85
|
+
const position = kept?.position === 'onchart' || kept?.position === 'offchart'
|
|
86
|
+
? kept.position
|
|
87
|
+
: isRecord(record.wrunSheet)
|
|
88
|
+
? wrunSheetPositionOf(record.wrunSheet)
|
|
89
|
+
: undefined;
|
|
90
|
+
const facts = kept?.package === packageName && kept.version === version ? { ...kept } : {};
|
|
91
|
+
delete facts.position;
|
|
92
|
+
return {
|
|
93
|
+
...record,
|
|
94
|
+
customScriptId: wrunRegistrySlugFor(packageName, version),
|
|
95
|
+
wrunRegistryRef: { ...facts, package: packageName, version, ...(position ? { position } : {}) },
|
|
96
|
+
wrunRunTarget: 'cloud',
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The settings the protected payload builder reads for a cloud record (the socket row source's default
|
|
101
|
+
* transport builds the createScript payload through the technical-script control): the wire identity
|
|
102
|
+
* (`wrunRef`) and the capability's slug (wrunCustomScriptSlug, the `scriptId` tharamine binds the tuple
|
|
103
|
+
* to) from the registry identity, and the protected discriminator the builder keys its wire on. With
|
|
104
|
+
* the sheet the source runs, its params ride as `wrunSheet` too: the socket worker's session identity
|
|
105
|
+
* reads a param's `style` there (wrun-style-row-rule `wrunStyleTierSheetOf`, lane parity C6), so an om
|
|
106
|
+
* style knob stays paint-only on the cloud as in the browser. Never persisted, never written on the
|
|
107
|
+
* record. A record without a pinned registry identity passes through.
|
|
108
|
+
*/
|
|
109
|
+
export function wrunSocketPayloadSettings(settings, sheet) {
|
|
110
|
+
const ref = wrunRegistryRefOf(settings);
|
|
111
|
+
if (ref === undefined || ref.version === '')
|
|
112
|
+
return settings;
|
|
113
|
+
const tuple = { package: ref.package, version: ref.version };
|
|
114
|
+
return {
|
|
115
|
+
...settings,
|
|
116
|
+
isProtectedScript: true,
|
|
117
|
+
customScriptId: wrunCustomScriptSlug(tuple.package, tuple.version),
|
|
118
|
+
wrunRef: tuple,
|
|
119
|
+
...(Array.isArray(sheet?.params) ? { wrunSheet: { params: sheet.params } } : {}),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export declare const WRUN_DAILY_LANE_DAY_MS: any;
|
|
2
|
+
/** The lane's own interval on every chart (an `Intervals.map_unit` key). */
|
|
3
|
+
export declare const WRUN_DAILY_LANE_INTERVAL_KEY = "1d";
|
|
4
|
+
/** What a chart bar reads off the day rows: see the module doc. */
|
|
5
|
+
export type WrunDailyLanding = 'sum' | 'last';
|
|
6
|
+
/** The UTC day (midnight, ms) a ts belongs to. */
|
|
7
|
+
export declare function wrunDailyLaneDayStart(ts: number): number;
|
|
8
|
+
/**
|
|
9
|
+
* The raw observation a daily column brings to the chart row opening at `ts` on a grid of
|
|
10
|
+
* `intervalMs`, off the lane rows indexed by day (`byDay` maps a day start to its row).
|
|
11
|
+
* Intraday or daily grid, either landing: the day's value on the first bar of its day only (a
|
|
12
|
+
* later bar of the day reads NaN, for the input's `missing` policy to fill): the bar opening
|
|
13
|
+
* inside the day's first interval, or the one whose predecessor on the chart (`previousBarTs`)
|
|
14
|
+
* belongs to an earlier day (see the module doc). A grid coarser than a day: `sum` adds the
|
|
15
|
+
* days that open inside the bar, `last` reads the newest of them that reported; NaN when none
|
|
16
|
+
* did. The bar's days end where the next chart bar opens (`nextBarTs`), else at its calendar
|
|
17
|
+
* end (`candleBarEndMs`), so a month bar holds its own month and nothing of the next.
|
|
18
|
+
*/
|
|
19
|
+
export declare function wrunDailyLaneObservation(byDay: ReadonlyMap<number, ArrayLike<number>>, column: number, ts: number, intervalMs: number, landing: WrunDailyLanding, previousBarTs?: number, nextBarTs?: number, nowMs?: number): number;
|
|
20
|
+
/**
|
|
21
|
+
* The newest finite value of a daily column at or before the chart row opening at `ts` (its
|
|
22
|
+
* own day on an intraday or daily grid, its last day on a coarser one: the day before the next
|
|
23
|
+
* chart bar opens, `nextBarTs`, else before its calendar end, `candleBarEndMs`), off the lane's
|
|
24
|
+
* FULL rows (ascending): what a `last` landing reads under the `carry` policy on a bar that
|
|
25
|
+
* brings no observation of its own. NaN when no row at or before that day reported the column.
|
|
26
|
+
* A binary search to the day, then back over the rows that did not report the column.
|
|
27
|
+
*/
|
|
28
|
+
export declare function wrunDailyLaneAsOf(rows: ReadonlyArray<ArrayLike<number>>, column: number, ts: number, intervalMs: number, nextBarTs?: number, nowMs?: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* What a daily column offers the chart row opening at `ts` BEFORE the input's `missing` policy
|
|
31
|
+
* is applied: the row's own observation (`wrunDailyLaneObservation` over `byDay`, the window's
|
|
32
|
+
* day index) and, for a `last` landing whose input rides the `carry` policy (`carries`), the
|
|
33
|
+
* newest value at or before the row when it brings none of its own (`wrunDailyLaneAsOf` over
|
|
34
|
+
* `rows`, the lane's full rows). A `sum` landing and the `nan` / `zero` policies read the own
|
|
35
|
+
* observation alone. A pure function of the rows, the bar, its neighbors on the chart
|
|
36
|
+
* (`previousBarTs`, `nextBarTs`) and the build's clock (`nowMs`, the forming bar's reach), so a
|
|
37
|
+
* tail build reads what the full build read.
|
|
38
|
+
*/
|
|
39
|
+
export declare function wrunDailyLaneRead(byDay: ReadonlyMap<number, ArrayLike<number>>, rows: ReadonlyArray<ArrayLike<number>>, column: number, ts: number, intervalMs: number, landing: WrunDailyLanding, carries: boolean, previousBarTs?: number, nextBarTs?: number, nowMs?: number): number;
|
|
40
|
+
/**
|
|
41
|
+
* Whether two versions of a daily lane's rows stand the same at the head of a window whose
|
|
42
|
+
* first day is `firstDayTs`: for every column, the newest finite value BEFORE that day is the
|
|
43
|
+
* same in both. That value is all a session reads of the rows older than its window
|
|
44
|
+
* (`wrunDailyLaneAsOf` hands it to a `last` landing's bars under `carry` until a day of the
|
|
45
|
+
* window reports); a change among the rows behind it reaches no bar. `same` is the caller's
|
|
46
|
+
* notion of two finite values that did not change.
|
|
47
|
+
*/
|
|
48
|
+
export declare function wrunDailyLaneHeadEqual(before: ReadonlyArray<ArrayLike<unknown>>, after: ReadonlyArray<ArrayLike<unknown>>, firstDayTs: number, same?: (a: number, b: number) => boolean): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Index day rows by their UTC day, only those at or after the day `fromTs` belongs to, walking
|
|
51
|
+
* back from the end (lanes are ascending): a tail opening mid-day still reads its own day's
|
|
52
|
+
* row. The LAST row of a day wins, as in a forward walk.
|
|
53
|
+
*/
|
|
54
|
+
export declare function indexWrunDailyLaneTail<T extends ArrayLike<unknown>>(rows: ReadonlyArray<T> | undefined, fromTs: number): Map<number, T>;
|
|
55
|
+
/**
|
|
56
|
+
* Where a daily lane's fetch window opens for a chart window opening at `fromTs`: the day the
|
|
57
|
+
* first row belongs to (a chart opening mid-day still reads its own day's row), `lookbackDays`
|
|
58
|
+
* days earlier when a `last` lane reads the observation standing at the window's head (a
|
|
59
|
+
* series reported weekly or monthly has none inside a short intraday window). The full run
|
|
60
|
+
* opens there for the chart window.
|
|
61
|
+
*/
|
|
62
|
+
export declare function wrunDailyLaneFetchFrom(fromTs: number, lookbackDays?: number): number;
|
|
63
|
+
/**
|
|
64
|
+
* Where a daily lane's full-run fetch window closes for a chart whose last bar opens at
|
|
65
|
+
* `lastBarTs` on a grid of `intervalMs`. An intraday or daily chart closes it at that open, as
|
|
66
|
+
* every lane does: the fetch is inclusive of its last source bar (`dataFetch` pads one source
|
|
67
|
+
* interval, a day), which is the day the bar opens in. A bar coarser than a day holds more days
|
|
68
|
+
* than that one, so the window closes at the bar's END (`candleBarEndMs`): the days of the
|
|
69
|
+
* forming week, month, quarter or year after its open are asked too. Closing at the open made a
|
|
70
|
+
* `last` landing read a stale value on the forming bar (and a `sum` landing miss its later days)
|
|
71
|
+
* until the first live reconcile, which already asks through the forming bar's end. The end of a
|
|
72
|
+
* forming bar lies in the future: `dataFetch` turns the window into a period and neither clamps
|
|
73
|
+
* nor refuses it, and a window that does not move with the clock keeps the request identity
|
|
74
|
+
* stable through the bar.
|
|
75
|
+
*/
|
|
76
|
+
export declare function wrunDailyLaneFetchTo(lastBarTs: number, intervalMs: number, nowMs?: number): number;
|
|
77
|
+
/**
|
|
78
|
+
* Where a daily lane's live RECONCILE closes on a chart of `intervalMs` whose chart-bar window
|
|
79
|
+
* closes at `toTs`: there, or on a chart coarser than a day the day after the clock's day when
|
|
80
|
+
* `toTs` has passed (the forming bar of a session grid reaches through today, and its days must
|
|
81
|
+
* be asked: a 3-day equity bar opened Friday still forms on Tuesday while the window closed on
|
|
82
|
+
* Monday). On a contiguous grid the window always closes ahead of the clock.
|
|
83
|
+
*/
|
|
84
|
+
export declare function wrunDailyLaneReconcileTo(toTs: number, intervalMs: number, nowMs: number): number;
|
|
85
|
+
/**
|
|
86
|
+
* Where a daily lane's live RECONCILE opens (its ask, and its answer's authority) for the
|
|
87
|
+
* chart-bar window opening at `fromTs`, in a session whose first row is `sessionFirstRowTs`:
|
|
88
|
+
* where a full run would open for that window (its day, `lookbackDays` earlier: the
|
|
89
|
+
* publication-lag horizon), but never before the session's own full run opened
|
|
90
|
+
* (`fullRunLookbackDays` before the first row's day; a lane whose full run reaches less far
|
|
91
|
+
* back than its reconcile, as the ETF lane's does, names it). A reconcile reaching past the
|
|
92
|
+
* rows the full run fetched (a chart shorter than the lookback, a session shorter than the
|
|
93
|
+
* reconcile tail) would install days no bar of the session reads and report them as revised.
|
|
94
|
+
*/
|
|
95
|
+
export declare function wrunDailyLaneReconcileFrom(fromTs: number, sessionFirstRowTs: number, lookbackDays?: number, fullRunLookbackDays?: number): number;
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A DAILY series on the chart grid: the rules every lane whose rows are one per UTC day shares,
|
|
3
|
+
* whatever the chart's interval. `etf_flow` (wrun-etf-flow-lane.util) and the daily joins of the
|
|
4
|
+
* poll-lane registry (`sources/`, `join: { kind: 'daily', ... }`) read them from here.
|
|
5
|
+
*
|
|
6
|
+
* Rows are `[dayTs, ...columns]`, ascending, stamped inside their UTC day (the gateway stamps
|
|
7
|
+
* 00:00 UTC of the day). Two landings decide what a chart bar brings:
|
|
8
|
+
*
|
|
9
|
+
* - `sum` (flows: `etf_flow`): the day's value lands on the FIRST bar of its day; the later
|
|
10
|
+
* bars of that day bring no observation of their own and follow the input's `missing` policy
|
|
11
|
+
* (`carry` repeats the value across the day, `nan` and `zero` leave a one-bar spike); a daily
|
|
12
|
+
* chart joins row for row; a bar coarser than a day SUMS the days that open inside it.
|
|
13
|
+
* - `last` (levels: a premium rate, a balance, a published observation): the same first-bar
|
|
14
|
+
* landing on an intraday or daily chart, and a bar coarser than a day reads its LAST day that
|
|
15
|
+
* reported. Under the default `carry` policy a bar with no observation of its own reads the
|
|
16
|
+
* newest value at or before its day (`wrunDailyLaneAsOf`), straight off the lane rows: the
|
|
17
|
+
* window's first bars read the day they open inside (or the last observation before the
|
|
18
|
+
* window, when the lane fetched one), and a day whose first bar the chart does not hold (a
|
|
19
|
+
* session gap) still reaches the bars after it. `nan` and `zero` keep the one-bar landing.
|
|
20
|
+
*
|
|
21
|
+
* The lane asks its own DAY interval on every chart (`WRUN_DAILY_LANE_INTERVAL_KEY`: the
|
|
22
|
+
* gateway serves these series at DAY, and `dataFetch` judges the restriction table at that
|
|
23
|
+
* interval), over a window opened at the first row's day (`wrunDailyLaneFetchFrom`; a `last`
|
|
24
|
+
* lane may reach further back for the observation standing at the window's head) and closed at
|
|
25
|
+
* the last bar's open, or at its END on a chart coarser than a day (`wrunDailyLaneFetchTo`: the
|
|
26
|
+
* forming week or month holds days after its open). A live reconcile re-asks from where the
|
|
27
|
+
* full run would open for its own chart-bar window (`wrunDailyLaneReconcileFrom`, the same
|
|
28
|
+
* lookback), never before the session's full run did: a day row is stamped at its midnight,
|
|
29
|
+
* before the chart-bar window it revises, and a row is often published after its stamp date (a
|
|
30
|
+
* daily rate prints the next business day, a monthly series weeks later), so the lookback is
|
|
31
|
+
* the publication-lag horizon. A changed or backdated day is detected over that whole window,
|
|
32
|
+
* as far as a bar can read it: a day of the session by its own row, the rows before the
|
|
33
|
+
* session's first day through the one value standing at its head (`wrunDailyLaneHeadEqual`).
|
|
34
|
+
*
|
|
35
|
+
* The day's FIRST bar is the bar opening inside the day's first interval (a chart whose days
|
|
36
|
+
* open at midnight), or the first bar the chart HOLDS in that day: the one whose predecessor on
|
|
37
|
+
* the chart belongs to an earlier day. A stock session opens at 13:30 UTC, a forex week on
|
|
38
|
+
* Sunday evening, a thin pool prints when it trades, and any chart may miss its midnight bar;
|
|
39
|
+
* the row builder hands the bar before each row (`previousBarTs`), so the landing is a function
|
|
40
|
+
* of the chart's rows and a tail build reads what the full build read. The first row of the
|
|
41
|
+
* chart window has no bar before it and lands by the first rule alone (a window opening
|
|
42
|
+
* mid-day does not take the day's value).
|
|
43
|
+
*
|
|
44
|
+
* A bar coarser than a day ends where the next one opens: the next chart row when the row
|
|
45
|
+
* builder holds it (`nextBarTs`), else its calendar end (`candleBarEndMs`, the chart's own
|
|
46
|
+
* rule: a week is a fixed length, a month, quarter or year bar follows the calendar; the
|
|
47
|
+
* chart's `intervalMs` for those is an average, 30.4375 days a month, so `ts + intervalMs`
|
|
48
|
+
* would run a February into March). The next row matters on a session grid: a 3-day equity
|
|
49
|
+
* bar holds three TRADING days (Thursday, Friday, Monday) and the next bar opens on Tuesday,
|
|
50
|
+
* so its calendar end (Sunday) would drop Monday's observation. The forming bar has no next
|
|
51
|
+
* row: it takes its calendar end, or the day after the clock's day when that end has passed
|
|
52
|
+
* (`nowMs`: the forming Friday bar of that grid still forms on Tuesday, so Monday's and
|
|
53
|
+
* Tuesday's days are its own, and the fetch windows reach the same day, `wrunDailyLaneFetchTo`
|
|
54
|
+
* and `wrunDailyLaneReconcileTo`). A contiguous grid's forming bar always ends ahead of the
|
|
55
|
+
* clock, so nothing changes there.
|
|
56
|
+
*
|
|
57
|
+
* Pure: no store, no chart instance. Every function is total over malformed rows (a non-finite
|
|
58
|
+
* stamp or cell is no observation).
|
|
59
|
+
*/
|
|
60
|
+
import { Intervals } from '../../constants/interval.constants.js';
|
|
61
|
+
import { candleBarEndMs } from '../chart/candle-bar-end.util.js';
|
|
62
|
+
export const WRUN_DAILY_LANE_DAY_MS = Intervals.DAY;
|
|
63
|
+
/** The lane's own interval on every chart (an `Intervals.map_unit` key). */
|
|
64
|
+
export const WRUN_DAILY_LANE_INTERVAL_KEY = '1d';
|
|
65
|
+
/** The UTC day (midnight, ms) a ts belongs to. */
|
|
66
|
+
export function wrunDailyLaneDayStart(ts) {
|
|
67
|
+
return Math.floor(ts / WRUN_DAILY_LANE_DAY_MS) * WRUN_DAILY_LANE_DAY_MS;
|
|
68
|
+
}
|
|
69
|
+
/** One row's cell as a number; an absent cell (null, undefined) is no observation, never 0. */
|
|
70
|
+
function dailyCell(row, column) {
|
|
71
|
+
const cell = row?.[column];
|
|
72
|
+
return cell === null || cell === undefined ? Number.NaN : Number(cell);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The raw observation a daily column brings to the chart row opening at `ts` on a grid of
|
|
76
|
+
* `intervalMs`, off the lane rows indexed by day (`byDay` maps a day start to its row).
|
|
77
|
+
* Intraday or daily grid, either landing: the day's value on the first bar of its day only (a
|
|
78
|
+
* later bar of the day reads NaN, for the input's `missing` policy to fill): the bar opening
|
|
79
|
+
* inside the day's first interval, or the one whose predecessor on the chart (`previousBarTs`)
|
|
80
|
+
* belongs to an earlier day (see the module doc). A grid coarser than a day: `sum` adds the
|
|
81
|
+
* days that open inside the bar, `last` reads the newest of them that reported; NaN when none
|
|
82
|
+
* did. The bar's days end where the next chart bar opens (`nextBarTs`), else at its calendar
|
|
83
|
+
* end (`candleBarEndMs`), so a month bar holds its own month and nothing of the next.
|
|
84
|
+
*/
|
|
85
|
+
export function wrunDailyLaneObservation(byDay, column, ts, intervalMs, landing, previousBarTs, nextBarTs, nowMs) {
|
|
86
|
+
if (!Number.isFinite(ts) || !(intervalMs > 0))
|
|
87
|
+
return Number.NaN;
|
|
88
|
+
if (intervalMs > WRUN_DAILY_LANE_DAY_MS) {
|
|
89
|
+
const endTs = wrunDailyLaneBarEnd(ts, intervalMs, nextBarTs, nowMs);
|
|
90
|
+
let firstDay = wrunDailyLaneDayStart(ts);
|
|
91
|
+
if (firstDay < ts)
|
|
92
|
+
firstDay += WRUN_DAILY_LANE_DAY_MS;
|
|
93
|
+
if (landing === 'last') {
|
|
94
|
+
for (let day = wrunDailyLaneDayStart(endTs - 1); day >= firstDay; day -= WRUN_DAILY_LANE_DAY_MS) {
|
|
95
|
+
const value = dailyCell(byDay.get(day), column);
|
|
96
|
+
if (Number.isFinite(value))
|
|
97
|
+
return value;
|
|
98
|
+
}
|
|
99
|
+
return Number.NaN;
|
|
100
|
+
}
|
|
101
|
+
let sum = Number.NaN;
|
|
102
|
+
for (let day = firstDay; day < endTs; day += WRUN_DAILY_LANE_DAY_MS) {
|
|
103
|
+
const value = dailyCell(byDay.get(day), column);
|
|
104
|
+
if (Number.isFinite(value))
|
|
105
|
+
sum = Number.isFinite(sum) ? sum + value : value;
|
|
106
|
+
}
|
|
107
|
+
return sum;
|
|
108
|
+
}
|
|
109
|
+
const day = wrunDailyLaneDayStart(ts);
|
|
110
|
+
const opensDay = ts - day < intervalMs ||
|
|
111
|
+
(previousBarTs !== undefined && Number.isFinite(previousBarTs) && wrunDailyLaneDayStart(previousBarTs) < day);
|
|
112
|
+
if (!opensDay)
|
|
113
|
+
return Number.NaN;
|
|
114
|
+
return dailyCell(byDay.get(day), column);
|
|
115
|
+
}
|
|
116
|
+
/** The day after the one `nowMs` belongs to (midnight, ms); undefined without a finite clock. */
|
|
117
|
+
function dayAfterNow(nowMs) {
|
|
118
|
+
if (nowMs === undefined || !Number.isFinite(nowMs))
|
|
119
|
+
return undefined;
|
|
120
|
+
return wrunDailyLaneDayStart(nowMs) + WRUN_DAILY_LANE_DAY_MS;
|
|
121
|
+
}
|
|
122
|
+
/** Where a bar coarser than a day ends: the next chart bar's open when known, else the bar's
|
|
123
|
+
* calendar end, or the day after the clock's day when that end has passed (the forming bar of
|
|
124
|
+
* a session grid, the module doc). A next bar at or before the open is no bound. */
|
|
125
|
+
function wrunDailyLaneBarEnd(ts, intervalMs, nextBarTs, nowMs) {
|
|
126
|
+
if (nextBarTs !== undefined && Number.isFinite(nextBarTs) && nextBarTs > ts)
|
|
127
|
+
return nextBarTs;
|
|
128
|
+
const calendarEnd = candleBarEndMs(ts, intervalMs);
|
|
129
|
+
const tomorrow = dayAfterNow(nowMs);
|
|
130
|
+
return tomorrow !== undefined && tomorrow > calendarEnd ? tomorrow : calendarEnd;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The newest finite value of a daily column at or before the chart row opening at `ts` (its
|
|
134
|
+
* own day on an intraday or daily grid, its last day on a coarser one: the day before the next
|
|
135
|
+
* chart bar opens, `nextBarTs`, else before its calendar end, `candleBarEndMs`), off the lane's
|
|
136
|
+
* FULL rows (ascending): what a `last` landing reads under the `carry` policy on a bar that
|
|
137
|
+
* brings no observation of its own. NaN when no row at or before that day reported the column.
|
|
138
|
+
* A binary search to the day, then back over the rows that did not report the column.
|
|
139
|
+
*/
|
|
140
|
+
export function wrunDailyLaneAsOf(rows, column, ts, intervalMs, nextBarTs, nowMs) {
|
|
141
|
+
if (!Number.isFinite(ts) || !(intervalMs > 0))
|
|
142
|
+
return Number.NaN;
|
|
143
|
+
const lastDay = wrunDailyLaneDayStart(intervalMs > WRUN_DAILY_LANE_DAY_MS ? wrunDailyLaneBarEnd(ts, intervalMs, nextBarTs, nowMs) - 1 : ts);
|
|
144
|
+
const endTs = lastDay + WRUN_DAILY_LANE_DAY_MS;
|
|
145
|
+
let low = 0;
|
|
146
|
+
let high = rows.length;
|
|
147
|
+
while (low < high) {
|
|
148
|
+
const mid = (low + high) >>> 1;
|
|
149
|
+
if (Number(rows[mid][0]) < endTs)
|
|
150
|
+
low = mid + 1;
|
|
151
|
+
else
|
|
152
|
+
high = mid;
|
|
153
|
+
}
|
|
154
|
+
for (let at = low - 1; at >= 0; at -= 1) {
|
|
155
|
+
const value = dailyCell(rows[at], column);
|
|
156
|
+
if (Number.isFinite(value))
|
|
157
|
+
return value;
|
|
158
|
+
}
|
|
159
|
+
return Number.NaN;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* What a daily column offers the chart row opening at `ts` BEFORE the input's `missing` policy
|
|
163
|
+
* is applied: the row's own observation (`wrunDailyLaneObservation` over `byDay`, the window's
|
|
164
|
+
* day index) and, for a `last` landing whose input rides the `carry` policy (`carries`), the
|
|
165
|
+
* newest value at or before the row when it brings none of its own (`wrunDailyLaneAsOf` over
|
|
166
|
+
* `rows`, the lane's full rows). A `sum` landing and the `nan` / `zero` policies read the own
|
|
167
|
+
* observation alone. A pure function of the rows, the bar, its neighbors on the chart
|
|
168
|
+
* (`previousBarTs`, `nextBarTs`) and the build's clock (`nowMs`, the forming bar's reach), so a
|
|
169
|
+
* tail build reads what the full build read.
|
|
170
|
+
*/
|
|
171
|
+
export function wrunDailyLaneRead(byDay, rows, column, ts, intervalMs, landing, carries, previousBarTs, nextBarTs, nowMs) {
|
|
172
|
+
const own = wrunDailyLaneObservation(byDay, column, ts, intervalMs, landing, previousBarTs, nextBarTs, nowMs);
|
|
173
|
+
if (Number.isFinite(own) || landing !== 'last' || !carries)
|
|
174
|
+
return own;
|
|
175
|
+
return wrunDailyLaneAsOf(rows, column, ts, intervalMs, nextBarTs, nowMs);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Whether two versions of a daily lane's rows stand the same at the head of a window whose
|
|
179
|
+
* first day is `firstDayTs`: for every column, the newest finite value BEFORE that day is the
|
|
180
|
+
* same in both. That value is all a session reads of the rows older than its window
|
|
181
|
+
* (`wrunDailyLaneAsOf` hands it to a `last` landing's bars under `carry` until a day of the
|
|
182
|
+
* window reports); a change among the rows behind it reaches no bar. `same` is the caller's
|
|
183
|
+
* notion of two finite values that did not change.
|
|
184
|
+
*/
|
|
185
|
+
export function wrunDailyLaneHeadEqual(before, after, firstDayTs, same = (a, b) => a === b) {
|
|
186
|
+
const was = dailyLaneHead(before, firstDayTs);
|
|
187
|
+
const now = dailyLaneHead(after, firstDayTs);
|
|
188
|
+
for (let column = 1; column < Math.max(was.length, now.length); column += 1) {
|
|
189
|
+
const a = was[column];
|
|
190
|
+
const b = now[column];
|
|
191
|
+
if (a === undefined && b === undefined)
|
|
192
|
+
continue;
|
|
193
|
+
if (a === undefined || b === undefined || !same(a, b))
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
/** The newest finite value of every column among the rows stamped before `firstDayTs`, by
|
|
199
|
+
* column index (a column no such row reported stays undefined). */
|
|
200
|
+
function dailyLaneHead(rows, firstDayTs) {
|
|
201
|
+
const head = [];
|
|
202
|
+
for (let at = rows.length - 1; at >= 0; at -= 1) {
|
|
203
|
+
const row = rows[at];
|
|
204
|
+
const ts = Number(row[0]);
|
|
205
|
+
if (!Number.isFinite(ts) || ts >= firstDayTs)
|
|
206
|
+
continue;
|
|
207
|
+
for (let column = 1; column < row.length; column += 1) {
|
|
208
|
+
if (head[column] !== undefined)
|
|
209
|
+
continue;
|
|
210
|
+
const value = dailyCell(row, column);
|
|
211
|
+
if (Number.isFinite(value))
|
|
212
|
+
head[column] = value;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return head;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Index day rows by their UTC day, only those at or after the day `fromTs` belongs to, walking
|
|
219
|
+
* back from the end (lanes are ascending): a tail opening mid-day still reads its own day's
|
|
220
|
+
* row. The LAST row of a day wins, as in a forward walk.
|
|
221
|
+
*/
|
|
222
|
+
export function indexWrunDailyLaneTail(rows, fromTs) {
|
|
223
|
+
const byDay = new Map();
|
|
224
|
+
if (!rows)
|
|
225
|
+
return byDay;
|
|
226
|
+
const fromDay = wrunDailyLaneDayStart(fromTs);
|
|
227
|
+
for (let at = rows.length - 1; at >= 0; at -= 1) {
|
|
228
|
+
const row = rows[at];
|
|
229
|
+
const ts = Number(row[0]);
|
|
230
|
+
if (!Number.isFinite(ts))
|
|
231
|
+
continue;
|
|
232
|
+
const day = wrunDailyLaneDayStart(ts);
|
|
233
|
+
if (day < fromDay)
|
|
234
|
+
break;
|
|
235
|
+
if (!byDay.has(day))
|
|
236
|
+
byDay.set(day, row);
|
|
237
|
+
}
|
|
238
|
+
return byDay;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Where a daily lane's fetch window opens for a chart window opening at `fromTs`: the day the
|
|
242
|
+
* first row belongs to (a chart opening mid-day still reads its own day's row), `lookbackDays`
|
|
243
|
+
* days earlier when a `last` lane reads the observation standing at the window's head (a
|
|
244
|
+
* series reported weekly or monthly has none inside a short intraday window). The full run
|
|
245
|
+
* opens there for the chart window.
|
|
246
|
+
*/
|
|
247
|
+
export function wrunDailyLaneFetchFrom(fromTs, lookbackDays = 0) {
|
|
248
|
+
const days = Number.isFinite(lookbackDays) && lookbackDays > 0 ? Math.floor(lookbackDays) : 0;
|
|
249
|
+
return wrunDailyLaneDayStart(fromTs) - days * WRUN_DAILY_LANE_DAY_MS;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Where a daily lane's full-run fetch window closes for a chart whose last bar opens at
|
|
253
|
+
* `lastBarTs` on a grid of `intervalMs`. An intraday or daily chart closes it at that open, as
|
|
254
|
+
* every lane does: the fetch is inclusive of its last source bar (`dataFetch` pads one source
|
|
255
|
+
* interval, a day), which is the day the bar opens in. A bar coarser than a day holds more days
|
|
256
|
+
* than that one, so the window closes at the bar's END (`candleBarEndMs`): the days of the
|
|
257
|
+
* forming week, month, quarter or year after its open are asked too. Closing at the open made a
|
|
258
|
+
* `last` landing read a stale value on the forming bar (and a `sum` landing miss its later days)
|
|
259
|
+
* until the first live reconcile, which already asks through the forming bar's end. The end of a
|
|
260
|
+
* forming bar lies in the future: `dataFetch` turns the window into a period and neither clamps
|
|
261
|
+
* nor refuses it, and a window that does not move with the clock keeps the request identity
|
|
262
|
+
* stable through the bar.
|
|
263
|
+
*/
|
|
264
|
+
export function wrunDailyLaneFetchTo(lastBarTs, intervalMs, nowMs) {
|
|
265
|
+
if (!Number.isFinite(lastBarTs) || !(intervalMs > WRUN_DAILY_LANE_DAY_MS))
|
|
266
|
+
return lastBarTs;
|
|
267
|
+
return wrunDailyLaneBarEnd(lastBarTs, intervalMs, undefined, nowMs);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Where a daily lane's live RECONCILE closes on a chart of `intervalMs` whose chart-bar window
|
|
271
|
+
* closes at `toTs`: there, or on a chart coarser than a day the day after the clock's day when
|
|
272
|
+
* `toTs` has passed (the forming bar of a session grid reaches through today, and its days must
|
|
273
|
+
* be asked: a 3-day equity bar opened Friday still forms on Tuesday while the window closed on
|
|
274
|
+
* Monday). On a contiguous grid the window always closes ahead of the clock.
|
|
275
|
+
*/
|
|
276
|
+
export function wrunDailyLaneReconcileTo(toTs, intervalMs, nowMs) {
|
|
277
|
+
if (!Number.isFinite(toTs) || !(intervalMs > WRUN_DAILY_LANE_DAY_MS))
|
|
278
|
+
return toTs;
|
|
279
|
+
const tomorrow = dayAfterNow(nowMs);
|
|
280
|
+
return tomorrow !== undefined && tomorrow > toTs ? tomorrow : toTs;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Where a daily lane's live RECONCILE opens (its ask, and its answer's authority) for the
|
|
284
|
+
* chart-bar window opening at `fromTs`, in a session whose first row is `sessionFirstRowTs`:
|
|
285
|
+
* where a full run would open for that window (its day, `lookbackDays` earlier: the
|
|
286
|
+
* publication-lag horizon), but never before the session's own full run opened
|
|
287
|
+
* (`fullRunLookbackDays` before the first row's day; a lane whose full run reaches less far
|
|
288
|
+
* back than its reconcile, as the ETF lane's does, names it). A reconcile reaching past the
|
|
289
|
+
* rows the full run fetched (a chart shorter than the lookback, a session shorter than the
|
|
290
|
+
* reconcile tail) would install days no bar of the session reads and report them as revised.
|
|
291
|
+
*/
|
|
292
|
+
export function wrunDailyLaneReconcileFrom(fromTs, sessionFirstRowTs, lookbackDays = 0, fullRunLookbackDays = lookbackDays) {
|
|
293
|
+
const from = wrunDailyLaneFetchFrom(fromTs, lookbackDays);
|
|
294
|
+
if (!Number.isFinite(sessionFirstRowTs))
|
|
295
|
+
return from;
|
|
296
|
+
return Math.max(from, wrunDailyLaneFetchFrom(sessionFirstRowTs, fullRunLookbackDays));
|
|
297
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deadline wrapper for the WRUN add/run chain.
|
|
3
|
+
*
|
|
4
|
+
* The registry add path (ported-row click, add-by-name, registry row,
|
|
5
|
+
* rehydrate) awaits work with no intrinsic bound: network fetches, the chart
|
|
6
|
+
* store's mount pipeline, and the kScript source fetch lanes (a V2 stream only
|
|
7
|
+
* settles when the wire answers). Any one of them hanging left the UI pinned
|
|
8
|
+
* in its in-flight state forever ("Checking availability..." with no outcome,
|
|
9
|
+
* the shipped wrun-tab hang). Every await on that chain now races a deadline:
|
|
10
|
+
* the underlying work is not cancelled (fetches and mounts are not idempotent
|
|
11
|
+
* to abort), but the CALLER always settles, so the row always leaves its
|
|
12
|
+
* checking state with a user-visible outcome.
|
|
13
|
+
*
|
|
14
|
+
* Deadlines are ceilings against "forever", not latency budgets: each is far
|
|
15
|
+
* above the lane's healthy worst case (mount was observed taking ~25s when
|
|
16
|
+
* metadata RPCs ride their own 30s timeouts), so a trip means genuinely hung
|
|
17
|
+
* work, and the error message names the phase that hung.
|
|
18
|
+
*
|
|
19
|
+
* Two clocks, one per kind of phase. A NETWORK phase (the registry resolve and
|
|
20
|
+
* download, a source fetch) is answered whether or not anyone looks, so it
|
|
21
|
+
* counts wall time: a hidden tab whose reply never comes still times out. An
|
|
22
|
+
* APPLY phase (the mount, the first run up to its commit) is work a hidden tab
|
|
23
|
+
* holds back (the candle commit and the apply wait for a visible frame), so it
|
|
24
|
+
* counts visible time (visible-timeout.util): a chart restored in a background
|
|
25
|
+
* tab never reads "Did not load in time" nor records a `timeout`, and a stall
|
|
26
|
+
* the user watches still trips after the same budget. The apply phases' own
|
|
27
|
+
* network legs keep their wall-clock deadlines inside them.
|
|
28
|
+
*/
|
|
29
|
+
/** The clock a deadline counts on: `wall` for a network phase, `visible` for an apply phase. */
|
|
30
|
+
export type WrunDeadlineClock = 'wall' | 'visible';
|
|
31
|
+
/** Downloading + verifying a package from the registry (resolve, tarball). A network phase. */
|
|
32
|
+
export declare const WRUN_DOWNLOAD_DEADLINE_MS = 45000;
|
|
33
|
+
/** The one LATENCY budget here: the resolve of a built-in's proven twin
|
|
34
|
+
* (option A, wrun-proven-twin-add.util). That Add has the shipped template
|
|
35
|
+
* to fall back on, so a registry that accepts the connection and never
|
|
36
|
+
* answers holds the click a few seconds, never the download ceiling above;
|
|
37
|
+
* the resolve keeps running in its memo, so a later click finds it. */
|
|
38
|
+
export declare const WRUN_TWIN_RESOLVE_DEADLINE_MS = 4000;
|
|
39
|
+
/** Mounting the overlay through chartStore.addIndicator. An apply phase (visible time). */
|
|
40
|
+
export declare const WRUN_MOUNT_DEADLINE_MS = 60000;
|
|
41
|
+
/** One full compute pass (source fetches + sandbox run + integration). An
|
|
42
|
+
* apply phase (visible time): its source fetches carry their own wall-clock
|
|
43
|
+
* deadline below. */
|
|
44
|
+
export declare const WRUN_RUN_DEADLINE_MS = 90000;
|
|
45
|
+
/** One kScript source fetch lane inside the run (book/trades/oi/vp/liq/
|
|
46
|
+
* funding/iv/skew). A network phase. */
|
|
47
|
+
export declare const WRUN_SOURCE_FETCH_DEADLINE_MS = 45000;
|
|
48
|
+
/** Await `promise`, but reject with a labeled WrunDeadlineError if it has not
|
|
49
|
+
* settled within `ms` on `clock` (wall time unless the phase is an apply
|
|
50
|
+
* phase). The losing promise is left running with its eventual rejection
|
|
51
|
+
* marked handled (no unhandled-rejection noise). */
|
|
52
|
+
export declare function withWrunDeadline<T>(promise: Promise<T>, ms: number, label: string, clock?: WrunDeadlineClock): Promise<T>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deadline wrapper for the WRUN add/run chain.
|
|
3
|
+
*
|
|
4
|
+
* The registry add path (ported-row click, add-by-name, registry row,
|
|
5
|
+
* rehydrate) awaits work with no intrinsic bound: network fetches, the chart
|
|
6
|
+
* store's mount pipeline, and the kScript source fetch lanes (a V2 stream only
|
|
7
|
+
* settles when the wire answers). Any one of them hanging left the UI pinned
|
|
8
|
+
* in its in-flight state forever ("Checking availability..." with no outcome,
|
|
9
|
+
* the shipped wrun-tab hang). Every await on that chain now races a deadline:
|
|
10
|
+
* the underlying work is not cancelled (fetches and mounts are not idempotent
|
|
11
|
+
* to abort), but the CALLER always settles, so the row always leaves its
|
|
12
|
+
* checking state with a user-visible outcome.
|
|
13
|
+
*
|
|
14
|
+
* Deadlines are ceilings against "forever", not latency budgets: each is far
|
|
15
|
+
* above the lane's healthy worst case (mount was observed taking ~25s when
|
|
16
|
+
* metadata RPCs ride their own 30s timeouts), so a trip means genuinely hung
|
|
17
|
+
* work, and the error message names the phase that hung.
|
|
18
|
+
*
|
|
19
|
+
* Two clocks, one per kind of phase. A NETWORK phase (the registry resolve and
|
|
20
|
+
* download, a source fetch) is answered whether or not anyone looks, so it
|
|
21
|
+
* counts wall time: a hidden tab whose reply never comes still times out. An
|
|
22
|
+
* APPLY phase (the mount, the first run up to its commit) is work a hidden tab
|
|
23
|
+
* holds back (the candle commit and the apply wait for a visible frame), so it
|
|
24
|
+
* counts visible time (visible-timeout.util): a chart restored in a background
|
|
25
|
+
* tab never reads "Did not load in time" nor records a `timeout`, and a stall
|
|
26
|
+
* the user watches still trips after the same budget. The apply phases' own
|
|
27
|
+
* network legs keep their wall-clock deadlines inside them.
|
|
28
|
+
*/
|
|
29
|
+
import { startVisibleTimeout } from '../common/visible-timeout.util.js';
|
|
30
|
+
import { WrunDeadlineError } from './wrun-registry-errors.util.js';
|
|
31
|
+
/** Downloading + verifying a package from the registry (resolve, tarball). A network phase. */
|
|
32
|
+
export const WRUN_DOWNLOAD_DEADLINE_MS = 45_000;
|
|
33
|
+
/** The one LATENCY budget here: the resolve of a built-in's proven twin
|
|
34
|
+
* (option A, wrun-proven-twin-add.util). That Add has the shipped template
|
|
35
|
+
* to fall back on, so a registry that accepts the connection and never
|
|
36
|
+
* answers holds the click a few seconds, never the download ceiling above;
|
|
37
|
+
* the resolve keeps running in its memo, so a later click finds it. */
|
|
38
|
+
export const WRUN_TWIN_RESOLVE_DEADLINE_MS = 4_000;
|
|
39
|
+
/** Mounting the overlay through chartStore.addIndicator. An apply phase (visible time). */
|
|
40
|
+
export const WRUN_MOUNT_DEADLINE_MS = 60_000;
|
|
41
|
+
/** One full compute pass (source fetches + sandbox run + integration). An
|
|
42
|
+
* apply phase (visible time): its source fetches carry their own wall-clock
|
|
43
|
+
* deadline below. */
|
|
44
|
+
export const WRUN_RUN_DEADLINE_MS = 90_000;
|
|
45
|
+
/** One kScript source fetch lane inside the run (book/trades/oi/vp/liq/
|
|
46
|
+
* funding/iv/skew). A network phase. */
|
|
47
|
+
export const WRUN_SOURCE_FETCH_DEADLINE_MS = 45_000;
|
|
48
|
+
/** Await `promise`, but reject with a labeled WrunDeadlineError if it has not
|
|
49
|
+
* settled within `ms` on `clock` (wall time unless the phase is an apply
|
|
50
|
+
* phase). The losing promise is left running with its eventual rejection
|
|
51
|
+
* marked handled (no unhandled-rejection noise). */
|
|
52
|
+
export async function withWrunDeadline(promise, ms, label, clock = 'wall') {
|
|
53
|
+
// If the deadline wins the race, a later rejection of the abandoned promise
|
|
54
|
+
// must not surface as an unhandled rejection.
|
|
55
|
+
void promise.catch(() => undefined);
|
|
56
|
+
let release;
|
|
57
|
+
try {
|
|
58
|
+
return await Promise.race([
|
|
59
|
+
promise,
|
|
60
|
+
new Promise((_, reject) => {
|
|
61
|
+
const seconds = Math.round(ms / 1000);
|
|
62
|
+
if (clock === 'visible') {
|
|
63
|
+
const deadline = startVisibleTimeout(() => {
|
|
64
|
+
// The background time before the visible budget ran out, for the report (never part of the budget).
|
|
65
|
+
const hiddenSeconds = Math.round(deadline.hiddenMs() / 1000);
|
|
66
|
+
const hidden = hiddenSeconds > 0 ? ` of visible time (${hiddenSeconds}s hidden before)` : '';
|
|
67
|
+
reject(new WrunDeadlineError(`${label} timed out after ${seconds}s${hidden}`));
|
|
68
|
+
}, ms);
|
|
69
|
+
release = () => deadline.clear();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const timer = setTimeout(() => {
|
|
73
|
+
reject(new WrunDeadlineError(`${label} timed out after ${seconds}s`));
|
|
74
|
+
}, ms);
|
|
75
|
+
release = () => clearTimeout(timer);
|
|
76
|
+
}),
|
|
77
|
+
]);
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
release?.();
|
|
81
|
+
}
|
|
82
|
+
}
|