@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,116 @@
1
+ import type { WrunLiveTailWindow } from '../../host-ports.types.js';
2
+ import type { WrunRunResult } from '../chart/wrun-run-result.util.js';
3
+ import type { WrunOutputRow } from '../../interfaces/wrun-runtime.interface.js';
4
+ import { type WrunBuildMemo } from './wrun-build-memo.util.js';
5
+ import type { WrunOverlayResultOptions } from './wrun-overlay-run.util.js';
6
+ /** Chart bars the window reaches before the first change: the seam the tail patch proves itself on. */
7
+ export declare const WRUN_LIVE_TAIL_SEAM_BARS = 2;
8
+ /** The chart bars and run clock a result was applied on (a new bar, or another clock, owes an apply). */
9
+ export interface WrunLiveChartBars {
10
+ firstTs: number;
11
+ lastTs: number;
12
+ rows: number;
13
+ runMs: number;
14
+ waitForClose: boolean;
15
+ }
16
+ /** A live build: the options a result was built with (its rows among them) and the result as built (its corner
17
+ * tables not yet placed). */
18
+ export interface WrunLiveBuild {
19
+ options: WrunOverlayResultOptions;
20
+ result: WrunRunResult;
21
+ }
22
+ /** What the live tick last applied: the reference of the next tick's diff. */
23
+ export interface WrunLiveApplied {
24
+ result: WrunRunResult;
25
+ bars: WrunLiveChartBars;
26
+ /** The overlay's mounted plots right after the apply, each with its rows array. */
27
+ plots: ReadonlyArray<readonly [Record<string, unknown>, unknown]>;
28
+ /** The build the chart shows (the one applied, or one the diff found unchanged against it). */
29
+ build?: WrunLiveBuild;
30
+ }
31
+ export type WrunLiveResultChange =
32
+ /** Nothing the chart draws changed. */
33
+ {
34
+ kind: 'unchanged';
35
+ }
36
+ /** Rows changed from `fromTs` on (Infinity when only drawings or untimed rows did). */
37
+ | {
38
+ kind: 'rows';
39
+ fromTs: number;
40
+ }
41
+ /** An output field, the output set or a run-level field changed: the whole result applies. */
42
+ | {
43
+ kind: 'structural';
44
+ };
45
+ /** Structural equality over a result's values: Object.is leaves (NaN equals NaN), arrays and plain records by
46
+ * content in key order, anything else by reference. */
47
+ export declare function wrunLiveValuesEqual(a: unknown, b: unknown): boolean;
48
+ /**
49
+ * What changed from the result the tick last applied to this one. Rows are
50
+ * compared cell by cell from the first row: the first difference anywhere is
51
+ * the change (a module that rewrote an older row moves it back). An output
52
+ * whose rows carry no stamp (a table, a corner label) changes the whole
53
+ * apply but no bar (the window carries it whole); a changed row whose shape
54
+ * differs from its set's first row (stamped among unstamped, or the reverse)
55
+ * is structural.
56
+ */
57
+ export declare function diffWrunLiveResults(applied: WrunRunResult, next: WrunRunResult): WrunLiveResultChange;
58
+ /** The chart's bars and the run clock a result applies on. */
59
+ export declare function wrunLiveChartBarsOf(rows: ReadonlyArray<ArrayLike<number>>, clock: {
60
+ runMs: number;
61
+ waitForClose: boolean;
62
+ }): WrunLiveChartBars | null;
63
+ export declare function wrunLiveChartBarsEqual(a: WrunLiveChartBars, b: WrunLiveChartBars): boolean;
64
+ /**
65
+ * The window of a tail patch: the change (never past the first bar the chart
66
+ * gained since the apply, nor past its newest bar: a new bar reaches every
67
+ * plot on the grid) and the bar `WRUN_LIVE_TAIL_SEAM_BARS` before it. Null
68
+ * when the chart's bars before the change are not the applied result's (an
69
+ * older bar moved: the whole result applies) or the change sits within the
70
+ * seam of the first bar.
71
+ */
72
+ export declare function wrunLiveTailWindowOf(applied: WrunLiveChartBars, chartRows: ReadonlyArray<ArrayLike<number>>, clock: {
73
+ runMs: number;
74
+ waitForClose: boolean;
75
+ }, change: {
76
+ fromTs: number;
77
+ }): WrunLiveTailWindow | null;
78
+ /**
79
+ * Whether a drawing-collapse key (boxes keep their last emission, labels their
80
+ * first: kscript-run-result `kScriptDrawingRowCollapseKey`) is shared between
81
+ * an output's rows before the window and its rows from it on, in the applied
82
+ * result or this one. Then the window cannot see a collapse the whole result
83
+ * makes (a box re-emitted on the forming bar retires its older row).
84
+ */
85
+ export declare function wrunLiveCollapseKeyCrossesWindow(applied: WrunRunResult, next: WrunRunResult, windowFromTs: number): boolean;
86
+ export declare function wrunLiveWindowResult(next: WrunRunResult, windowFromTs: number): WrunRunResult;
87
+ /**
88
+ * The outputs (by key) whose rows hold no value at all before `windowFromTs`
89
+ * (`WrunLiveTailWindow.headless`): every row the whole preparation keeps of
90
+ * such an output rides the window, so the tail may patch it the whole
91
+ * refresh's way when none of them falls before the change.
92
+ */
93
+ export declare function wrunLiveHeadlessOutputs(next: WrunRunResult, windowFromTs: number): Set<string>;
94
+ /** The overlay's mounted plots with their rows arrays (the parent, then each nested plot). */
95
+ export declare function wrunLivePlotsOf(meta: Record<string, unknown>): Array<readonly [Record<string, unknown>, unknown]>;
96
+ /** Whether the mounted plots are still the ones the last apply left (same plots, same rows arrays). */
97
+ export declare function wrunLivePlotsIntact(meta: Record<string, unknown>, applied: WrunLiveApplied): boolean;
98
+ /**
99
+ * Whether a build over `next` reads what the build over `was` read: the same
100
+ * rows (every row before the newest the same row, the newest alike by value:
101
+ * a block re-sending the forming bar replaces only that row) and the same
102
+ * run-level attachments the builder reads off them (the handle set, the
103
+ * frames; a strategy's broker output never counts as the same).
104
+ */
105
+ export declare function wrunLiveSameBuildRows(was: ReadonlyArray<WrunOutputRow>, next: ReadonlyArray<WrunOutputRow>): boolean;
106
+ /**
107
+ * Whether the tick can show the result the chart already shows instead of
108
+ * building one (the module note): the chart shows a build (`applied.build`)
109
+ * on the same bars, and a build over `options` reads the same sheet, the same
110
+ * rows and attachments (`wrunLiveSameBuildRows`) and the same options. The
111
+ * builder reads nothing else, so it would make that result again. A sheet with
112
+ * price canvases (heatmaps, profiles) reads the chart's own cells (the forming
113
+ * candle among them), which the options carry by reference: it always builds.
114
+ */
115
+ export declare function wrunLiveBuildReusable(applied: WrunLiveApplied | undefined, options: WrunOverlayResultOptions, bars: WrunLiveChartBars | null): boolean;
116
+ export declare function wrunLiveBuildMemoOf(context: object): WrunBuildMemo | undefined;
@@ -0,0 +1,523 @@
1
+ /**
2
+ * The wrun live tick's patch plan (wrun-live-tick `applyWrunLiveRunResult`):
3
+ * what a live update changed in the overlay's run result, and the window the
4
+ * tail patch applies it through.
5
+ *
6
+ * Every live update rebuilds the run result over the session's whole window
7
+ * (displacement, boxes, selections and colour tables derive from all rows), but
8
+ * what it changes is the newest rows: the forming bar, the closed bar at a
9
+ * roll, and any row the module rewrote. The tick keeps the result it last
10
+ * applied (`WrunLiveApplied`) and compares the new one with it
11
+ * (`diffWrunLiveResults`): nothing changed skips the apply and its paint (the
12
+ * kScript lane's skip-unchanged gate); rows changed from some bar on patch only
13
+ * those rows (`safeRefreshMountedKScriptRowsFromRunResult` with `liveTail`,
14
+ * which proves the splice on the bars before the change); anything else
15
+ * (an output field, the output set, a run-level field) refreshes the whole
16
+ * result as before.
17
+ *
18
+ * The tail patch's caller guarantees (WrunLiveTailWindow) are kept here:
19
+ * - rows before `fromTs` are unchanged: the diff walks every output's rows;
20
+ * - every output field but its rows is unchanged: anything else is structural;
21
+ * - the chart's bars before the change are the applied result's: the first bar
22
+ * and the bar count up to the applied result's last bar hold
23
+ * (`wrunLiveTailWindowOf`);
24
+ * - no drawing-collapse key crosses the window start
25
+ * (`wrunLiveCollapseKeyCrossesWindow`);
26
+ * - the mounted plots are the ones the last apply left (`wrunLivePlotsIntact`):
27
+ * another writer (a pause blank, a replay cut, a style save, a remount)
28
+ * replaces a plot's rows array, and the tick then refreshes the whole.
29
+ *
30
+ * Before any of that, the tick asks whether it has anything to build: a block
31
+ * that re-sent the forming bar with every value, string, handle and frame the
32
+ * chart already shows, under the same build options on the same bars, builds
33
+ * nothing (`wrunLiveBuildReusable`): the result the chart shows is the result
34
+ * a full build would make. A block that changed some values builds the result
35
+ * through the build memo (`wrunLiveBuildMemoOf`, wrun-build-memo.util), which
36
+ * rebuilds only the outputs and bands those values reach.
37
+ */
38
+ import { isKScriptCollapsedDrawingPlotType, kScriptDrawingRowCollapseKey, } from '../chart/kscript-run-result-normalize.util.js';
39
+ import { createWrunBuildMemo } from './wrun-build-memo.util.js';
40
+ import { wrunStrategyOf } from './wrun-box-segment.util.js';
41
+ import { wrunHandlesOf } from './wrun-handles.util.js';
42
+ import { wrunFramesOf } from './wrun-pack.util.js';
43
+ /** Chart bars the window reaches before the first change: the seam the tail patch proves itself on. */
44
+ export const WRUN_LIVE_TAIL_SEAM_BARS = 2;
45
+ /** Run-level fields the diff does not hold equal: the outputs (walked apart), the drawings and the drawing budget
46
+ * (they change the apply, never the structure; the budget's revision moves on every result) and the children
47
+ * (mounted on their own every tick). */
48
+ const WRUN_LIVE_DIFF_OWN_FIELDS = new Set([
49
+ 'outputs',
50
+ 'drawings',
51
+ 'drawingsBudget',
52
+ 'childOverlays',
53
+ ]);
54
+ const STRUCTURAL = { kind: 'structural' };
55
+ function isPlainRecord(value) {
56
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
57
+ return false;
58
+ const proto = Object.getPrototypeOf(value);
59
+ return proto === Object.prototype || proto === null;
60
+ }
61
+ /** Structural equality over a result's values: Object.is leaves (NaN equals NaN), arrays and plain records by
62
+ * content in key order, anything else by reference. */
63
+ export function wrunLiveValuesEqual(a, b) {
64
+ if (Object.is(a, b))
65
+ return true;
66
+ if (Array.isArray(a)) {
67
+ if (!Array.isArray(b) || a.length !== b.length)
68
+ return false;
69
+ for (let index = 0; index < a.length; index += 1)
70
+ if (!wrunLiveValuesEqual(a[index], b[index]))
71
+ return false;
72
+ return true;
73
+ }
74
+ if (!isPlainRecord(a) || !isPlainRecord(b))
75
+ return false;
76
+ const keys = Object.keys(a);
77
+ if (keys.length !== Object.keys(b).length)
78
+ return false;
79
+ for (const key of keys) {
80
+ if (!Object.prototype.hasOwnProperty.call(b, key) || !wrunLiveValuesEqual(a[key], b[key]))
81
+ return false;
82
+ }
83
+ return true;
84
+ }
85
+ function rowTs(row) {
86
+ const ts = Array.isArray(row) ? row[0] : undefined;
87
+ return typeof ts === 'number' && Number.isFinite(ts) ? ts : null;
88
+ }
89
+ /**
90
+ * One row against another, the diff's hot loop: numbers equal as the live row
91
+ * swap's own differ reads them (NaN equals NaN, 0 equals -0: kscript-live-row-damage
92
+ * `cellsEqual`, so a row the swap would keep is no change here either),
93
+ * payloads structurally.
94
+ */
95
+ function wrunLiveRowsEqual(a, b) {
96
+ if (a === b)
97
+ return true;
98
+ if (!Array.isArray(a) || !Array.isArray(b))
99
+ return wrunLiveValuesEqual(a, b);
100
+ const length = a.length;
101
+ if (length !== b.length)
102
+ return false;
103
+ for (let index = 0; index < length; index += 1) {
104
+ const cell = a[index];
105
+ const other = b[index];
106
+ if (cell === other)
107
+ continue;
108
+ if (typeof cell === 'number') {
109
+ if (Number.isNaN(cell) && typeof other === 'number' && Number.isNaN(other))
110
+ continue;
111
+ return false;
112
+ }
113
+ if (typeof cell !== 'object' || typeof other !== 'object' || !wrunLiveValuesEqual(cell, other))
114
+ return false;
115
+ }
116
+ return true;
117
+ }
118
+ /** The drawing budget's counts (the "Drawings capped" row reads them); its revision stays out. */
119
+ function budgetCounts(budget) {
120
+ if (!isPlainRecord(budget))
121
+ return budget;
122
+ return [budget.total, budget.keptAfterPreflight, budget.cap];
123
+ }
124
+ /**
125
+ * What changed from the result the tick last applied to this one. Rows are
126
+ * compared cell by cell from the first row: the first difference anywhere is
127
+ * the change (a module that rewrote an older row moves it back). An output
128
+ * whose rows carry no stamp (a table, a corner label) changes the whole
129
+ * apply but no bar (the window carries it whole); a changed row whose shape
130
+ * differs from its set's first row (stamped among unstamped, or the reverse)
131
+ * is structural.
132
+ */
133
+ export function diffWrunLiveResults(applied, next) {
134
+ const before = applied;
135
+ const after = next;
136
+ const ownKeys = (record) => Object.keys(record).filter((key) => !WRUN_LIVE_DIFF_OWN_FIELDS.has(key));
137
+ const beforeKeys = ownKeys(before);
138
+ const afterKeys = ownKeys(after);
139
+ if (!wrunLiveValuesEqual(beforeKeys, afterKeys))
140
+ return STRUCTURAL;
141
+ for (const key of afterKeys)
142
+ if (!wrunLiveValuesEqual(before[key], after[key]))
143
+ return STRUCTURAL;
144
+ let changed = !wrunLiveValuesEqual(before.drawings, after.drawings);
145
+ if (!wrunLiveValuesEqual(budgetCounts(before.drawingsBudget), budgetCounts(after.drawingsBudget)))
146
+ changed = true;
147
+ const beforeOutputs = before.outputs;
148
+ const afterOutputs = after.outputs;
149
+ if (beforeOutputs === undefined && afterOutputs === undefined)
150
+ return changed ? { kind: 'rows', fromTs: Infinity } : { kind: 'unchanged' };
151
+ if (!isPlainRecord(beforeOutputs) || !isPlainRecord(afterOutputs))
152
+ return STRUCTURAL;
153
+ const outputKeys = Object.keys(afterOutputs);
154
+ if (!wrunLiveValuesEqual(Object.keys(beforeOutputs), outputKeys))
155
+ return STRUCTURAL;
156
+ let fromTs = Infinity;
157
+ for (const key of outputKeys) {
158
+ const was = beforeOutputs[key];
159
+ const is = afterOutputs[key];
160
+ // The build memo hands an output it did not rebuild back as the same record.
161
+ if (was === is)
162
+ continue;
163
+ if (!isPlainRecord(was) || !isPlainRecord(is)) {
164
+ if (!wrunLiveValuesEqual(was, is))
165
+ return STRUCTURAL;
166
+ continue;
167
+ }
168
+ const fieldKeys = Object.keys(is).filter((field) => field !== 'data');
169
+ if (!wrunLiveValuesEqual(Object.keys(was).filter((field) => field !== 'data'), fieldKeys))
170
+ return STRUCTURAL;
171
+ for (const field of fieldKeys)
172
+ if (!wrunLiveValuesEqual(was[field], is[field]))
173
+ return STRUCTURAL;
174
+ const wasRows = was.data;
175
+ const isRows = is.data;
176
+ if (wasRows === isRows)
177
+ continue;
178
+ if (!Array.isArray(wasRows) || !Array.isArray(isRows)) {
179
+ if (!wrunLiveValuesEqual(wasRows, isRows))
180
+ return STRUCTURAL;
181
+ continue;
182
+ }
183
+ const shared = Math.min(wasRows.length, isRows.length);
184
+ let at = 0;
185
+ while (at < shared && wrunLiveRowsEqual(wasRows[at], isRows[at]))
186
+ at += 1;
187
+ if (at === shared && wasRows.length === isRows.length)
188
+ continue;
189
+ changed = true;
190
+ // A row set is stamped or not as its first row is: a changed row of the other shape mixes them.
191
+ const stamped = rowTs((isRows.length > 0 ? isRows : wasRows)[0]) !== null;
192
+ for (const row of [wasRows[at], isRows[at]]) {
193
+ if (row === undefined)
194
+ continue;
195
+ const ts = rowTs(row);
196
+ if ((ts !== null) !== stamped)
197
+ return STRUCTURAL;
198
+ if (ts !== null && ts < fromTs)
199
+ fromTs = ts;
200
+ }
201
+ }
202
+ return changed ? { kind: 'rows', fromTs } : { kind: 'unchanged' };
203
+ }
204
+ /** The chart's bars and the run clock a result applies on. */
205
+ export function wrunLiveChartBarsOf(rows, clock) {
206
+ if (rows.length === 0)
207
+ return null;
208
+ const firstTs = Number(rows[0][0]);
209
+ const lastTs = Number(rows[rows.length - 1][0]);
210
+ if (!Number.isFinite(firstTs) || !Number.isFinite(lastTs))
211
+ return null;
212
+ return { firstTs, lastTs, rows: rows.length, runMs: clock.runMs, waitForClose: clock.waitForClose };
213
+ }
214
+ export function wrunLiveChartBarsEqual(a, b) {
215
+ return (a.firstTs === b.firstTs &&
216
+ a.lastTs === b.lastTs &&
217
+ a.rows === b.rows &&
218
+ a.runMs === b.runMs &&
219
+ a.waitForClose === b.waitForClose);
220
+ }
221
+ /** The first index whose bar opens at or after `ts` (bars ascending); rows.length when none. */
222
+ function firstBarAtOrAfter(rows, ts) {
223
+ let low = 0;
224
+ let high = rows.length;
225
+ while (low < high) {
226
+ const mid = (low + high) >>> 1;
227
+ if (Number(rows[mid][0]) < ts)
228
+ low = mid + 1;
229
+ else
230
+ high = mid;
231
+ }
232
+ return low;
233
+ }
234
+ /**
235
+ * The window of a tail patch: the change (never past the first bar the chart
236
+ * gained since the apply, nor past its newest bar: a new bar reaches every
237
+ * plot on the grid) and the bar `WRUN_LIVE_TAIL_SEAM_BARS` before it. Null
238
+ * when the chart's bars before the change are not the applied result's (an
239
+ * older bar moved: the whole result applies) or the change sits within the
240
+ * seam of the first bar.
241
+ */
242
+ export function wrunLiveTailWindowOf(applied, chartRows, clock, change) {
243
+ const bars = wrunLiveChartBarsOf(chartRows, clock);
244
+ if (bars === null || bars.firstTs !== applied.firstTs || bars.runMs !== applied.runMs)
245
+ return null;
246
+ if (bars.waitForClose !== applied.waitForClose || bars.rows < applied.rows)
247
+ return null;
248
+ // The bars up to the applied result's newest are the ones it was applied on (same first, same count).
249
+ if (Number(chartRows[applied.rows - 1][0]) !== applied.lastTs)
250
+ return null;
251
+ const firstNewBarTs = bars.rows > applied.rows ? Number(chartRows[applied.rows][0]) : Infinity;
252
+ const fromTs = Math.min(change.fromTs, firstNewBarTs, bars.lastTs);
253
+ const at = firstBarAtOrAfter(chartRows, fromTs);
254
+ if (at < WRUN_LIVE_TAIL_SEAM_BARS || at >= chartRows.length)
255
+ return null;
256
+ return { fromTs, windowFromTs: Number(chartRows[at - WRUN_LIVE_TAIL_SEAM_BARS][0]) };
257
+ }
258
+ /**
259
+ * Whether a drawing-collapse key (boxes keep their last emission, labels their
260
+ * first: kscript-run-result `kScriptDrawingRowCollapseKey`) is shared between
261
+ * an output's rows before the window and its rows from it on, in the applied
262
+ * result or this one. Then the window cannot see a collapse the whole result
263
+ * makes (a box re-emitted on the forming bar retires its older row).
264
+ */
265
+ export function wrunLiveCollapseKeyCrossesWindow(applied, next, windowFromTs) {
266
+ const before = (applied.outputs ?? {});
267
+ for (const [key, output] of Object.entries((next.outputs ?? {}))) {
268
+ // An output the build memo handed back unchanged patches nothing: the window keeps its mounted rows.
269
+ if (!isPlainRecord(output) || before[key] === output)
270
+ continue;
271
+ const plotType = typeof output.plotType === 'string' ? output.plotType : typeof output.plot === 'string' ? output.plot : undefined;
272
+ if (!isKScriptCollapsedDrawingPlotType(plotType))
273
+ continue;
274
+ const head = new Set();
275
+ const tail = new Set();
276
+ const sort = (rows, intoHead) => {
277
+ if (!Array.isArray(rows))
278
+ return;
279
+ for (const row of rows) {
280
+ const collapseKey = kScriptDrawingRowCollapseKey(plotType, row);
281
+ if (collapseKey === null)
282
+ continue;
283
+ const ts = rowTs(row);
284
+ if (ts !== null && ts < windowFromTs) {
285
+ if (intoHead)
286
+ head.add(collapseKey);
287
+ }
288
+ else
289
+ tail.add(collapseKey);
290
+ }
291
+ };
292
+ sort(output.data, true);
293
+ const was = before[key];
294
+ sort(isPlainRecord(was) ? was.data : undefined, false);
295
+ for (const collapseKey of tail)
296
+ if (head.has(collapseKey))
297
+ return true;
298
+ }
299
+ return false;
300
+ }
301
+ /** Whether a row carries a drawable payload (every cell after its stamp a finite number, a string, a boolean or a
302
+ * record): the rows the renderer filter keeps whatever the plot. */
303
+ function wrunLiveRowIsReal(row) {
304
+ if (!Array.isArray(row) || row.length < 2)
305
+ return false;
306
+ for (let index = 1; index < row.length; index += 1) {
307
+ const cell = row[index];
308
+ if (typeof cell === 'number' ? !Number.isFinite(cell) : cell === null || cell === undefined)
309
+ return false;
310
+ }
311
+ return true;
312
+ }
313
+ /**
314
+ * The window result of a tail patch: every output's rows from the window's
315
+ * first bar on (unstamped rows whole), after the output's last real row before
316
+ * it, its context: the preparation reads the whole row set (a plot whose rows
317
+ * are all NaN in the window aligns to the chart's bars only when it owns a
318
+ * drawable row, a gap pad spans from its previous row), never the bars before
319
+ * the window, and the splice keeps the mounted rows there.
320
+ */
321
+ /** Per output record: its window at one window start (an output the build memo hands back unchanged keeps the
322
+ * same record, so its window is not cut again). */
323
+ const windowsByOutput = new WeakMap();
324
+ export function wrunLiveWindowResult(next, windowFromTs) {
325
+ const outputs = next.outputs;
326
+ if (!isPlainRecord(outputs))
327
+ return next;
328
+ const windowOutputs = {};
329
+ for (const [key, output] of Object.entries(outputs)) {
330
+ const rows = isPlainRecord(output) ? output.data : undefined;
331
+ if (!isPlainRecord(output) || !Array.isArray(rows) || rows.length === 0 || rowTs(rows[0]) === null) {
332
+ windowOutputs[key] = output;
333
+ continue;
334
+ }
335
+ const known = windowsByOutput.get(output);
336
+ if (known !== undefined && known.windowFromTs === windowFromTs) {
337
+ windowOutputs[key] = known.window;
338
+ continue;
339
+ }
340
+ let from = rows.length;
341
+ while (from > 0) {
342
+ const ts = rowTs(rows[from - 1]);
343
+ if (ts !== null && ts < windowFromTs)
344
+ break;
345
+ from -= 1;
346
+ }
347
+ let context = from - 1;
348
+ while (context >= 0 && !wrunLiveRowIsReal(rows[context]))
349
+ context -= 1;
350
+ const window = { ...output, data: context >= 0 ? [rows[context], ...rows.slice(from)] : rows.slice(from) };
351
+ windowsByOutput.set(output, { windowFromTs, window });
352
+ windowOutputs[key] = window;
353
+ }
354
+ return { ...next, outputs: windowOutputs };
355
+ }
356
+ /** Whether a row holds no value at all: every cell after its stamp NaN, null or absent. */
357
+ function wrunLiveRowIsEmpty(row) {
358
+ if (!Array.isArray(row))
359
+ return false;
360
+ for (let index = 1; index < row.length; index += 1) {
361
+ const cell = row[index];
362
+ if (cell === null || cell === undefined || (typeof cell === 'number' && Number.isNaN(cell)))
363
+ continue;
364
+ return false;
365
+ }
366
+ return true;
367
+ }
368
+ /** Per output record: whether it is headless before one window start. */
369
+ const headlessByOutput = new WeakMap();
370
+ /**
371
+ * The outputs (by key) whose rows hold no value at all before `windowFromTs`
372
+ * (`WrunLiveTailWindow.headless`): every row the whole preparation keeps of
373
+ * such an output rides the window, so the tail may patch it the whole
374
+ * refresh's way when none of them falls before the change.
375
+ */
376
+ export function wrunLiveHeadlessOutputs(next, windowFromTs) {
377
+ const headless = new Set();
378
+ const outputs = next.outputs;
379
+ if (!isPlainRecord(outputs))
380
+ return headless;
381
+ for (const [key, output] of Object.entries(outputs)) {
382
+ if (!isPlainRecord(output) || !Array.isArray(output.data) || output.data.length === 0)
383
+ continue;
384
+ const known = headlessByOutput.get(output);
385
+ let empty;
386
+ if (known !== undefined && known.windowFromTs === windowFromTs)
387
+ empty = known.headless;
388
+ else {
389
+ empty = true;
390
+ for (const row of output.data) {
391
+ const ts = rowTs(row);
392
+ if (ts === null) {
393
+ empty = false;
394
+ break;
395
+ }
396
+ if (ts >= windowFromTs)
397
+ break;
398
+ if (!wrunLiveRowIsEmpty(row)) {
399
+ empty = false;
400
+ break;
401
+ }
402
+ }
403
+ headlessByOutput.set(output, { windowFromTs, headless: empty });
404
+ }
405
+ if (empty)
406
+ headless.add(key);
407
+ }
408
+ return headless;
409
+ }
410
+ /** The overlay's mounted plots with their rows arrays (the parent, then each nested plot). */
411
+ export function wrunLivePlotsOf(meta) {
412
+ const plots = [[meta, meta.rawData]];
413
+ if (Array.isArray(meta.nestedMeta)) {
414
+ for (const nested of meta.nestedMeta) {
415
+ if (isPlainRecordLike(nested))
416
+ plots.push([nested, nested.rawData]);
417
+ }
418
+ }
419
+ return plots;
420
+ }
421
+ function isPlainRecordLike(value) {
422
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
423
+ }
424
+ /** Whether the mounted plots are still the ones the last apply left (same plots, same rows arrays). */
425
+ export function wrunLivePlotsIntact(meta, applied) {
426
+ const plots = wrunLivePlotsOf(meta);
427
+ if (plots.length !== applied.plots.length)
428
+ return false;
429
+ for (let index = 0; index < plots.length; index += 1) {
430
+ if (plots[index][0] !== applied.plots[index][0] || plots[index][1] !== applied.plots[index][1])
431
+ return false;
432
+ }
433
+ return true;
434
+ }
435
+ /** Two output rows alike as the build reads them: the stamp, every value (Object.is) and every string slot. */
436
+ function wrunLiveOutputRowsEqual(a, b) {
437
+ if (a === b)
438
+ return true;
439
+ if (a.ts !== b.ts)
440
+ return false;
441
+ const values = a.outputs;
442
+ const others = b.outputs;
443
+ if (values === null || others === null) {
444
+ if (values !== others)
445
+ return false;
446
+ }
447
+ else {
448
+ if (values.length !== others.length)
449
+ return false;
450
+ for (let index = 0; index < values.length; index += 1)
451
+ if (!Object.is(values[index], others[index]))
452
+ return false;
453
+ }
454
+ const strings = a.strings ?? [];
455
+ const otherStrings = b.strings ?? [];
456
+ if (strings.length !== otherStrings.length)
457
+ return false;
458
+ for (let slot = 0; slot < strings.length; slot += 1)
459
+ if (strings[slot] !== otherStrings[slot])
460
+ return false;
461
+ return true;
462
+ }
463
+ /**
464
+ * Whether a build over `next` reads what the build over `was` read: the same
465
+ * rows (every row before the newest the same row, the newest alike by value:
466
+ * a block re-sending the forming bar replaces only that row) and the same
467
+ * run-level attachments the builder reads off them (the handle set, the
468
+ * frames; a strategy's broker output never counts as the same).
469
+ */
470
+ export function wrunLiveSameBuildRows(was, next) {
471
+ const length = next.length;
472
+ if (was.length !== length || length === 0)
473
+ return false;
474
+ for (let at = 0; at < length - 1; at += 1)
475
+ if (was[at] !== next[at])
476
+ return false;
477
+ if (!wrunLiveOutputRowsEqual(was[length - 1], next[length - 1]))
478
+ return false;
479
+ if (wrunStrategyOf(was) !== undefined || wrunStrategyOf(next) !== undefined)
480
+ return false;
481
+ return (wrunLiveValuesEqual(wrunHandlesOf(was), wrunHandlesOf(next)) &&
482
+ wrunLiveValuesEqual(wrunFramesOf(was), wrunFramesOf(next)));
483
+ }
484
+ /** Build options the reuse check compares apart (the rows) or never (the build memo is the tick's own state). */
485
+ const WRUN_LIVE_BUILD_OWN_OPTIONS = new Set(['outputRows', 'metadata', 'cellRows', 'buildMemo']);
486
+ /**
487
+ * Whether the tick can show the result the chart already shows instead of
488
+ * building one (the module note): the chart shows a build (`applied.build`)
489
+ * on the same bars, and a build over `options` reads the same sheet, the same
490
+ * rows and attachments (`wrunLiveSameBuildRows`) and the same options. The
491
+ * builder reads nothing else, so it would make that result again. A sheet with
492
+ * price canvases (heatmaps, profiles) reads the chart's own cells (the forming
493
+ * candle among them), which the options carry by reference: it always builds.
494
+ */
495
+ export function wrunLiveBuildReusable(applied, options, bars) {
496
+ const build = applied?.build;
497
+ if (build === undefined || bars === null || !wrunLiveChartBarsEqual(applied.bars, bars))
498
+ return false;
499
+ const was = build.options;
500
+ const next = options;
501
+ if (was.metadata !== next.metadata)
502
+ return false;
503
+ if ((options.metadata.heatmaps?.length ?? 0) > 0 || (options.metadata.profiles?.length ?? 0) > 0)
504
+ return false;
505
+ const keys = Object.keys(next).filter((key) => !WRUN_LIVE_BUILD_OWN_OPTIONS.has(key));
506
+ if (keys.length !== Object.keys(was).filter((key) => !WRUN_LIVE_BUILD_OWN_OPTIONS.has(key)).length)
507
+ return false;
508
+ for (const key of keys) {
509
+ if (!Object.prototype.hasOwnProperty.call(was, key) || !wrunLiveValuesEqual(was[key], next[key]))
510
+ return false;
511
+ }
512
+ return wrunLiveSameBuildRows(build.options.outputRows, options.outputRows);
513
+ }
514
+ /** The build memo a live tick builds through (one per live context, created on first use). */
515
+ const buildMemos = new WeakMap();
516
+ export function wrunLiveBuildMemoOf(context) {
517
+ let memo = buildMemos.get(context);
518
+ if (memo === undefined) {
519
+ memo = createWrunBuildMemo();
520
+ buildMemos.set(context, memo);
521
+ }
522
+ return memo;
523
+ }