@orangecharts/wrun-chart-host 0.11.1 → 0.14.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.
Files changed (307) hide show
  1. package/README.md +1 -0
  2. package/dist/constants/feature-flags.constants.d.ts +3 -4
  3. package/dist/constants/feature-flags.constants.js +34 -52
  4. package/dist/constants/feature-limits.constants.d.ts +1 -1
  5. package/dist/constants/feature-limits.constants.js +5 -4
  6. package/dist/constants/interval.constants.d.ts +7 -0
  7. package/dist/constants/interval.constants.js +7 -0
  8. package/dist/constants/scriptEditor/cme-official-scripts.constants.d.ts +20 -149
  9. package/dist/constants/scriptEditor/cme-official-scripts.constants.js +20 -309
  10. package/dist/constants/stocks-compliance.constants.d.ts +15 -0
  11. package/dist/constants/stocks-compliance.constants.js +15 -0
  12. package/dist/host-env.d.ts +55 -3
  13. package/dist/host-env.js +6 -0
  14. package/dist/host-ports.types.d.ts +36 -3
  15. package/dist/index.d.ts +17 -0
  16. package/dist/index.js +18 -0
  17. package/dist/indicators/controls/tpo-session.util.d.ts +52 -12
  18. package/dist/indicators/controls/tpo-session.util.js +113 -16
  19. package/dist/instances/script-engine-worker-ohlcv-transfer.d.ts +6 -0
  20. package/dist/instances/script-engine-worker-ohlcv-transfer.js +16 -0
  21. package/dist/interfaces/cme-realtime.interface.d.ts +8 -0
  22. package/dist/interfaces/cme-realtime.interface.js +2 -1
  23. package/dist/interfaces/feed.interface.d.ts +15 -1
  24. package/dist/interfaces/replay.interface.d.ts +5 -0
  25. package/dist/interfaces/stocks-realtime.interface.d.ts +4 -3
  26. package/dist/interfaces/stocks-realtime.interface.js +5 -4
  27. package/dist/interfaces/wrun-runtime.interface.d.ts +97 -19
  28. package/dist/kscript-data/controls/live-ohlcv-merge.util.d.ts +17 -0
  29. package/dist/kscript-data/controls/live-ohlcv-merge.util.js +22 -0
  30. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +46 -40
  31. package/dist/kscript-data/controls/live-trades-merge.util.js +80 -107
  32. package/dist/market-data/billing.interface.d.ts +9 -1
  33. package/dist/market-data/venue.d.ts +1 -1
  34. package/dist/market-data/venues/index.d.ts +4 -4
  35. package/dist/market-data/venues/stocks.contract.copy.json +4 -4
  36. package/dist/market-data/venues/stocks.d.ts +4 -4
  37. package/dist/market-data/venues/stocks.js +15 -13
  38. package/dist/settings-templates/frvp-fields.d.ts +12 -1
  39. package/dist/settings-templates/frvp-fields.js +15 -4
  40. package/dist/settings-templates/index.js +12 -5
  41. package/dist/settings-templates/indicator-fields.js +28 -2
  42. package/dist/settings-templates/tool-rules.d.ts +17 -8
  43. package/dist/settings-templates/tool-rules.js +15 -8
  44. package/dist/settings-templates/tool-tables.generated.js +4 -2
  45. package/dist/utility/auth/server-clock.util.d.ts +3 -1
  46. package/dist/utility/auth/server-clock.util.js +3 -1
  47. package/dist/utility/chart/book-live-bucket.util.js +2 -2
  48. package/dist/utility/chart/cache-alignment.util.d.ts +15 -7
  49. package/dist/utility/chart/cache-alignment.util.js +14 -7
  50. package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +2 -0
  51. package/dist/utility/chart/chart-data-fetch-generation.util.js +16 -0
  52. package/dist/utility/chart/cme-session-bucket.util.d.ts +18 -75
  53. package/dist/utility/chart/cme-session-bucket.util.js +25 -332
  54. package/dist/utility/chart/continuous-contracts.util.js +6 -5
  55. package/dist/utility/chart/display-offset.leaf.d.ts +24 -0
  56. package/dist/utility/chart/display-offset.leaf.js +41 -0
  57. package/dist/utility/chart/effective-chart-session.util.d.ts +2 -1
  58. package/dist/utility/chart/effective-chart-session.util.js +13 -5
  59. package/dist/utility/chart/feed-interval.util.d.ts +6 -20
  60. package/dist/utility/chart/feed-interval.util.js +13 -22
  61. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +27 -7
  62. package/dist/utility/chart/fetch-dedupe-policy.util.js +86 -11
  63. package/dist/utility/chart/host-bar-placement.util.d.ts +7 -4
  64. package/dist/utility/chart/host-bar-placement.util.js +8 -2
  65. package/dist/utility/chart/indicator-inflight-registry.util.d.ts +32 -0
  66. package/dist/utility/chart/indicator-inflight-registry.util.js +52 -0
  67. package/dist/utility/chart/indicator-run-interval.util.d.ts +10 -4
  68. package/dist/utility/chart/indicator-run-interval.util.js +21 -12
  69. package/dist/utility/chart/interval-registry.util.d.ts +1 -1
  70. package/dist/utility/chart/interval-registry.util.js +1 -1
  71. package/dist/utility/chart/kscript-legend-entries.util.d.ts +12 -0
  72. package/dist/utility/chart/kscript-legend-entries.util.js +16 -0
  73. package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +1 -1
  74. package/dist/utility/chart/kscript-run-interval-projection.util.js +4 -2
  75. package/dist/utility/chart/kscript-venue-policy.util.d.ts +53 -62
  76. package/dist/utility/chart/kscript-venue-policy.util.js +85 -94
  77. package/dist/utility/chart/live-bucket.util.d.ts +39 -17
  78. package/dist/utility/chart/live-bucket.util.js +103 -57
  79. package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +58 -20
  80. package/dist/utility/chart/local-kscript-source-revalidation.util.js +98 -23
  81. package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +35 -11
  82. package/dist/utility/chart/local-kscript-warmup-depth.util.js +24 -3
  83. package/dist/utility/chart/market-session-schedule.util.d.ts +8 -0
  84. package/dist/utility/chart/market-session-schedule.util.js +39 -1
  85. package/dist/utility/chart/market-session.util.d.ts +136 -0
  86. package/dist/utility/chart/market-session.util.js +341 -0
  87. package/dist/utility/chart/om-panel.util.d.ts +5 -3
  88. package/dist/utility/chart/om-panel.util.js +42 -7
  89. package/dist/utility/chart/om-target.util.d.ts +14 -1
  90. package/dist/utility/chart/om-target.util.js +22 -5
  91. package/dist/utility/chart/opra-read-access.leaf.d.ts +16 -1
  92. package/dist/utility/chart/opra-read-access.leaf.js +22 -0
  93. package/dist/utility/chart/profile-row-height.util.d.ts +49 -16
  94. package/dist/utility/chart/profile-row-height.util.js +74 -37
  95. package/dist/utility/chart/rth-session.util.d.ts +55 -20
  96. package/dist/utility/chart/rth-session.util.js +94 -46
  97. package/dist/utility/chart/session-lattice.util.d.ts +150 -0
  98. package/dist/utility/chart/session-lattice.util.js +488 -0
  99. package/dist/utility/chart/trading-day.util.d.ts +40 -2
  100. package/dist/utility/chart/trading-day.util.js +84 -7
  101. package/dist/utility/chart/us-equities-session.util.d.ts +32 -11
  102. package/dist/utility/chart/us-equities-session.util.js +44 -15
  103. package/dist/utility/chart/window-geometry.leaf.d.ts +28 -7
  104. package/dist/utility/chart/window-geometry.leaf.js +57 -8
  105. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +21 -14
  106. package/dist/utility/chart/wrun-bar-session-facts.util.js +32 -38
  107. package/dist/utility/chart/wrun-run-result.util.d.ts +29 -12
  108. package/dist/utility/chart/wrun-run-result.util.js +89 -25
  109. package/dist/utility/common/time.util.js +5 -4
  110. package/dist/utility/market-events/earnings-scope.util.d.ts +10 -5
  111. package/dist/utility/market-events/earnings-scope.util.js +17 -9
  112. package/dist/utility/market-events/market-events.util.d.ts +14 -7
  113. package/dist/utility/market-events/market-events.util.js +30 -17
  114. package/dist/utility/number-format.util.d.ts +14 -21
  115. package/dist/utility/number-format.util.js +38 -24
  116. package/dist/utility/options/option-venue-disclosure.util.d.ts +40 -6
  117. package/dist/utility/options/option-venue-disclosure.util.js +71 -11
  118. package/dist/utility/options/option-venue.util.d.ts +1 -1
  119. package/dist/utility/options/option-venue.util.js +1 -1
  120. package/dist/utility/pool-symbol.leaf.d.ts +7 -0
  121. package/dist/utility/pool-symbol.leaf.js +50 -5
  122. package/dist/utility/stocks/stock-display.util.d.ts +15 -0
  123. package/dist/utility/stocks/stock-display.util.js +37 -0
  124. package/dist/utility/symbol-selection/contract-expiry.util.js +5 -4
  125. package/dist/utility/v2/gate-plane.util.d.ts +6 -0
  126. package/dist/utility/v2/gate-plane.util.js +11 -1
  127. package/dist/utility/v2/gate-session-latch.util.d.ts +1 -1
  128. package/dist/utility/v2/gate-session-latch.util.js +3 -3
  129. package/dist/utility/v2/governed-tier.leaf.d.ts +17 -16
  130. package/dist/utility/v2/governed-tier.leaf.js +17 -16
  131. package/dist/utility/v2/stocks-governed.util.d.ts +5 -0
  132. package/dist/utility/v2/stocks-governed.util.js +14 -0
  133. package/dist/utility/v2/v2-enums.leaf.d.ts +13 -0
  134. package/dist/utility/v2/v2-enums.leaf.js +458 -0
  135. package/dist/utility/wrun/derived-roots.leaf.d.ts +21 -1
  136. package/dist/utility/wrun/derived-roots.leaf.js +27 -1
  137. package/dist/utility/wrun/derived-roots.util.d.ts +44 -32
  138. package/dist/utility/wrun/derived-roots.util.js +97 -56
  139. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.d.ts +4 -3
  140. package/dist/utility/wrun/run-schedule/wrun-late-reads.util.js +4 -3
  141. package/dist/utility/wrun/sources/lanes/option_daily.d.ts +2 -1
  142. package/dist/utility/wrun/sources/lanes/option_daily.js +2 -1
  143. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +3 -0
  144. package/dist/utility/wrun/sources/lanes/options_flow.js +23 -5
  145. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +3 -4
  146. package/dist/utility/wrun/sources/row-lane-registry.js +9 -4
  147. package/dist/utility/wrun/sources/row-lanes/dark_pool.d.ts +19 -0
  148. package/dist/utility/wrun/sources/row-lanes/dark_pool.js +104 -0
  149. package/dist/utility/wrun/sources/row-lanes/index.js +2 -0
  150. package/dist/utility/wrun/sources/wrun-lane-fetch-abort.util.d.ts +20 -0
  151. package/dist/utility/wrun/sources/wrun-lane-fetch-abort.util.js +103 -0
  152. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +19 -2
  153. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +15 -13
  154. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +49 -23
  155. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +14 -9
  156. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +75 -27
  157. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +139 -82
  158. package/dist/utility/wrun/wrun-app-layer.leaf.d.ts +78 -0
  159. package/dist/utility/wrun/wrun-app-layer.leaf.js +89 -0
  160. package/dist/utility/wrun/wrun-bar-count.util.d.ts +11 -7
  161. package/dist/utility/wrun/wrun-bar-count.util.js +12 -8
  162. package/dist/utility/wrun/wrun-batched-kinds.leaf.d.ts +13 -0
  163. package/dist/utility/wrun/wrun-batched-kinds.leaf.js +18 -0
  164. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +41 -22
  165. package/dist/utility/wrun/wrun-batched-marks.util.js +255 -59
  166. package/dist/utility/wrun/wrun-batched-readout.util.d.ts +26 -19
  167. package/dist/utility/wrun/wrun-batched-readout.util.js +81 -27
  168. package/dist/utility/wrun/wrun-book-bands.leaf.d.ts +8 -0
  169. package/dist/utility/wrun/wrun-book-bands.leaf.js +7 -0
  170. package/dist/utility/wrun/wrun-candle-equal.leaf.d.ts +19 -0
  171. package/dist/utility/wrun/wrun-candle-equal.leaf.js +40 -0
  172. package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +4 -2
  173. package/dist/utility/wrun/wrun-canvases.util.js +7 -3
  174. package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +6 -3
  175. package/dist/utility/wrun/wrun-chart-context-names.util.js +8 -4
  176. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +47 -29
  177. package/dist/utility/wrun/wrun-chart-market-facts.util.js +201 -201
  178. package/dist/utility/wrun/wrun-child-overlay-id.util.js +2 -1
  179. package/dist/utility/wrun/wrun-cme-legs-note.util.d.ts +15 -0
  180. package/dist/utility/wrun/wrun-cme-legs-note.util.js +49 -0
  181. package/dist/utility/wrun/wrun-cme-root-specs.util.d.ts +38 -0
  182. package/dist/utility/wrun/wrun-cme-root-specs.util.js +81 -0
  183. package/dist/utility/wrun/wrun-coin-lane-live.util.js +3 -0
  184. package/dist/utility/wrun/wrun-color-settings.util.d.ts +6 -1
  185. package/dist/utility/wrun/wrun-color-settings.util.js +32 -7
  186. package/dist/utility/wrun/wrun-dark-pool.util.d.ts +50 -0
  187. package/dist/utility/wrun/wrun-dark-pool.util.js +127 -0
  188. package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +67 -12
  189. package/dist/utility/wrun/wrun-declared-warmup.util.js +165 -13
  190. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +18 -8
  191. package/dist/utility/wrun/wrun-draft-legend-note.util.js +57 -11
  192. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +14 -10
  193. package/dist/utility/wrun/wrun-draft-overlay.util.js +26 -14
  194. package/dist/utility/wrun/wrun-earnings-facts.util.js +3 -2
  195. package/dist/utility/wrun/wrun-etf-funds.util.d.ts +2 -0
  196. package/dist/utility/wrun/wrun-etf-funds.util.js +4 -0
  197. package/dist/utility/wrun/wrun-held-lanes.util.js +8 -2
  198. package/dist/utility/wrun/wrun-history-as-of.util.d.ts +77 -0
  199. package/dist/utility/wrun/wrun-history-as-of.util.js +108 -0
  200. package/dist/utility/wrun/wrun-host.service.d.ts +64 -14
  201. package/dist/utility/wrun/wrun-host.service.js +137 -27
  202. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +3 -3
  203. package/dist/utility/wrun/wrun-hosted-wire-caps.js +12 -2
  204. package/dist/utility/wrun/wrun-inert-legend.util.d.ts +13 -0
  205. package/dist/utility/wrun/wrun-inert-legend.util.js +31 -3
  206. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +7 -5
  207. package/dist/utility/wrun/wrun-input-requirements.leaf.js +16 -6
  208. package/dist/utility/wrun/wrun-install-pacer.util.d.ts +26 -0
  209. package/dist/utility/wrun/wrun-install-pacer.util.js +145 -0
  210. package/dist/utility/wrun/wrun-kit-refusal-stages.types.d.ts +22 -0
  211. package/dist/utility/wrun/wrun-kit-refusal-stages.types.js +1 -0
  212. package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +12 -5
  213. package/dist/utility/wrun/wrun-lane-refusal.leaf.js +23 -5
  214. package/dist/utility/wrun/wrun-lane-warmup.util.js +22 -4
  215. package/dist/utility/wrun/wrun-leg-close.util.d.ts +6 -5
  216. package/dist/utility/wrun/wrun-leg-close.util.js +11 -9
  217. package/dist/utility/wrun/wrun-leg-fetch.util.d.ts +3 -1
  218. package/dist/utility/wrun/wrun-leg-fetch.util.js +9 -2
  219. package/dist/utility/wrun/wrun-levels-child.util.d.ts +2 -0
  220. package/dist/utility/wrun/wrun-levels-child.util.js +6 -0
  221. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +4 -0
  222. package/dist/utility/wrun/wrun-live-intake.util.d.ts +15 -6
  223. package/dist/utility/wrun/wrun-live-intake.util.js +167 -47
  224. package/dist/utility/wrun/wrun-live-tick.util.d.ts +52 -8
  225. package/dist/utility/wrun/wrun-live-tick.util.js +648 -97
  226. package/dist/utility/wrun/wrun-market-facts.util.d.ts +16 -2
  227. package/dist/utility/wrun/wrun-market-facts.util.js +32 -3
  228. package/dist/utility/wrun/wrun-market-size-defaults.leaf.d.ts +27 -27
  229. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +28 -16
  230. package/dist/utility/wrun/wrun-market-size-defaults.util.js +34 -5
  231. package/dist/utility/wrun/wrun-oi-lane.util.d.ts +10 -7
  232. package/dist/utility/wrun/wrun-oi-lane.util.js +16 -10
  233. package/dist/utility/wrun/wrun-option-strike-flow.util.js +1 -1
  234. package/dist/utility/wrun/wrun-option-views.util.d.ts +2 -2
  235. package/dist/utility/wrun/wrun-option-views.util.js +5 -2
  236. package/dist/utility/wrun/wrun-options-flow-underlying.leaf.d.ts +5 -0
  237. package/dist/utility/wrun/wrun-options-flow-underlying.leaf.js +16 -0
  238. package/dist/utility/wrun/wrun-options-stop.util.d.ts +3 -2
  239. package/dist/utility/wrun/wrun-options-stop.util.js +6 -4
  240. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +75 -11
  241. package/dist/utility/wrun/wrun-overlay-drivers.util.js +176 -43
  242. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +20 -10
  243. package/dist/utility/wrun/wrun-overlay-park.util.d.ts +84 -0
  244. package/dist/utility/wrun/wrun-overlay-park.util.js +135 -0
  245. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +37 -4
  246. package/dist/utility/wrun/wrun-overlay-recovery.util.js +26 -14
  247. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +239 -24
  248. package/dist/utility/wrun/wrun-overlay-run.util.js +2204 -405
  249. package/dist/utility/wrun/wrun-pack.util.d.ts +8 -5
  250. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +2 -1
  251. package/dist/utility/wrun/wrun-panel-mount.util.js +20 -14
  252. package/dist/utility/wrun/wrun-panel-style.util.d.ts +4 -2
  253. package/dist/utility/wrun/wrun-panel-style.util.js +3 -2
  254. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +7 -0
  255. package/dist/utility/wrun/wrun-pin-spelling.util.js +18 -4
  256. package/dist/utility/wrun/wrun-pin-venues.util.d.ts +26 -17
  257. package/dist/utility/wrun/wrun-pin-venues.util.js +43 -36
  258. package/dist/utility/wrun/wrun-pinned-lanes.util.d.ts +58 -0
  259. package/dist/utility/wrun/wrun-pinned-lanes.util.js +72 -0
  260. package/dist/utility/wrun/wrun-prefix-cohort.util.js +2 -1
  261. package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +22 -9
  262. package/dist/utility/wrun/wrun-prefix-lanes.util.js +145 -26
  263. package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +29 -0
  264. package/dist/utility/wrun/wrun-prefix-proof.util.js +23 -5
  265. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +9 -1
  266. package/dist/utility/wrun/wrun-refusal-surface.util.js +15 -1
  267. package/dist/utility/wrun/wrun-refusal.util.d.ts +19 -1
  268. package/dist/utility/wrun/wrun-refusal.util.js +103 -16
  269. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +20 -6
  270. package/dist/utility/wrun/wrun-registry-errors.util.js +20 -6
  271. package/dist/utility/wrun/wrun-replay-rows.util.js +6 -10
  272. package/dist/utility/wrun/wrun-run-health.util.d.ts +89 -2
  273. package/dist/utility/wrun/wrun-run-health.util.js +204 -1
  274. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +2 -2
  275. package/dist/utility/wrun/wrun-run-interval-session.util.js +2 -2
  276. package/dist/utility/wrun/wrun-run-interval.util.d.ts +9 -8
  277. package/dist/utility/wrun/wrun-run-interval.util.js +13 -11
  278. package/dist/utility/wrun/wrun-sandbox-row-source.js +5 -2
  279. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +13 -3
  280. package/dist/utility/wrun/wrun-script-inputs.util.js +51 -13
  281. package/dist/utility/wrun/wrun-session-composition.util.d.ts +81 -0
  282. package/dist/utility/wrun/wrun-session-composition.util.js +169 -0
  283. package/dist/utility/wrun/wrun-setting-words.util.d.ts +10 -7
  284. package/dist/utility/wrun/wrun-setting-words.util.js +25 -7
  285. package/dist/utility/wrun/wrun-source-rows.util.d.ts +94 -28
  286. package/dist/utility/wrun/wrun-source-rows.util.js +738 -93
  287. package/dist/utility/wrun/wrun-stream-clock.util.d.ts +45 -0
  288. package/dist/utility/wrun/wrun-stream-clock.util.js +108 -0
  289. package/dist/utility/wrun/wrun-tape-coins.util.d.ts +116 -0
  290. package/dist/utility/wrun/wrun-tape-coins.util.js +110 -0
  291. package/dist/utility/wrun/wrun-tape-source.util.d.ts +62 -32
  292. package/dist/utility/wrun/wrun-tape-source.util.js +72 -34
  293. package/dist/utility/wrun/wrun-tier-grid.util.d.ts +13 -5
  294. package/dist/utility/wrun/wrun-tier-grid.util.js +23 -13
  295. package/dist/utility/wrun/wrun-tpo-rows.util.js +2 -1
  296. package/dist/utility/wrun/wrun-trades-lane.util.d.ts +73 -0
  297. package/dist/utility/wrun/wrun-trades-lane.util.js +82 -0
  298. package/dist/utility/wrun/wrun-twin-compute-inputs.util.d.ts +5 -0
  299. package/dist/utility/wrun/wrun-twin-compute-inputs.util.js +9 -2
  300. package/dist/utility/wrun/wrun-visibility-table.d.ts +13 -0
  301. package/dist/utility/wrun/wrun-visibility-table.js +9 -0
  302. package/dist/utility/wrun/wrun-volume-profile.util.js +7 -3
  303. package/dist/utils/replay/replay-buffer-math.d.ts +16 -6
  304. package/dist/utils/replay/replay-buffer-math.js +60 -30
  305. package/dist/workers/constants/socket-slots.d.ts +11 -7
  306. package/dist/workers/constants/socket-slots.js +6 -5
  307. package/package.json +5 -5
@@ -5,32 +5,81 @@
5
5
  * stale-but-fast; the caching contract (perf/caching.md: stale paints, fresh
6
6
  * replaces) then owes one live re-fetch. The boot second pass cannot be that
7
7
  * re-fetch: on a warm boot it is skipped entirely, and on any pass the cache
8
- * would simply hit again. So: the acquisition MARKS the overlay pending here;
9
- * after that generation's first run integrates (the overlay actually painted),
10
- * the owner (data-fetching.util) runs a one-shot per-(chart, overlay) refresh
11
- * over the recorded range with a generation-owned BYPASS TOKEN installed.
12
- * Every source acquisition belonging to that refresh observes the token (and
13
- * never consumes it); the owner clears it in `finally` only if it still owns
14
- * it. Teardown clears both maps.
8
+ * would simply hit again. So: the acquisition MARKS the overlay pending here,
9
+ * with the window and the LANE the replay cache served (its replay-series
10
+ * identity, `kScriptSourceReplayLaneKey`); after that generation's first run
11
+ * integrates (the overlay actually painted), the owner (the wrun lifecycle
12
+ * door) runs a one-shot per-(chart, overlay) refresh over the recorded range
13
+ * with a generation-owned BYPASS TOKEN installed over the marked lanes. Only
14
+ * those lanes reach the wire: every other lane of the refresh takes its normal
15
+ * ladder (row cache, composition, resident split, replay cache read), so a lane
16
+ * the row cache holds fresh is never bought again. A token installed without
17
+ * lanes (the live tick's reconcile, the full-fetch debug oracle) covers every
18
+ * lane. Every source acquisition observes the standing tokens (and never
19
+ * consumes one); an owner releases only its own token, in `finally`. The
20
+ * tokens of one overlay stack: a lane bypasses while any standing token covers
21
+ * it, so a narrower token never narrows a wider one that stands. Teardown
22
+ * clears both maps.
15
23
  *
16
- * This module is pure state so titan-charts (acquisition side) and
17
- * data-fetching.util (refresh side) can share it without an import cycle.
24
+ * This module is pure state so titan-charts (acquisition side) and the
25
+ * lifecycle door (refresh side) can share it without an import cycle.
18
26
  */
19
27
  const pendingByOverlay = new Map();
28
+ /** Per overlay, its standing tokens: each token's lane set, or null for a token over every lane. */
20
29
  const bypassTokens = new Map();
21
30
  function overlayKey(chartIndex, overlayId) {
22
31
  return `${chartIndex}:${overlayId}`;
23
32
  }
24
- /** Called by the acquisition path on a non-polling replay-cache hit. */
25
- export function markLocalKScriptSourceCacheHit(chartIndex, overlayId, fromMs, toMs) {
33
+ /** The request window as a source payload names it: never part of a lane's identity. */
34
+ const LANE_WINDOW_FIELDS = new Set(['from', 'period']);
35
+ /** Key-order-free JSON, an undefined field left out (the replay cache serialises its identity the same way). */
36
+ function stableStringify(value) {
37
+ if (value === null || typeof value !== 'object')
38
+ return JSON.stringify(value) ?? 'null';
39
+ if (Array.isArray(value))
40
+ return `[${value.map(stableStringify).join(',')}]`;
41
+ const record = value;
42
+ const fields = Object.keys(record)
43
+ .filter((field) => record[field] !== undefined)
44
+ .sort();
45
+ return `{${fields.map((field) => `${JSON.stringify(field)}:${stableStringify(record[field])}`).join(',')}}`;
46
+ }
47
+ /**
48
+ * A lane's replay-series identity: its replay cache key parts without the
49
+ * window, serialised key-order-free. A prefix page and a rerun of one lane ask
50
+ * the same parts over different windows (under different source names), so
51
+ * they share one key, and every replay-eligible type (K_VOLUME_PROFILE,
52
+ * K_BUY_SELL_VOLUME, K_ORDERBOOK) has one. Never the row cache's series key,
53
+ * which K_ORDERBOOK lacks. The parts are taken structurally: their type
54
+ * (`KScriptSourceReplayCacheKeyParts`) lives in the app, outside this package.
55
+ */
56
+ export function kScriptSourceReplayLaneKey(parts) {
57
+ const identity = {};
58
+ for (const [field, value] of Object.entries(parts)) {
59
+ if (!LANE_WINDOW_FIELDS.has(field))
60
+ identity[field] = value;
61
+ }
62
+ return stableStringify(identity);
63
+ }
64
+ /**
65
+ * Called by the acquisition path on a non-polling replay-cache hit: the lane
66
+ * joins the overlay's pending lanes and the window joins its range. A mark
67
+ * with no lane key adds no lane (a record with no lanes revalidates every
68
+ * lane, never none).
69
+ */
70
+ export function markLocalKScriptSourceCacheHit(chartIndex, overlayId, fromMs, toMs, laneKey) {
26
71
  if (!Number.isFinite(fromMs) || !Number.isFinite(toMs) || toMs <= fromMs)
27
72
  return;
28
73
  const key = overlayKey(chartIndex, overlayId);
29
74
  const existing = pendingByOverlay.get(key);
75
+ const lanes = new Set(existing?.lanes);
76
+ if (typeof laneKey === 'string' && laneKey.length > 0)
77
+ lanes.add(laneKey);
30
78
  pendingByOverlay.set(key, {
31
79
  fromMs: existing ? Math.min(existing.fromMs, fromMs) : fromMs,
32
80
  toMs: existing ? Math.max(existing.toMs, toMs) : toMs,
33
81
  markedAt: Date.now(),
82
+ lanes,
34
83
  scheduled: existing?.scheduled === true,
35
84
  });
36
85
  }
@@ -51,7 +100,7 @@ export function disarmLocalKScriptSourceRevalidation(chartIndex, overlayId) {
51
100
  if (pending)
52
101
  pending.scheduled = false;
53
102
  }
54
- /** Consumes and returns the pending mark, if any (owner-side). */
103
+ /** Consumes and returns the pending mark, its lanes included, if any (owner-side). */
55
104
  export function takePendingLocalKScriptSourceRevalidation(chartIndex, overlayId) {
56
105
  const key = overlayKey(chartIndex, overlayId);
57
106
  const pending = pendingByOverlay.get(key);
@@ -63,27 +112,35 @@ export function hasPendingLocalKScriptSourceRevalidation(chartIndex, overlayId)
63
112
  return pendingByOverlay.has(overlayKey(chartIndex, overlayId));
64
113
  }
65
114
  /**
66
- * Install a bypass token for one overlay's revalidation refresh. Returns the
67
- * token; the owner must release with the SAME token so an older generation
68
- * can never clear a newer one.
115
+ * Install a bypass token for one overlay's refresh. With `lanes`, the token
116
+ * covers only those lanes (the revalidation of the lanes the replay cache
117
+ * served); without, every lane of the overlay (the live tick's reconcile, the
118
+ * full-fetch oracle). An empty set covers every lane too, so a stale caller
119
+ * never silently skips one. Returns the token; the owner must release with the
120
+ * SAME token, so one owner can never clear another's.
69
121
  */
70
- export function installLocalKScriptSourceCacheBypass(chartIndex, overlayId) {
122
+ export function installLocalKScriptSourceCacheBypass(chartIndex, overlayId, lanes) {
71
123
  const key = overlayKey(chartIndex, overlayId);
72
124
  const token = Symbol(key);
73
- bypassTokens.set(key, token);
125
+ const standing = bypassTokens.get(key) ?? new Map();
126
+ standing.set(token, lanes !== undefined && lanes.size > 0 ? new Set(lanes) : null);
127
+ bypassTokens.set(key, standing);
74
128
  return token;
75
129
  }
76
130
  export function releaseLocalKScriptSourceCacheBypass(chartIndex, overlayId, token) {
77
131
  const key = overlayKey(chartIndex, overlayId);
78
- if (bypassTokens.get(key) === token)
132
+ const standing = bypassTokens.get(key);
133
+ if (!standing?.delete(token))
134
+ return;
135
+ if (standing.size === 0)
79
136
  bypassTokens.delete(key);
80
137
  }
81
138
  /**
82
139
  * Install one bypass token per overlay for a whole-chart forced refresh (the
83
140
  * full-fetch debug oracle): every listed overlay's source acquisitions reach
84
141
  * the wire until the returned release runs. Release is token-owned per
85
- * overlay, so a revalidation refresh that installed its own newer token in
86
- * the meantime keeps it.
142
+ * overlay, so a revalidation refresh that installed its own token in the
143
+ * meantime keeps it.
87
144
  */
88
145
  export function installLocalKScriptSourceCacheBypassForOverlays(chartIndex, overlayIds) {
89
146
  const owned = overlayIds.map((overlayId) => ({
@@ -95,9 +152,27 @@ export function installLocalKScriptSourceCacheBypassForOverlays(chartIndex, over
95
152
  releaseLocalKScriptSourceCacheBypass(chartIndex, overlayId, token);
96
153
  };
97
154
  }
98
- /** Observed (never consumed) by every source acquisition of the overlay. */
99
- export function shouldBypassLocalKScriptSourceReplayCache(chartIndex, overlayId) {
100
- return bypassTokens.has(overlayKey(chartIndex, overlayId));
155
+ /**
156
+ * Which standing token covers the lane: 'overlay' when a token over every lane
157
+ * stands, 'lane' when a lane-scoped token holds the lane, null otherwise (no
158
+ * token, or only tokens over other lanes). Observed, never consumed.
159
+ */
160
+ export function localKScriptSourceReplayCacheBypassScope(chartIndex, overlayId, laneKey) {
161
+ const standing = bypassTokens.get(overlayKey(chartIndex, overlayId));
162
+ if (!standing)
163
+ return null;
164
+ let scope = null;
165
+ for (const lanes of standing.values()) {
166
+ if (lanes === null)
167
+ return 'overlay';
168
+ if (lanes.has(laneKey))
169
+ scope = 'lane';
170
+ }
171
+ return scope;
172
+ }
173
+ /** Observed (never consumed) by every source acquisition of the overlay: true when a standing token covers the lane. */
174
+ export function shouldBypassLocalKScriptSourceReplayCache(chartIndex, overlayId, laneKey) {
175
+ return localKScriptSourceReplayCacheBypassScope(chartIndex, overlayId, laneKey) !== null;
101
176
  }
102
177
  /** Chart teardown / dataset replacement: drop marks and tokens for the chart (or one overlay). */
103
178
  export function clearLocalKScriptSourceRevalidation(chartIndex, overlayId) {
@@ -41,13 +41,18 @@ export declare function warmupBucketsForNeed(needBars: number): number;
41
41
  * shows, and a fetch for it buys nothing the eye can see.
42
42
  */
43
43
  export declare const LOCAL_KSCRIPT_WARMUP_DEPTH_MIN_GAP_BARS = 25;
44
+ /** The bars a window must hold past a sheet's declared warm-up before an empty result is trusted: declarations
45
+ * under-report (a script declaring 252 first printed at bar 351), so one loader bucket of slack. */
46
+ export declare const LOCAL_KSCRIPT_WARMUP_DECLARED_SLACK_BARS = 250;
44
47
  type LocalKScriptWarmupDepthSkipReason = 'no-rows' | 'no-viewport' | 'warmup-offscreen' | 'gap-too-small' | 'rounds-exhausted' | 'left-exhausted' | 'gesture-active'
45
- /** A source of the script is still loading, degraded, or never settled: an all-NaN run is not warmup evidence. */
48
+ /** A source is still landing (for an empty result, any source unsettled): no evidence until it lands. */
46
49
  | 'sources-pending'
47
50
  /** The script declares a lookback of 0 and simply printed nothing: an empty output is not a warmup gap. */
48
51
  | 'zero-lookback-empty'
49
52
  /** The visible first value is where a source's history begins (`sourceReachFromTs`): no page can move it. */
50
- | 'source-reach';
53
+ | 'source-reach'
54
+ /** Nothing printed over a window that holds the sheet's declared warm-up and its slack: not warmup. */
55
+ | 'no-values-declared-covered';
51
56
  export type LocalKScriptWarmupDepthDecision = {
52
57
  fetch: true;
53
58
  reason: 'warmup-visible' | 'no-values-yet' | 'declared-depth';
@@ -105,17 +110,23 @@ export interface LocalKScriptWarmupDepthInput {
105
110
  * script that declares 5 bars is never owed a second bucket.
106
111
  */
107
112
  lookbackBars: number | null;
108
- /** Every source of the engine settled for the current timeline (the proxy's sourceSettlementLedger). */
113
+ /** Every source answered for the current timeline (wrun: a dead lane leaves it false): an empty result needs it. */
109
114
  sourcesSettled: boolean;
115
+ /** A source's recovery can still rerun it (wrun: `warmupSourceEntryLanding` over the degrade registry); absent,
116
+ * `!sourcesSettled`. A result with values waits for it alone: a source given up on cannot move a first value. */
117
+ sourcesLanding?: boolean;
110
118
  /**
111
- * Where the rows of the result's history sources begin at the clock, null or absent when unknown or when a source
112
- * reads without a reach (the wrun lane: `wrunRunSourceReachFromMs`, the earliest of its row lanes' reaches, a
113
- * horizon's served start or the oldest bar a lane's longest-kept tier holds). A visible first value at or after it,
114
- * with the reach at or after the loaded start, is that history beginning, not a warm-up: a page of candles older
115
- * than the loaded start holds none of the source's rows, so it cannot move the first value ('source-reach'). Spot
116
- * Exposures on a 52-day 1h viewport bought a 500-bar page this way for strike rows kept 7 days (INT 2026-10-20).
119
+ * Where the rows of the result's history sources begin at the clock, null or absent when unknown (the wrun lane:
120
+ * `wrunRunSourceReachFromMs`, from declared reaches and every-bar answers only). A visible
121
+ * first value at or after it, with the reach at or after the loaded start, is that history beginning, not a warm-up:
122
+ * a page of candles older than the loaded start holds none of the source's rows, so it cannot move the first value
123
+ * ('source-reach'). Spot Exposures on a 52-day 1h viewport bought a 500-bar page this way for strike rows kept 7 days
124
+ * (INT 2026-10-20).
117
125
  */
118
126
  sourceReachFromTs?: number | null;
127
+ /** A sheet's declared warm-up (wrun `warmup` / `warmup_bars`): true when the run's rows hold it plus
128
+ * LOCAL_KSCRIPT_WARMUP_DECLARED_SLACK_BARS, false when they do not; null or absent when it declares none. */
129
+ declaredWarmupCovered?: boolean | null;
119
130
  }
120
131
  /**
121
132
  * Bars in the loaded main window: floor((last - first) / interval) + 1. Null
@@ -123,6 +134,16 @@ export interface LocalKScriptWarmupDepthInput {
123
134
  * are inverted (a malformed read is unknown, never a small window).
124
135
  */
125
136
  export declare function loadedBarsOfWindow(loadedFirstTs: number | null | undefined, loadedLastTs: number | null | undefined, intervalMs: number): number | null;
137
+ /** Whether a source's answer is still coming: the caller's `sourcesLanding`, else any source not settled. */
138
+ export declare function warmupSourcesLanding(input: Pick<LocalKScriptWarmupDepthInput, 'sourcesSettled' | 'sourcesLanding'>): boolean;
139
+ /** A source's entry in the degrade registry, as the warm-up reads it. */
140
+ export interface WarmupSourceEntryLike {
141
+ phase: 'pending' | 'degraded' | 'recovered';
142
+ terminal: boolean;
143
+ }
144
+ /** Whether a source is still landing: pending (in flight, a first slice) or degraded with its ladder not given up. Once
145
+ * the ladder is terminal it is settled, whatever its cause or retryable flag. */
146
+ export declare function warmupSourceEntryLanding(entry: WarmupSourceEntryLike): boolean;
126
147
  /**
127
148
  * Decide whether to spend a warmup round. The first value must sit inside or
128
149
  * to the right of the visible window (offscreen warmup is the normal, harmless
@@ -131,13 +152,16 @@ export declare function loadedBarsOfWindow(loadedFirstTs: number | null | undefi
131
152
  * all-NaN run is evidence only after every source settled (field 2026-09-05:
132
153
  * Volume Bubbles fired a blind 500-bar page while its volume-profile source
133
154
  * was still downloading, and every heavy native overlay refetched the widened
134
- * range). A declared lookback deeper than the loaded window, with the first
155
+ * range), and a result with values only once no source is still landing. A
156
+ * declared lookback deeper than the loaded window, with the first
135
157
  * value at the loaded start, is the one non-observed reason ('declared-depth',
136
158
  * sized to the shortfall, one page at a time; a shortfall under the absolute
137
159
  * gap floor, or the caller's `minGapBars`, is left alone like any other small gap).
138
160
  * A visible first value that a source's history explains (`sourceReachFromTs`:
139
161
  * that history begins inside the loaded window and the first value at or after
140
- * it) owes no page: older candles hold none of the source's rows.
162
+ * it) owes no page: older candles hold none of the source's rows. An all-NaN
163
+ * run whose rows hold the sheet's declared warm-up plus its slack owes none
164
+ * either ('no-values-declared-covered'); an undeclared one keeps its probe page.
141
165
  */
142
166
  export declare function chooseLocalKScriptWarmupDepth(input: LocalKScriptWarmupDepthInput): LocalKScriptWarmupDepthDecision;
143
167
  export interface WarmupOutputLike {
@@ -49,6 +49,9 @@ export function warmupBucketsForNeed(needBars) {
49
49
  */
50
50
  export const LOCAL_KSCRIPT_WARMUP_DEPTH_MIN_GAP_BARS = 25;
51
51
  const LOCAL_KSCRIPT_WARMUP_DEPTH_MIN_GAP_VIEWPORT_FRACTION = 0.1;
52
+ /** The bars a window must hold past a sheet's declared warm-up before an empty result is trusted: declarations
53
+ * under-report (a script declaring 252 first printed at bar 351), so one loader bucket of slack. */
54
+ export const LOCAL_KSCRIPT_WARMUP_DECLARED_SLACK_BARS = LOCAL_KSCRIPT_WARMUP_DEPTH_BUCKET_BARS;
52
55
  function isFiniteTs(value) {
53
56
  return typeof value === 'number' && Number.isFinite(value);
54
57
  }
@@ -75,6 +78,15 @@ export function loadedBarsOfWindow(loadedFirstTs, loadedLastTs, intervalMs) {
75
78
  const bars = Math.floor((loadedLastTs - loadedFirstTs) / intervalMs) + 1;
76
79
  return bars >= 1 ? bars : null;
77
80
  }
81
+ /** Whether a source's answer is still coming: the caller's `sourcesLanding`, else any source not settled. */
82
+ export function warmupSourcesLanding(input) {
83
+ return input.sourcesLanding ?? !input.sourcesSettled;
84
+ }
85
+ /** Whether a source is still landing: pending (in flight, a first slice) or degraded with its ladder not given up. Once
86
+ * the ladder is terminal it is settled, whatever its cause or retryable flag. */
87
+ export function warmupSourceEntryLanding(entry) {
88
+ return entry.phase === 'pending' || (entry.phase === 'degraded' && !entry.terminal);
89
+ }
78
90
  /**
79
91
  * Decide whether to spend a warmup round. The first value must sit inside or
80
92
  * to the right of the visible window (offscreen warmup is the normal, harmless
@@ -83,13 +95,16 @@ export function loadedBarsOfWindow(loadedFirstTs, loadedLastTs, intervalMs) {
83
95
  * all-NaN run is evidence only after every source settled (field 2026-09-05:
84
96
  * Volume Bubbles fired a blind 500-bar page while its volume-profile source
85
97
  * was still downloading, and every heavy native overlay refetched the widened
86
- * range). A declared lookback deeper than the loaded window, with the first
98
+ * range), and a result with values only once no source is still landing. A
99
+ * declared lookback deeper than the loaded window, with the first
87
100
  * value at the loaded start, is the one non-observed reason ('declared-depth',
88
101
  * sized to the shortfall, one page at a time; a shortfall under the absolute
89
102
  * gap floor, or the caller's `minGapBars`, is left alone like any other small gap).
90
103
  * A visible first value that a source's history explains (`sourceReachFromTs`:
91
104
  * that history begins inside the loaded window and the first value at or after
92
- * it) owes no page: older candles hold none of the source's rows.
105
+ * it) owes no page: older candles hold none of the source's rows. An all-NaN
106
+ * run whose rows hold the sheet's declared warm-up plus its slack owes none
107
+ * either ('no-values-declared-covered'); an undeclared one keeps its probe page.
93
108
  */
94
109
  export function chooseLocalKScriptWarmupDepth(input) {
95
110
  if (!isFiniteTs(input.loadedFirstTs))
@@ -114,6 +129,9 @@ export function chooseLocalKScriptWarmupDepth(input) {
114
129
  return { fetch: false, reason: 'sources-pending' };
115
130
  if (lookbackBars === 0)
116
131
  return { fetch: false, reason: 'zero-lookback-empty' };
132
+ // A declaration is trusted: rows holding it and its slack that printed nothing are no warm-up (an interval gate).
133
+ if (input.declaredWarmupCovered === true)
134
+ return { fetch: false, reason: 'no-values-declared-covered' };
117
135
  // The declared lookback under-reports (a script declaring 252 first
118
136
  // printed at bar 351), so the need is at least one bucket; an unknown
119
137
  // lookback keeps the two-bucket page the field relied on.
@@ -146,7 +164,7 @@ export function chooseLocalKScriptWarmupDepth(input) {
146
164
  loadedBars < lookbackBars &&
147
165
  input.firstValueTs <= input.loadedFirstTs + input.intervalMs) {
148
166
  // A truncated run with sources still in flight proves nothing yet.
149
- if (!input.sourcesSettled)
167
+ if (warmupSourcesLanding(input))
150
168
  return { fetch: false, reason: 'sources-pending' };
151
169
  const missingBars = lookbackBars - loadedBars;
152
170
  // The absolute gap floor applies here too: a shortfall under
@@ -174,6 +192,9 @@ export function chooseLocalKScriptWarmupDepth(input) {
174
192
  const minGapBars = Math.max(LOCAL_KSCRIPT_WARMUP_DEPTH_MIN_GAP_BARS, Math.ceil(viewportBars * LOCAL_KSCRIPT_WARMUP_DEPTH_MIN_GAP_VIEWPORT_FRACTION));
175
193
  if (missingBars < minGapBars)
176
194
  return { fetch: false, reason: 'gap-too-small' };
195
+ // A lane still landing (a first slice) reads its first value late; the run after it settles judges again.
196
+ if (warmupSourcesLanding(input))
197
+ return { fetch: false, reason: 'sources-pending' };
177
198
  // A first value a source's history explains: that history begins inside the loaded window and the first value sits
178
199
  // at or after its start, so a page of older candles holds none of the source's rows and cannot move it.
179
200
  const reachTs = input.sourceReachFromTs;
@@ -101,3 +101,11 @@ export declare function currentCmeSessionStartMs(nowMs: number, opts: {
101
101
  symbol?: string | null;
102
102
  rth: boolean;
103
103
  }): number | null;
104
+ /** The session that traded last before a closed `nowMs`, in `currentCmeSessionStartMs`'s mode; null inside one, holidays unknown. */
105
+ export declare function lastCmeSessionBoundsBefore(nowMs: number, opts: {
106
+ symbol?: string | null;
107
+ rth: boolean;
108
+ }): {
109
+ openMs: number;
110
+ closeMs: number;
111
+ } | null;
@@ -25,7 +25,7 @@
25
25
  */
26
26
  import { cmeServedAccessForExchange } from './cme-cache-context.util.js';
27
27
  import { zoneWallMsAt } from './ny-calendar.util.js';
28
- import { getRthWindowForSymbol, rthSessionOpenMs } from './rth-session.util.js';
28
+ import { getRthWindowForSymbol, rthSessionOpenMs, sessionDayBoundsFor } from './rth-session.util.js';
29
29
  import { delayedDefaultSecondsFor, gateProviderForExchange } from '../v2/gate-plane.util.js';
30
30
  export const GOVERNED_FUTURES_TIME_ZONE = 'America/Chicago';
31
31
  /** Sunday-based minutes-of-week for the two boundary kinds. */
@@ -373,3 +373,41 @@ export function currentCmeSessionStartMs(nowMs, opts) {
373
373
  return alwaysOnSessionStartMs(nowMs, sinceMs);
374
374
  return globexSessionStartMs(nowMs);
375
375
  }
376
+ /** The session that traded last before a closed `nowMs`, in `currentCmeSessionStartMs`'s mode; null inside one, holidays unknown. */
377
+ export function lastCmeSessionBoundsBefore(nowMs, opts) {
378
+ if (!Number.isFinite(nowMs) || currentCmeSessionStartMs(nowMs, opts) !== null)
379
+ return null;
380
+ const window = opts.rth ? getRthWindowForSymbol(opts.symbol) : null;
381
+ if (window !== null) {
382
+ // The reader above names the days that trade (a holiday morning too): the newest window it reads open.
383
+ let cursorMs = nowMs;
384
+ for (let back = 0; back <= 7; back += 1) {
385
+ const day = sessionDayBoundsFor(window, cursorMs);
386
+ if (day === null)
387
+ return null;
388
+ if (day.closeMs <= nowMs && currentCmeSessionStartMs(day.closeMs - 1, opts) === day.openMs) {
389
+ return { openMs: day.openMs, closeMs: day.closeMs };
390
+ }
391
+ cursorMs = day.dayStartMs - 1;
392
+ }
393
+ return null;
394
+ }
395
+ const p = wallClockPartsAt(nowMs);
396
+ const sinceMs = cmeAlwaysOnSinceMs(opts.symbol);
397
+ if (sinceMs !== null && nowMs >= sinceMs) {
398
+ // Closed here means the Saturday maintenance window: the session ran from the Saturday before.
399
+ const opened = chicagoDateDaysBefore(p, 7);
400
+ return {
401
+ openMs: Math.max(sinceMs, chicagoWallTimeToUtc(opened.year, opened.month, opened.day, ALWAYS_ON_MAINTENANCE_END_HOUR)),
402
+ closeMs: chicagoWallTimeToUtc(p.year, p.month, p.day, ALWAYS_ON_MAINTENANCE_START_HOUR),
403
+ };
404
+ }
405
+ // The weekly cycle: the 16:00 CT close of today on a weekday, of Friday across the weekend.
406
+ const daysBack = p.weekday === 6 ? 1 : p.weekday === 0 ? 2 : 0;
407
+ const closed = chicagoDateDaysBefore(p, daysBack);
408
+ const opened = chicagoDateDaysBefore(p, daysBack + 1);
409
+ return {
410
+ openMs: chicagoWallTimeToUtc(opened.year, opened.month, opened.day, OPEN_HOUR),
411
+ closeMs: chicagoWallTimeToUtc(closed.year, closed.month, closed.day, CLOSE_HOUR),
412
+ };
413
+ }
@@ -0,0 +1,136 @@
1
+ /**
2
+ * The market-session contract: which regular session a market has, whether a chart and an overlay ride it, and where
3
+ * its edges fall, for every market the chart's session-aware tools serve (the footprint, the session, delta, visible,
4
+ * fixed-range and developing profiles, CVD, volume delta and VWAP).
5
+ *
6
+ * Why this exists: those tools decided trading hours through rth-session.util, whose rules are futures-only
7
+ * (`hasRthWindow` needs a CME-governed venue, `getRthWindowForSymbol` keys futures roots), so a US stock had no
8
+ * session: regular-hours stock charts at 45m to 12h drew order flow 30 minutes off the 09:30 New York grid with the
9
+ * closing bar empty. This module answers both markets through one door:
10
+ * 'cme' exactly rth-session.util: every CME answer is the named rth-session helper's own answer (same null
11
+ * and fail-open contracts), byte-identical to the futures-only path it replaces.
12
+ * 'us-equity' the regular session 09:30 to 16:00 America/New_York (us-equities-session.util
13
+ * `US_EQUITIES_REGULAR_WINDOW`), DST-correct, on the per-window day walk the CME window rides
14
+ * (rth-session.util `sessionDayBoundsFor`). The gateway keeps a REGULAR bucket by its START, so the
15
+ * 16:00:00 closing cross sits outside the window, as it sits outside the candles.
16
+ * null every other market (crypto, forex, unmapped futures roots): each op answers what its rth-session
17
+ * helper answers with no window.
18
+ *
19
+ * The equities calendar is weekdays plus DST only: ny-calendar.util models no exchange holidays and no early closes.
20
+ * Saturday and Sunday hold no session (the per-instant ops answer out of session there); a holiday (2026-11-26) still
21
+ * reads as an ordinary weekday session and an early close (2026-11-27) as a full one. Bucketing is data-driven, so
22
+ * that is safe there: a holiday has no rows to bucket, and an early close's rows land in the buckets they fall in. A
23
+ * caller that PICKS a session (a developing-session window, a visible-range prior day) must pick one that holds
24
+ * candles: `latestMarketSessionBoundsAtOrBefore` names a holiday's window like any weekday's.
25
+ *
26
+ * Worker-safe: no Vue, store or i18n imports (workers and the live-feed gates call these per row and per frame).
27
+ */
28
+ import { type RthWindow, type SessionDayWindow } from './rth-session.util.js';
29
+ export type MarketSessionKind = 'cme' | 'us-equity';
30
+ /**
31
+ * A US stock market: a Polygon listing code (marketKind.util `checkIsPolygon`: POLYGON, US_STOCKS, NYSE, NASDAQ,
32
+ * CBOE) or a stocks tape code (stocks-governed.util `isStocksTapeGoverned`: NYSE_TAPE, NYSE_ARCA_TAPE,
33
+ * NASDAQ_TAPE). Case-insensitive; false for anything that is not a string.
34
+ */
35
+ export declare function isUsEquityMarket(exchange: unknown): boolean;
36
+ /**
37
+ * The regular session a market has: 'cme' exactly when rth-session.util `hasRthWindow(symbol, exchange)` (a
38
+ * CME-governed venue and a mapped futures root), 'us-equity' when `isUsEquityMarket(exchange)`, else null. The two
39
+ * venue sets are disjoint.
40
+ */
41
+ export declare function marketSessionKind(exchange: unknown, symbol: unknown): MarketSessionKind | null;
42
+ /**
43
+ * The market's regular window: the root's own window on CME (`getRthWindowForSymbol`, under the `hasRthWindow`
44
+ * gate), `US_EQUITIES_REGULAR_WINDOW` on a US stock, else null.
45
+ */
46
+ export declare function marketRegularWindow(exchange: unknown, symbol: unknown): Readonly<RthWindow> | null;
47
+ export declare function marketHasRegularWindow(exchange: unknown, symbol: unknown): boolean;
48
+ /**
49
+ * The regular session THIS chart draws at `chartTfMs` (milliseconds), for overlay purposes; intraday only:
50
+ * 'cme' exactly when rth-session.util `isChartRthActive(exchange, symbol, sessionType, chartTfMs)`.
51
+ * 'us-equity' when the candles' own gate holds, us-equities-session.util
52
+ * `isEquityRegularSessionGated(exchange, sessionType, chartTfMs)` (a Polygon listing whose word is not
53
+ * an active 'extended'), at an intraday `chartTfMs`. A chart opened on a tape venue (NASDAQ_TAPE) has
54
+ * no candle session handling, so it answers null, as it rides today.
55
+ * null otherwise: an ETH or extended chart, a daily or longer interval, a label instead of milliseconds.
56
+ */
57
+ export declare function chartRegularSessionKind(exchange: unknown, symbol: unknown, sessionType: unknown, chartTfMs: unknown): MarketSessionKind | null;
58
+ /**
59
+ * The chart's regular session as a cache-key settings bag carries it (cache-key-guard.util `indicatorCacheSettings`):
60
+ * its `chartRegularKind`, else the CME-only `chartRthActive` flag the bag always carried (true reads 'cme'), so a bag
61
+ * without the kind keys every CME overlay as before; else null. Key builders read the TARGET chart's session from the
62
+ * bag, never the focused cell. The one reader: the footprint, profile and order-flow keys must never disagree on it.
63
+ */
64
+ export declare function chartRegularKindFromCacheBag(bag: Readonly<Record<string, unknown>> | {
65
+ chartRegularKind?: unknown;
66
+ chartRthActive?: unknown;
67
+ } | null | undefined): MarketSessionKind | null;
68
+ /**
69
+ * Whether an overlay's session filter is ACTIVE on a chart whose regular session is `chartRegularKind`
70
+ * (`chartRegularSessionKind` of the chart). The overlay's own market decides the rule:
71
+ * CME exactly rth-session.util `isRthSessionHoursActive(settings, chartTfMs, chartRegularKind === 'cme')`:
72
+ * an explicit 'rth' stays active on any chart (a stock, crypto or ETH chart included), 'eth' never
73
+ * is, and the 'chart' default follows a CME RTH chart only.
74
+ * US stock active exactly while the chart draws the US equities regular session at an intraday `chartTfMs`.
75
+ * Stock overlays always follow the chart: their session row is hidden, so a persisted 'rth' or 'eth'
76
+ * carried over from a futures chart is ignored.
77
+ * any other never active (no window to filter on).
78
+ */
79
+ export declare function isMarketSessionHoursActive(settings: {
80
+ sessionHours?: unknown;
81
+ symbol?: unknown;
82
+ exchange?: unknown;
83
+ } | null | undefined, chartTfMs: unknown, chartRegularKind: MarketSessionKind | null): boolean;
84
+ /**
85
+ * `isWithinRthWindow`: whether `tsMs` sits in the market's `[open, close)` session. Fails OPEN with no window (a
86
+ * market without a regular session keeps every row), false for a non-finite instant on a market with one.
87
+ */
88
+ export declare function isWithinMarketRegularWindow(exchange: unknown, symbol: unknown, tsMs: number): boolean;
89
+ /**
90
+ * `rthSessionOpenMs`: the open of the session holding `tsMs`, null outside it. Null for EVERY instant on a market
91
+ * without a window, so a caller gates on `marketHasRegularWindow` before reading null as "out of session".
92
+ */
93
+ export declare function marketSessionOpenMs(exchange: unknown, symbol: unknown, tsMs: number): number | null;
94
+ /** `rthSessionCloseMs`: the EXCLUSIVE close of the session holding `tsMs`; the open's null contract. */
95
+ export declare function marketSessionCloseMs(exchange: unknown, symbol: unknown, tsMs: number): number | null;
96
+ /**
97
+ * `rthBucketOverlapsSessionMs`: whether `[bucketStartMs, bucketStartMs + tfMs)` overlaps the session of the day
98
+ * holding its start or its last ms (a UTC-grid bucket holding the open or the close carries in-session rows although
99
+ * its start sits outside). False with no window or invalid inputs.
100
+ */
101
+ export declare function marketBucketOverlapsSession(exchange: unknown, symbol: unknown, bucketStartMs: number, tfMs: number): boolean;
102
+ /**
103
+ * `rthAnchoredBucketStartMs`: the session-anchored bucket holding `tsMs`, `open + n * tfMs` (the grid the gateway
104
+ * serves REGULAR bars on above 30m: 13:30Z hourly bars in EDT). Null with no window, invalid inputs, or `tsMs` out
105
+ * of session (live callers drop such a frame). On a stock it equals us-equities-session.util
106
+ * `usEquityAnchoredBucketStartMs`.
107
+ */
108
+ export declare function marketAnchoredBucketStartMs(exchange: unknown, symbol: unknown, tsMs: number, tfMs: number): number | null;
109
+ /**
110
+ * `rthAnchoredBucketEndMs`: the EXCLUSIVE end of the anchored bucket starting at `bucketStartMs`,
111
+ * `min(start + tfMs, session close)` (a stock's 15:30 hourly bucket ends at 16:00). Null mirrors the start.
112
+ */
113
+ export declare function marketAnchoredBucketEndMs(exchange: unknown, symbol: unknown, bucketStartMs: number, tfMs: number): number | null;
114
+ /**
115
+ * `footprintFoldBucketEndMs`: the instant a folded bucket stops changing. 'anchored' is the anchored end; 'eth'
116
+ * (the market's own full-session grid) is `start + tfMs` capped at the close of the session it holds. With no window,
117
+ * 'anchored' is null and 'eth' the nominal end.
118
+ */
119
+ export declare function marketFoldBucketEndMs(exchange: unknown, symbol: unknown, bucketStartMs: number, tfMs: number, bucketMode: 'anchored' | 'eth'): number | null;
120
+ /**
121
+ * `latestRthSessionBoundsAtOrBefore`: the most recent session whose OPEN is at or before `tsMs`, in session or not
122
+ * (a session-anchored profile shows the last session outside trading hours). CME names CME trade dates only; a stock
123
+ * names the most recent WEEKDAY session (a Saturday or a Monday pre-open names Friday's), with no holiday calendar:
124
+ * a caller picking a session to draw skips one that holds no candles. Null with no window or a non-finite instant.
125
+ */
126
+ export declare function latestMarketSessionBoundsAtOrBefore(exchange: unknown, symbol: unknown, tsMs: number): {
127
+ openMs: number;
128
+ closeMs: number;
129
+ } | null;
130
+ /**
131
+ * `rthWindowsInRange` / us-equities-session.util `usEquityRegularWindowsInRange`: every venue-local calendar day's
132
+ * `[open, close)` window touching `[fromMs, toMs]`, in order. Calendar-based on both markets: Saturday and Sunday
133
+ * windows are listed too, harmless for consumers that shade or reset on BARS (none trade then) and wrong for one that
134
+ * counts windows as trading days. Empty with no window.
135
+ */
136
+ export declare function marketWindowsInRange(exchange: unknown, symbol: unknown, fromMs: number, toMs: number): SessionDayWindow[];