@orangecharts/wrun-chart-host 0.4.0 → 0.6.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 +17 -5
- package/dist/constants/exchange-names.leaf.d.ts +8 -0
- package/dist/constants/exchange-names.leaf.js +101 -0
- package/dist/constants/feature-flags.constants.js +7 -2
- package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +15 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.js +40 -0
- package/dist/constants/opra-compliance.constants.d.ts +19 -0
- package/dist/constants/opra-compliance.constants.js +19 -0
- package/dist/constants/replay-ladder.leaf.d.ts +30 -0
- package/dist/constants/replay-ladder.leaf.js +99 -0
- package/dist/constants/scriptEditor/cme-official-scripts.constants.d.ts +168 -0
- package/dist/constants/scriptEditor/cme-official-scripts.constants.js +398 -0
- package/dist/constants/scriptEditor/converted-script-id.leaf.d.ts +8 -0
- package/dist/constants/scriptEditor/converted-script-id.leaf.js +10 -0
- package/dist/constants/scriptEditor/execution.constants.d.ts +4 -0
- package/dist/constants/scriptEditor/execution.constants.js +14 -0
- package/dist/constants/wrun-prefix-safe.constants.d.ts +23 -0
- package/dist/constants/wrun-prefix-safe.constants.js +26 -0
- package/dist/host-env.d.ts +301 -22
- package/dist/host-env.js +15 -0
- package/dist/host-ports.types.d.ts +853 -29
- package/dist/index.d.ts +140 -2
- package/dist/index.js +140 -2
- package/dist/instances/script-engine-worker-ohlcv-transfer.d.ts +31 -0
- package/dist/instances/script-engine-worker-ohlcv-transfer.js +164 -0
- package/dist/interfaces/market-event.interface.d.ts +231 -0
- package/dist/interfaces/market-event.interface.js +15 -0
- package/dist/interfaces/opra-realtime.interface.d.ts +70 -134
- package/dist/interfaces/opra-realtime.interface.js +34 -59
- package/dist/interfaces/replay.interface.d.ts +285 -0
- package/dist/interfaces/replay.interface.js +1 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +88 -13
- package/dist/interfaces/wrun-runtime.interface.js +17 -3
- package/dist/kscript-data/controls/live-ohlcv-merge.util.d.ts +1 -0
- package/dist/kscript-data/controls/live-ohlcv-merge.util.js +93 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +5 -1
- package/dist/kscript-data/controls/live-trades-merge.util.js +2 -2
- package/dist/market-data/billing.interface.d.ts +219 -0
- package/dist/market-data/billing.interface.js +58 -0
- package/dist/market-data/venue-governed.util.d.ts +2 -0
- package/dist/market-data/venue-governed.util.js +10 -0
- package/dist/market-data/venue.d.ts +122 -0
- package/dist/market-data/venue.js +1 -0
- package/dist/market-data/venues/index.d.ts +97 -0
- package/dist/market-data/venues/index.js +33 -0
- package/dist/market-data/venues/opra.contract.copy.json +35 -0
- package/dist/market-data/venues/opra.d.ts +70 -0
- package/dist/market-data/venues/opra.js +74 -0
- package/dist/replay/replayIndicatorRows.d.ts +31 -0
- package/dist/replay/replayIndicatorRows.js +117 -0
- package/dist/replay/replayLadder.d.ts +85 -0
- package/dist/replay/replayLadder.js +388 -0
- package/dist/utility/auth/server-clock.util.d.ts +81 -0
- package/dist/utility/auth/server-clock.util.js +238 -0
- package/dist/utility/chart/builtin-identity.util.d.ts +18 -0
- package/dist/utility/chart/builtin-identity.util.js +51 -0
- package/dist/utility/chart/cache-alignment.util.d.ts +454 -0
- package/dist/utility/chart/cache-alignment.util.js +926 -0
- package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +15 -0
- package/dist/utility/chart/chart-data-fetch-generation.util.js +22 -0
- package/dist/utility/chart/chart-mount-epoch.util.d.ts +17 -0
- package/dist/utility/chart/chart-mount-epoch.util.js +61 -0
- package/dist/utility/chart/chart-time-domain.util.d.ts +12 -0
- package/dist/utility/chart/chart-time-domain.util.js +23 -0
- package/dist/utility/chart/color-customization.leaf.d.ts +10 -0
- package/dist/utility/chart/color-customization.leaf.js +16 -0
- package/dist/utility/chart/footprint-tick-grid.util.d.ts +106 -0
- package/dist/utility/chart/footprint-tick-grid.util.js +167 -0
- package/dist/utility/chart/gesture-timing.leaf.d.ts +29 -0
- package/dist/utility/chart/gesture-timing.leaf.js +29 -0
- package/dist/utility/chart/governed-contract-coin.util.d.ts +22 -0
- package/dist/utility/chart/governed-contract-coin.util.js +39 -0
- package/dist/utility/chart/host-bar-placement.util.d.ts +107 -0
- package/dist/utility/chart/host-bar-placement.util.js +447 -0
- package/dist/utility/chart/index-host-tier.util.d.ts +31 -0
- package/dist/utility/chart/index-host-tier.util.js +118 -0
- package/dist/utility/chart/index-mode-admission.util.d.ts +34 -0
- package/dist/utility/chart/index-mode-admission.util.js +67 -0
- package/dist/utility/chart/indicator-error-message.util.d.ts +35 -0
- package/dist/utility/chart/indicator-error-message.util.js +44 -0
- package/dist/utility/chart/kscript-apply-fingerprint.util.d.ts +65 -0
- package/dist/utility/chart/kscript-apply-fingerprint.util.js +357 -0
- package/dist/utility/chart/kscript-chart-flush.leaf.d.ts +22 -0
- package/dist/utility/chart/kscript-chart-flush.leaf.js +13 -0
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +6 -0
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +27 -0
- package/dist/utility/chart/kscript-integration-decision.leaf.d.ts +89 -0
- package/dist/utility/chart/kscript-integration-decision.leaf.js +80 -0
- package/dist/utility/chart/kscript-live-coalesce.util.d.ts +76 -0
- package/dist/utility/chart/kscript-live-coalesce.util.js +156 -0
- package/dist/utility/chart/kscript-live-rest-pace.util.d.ts +34 -0
- package/dist/utility/chart/kscript-live-rest-pace.util.js +134 -0
- package/dist/utility/chart/kscript-live-source-identity.util.d.ts +98 -0
- package/dist/utility/chart/kscript-live-source-identity.util.js +121 -0
- package/dist/utility/chart/kscript-mounted-plot-set.leaf.d.ts +48 -0
- package/dist/utility/chart/kscript-mounted-plot-set.leaf.js +145 -0
- package/dist/utility/chart/kscript-perf-tracker.util.d.ts +243 -0
- package/dist/utility/chart/kscript-perf-tracker.util.js +522 -0
- package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +43 -0
- package/dist/utility/chart/kscript-run-interval-projection.util.js +471 -0
- package/dist/utility/chart/kscript-run-result-equality.util.d.ts +38 -0
- package/dist/utility/chart/kscript-run-result-equality.util.js +89 -0
- package/dist/utility/chart/kscript-settings-revision.leaf.d.ts +2 -0
- package/dist/utility/chart/kscript-settings-revision.leaf.js +12 -0
- package/dist/utility/chart/kscript-source-degrade.leaf.d.ts +63 -0
- package/dist/utility/chart/kscript-source-degrade.leaf.js +68 -0
- package/dist/utility/chart/kscript-source-retention.util.d.ts +134 -0
- package/dist/utility/chart/kscript-source-retention.util.js +218 -0
- package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +57 -0
- package/dist/utility/chart/kscript-standin-identity.leaf.js +61 -0
- package/dist/utility/chart/kscript-titancharts-preparation.util.d.ts +15 -0
- package/dist/utility/chart/kscript-titancharts-preparation.util.js +376 -0
- package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +9 -0
- package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +130 -0
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +217 -0
- package/dist/utility/chart/kscript-venue-policy.util.js +324 -0
- package/dist/utility/chart/live-cadence.util.d.ts +38 -0
- package/dist/utility/chart/live-cadence.util.js +37 -0
- package/dist/utility/chart/live-feed-series-match.leaf.d.ts +13 -0
- package/dist/utility/chart/live-feed-series-match.leaf.js +21 -0
- package/dist/utility/chart/local-engine-self-heal-backoff.util.d.ts +46 -0
- package/dist/utility/chart/local-engine-self-heal-backoff.util.js +46 -0
- package/dist/utility/chart/local-engine-uninit.leaf.d.ts +21 -0
- package/dist/utility/chart/local-engine-uninit.leaf.js +22 -0
- package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +62 -0
- package/dist/utility/chart/local-kscript-source-revalidation.util.js +123 -0
- package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +214 -0
- package/dist/utility/chart/local-kscript-warmup-depth.util.js +376 -0
- package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.d.ts +85 -0
- package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.js +197 -0
- package/dist/utility/chart/local-technical-script-range.leaf.d.ts +72 -0
- package/dist/utility/chart/local-technical-script-range.leaf.js +126 -0
- package/dist/utility/chart/mixed-mode.util.d.ts +167 -0
- package/dist/utility/chart/mixed-mode.util.js +139 -0
- package/dist/utility/chart/ohlcv-row-readiness.util.d.ts +36 -0
- package/dist/utility/chart/ohlcv-row-readiness.util.js +90 -0
- package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +19 -0
- package/dist/utility/chart/opra-user-scripts-gate.util.js +32 -0
- package/dist/utility/chart/overlay-execution-guard-key.leaf.d.ts +8 -0
- package/dist/utility/chart/overlay-execution-guard-key.leaf.js +10 -0
- package/dist/utility/chart/price-precision.util.d.ts +40 -0
- package/dist/utility/chart/price-precision.util.js +70 -0
- package/dist/utility/chart/profile-block-size.util.d.ts +64 -0
- package/dist/utility/chart/profile-block-size.util.js +141 -0
- package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.d.ts +11 -0
- package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.js +29 -0
- package/dist/utility/chart/protected-kscript-empty-output.util.d.ts +28 -0
- package/dist/utility/chart/protected-kscript-empty-output.util.js +84 -0
- package/dist/utility/chart/run-interval-unservable.leaf.d.ts +9 -0
- package/dist/utility/chart/run-interval-unservable.leaf.js +20 -0
- package/dist/utility/chart/run-interval-warmup.leaf.d.ts +19 -0
- package/dist/utility/chart/run-interval-warmup.leaf.js +35 -0
- package/dist/utility/chart/titan-constants.pin.d.ts +9 -5
- package/dist/utility/chart/titan-constants.pin.js +18 -5
- package/dist/utility/chart/warmup-backfill-retry.leaf.d.ts +9 -0
- package/dist/utility/chart/warmup-backfill-retry.leaf.js +9 -0
- package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +11 -2
- package/dist/utility/chart/wrun-bar-session-facts.util.js +10 -3
- package/dist/utility/chart/wrun-run-result.util.d.ts +5 -1
- package/dist/utility/chart/wrun-run-result.util.js +20 -14
- package/dist/utility/common/data-processing.util.d.ts +138 -0
- package/dist/utility/common/data-processing.util.js +346 -0
- package/dist/utility/common/visible-timeout.util.d.ts +13 -4
- package/dist/utility/common/visible-timeout.util.js +23 -8
- package/dist/utility/exchange-format.leaf.d.ts +1 -0
- package/dist/utility/exchange-format.leaf.js +47 -0
- package/dist/utility/market-events/earnings-scope.util.d.ts +60 -0
- package/dist/utility/market-events/earnings-scope.util.js +92 -0
- package/dist/utility/market-events/market-events.util.d.ts +147 -0
- package/dist/utility/market-events/market-events.util.js +392 -0
- package/dist/utility/market-events/zoned-clock.util.d.ts +1 -0
- package/dist/utility/market-events/zoned-clock.util.js +11 -0
- package/dist/utility/options/option-venue-disclosure.util.d.ts +43 -0
- package/dist/utility/options/option-venue-disclosure.util.js +56 -0
- package/dist/utility/scriptEditor/package-semver.util.d.ts +51 -0
- package/dist/utility/scriptEditor/package-semver.util.js +120 -0
- package/dist/utility/scriptEditor/temp-script-id.util.d.ts +18 -0
- package/dist/utility/scriptEditor/temp-script-id.util.js +25 -0
- package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.d.ts +20 -0
- package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.js +81 -0
- package/dist/utility/v2/governed-tier.leaf.d.ts +103 -0
- package/dist/utility/v2/governed-tier.leaf.js +113 -0
- package/dist/utility/watchlist/import/import-request.leaf.d.ts +10 -0
- package/dist/utility/watchlist/import/import-request.leaf.js +10 -0
- package/dist/utility/wrun/sources/lanes/series.js +2 -2
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +4 -4
- package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +5 -6
- package/dist/utility/wrun/wrun-alert-outputs.registry.d.ts +166 -0
- package/dist/utility/wrun/wrun-alert-outputs.registry.js +219 -0
- package/dist/utility/wrun/wrun-bar-count.util.d.ts +94 -0
- package/dist/utility/wrun/wrun-bar-count.util.js +274 -0
- package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +84 -0
- package/dist/utility/wrun/wrun-chart-context-names.util.js +186 -0
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +253 -0
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +731 -0
- package/dist/utility/wrun/wrun-cloud-opra-stamp.util.d.ts +28 -0
- package/dist/utility/wrun/wrun-cloud-opra-stamp.util.js +45 -0
- package/dist/utility/wrun/wrun-coin-lane-live.util.d.ts +18 -0
- package/dist/utility/wrun/wrun-coin-lane-live.util.js +47 -0
- package/dist/utility/wrun/wrun-deadline.util.js +2 -1
- package/dist/utility/wrun/wrun-debug-output.util.d.ts +39 -0
- package/dist/utility/wrun/wrun-debug-output.util.js +63 -0
- package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +113 -0
- package/dist/utility/wrun/wrun-declared-warmup.util.js +181 -0
- package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +43 -0
- package/dist/utility/wrun/wrun-draft-legend-note.util.js +158 -0
- package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +181 -0
- package/dist/utility/wrun/wrun-draft-overlay.util.js +357 -0
- package/dist/utility/wrun/wrun-draw-skipped.leaf.d.ts +16 -0
- package/dist/utility/wrun/wrun-draw-skipped.leaf.js +16 -0
- package/dist/utility/wrun/wrun-earnings-facts.util.d.ts +42 -0
- package/dist/utility/wrun/wrun-earnings-facts.util.js +131 -0
- package/dist/utility/wrun/wrun-first-run-depth.util.d.ts +32 -0
- package/dist/utility/wrun/wrun-first-run-depth.util.js +118 -0
- package/dist/utility/wrun/wrun-gate-plane-readers.util.d.ts +24 -0
- package/dist/utility/wrun/wrun-gate-plane-readers.util.js +31 -0
- package/dist/utility/wrun/wrun-held-lanes.util.d.ts +32 -0
- package/dist/utility/wrun/wrun-held-lanes.util.js +94 -0
- package/dist/utility/wrun/wrun-host-visible-clock.util.d.ts +2 -0
- package/dist/utility/wrun/wrun-host-visible-clock.util.js +17 -0
- package/dist/utility/wrun/wrun-host.service.d.ts +330 -0
- package/dist/utility/wrun/wrun-host.service.js +855 -0
- package/dist/utility/wrun/wrun-hover.util.d.ts +3 -0
- package/dist/utility/wrun/wrun-hover.util.js +25 -4
- package/dist/utility/wrun/wrun-inert-legend.util.d.ts +33 -0
- package/dist/utility/wrun/wrun-inert-legend.util.js +125 -0
- package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +155 -0
- package/dist/utility/wrun/wrun-input-requirements.leaf.js +450 -0
- package/dist/utility/wrun/wrun-integration-route.util.d.ts +51 -0
- package/dist/utility/wrun/wrun-integration-route.util.js +59 -0
- package/dist/utility/wrun/wrun-latest-history.leaf.d.ts +8 -0
- package/dist/utility/wrun/wrun-latest-history.leaf.js +8 -0
- package/dist/utility/wrun/wrun-legend-hover.lazy.d.ts +12 -0
- package/dist/utility/wrun/wrun-legend-hover.lazy.js +96 -0
- package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +21 -0
- package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +21 -0
- package/dist/utility/wrun/wrun-live-hidden-hold.util.d.ts +23 -0
- package/dist/utility/wrun/wrun-live-hidden-hold.util.js +13 -0
- package/dist/utility/wrun/wrun-live-intake.util.d.ts +374 -0
- package/dist/utility/wrun/wrun-live-intake.util.js +2027 -0
- package/dist/utility/wrun/wrun-live-patch.util.d.ts +116 -0
- package/dist/utility/wrun/wrun-live-patch.util.js +523 -0
- package/dist/utility/wrun/wrun-live-tick.util.d.ts +619 -0
- package/dist/utility/wrun/wrun-live-tick.util.js +4974 -0
- package/dist/utility/wrun/wrun-loading-owner.util.d.ts +58 -0
- package/dist/utility/wrun/wrun-loading-owner.util.js +89 -0
- package/dist/utility/wrun/wrun-official-scope.leaf.d.ts +29 -0
- package/dist/utility/wrun/wrun-official-scope.leaf.js +36 -0
- package/dist/utility/wrun/wrun-oi-lane.util.d.ts +27 -0
- package/dist/utility/wrun/wrun-oi-lane.util.js +42 -0
- package/dist/utility/wrun/wrun-options-stop.util.d.ts +52 -0
- package/dist/utility/wrun/wrun-options-stop.util.js +123 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +719 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +1180 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +50 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +131 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +118 -0
- package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +466 -0
- package/dist/utility/wrun/wrun-overlay-metadata.util.d.ts +45 -0
- package/dist/utility/wrun/wrun-overlay-metadata.util.js +112 -0
- package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +114 -0
- package/dist/utility/wrun/wrun-overlay-recovery.util.js +971 -0
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +858 -0
- package/dist/utility/wrun/wrun-overlay-run.util.js +11013 -0
- package/dist/utility/wrun/wrun-pack.util.d.ts +2 -1
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +24 -9
- package/dist/utility/wrun/wrun-panel-mount.util.js +138 -43
- package/dist/utility/wrun/wrun-param-map.util.d.ts +19 -4
- package/dist/utility/wrun/wrun-param-map.util.js +40 -47
- package/dist/utility/wrun/wrun-param-values.util.d.ts +9 -3
- package/dist/utility/wrun/wrun-param-values.util.js +5 -5
- package/dist/utility/wrun/wrun-prefix-cohort.util.d.ts +93 -0
- package/dist/utility/wrun/wrun-prefix-cohort.util.js +484 -0
- package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +114 -0
- package/dist/utility/wrun/wrun-prefix-lanes.util.js +486 -0
- package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +317 -0
- package/dist/utility/wrun/wrun-prefix-proof.util.js +630 -0
- package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +73 -0
- package/dist/utility/wrun/wrun-refusal-surface.util.js +380 -0
- package/dist/utility/wrun/wrun-refusal-text.util.d.ts +15 -0
- package/dist/utility/wrun/wrun-refusal-text.util.js +40 -0
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
- package/dist/utility/wrun/wrun-replay-lane.util.d.ts +139 -0
- package/dist/utility/wrun/wrun-replay-lane.util.js +520 -0
- package/dist/utility/wrun/wrun-replay-rows.util.d.ts +21 -0
- package/dist/utility/wrun/wrun-replay-rows.util.js +172 -0
- package/dist/utility/wrun/wrun-row-source-factory.d.ts +53 -0
- package/dist/utility/wrun/wrun-row-source-factory.js +435 -0
- package/dist/utility/wrun/wrun-run-cells.util.d.ts +36 -0
- package/dist/utility/wrun/wrun-run-cells.util.js +46 -0
- package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +133 -0
- package/dist/utility/wrun/wrun-run-interval-session.util.js +121 -0
- package/dist/utility/wrun/wrun-run-interval.util.d.ts +98 -0
- package/dist/utility/wrun/wrun-run-interval.util.js +207 -0
- package/dist/utility/wrun/wrun-run-retained.util.d.ts +122 -0
- package/dist/utility/wrun/wrun-run-retained.util.js +255 -0
- package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +184 -0
- package/dist/utility/wrun/wrun-sandbox-row-source.js +444 -0
- package/dist/utility/wrun/wrun-script-inputs.util.js +4 -4
- package/dist/utility/wrun/wrun-series-stream.util.d.ts +86 -0
- package/dist/utility/wrun/wrun-series-stream.util.js +537 -0
- package/dist/utility/wrun/wrun-sha256.leaf.d.ts +13 -0
- package/dist/utility/wrun/wrun-sha256.leaf.js +84 -0
- package/dist/utility/wrun/wrun-sheet-remembered.util.d.ts +21 -0
- package/dist/utility/wrun/wrun-sheet-remembered.util.js +36 -0
- package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.d.ts +7 -0
- package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.js +12 -0
- package/dist/utility/wrun/wrun-socket-row-source.js +4 -2
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +175 -3
- package/dist/utility/wrun/wrun-source-rows.util.js +294 -8
- package/dist/utility/wrun/wrun-stats-strip.util.d.ts +46 -0
- package/dist/utility/wrun/wrun-stats-strip.util.js +87 -0
- package/dist/utility/wrun/wrun-table-chrome.util.d.ts +163 -0
- package/dist/utility/wrun/wrun-table-chrome.util.js +557 -0
- package/dist/utility/wrun/wrun-text-params.util.d.ts +11 -6
- package/dist/utility/wrun/wrun-text-params.util.js +19 -30
- package/dist/utility/wrun/wrun-transient-rerun.util.d.ts +64 -0
- package/dist/utility/wrun/wrun-transient-rerun.util.js +317 -0
- package/dist/utility/wrun/wrun-twin-lookback.util.d.ts +10 -0
- package/dist/utility/wrun/wrun-twin-lookback.util.js +43 -0
- package/dist/utility/wrun/wrun-warmup-head-store.util.d.ts +41 -0
- package/dist/utility/wrun/wrun-warmup-head-store.util.js +120 -0
- package/dist/utility/wrun-alert-params.leaf.d.ts +24 -0
- package/dist/utility/wrun-alert-params.leaf.js +24 -0
- package/dist/utils/replay/replay-buffer-math.d.ts +148 -0
- package/dist/utils/replay/replay-buffer-math.js +684 -0
- package/dist/workers/wrun/wrun-abi-host.d.ts +203 -0
- package/dist/workers/wrun/wrun-abi-host.js +1220 -0
- package/dist/workers/wrun/wrun-engine-handler.d.ts +20 -0
- package/dist/workers/wrun/wrun-engine-handler.js +380 -0
- package/package.json +3 -3
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
// Replay fidelity ladder: measured retention and request-shaping constants.
|
|
2
|
+
import { RAIL_TFS, RAIL_TF_BOOK_EDGE_SEC, RAIL_TF_BUCKET_SEC, RAIL_TF_EDGE_SEC, REPLAY_LADDER_EDGES_SEC, REPLAY_STEP_TFS, REPLAY_STEP_TF_BOOK_EDGE_SEC, REPLAY_STEP_TF_BUCKET_SEC, REPLAY_STEP_TF_EDGE_SEC, } from '../constants/replay-ladder.leaf.js';
|
|
3
|
+
import { FEATURE_LIMITS, GATEWAY_TIER_MAX_BARS } from '../constants/feature-limits.constants.js';
|
|
4
|
+
import { checkIsBlockedOn1s } from '../utility/chart/index-mode.util.js';
|
|
5
|
+
import { standardIntervalMsAtOrBelow } from '../utility/chart/interval-registry.util.js';
|
|
6
|
+
const orderedCoveringTfs = ['1m', '5m', '15m', '1h', '1d'];
|
|
7
|
+
const tickResolution = { kind: 'tick' };
|
|
8
|
+
const weekMs = 7 * RAIL_TF_BUCKET_SEC['1d'] * 1000;
|
|
9
|
+
const replayResolutionByChartIntervalMs = new Map([
|
|
10
|
+
[bucketMsForTf('1m'), [tickResolution, { kind: 'bar', tf: '1m' }]],
|
|
11
|
+
[bucketMsForTf('5m'), [tickResolution, { kind: 'bar', tf: '1m' }, { kind: 'bar', tf: '5m' }]],
|
|
12
|
+
[
|
|
13
|
+
bucketMsForTf('15m'),
|
|
14
|
+
[tickResolution, { kind: 'bar', tf: '1m' }, { kind: 'bar', tf: '5m' }, { kind: 'bar', tf: '15m' }],
|
|
15
|
+
],
|
|
16
|
+
[
|
|
17
|
+
bucketMsForTf('30m'),
|
|
18
|
+
[
|
|
19
|
+
tickResolution,
|
|
20
|
+
{ kind: 'bar', tf: '1m' },
|
|
21
|
+
{ kind: 'bar', tf: '5m' },
|
|
22
|
+
{ kind: 'bar', tf: '10m' },
|
|
23
|
+
{ kind: 'bar', tf: '15m' },
|
|
24
|
+
{ kind: 'bar', tf: '30m' },
|
|
25
|
+
],
|
|
26
|
+
],
|
|
27
|
+
[
|
|
28
|
+
bucketMsForTf('1h'),
|
|
29
|
+
[
|
|
30
|
+
tickResolution,
|
|
31
|
+
{ kind: 'bar', tf: '1m' },
|
|
32
|
+
{ kind: 'bar', tf: '5m' },
|
|
33
|
+
{ kind: 'bar', tf: '10m' },
|
|
34
|
+
{ kind: 'bar', tf: '15m' },
|
|
35
|
+
{ kind: 'bar', tf: '30m' },
|
|
36
|
+
{ kind: 'bar', tf: '1h' },
|
|
37
|
+
],
|
|
38
|
+
],
|
|
39
|
+
[
|
|
40
|
+
bucketMsForTf('4h'),
|
|
41
|
+
[
|
|
42
|
+
tickResolution,
|
|
43
|
+
{ kind: 'bar', tf: '1m' },
|
|
44
|
+
{ kind: 'bar', tf: '5m' },
|
|
45
|
+
{ kind: 'bar', tf: '10m' },
|
|
46
|
+
{ kind: 'bar', tf: '15m' },
|
|
47
|
+
{ kind: 'bar', tf: '30m' },
|
|
48
|
+
{ kind: 'bar', tf: '1h' },
|
|
49
|
+
{ kind: 'bar', tf: '2h' },
|
|
50
|
+
{ kind: 'bar', tf: '4h' },
|
|
51
|
+
],
|
|
52
|
+
],
|
|
53
|
+
[
|
|
54
|
+
bucketMsForTf('1d'),
|
|
55
|
+
[
|
|
56
|
+
{ kind: 'bar', tf: '1h' },
|
|
57
|
+
{ kind: 'bar', tf: '2h' },
|
|
58
|
+
{ kind: 'bar', tf: '3h' },
|
|
59
|
+
{ kind: 'bar', tf: '4h' },
|
|
60
|
+
{ kind: 'bar', tf: '1d' },
|
|
61
|
+
],
|
|
62
|
+
],
|
|
63
|
+
[weekMs, [{ kind: 'bar', tf: '1d' }]],
|
|
64
|
+
]);
|
|
65
|
+
export function bucketMsForTf(tf) {
|
|
66
|
+
return REPLAY_STEP_TF_BUCKET_SEC[tf] * 1000;
|
|
67
|
+
}
|
|
68
|
+
export function nearestReplayStepTfForIntervalMs(chartIntervalMs) {
|
|
69
|
+
const targetMs = Number.isFinite(chartIntervalMs) && chartIntervalMs > 0 ? chartIntervalMs : bucketMsForTf('1m');
|
|
70
|
+
let nearest = REPLAY_STEP_TFS[0];
|
|
71
|
+
let nearestDistanceMs = Math.abs(bucketMsForTf(nearest) - targetMs);
|
|
72
|
+
for (const tf of REPLAY_STEP_TFS.slice(1)) {
|
|
73
|
+
const distanceMs = Math.abs(bucketMsForTf(tf) - targetMs);
|
|
74
|
+
if (distanceMs < nearestDistanceMs) {
|
|
75
|
+
nearest = tf;
|
|
76
|
+
nearestDistanceMs = distanceMs;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return nearest;
|
|
80
|
+
}
|
|
81
|
+
/** A chart shorter than a minute (1s 5s 15s 30s): only the tick lane is fine enough to form its bars. */
|
|
82
|
+
function isSubMinuteChartIntervalMs(chartIntervalMs) {
|
|
83
|
+
return chartIntervalMs > 0 && chartIntervalMs < bucketMsForTf('1m');
|
|
84
|
+
}
|
|
85
|
+
export function replayChartIntervalBookEdgeSec(chartIntervalMs) {
|
|
86
|
+
// A sub-minute chart replays on the tick lane, so its book is the 1s one,
|
|
87
|
+
// not the nearest bar step's (1m).
|
|
88
|
+
if (isSubMinuteChartIntervalMs(chartIntervalMs))
|
|
89
|
+
return replayResolutionBookEdgeSec(tickResolution);
|
|
90
|
+
// Nearest-by-distance would give a 4m chart the 5m book edge; a custom
|
|
91
|
+
// interval's book comes from its standard at or below.
|
|
92
|
+
return REPLAY_STEP_TF_BOOK_EDGE_SEC[nearestReplayStepTfForIntervalMs(standardIntervalMsAtOrBelow(chartIntervalMs))];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* How far back the chart's own bars are retained, in seconds: the deepest start
|
|
96
|
+
* replay can make on this chart. The main candles always come at the chart
|
|
97
|
+
* interval whatever the replay step, so a coarser step cannot reach past this.
|
|
98
|
+
* Sub-minute charts form on the tick lane; a custom interval's bars come from
|
|
99
|
+
* its standard at or below (the same mapping as the book edge above).
|
|
100
|
+
*/
|
|
101
|
+
export function replayChartIntervalEdgeSec(chartIntervalMs) {
|
|
102
|
+
if (isSubMinuteChartIntervalMs(chartIntervalMs))
|
|
103
|
+
return REPLAY_LADDER_EDGES_SEC.tick;
|
|
104
|
+
return REPLAY_STEP_TF_EDGE_SEC[nearestReplayStepTfForIntervalMs(standardIntervalMsAtOrBelow(chartIntervalMs))];
|
|
105
|
+
}
|
|
106
|
+
function copyReplayResolution(resolution) {
|
|
107
|
+
return resolution.kind === 'tick' ? { kind: 'tick' } : { kind: 'bar', tf: resolution.tf };
|
|
108
|
+
}
|
|
109
|
+
function sameReplayResolution(left, right) {
|
|
110
|
+
if (left.kind !== right.kind)
|
|
111
|
+
return false;
|
|
112
|
+
if (left.kind === 'tick')
|
|
113
|
+
return true;
|
|
114
|
+
return right.kind === 'bar' && left.tf === right.tf;
|
|
115
|
+
}
|
|
116
|
+
function appendReplayResolution(candidates, resolution) {
|
|
117
|
+
if (!candidates.some((candidate) => sameReplayResolution(candidate, resolution))) {
|
|
118
|
+
candidates.push(resolution);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export function replayResolutionCandidatesForChartInterval(chartIntervalMs) {
|
|
122
|
+
const exact = replayResolutionByChartIntervalMs.get(chartIntervalMs);
|
|
123
|
+
if (exact)
|
|
124
|
+
return exact.map(copyReplayResolution);
|
|
125
|
+
const candidates = [];
|
|
126
|
+
if (chartIntervalMs <= bucketMsForTf('4h'))
|
|
127
|
+
candidates.push({ kind: 'tick' });
|
|
128
|
+
candidates.push(...REPLAY_STEP_TFS.filter((tf) => {
|
|
129
|
+
const stepMs = bucketMsForTf(tf);
|
|
130
|
+
return stepMs <= chartIntervalMs && chartIntervalMs % stepMs === 0;
|
|
131
|
+
}).map((tf) => ({ kind: 'bar', tf })));
|
|
132
|
+
return candidates;
|
|
133
|
+
}
|
|
134
|
+
function replayResolutionFallbackCandidatesForChartInterval(chartIntervalMs) {
|
|
135
|
+
const candidates = replayResolutionCandidatesForChartInterval(chartIntervalMs);
|
|
136
|
+
for (const tf of REPLAY_STEP_TFS) {
|
|
137
|
+
const stepMs = bucketMsForTf(tf);
|
|
138
|
+
if (stepMs > chartIntervalMs)
|
|
139
|
+
appendReplayResolution(candidates, { kind: 'bar', tf });
|
|
140
|
+
}
|
|
141
|
+
return candidates;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The first offered step at least as coarse as the chart interval, so it plays
|
|
145
|
+
* whole chart bars: the chart's own step when offered (`available` runs fine to
|
|
146
|
+
* coarse). Null when every offered step is finer than the chart interval.
|
|
147
|
+
*/
|
|
148
|
+
export function firstCoarserAvailableResolution(available, chartIntervalMs) {
|
|
149
|
+
return (available.find((resolution) => {
|
|
150
|
+
const stepMs = resolution.kind === 'tick' ? 1000 : bucketMsForTf(resolution.tf);
|
|
151
|
+
return stepMs >= chartIntervalMs;
|
|
152
|
+
}) ?? null);
|
|
153
|
+
}
|
|
154
|
+
function replayResolutionForChartInterval(chartIntervalMs) {
|
|
155
|
+
// 5s 15s 30s form their bars from the tick lane like 1s: no bar step is finer than 1m.
|
|
156
|
+
if (isSubMinuteChartIntervalMs(chartIntervalMs))
|
|
157
|
+
return { kind: 'tick' };
|
|
158
|
+
const tf = REPLAY_STEP_TFS.find((candidate) => bucketMsForTf(candidate) === chartIntervalMs);
|
|
159
|
+
return tf ? { kind: 'bar', tf } : null;
|
|
160
|
+
}
|
|
161
|
+
export function tfLabelForMs(ms) {
|
|
162
|
+
const tf = REPLAY_STEP_TFS.find((candidate) => bucketMsForTf(candidate) === ms);
|
|
163
|
+
if (tf)
|
|
164
|
+
return tf;
|
|
165
|
+
const wholeMs = Math.max(1, Math.floor(ms));
|
|
166
|
+
const dayMs = 24 * 60 * 60 * 1000;
|
|
167
|
+
const hourMs = 60 * 60 * 1000;
|
|
168
|
+
const minuteMs = 60 * 1000;
|
|
169
|
+
if (wholeMs % dayMs === 0)
|
|
170
|
+
return `${wholeMs / dayMs}d`;
|
|
171
|
+
if (wholeMs % hourMs === 0)
|
|
172
|
+
return `${wholeMs / hourMs}h`;
|
|
173
|
+
if (wholeMs % minuteMs === 0)
|
|
174
|
+
return `${wholeMs / minuteMs}m`;
|
|
175
|
+
if (wholeMs % 1000 === 0)
|
|
176
|
+
return `${wholeMs / 1000}s`;
|
|
177
|
+
return `${wholeMs}ms`;
|
|
178
|
+
}
|
|
179
|
+
export function railTfAtLeastMs(ms) {
|
|
180
|
+
const minMs = Math.max(0, ms);
|
|
181
|
+
return RAIL_TFS.find((tf) => bucketMsForTf(tf) >= minMs) ?? '1d';
|
|
182
|
+
}
|
|
183
|
+
export function coarseRailTfForAge(ageSec, userIntervalMs) {
|
|
184
|
+
void userIntervalMs;
|
|
185
|
+
const finest = finestRailCoveringAge(ageSec) ?? '1d';
|
|
186
|
+
return finest;
|
|
187
|
+
}
|
|
188
|
+
export function replayResolutionStepMs(resolution) {
|
|
189
|
+
return resolution.kind === 'tick' ? 1000 : bucketMsForTf(resolution.tf);
|
|
190
|
+
}
|
|
191
|
+
export function replayResolutionFitsChartInterval(resolution, chartIntervalMs) {
|
|
192
|
+
const stepMs = replayResolutionStepMs(resolution);
|
|
193
|
+
return stepMs <= chartIntervalMs && chartIntervalMs % stepMs === 0;
|
|
194
|
+
}
|
|
195
|
+
export function replayResolutionBookEdgeSec(resolution) {
|
|
196
|
+
return resolution.kind === 'tick' ? REPLAY_LADDER_EDGES_SEC.tick : REPLAY_STEP_TF_BOOK_EDGE_SEC[resolution.tf];
|
|
197
|
+
}
|
|
198
|
+
// The interval label of the request a resolution actually sends. Synthetic
|
|
199
|
+
// steps fetch a retained source rail (10m -> 5m, 2h/3h -> 1h), and the
|
|
200
|
+
// gateway's tier wall is measured in bars OF THE REQUESTED INTERVAL, so tier
|
|
201
|
+
// reach must be computed on this label, not on the replay step itself.
|
|
202
|
+
function replayResolutionRequestIntervalLabel(resolution) {
|
|
203
|
+
if (resolution.kind === 'tick')
|
|
204
|
+
return '1s';
|
|
205
|
+
if (resolution.tf === '10m')
|
|
206
|
+
return '5m';
|
|
207
|
+
if (resolution.tf === '2h' || resolution.tf === '3h')
|
|
208
|
+
return '1h';
|
|
209
|
+
return resolution.tf;
|
|
210
|
+
}
|
|
211
|
+
export function gatewayTierMaxBars(tier, resolution) {
|
|
212
|
+
const limits = GATEWAY_TIER_MAX_BARS[tier];
|
|
213
|
+
if (!limits)
|
|
214
|
+
return Number.POSITIVE_INFINITY;
|
|
215
|
+
const label = replayResolutionRequestIntervalLabel(resolution);
|
|
216
|
+
return limits.intervals[label] ?? limits.default;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Whether upgrading would move a replay reach wall at `resolution`: only a
|
|
220
|
+
* free session is ever sold Plus, and only while Plus reaches deeper, by plan
|
|
221
|
+
* reach or by the gateway bar limit. Free got both on 2026-09-29, so a free
|
|
222
|
+
* wall now explains itself the way a paid one does.
|
|
223
|
+
*/
|
|
224
|
+
export function replayPlusReachesFurther(tier, reachBars, resolution) {
|
|
225
|
+
if (tier !== 'free')
|
|
226
|
+
return false;
|
|
227
|
+
return (FEATURE_LIMITS.replayReachBars.plus > reachBars ||
|
|
228
|
+
gatewayTierMaxBars('plus', resolution) > gatewayTierMaxBars('free', resolution));
|
|
229
|
+
}
|
|
230
|
+
export function gatewayTierReachMs(tier, resolution) {
|
|
231
|
+
const label = replayResolutionRequestIntervalLabel(resolution);
|
|
232
|
+
const intervalMs = label === '1s' ? 1000 : bucketMsForTf(label);
|
|
233
|
+
return gatewayTierMaxBars(tier, resolution) * intervalMs;
|
|
234
|
+
}
|
|
235
|
+
function replayReachWallFromTerms(domain, terms, maxBars, barAnchor) {
|
|
236
|
+
const entitlementReachMs = Math.min(terms.planReachMs, terms.gatewayReachMs);
|
|
237
|
+
let wallMs = domain.endMs - Math.min(terms.backendReachMs, entitlementReachMs);
|
|
238
|
+
if (barAnchor && Number.isFinite(barAnchor.lastTradedBarMs)) {
|
|
239
|
+
const timestamps = barAnchor.rowTimestamps;
|
|
240
|
+
const barTrueWallMs = timestamps !== undefined && Number.isFinite(maxBars) && maxBars >= 1 && timestamps.length >= maxBars
|
|
241
|
+
? Number(timestamps[timestamps.length - maxBars])
|
|
242
|
+
: Number.NEGATIVE_INFINITY;
|
|
243
|
+
// Bar-true when enough real rows are loaded; otherwise the entitlement
|
|
244
|
+
// reach counts back from the last traded bar (a floor: the wall can never
|
|
245
|
+
// land past the newest bar that exists). Retention still binds below.
|
|
246
|
+
const anchoredWallMs = Number.isFinite(barTrueWallMs)
|
|
247
|
+
? barTrueWallMs
|
|
248
|
+
: barAnchor.lastTradedBarMs - entitlementReachMs;
|
|
249
|
+
wallMs = Math.min(wallMs, Math.max(domain.endMs - terms.backendReachMs, anchoredWallMs));
|
|
250
|
+
}
|
|
251
|
+
return Math.max(domain.startMs, wallMs);
|
|
252
|
+
}
|
|
253
|
+
// The product cap counts CHART bars when the chart interval is known: "500
|
|
254
|
+
// replay bars" must mean 500 candles regardless of how fine the forming step
|
|
255
|
+
// is, otherwise a finer auto step would silently shrink the free reach.
|
|
256
|
+
function replayReachTerms(resolution, maxBars, tier, chartIntervalMs) {
|
|
257
|
+
return {
|
|
258
|
+
backendReachMs: (resolution.kind === 'tick' ? REPLAY_LADDER_EDGES_SEC.tick : REPLAY_STEP_TF_EDGE_SEC[resolution.tf]) * 1000,
|
|
259
|
+
planReachMs: (chartIntervalMs ?? replayResolutionStepMs(resolution)) * maxBars,
|
|
260
|
+
gatewayReachMs: tier === undefined ? Number.POSITIVE_INFINITY : gatewayTierReachMs(tier, resolution),
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
/** Reach of one resolution option under plan and gateway walls, in ms. */
|
|
264
|
+
export function replayResolutionTierReachMs(resolution, maxBars, tier, chartIntervalMs) {
|
|
265
|
+
const terms = replayReachTerms(resolution, maxBars, tier, chartIntervalMs);
|
|
266
|
+
return Math.min(terms.planReachMs, terms.gatewayReachMs);
|
|
267
|
+
}
|
|
268
|
+
// Retention wins ties deliberately: a plan or gateway wall that coincides with
|
|
269
|
+
// the backend edge is not presented as a lock, it is simply where data ends.
|
|
270
|
+
function replayReachLimitedBy(terms) {
|
|
271
|
+
const reachMs = Math.min(terms.backendReachMs, terms.planReachMs, terms.gatewayReachMs);
|
|
272
|
+
if (terms.backendReachMs <= reachMs)
|
|
273
|
+
return 'retention';
|
|
274
|
+
return terms.planReachMs <= terms.gatewayReachMs ? 'plan' : 'gateway';
|
|
275
|
+
}
|
|
276
|
+
export function replayReachWallMs(domain, resolution, maxBars, tier, chartIntervalMs, barAnchor) {
|
|
277
|
+
const terms = replayReachTerms(resolution, maxBars, tier, chartIntervalMs);
|
|
278
|
+
return replayReachWallFromTerms(domain, terms, maxBars, barAnchor);
|
|
279
|
+
}
|
|
280
|
+
export function clampReplayReach(requestedMs, domain, resolution, maxBars, intent, tier, chartIntervalMs, barAnchor) {
|
|
281
|
+
const terms = replayReachTerms(resolution, maxBars, tier, chartIntervalMs);
|
|
282
|
+
const wallMs = replayReachWallFromTerms(domain, terms, maxBars, barAnchor);
|
|
283
|
+
const limitedBy = replayReachLimitedBy(terms);
|
|
284
|
+
const exempt = intent === 'warmup' || intent === 'forward';
|
|
285
|
+
const targetMs = exempt ? requestedMs : Math.max(requestedMs, wallMs);
|
|
286
|
+
return {
|
|
287
|
+
requestedMs,
|
|
288
|
+
targetMs,
|
|
289
|
+
wallMs,
|
|
290
|
+
clamped: targetMs !== requestedMs,
|
|
291
|
+
limited: limitedBy !== 'retention',
|
|
292
|
+
limitedBy,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
export function reconcileReplayResolution(ageSec, chartIntervalMs, exchange) {
|
|
296
|
+
const age = Math.max(0, ageSec);
|
|
297
|
+
const playbackTf = coarseRailTfForAge(age, chartIntervalMs);
|
|
298
|
+
const tickAvailable = age <= REPLAY_LADDER_EDGES_SEC.tick && !checkIsBlockedOn1s(exchange);
|
|
299
|
+
const candidates = replayResolutionFallbackCandidatesForChartInterval(chartIntervalMs);
|
|
300
|
+
const chartResolution = replayResolutionForChartInterval(chartIntervalMs);
|
|
301
|
+
const available = candidates.filter((resolution) => resolution.kind === 'tick' ? tickAvailable : REPLAY_STEP_TF_EDGE_SEC[resolution.tf] >= age);
|
|
302
|
+
// Callers detect "replay unavailable" by `available.length === 0`;
|
|
303
|
+
// autoSelect/playbackTf remain a stable fallback and must be ignored.
|
|
304
|
+
if (available.length === 0) {
|
|
305
|
+
return {
|
|
306
|
+
available: [],
|
|
307
|
+
autoSelect: { kind: 'bar', tf: playbackTf },
|
|
308
|
+
playbackTf,
|
|
309
|
+
bookOk: false,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
const autoSelect = pickAutoReplayResolution(available, chartIntervalMs, chartResolution);
|
|
313
|
+
return {
|
|
314
|
+
available,
|
|
315
|
+
autoSelect,
|
|
316
|
+
playbackTf,
|
|
317
|
+
bookOk: age <= replayResolutionBookEdgeSec(autoSelect),
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
// Auto favors a finer retained bar step so default playback FORMS candles
|
|
321
|
+
// instead of popping whole bars: the finest fitting bar step no finer than
|
|
322
|
+
// chartInterval/60, i.e. 5-60 forming sub-steps per bar (15m charts step at
|
|
323
|
+
// 1m, 4h at 5m, 1d at 1h). Tick is never auto-selected: it is plan- and
|
|
324
|
+
// entitlement-gated and far heavier, so it stays an explicit user choice.
|
|
325
|
+
// Falls back to the chart-interval step, then to the first coarser retained
|
|
326
|
+
// step at depths where nothing finer survives.
|
|
327
|
+
function pickAutoReplayResolution(available, chartIntervalMs, chartResolution) {
|
|
328
|
+
const floorMs = chartIntervalMs / 60;
|
|
329
|
+
const formingSteps = available
|
|
330
|
+
.filter((resolution) => resolution.kind === 'bar')
|
|
331
|
+
.filter((resolution) => {
|
|
332
|
+
const stepMs = bucketMsForTf(resolution.tf);
|
|
333
|
+
return stepMs < chartIntervalMs && stepMs >= floorMs && chartIntervalMs % stepMs === 0;
|
|
334
|
+
})
|
|
335
|
+
.sort((left, right) => bucketMsForTf(left.tf) - bucketMsForTf(right.tf));
|
|
336
|
+
if (formingSteps.length)
|
|
337
|
+
return formingSteps[0];
|
|
338
|
+
if (chartResolution && available.some((resolution) => sameReplayResolution(resolution, chartResolution))) {
|
|
339
|
+
return chartResolution;
|
|
340
|
+
}
|
|
341
|
+
return firstCoarserAvailableResolution(available, chartIntervalMs) ?? available[0];
|
|
342
|
+
}
|
|
343
|
+
export function displayLaneForAge(ageSec, userIntervalMs) {
|
|
344
|
+
const age = Math.max(0, ageSec);
|
|
345
|
+
if (age <= REPLAY_LADDER_EDGES_SEC.tick) {
|
|
346
|
+
return { mode: 'tick', tf: 'tick', tfMs: userIntervalMs, hasBook: true, bookTf: '1m' };
|
|
347
|
+
}
|
|
348
|
+
const tf = coarseRailTfForAge(age, userIntervalMs);
|
|
349
|
+
return {
|
|
350
|
+
mode: 'coarse',
|
|
351
|
+
tf,
|
|
352
|
+
tfMs: bucketMsForTf(tf),
|
|
353
|
+
hasBook: age <= RAIL_TF_BOOK_EDGE_SEC[tf],
|
|
354
|
+
bookTf: tf,
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
export function finestRailCoveringAge(ageSec) {
|
|
358
|
+
const age = Math.max(0, ageSec);
|
|
359
|
+
for (const tf of orderedCoveringTfs) {
|
|
360
|
+
if (age <= RAIL_TF_EDGE_SEC[tf])
|
|
361
|
+
return tf;
|
|
362
|
+
}
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
export function laneForAge(ageSec) {
|
|
366
|
+
const age = Math.max(0, ageSec);
|
|
367
|
+
if (age <= REPLAY_LADDER_EDGES_SEC.tick) {
|
|
368
|
+
return { kind: 'tick', tf: 'tick', bucketMs: 1000, hasBook: true };
|
|
369
|
+
}
|
|
370
|
+
const tf = finestRailCoveringAge(age) ?? '1d';
|
|
371
|
+
return {
|
|
372
|
+
kind: 'bars',
|
|
373
|
+
tf,
|
|
374
|
+
bucketMs: bucketMsForTf(tf),
|
|
375
|
+
hasBook: age <= RAIL_TF_BOOK_EDGE_SEC[tf],
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
export function railTfsFor(domain) {
|
|
379
|
+
const [youngestAge, oldestAge] = typeof domain === 'number'
|
|
380
|
+
? [0, Math.max(0, domain)]
|
|
381
|
+
: [Math.max(0, domain.nowSec - (domain.toSec ?? domain.nowSec)), Math.max(0, domain.nowSec - domain.fromSec)];
|
|
382
|
+
const lo = Math.min(youngestAge, oldestAge);
|
|
383
|
+
const hi = Math.max(youngestAge, oldestAge);
|
|
384
|
+
return orderedCoveringTfs.filter((tf, i) => {
|
|
385
|
+
const prevEdge = i === 0 ? 0 : RAIL_TF_EDGE_SEC[orderedCoveringTfs[i - 1]];
|
|
386
|
+
return hi > prevEdge && lo <= RAIL_TF_EDGE_SEC[tf];
|
|
387
|
+
});
|
|
388
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server time for every thread: the device clock is never the server's "now".
|
|
3
|
+
*
|
|
4
|
+
* About 1.3% of devices run a clock more than 30 s ahead (18 in 8,196 more
|
|
5
|
+
* than 30 min). A window sent to the gateway, or a "now" compared with server
|
|
6
|
+
* timestamps, read off such a clock asks the future: a 30 s trailing window
|
|
7
|
+
* an hour ahead answers 0 rows and the pane says "No data in range". Anything
|
|
8
|
+
* compared with server time reads `serverNowMs()`; a duration between two
|
|
9
|
+
* device events reads `performance.now()`; a device wall-clock stamp that
|
|
10
|
+
* must survive a reload (an IndexedDB TTL) reads `deviceNowMs()`, so every
|
|
11
|
+
* device-clock read is a decision (docs/features/data/loading/architecture.md, "Server time").
|
|
12
|
+
* The server clock steps when a calibration lands (the first response, a
|
|
13
|
+
* device clock jump), so a duration never subtracts two server-clock reads.
|
|
14
|
+
*
|
|
15
|
+
* The offset (server minus client, ms) comes from responses the app already
|
|
16
|
+
* receives: no request of its own. Every API response carries a `Date`
|
|
17
|
+
* header; the app calls the API on its own origin, so the header is readable.
|
|
18
|
+
* HttpService and the refresh-token call hand each response's header here
|
|
19
|
+
* with the client time it arrived. The header floors to the second and is
|
|
20
|
+
* stamped before the response travels, and the arrival is stamped after the
|
|
21
|
+
* body landed and the continuation ran, so each sample is a LOWER bound of
|
|
22
|
+
* the true offset (by up to about one second plus transit, seconds more
|
|
23
|
+
* behind a slow response or a busy main thread): the largest sample is the
|
|
24
|
+
* tightest. A sample more than `JUMP_MS` above the estimate is a device clock
|
|
25
|
+
* that went back, followed at once (a delay only lowers a sample); one more
|
|
26
|
+
* than `JUMP_MS` below it is a late sample or a device clock that jumped
|
|
27
|
+
* ahead, held until a second sample confirms it. An estimate is stored only
|
|
28
|
+
* once a second sample agrees with it.
|
|
29
|
+
*
|
|
30
|
+
* Not the access token: internal roles get a 1-day token while the login and
|
|
31
|
+
* refresh responses report the 15-minute lifetime, so `exp` against the
|
|
32
|
+
* client's `accessExpiresAt` reads a day of fake skew for those accounts.
|
|
33
|
+
*
|
|
34
|
+
* Threads: the main thread samples responses and applies a correction (the
|
|
35
|
+
* offset outside the deadband, else 0) that moves on a change of
|
|
36
|
+
* `APPLY_STEP_MS` or more and on every deadband crossing. The data worker
|
|
37
|
+
* receives exactly that correction through the WorkerManager mirror
|
|
38
|
+
* (`setServerClockOffsetMs`) on every move and in each worker's bootstrap,
|
|
39
|
+
* so `serverNowMs()` reads the same clock in both.
|
|
40
|
+
*
|
|
41
|
+
* Boot: nothing awaits an API response before the first chart request, so the
|
|
42
|
+
* last measured offset is kept in localStorage (a device's skew is stable for
|
|
43
|
+
* days) and serves until this page measures one. It is rewritten at least
|
|
44
|
+
* daily while it holds, so a stable skew never ages out.
|
|
45
|
+
*/
|
|
46
|
+
/** An offset this close to zero reads as zero: a synced device keeps the device clock exactly. */
|
|
47
|
+
export declare const SERVER_CLOCK_DEADBAND_MS = 2000;
|
|
48
|
+
export declare const SERVER_CLOCK_STORAGE_KEY = "kiyo:server-clock-offset";
|
|
49
|
+
/** Record one response's `Date` header against the client time it arrived. */
|
|
50
|
+
export declare function noteServerDateHeader(dateHeader: unknown, receivedAtMs: number): void;
|
|
51
|
+
/**
|
|
52
|
+
* The worker side of the mirror: the correction the main thread applies (null when it has none), applied exactly. A
|
|
53
|
+
* worker never samples a response itself, so this is its only source.
|
|
54
|
+
*/
|
|
55
|
+
export declare function setServerClockOffsetMs(correctionMs: number | null): void;
|
|
56
|
+
/**
|
|
57
|
+
* Server minus client clock (ms) measured in this session, or null when no response carried a usable `Date`
|
|
58
|
+
* (a dev build pointed at a cross-origin API never exposes it). A label that must not guess reads this and
|
|
59
|
+
* treats null as "no server clock" (the CME late-feed label).
|
|
60
|
+
*/
|
|
61
|
+
export declare function serverClockOffsetMs(): number | null;
|
|
62
|
+
/** The offset before the deadband: this session's, else the last session's, else null. */
|
|
63
|
+
export declare function effectiveServerClockOffsetMs(): number | null;
|
|
64
|
+
/**
|
|
65
|
+
* The correction `serverNowMs` applies to the device clock (ms): the offset outside the deadband, else 0; null when
|
|
66
|
+
* none is known. The WorkerManager mirror carries exactly this, so both threads apply the same.
|
|
67
|
+
*/
|
|
68
|
+
export declare function serverClockCorrectionMs(): number | null;
|
|
69
|
+
/** The server's "now" in ms: the device clock corrected by the offset (exactly the device clock when synced). */
|
|
70
|
+
export declare function serverNowMs(): number;
|
|
71
|
+
/** The server's "now" in whole unix seconds. */
|
|
72
|
+
export declare function serverNowS(): number;
|
|
73
|
+
/**
|
|
74
|
+
* The device wall clock, named: for a stamp that must survive a reload and is only ever compared with other device
|
|
75
|
+
* stamps (an IndexedDB TTL). Never for anything compared with server time.
|
|
76
|
+
*/
|
|
77
|
+
export declare function deviceNowMs(): number;
|
|
78
|
+
/** Called with the applied correction whenever it moves (the WorkerManager mirror). Returns the unsubscribe. */
|
|
79
|
+
export declare function onServerClockChange(listener: (correctionMs: number | null) => void): () => void;
|
|
80
|
+
/** Specs only: forget every observation, the stored offset and the listeners. */
|
|
81
|
+
export declare function resetServerClockForTests(): void;
|