@orangecharts/wrun-chart-host 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. package/README.md +17 -5
  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/feature-flags.constants.js +7 -2
  5. package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +15 -0
  6. package/dist/constants/kscript-data-interval-restrictions.constants.js +40 -0
  7. package/dist/constants/opra-compliance.constants.d.ts +19 -0
  8. package/dist/constants/opra-compliance.constants.js +19 -0
  9. package/dist/constants/replay-ladder.leaf.d.ts +30 -0
  10. package/dist/constants/replay-ladder.leaf.js +99 -0
  11. package/dist/constants/scriptEditor/cme-official-scripts.constants.d.ts +168 -0
  12. package/dist/constants/scriptEditor/cme-official-scripts.constants.js +398 -0
  13. package/dist/constants/scriptEditor/converted-script-id.leaf.d.ts +8 -0
  14. package/dist/constants/scriptEditor/converted-script-id.leaf.js +10 -0
  15. package/dist/constants/scriptEditor/execution.constants.d.ts +4 -0
  16. package/dist/constants/scriptEditor/execution.constants.js +14 -0
  17. package/dist/constants/wrun-prefix-safe.constants.d.ts +23 -0
  18. package/dist/constants/wrun-prefix-safe.constants.js +26 -0
  19. package/dist/host-env.d.ts +301 -22
  20. package/dist/host-env.js +15 -0
  21. package/dist/host-ports.types.d.ts +853 -29
  22. package/dist/index.d.ts +140 -2
  23. package/dist/index.js +140 -2
  24. package/dist/instances/script-engine-worker-ohlcv-transfer.d.ts +31 -0
  25. package/dist/instances/script-engine-worker-ohlcv-transfer.js +164 -0
  26. package/dist/interfaces/market-event.interface.d.ts +231 -0
  27. package/dist/interfaces/market-event.interface.js +15 -0
  28. package/dist/interfaces/opra-realtime.interface.d.ts +70 -134
  29. package/dist/interfaces/opra-realtime.interface.js +34 -59
  30. package/dist/interfaces/replay.interface.d.ts +285 -0
  31. package/dist/interfaces/replay.interface.js +1 -0
  32. package/dist/interfaces/wrun-runtime.interface.d.ts +88 -13
  33. package/dist/interfaces/wrun-runtime.interface.js +17 -3
  34. package/dist/kscript-data/controls/live-ohlcv-merge.util.d.ts +1 -0
  35. package/dist/kscript-data/controls/live-ohlcv-merge.util.js +93 -0
  36. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +5 -1
  37. package/dist/kscript-data/controls/live-trades-merge.util.js +2 -2
  38. package/dist/market-data/billing.interface.d.ts +219 -0
  39. package/dist/market-data/billing.interface.js +58 -0
  40. package/dist/market-data/venue-governed.util.d.ts +2 -0
  41. package/dist/market-data/venue-governed.util.js +10 -0
  42. package/dist/market-data/venue.d.ts +122 -0
  43. package/dist/market-data/venue.js +1 -0
  44. package/dist/market-data/venues/index.d.ts +97 -0
  45. package/dist/market-data/venues/index.js +33 -0
  46. package/dist/market-data/venues/opra.contract.copy.json +35 -0
  47. package/dist/market-data/venues/opra.d.ts +70 -0
  48. package/dist/market-data/venues/opra.js +74 -0
  49. package/dist/replay/replayIndicatorRows.d.ts +31 -0
  50. package/dist/replay/replayIndicatorRows.js +117 -0
  51. package/dist/replay/replayLadder.d.ts +85 -0
  52. package/dist/replay/replayLadder.js +388 -0
  53. package/dist/utility/auth/server-clock.util.d.ts +81 -0
  54. package/dist/utility/auth/server-clock.util.js +238 -0
  55. package/dist/utility/chart/builtin-identity.util.d.ts +18 -0
  56. package/dist/utility/chart/builtin-identity.util.js +51 -0
  57. package/dist/utility/chart/cache-alignment.util.d.ts +454 -0
  58. package/dist/utility/chart/cache-alignment.util.js +926 -0
  59. package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +15 -0
  60. package/dist/utility/chart/chart-data-fetch-generation.util.js +22 -0
  61. package/dist/utility/chart/chart-mount-epoch.util.d.ts +17 -0
  62. package/dist/utility/chart/chart-mount-epoch.util.js +61 -0
  63. package/dist/utility/chart/chart-time-domain.util.d.ts +12 -0
  64. package/dist/utility/chart/chart-time-domain.util.js +23 -0
  65. package/dist/utility/chart/color-customization.leaf.d.ts +10 -0
  66. package/dist/utility/chart/color-customization.leaf.js +16 -0
  67. package/dist/utility/chart/footprint-tick-grid.util.d.ts +106 -0
  68. package/dist/utility/chart/footprint-tick-grid.util.js +167 -0
  69. package/dist/utility/chart/gesture-timing.leaf.d.ts +29 -0
  70. package/dist/utility/chart/gesture-timing.leaf.js +29 -0
  71. package/dist/utility/chart/governed-contract-coin.util.d.ts +22 -0
  72. package/dist/utility/chart/governed-contract-coin.util.js +39 -0
  73. package/dist/utility/chart/host-bar-placement.util.d.ts +107 -0
  74. package/dist/utility/chart/host-bar-placement.util.js +447 -0
  75. package/dist/utility/chart/index-host-tier.util.d.ts +31 -0
  76. package/dist/utility/chart/index-host-tier.util.js +118 -0
  77. package/dist/utility/chart/index-mode-admission.util.d.ts +34 -0
  78. package/dist/utility/chart/index-mode-admission.util.js +67 -0
  79. package/dist/utility/chart/indicator-error-message.util.d.ts +35 -0
  80. package/dist/utility/chart/indicator-error-message.util.js +44 -0
  81. package/dist/utility/chart/kscript-apply-fingerprint.util.d.ts +65 -0
  82. package/dist/utility/chart/kscript-apply-fingerprint.util.js +357 -0
  83. package/dist/utility/chart/kscript-chart-flush.leaf.d.ts +22 -0
  84. package/dist/utility/chart/kscript-chart-flush.leaf.js +13 -0
  85. package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +6 -0
  86. package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +27 -0
  87. package/dist/utility/chart/kscript-integration-decision.leaf.d.ts +89 -0
  88. package/dist/utility/chart/kscript-integration-decision.leaf.js +80 -0
  89. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +76 -0
  90. package/dist/utility/chart/kscript-live-coalesce.util.js +156 -0
  91. package/dist/utility/chart/kscript-live-rest-pace.util.d.ts +34 -0
  92. package/dist/utility/chart/kscript-live-rest-pace.util.js +134 -0
  93. package/dist/utility/chart/kscript-live-source-identity.util.d.ts +98 -0
  94. package/dist/utility/chart/kscript-live-source-identity.util.js +121 -0
  95. package/dist/utility/chart/kscript-mounted-plot-set.leaf.d.ts +48 -0
  96. package/dist/utility/chart/kscript-mounted-plot-set.leaf.js +145 -0
  97. package/dist/utility/chart/kscript-perf-tracker.util.d.ts +243 -0
  98. package/dist/utility/chart/kscript-perf-tracker.util.js +522 -0
  99. package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +43 -0
  100. package/dist/utility/chart/kscript-run-interval-projection.util.js +471 -0
  101. package/dist/utility/chart/kscript-run-result-equality.util.d.ts +38 -0
  102. package/dist/utility/chart/kscript-run-result-equality.util.js +89 -0
  103. package/dist/utility/chart/kscript-settings-revision.leaf.d.ts +2 -0
  104. package/dist/utility/chart/kscript-settings-revision.leaf.js +12 -0
  105. package/dist/utility/chart/kscript-source-degrade.leaf.d.ts +63 -0
  106. package/dist/utility/chart/kscript-source-degrade.leaf.js +68 -0
  107. package/dist/utility/chart/kscript-source-retention.util.d.ts +134 -0
  108. package/dist/utility/chart/kscript-source-retention.util.js +218 -0
  109. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +57 -0
  110. package/dist/utility/chart/kscript-standin-identity.leaf.js +61 -0
  111. package/dist/utility/chart/kscript-titancharts-preparation.util.d.ts +15 -0
  112. package/dist/utility/chart/kscript-titancharts-preparation.util.js +376 -0
  113. package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +9 -0
  114. package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +130 -0
  115. package/dist/utility/chart/kscript-venue-policy.util.d.ts +217 -0
  116. package/dist/utility/chart/kscript-venue-policy.util.js +324 -0
  117. package/dist/utility/chart/live-cadence.util.d.ts +38 -0
  118. package/dist/utility/chart/live-cadence.util.js +37 -0
  119. package/dist/utility/chart/live-feed-series-match.leaf.d.ts +13 -0
  120. package/dist/utility/chart/live-feed-series-match.leaf.js +21 -0
  121. package/dist/utility/chart/local-engine-self-heal-backoff.util.d.ts +46 -0
  122. package/dist/utility/chart/local-engine-self-heal-backoff.util.js +46 -0
  123. package/dist/utility/chart/local-engine-uninit.leaf.d.ts +21 -0
  124. package/dist/utility/chart/local-engine-uninit.leaf.js +22 -0
  125. package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +62 -0
  126. package/dist/utility/chart/local-kscript-source-revalidation.util.js +123 -0
  127. package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +214 -0
  128. package/dist/utility/chart/local-kscript-warmup-depth.util.js +376 -0
  129. package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.d.ts +85 -0
  130. package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.js +197 -0
  131. package/dist/utility/chart/local-technical-script-range.leaf.d.ts +72 -0
  132. package/dist/utility/chart/local-technical-script-range.leaf.js +126 -0
  133. package/dist/utility/chart/mixed-mode.util.d.ts +167 -0
  134. package/dist/utility/chart/mixed-mode.util.js +139 -0
  135. package/dist/utility/chart/ohlcv-row-readiness.util.d.ts +36 -0
  136. package/dist/utility/chart/ohlcv-row-readiness.util.js +90 -0
  137. package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +19 -0
  138. package/dist/utility/chart/opra-user-scripts-gate.util.js +32 -0
  139. package/dist/utility/chart/overlay-execution-guard-key.leaf.d.ts +8 -0
  140. package/dist/utility/chart/overlay-execution-guard-key.leaf.js +10 -0
  141. package/dist/utility/chart/price-precision.util.d.ts +40 -0
  142. package/dist/utility/chart/price-precision.util.js +70 -0
  143. package/dist/utility/chart/profile-block-size.util.d.ts +64 -0
  144. package/dist/utility/chart/profile-block-size.util.js +141 -0
  145. package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.d.ts +11 -0
  146. package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.js +29 -0
  147. package/dist/utility/chart/protected-kscript-empty-output.util.d.ts +28 -0
  148. package/dist/utility/chart/protected-kscript-empty-output.util.js +84 -0
  149. package/dist/utility/chart/run-interval-unservable.leaf.d.ts +9 -0
  150. package/dist/utility/chart/run-interval-unservable.leaf.js +20 -0
  151. package/dist/utility/chart/run-interval-warmup.leaf.d.ts +19 -0
  152. package/dist/utility/chart/run-interval-warmup.leaf.js +35 -0
  153. package/dist/utility/chart/titan-constants.pin.d.ts +9 -5
  154. package/dist/utility/chart/titan-constants.pin.js +18 -5
  155. package/dist/utility/chart/warmup-backfill-retry.leaf.d.ts +9 -0
  156. package/dist/utility/chart/warmup-backfill-retry.leaf.js +9 -0
  157. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +11 -2
  158. package/dist/utility/chart/wrun-bar-session-facts.util.js +10 -3
  159. package/dist/utility/chart/wrun-run-result.util.d.ts +5 -1
  160. package/dist/utility/chart/wrun-run-result.util.js +20 -14
  161. package/dist/utility/common/data-processing.util.d.ts +138 -0
  162. package/dist/utility/common/data-processing.util.js +346 -0
  163. package/dist/utility/common/visible-timeout.util.d.ts +13 -4
  164. package/dist/utility/common/visible-timeout.util.js +23 -8
  165. package/dist/utility/exchange-format.leaf.d.ts +1 -0
  166. package/dist/utility/exchange-format.leaf.js +47 -0
  167. package/dist/utility/market-events/earnings-scope.util.d.ts +60 -0
  168. package/dist/utility/market-events/earnings-scope.util.js +92 -0
  169. package/dist/utility/market-events/market-events.util.d.ts +147 -0
  170. package/dist/utility/market-events/market-events.util.js +392 -0
  171. package/dist/utility/market-events/zoned-clock.util.d.ts +1 -0
  172. package/dist/utility/market-events/zoned-clock.util.js +11 -0
  173. package/dist/utility/options/option-venue-disclosure.util.d.ts +43 -0
  174. package/dist/utility/options/option-venue-disclosure.util.js +56 -0
  175. package/dist/utility/scriptEditor/package-semver.util.d.ts +51 -0
  176. package/dist/utility/scriptEditor/package-semver.util.js +120 -0
  177. package/dist/utility/scriptEditor/temp-script-id.util.d.ts +18 -0
  178. package/dist/utility/scriptEditor/temp-script-id.util.js +25 -0
  179. package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.d.ts +20 -0
  180. package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.js +81 -0
  181. package/dist/utility/v2/governed-tier.leaf.d.ts +103 -0
  182. package/dist/utility/v2/governed-tier.leaf.js +113 -0
  183. package/dist/utility/watchlist/import/import-request.leaf.d.ts +10 -0
  184. package/dist/utility/watchlist/import/import-request.leaf.js +10 -0
  185. package/dist/utility/wrun/sources/lanes/series.js +2 -2
  186. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +4 -4
  187. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +5 -6
  188. package/dist/utility/wrun/wrun-alert-outputs.registry.d.ts +166 -0
  189. package/dist/utility/wrun/wrun-alert-outputs.registry.js +219 -0
  190. package/dist/utility/wrun/wrun-bar-count.util.d.ts +94 -0
  191. package/dist/utility/wrun/wrun-bar-count.util.js +274 -0
  192. package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +84 -0
  193. package/dist/utility/wrun/wrun-chart-context-names.util.js +186 -0
  194. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +253 -0
  195. package/dist/utility/wrun/wrun-chart-market-facts.util.js +731 -0
  196. package/dist/utility/wrun/wrun-cloud-opra-stamp.util.d.ts +28 -0
  197. package/dist/utility/wrun/wrun-cloud-opra-stamp.util.js +45 -0
  198. package/dist/utility/wrun/wrun-coin-lane-live.util.d.ts +18 -0
  199. package/dist/utility/wrun/wrun-coin-lane-live.util.js +47 -0
  200. package/dist/utility/wrun/wrun-deadline.util.js +2 -1
  201. package/dist/utility/wrun/wrun-debug-output.util.d.ts +39 -0
  202. package/dist/utility/wrun/wrun-debug-output.util.js +63 -0
  203. package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +113 -0
  204. package/dist/utility/wrun/wrun-declared-warmup.util.js +181 -0
  205. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +43 -0
  206. package/dist/utility/wrun/wrun-draft-legend-note.util.js +158 -0
  207. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +181 -0
  208. package/dist/utility/wrun/wrun-draft-overlay.util.js +357 -0
  209. package/dist/utility/wrun/wrun-draw-skipped.leaf.d.ts +16 -0
  210. package/dist/utility/wrun/wrun-draw-skipped.leaf.js +16 -0
  211. package/dist/utility/wrun/wrun-earnings-facts.util.d.ts +42 -0
  212. package/dist/utility/wrun/wrun-earnings-facts.util.js +131 -0
  213. package/dist/utility/wrun/wrun-first-run-depth.util.d.ts +32 -0
  214. package/dist/utility/wrun/wrun-first-run-depth.util.js +118 -0
  215. package/dist/utility/wrun/wrun-gate-plane-readers.util.d.ts +24 -0
  216. package/dist/utility/wrun/wrun-gate-plane-readers.util.js +31 -0
  217. package/dist/utility/wrun/wrun-held-lanes.util.d.ts +32 -0
  218. package/dist/utility/wrun/wrun-held-lanes.util.js +94 -0
  219. package/dist/utility/wrun/wrun-host-visible-clock.util.d.ts +2 -0
  220. package/dist/utility/wrun/wrun-host-visible-clock.util.js +17 -0
  221. package/dist/utility/wrun/wrun-host.service.d.ts +330 -0
  222. package/dist/utility/wrun/wrun-host.service.js +855 -0
  223. package/dist/utility/wrun/wrun-hover.util.d.ts +3 -0
  224. package/dist/utility/wrun/wrun-hover.util.js +25 -4
  225. package/dist/utility/wrun/wrun-inert-legend.util.d.ts +33 -0
  226. package/dist/utility/wrun/wrun-inert-legend.util.js +125 -0
  227. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +155 -0
  228. package/dist/utility/wrun/wrun-input-requirements.leaf.js +450 -0
  229. package/dist/utility/wrun/wrun-integration-route.util.d.ts +51 -0
  230. package/dist/utility/wrun/wrun-integration-route.util.js +59 -0
  231. package/dist/utility/wrun/wrun-latest-history.leaf.d.ts +8 -0
  232. package/dist/utility/wrun/wrun-latest-history.leaf.js +8 -0
  233. package/dist/utility/wrun/wrun-legend-hover.lazy.d.ts +12 -0
  234. package/dist/utility/wrun/wrun-legend-hover.lazy.js +96 -0
  235. package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +21 -0
  236. package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +21 -0
  237. package/dist/utility/wrun/wrun-live-hidden-hold.util.d.ts +23 -0
  238. package/dist/utility/wrun/wrun-live-hidden-hold.util.js +13 -0
  239. package/dist/utility/wrun/wrun-live-intake.util.d.ts +374 -0
  240. package/dist/utility/wrun/wrun-live-intake.util.js +2027 -0
  241. package/dist/utility/wrun/wrun-live-patch.util.d.ts +116 -0
  242. package/dist/utility/wrun/wrun-live-patch.util.js +523 -0
  243. package/dist/utility/wrun/wrun-live-tick.util.d.ts +619 -0
  244. package/dist/utility/wrun/wrun-live-tick.util.js +4974 -0
  245. package/dist/utility/wrun/wrun-loading-owner.util.d.ts +58 -0
  246. package/dist/utility/wrun/wrun-loading-owner.util.js +89 -0
  247. package/dist/utility/wrun/wrun-official-scope.leaf.d.ts +29 -0
  248. package/dist/utility/wrun/wrun-official-scope.leaf.js +36 -0
  249. package/dist/utility/wrun/wrun-oi-lane.util.d.ts +27 -0
  250. package/dist/utility/wrun/wrun-oi-lane.util.js +42 -0
  251. package/dist/utility/wrun/wrun-options-stop.util.d.ts +52 -0
  252. package/dist/utility/wrun/wrun-options-stop.util.js +123 -0
  253. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +719 -0
  254. package/dist/utility/wrun/wrun-overlay-drivers.util.js +1180 -0
  255. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +50 -0
  256. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +131 -0
  257. package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +118 -0
  258. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +466 -0
  259. package/dist/utility/wrun/wrun-overlay-metadata.util.d.ts +45 -0
  260. package/dist/utility/wrun/wrun-overlay-metadata.util.js +112 -0
  261. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +114 -0
  262. package/dist/utility/wrun/wrun-overlay-recovery.util.js +971 -0
  263. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +858 -0
  264. package/dist/utility/wrun/wrun-overlay-run.util.js +11013 -0
  265. package/dist/utility/wrun/wrun-pack.util.d.ts +2 -1
  266. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +24 -9
  267. package/dist/utility/wrun/wrun-panel-mount.util.js +138 -43
  268. package/dist/utility/wrun/wrun-param-map.util.d.ts +19 -4
  269. package/dist/utility/wrun/wrun-param-map.util.js +40 -47
  270. package/dist/utility/wrun/wrun-param-values.util.d.ts +9 -3
  271. package/dist/utility/wrun/wrun-param-values.util.js +5 -5
  272. package/dist/utility/wrun/wrun-prefix-cohort.util.d.ts +93 -0
  273. package/dist/utility/wrun/wrun-prefix-cohort.util.js +484 -0
  274. package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +114 -0
  275. package/dist/utility/wrun/wrun-prefix-lanes.util.js +486 -0
  276. package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +317 -0
  277. package/dist/utility/wrun/wrun-prefix-proof.util.js +630 -0
  278. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +73 -0
  279. package/dist/utility/wrun/wrun-refusal-surface.util.js +380 -0
  280. package/dist/utility/wrun/wrun-refusal-text.util.d.ts +15 -0
  281. package/dist/utility/wrun/wrun-refusal-text.util.js +40 -0
  282. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
  283. package/dist/utility/wrun/wrun-replay-lane.util.d.ts +139 -0
  284. package/dist/utility/wrun/wrun-replay-lane.util.js +520 -0
  285. package/dist/utility/wrun/wrun-replay-rows.util.d.ts +21 -0
  286. package/dist/utility/wrun/wrun-replay-rows.util.js +172 -0
  287. package/dist/utility/wrun/wrun-row-source-factory.d.ts +53 -0
  288. package/dist/utility/wrun/wrun-row-source-factory.js +435 -0
  289. package/dist/utility/wrun/wrun-run-cells.util.d.ts +36 -0
  290. package/dist/utility/wrun/wrun-run-cells.util.js +46 -0
  291. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +133 -0
  292. package/dist/utility/wrun/wrun-run-interval-session.util.js +121 -0
  293. package/dist/utility/wrun/wrun-run-interval.util.d.ts +98 -0
  294. package/dist/utility/wrun/wrun-run-interval.util.js +207 -0
  295. package/dist/utility/wrun/wrun-run-retained.util.d.ts +122 -0
  296. package/dist/utility/wrun/wrun-run-retained.util.js +255 -0
  297. package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +184 -0
  298. package/dist/utility/wrun/wrun-sandbox-row-source.js +444 -0
  299. package/dist/utility/wrun/wrun-script-inputs.util.js +4 -4
  300. package/dist/utility/wrun/wrun-series-stream.util.d.ts +86 -0
  301. package/dist/utility/wrun/wrun-series-stream.util.js +537 -0
  302. package/dist/utility/wrun/wrun-sha256.leaf.d.ts +13 -0
  303. package/dist/utility/wrun/wrun-sha256.leaf.js +84 -0
  304. package/dist/utility/wrun/wrun-sheet-remembered.util.d.ts +21 -0
  305. package/dist/utility/wrun/wrun-sheet-remembered.util.js +36 -0
  306. package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.d.ts +7 -0
  307. package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.js +12 -0
  308. package/dist/utility/wrun/wrun-socket-row-source.js +4 -2
  309. package/dist/utility/wrun/wrun-source-rows.util.d.ts +175 -3
  310. package/dist/utility/wrun/wrun-source-rows.util.js +294 -8
  311. package/dist/utility/wrun/wrun-stats-strip.util.d.ts +46 -0
  312. package/dist/utility/wrun/wrun-stats-strip.util.js +87 -0
  313. package/dist/utility/wrun/wrun-table-chrome.util.d.ts +163 -0
  314. package/dist/utility/wrun/wrun-table-chrome.util.js +557 -0
  315. package/dist/utility/wrun/wrun-text-params.util.d.ts +11 -6
  316. package/dist/utility/wrun/wrun-text-params.util.js +19 -30
  317. package/dist/utility/wrun/wrun-transient-rerun.util.d.ts +64 -0
  318. package/dist/utility/wrun/wrun-transient-rerun.util.js +317 -0
  319. package/dist/utility/wrun/wrun-twin-lookback.util.d.ts +10 -0
  320. package/dist/utility/wrun/wrun-twin-lookback.util.js +43 -0
  321. package/dist/utility/wrun/wrun-warmup-head-store.util.d.ts +41 -0
  322. package/dist/utility/wrun/wrun-warmup-head-store.util.js +120 -0
  323. package/dist/utility/wrun-alert-params.leaf.d.ts +24 -0
  324. package/dist/utility/wrun-alert-params.leaf.js +24 -0
  325. package/dist/utils/replay/replay-buffer-math.d.ts +148 -0
  326. package/dist/utils/replay/replay-buffer-math.js +684 -0
  327. package/dist/workers/wrun/wrun-abi-host.d.ts +203 -0
  328. package/dist/workers/wrun/wrun-abi-host.js +1220 -0
  329. package/dist/workers/wrun/wrun-engine-handler.d.ts +20 -0
  330. package/dist/workers/wrun/wrun-engine-handler.js +380 -0
  331. package/package.json +3 -3
@@ -0,0 +1,122 @@
1
+ import type { WrunIndicatorMetadata, WrunOutputRow } from '../../interfaces/wrun-runtime.interface.js';
2
+ import type { WrunOverlayLiveContext } from './wrun-overlay-drivers.util.js';
3
+ import type { StrategyOutput } from '@orangecharts/indicator-kit/host';
4
+ /** A live eviction keeps this share of the cap (the heatmap and batched budgets' watermark): one
5
+ * whole repaint per crossing, not one per bar at the cap. A run (or a reseed) past its cap lands
6
+ * the same share, so the headroom exists from its first bar roll on. */
7
+ export declare const WRUN_RETAINED_TRIM_WATERMARK = 0.95;
8
+ /** What a session's run budget kept, once it holds fewer bars than its chart asked. */
9
+ export interface WrunRetainedRange {
10
+ /** The most rows a run of the session may hold: the smaller of the two budgets. */
11
+ cap: number;
12
+ /** The bars the session calculated: its rows from its first row on. */
13
+ calculatedBars: number;
14
+ /** The older bars the budget left out (the run's window start, and every live eviction since). */
15
+ droppedBars: number;
16
+ }
17
+ /** The newest chart rows a run computes over when its rows pass the cap. */
18
+ export interface WrunRunRetainedWindow<Row> {
19
+ /** The newest rows that fit (the same row objects, the recorded missing bars inside them kept). */
20
+ rows: Row[];
21
+ cap: number;
22
+ /** The rows it kept and the older ones it left out. */
23
+ retainedBars: number;
24
+ droppedBars: number;
25
+ }
26
+ /**
27
+ * The most rows a run of this sheet may hold: the smaller of the worker's cell budget over its
28
+ * declared outputs and the integrated-row budget over the series it can mount per bar (the run
29
+ * target's fill pairs and candle groups among them), the fixed decorator rows the sheet declares
30
+ * (`wrunSheetFixedRows`: one per table and label, a declared upper bound) taken off that budget
31
+ * first, so a session at the cap passes the preflight and its live growth evicts before it refuses.
32
+ * Undefined when neither binds: a frame-only sheet with nothing plotted.
33
+ */
34
+ export declare function wrunRunRetainedRowsCap(metadata: WrunIndicatorMetadata, target?: {
35
+ fills?: ReadonlyArray<unknown>;
36
+ candles?: ReadonlyArray<unknown>;
37
+ }): number | undefined;
38
+ /**
39
+ * The most rows one run block of this sheet may hold, a hidden warm-up head included: the worker's
40
+ * cell budget alone (`wrunRunCellsRows` over the declared outputs). A head's rows are cut by
41
+ * timestamp before anything integrates (wrun-overlay-run's `wrunSandboxLandedRows` and
42
+ * `wrunLandedOutputRows`), so they cost worker cells and never integrated rows: the integrated-row
43
+ * budget bounds the landed window only (`wrunRunRetainedRowsCap`). Undefined for a sheet that
44
+ * declares no outputs (a frame-only run allocates no cells).
45
+ */
46
+ export declare function wrunRunBlockRowsCap(metadata: Pick<WrunIndicatorMetadata, 'outputs'>): number | undefined;
47
+ /**
48
+ * The rows a run walks over a `wrunChartCandleRows` array: its candles plus the missing bars recorded strictly
49
+ * between them. A package that reads another lane on the chart's timeline walks a row at each recorded gap, and the
50
+ * dense grid of a nan or zero primary steps through them too for a non-candle primary only (a candle class's walks
51
+ * the chart's candles on every chart, wrun-source-rows.util `wrunNeedsChartPrimary`), so this bounds the input rows
52
+ * the row builder makes from these candles; a candle-only package walks the candles alone, under it.
53
+ */
54
+ export declare function wrunChartWalkedRows(rows: ReadonlyArray<ArrayLike<number>>): number;
55
+ /**
56
+ * The run's window over the chart rows it would compute (a `wrunChartCandleRows` array, a replay's rows): undefined
57
+ * when their walk fits the cap, else the newest rows whose walk fits `WRUN_RETAINED_TRIM_WATERMARK` of it (the same
58
+ * row objects in order, the recorded missing bars inside them kept: `wrunChartCandleRowsWithin`). The full run and the
59
+ * reseed decide here, so the session they install sits at the watermark under the cap its live eviction compares
60
+ * against: the first bar roll after either evicts nothing (landing at the cap evicted and repainted whole on it). A
61
+ * run over a window takes no hidden head.
62
+ */
63
+ export declare function wrunRunRetainedWindowOf<Row extends ArrayLike<number>>(rows: ReadonlyArray<Row>, cap: number | undefined): WrunRunRetainedWindow<Row> | undefined;
64
+ /** Whether a hidden head of `headRows` rows fits the worker's run block beside the window it runs before
65
+ * (`blockRowsCap`, `wrunRunBlockRowsCap`: the cell budget alone, its rows never integrate); a run whose head does not
66
+ * fit runs without it (cold at its first landed bar), never with fewer bars of its window. */
67
+ export declare function wrunRunRetainedHeadFits(rows: ReadonlyArray<ArrayLike<number>>, headRows: number, blockRowsCap: number | undefined): boolean;
68
+ /**
69
+ * A live session's merged rows over its cap lose their oldest rows down to
70
+ * `WRUN_RETAINED_TRIM_WATERMARK` of it, the run-level attachments (the handle set, the frames, the
71
+ * live block's accounting) carried over and the strategy rebased onto the kept rows
72
+ * (`wrunStrategyOnRows`); undefined while they fit. The newest row always stays.
73
+ */
74
+ export declare function evictWrunRetainedOutputRows(rows: WrunOutputRow[], cap: number | undefined): {
75
+ rows: WrunOutputRow[];
76
+ evicted: number;
77
+ } | undefined;
78
+ /**
79
+ * A session's broker output on its rows (design 5). The live guest's broker keeps every bar it ran since the session
80
+ * opened (one equity sample per bar, bar indexes counted from its first), while an eviction drops the session's
81
+ * oldest rows and the result's timeline (`combinedTimes`) is the rows' own timestamps: unrebased, the Strategy
82
+ * Tester would date each sample a dropped bar's count too late and leave the newest without a time. So the bars
83
+ * before the rows go: the per-bar series keep the rows' bars, every bar index moves back by the bars dropped, the
84
+ * closed trades keep those that exit on the rows (one that entered before them keeps its entry, at a negative bar),
85
+ * and the open trades all stay. The stats stay the run's, with the closed trades the cut left out counted
86
+ * (`closedTradeCount`, the tester's truncated-head rule). The output itself when its broker ran no bar before the
87
+ * rows; the broker's own answer is never rewritten.
88
+ */
89
+ export declare function wrunStrategyOnRows(strategy: StrategyOutput, rowCount: number): StrategyOutput;
90
+ /**
91
+ * The rows of a time-ordered `[ts, ...]` array (the chart's candles, a lane buffer) from `fromTs` on: the array itself
92
+ * when its first row is not older (a buffer trimmed at its last eviction: no copy), else one slice from the first row
93
+ * that is not, found by bisection (never a walk of the older rows).
94
+ */
95
+ export declare function wrunRowsFromTs<Row>(rows: Row[], fromTs: number): Row[];
96
+ export declare function wrunRowsFromTs<Row>(rows: ReadonlyArray<Row>, fromTs: number): ReadonlyArray<Row>;
97
+ /** A run's price-canvas source rows (`wrunCellRowsOf`'s): the candles and the celled lanes. */
98
+ export interface WrunCanvasSourceRows {
99
+ ohlcvRows?: ReadonlyArray<unknown>;
100
+ bookRows?: ReadonlyArray<unknown>;
101
+ volumeProfileRows?: ReadonlyArray<unknown>;
102
+ intrabarRows?: Readonly<Record<string, ReadonlyArray<unknown>>>;
103
+ }
104
+ /**
105
+ * A session's price-canvas source rows from its retained start on (design 5: nothing outside the retained range is
106
+ * mounted): a canvas that takes its rows whole (an eviction's swap, a heatmap mounted afresh, a reseed's) paints the
107
+ * bars the session calculated and none before them, as the full run's own canvases did over its window, and a TPO
108
+ * folds the same bars on every tick. A lane trimmed there already is handed as it is; the chart's candles are cut
109
+ * from the first retained bar.
110
+ */
111
+ export declare function wrunRetainedCanvasSources(sources: WrunCanvasSourceRows, fromTs: number): WrunCanvasSourceRows;
112
+ /**
113
+ * A session's celled canvas lanes (the book, the volume profile, the intrabar legs) trimmed to its retained start
114
+ * (design 5: nothing outside the retained range is carried, and a swap's cost stays the kept window's): a buffer
115
+ * reaching before `fromTs` is replaced by its rows from there on, once per move of the start (an eviction, a reseed's
116
+ * later window), and the lanes' start (`lanesFromTs`) follows, so a settings save never computes a window opening
117
+ * before it over these buffers. The scalar lanes keep their rows (an as-of read of the first retained bar may need
118
+ * the row before it).
119
+ */
120
+ export declare function trimWrunRetainedCanvasLanes(session: Pick<WrunOverlayLiveContext, 'bookRows' | 'volumeProfileRows' | 'intrabarRows' | 'lanesFromTs'>, fromTs: number): void;
121
+ /** The `wrun-run-retained` ring line (the debug dump): where a budget decided a window, and what it kept. */
122
+ export declare function ringWrunRunRetained(details: Record<string, unknown>): void;
@@ -0,0 +1,255 @@
1
+ /**
2
+ * The run's retained range (WRUN-MARKS-CONTRACT design 5): ONE decision, made where a run's input
3
+ * range is decided (the full run's planner and the reseed, wrun-overlay-run.util), shared by every
4
+ * reader of the run (packing, unpacking, the strategy feed, the session, the warm-up and prefix
5
+ * evidence, the reseed). A run asks for the newest rows its two budgets fit as its window:
6
+ *
7
+ * - the worker's cell budget: a run block holds `rows x outputCount` f64 cells, at most
8
+ * `WRUN_MAX_RUN_CELLS` (wrun-run-cells.util; Big Trades 0.4.0, 97 outputs: 41,237 rows);
9
+ * - the chart's integrated-row budget: the result mounts `rows x series` rows plus its fixed
10
+ * decorator rows (`wrunSheetFixedRows`: a table's, a label's), at most
11
+ * `OVERLAY_HISTORICAL_ROW_BUDGET` (the preflight, `applyWrunIntegrationBudget`), over the series
12
+ * per bar the sheet can mount (`wrunSheetRowSeriesPerBar`: 100 outputs with 11 plotted keep
13
+ * 36,363 rows).
14
+ *
15
+ * The smaller one is the session's cap (`retainedRowsCap`). A run whose rows pass it computes over
16
+ * the newest rows that fit the watermark of it (95%, the live eviction's, so the first bar roll after
17
+ * the run evicts nothing) with no hidden head (the window is the budget), and the session records
18
+ * what it kept (`retained`) and keeps the cap its eviction compares against. A hidden warm-up head
19
+ * costs worker cells only (its rows are cut before anything integrates), so it is checked against
20
+ * the worker's block alone (`wrunRunBlockRowsCap`). A range refresh whose retained window starts
21
+ * after the mounted rows replaces them, never merges onto them (wrun-overlay-run's integrate).
22
+ * Nothing outside the retained range is mounted, carried or used as
23
+ * evidence: the landing replaces the picture; a live session growing past the cap evicts its oldest
24
+ * rows to 95% of it (`evictWrunRetainedOutputRows`), so its merged result never passes either
25
+ * budget; a later prepend that would pass the cap evicts from the old end (the prefix planner
26
+ * declines it and the whole run decides again; a session holding a retained range takes no page
27
+ * before its first row, the lifecycle door's rule); a reseed computes nothing before the first row
28
+ * of a session holding a retained range and decides again over its own rows. The
29
+ * worker's refusal by name (`wrun_run_cells_too_large`) stays the backstop of a request nothing
30
+ * sized.
31
+ *
32
+ * The cost: a script whose state depends on bars before the kept window starts cold at the window,
33
+ * as on a chart whose history starts there.
34
+ */
35
+ import { wrunChartHostEnv } from '../../host-env.js';
36
+ import { attachWrunLive, wrunLiveOf } from '../../interfaces/wrun-runtime.interface.js';
37
+ import { OVERLAY_HISTORICAL_ROW_BUDGET } from '../chart/overlay-output-budget.util.js';
38
+ import { wrunSheetFixedRows, wrunSheetRowSeriesPerBar } from '../chart/wrun-run-result.util.js';
39
+ import { attachWrunStrategy, wrunStrategyOf } from './wrun-box-segment.util.js';
40
+ import { attachWrunHandles, wrunHandlesOf } from './wrun-handles.util.js';
41
+ import { attachWrunFrames, wrunFramesOf } from './wrun-pack.util.js';
42
+ import { wrunRunCellsRows } from './wrun-run-cells.util.js';
43
+ import { wrunChartCandleRowsWithin, wrunChartGapBarsOf } from './wrun-source-rows.util.js';
44
+ /** A live eviction keeps this share of the cap (the heatmap and batched budgets' watermark): one
45
+ * whole repaint per crossing, not one per bar at the cap. A run (or a reseed) past its cap lands
46
+ * the same share, so the headroom exists from its first bar roll on. */
47
+ export const WRUN_RETAINED_TRIM_WATERMARK = 0.95;
48
+ /**
49
+ * The most rows a run of this sheet may hold: the smaller of the worker's cell budget over its
50
+ * declared outputs and the integrated-row budget over the series it can mount per bar (the run
51
+ * target's fill pairs and candle groups among them), the fixed decorator rows the sheet declares
52
+ * (`wrunSheetFixedRows`: one per table and label, a declared upper bound) taken off that budget
53
+ * first, so a session at the cap passes the preflight and its live growth evicts before it refuses.
54
+ * Undefined when neither binds: a frame-only sheet with nothing plotted.
55
+ */
56
+ export function wrunRunRetainedRowsCap(metadata, target = {}) {
57
+ const caps = [];
58
+ const cells = wrunRunCellsRows(metadata.outputs?.length ?? 0);
59
+ if (cells !== null)
60
+ caps.push(cells);
61
+ const series = wrunSheetRowSeriesPerBar(metadata, target);
62
+ if (series > 0)
63
+ caps.push(Math.floor((OVERLAY_HISTORICAL_ROW_BUDGET - wrunSheetFixedRows(metadata)) / series));
64
+ return caps.length === 0 ? undefined : Math.max(1, Math.min(...caps));
65
+ }
66
+ /**
67
+ * The most rows one run block of this sheet may hold, a hidden warm-up head included: the worker's
68
+ * cell budget alone (`wrunRunCellsRows` over the declared outputs). A head's rows are cut by
69
+ * timestamp before anything integrates (wrun-overlay-run's `wrunSandboxLandedRows` and
70
+ * `wrunLandedOutputRows`), so they cost worker cells and never integrated rows: the integrated-row
71
+ * budget bounds the landed window only (`wrunRunRetainedRowsCap`). Undefined for a sheet that
72
+ * declares no outputs (a frame-only run allocates no cells).
73
+ */
74
+ export function wrunRunBlockRowsCap(metadata) {
75
+ return wrunRunCellsRows(metadata.outputs?.length ?? 0) ?? undefined;
76
+ }
77
+ /**
78
+ * The rows a run walks over a `wrunChartCandleRows` array: its candles plus the missing bars recorded strictly
79
+ * between them. A package that reads another lane on the chart's timeline walks a row at each recorded gap, and the
80
+ * dense grid of a nan or zero primary steps through them too for a non-candle primary only (a candle class's walks
81
+ * the chart's candles on every chart, wrun-source-rows.util `wrunNeedsChartPrimary`), so this bounds the input rows
82
+ * the row builder makes from these candles; a candle-only package walks the candles alone, under it.
83
+ */
84
+ export function wrunChartWalkedRows(rows) {
85
+ return rows.length + wrunChartGapBarsOf(rows).length;
86
+ }
87
+ /**
88
+ * The run's window over the chart rows it would compute (a `wrunChartCandleRows` array, a replay's rows): undefined
89
+ * when their walk fits the cap, else the newest rows whose walk fits `WRUN_RETAINED_TRIM_WATERMARK` of it (the same
90
+ * row objects in order, the recorded missing bars inside them kept: `wrunChartCandleRowsWithin`). The full run and the
91
+ * reseed decide here, so the session they install sits at the watermark under the cap its live eviction compares
92
+ * against: the first bar roll after either evicts nothing (landing at the cap evicted and repainted whole on it). A
93
+ * run over a window takes no hidden head.
94
+ */
95
+ export function wrunRunRetainedWindowOf(rows, cap) {
96
+ if (cap === undefined || wrunChartWalkedRows(rows) <= cap)
97
+ return undefined;
98
+ const keep = Math.max(1, Math.floor(cap * WRUN_RETAINED_TRIM_WATERMARK));
99
+ const gaps = wrunChartGapBarsOf(rows);
100
+ // The gaps after a row's open (every gap sits before the newest row, so a slice from that row holds them all).
101
+ const gapsAfter = (ts) => {
102
+ let low = 0;
103
+ let high = gaps.length;
104
+ while (low < high) {
105
+ const mid = (low + high) >>> 1;
106
+ if (gaps[mid] > ts)
107
+ high = mid;
108
+ else
109
+ low = mid + 1;
110
+ }
111
+ return gaps.length - low;
112
+ };
113
+ // A slice from `from` walks `rows.length - from` rows and the gaps after its first: the first `from` that fits.
114
+ let low = 0;
115
+ let high = rows.length - 1;
116
+ while (low < high) {
117
+ const mid = (low + high) >>> 1;
118
+ if (rows.length - mid + gapsAfter(Number(rows[mid][0])) <= keep)
119
+ high = mid;
120
+ else
121
+ low = mid + 1;
122
+ }
123
+ const kept = wrunChartCandleRowsWithin(rows, Number(rows[low][0]));
124
+ return { rows: kept, cap, retainedBars: kept.length, droppedBars: rows.length - kept.length };
125
+ }
126
+ /** Whether a hidden head of `headRows` rows fits the worker's run block beside the window it runs before
127
+ * (`blockRowsCap`, `wrunRunBlockRowsCap`: the cell budget alone, its rows never integrate); a run whose head does not
128
+ * fit runs without it (cold at its first landed bar), never with fewer bars of its window. */
129
+ export function wrunRunRetainedHeadFits(rows, headRows, blockRowsCap) {
130
+ return blockRowsCap === undefined || headRows <= 0 || wrunChartWalkedRows(rows) + headRows <= blockRowsCap;
131
+ }
132
+ /**
133
+ * A live session's merged rows over its cap lose their oldest rows down to
134
+ * `WRUN_RETAINED_TRIM_WATERMARK` of it, the run-level attachments (the handle set, the frames, the
135
+ * live block's accounting) carried over and the strategy rebased onto the kept rows
136
+ * (`wrunStrategyOnRows`); undefined while they fit. The newest row always stays.
137
+ */
138
+ export function evictWrunRetainedOutputRows(rows, cap) {
139
+ if (cap === undefined || rows.length <= cap)
140
+ return undefined;
141
+ const keep = Math.max(1, Math.floor(cap * WRUN_RETAINED_TRIM_WATERMARK));
142
+ const kept = rows.slice(rows.length - keep);
143
+ const handles = wrunHandlesOf(rows);
144
+ if (handles !== undefined)
145
+ attachWrunHandles(kept, handles);
146
+ const strategy = wrunStrategyOf(rows);
147
+ if (strategy !== undefined)
148
+ attachWrunStrategy(kept, wrunStrategyOnRows(strategy, kept.length));
149
+ const frames = wrunFramesOf(rows);
150
+ if (frames !== undefined)
151
+ attachWrunFrames(kept, frames);
152
+ const live = wrunLiveOf(rows);
153
+ if (live !== undefined)
154
+ attachWrunLive(kept, live);
155
+ return { rows: kept, evicted: rows.length - keep };
156
+ }
157
+ /**
158
+ * A session's broker output on its rows (design 5). The live guest's broker keeps every bar it ran since the session
159
+ * opened (one equity sample per bar, bar indexes counted from its first), while an eviction drops the session's
160
+ * oldest rows and the result's timeline (`combinedTimes`) is the rows' own timestamps: unrebased, the Strategy
161
+ * Tester would date each sample a dropped bar's count too late and leave the newest without a time. So the bars
162
+ * before the rows go: the per-bar series keep the rows' bars, every bar index moves back by the bars dropped, the
163
+ * closed trades keep those that exit on the rows (one that entered before them keeps its entry, at a negative bar),
164
+ * and the open trades all stay. The stats stay the run's, with the closed trades the cut left out counted
165
+ * (`closedTradeCount`, the tester's truncated-head rule). The output itself when its broker ran no bar before the
166
+ * rows; the broker's own answer is never rewritten.
167
+ */
168
+ export function wrunStrategyOnRows(strategy, rowCount) {
169
+ const dropped = strategy.equity.length - rowCount;
170
+ if (!(dropped > 0))
171
+ return strategy;
172
+ const trades = strategy.trades.filter((trade) => trade.exitBar >= dropped);
173
+ const stated = strategy.stats.closedTradeCount;
174
+ const closedTradeCount = typeof stated === 'number' ? stated : strategy.trades.length;
175
+ return {
176
+ ...strategy,
177
+ trades: trades.map((trade) => ({ ...trade, entryBar: trade.entryBar - dropped, exitBar: trade.exitBar - dropped })),
178
+ openTrades: strategy.openTrades.map((trade) => ({ ...trade, entryBar: trade.entryBar - dropped })),
179
+ equity: strategy.equity.slice(dropped),
180
+ drawdown: strategy.drawdown.slice(dropped),
181
+ ...(strategy.committedMarginSeries !== undefined
182
+ ? { committedMarginSeries: strategy.committedMarginSeries.slice(dropped) }
183
+ : {}),
184
+ ...(strategy.fundingPaidSeries !== undefined
185
+ ? { fundingPaidSeries: strategy.fundingPaidSeries.slice(dropped) }
186
+ : {}),
187
+ ...(trades.length < strategy.trades.length
188
+ ? { stats: { ...strategy.stats, closedTradeCount } }
189
+ : {}),
190
+ };
191
+ }
192
+ export function wrunRowsFromTs(rows, fromTs) {
193
+ const tsAt = (at) => {
194
+ const row = rows[at];
195
+ return Number(row[0]);
196
+ };
197
+ if (rows.length === 0 || !(tsAt(0) < fromTs))
198
+ return rows;
199
+ let low = 1;
200
+ let high = rows.length;
201
+ while (low < high) {
202
+ const mid = (low + high) >>> 1;
203
+ if (tsAt(mid) < fromTs)
204
+ low = mid + 1;
205
+ else
206
+ high = mid;
207
+ }
208
+ return rows.slice(low);
209
+ }
210
+ /**
211
+ * A session's price-canvas source rows from its retained start on (design 5: nothing outside the retained range is
212
+ * mounted): a canvas that takes its rows whole (an eviction's swap, a heatmap mounted afresh, a reseed's) paints the
213
+ * bars the session calculated and none before them, as the full run's own canvases did over its window, and a TPO
214
+ * folds the same bars on every tick. A lane trimmed there already is handed as it is; the chart's candles are cut
215
+ * from the first retained bar.
216
+ */
217
+ export function wrunRetainedCanvasSources(sources, fromTs) {
218
+ const { ohlcvRows, bookRows, volumeProfileRows, intrabarRows } = sources;
219
+ return {
220
+ ...(ohlcvRows !== undefined ? { ohlcvRows: wrunRowsFromTs(ohlcvRows, fromTs) } : {}),
221
+ ...(bookRows !== undefined ? { bookRows: wrunRowsFromTs(bookRows, fromTs) } : {}),
222
+ ...(volumeProfileRows !== undefined ? { volumeProfileRows: wrunRowsFromTs(volumeProfileRows, fromTs) } : {}),
223
+ ...(intrabarRows !== undefined
224
+ ? {
225
+ intrabarRows: Object.fromEntries(Object.entries(intrabarRows).map(([fetchKey, rows]) => [fetchKey, wrunRowsFromTs(rows, fromTs)])),
226
+ }
227
+ : {}),
228
+ };
229
+ }
230
+ /**
231
+ * A session's celled canvas lanes (the book, the volume profile, the intrabar legs) trimmed to its retained start
232
+ * (design 5: nothing outside the retained range is carried, and a swap's cost stays the kept window's): a buffer
233
+ * reaching before `fromTs` is replaced by its rows from there on, once per move of the start (an eviction, a reseed's
234
+ * later window), and the lanes' start (`lanesFromTs`) follows, so a settings save never computes a window opening
235
+ * before it over these buffers. The scalar lanes keep their rows (an as-of read of the first retained bar may need
236
+ * the row before it).
237
+ */
238
+ export function trimWrunRetainedCanvasLanes(session, fromTs) {
239
+ if (session.bookRows !== undefined)
240
+ session.bookRows = wrunRowsFromTs(session.bookRows, fromTs);
241
+ if (session.volumeProfileRows !== undefined) {
242
+ session.volumeProfileRows = wrunRowsFromTs(session.volumeProfileRows, fromTs);
243
+ }
244
+ const intrabar = session.intrabarRows;
245
+ if (intrabar !== undefined && Object.values(intrabar).some((rows) => rows.length > 0 && rows[0][0] < fromTs)) {
246
+ session.intrabarRows = Object.fromEntries(Object.entries(intrabar).map(([fetchKey, rows]) => [fetchKey, wrunRowsFromTs(rows, fromTs)]));
247
+ }
248
+ if (session.lanesFromTs !== undefined && session.lanesFromTs < fromTs)
249
+ session.lanesFromTs = fromTs;
250
+ }
251
+ /** The `wrun-run-retained` ring line (the debug dump): where a budget decided a window, and what it kept. */
252
+ export function ringWrunRunRetained(details) {
253
+ if (wrunChartHostEnv().diagnostics.debugEnabled())
254
+ wrunChartHostEnv().diagnostics.debug('wrun-run-retained', details);
255
+ }
@@ -0,0 +1,184 @@
1
+ /**
2
+ * The browser lane's row source (WRUN-PARITY-PLAN contract C7, unit U13): `SandboxWrunRowSource` implements
3
+ * `WrunRowSource` over today's browser lanes, so the own run's pass asks a source for rows and reads the batch.
4
+ *
5
+ * - `create` raises the overlay's load signals, asks the pass's lanes (`WrunSandboxHost.prepare`: the chart's sources
6
+ * resolved through wrun-source-rows.util.ts, the tape plan's settings included, into the engine worker's request),
7
+ * runs the module in the engine worker over the window and answers a `WrunRowBatch` in the hosted wire's shape:
8
+ * the module's rows, the canvases' cells (`grids`), the frames, the handles and the sheet.
9
+ * - `range` answers another window of the same session; `changeSettings` re-runs the session's own window with the
10
+ * patched record (a `null` drops the value), the same session, never a new source.
11
+ * - `frames` is the session's live stream: the live tick's hook (`emitWrunSandboxRowFrame`) hands its frames to the
12
+ * listener the pass subscribed. Subscribing is also the pass's word that the batch landed (below).
13
+ * - `teardown` releases the session: the engine worker's live session this source opened (its generation only), the
14
+ * overlay's session lock and every load signal still raised.
15
+ *
16
+ * The source charges no render size of its own: the run-result builder's budget (wrun-render-select.util
17
+ * `createWrunRenderBudget`, one counter over the selection, the frame consumers, the handles and the strategy) is the
18
+ * browser lane's one accounting of the `chart-browser` profile's `caps.renderBytes`, and its refusal carries the kit's
19
+ * code (`wrun_render_result_too_large`) as the cloud's does (plan row 15). The browser profile refuses no family, so a
20
+ * batch carries no refusal.
21
+ *
22
+ * The landing protocol. A run that opens the overlay's live session (`plan.live`: its window reaches the chart's
23
+ * newest bar) holds the overlay's session lock from right before the session opens until the pass took the session:
24
+ * a tick or a reseed never interleaves with the start, the integrate and the context install, as when the pass held
25
+ * the lock itself. The pass takes the session by subscribing to `frames` once the batch is integrated; `teardown`
26
+ * releases it instead (a failed integrate, or a page that opened no session). The load signals a call raised stay up
27
+ * until then too, so the legend loader and the store's kScript loading flag cover the whole pass (data-loading rule
28
+ * 2: the source raises and lowers, the chokepoint derives what shows; rule 3: lowered on success, failure, abort and
29
+ * the deadline alike). A call made after the session was taken, that opens no session, lands with its answer.
30
+ *
31
+ * The source keeps no fetch registry of its own: its lanes ask through `dataFetch`, the coverage planner's in-flight
32
+ * registry and dedupe table.
33
+ */
34
+ import type { WrunChartHandle } from '../../host-ports.types.js';
35
+ import type { WrunIndicatorMetadata, WrunModuleHandle, WrunOutputRow } from '../../interfaces/wrun-runtime.interface.js';
36
+ import type { WrunCellRows } from './wrun-canvases.util.js';
37
+ import { type WrunStrategyRunInput } from './wrun-host.service.js';
38
+ import { type WrunInputRow } from './wrun-pack.util.js';
39
+ import type { WrunRowBatch, WrunRowFrame, WrunRowFrameStream, WrunRowSource, WrunRowSourceIdentity, WrunRowSourcePatch, WrunRowSourceRecord, WrunRowWindow } from './wrun-row-source.js';
40
+ /** The chart engine a run computes for (the pass's `getTC` read at its head). */
41
+ type WrunSandboxChart = WrunChartHandle;
42
+ /** The engine and the overlay meta a run computes for and integrates into. */
43
+ export interface WrunSandboxMount {
44
+ tc: WrunSandboxChart;
45
+ meta: Record<string, unknown>;
46
+ }
47
+ /** Whether a run's overlay is still on the chart that ran it: the index still holds the same engine, and that engine
48
+ * still holds the same meta (a removal takes the meta off; a remount under the same id is a new meta that its own run
49
+ * publishes for, the same identity `placeWrunResultTables` follows). */
50
+ export declare function isWrunRunMountOnChart(chartIndex: number, mount: {
51
+ tc: unknown;
52
+ meta: unknown;
53
+ }): boolean;
54
+ /** The load signals one call raised: `lower` takes them down (idempotent). */
55
+ export interface WrunSandboxLoadHold {
56
+ lower(): void;
57
+ }
58
+ /**
59
+ * Raise a run's load signals, in the vocabulary a cloud run's fetch speaks: the legend loader (`tc.updateLoadState`,
60
+ * the overlay's legend spinner, the affordance kScript overlays show) and the store's kScript loading flag through
61
+ * its single chokepoint (`setKScriptLoadingIndicator`), whose watchdog adds the "Still loading" chip after 20 s and
62
+ * force-lowers a run still going at 75 s with the "Loading stopped" chip: the same chips at the same thresholds on
63
+ * both lanes. Every full run rides it (the add-time initial run, rehydrate, the settings-save recompute, a prefix run,
64
+ * the lazy-wave pan-back rerun dispatched through the drivers' single-flight executor); the live forming-bar tick lane
65
+ * bypasses it and stays loader-free.
66
+ *
67
+ * The legend lower is instance-guarded like the chart's other owners (a chart rebuilt at this index mid-run keeps its
68
+ * own load state). The flag, keyed by the overlay, has one owner across its raisers (wrun-loading-owner.util): a run
69
+ * claims it when it is down or an earlier run holds it (a replacement's run takes it over), leaves a restored
70
+ * record's or a settings-apply cycle's to them, and lowers it only while it still owns it, so a replacement's run or
71
+ * restore that took it over keeps it. A run whose mount is gone before it raises (the chart rebuilt at the index, the
72
+ * record mounted again) computes for nothing on the chart and claims nothing. The store is advisory: one that cannot
73
+ * load (or a partial double) leaves the legend loader as the run's only signal. The lower also takes back the
74
+ * "Loading stopped" chip of a forced lower the run outlived (its verdict replaces it, as a cloud run's result does).
75
+ */
76
+ export declare function raiseWrunSandboxLoading(chartIndex: number, indicatorId: string, mount: WrunSandboxMount): Promise<WrunSandboxLoadHold>;
77
+ /** What a sandbox batch is built from: the sheet the module ran, its rows (the module's own array, its frames,
78
+ * handles and strategy riding on it) and the aligned input rows it read. */
79
+ export interface WrunSandboxBatchInput {
80
+ sheet: WrunIndicatorMetadata;
81
+ rows: WrunOutputRow[];
82
+ inputs: readonly WrunInputRow[];
83
+ /** The window asked for: the batch's window when the run answered no row. */
84
+ window: WrunRowWindow;
85
+ /** The canvases' cells in the browser's own lanes (the run's source rows), beside the wire's `grids`. */
86
+ cellRows?: WrunCellRows;
87
+ /** A create's batch carries the sheet it ran. */
88
+ withSheet: boolean;
89
+ }
90
+ /** The canvases' cells of a sandbox batch in the browser's own lanes (book, profile and intrabar rows as the price
91
+ * canvases read them), the same blocks the batch's `grids` spell for the wire; undefined for a batch that carries
92
+ * none. */
93
+ export declare function wrunRowBatchCellRows(batch: WrunRowBatch): WrunCellRows | undefined;
94
+ /**
95
+ * One batch of the sandbox (a create, a range, a patch or a live frame) in the hosted wire's shape, with no refusal
96
+ * (the browser profile refuses no family; the run-result builder's budget charges the render size). `rows` is the
97
+ * module's own array; `window` and `asOfMs` read off it. `grids` are derived from the input rows on their first
98
+ * read: the browser's canvases read the same blocks in their own lanes (`wrunRowBatchCellRows`), so a run whose batch
99
+ * nobody spells pays no copy of its cells. The shared host must be loaded (every sandbox run loads it first).
100
+ */
101
+ export declare function wrunSandboxRowBatchOf(input: WrunSandboxBatchInput): WrunRowBatch;
102
+ /** The engine worker's request one window resolves to (`WrunBrowserHost.runSeries` / `startLiveSeries`). */
103
+ export interface WrunSandboxRunRequest {
104
+ module: WrunModuleHandle;
105
+ metadata: WrunIndicatorMetadata;
106
+ rows: readonly WrunInputRow[];
107
+ initArgs: readonly number[];
108
+ textParams?: Readonly<Record<number, Uint8Array>>;
109
+ strategy?: WrunStrategyRunInput;
110
+ /** A Retry or a settings run dispatches a package the host quarantined (C5). */
111
+ overrideQuarantine?: boolean;
112
+ }
113
+ /** One window of the browser lane resolved through its lanes: what the engine worker computes. */
114
+ export interface WrunSandboxPlan {
115
+ /** The run opens the overlay's live forming-bar session (its window reaches the chart's newest bar). */
116
+ live: boolean;
117
+ request: WrunSandboxRunRequest;
118
+ /** The pass's last word before the module runs, under the session lock on a live run (a pause, the chart owner):
119
+ * throws to stand the run down. */
120
+ admit(): Promise<void>;
121
+ /** The canvases' cells in the browser's own lanes, carried on the batch. */
122
+ cellRows?: WrunCellRows;
123
+ /** Stamped by the source when the run opens the live session: the generation the session opened under (the
124
+ * session epoch; the live context carries it). */
125
+ epoch?: number;
126
+ }
127
+ /** What a sandbox source needs from the pass that drives it: the mount it raises the load signals on, and the
128
+ * browser lane's lanes, resolving a window's sources (wrun-source-rows.util.ts) into the engine worker's request. */
129
+ export interface WrunSandboxHost {
130
+ mount: WrunSandboxMount;
131
+ prepare(window: WrunRowWindow, record: WrunRowSourceRecord): Promise<WrunSandboxPlan>;
132
+ /** The module answered, before its result is built: the run's debug lines reach the editor console now, so a result
133
+ * the builder refuses still shows the lines that explain it. */
134
+ answered?(rows: WrunOutputRow[]): Promise<void> | void;
135
+ }
136
+ /**
137
+ * The live tick's hook (C7; U14 and U15 wire it): hand one frame of an overlay's sandbox session (built with
138
+ * `wrunSandboxRowBatchOf`) to the listener the pass subscribed. False when no pass took the
139
+ * overlay's session: the tick then integrates its own frame, today's path.
140
+ */
141
+ export declare function emitWrunSandboxRowFrame(indicatorId: string, frame: WrunRowFrame): boolean;
142
+ /** Specs only: forget every taken session. */
143
+ export declare function __resetWrunSandboxRowSourcesForTests(): void;
144
+ export declare class SandboxWrunRowSource implements WrunRowSource {
145
+ private readonly host;
146
+ readonly frames: WrunRowFrameStream;
147
+ private identity;
148
+ private record;
149
+ private window;
150
+ /** The engine worker's live session this source opened last (its generation). */
151
+ private opened;
152
+ /** Releases the session lock the last live open holds until the pass takes the session. */
153
+ private landing;
154
+ /** The load signals of calls whose batch has not landed yet. */
155
+ private readonly holds;
156
+ private listener;
157
+ private taken;
158
+ private torn;
159
+ constructor(host: WrunSandboxHost);
160
+ create(identity: WrunRowSourceIdentity, record: WrunRowSourceRecord, window: WrunRowWindow): Promise<WrunRowBatch>;
161
+ range(window: WrunRowWindow): Promise<WrunRowBatch>;
162
+ changeSettings(patch: WrunRowSourcePatch): Promise<WrunRowBatch>;
163
+ teardown(): void;
164
+ /** The pass took the session: its frames flow to `listener`, the session lock goes and the load signals lower. */
165
+ private subscribe;
166
+ /** Every call's batch landed: the load signals still up lower, and a live open's session lock goes. */
167
+ private land;
168
+ private lowerHold;
169
+ private created;
170
+ private assertStanding;
171
+ private compute;
172
+ /** A page short of the live edge: the module runs cold over the window, no live session. */
173
+ private runCold;
174
+ /**
175
+ * Open the overlay's live session under its session lock and answer the module's rows with the lock still held:
176
+ * the pass's admit (paused meanwhile, the chart's owner left) right before the session is replaced, the generation
177
+ * bumped BEFORE the start so the worker session opens under the epoch the live context will carry. A start that
178
+ * fails ends the session it opened (that generation only, the previous context's next drain then finds no session
179
+ * and reseeds) and lets the lock go. On success the lock stays held until the landing (`land`) or a failure of the
180
+ * call (`compute`) releases it.
181
+ */
182
+ private openLive;
183
+ }
184
+ export {};