@orangecharts/wrun-chart-host 0.3.0 → 0.5.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 (362) hide show
  1. package/README.md +23 -6
  2. package/dist/constants/exchange-names.leaf.d.ts +8 -0
  3. package/dist/constants/exchange-names.leaf.js +101 -0
  4. package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +15 -0
  5. package/dist/constants/kscript-data-interval-restrictions.constants.js +40 -0
  6. package/dist/constants/opra-compliance.constants.d.ts +19 -0
  7. package/dist/constants/opra-compliance.constants.js +19 -0
  8. package/dist/constants/replay-ladder.leaf.d.ts +30 -0
  9. package/dist/constants/replay-ladder.leaf.js +99 -0
  10. package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +133 -0
  11. package/dist/constants/scriptEditor/builtin-script-snippets.js +451 -0
  12. package/dist/constants/scriptEditor/cme-official-scripts.constants.d.ts +168 -0
  13. package/dist/constants/scriptEditor/cme-official-scripts.constants.js +398 -0
  14. package/dist/constants/scriptEditor/converted-script-id.leaf.d.ts +8 -0
  15. package/dist/constants/scriptEditor/converted-script-id.leaf.js +10 -0
  16. package/dist/constants/scriptEditor/execution.constants.d.ts +4 -0
  17. package/dist/constants/scriptEditor/execution.constants.js +14 -0
  18. package/dist/constants/wrun-prefix-safe.constants.d.ts +23 -0
  19. package/dist/constants/wrun-prefix-safe.constants.js +26 -0
  20. package/dist/host-env.d.ts +321 -24
  21. package/dist/host-env.js +15 -0
  22. package/dist/host-ports.types.d.ts +857 -35
  23. package/dist/index.d.ts +149 -2
  24. package/dist/index.js +149 -2
  25. package/dist/instances/script-engine-worker-ohlcv-transfer.d.ts +31 -0
  26. package/dist/instances/script-engine-worker-ohlcv-transfer.js +164 -0
  27. package/dist/interfaces/market-event.interface.d.ts +231 -0
  28. package/dist/interfaces/market-event.interface.js +15 -0
  29. package/dist/interfaces/opra-realtime.interface.d.ts +70 -134
  30. package/dist/interfaces/opra-realtime.interface.js +34 -59
  31. package/dist/interfaces/replay.interface.d.ts +285 -0
  32. package/dist/interfaces/replay.interface.js +1 -0
  33. package/dist/kscript-data/controls/live-ohlcv-merge.util.d.ts +1 -0
  34. package/dist/kscript-data/controls/live-ohlcv-merge.util.js +93 -0
  35. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +5 -1
  36. package/dist/kscript-data/controls/live-trades-merge.util.js +2 -2
  37. package/dist/market-data/billing.interface.d.ts +219 -0
  38. package/dist/market-data/billing.interface.js +58 -0
  39. package/dist/market-data/venue-governed.util.d.ts +2 -0
  40. package/dist/market-data/venue-governed.util.js +10 -0
  41. package/dist/market-data/venue.d.ts +122 -0
  42. package/dist/market-data/venue.js +1 -0
  43. package/dist/market-data/venues/index.d.ts +97 -0
  44. package/dist/market-data/venues/index.js +33 -0
  45. package/dist/market-data/venues/opra.contract.copy.json +35 -0
  46. package/dist/market-data/venues/opra.d.ts +70 -0
  47. package/dist/market-data/venues/opra.js +74 -0
  48. package/dist/replay/replayIndicatorRows.d.ts +31 -0
  49. package/dist/replay/replayIndicatorRows.js +117 -0
  50. package/dist/replay/replayLadder.d.ts +85 -0
  51. package/dist/replay/replayLadder.js +388 -0
  52. package/dist/utility/auth/server-clock.util.d.ts +81 -0
  53. package/dist/utility/auth/server-clock.util.js +238 -0
  54. package/dist/utility/chart/builtin-identity.util.d.ts +18 -0
  55. package/dist/utility/chart/builtin-identity.util.js +51 -0
  56. package/dist/utility/chart/cache-alignment.util.d.ts +454 -0
  57. package/dist/utility/chart/cache-alignment.util.js +926 -0
  58. package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +15 -0
  59. package/dist/utility/chart/chart-data-fetch-generation.util.js +22 -0
  60. package/dist/utility/chart/chart-mount-epoch.util.d.ts +5 -0
  61. package/dist/utility/chart/chart-mount-epoch.util.js +29 -0
  62. package/dist/utility/chart/chart-time-domain.util.d.ts +12 -0
  63. package/dist/utility/chart/chart-time-domain.util.js +23 -0
  64. package/dist/utility/chart/color-customization.leaf.d.ts +10 -0
  65. package/dist/utility/chart/color-customization.leaf.js +16 -0
  66. package/dist/utility/chart/date-labelled-interval.leaf.d.ts +15 -0
  67. package/dist/utility/chart/date-labelled-interval.leaf.js +19 -0
  68. package/dist/utility/chart/footprint-tick-grid.util.d.ts +106 -0
  69. package/dist/utility/chart/footprint-tick-grid.util.js +167 -0
  70. package/dist/utility/chart/gesture-timing.leaf.d.ts +29 -0
  71. package/dist/utility/chart/gesture-timing.leaf.js +29 -0
  72. package/dist/utility/chart/governed-contract-coin.util.d.ts +22 -0
  73. package/dist/utility/chart/governed-contract-coin.util.js +39 -0
  74. package/dist/utility/chart/host-bar-placement.util.d.ts +107 -0
  75. package/dist/utility/chart/host-bar-placement.util.js +447 -0
  76. package/dist/utility/chart/index-host-tier.util.d.ts +31 -0
  77. package/dist/utility/chart/index-host-tier.util.js +118 -0
  78. package/dist/utility/chart/index-mode-admission.util.d.ts +34 -0
  79. package/dist/utility/chart/index-mode-admission.util.js +67 -0
  80. package/dist/utility/chart/indicator-error-message.util.d.ts +35 -0
  81. package/dist/utility/chart/indicator-error-message.util.js +44 -0
  82. package/dist/utility/chart/indicator-run-interval.util.d.ts +130 -0
  83. package/dist/utility/chart/indicator-run-interval.util.js +268 -0
  84. package/dist/utility/chart/kscript-apply-fingerprint.util.d.ts +65 -0
  85. package/dist/utility/chart/kscript-apply-fingerprint.util.js +357 -0
  86. package/dist/utility/chart/kscript-chart-flush.leaf.d.ts +22 -0
  87. package/dist/utility/chart/kscript-chart-flush.leaf.js +13 -0
  88. package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +6 -0
  89. package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +27 -0
  90. package/dist/utility/chart/kscript-integration-decision.leaf.d.ts +89 -0
  91. package/dist/utility/chart/kscript-integration-decision.leaf.js +80 -0
  92. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +76 -0
  93. package/dist/utility/chart/kscript-live-coalesce.util.js +156 -0
  94. package/dist/utility/chart/kscript-live-rest-pace.util.d.ts +34 -0
  95. package/dist/utility/chart/kscript-live-rest-pace.util.js +134 -0
  96. package/dist/utility/chart/kscript-live-source-identity.util.d.ts +98 -0
  97. package/dist/utility/chart/kscript-live-source-identity.util.js +121 -0
  98. package/dist/utility/chart/kscript-mounted-plot-set.leaf.d.ts +48 -0
  99. package/dist/utility/chart/kscript-mounted-plot-set.leaf.js +145 -0
  100. package/dist/utility/chart/kscript-perf-tracker.util.d.ts +243 -0
  101. package/dist/utility/chart/kscript-perf-tracker.util.js +522 -0
  102. package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +43 -0
  103. package/dist/utility/chart/kscript-run-interval-projection.util.js +471 -0
  104. package/dist/utility/chart/kscript-run-result-equality.util.d.ts +38 -0
  105. package/dist/utility/chart/kscript-run-result-equality.util.js +89 -0
  106. package/dist/utility/chart/kscript-settings-revision.leaf.d.ts +2 -0
  107. package/dist/utility/chart/kscript-settings-revision.leaf.js +12 -0
  108. package/dist/utility/chart/kscript-source-degrade.leaf.d.ts +63 -0
  109. package/dist/utility/chart/kscript-source-degrade.leaf.js +68 -0
  110. package/dist/utility/chart/kscript-source-retention.util.d.ts +134 -0
  111. package/dist/utility/chart/kscript-source-retention.util.js +218 -0
  112. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +57 -0
  113. package/dist/utility/chart/kscript-standin-identity.leaf.js +61 -0
  114. package/dist/utility/chart/kscript-titancharts-preparation.util.d.ts +15 -0
  115. package/dist/utility/chart/kscript-titancharts-preparation.util.js +376 -0
  116. package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +9 -0
  117. package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +130 -0
  118. package/dist/utility/chart/kscript-venue-policy.util.d.ts +217 -0
  119. package/dist/utility/chart/kscript-venue-policy.util.js +324 -0
  120. package/dist/utility/chart/live-cadence.util.d.ts +38 -0
  121. package/dist/utility/chart/live-cadence.util.js +37 -0
  122. package/dist/utility/chart/live-feed-series-match.leaf.d.ts +13 -0
  123. package/dist/utility/chart/live-feed-series-match.leaf.js +21 -0
  124. package/dist/utility/chart/local-engine-self-heal-backoff.util.d.ts +46 -0
  125. package/dist/utility/chart/local-engine-self-heal-backoff.util.js +46 -0
  126. package/dist/utility/chart/local-engine-uninit.leaf.d.ts +21 -0
  127. package/dist/utility/chart/local-engine-uninit.leaf.js +22 -0
  128. package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +62 -0
  129. package/dist/utility/chart/local-kscript-source-revalidation.util.js +123 -0
  130. package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +214 -0
  131. package/dist/utility/chart/local-kscript-warmup-depth.util.js +376 -0
  132. package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.d.ts +85 -0
  133. package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.js +197 -0
  134. package/dist/utility/chart/local-technical-script-range.leaf.d.ts +72 -0
  135. package/dist/utility/chart/local-technical-script-range.leaf.js +126 -0
  136. package/dist/utility/chart/mixed-mode.util.d.ts +167 -0
  137. package/dist/utility/chart/mixed-mode.util.js +139 -0
  138. package/dist/utility/chart/ohlcv-row-readiness.util.d.ts +36 -0
  139. package/dist/utility/chart/ohlcv-row-readiness.util.js +90 -0
  140. package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +19 -0
  141. package/dist/utility/chart/opra-user-scripts-gate.util.js +32 -0
  142. package/dist/utility/chart/overlay-execution-guard-key.leaf.d.ts +8 -0
  143. package/dist/utility/chart/overlay-execution-guard-key.leaf.js +10 -0
  144. package/dist/utility/chart/price-precision.util.d.ts +40 -0
  145. package/dist/utility/chart/price-precision.util.js +70 -0
  146. package/dist/utility/chart/profile-block-size.util.d.ts +64 -0
  147. package/dist/utility/chart/profile-block-size.util.js +141 -0
  148. package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.d.ts +11 -0
  149. package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.js +29 -0
  150. package/dist/utility/chart/protected-kscript-empty-output.util.d.ts +28 -0
  151. package/dist/utility/chart/protected-kscript-empty-output.util.js +84 -0
  152. package/dist/utility/chart/run-interval-unservable.leaf.d.ts +9 -0
  153. package/dist/utility/chart/run-interval-unservable.leaf.js +20 -0
  154. package/dist/utility/chart/run-interval-warmup.leaf.d.ts +19 -0
  155. package/dist/utility/chart/run-interval-warmup.leaf.js +35 -0
  156. package/dist/utility/chart/titan-constants.pin.d.ts +9 -5
  157. package/dist/utility/chart/titan-constants.pin.js +18 -5
  158. package/dist/utility/chart/warmup-backfill-retry.leaf.d.ts +9 -0
  159. package/dist/utility/chart/warmup-backfill-retry.leaf.js +9 -0
  160. package/dist/utility/chart/window-geometry.leaf.d.ts +119 -0
  161. package/dist/utility/chart/window-geometry.leaf.js +391 -0
  162. package/dist/utility/chart/window-owner.leaf.d.ts +19 -0
  163. package/dist/utility/chart/window-owner.leaf.js +24 -0
  164. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +11 -2
  165. package/dist/utility/chart/wrun-bar-session-facts.util.js +10 -3
  166. package/dist/utility/chart/wrun-run-result.util.d.ts +5 -1
  167. package/dist/utility/chart/wrun-run-result.util.js +20 -14
  168. package/dist/utility/common/data-processing.util.d.ts +138 -0
  169. package/dist/utility/common/data-processing.util.js +346 -0
  170. package/dist/utility/common/visible-timeout.util.d.ts +13 -4
  171. package/dist/utility/common/visible-timeout.util.js +23 -8
  172. package/dist/utility/exchange-format.leaf.d.ts +1 -0
  173. package/dist/utility/exchange-format.leaf.js +47 -0
  174. package/dist/utility/html-escape.leaf.d.ts +11 -0
  175. package/dist/utility/html-escape.leaf.js +20 -0
  176. package/dist/utility/market-events/earnings-scope.util.d.ts +60 -0
  177. package/dist/utility/market-events/earnings-scope.util.js +92 -0
  178. package/dist/utility/market-events/market-events.util.d.ts +147 -0
  179. package/dist/utility/market-events/market-events.util.js +392 -0
  180. package/dist/utility/market-events/zoned-clock.util.d.ts +1 -0
  181. package/dist/utility/market-events/zoned-clock.util.js +11 -0
  182. package/dist/utility/options/option-venue-disclosure.util.d.ts +43 -0
  183. package/dist/utility/options/option-venue-disclosure.util.js +56 -0
  184. package/dist/utility/scriptEditor/package-semver.util.d.ts +51 -0
  185. package/dist/utility/scriptEditor/package-semver.util.js +120 -0
  186. package/dist/utility/scriptEditor/temp-script-id.util.d.ts +18 -0
  187. package/dist/utility/scriptEditor/temp-script-id.util.js +25 -0
  188. package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.d.ts +20 -0
  189. package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.js +81 -0
  190. package/dist/utility/v2/governed-tier.leaf.d.ts +103 -0
  191. package/dist/utility/v2/governed-tier.leaf.js +113 -0
  192. package/dist/utility/watchlist/import/import-request.leaf.d.ts +10 -0
  193. package/dist/utility/watchlist/import/import-request.leaf.js +10 -0
  194. package/dist/utility/wrun/sources/lanes/option_daily.d.ts +43 -15
  195. package/dist/utility/wrun/sources/lanes/option_daily.js +78 -20
  196. package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +14 -10
  197. package/dist/utility/wrun/sources/lanes/option_stats_10m.js +5 -4
  198. package/dist/utility/wrun/sources/lanes/series.js +2 -2
  199. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +22 -3
  200. package/dist/utility/wrun/sources/opra-option-lanes.util.js +38 -7
  201. package/dist/utility/wrun/sources/registry.js +31 -1
  202. package/dist/utility/wrun/sources/row-lane-registry.js +5 -5
  203. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +49 -0
  204. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +75 -20
  205. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +49 -0
  206. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +57 -47
  207. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +36 -4
  208. package/dist/utility/wrun/sources/row-lanes/option_surface.js +6 -12
  209. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +37 -3
  210. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +128 -2
  211. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +233 -51
  212. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +0 -8
  213. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +26 -24
  214. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +85 -104
  215. package/dist/utility/wrun/wrun-alert-outputs.registry.d.ts +166 -0
  216. package/dist/utility/wrun/wrun-alert-outputs.registry.js +219 -0
  217. package/dist/utility/wrun/wrun-bar-count.util.d.ts +83 -0
  218. package/dist/utility/wrun/wrun-bar-count.util.js +259 -0
  219. package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +84 -0
  220. package/dist/utility/wrun/wrun-chart-context-names.util.js +186 -0
  221. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +253 -0
  222. package/dist/utility/wrun/wrun-chart-market-facts.util.js +731 -0
  223. package/dist/utility/wrun/wrun-cloud-opra-stamp.util.d.ts +28 -0
  224. package/dist/utility/wrun/wrun-cloud-opra-stamp.util.js +45 -0
  225. package/dist/utility/wrun/wrun-coin-lane-live.util.d.ts +18 -0
  226. package/dist/utility/wrun/wrun-coin-lane-live.util.js +47 -0
  227. package/dist/utility/wrun/wrun-deadline.util.js +2 -1
  228. package/dist/utility/wrun/wrun-debug-output.util.d.ts +39 -0
  229. package/dist/utility/wrun/wrun-debug-output.util.js +63 -0
  230. package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +113 -0
  231. package/dist/utility/wrun/wrun-declared-warmup.util.js +181 -0
  232. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +43 -0
  233. package/dist/utility/wrun/wrun-draft-legend-note.util.js +158 -0
  234. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +181 -0
  235. package/dist/utility/wrun/wrun-draft-overlay.util.js +357 -0
  236. package/dist/utility/wrun/wrun-draw-skipped.leaf.d.ts +16 -0
  237. package/dist/utility/wrun/wrun-draw-skipped.leaf.js +16 -0
  238. package/dist/utility/wrun/wrun-earnings-facts.util.d.ts +42 -0
  239. package/dist/utility/wrun/wrun-earnings-facts.util.js +131 -0
  240. package/dist/utility/wrun/wrun-first-run-depth.util.d.ts +32 -0
  241. package/dist/utility/wrun/wrun-first-run-depth.util.js +118 -0
  242. package/dist/utility/wrun/wrun-gate-plane-readers.util.d.ts +24 -0
  243. package/dist/utility/wrun/wrun-gate-plane-readers.util.js +31 -0
  244. package/dist/utility/wrun/wrun-held-lanes.util.d.ts +32 -0
  245. package/dist/utility/wrun/wrun-held-lanes.util.js +94 -0
  246. package/dist/utility/wrun/wrun-host-visible-clock.util.d.ts +2 -0
  247. package/dist/utility/wrun/wrun-host-visible-clock.util.js +17 -0
  248. package/dist/utility/wrun/wrun-host.service.d.ts +266 -0
  249. package/dist/utility/wrun/wrun-host.service.js +655 -0
  250. package/dist/utility/wrun/wrun-inert-legend.util.d.ts +33 -0
  251. package/dist/utility/wrun/wrun-inert-legend.util.js +125 -0
  252. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +155 -0
  253. package/dist/utility/wrun/wrun-input-requirements.leaf.js +450 -0
  254. package/dist/utility/wrun/wrun-integration-route.util.d.ts +51 -0
  255. package/dist/utility/wrun/wrun-integration-route.util.js +59 -0
  256. package/dist/utility/wrun/wrun-latest-history.leaf.d.ts +8 -0
  257. package/dist/utility/wrun/wrun-latest-history.leaf.js +8 -0
  258. package/dist/utility/wrun/wrun-legend-hover.lazy.d.ts +12 -0
  259. package/dist/utility/wrun/wrun-legend-hover.lazy.js +96 -0
  260. package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +21 -0
  261. package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +21 -0
  262. package/dist/utility/wrun/wrun-live-hidden-hold.util.d.ts +23 -0
  263. package/dist/utility/wrun/wrun-live-hidden-hold.util.js +13 -0
  264. package/dist/utility/wrun/wrun-live-intake.util.d.ts +374 -0
  265. package/dist/utility/wrun/wrun-live-intake.util.js +2027 -0
  266. package/dist/utility/wrun/wrun-live-patch.util.d.ts +116 -0
  267. package/dist/utility/wrun/wrun-live-patch.util.js +523 -0
  268. package/dist/utility/wrun/wrun-live-tick.util.d.ts +619 -0
  269. package/dist/utility/wrun/wrun-live-tick.util.js +4974 -0
  270. package/dist/utility/wrun/wrun-loading-owner.util.d.ts +58 -0
  271. package/dist/utility/wrun/wrun-loading-owner.util.js +89 -0
  272. package/dist/utility/wrun/wrun-official-scope.leaf.d.ts +29 -0
  273. package/dist/utility/wrun/wrun-official-scope.leaf.js +36 -0
  274. package/dist/utility/wrun/wrun-oi-lane.util.d.ts +27 -0
  275. package/dist/utility/wrun/wrun-oi-lane.util.js +42 -0
  276. package/dist/utility/wrun/wrun-opra-stats.leaf.d.ts +29 -10
  277. package/dist/utility/wrun/wrun-opra-stats.leaf.js +29 -10
  278. package/dist/utility/wrun/wrun-options-stop.util.d.ts +52 -0
  279. package/dist/utility/wrun/wrun-options-stop.util.js +123 -0
  280. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +719 -0
  281. package/dist/utility/wrun/wrun-overlay-drivers.util.js +1180 -0
  282. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +50 -0
  283. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +131 -0
  284. package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +118 -0
  285. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +466 -0
  286. package/dist/utility/wrun/wrun-overlay-metadata.util.d.ts +45 -0
  287. package/dist/utility/wrun/wrun-overlay-metadata.util.js +112 -0
  288. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +114 -0
  289. package/dist/utility/wrun/wrun-overlay-recovery.util.js +971 -0
  290. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +858 -0
  291. package/dist/utility/wrun/wrun-overlay-run.util.js +11013 -0
  292. package/dist/utility/wrun/wrun-panel-mount.lazy.d.ts +10 -0
  293. package/dist/utility/wrun/wrun-panel-mount.lazy.js +68 -0
  294. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +392 -0
  295. package/dist/utility/wrun/wrun-panel-mount.util.js +2346 -0
  296. package/dist/utility/wrun/wrun-param-map.util.d.ts +19 -4
  297. package/dist/utility/wrun/wrun-param-map.util.js +40 -47
  298. package/dist/utility/wrun/wrun-param-values.util.d.ts +9 -3
  299. package/dist/utility/wrun/wrun-param-values.util.js +5 -5
  300. package/dist/utility/wrun/wrun-pause-dim.util.d.ts +52 -0
  301. package/dist/utility/wrun/wrun-pause-dim.util.js +153 -0
  302. package/dist/utility/wrun/wrun-plot-gate.types.d.ts +23 -0
  303. package/dist/utility/wrun/wrun-plot-gate.types.js +7 -0
  304. package/dist/utility/wrun/wrun-prefix-cohort.util.d.ts +93 -0
  305. package/dist/utility/wrun/wrun-prefix-cohort.util.js +484 -0
  306. package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +114 -0
  307. package/dist/utility/wrun/wrun-prefix-lanes.util.js +486 -0
  308. package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +317 -0
  309. package/dist/utility/wrun/wrun-prefix-proof.util.js +630 -0
  310. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +73 -0
  311. package/dist/utility/wrun/wrun-refusal-surface.util.js +380 -0
  312. package/dist/utility/wrun/wrun-refusal-text.util.d.ts +15 -0
  313. package/dist/utility/wrun/wrun-refusal-text.util.js +40 -0
  314. package/dist/utility/wrun/wrun-replay-lane.util.d.ts +139 -0
  315. package/dist/utility/wrun/wrun-replay-lane.util.js +520 -0
  316. package/dist/utility/wrun/wrun-replay-rows.util.d.ts +21 -0
  317. package/dist/utility/wrun/wrun-replay-rows.util.js +172 -0
  318. package/dist/utility/wrun/wrun-row-source-factory.d.ts +53 -0
  319. package/dist/utility/wrun/wrun-row-source-factory.js +435 -0
  320. package/dist/utility/wrun/wrun-run-cells.util.d.ts +36 -0
  321. package/dist/utility/wrun/wrun-run-cells.util.js +46 -0
  322. package/dist/utility/wrun/wrun-run-interval-projection.types.d.ts +14 -0
  323. package/dist/utility/wrun/wrun-run-interval-projection.types.js +1 -0
  324. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +133 -0
  325. package/dist/utility/wrun/wrun-run-interval-session.util.js +121 -0
  326. package/dist/utility/wrun/wrun-run-interval.util.d.ts +98 -0
  327. package/dist/utility/wrun/wrun-run-interval.util.js +207 -0
  328. package/dist/utility/wrun/wrun-run-retained.util.d.ts +122 -0
  329. package/dist/utility/wrun/wrun-run-retained.util.js +255 -0
  330. package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +184 -0
  331. package/dist/utility/wrun/wrun-sandbox-row-source.js +444 -0
  332. package/dist/utility/wrun/wrun-script-inputs.util.js +4 -4
  333. package/dist/utility/wrun/wrun-series-stream.util.d.ts +86 -0
  334. package/dist/utility/wrun/wrun-series-stream.util.js +537 -0
  335. package/dist/utility/wrun/wrun-sheet-remembered.util.d.ts +21 -0
  336. package/dist/utility/wrun/wrun-sheet-remembered.util.js +36 -0
  337. package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.d.ts +7 -0
  338. package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.js +12 -0
  339. package/dist/utility/wrun/wrun-socket-row-source.js +4 -2
  340. package/dist/utility/wrun/wrun-source-rows.util.d.ts +175 -3
  341. package/dist/utility/wrun/wrun-source-rows.util.js +294 -8
  342. package/dist/utility/wrun/wrun-stats-strip.util.d.ts +46 -0
  343. package/dist/utility/wrun/wrun-stats-strip.util.js +87 -0
  344. package/dist/utility/wrun/wrun-table-chrome.util.d.ts +163 -0
  345. package/dist/utility/wrun/wrun-table-chrome.util.js +557 -0
  346. package/dist/utility/wrun/wrun-text-params.util.d.ts +11 -6
  347. package/dist/utility/wrun/wrun-text-params.util.js +19 -30
  348. package/dist/utility/wrun/wrun-transient-rerun.util.d.ts +64 -0
  349. package/dist/utility/wrun/wrun-transient-rerun.util.js +317 -0
  350. package/dist/utility/wrun/wrun-twin-lookback.util.d.ts +10 -0
  351. package/dist/utility/wrun/wrun-twin-lookback.util.js +43 -0
  352. package/dist/utility/wrun/wrun-warmup-head-store.util.d.ts +41 -0
  353. package/dist/utility/wrun/wrun-warmup-head-store.util.js +120 -0
  354. package/dist/utility/wrun-alert-params.leaf.d.ts +24 -0
  355. package/dist/utility/wrun-alert-params.leaf.js +24 -0
  356. package/dist/utils/replay/replay-buffer-math.d.ts +148 -0
  357. package/dist/utils/replay/replay-buffer-math.js +684 -0
  358. package/dist/workers/wrun/wrun-abi-host.d.ts +190 -0
  359. package/dist/workers/wrun/wrun-abi-host.js +1201 -0
  360. package/dist/workers/wrun/wrun-engine-handler.d.ts +37 -0
  361. package/dist/workers/wrun/wrun-engine-handler.js +211 -0
  362. package/package.json +3 -3
@@ -0,0 +1,107 @@
1
+ /**
2
+ * The host bar that holds each row: ONE placement for every series that rides another bar grid than the chart it
3
+ * lands on. Since 2026-09-16 a regular-session US stock's 45m to 12h bars open on the 09:30 New York anchor (13:30Z
4
+ * hours in EDT, the session's last bar a stub closing at 16:00), while a 24/7 series buckets on the UTC grid (:00
5
+ * hours). A row matched to the host's bars by its exact timestamp never lands there; this module puts each row in
6
+ * the host bar whose [open, close) holds it, through the host's own bucket function (`liveBucketStartMs` over
7
+ * `liveBucketVenueOf(<host metadata>)`), and merges a bar's rows by the series' kind.
8
+ *
9
+ * Its readers: the app's overlay doors (`filterIndicatorData`'s index branch, the cache paint, the live doors), the
10
+ * kScript source alignment (`dataFetch`) and the wrun row builder's grid and trades legs (`wrun-source-rows.util`),
11
+ * so the package and the app place a row the same way. The app re-exports every name from `overlay-grid-rule.util`.
12
+ *
13
+ * The code below is the app's placement as the anchored-host fix round left it (015defa671), moved byte for byte
14
+ * apart from its import paths.
15
+ *
16
+ * Pure: the package's bucket function and session option, nothing else.
17
+ */
18
+ import { type LiveBucketVenue } from './live-bucket.util.js';
19
+ /**
20
+ * How a host merges what lands in one of its bars: `flow` sums the rows,
21
+ * `level` keeps the last row, `candle` folds OHLCV rows into one candle, and
22
+ * `cells` (rows of time-stamped cells: a trade tape, option prints) places
23
+ * each CELL by its own instant, its offset rebased to the bar's open.
24
+ */
25
+ export type IndexHostMerge = 'flow' | 'level' | 'candle' | 'cells';
26
+ /** An index-mode host's bars as the placement reads them. */
27
+ export interface IndexHostBars {
28
+ /** The mounted main candles, ascending by timestamp (ms). */
29
+ mainRows: readonly number[][];
30
+ /** The chart interval in ms. */
31
+ intervalMs: number;
32
+ /** The host chart's bar-grid identity (`liveBucketVenueOf(metadata)`); absent, the UTC floor. */
33
+ venue?: LiveBucketVenue | null;
34
+ }
35
+ /**
36
+ * The row one host bar shows for the rows it holds, in timestamp order (the
37
+ * merge `placeRowsInHostBars` runs per bar): a single row stamped on the bar's
38
+ * open is itself, anything else a new row (`flow` sums, `level` keeps the
39
+ * last, `candle` folds). Exported for a live door that re-places one bar
40
+ * from its own rows, with no bucket call.
41
+ */
42
+ export declare function hostBarRowOf(barTs: number, rows: readonly number[][], merge: Exclude<IndexHostMerge, 'cells'>): number[];
43
+ /** Options of `placeRowsInHostBars`. */
44
+ export interface PlaceRowsInHostBarsOptions {
45
+ /**
46
+ * The span of each row: the rows' OWN interval (their wire interval, never
47
+ * the chart's; a 1m leg on a 5m chart passes 1m). With it a row lands in the
48
+ * host bar holding its LAST instant (`ts + rowSpanMs - 1`), so a closed host
49
+ * bar holds only values known by its close (TradingView's `request.security`
50
+ * with lookahead off): a 24/7 hour [14:00, 15:00) lands in a stock's 14:30
51
+ * bar, never in the 13:30 bar it opens in, and the 15:30 stub holds the
52
+ * [15:00, 16:00) hour. A row stamped on a host bar's open stays in that bar
53
+ * (a series on the host grid comes back as the same objects); a row whose
54
+ * last instant falls in a bar the host has not printed yet (still forming at
55
+ * the live edge) lands in the bar holding its open, so the forming bar shows
56
+ * the latest value; any other row is dropped. Without it a row lands in the
57
+ * bar holding its open (the overlay doors' tier rows sit inside one host bar).
58
+ */
59
+ rowSpanMs?: number;
60
+ /**
61
+ * The host bar forming NOW (`liveBucketStartMs` of the server clock's now),
62
+ * or null when the chart is not live (go-to-date history). The live-edge
63
+ * rule of `rowSpanMs` applies only to a row whose open falls in this bar;
64
+ * absent or null, no row takes it.
65
+ */
66
+ formingBarTs?: number | null;
67
+ }
68
+ /**
69
+ * Place every row in the host bar whose [open, close) holds its timestamp and
70
+ * merge each bar's rows (`merge`: a flow sums, a level keeps the last row, a
71
+ * candle opens on the first row, spans the rows' high and low, closes on the
72
+ * last and sums the volume).
73
+ * A row stamped on a bar lands on it; any other row lands on the last bar
74
+ * opening before it when that bar is still open at the row's instant: a bar
75
+ * whose successor opens exactly one interval later spans the gap between them,
76
+ * and any other bar (the session's stub before the close, a bar before a
77
+ * halt, a session-long bar at 8h or 12h, the last bar) asks the host's own
78
+ * bucket function (`liveBucketStartMs` over `venue`) once per bar span, not
79
+ * once per row (`heldRowsAfterOpen`). Rows before the first bar, off session
80
+ * or in a bar the host does not hold are dropped. A bar holding one row
81
+ * stamped on it keeps that row object, so a series already on the host grid
82
+ * comes back as the exact timestamp filter returned it; every other bar's row
83
+ * is new and is handed to `onMade`. `opts.rowSpanMs` places each row by its
84
+ * last instant instead (`PlaceRowsInHostBarsOptions`).
85
+ */
86
+ export declare function placeRowsInHostBars(rows: readonly number[][], bars: IndexHostBars, merge: IndexHostMerge, onMade?: (row: number[]) => void, opts?: PlaceRowsInHostBarsOptions): number[][];
87
+ /**
88
+ * A host's bucket function for a stream of instants (a live door's ticks):
89
+ * `liveBucketStartMs` over `venue` at `intervalMs`, asked only when an instant
90
+ * leaves the span it last resolved. A bar's span is [its start, its true
91
+ * end): the interval, cut at the session close for a stub bar (the end found
92
+ * once per bar by bisection on the minute grid every session boundary sits
93
+ * on); an off-session instant resolves to null for its own minute. So 1,000
94
+ * ticks inside one bar ask the bucket function a handful of times (on a
95
+ * regular-session stock above 30m each call is several time-zone
96
+ * conversions), never once per tick.
97
+ *
98
+ * A bar whose instants do not all sit in [stamp, end) misses that span: a CME
99
+ * trade-date bar (1D, 3D, 1W and the months, stamped 00:00Z) opens at 22:00Z
100
+ * or 23:00Z the evening before its stamp, and a regular-session stock's 3D bar
101
+ * holds three sessions with nights between them. Each bar's end is therefore
102
+ * remembered (the last few bars a door met), so such a miss costs the one
103
+ * bucket call that names the bar, never the end's bisection again.
104
+ */
105
+ export declare function createHostBucketResolver(intervalMs: number, venue: LiveBucketVenue | null | undefined): (tsMs: number) => number | null;
106
+ /** The shared `createHostBucketResolver` of a host grid (every live door on that grid reuses its cached span). */
107
+ export declare function hostBucketResolverFor(intervalMs: number, venue: LiveBucketVenue | null | undefined): (tsMs: number) => number | null;
@@ -0,0 +1,447 @@
1
+ /**
2
+ * The host bar that holds each row: ONE placement for every series that rides another bar grid than the chart it
3
+ * lands on. Since 2026-09-16 a regular-session US stock's 45m to 12h bars open on the 09:30 New York anchor (13:30Z
4
+ * hours in EDT, the session's last bar a stub closing at 16:00), while a 24/7 series buckets on the UTC grid (:00
5
+ * hours). A row matched to the host's bars by its exact timestamp never lands there; this module puts each row in
6
+ * the host bar whose [open, close) holds it, through the host's own bucket function (`liveBucketStartMs` over
7
+ * `liveBucketVenueOf(<host metadata>)`), and merges a bar's rows by the series' kind.
8
+ *
9
+ * Its readers: the app's overlay doors (`filterIndicatorData`'s index branch, the cache paint, the live doors), the
10
+ * kScript source alignment (`dataFetch`) and the wrun row builder's grid and trades legs (`wrun-source-rows.util`),
11
+ * so the package and the app place a row the same way. The app re-exports every name from `overlay-grid-rule.util`.
12
+ *
13
+ * The code below is the app's placement as the anchored-host fix round left it (015defa671), moved byte for byte
14
+ * apart from its import paths.
15
+ *
16
+ * Pure: the package's bucket function and session option, nothing else.
17
+ */
18
+ import { liveBucketStartMs } from './live-bucket.util.js';
19
+ import { usEquitiesSessionConfig } from './us-equities-session.util.js';
20
+ function isAscendingByTs(rows) {
21
+ for (let i = 1; i < rows.length; i++)
22
+ if (rows[i][0] < rows[i - 1][0])
23
+ return false;
24
+ return true;
25
+ }
26
+ // A candle bar's columns 1 to 5 (open, high, low, close, volume); every later column is the last row's.
27
+ const CANDLE_COLUMN_MERGE = ['first', 'max', 'min', 'last', 'sum'];
28
+ /** The column's merged cell: max, min and sum skip non-finite cells, and a column with none keeps the last row's. */
29
+ function mergeColumn(rows, column, how) {
30
+ const last = rows[rows.length - 1][column];
31
+ if (how === 'first')
32
+ return rows[0][column];
33
+ if (how === 'last')
34
+ return last;
35
+ let merged = null;
36
+ for (const row of rows) {
37
+ const value = row[column];
38
+ if (typeof value !== 'number' || !Number.isFinite(value))
39
+ continue;
40
+ if (merged === null)
41
+ merged = value;
42
+ else if (how === 'sum')
43
+ merged += value;
44
+ else if (how === 'max')
45
+ merged = Math.max(merged, value);
46
+ else
47
+ merged = Math.min(merged, value);
48
+ }
49
+ return merged ?? last;
50
+ }
51
+ /** A flow bar sums every column; a candle bar merges its OHLCV columns (CANDLE_COLUMN_MERGE). */
52
+ function mergeRowsOntoBar(barTs, rows, merge) {
53
+ let width = 0;
54
+ for (const row of rows)
55
+ width = Math.max(width, row.length);
56
+ const out = [barTs];
57
+ for (let column = 1; column < width; column++) {
58
+ const how = merge === 'flow' ? 'sum' : (CANDLE_COLUMN_MERGE[column - 1] ?? 'last');
59
+ out.push(mergeColumn(rows, column, how));
60
+ }
61
+ return out;
62
+ }
63
+ /**
64
+ * The row one host bar shows for the rows it holds, in timestamp order (the
65
+ * merge `placeRowsInHostBars` runs per bar): a single row stamped on the bar's
66
+ * open is itself, anything else a new row (`flow` sums, `level` keeps the
67
+ * last, `candle` folds). Exported for a live door that re-places one bar
68
+ * from its own rows, with no bucket call.
69
+ */
70
+ export function hostBarRowOf(barTs, rows, merge) {
71
+ if (rows.length === 1 && rows[0][0] === barTs)
72
+ return rows[0];
73
+ return merge === 'level' ? [barTs, ...rows[rows.length - 1].slice(1)] : mergeRowsOntoBar(barTs, rows, merge);
74
+ }
75
+ const hasFiniteTs = (row) => {
76
+ const ts = row?.[0];
77
+ return typeof ts === 'number' && Number.isFinite(ts);
78
+ };
79
+ /**
80
+ * How many of the row keys `keyAt(from..to)` (instants after `barTs` and
81
+ * before the next mounted bar opens) the bar opening at `barTs` holds, by the
82
+ * host's own bucket function. A bar's span is contiguous and bucket starts
83
+ * never fall back, so the held keys are a prefix: found by bisection, the
84
+ * previous bar's count (`hint`: bars of one grid hold the same rows) tried
85
+ * first. A run of like bars asks the bucket function twice per bar, any bar
86
+ * about log2 of its rows: never once per row (a session-long 12h stock bar
87
+ * spans a day of 30m tier rows, and the function costs a time-zone parse per
88
+ * call).
89
+ */
90
+ function heldRowsAfterOpen(keyAt, from, to, barTs, intervalMs, venue, hint) {
91
+ const held = (index) => liveBucketStartMs(keyAt(index), intervalMs, venue) === barTs;
92
+ // Rows before `lo` are held; rows from `hi` on are not.
93
+ let lo = from;
94
+ let hi = to;
95
+ const guess = from + hint;
96
+ if (guess > lo && guess <= hi) {
97
+ if (held(guess - 1))
98
+ lo = guess;
99
+ else
100
+ hi = guess - 1;
101
+ }
102
+ if (guess >= lo && guess < hi) {
103
+ if (held(guess))
104
+ lo = guess + 1;
105
+ else
106
+ hi = guess;
107
+ }
108
+ while (lo < hi) {
109
+ const mid = (lo + hi) >>> 1;
110
+ if (held(mid))
111
+ lo = mid + 1;
112
+ else
113
+ hi = mid;
114
+ }
115
+ return lo - from;
116
+ }
117
+ /**
118
+ * The bar sweep both placements share: one walk over the mounted bars and the
119
+ * row keys ascending (`count` keys read by `keyAt`), handing each bar the run
120
+ * of keys it holds (`onBar(barIndex, from, to)`): the keys on its open, then
121
+ * the keys after it that its span holds. A bar whose successor opens exactly
122
+ * one interval later spans the gap between them; any other bar (the session's
123
+ * stub before the close, a bar before a halt, a session-long bar at 8h or
124
+ * 12h, the last bar) asks the host's bucket function once per bar span
125
+ * (`heldRowsAfterOpen`). Keys before the first bar, off session or in a bar
126
+ * the host does not hold land nowhere. Returns where the keys the LAST bar
127
+ * does not hold begin (`count` when none is left past it).
128
+ */
129
+ function sweepHostBars(count, keyAt, main, intervalMs, venue, onBar) {
130
+ let next = 0;
131
+ let hint = 0;
132
+ let pastLastBar = count;
133
+ for (let barIndex = 0; barIndex < main.length && next < count; barIndex++) {
134
+ const barTs = main[barIndex][0];
135
+ const nextTs = main[barIndex + 1]?.[0];
136
+ // Rows before the first bar, and rows a previous bar's span ended before, land nowhere.
137
+ while (next < count && keyAt(next) < barTs)
138
+ next++;
139
+ let afterOpen = next;
140
+ while (afterOpen < count && keyAt(afterOpen) === barTs)
141
+ afterOpen++;
142
+ let end = afterOpen;
143
+ while (end < count && (nextTs === undefined || keyAt(end) < nextTs))
144
+ end++;
145
+ let held = end;
146
+ if (nextTs !== barTs + intervalMs && end > afterOpen) {
147
+ hint = heldRowsAfterOpen(keyAt, afterOpen, end, barTs, intervalMs, venue, hint);
148
+ held = afterOpen + hint;
149
+ }
150
+ if (held > next)
151
+ onBar(barIndex, next, held);
152
+ if (nextTs === undefined)
153
+ pastLastBar = held;
154
+ next = end;
155
+ }
156
+ return pastLastBar;
157
+ }
158
+ /** The index of the mounted bar whose [open, close) holds `ms` (the sweep's own span rule), or -1. */
159
+ function barIndexHolding(main, ms, intervalMs, venue) {
160
+ let lo = 0;
161
+ let hi = main.length - 1;
162
+ let found = -1;
163
+ while (lo <= hi) {
164
+ const mid = (lo + hi) >>> 1;
165
+ if (main[mid][0] <= ms) {
166
+ found = mid;
167
+ lo = mid + 1;
168
+ }
169
+ else
170
+ hi = mid - 1;
171
+ }
172
+ if (found < 0)
173
+ return -1;
174
+ const barTs = main[found][0];
175
+ if (ms === barTs || main[found + 1]?.[0] === barTs + intervalMs)
176
+ return found;
177
+ return liveBucketStartMs(ms, intervalMs, venue) === barTs ? found : -1;
178
+ }
179
+ function isAscendingNumbers(values) {
180
+ for (let i = 1; i < values.length; i++)
181
+ if (values[i] < values[i - 1])
182
+ return false;
183
+ return true;
184
+ }
185
+ /**
186
+ * The last-instant placement (`PlaceRowsInHostBarsOptions.rowSpanMs`): every
187
+ * row keys on its last instant (`ts + rowSpanMs - 1`) unless it is stamped on
188
+ * a mounted bar's open, the shared sweep lands the keys, and a row whose last
189
+ * instant only a bar after the last mounted one holds (the live edge) lands in
190
+ * the bar holding its open. Each bar's rows merge in timestamp order.
191
+ */
192
+ function placeRowsByLastInstant(sorted, bars, rowSpanMs, formingBarTs, land) {
193
+ const main = bars.mainRows;
194
+ const { intervalMs } = bars;
195
+ const venue = bars.venue ?? undefined;
196
+ const opens = new Set();
197
+ for (const bar of main)
198
+ opens.add(bar[0]);
199
+ const keys = sorted.map((row) => (opens.has(row[0]) ? row[0] : row[0] + rowSpanMs - 1));
200
+ const order = keys.map((_, index) => index);
201
+ // Rows denser than their span can key out of order: sort by key, ties in timestamp order.
202
+ if (!isAscendingNumbers(keys))
203
+ order.sort((a, b) => keys[a] - keys[b] || a - b);
204
+ const groups = new Map();
205
+ const pastLastBar = sweepHostBars(order.length, (k) => keys[order[k]], main, intervalMs, venue, (barIndex, from, to) => groups.set(barIndex, order.slice(from, to)));
206
+ // The live edge: a row whose last instant falls in a bar the host has not
207
+ // printed yet is still forming, and the bar holding its open shows its
208
+ // latest value, but only when that bar is the one forming NOW
209
+ // (`formingBarTs`). A series ending at a closed bar (go-to-date history, a
210
+ // thin stock before its next print) has no forming bar: a completed later
211
+ // row there would put its close into a bar that closed before it, and is
212
+ // dropped. Keys ascend, so once a row opens past the last bar every later
213
+ // one does too.
214
+ const lastBarTs = main[main.length - 1][0];
215
+ for (let k = pastLastBar; formingBarTs !== null && k < order.length; k++) {
216
+ const index = order[k];
217
+ const openTs = sorted[index][0];
218
+ const openBar = barIndexHolding(main, openTs, intervalMs, venue);
219
+ if (openBar < 0) {
220
+ if (openTs > lastBarTs)
221
+ break;
222
+ continue;
223
+ }
224
+ if (main[openBar][0] !== formingBarTs)
225
+ continue;
226
+ const lastBar = liveBucketStartMs(keys[index], intervalMs, venue);
227
+ if (lastBar === null || lastBar <= lastBarTs)
228
+ continue;
229
+ const group = groups.get(openBar);
230
+ if (group)
231
+ group.push(index);
232
+ else
233
+ groups.set(openBar, [index]);
234
+ }
235
+ for (const barIndex of [...groups.keys()].sort((a, b) => a - b)) {
236
+ const indexes = groups.get(barIndex);
237
+ if (!isAscendingNumbers(indexes))
238
+ indexes.sort((a, b) => a - b);
239
+ land(main[barIndex][0], indexes.map((index) => sorted[index]));
240
+ }
241
+ }
242
+ /**
243
+ * The `cells` placement: every cell of every row (`[offsetMs, ...]`, the
244
+ * offset from its row's timestamp) lands in the host bar holding its own
245
+ * instant (`rowTs + offsetMs`), and a bar's row is `[barTs, ...cells]` in
246
+ * time order with each offset rebased to `barTs`, so a print reads its true
247
+ * instant on every grid (re-stamped whole, a 13:05Z print in a 13:00Z hour
248
+ * read 13:35Z on a 13:30Z bar). A print is an instant, so no span applies and
249
+ * a closed bar never holds a later one. A bar whose cells all come from one
250
+ * row stamped on its open keeps that row object, and a cell-less row stamped
251
+ * on an otherwise empty bar's open stays too (a series on the host grid comes
252
+ * back as the same objects); every other bar's row is new (`onMade`).
253
+ */
254
+ function placeCellsInHostBars(sorted, bars, out, onMade) {
255
+ const main = bars.mainRows;
256
+ const opens = new Set();
257
+ for (const bar of main)
258
+ opens.add(bar[0]);
259
+ const instants = [];
260
+ const cells = [];
261
+ const owners = [];
262
+ const bare = new Map();
263
+ for (let index = 0; index < sorted.length; index++) {
264
+ const row = sorted[index];
265
+ let held = 0;
266
+ for (let column = 1; column < row.length; column++) {
267
+ const cell = row[column];
268
+ const offset = Array.isArray(cell) ? Number(cell[0]) : NaN;
269
+ if (!Number.isFinite(offset))
270
+ continue;
271
+ instants.push(row[0] + offset);
272
+ cells.push(cell);
273
+ owners.push(index);
274
+ held++;
275
+ }
276
+ if (held === 0 && opens.has(row[0]))
277
+ bare.set(row[0], row);
278
+ }
279
+ const order = instants.map((_, k) => k);
280
+ if (!isAscendingNumbers(instants))
281
+ order.sort((a, b) => instants[a] - instants[b] || a - b);
282
+ const byBar = new Map();
283
+ sweepHostBars(order.length, (k) => instants[order[k]], main, bars.intervalMs, bars.venue ?? undefined, (barIndex, from, to) => byBar.set(main[barIndex][0], order.slice(from, to)));
284
+ for (const barTs of bare.keys())
285
+ if (!byBar.has(barTs))
286
+ byBar.set(barTs, []);
287
+ for (const barTs of [...byBar.keys()].sort((a, b) => a - b)) {
288
+ const picked = byBar.get(barTs);
289
+ if (picked.length === 0) {
290
+ out.push(bare.get(barTs));
291
+ continue;
292
+ }
293
+ const owner = sorted[owners[picked[0]]];
294
+ const ownerCells = owner.length - 1;
295
+ if (owner[0] === barTs &&
296
+ picked.length === ownerCells &&
297
+ picked.every((k) => sorted[owners[k]] === owner) &&
298
+ isAscendingNumbers(picked.map((k) => instants[k]))) {
299
+ out.push(owner);
300
+ continue;
301
+ }
302
+ const row = [barTs];
303
+ for (const k of picked)
304
+ row.push([instants[k] - barTs, ...cells[k].slice(1)]);
305
+ onMade?.(row);
306
+ out.push(row);
307
+ }
308
+ }
309
+ /**
310
+ * Place every row in the host bar whose [open, close) holds its timestamp and
311
+ * merge each bar's rows (`merge`: a flow sums, a level keeps the last row, a
312
+ * candle opens on the first row, spans the rows' high and low, closes on the
313
+ * last and sums the volume).
314
+ * A row stamped on a bar lands on it; any other row lands on the last bar
315
+ * opening before it when that bar is still open at the row's instant: a bar
316
+ * whose successor opens exactly one interval later spans the gap between them,
317
+ * and any other bar (the session's stub before the close, a bar before a
318
+ * halt, a session-long bar at 8h or 12h, the last bar) asks the host's own
319
+ * bucket function (`liveBucketStartMs` over `venue`) once per bar span, not
320
+ * once per row (`heldRowsAfterOpen`). Rows before the first bar, off session
321
+ * or in a bar the host does not hold are dropped. A bar holding one row
322
+ * stamped on it keeps that row object, so a series already on the host grid
323
+ * comes back as the exact timestamp filter returned it; every other bar's row
324
+ * is new and is handed to `onMade`. `opts.rowSpanMs` places each row by its
325
+ * last instant instead (`PlaceRowsInHostBarsOptions`).
326
+ */
327
+ export function placeRowsInHostBars(rows, bars, merge, onMade, opts) {
328
+ const main = bars.mainRows;
329
+ const out = [];
330
+ if (!rows.length || !main.length)
331
+ return out;
332
+ const finite = rows.every(hasFiniteTs) ? rows : rows.filter(hasFiniteTs);
333
+ const sorted = isAscendingByTs(finite) ? finite : [...finite].sort((a, b) => a[0] - b[0]);
334
+ if (merge === 'cells') {
335
+ placeCellsInHostBars(sorted, bars, out, onMade);
336
+ return out;
337
+ }
338
+ const land = (barTs, group) => {
339
+ const row = hostBarRowOf(barTs, group, merge);
340
+ if (row !== group[0])
341
+ onMade?.(row);
342
+ out.push(row);
343
+ };
344
+ const rowSpanMs = opts?.rowSpanMs;
345
+ if (typeof rowSpanMs === 'number' && Number.isFinite(rowSpanMs) && rowSpanMs > 0) {
346
+ placeRowsByLastInstant(sorted, bars, rowSpanMs, opts?.formingBarTs ?? null, land);
347
+ return out;
348
+ }
349
+ sweepHostBars(sorted.length, (index) => sorted[index][0], main, bars.intervalMs, bars.venue ?? undefined, (barIndex, from, to) => land(main[barIndex][0], sorted.slice(from, to)));
350
+ return out;
351
+ }
352
+ /** The inputs `liveBucketStartMs` reads for a venue at an interval (the extended-hours option included). */
353
+ function gridKeyOf(intervalMs, venue) {
354
+ return [
355
+ intervalMs,
356
+ venue?.exchange,
357
+ venue?.symbol,
358
+ venue?.sessionType,
359
+ venue?.transformations,
360
+ usEquitiesSessionConfig.extendedHoursEnabled,
361
+ ].join('|');
362
+ }
363
+ const MINUTE_MS = 60_000;
364
+ /**
365
+ * A host's bucket function for a stream of instants (a live door's ticks):
366
+ * `liveBucketStartMs` over `venue` at `intervalMs`, asked only when an instant
367
+ * leaves the span it last resolved. A bar's span is [its start, its true
368
+ * end): the interval, cut at the session close for a stub bar (the end found
369
+ * once per bar by bisection on the minute grid every session boundary sits
370
+ * on); an off-session instant resolves to null for its own minute. So 1,000
371
+ * ticks inside one bar ask the bucket function a handful of times (on a
372
+ * regular-session stock above 30m each call is several time-zone
373
+ * conversions), never once per tick.
374
+ *
375
+ * A bar whose instants do not all sit in [stamp, end) misses that span: a CME
376
+ * trade-date bar (1D, 3D, 1W and the months, stamped 00:00Z) opens at 22:00Z
377
+ * or 23:00Z the evening before its stamp, and a regular-session stock's 3D bar
378
+ * holds three sessions with nights between them. Each bar's end is therefore
379
+ * remembered (the last few bars a door met), so such a miss costs the one
380
+ * bucket call that names the bar, never the end's bisection again.
381
+ */
382
+ export function createHostBucketResolver(intervalMs, venue) {
383
+ const v = venue ?? undefined;
384
+ let spanStart = Infinity;
385
+ let spanEnd = -Infinity;
386
+ let spanBar = null;
387
+ // The ends of the last few bars (a live door's ticks sit in the newest bars).
388
+ const BAR_END_MEMO_MAX = 8;
389
+ const barEnds = new Map();
390
+ const barEnd = (bar) => {
391
+ const known = barEnds.get(bar);
392
+ if (known !== undefined)
393
+ return known;
394
+ const end = findBarEnd(bar);
395
+ if (barEnds.size >= BAR_END_MEMO_MAX)
396
+ barEnds.clear();
397
+ barEnds.set(bar, end);
398
+ return end;
399
+ };
400
+ const findBarEnd = (bar) => {
401
+ const full = bar + intervalMs;
402
+ if (liveBucketStartMs(full - 1, intervalMs, v) === bar)
403
+ return full;
404
+ // A stub: the first minute past `bar` that the bar does not hold.
405
+ let held = Math.floor(bar / MINUTE_MS);
406
+ let notHeld = Math.floor((full - 1) / MINUTE_MS);
407
+ while (notHeld - held > 1) {
408
+ const mid = Math.floor((held + notHeld) / 2);
409
+ if (liveBucketStartMs(mid * MINUTE_MS, intervalMs, v) === bar)
410
+ held = mid;
411
+ else
412
+ notHeld = mid;
413
+ }
414
+ return Math.max(bar + 1, notHeld * MINUTE_MS);
415
+ };
416
+ return (tsMs) => {
417
+ if (!Number.isFinite(tsMs) || !(intervalMs > 0))
418
+ return null;
419
+ if (tsMs >= spanStart && tsMs < spanEnd)
420
+ return spanBar;
421
+ const bar = liveBucketStartMs(tsMs, intervalMs, v);
422
+ if (bar === null || !Number.isFinite(bar)) {
423
+ spanStart = tsMs - (((tsMs % MINUTE_MS) + MINUTE_MS) % MINUTE_MS);
424
+ spanEnd = spanStart + MINUTE_MS;
425
+ spanBar = null;
426
+ return null;
427
+ }
428
+ spanStart = bar;
429
+ spanEnd = barEnd(bar);
430
+ spanBar = bar;
431
+ return bar;
432
+ };
433
+ }
434
+ const RESOLVER_MEMO_MAX = 32;
435
+ const hostBucketResolvers = new Map();
436
+ /** The shared `createHostBucketResolver` of a host grid (every live door on that grid reuses its cached span). */
437
+ export function hostBucketResolverFor(intervalMs, venue) {
438
+ const key = gridKeyOf(intervalMs, venue);
439
+ let resolve = hostBucketResolvers.get(key);
440
+ if (!resolve) {
441
+ if (hostBucketResolvers.size >= RESOLVER_MEMO_MAX)
442
+ hostBucketResolvers.clear();
443
+ resolve = createHostBucketResolver(intervalMs, venue);
444
+ hostBucketResolvers.set(key, resolve);
445
+ }
446
+ return resolve;
447
+ }
@@ -0,0 +1,31 @@
1
+ import { type LiveBucketVenue } from './live-bucket.util.js';
2
+ /**
3
+ * The interval an overlay asks on an index-mode host (stocks, forex,
4
+ * commodities, dex): the chart interval itself, except where a bar grid the
5
+ * overlay meets opens intraday bars off the chart interval's UTC grid (a
6
+ * regular-session stock's 09:30-anchored 45m to 12h bars), on the host or on
7
+ * a leg (`legVenues`: the series the overlay fetches, each keyed by its own
8
+ * venue). Each grid's fitting tier is the coarsest natively served tier that
9
+ * fits every bar it opens on a summer and a winter day (`wrunTierFitsBar`:
10
+ * the tier divides the bar and the bar opens on the tier's grid): 30m under
11
+ * :30 hourly bars, 15m under 45m bars, the chart interval on the UTC grid.
12
+ * The overlay asks the finest of them (the host's and each leg's), so every
13
+ * host bar AND every leg bar is a whole number of tier buckets and
14
+ * `placeRowsInHostBars` merges exactly. A leg list whose every leg opens on
15
+ * the host's own bars (stock vs stock in one session) asks the chart
16
+ * interval: its bars already are the host's. Without legs (flows over 24/7
17
+ * venues) the host grid decides. Daily and longer intervals, and every host
18
+ * that is not index-mode, ask the chart interval.
19
+ */
20
+ export declare function indexHostFetchTierMs(intervalMs: number, hostVenue: LiveBucketVenue | null | undefined, legVenues?: ReadonlyArray<LiveBucketVenue | null | undefined>): number;
21
+ /**
22
+ * Whether a source's rows (its venue's bars at `rowSpanMs`) straddle the
23
+ * host's bars at `intervalMs`: some host bar of a summer or a winter probe day
24
+ * opens inside a source row rather than on a row's open (a stock's 13:30Z
25
+ * hours over a 24/7 source's :00 hours, or the reverse on a crypto chart).
26
+ * Then the row closing first inside a host bar opens before that bar, so a
27
+ * fetch placed by last instant (`PlaceRowsInHostBarsOptions.rowSpanMs`) asks
28
+ * one source span early to hold the first bar's row. A source on the host's
29
+ * own grid, or a finer grid dividing it, never straddles.
30
+ */
31
+ export declare function sourceRowsStraddleHostBars(intervalMs: number, hostVenue: LiveBucketVenue | null | undefined, rowSpanMs: number, sourceVenue: LiveBucketVenue | null | undefined): boolean;