@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,376 @@
1
+ /**
2
+ * Warmup depth for browser-run ("local") kScript indicators.
3
+ *
4
+ * A long-window script (a 252-bar walk-forward, a 200-bar tail estimator)
5
+ * prints nothing for its first N loaded bars. On a boot window of ~500
6
+ * candles that warmup swallows most of the visible pane: the user sees an
7
+ * indicator that "did not load its back portion" (field report 2026-09-02),
8
+ * while TradingView hides the same warmup behind a 5000-bar first load.
9
+ *
10
+ * Rather than widening the boot fetch (the declared `minimumBars` is
11
+ * unreliable: a script declaring 252 first printed at bar 351), this reads
12
+ * the OBSERVED first value of the run result and, when it lands inside the
13
+ * viewport, asks for one more page of older candles through the same path a
14
+ * user pan-back takes. One declared read joins the observed ones: a script
15
+ * that prints from its first loaded bar while declaring a lookback deeper
16
+ * than the loaded window is computing on a truncated window (an anchored
17
+ * calculation clamped at the oldest loaded bar), and owes a page too
18
+ * ('declared-depth'). Bounded: at most LOCAL_KSCRIPT_WARMUP_DEPTH_MAX_ROUNDS
19
+ * rounds per overlay per chart identity, never while the viewport is moving,
20
+ * never past the venue's left wall.
21
+ *
22
+ * Pure by construction (every input is passed in) so the decision is unit
23
+ * testable and the ring events publish exactly what was chosen.
24
+ */
25
+ import { BARS_PER_BUCKET } from './cache-alignment.util.js';
26
+ /** Rounds of older history one overlay may request for its warmup. */
27
+ export const LOCAL_KSCRIPT_WARMUP_DEPTH_MAX_ROUNDS = 2;
28
+ /**
29
+ * The lazy loader edge-aligns every request to whole BARS_PER_BUCKET buckets
30
+ * (computeEdgeAnchoredLazyRange): a 30-bar ask still prepends 250 candles. So
31
+ * a warmup page is 0, one bucket, or two buckets (the lazy round clamp), and
32
+ * `bars` in a decision is stated in loader terms.
33
+ */
34
+ export const LOCAL_KSCRIPT_WARMUP_DEPTH_BUCKET_BARS = BARS_PER_BUCKET;
35
+ export const LOCAL_KSCRIPT_WARMUP_DEPTH_MIN_BARS = LOCAL_KSCRIPT_WARMUP_DEPTH_BUCKET_BARS;
36
+ export const LOCAL_KSCRIPT_WARMUP_DEPTH_MAX_BARS = 2 * LOCAL_KSCRIPT_WARMUP_DEPTH_BUCKET_BARS;
37
+ /** Whole loader buckets that cover a positive need: one up to a bucket, two past it (never more). */
38
+ export function warmupBucketsForNeed(needBars) {
39
+ if (!(needBars > 0))
40
+ return 0;
41
+ return needBars <= LOCAL_KSCRIPT_WARMUP_DEPTH_BUCKET_BARS
42
+ ? LOCAL_KSCRIPT_WARMUP_DEPTH_BUCKET_BARS
43
+ : LOCAL_KSCRIPT_WARMUP_DEPTH_MAX_BARS;
44
+ }
45
+ /**
46
+ * A visible warmup gap smaller than BOTH of these is left alone: a 20-bar
47
+ * moving-average warmup at the far left edge is what every charting product
48
+ * shows, and a fetch for it buys nothing the eye can see.
49
+ */
50
+ export const LOCAL_KSCRIPT_WARMUP_DEPTH_MIN_GAP_BARS = 25;
51
+ const LOCAL_KSCRIPT_WARMUP_DEPTH_MIN_GAP_VIEWPORT_FRACTION = 0.1;
52
+ function isFiniteTs(value) {
53
+ return typeof value === 'number' && Number.isFinite(value);
54
+ }
55
+ /** The rounds cap a decision applies: a positive whole `maxRounds`, else the warm-up default. */
56
+ function warmupRoundsCap(maxRounds) {
57
+ return typeof maxRounds === 'number' && Number.isFinite(maxRounds) && maxRounds >= 1
58
+ ? Math.floor(maxRounds)
59
+ : LOCAL_KSCRIPT_WARMUP_DEPTH_MAX_ROUNDS;
60
+ }
61
+ /** The declared-depth floor a decision applies: a positive whole `minGapBars`, else the warm-up floor. */
62
+ function declaredDepthMinGapBars(minGapBars) {
63
+ return typeof minGapBars === 'number' && Number.isFinite(minGapBars) && minGapBars >= 1
64
+ ? Math.floor(minGapBars)
65
+ : LOCAL_KSCRIPT_WARMUP_DEPTH_MIN_GAP_BARS;
66
+ }
67
+ /**
68
+ * Bars in the loaded main window: floor((last - first) / interval) + 1. Null
69
+ * when either edge is unknown, the interval is not positive, or the edges
70
+ * are inverted (a malformed read is unknown, never a small window).
71
+ */
72
+ export function loadedBarsOfWindow(loadedFirstTs, loadedLastTs, intervalMs) {
73
+ if (!isFiniteTs(loadedFirstTs) || !isFiniteTs(loadedLastTs) || !(intervalMs > 0))
74
+ return null;
75
+ const bars = Math.floor((loadedLastTs - loadedFirstTs) / intervalMs) + 1;
76
+ return bars >= 1 ? bars : null;
77
+ }
78
+ /**
79
+ * Decide whether to spend a warmup round. The first value must sit inside or
80
+ * to the right of the visible window (offscreen warmup is the normal, harmless
81
+ * case), and the request is sized to what the warmup still lacks, clamped to
82
+ * one lazy page and, when the script declares a lookback, bounded by it. An
83
+ * all-NaN run is evidence only after every source settled (field 2026-09-05:
84
+ * Volume Bubbles fired a blind 500-bar page while its volume-profile source
85
+ * was still downloading, and every heavy native overlay refetched the widened
86
+ * range). A declared lookback deeper than the loaded window, with the first
87
+ * value at the loaded start, is the one non-observed reason ('declared-depth',
88
+ * sized to the shortfall, one page at a time; a shortfall under the absolute
89
+ * gap floor, or the caller's `minGapBars`, is left alone like any other small gap).
90
+ */
91
+ export function chooseLocalKScriptWarmupDepth(input) {
92
+ if (!isFiniteTs(input.loadedFirstTs))
93
+ return { fetch: false, reason: 'no-rows' };
94
+ if (!isFiniteTs(input.viewportStartTs) || !(input.intervalMs > 0))
95
+ return { fetch: false, reason: 'no-viewport' };
96
+ if (input.roundsUsed >= warmupRoundsCap(input.maxRounds))
97
+ return { fetch: false, reason: 'rounds-exhausted' };
98
+ if (input.leftExhausted)
99
+ return { fetch: false, reason: 'left-exhausted' };
100
+ if (input.gestureActive)
101
+ return { fetch: false, reason: 'gesture-active' };
102
+ const lookbackBars = isFiniteTs(input.lookbackBars) ? Math.max(0, Math.floor(input.lookbackBars)) : null;
103
+ if (!isFiniteTs(input.firstValueTs)) {
104
+ // Every loaded bar is NaN. That is warmup evidence only once every source
105
+ // the script reads has actually arrived (an all-NaN run against a source
106
+ // still downloading, or degraded to empty, says nothing about depth) and
107
+ // only when the script declares a lookback at all (a zero-lookback script
108
+ // with empty outputs has nothing to warm up; fetching older candles would
109
+ // not change its output).
110
+ if (!input.sourcesSettled)
111
+ return { fetch: false, reason: 'sources-pending' };
112
+ if (lookbackBars === 0)
113
+ return { fetch: false, reason: 'zero-lookback-empty' };
114
+ // The declared lookback under-reports (a script declaring 252 first
115
+ // printed at bar 351), so the need is at least one bucket; an unknown
116
+ // lookback keeps the two-bucket page the field relied on.
117
+ const needBars = lookbackBars === null
118
+ ? LOCAL_KSCRIPT_WARMUP_DEPTH_MAX_BARS
119
+ : Math.min(LOCAL_KSCRIPT_WARMUP_DEPTH_MAX_BARS, Math.max(LOCAL_KSCRIPT_WARMUP_DEPTH_BUCKET_BARS, lookbackBars));
120
+ return {
121
+ fetch: true,
122
+ reason: 'no-values-yet',
123
+ bars: warmupBucketsForNeed(needBars),
124
+ needBars,
125
+ missingBars: needBars,
126
+ };
127
+ }
128
+ // Declared depth: the script prints from its first loaded bar (within one
129
+ // interval of the loaded start) while declaring a lookback deeper than the
130
+ // loaded window. That is not warmup, it is a truncated window: an anchored
131
+ // calculation clamps its anchor at the oldest loaded bar and visibly
132
+ // re-anchors on every later history extension (Anchored VWAP with a day
133
+ // anchor declares 1440 bars on a 1m chart once the engine folds the
134
+ // calendar-anchor span into minimumBars, and prints from bar 0 of a 251-bar
135
+ // boot). The page is owed while the declaration exceeds the window by at
136
+ // least the gap floor; the rounds cap and the page size bound the spend (a
137
+ // 5000-bar declaration on that boot buys two 500-bar pages and stops at
138
+ // rounds-exhausted).
139
+ const loadedBars = loadedBarsOfWindow(input.loadedFirstTs, input.loadedLastTs, input.intervalMs);
140
+ if (lookbackBars !== null &&
141
+ lookbackBars > 0 &&
142
+ loadedBars !== null &&
143
+ loadedBars < lookbackBars &&
144
+ input.firstValueTs <= input.loadedFirstTs + input.intervalMs) {
145
+ // A truncated run with sources still in flight proves nothing yet.
146
+ if (!input.sourcesSettled)
147
+ return { fetch: false, reason: 'sources-pending' };
148
+ const missingBars = lookbackBars - loadedBars;
149
+ // The absolute gap floor applies here too: a shortfall under
150
+ // LOCAL_KSCRIPT_WARMUP_DEPTH_MIN_GAP_BARS moves an anchor by less than
151
+ // the eye can see, and the loader would still spend a whole bucket on it.
152
+ // A caller whose shortfall is a need already lowers it (`minGapBars`).
153
+ if (missingBars < declaredDepthMinGapBars(input.minGapBars))
154
+ return { fetch: false, reason: 'gap-too-small' };
155
+ const needBars = Math.min(LOCAL_KSCRIPT_WARMUP_DEPTH_MAX_BARS, missingBars);
156
+ return { fetch: true, reason: 'declared-depth', bars: warmupBucketsForNeed(needBars), needBars, missingBars };
157
+ }
158
+ if (input.firstValueTs <= input.viewportStartTs)
159
+ return { fetch: false, reason: 'warmup-offscreen' };
160
+ const missingBars = Math.max(1, Math.ceil((input.firstValueTs - input.viewportStartTs) / input.intervalMs));
161
+ // The visible bars end at the last loaded candle: the empty space right of
162
+ // it (the right margin, wider with a visible-range profile docked there)
163
+ // holds no bars, and counting it raised the 10% floor past a real gap (a
164
+ // 28-bar margin refused a 26-bar RSI warm-up on a 250-bar window).
165
+ const visibleEndTs = isFiniteTs(input.viewportEndTs) && isFiniteTs(input.loadedLastTs)
166
+ ? Math.min(input.viewportEndTs, input.loadedLastTs)
167
+ : input.viewportEndTs;
168
+ const viewportBars = isFiniteTs(visibleEndTs)
169
+ ? Math.max(0, (visibleEndTs - input.viewportStartTs) / input.intervalMs)
170
+ : 0;
171
+ const minGapBars = Math.max(LOCAL_KSCRIPT_WARMUP_DEPTH_MIN_GAP_BARS, Math.ceil(viewportBars * LOCAL_KSCRIPT_WARMUP_DEPTH_MIN_GAP_VIEWPORT_FRACTION));
172
+ if (missingBars < minGapBars)
173
+ return { fetch: false, reason: 'gap-too-small' };
174
+ // The need is the observed visible gap, capped at two buckets. A known
175
+ // lookback caps it further at max(lookback, one bucket): a script declaring
176
+ // 5 bars never gets a second bucket even behind a 300-bar visible gap, a
177
+ // zero-lookback script whose gap is its source's own alignment (a daily
178
+ // anchor on an hourly chart) gets one bucket at most. The loader prepends
179
+ // whole buckets, so the bound decides whether the second one is spent.
180
+ const capped = Math.min(LOCAL_KSCRIPT_WARMUP_DEPTH_MAX_BARS, missingBars);
181
+ const needBars = lookbackBars === null ? capped : Math.min(capped, Math.max(lookbackBars, LOCAL_KSCRIPT_WARMUP_DEPTH_BUCKET_BARS));
182
+ return { fetch: true, reason: 'warmup-visible', bars: warmupBucketsForNeed(needBars), needBars, missingBars };
183
+ }
184
+ /**
185
+ * Output kinds whose rows are sparse by design (markers, labels, tables):
186
+ * never warmup evidence. `priceLabel` rows are label payloads (objects, never
187
+ * numbers), and `empty` is the kScript container plot that mirrors the main
188
+ * output: it repeats whatever the main output is and adds no evidence of its
189
+ * own. Both read as "all NaN" to a finite-number scan, which is how Volume
190
+ * Bubbles (container + priceLabel + point + table) bought two blind 250-bar
191
+ * pages on every reload (2026-09-13 dump, workspace P5VOQwHo).
192
+ */
193
+ const SPARSE_PLOT_TYPES = new Set([
194
+ 'triangle',
195
+ 'point',
196
+ 'arrow',
197
+ 'shape',
198
+ 'label',
199
+ 'priceLabel',
200
+ 'text',
201
+ 'statsRow',
202
+ 'table',
203
+ 'box',
204
+ 'hline',
205
+ 'drawing',
206
+ 'fill',
207
+ 'empty',
208
+ ]);
209
+ function isDenseOutput(output) {
210
+ return typeof output.plotType === 'string' && !SPARSE_PLOT_TYPES.has(output.plotType);
211
+ }
212
+ /** First row timestamp with a finite value in any value column (rows are `[ts, ...values]`), null when none. */
213
+ export function firstFiniteTsOfRows(rows) {
214
+ return profileWarmupRows(rows).firstFiniteTs;
215
+ }
216
+ /**
217
+ * What a dense-typed output's rows actually hold. Scans stop at the second
218
+ * finite row (a line is proven), so a healthy line costs the same as the
219
+ * plain first-finite scan; an all-NaN or object-valued output is scanned to
220
+ * the end, exactly as before.
221
+ */
222
+ export function profileWarmupRows(rows) {
223
+ let firstRowTs = null;
224
+ let firstFiniteTs = null;
225
+ let finiteRows = 0;
226
+ let objectRows = 0;
227
+ for (const row of rows ?? []) {
228
+ if (!row || row.length < 2)
229
+ continue;
230
+ const ts = row[0];
231
+ if (typeof ts !== 'number' || !Number.isFinite(ts))
232
+ continue;
233
+ if (firstRowTs === null)
234
+ firstRowTs = ts;
235
+ let finite = false;
236
+ let object = false;
237
+ for (let i = 1; i < row.length; i += 1) {
238
+ const v = row[i];
239
+ if (typeof v === 'number' && Number.isFinite(v)) {
240
+ finite = true;
241
+ break;
242
+ }
243
+ if (v !== null && typeof v === 'object')
244
+ object = true;
245
+ }
246
+ if (finite) {
247
+ finiteRows += 1;
248
+ if (firstFiniteTs === null)
249
+ firstFiniteTs = ts;
250
+ if (finiteRows >= 2)
251
+ break;
252
+ }
253
+ else if (object) {
254
+ objectRows += 1;
255
+ }
256
+ }
257
+ return { firstRowTs, firstFiniteTs, finiteRows, objectRows };
258
+ }
259
+ /**
260
+ * Where the pane becomes complete. Each dense output contributes the timestamp
261
+ * of its first finite value; the LATEST wins, because a pane with a reference
262
+ * line printing from bar 0 and a main line printing from bar 100 is still
263
+ * empty for 100 bars. Sparse outputs (markers, tables, hlines) are ignored: a
264
+ * signal that first fires mid-screen is not warmup.
265
+ *
266
+ * Two more shapes carry no evidence even under a line type (2026-09-13 dump):
267
+ * - object-valued rows (label / marker payloads under a line plot type, or an
268
+ * unlisted sparse type): not "all NaN", just not numbers;
269
+ * - a single finite row: the current-value dot a script draws with a spline
270
+ * (Anchored VWAP), which sits on the newest bar and can never move left, so
271
+ * it read as a visible warmup end and bought two pages that changed nothing.
272
+ * A line that genuinely printed only its newest bar is indistinguishable in
273
+ * one run and forgoes the page; a boot window that short is the user's pan.
274
+ */
275
+ export function warmupEndOfOutputs(outputs) {
276
+ let dense = 0;
277
+ let latest = null;
278
+ for (const profile of denseWarmupProfiles(outputs)) {
279
+ dense += 1;
280
+ const ts = profile.firstFiniteTs;
281
+ if (ts === null)
282
+ continue;
283
+ if (latest === null || ts > latest)
284
+ latest = ts;
285
+ }
286
+ if (dense === 0)
287
+ return { kind: 'no-dense-output' };
288
+ if (latest === null)
289
+ return { kind: 'no-values-yet' };
290
+ return { kind: 'warmup-end', ts: latest };
291
+ }
292
+ /**
293
+ * The outputs' warm-up end joined by a DECLARED one (the wrun lane: a sheet's `warmup` /
294
+ * `warmup_bars`, placed that many bars into the run's window): the declaration reads as one more
295
+ * dense output whose first value sits at `declaredEndTs`, so the LATER of the two is where the pane
296
+ * is complete, exactly as `warmupEndOfOutputs` takes the latest first value across the outputs. A
297
+ * result with no dense output (a drawings-only sheet) carries the declaration alone; an all-NaN
298
+ * result stays `no-values-yet` (nothing printed is the stronger read). A missing or non-finite
299
+ * declaration changes nothing.
300
+ */
301
+ export function withDeclaredWarmupEnd(evidence, declaredEndTs) {
302
+ if (typeof declaredEndTs !== 'number' || !Number.isFinite(declaredEndTs))
303
+ return evidence;
304
+ if (evidence.kind === 'no-values-yet')
305
+ return evidence;
306
+ if (evidence.kind === 'warmup-end')
307
+ return { kind: 'warmup-end', ts: Math.max(evidence.ts, declaredEndTs) };
308
+ return { kind: 'warmup-end', ts: declaredEndTs };
309
+ }
310
+ /**
311
+ * Where the run's rows START across the dense outputs (the earliest first
312
+ * row), null when none carries rows. This is the window the engine actually
313
+ * computed on, which is not the chart's loaded window while a prepended page
314
+ * has landed on the chart but not yet reached the engine: a result judged
315
+ * against the chart's new start would read "unchanged first value" and
316
+ * freeze the identity (2026-09-14 field dump: the Anchored VWAP's first
317
+ * page landed at 09:00Z, the next integrated result still ran on the 11:15Z
318
+ * window, and the hold released on a false no-progress verdict).
319
+ */
320
+ export function warmupOutputsWindowStartTs(outputs) {
321
+ let earliest = null;
322
+ for (const profile of denseWarmupProfiles(outputs)) {
323
+ const ts = profile.firstRowTs;
324
+ if (ts === null)
325
+ continue;
326
+ if (earliest === null || ts < earliest)
327
+ earliest = ts;
328
+ }
329
+ return earliest;
330
+ }
331
+ /** The dense outputs that carry warmup evidence, profiled; the object-valued and single-point shapes are skipped here. */
332
+ function* denseWarmupProfiles(outputs) {
333
+ for (const output of outputs) {
334
+ if (!isDenseOutput(output))
335
+ continue;
336
+ const profile = profileWarmupRows(output.rows);
337
+ if (profile.finiteRows === 0 && profile.objectRows > 0)
338
+ continue;
339
+ if (profile.finiteRows === 1)
340
+ continue;
341
+ yield profile;
342
+ }
343
+ }
344
+ /**
345
+ * Declared lookback of the script version actually executed, in bars.
346
+ * Priority: the run result's `lookbackInfo.minimumBars` (stamped by the
347
+ * engine worker from the declaration pass over the executed code, so editor
348
+ * drafts read their own value), else the overlay settings' `lookbackInfo`
349
+ * (the saved contract, object or JSON string: the retention hint's read),
350
+ * else null. Any unparsable or non-finite shape is null (unknown), never 0:
351
+ * only a declared finite 0 is 0.
352
+ */
353
+ export function resolveDeclaredLookbackBars(runLookbackInfo, settingsLookbackInfo) {
354
+ const fromRun = minimumBarsOf(runLookbackInfo);
355
+ if (fromRun !== null)
356
+ return fromRun;
357
+ return minimumBarsOf(settingsLookbackInfo);
358
+ }
359
+ function minimumBarsOf(lookbackInfo) {
360
+ if (typeof lookbackInfo === 'string') {
361
+ if (!lookbackInfo.trim())
362
+ return null;
363
+ try {
364
+ return minimumBarsOf(JSON.parse(lookbackInfo));
365
+ }
366
+ catch {
367
+ return null;
368
+ }
369
+ }
370
+ if (!lookbackInfo || typeof lookbackInfo !== 'object' || Array.isArray(lookbackInfo))
371
+ return null;
372
+ const minimumBars = lookbackInfo.minimumBars;
373
+ if (typeof minimumBars !== 'number' || !Number.isFinite(minimumBars))
374
+ return null;
375
+ return Math.max(0, Math.floor(minimumBars));
376
+ }
@@ -0,0 +1,85 @@
1
+ export declare const LOCAL_TECHNICAL_SCRIPT_LIVE_APPLY_VIEWPORT_IDLE_MS = 750;
2
+ export interface LocalTechnicalScriptLiveApplyDropDetails {
3
+ updateCount: number;
4
+ /** The parked result's settings revision, undefined when it named none. */
5
+ revision?: number;
6
+ /** The revision the save tail applied from. */
7
+ floorRevision: number;
8
+ }
9
+ export interface ScheduleLocalTechnicalScriptLiveApplyOptions {
10
+ chartIndex: number;
11
+ indicatorId: string;
12
+ getLastViewportInteractionAt: () => number;
13
+ canApply?: () => boolean;
14
+ apply: (updateCount: number) => void;
15
+ idleMs?: number;
16
+ blockedRetryMs?: number;
17
+ /**
18
+ * Hard ceiling on the total hold. The FIRST schedule of a pending arms it;
19
+ * latest-wins re-schedules keep the original deadline, so a stream of
20
+ * results during an endless gesture cannot push the flush out forever.
21
+ * A deadline flush applies unconditionally (call sites re-validate).
22
+ */
23
+ maxWaitMs?: number;
24
+ onScheduled?: (details: {
25
+ remainingMs: number;
26
+ updateCount: number;
27
+ }) => void;
28
+ onFlush?: (updateCount: number) => void;
29
+ onBlocked?: (details: {
30
+ retryMs: number;
31
+ updateCount: number;
32
+ }) => void;
33
+ /**
34
+ * The settings revision the parked result was computed from (the worker's
35
+ * inputs stamp). The settings save tail applies only results at or above its
36
+ * own revision (flushLocalTechnicalScriptLiveApplyNow); omitted by schedulers
37
+ * that park no result (the shed-replay request), which keep the old rule.
38
+ */
39
+ revision?: number;
40
+ /** The save tail dropped this parked result as older than the save (never on the idle path). */
41
+ onDropped?: (details: LocalTechnicalScriptLiveApplyDropDetails) => void;
42
+ }
43
+ export declare function __setLocalTechnicalScriptLiveApplyClockForTests(fn: (() => number) | null): void;
44
+ export declare function scheduleLocalTechnicalScriptLiveApplyAfterViewportIdle(options: ScheduleLocalTechnicalScriptLiveApplyOptions): boolean;
45
+ /**
46
+ * Same machinery, separate pending lane: holds a FULL (non-live) local-run
47
+ * integration until the viewport goes still, latest result wins. Kept apart
48
+ * from the live lane because a live rows-refresh apply must never replace a
49
+ * pending full remount (rows-refresh cannot mount freshly backfilled rows).
50
+ * Landing a full remount mid-gesture is the render-bound frame-gap class
51
+ * (see debugging-diagnostics.md); pass `maxWaitMs` (the heavy-apply gesture
52
+ * ceiling) so a pathological never-idle viewport still flushes.
53
+ */
54
+ export declare function scheduleLocalTechnicalScriptLazyApplyAfterViewportIdle(options: ScheduleLocalTechnicalScriptLiveApplyOptions): boolean;
55
+ /**
56
+ * The settings save tail: runs the overlay's parked applies now, ignoring the
57
+ * viewport-idle window and the canApply gate (a settings change must paint
58
+ * wherever the user is looking, live edge offscreen included), and keyed by
59
+ * settings revision so it neither deletes the save's own result nor lands an
60
+ * older one over it (K1/K2, SETTINGS-RAPID-TOGGLE).
61
+ *
62
+ * The floor is the save's revision when the caller names it, raised to the
63
+ * newest revision a parked result names. A parked result below the floor was
64
+ * computed from a superseded save's inputs: dropped (onDropped). Every parked
65
+ * result at or above it is applied in schedule order, so the newest lands last
66
+ * and a lazy full integration (the recompute that missed the owed mark, a row
67
+ * set only a remount can change) lands under a newer live rows refresh. Each
68
+ * apply re-validates against the overlay's CURRENT style inputs and revision.
69
+ * A parked entry that names no revision keeps the old rule: a live entry
70
+ * applies (the shed-replay request, whose replay is revision-checked on
71
+ * arrival), a lazy one is dropped. Returns whether anything was applied.
72
+ */
73
+ export declare function flushLocalTechnicalScriptLiveApplyNow(chartIndex: number, indicatorId: string, minRevision?: number): boolean;
74
+ /**
75
+ * Drop the LIVE-lane pending for one key without applying it, leaving any
76
+ * lazy-lane pending untouched. Owned by the gesture settle-hold: when the
77
+ * hold takes a newer settle, an older coalescer-parked live result for the
78
+ * same key must not out-apply it later (idle timer or offscreen retry), so
79
+ * exactly one lane owns supersession at any time. Returns whether a pending
80
+ * was dropped.
81
+ */
82
+ export declare function dropLocalTechnicalScriptLiveLanePending(chartIndex: number, indicatorId: string): boolean;
83
+ export declare function clearLocalTechnicalScriptLiveApply(chartIndex: number, indicatorId?: string): void;
84
+ export declare function clearAllLocalTechnicalScriptLiveApplies(): void;
85
+ export declare function __getPendingLocalTechnicalScriptLiveApplyCountForTests(): number;
@@ -0,0 +1,197 @@
1
+ export const LOCAL_TECHNICAL_SCRIPT_LIVE_APPLY_VIEWPORT_IDLE_MS = 750;
2
+ const pendingByKey = new Map();
3
+ let pendingSeq = 0;
4
+ let nowFn = () => Date.now();
5
+ export function __setLocalTechnicalScriptLiveApplyClockForTests(fn) {
6
+ nowFn = fn ?? (() => Date.now());
7
+ }
8
+ function pendingKey(chartIndex, indicatorId, lane = 'live') {
9
+ // The live key stays bare so existing behavior (and persisted expectations in
10
+ // specs) are unchanged; the lazy lane gets its own key because a pending lazy
11
+ // FULL integration must never be replaced by a live rows-refresh apply (the
12
+ // mounted-rows fast path cannot mount freshly backfilled rows).
13
+ return lane === 'lazy' ? `${chartIndex}:${indicatorId}#lazy` : `${chartIndex}:${indicatorId}`;
14
+ }
15
+ function clearPendingKey(key) {
16
+ const pending = pendingByKey.get(key);
17
+ if (!pending)
18
+ return;
19
+ clearTimeout(pending.timer);
20
+ pendingByKey.delete(key);
21
+ }
22
+ function msUntilViewportIdle(pending) {
23
+ const lastViewportInteractionAt = pending.getLastViewportInteractionAt();
24
+ if (lastViewportInteractionAt <= 0)
25
+ return 0;
26
+ return Math.max(0, pending.idleMs - (nowFn() - lastViewportInteractionAt));
27
+ }
28
+ function canApplyNow(pending) {
29
+ return pending.canApply?.() !== false;
30
+ }
31
+ function flushWhenIdle(key) {
32
+ const pending = pendingByKey.get(key);
33
+ if (!pending)
34
+ return;
35
+ const pastDeadline = pending.deadlineAt !== undefined && nowFn() >= pending.deadlineAt;
36
+ if (!pastDeadline) {
37
+ const remainingMs = msUntilViewportIdle(pending);
38
+ if (remainingMs > 0) {
39
+ const untilDeadlineMs = pending.deadlineAt !== undefined ? Math.max(0, pending.deadlineAt - nowFn()) : Number.POSITIVE_INFINITY;
40
+ pending.timer = setTimeout(() => flushWhenIdle(key), Math.min(remainingMs, untilDeadlineMs));
41
+ return;
42
+ }
43
+ if (!canApplyNow(pending)) {
44
+ pending.onBlocked?.({ retryMs: pending.blockedRetryMs, updateCount: pending.updateCount });
45
+ const untilDeadlineMs = pending.deadlineAt !== undefined ? Math.max(50, pending.deadlineAt - nowFn()) : Number.POSITIVE_INFINITY;
46
+ pending.timer = setTimeout(() => flushWhenIdle(key), Math.min(pending.blockedRetryMs, untilDeadlineMs));
47
+ return;
48
+ }
49
+ }
50
+ pendingByKey.delete(key);
51
+ pending.onFlush?.(pending.updateCount);
52
+ pending.apply(pending.updateCount);
53
+ }
54
+ function scheduleApplyAfterViewportIdle(lane, options) {
55
+ const idleMs = Math.max(0, options.idleMs ?? LOCAL_TECHNICAL_SCRIPT_LIVE_APPLY_VIEWPORT_IDLE_MS);
56
+ const blockedRetryMs = Math.max(50, options.blockedRetryMs ?? 1_000);
57
+ const key = pendingKey(options.chartIndex, options.indicatorId, lane);
58
+ const existing = pendingByKey.get(key);
59
+ const remainingMs = msUntilViewportIdle({
60
+ getLastViewportInteractionAt: options.getLastViewportInteractionAt,
61
+ idleMs,
62
+ });
63
+ if (remainingMs <= 0 && options.canApply?.() !== false) {
64
+ clearPendingKey(key);
65
+ return false;
66
+ }
67
+ if (existing) {
68
+ clearTimeout(existing.timer);
69
+ }
70
+ const updateCount = (existing?.updateCount ?? 0) + 1;
71
+ const deadlineAt = existing?.deadlineAt ?? (options.maxWaitMs !== undefined ? nowFn() + Math.max(0, options.maxWaitMs) : undefined);
72
+ const untilDeadlineMs = deadlineAt !== undefined ? Math.max(0, deadlineAt - nowFn()) : Number.POSITIVE_INFINITY;
73
+ const pending = {
74
+ apply: options.apply,
75
+ canApply: options.canApply,
76
+ getLastViewportInteractionAt: options.getLastViewportInteractionAt,
77
+ idleMs,
78
+ blockedRetryMs,
79
+ timer: setTimeout(() => flushWhenIdle(key), Math.min(Math.max(0, remainingMs || blockedRetryMs), untilDeadlineMs)),
80
+ updateCount,
81
+ deadlineAt,
82
+ onFlush: options.onFlush,
83
+ onBlocked: options.onBlocked,
84
+ lane,
85
+ seq: ++pendingSeq,
86
+ revision: options.revision,
87
+ onDropped: options.onDropped,
88
+ };
89
+ pendingByKey.set(key, pending);
90
+ options.onScheduled?.({ remainingMs, updateCount });
91
+ return true;
92
+ }
93
+ export function scheduleLocalTechnicalScriptLiveApplyAfterViewportIdle(options) {
94
+ // The LIVE lane structurally never carries a deadline: deadlineAt is
95
+ // inherited by every LATER scheduler on the shared key (three independent
96
+ // call sites write it) and a past-deadline flush bypasses the canApply
97
+ // live-edge gate, so one caller's ceiling would force-paint an unrelated
98
+ // caller's live result into a history viewport. Only the lazy lane
99
+ // honours maxWaitMs; stripping it here turns the invariant from prose
100
+ // into structure (review round 2), pinned by spec.
101
+ const { maxWaitMs: _liveLaneNeverDeadlines, ...rest } = options;
102
+ return scheduleApplyAfterViewportIdle('live', rest);
103
+ }
104
+ /**
105
+ * Same machinery, separate pending lane: holds a FULL (non-live) local-run
106
+ * integration until the viewport goes still, latest result wins. Kept apart
107
+ * from the live lane because a live rows-refresh apply must never replace a
108
+ * pending full remount (rows-refresh cannot mount freshly backfilled rows).
109
+ * Landing a full remount mid-gesture is the render-bound frame-gap class
110
+ * (see debugging-diagnostics.md); pass `maxWaitMs` (the heavy-apply gesture
111
+ * ceiling) so a pathological never-idle viewport still flushes.
112
+ */
113
+ export function scheduleLocalTechnicalScriptLazyApplyAfterViewportIdle(options) {
114
+ return scheduleApplyAfterViewportIdle('lazy', options);
115
+ }
116
+ /**
117
+ * The settings save tail: runs the overlay's parked applies now, ignoring the
118
+ * viewport-idle window and the canApply gate (a settings change must paint
119
+ * wherever the user is looking, live edge offscreen included), and keyed by
120
+ * settings revision so it neither deletes the save's own result nor lands an
121
+ * older one over it (K1/K2, SETTINGS-RAPID-TOGGLE).
122
+ *
123
+ * The floor is the save's revision when the caller names it, raised to the
124
+ * newest revision a parked result names. A parked result below the floor was
125
+ * computed from a superseded save's inputs: dropped (onDropped). Every parked
126
+ * result at or above it is applied in schedule order, so the newest lands last
127
+ * and a lazy full integration (the recompute that missed the owed mark, a row
128
+ * set only a remount can change) lands under a newer live rows refresh. Each
129
+ * apply re-validates against the overlay's CURRENT style inputs and revision.
130
+ * A parked entry that names no revision keeps the old rule: a live entry
131
+ * applies (the shed-replay request, whose replay is revision-checked on
132
+ * arrival), a lazy one is dropped. Returns whether anything was applied.
133
+ */
134
+ export function flushLocalTechnicalScriptLiveApplyNow(chartIndex, indicatorId, minRevision) {
135
+ const parked = [];
136
+ for (const lane of ['lazy', 'live']) {
137
+ const key = pendingKey(chartIndex, indicatorId, lane);
138
+ const pending = pendingByKey.get(key);
139
+ if (!pending)
140
+ continue;
141
+ clearPendingKey(key);
142
+ parked.push(pending);
143
+ }
144
+ let floorRevision = minRevision !== undefined && Number.isFinite(minRevision) ? minRevision : 0;
145
+ for (const pending of parked) {
146
+ if (pending.revision !== undefined && pending.revision > floorRevision)
147
+ floorRevision = pending.revision;
148
+ }
149
+ const applies = [];
150
+ for (const pending of parked) {
151
+ const current = pending.revision === undefined ? pending.lane === 'live' : pending.revision >= floorRevision;
152
+ if (current)
153
+ applies.push(pending);
154
+ else
155
+ pending.onDropped?.({ updateCount: pending.updateCount, revision: pending.revision, floorRevision });
156
+ }
157
+ applies.sort((a, b) => a.seq - b.seq);
158
+ for (const pending of applies) {
159
+ pending.onFlush?.(pending.updateCount);
160
+ pending.apply(pending.updateCount);
161
+ }
162
+ return applies.length > 0;
163
+ }
164
+ /**
165
+ * Drop the LIVE-lane pending for one key without applying it, leaving any
166
+ * lazy-lane pending untouched. Owned by the gesture settle-hold: when the
167
+ * hold takes a newer settle, an older coalescer-parked live result for the
168
+ * same key must not out-apply it later (idle timer or offscreen retry), so
169
+ * exactly one lane owns supersession at any time. Returns whether a pending
170
+ * was dropped.
171
+ */
172
+ export function dropLocalTechnicalScriptLiveLanePending(chartIndex, indicatorId) {
173
+ const key = pendingKey(chartIndex, indicatorId);
174
+ const had = pendingByKey.has(key);
175
+ clearPendingKey(key);
176
+ return had;
177
+ }
178
+ export function clearLocalTechnicalScriptLiveApply(chartIndex, indicatorId) {
179
+ if (indicatorId) {
180
+ clearPendingKey(pendingKey(chartIndex, indicatorId));
181
+ clearPendingKey(pendingKey(chartIndex, indicatorId, 'lazy'));
182
+ return;
183
+ }
184
+ const prefix = `${chartIndex}:`;
185
+ for (const key of [...pendingByKey.keys()]) {
186
+ if (key.startsWith(prefix))
187
+ clearPendingKey(key);
188
+ }
189
+ }
190
+ export function clearAllLocalTechnicalScriptLiveApplies() {
191
+ for (const key of [...pendingByKey.keys()]) {
192
+ clearPendingKey(key);
193
+ }
194
+ }
195
+ export function __getPendingLocalTechnicalScriptLiveApplyCountForTests() {
196
+ return pendingByKey.size;
197
+ }