@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,118 @@
1
+ /**
2
+ * A twin's FIRST-RUN ordering, the kScript lane's (chart.add-indicator.ts, the local script init):
3
+ * before its first run on the chart a script waits for an in-flight main candle fetch to commit
4
+ * (`waitForMainCandleFetchCommit`, bounded) and buys the pages its declared lookback owes the loaded
5
+ * window (`prefetchDeclaredDepthBeforeFirstRun`: the same ledger, chooser and landed rule as every
6
+ * warm-up page), so the first picture is computed on the history the declaration needs. The kScript
7
+ * Anchored VWAP (a 366-day anchor, 5,000 bars at 1h) never shows a picture computed on the 568 bars a
8
+ * fresh 1h chart holds; its twin computed exactly that and stayed there until a wave reran it
9
+ * (parity sweep 10-06, m_vwap 80,988.64 against 80,002.95).
10
+ *
11
+ * The run pass calls this for an `initial` run (the add, the rehydrate) whose lookback is the
12
+ * original's (wrun-twin-lookback.util): every later run reads the same lookback through the
13
+ * post-run ask (`askWrunWarmupBackfillIfOwed`), as the kScript lane's later results do. Every read
14
+ * of the chart goes through the executor ports `chart.askDeclaredDepthBeforeRun` and
15
+ * `chart.isWarmupRoundLandedOn` (web binds the ask util's `askLocalKScriptDeclaredDepthBeforeRun` and
16
+ * `isLocalKScriptWarmupRoundLandedOn`, web-ports/executor.ts), so the ordering is driven by fakes in the
17
+ * run pass specs.
18
+ */
19
+ import { wrunChartHostEnv } from '../../host-env.js';
20
+ import { loadedBarsOfWindow } from '../chart/local-kscript-warmup-depth.util.js';
21
+ import { WARMUP_BACKFILL_GESTURE_RETRY_LIMIT, WARMUP_BACKFILL_GESTURE_RETRY_MS, } from '../chart/warmup-backfill-retry.leaf.js';
22
+ /** The kScript first run's bound on an in-flight main candle fetch (LOCAL_KSCRIPT_FIRST_RUN_MAIN_FETCH_WAIT_MS). */
23
+ export const WRUN_FIRST_RUN_MAIN_FETCH_WAIT_MS = 4_000;
24
+ /** The kScript first run's poll between its rounds (LOCAL_KSCRIPT_FIRST_RUN_DEPTH_POLL_MS). */
25
+ export const WRUN_FIRST_RUN_DEPTH_POLL_MS = 100;
26
+ /**
27
+ * The whole ordering's ceiling. The kScript lane holds its first run up to 75 s; a wrun first run
28
+ * rides inside the add's 90 s compute deadline (WRUN_RUN_DEADLINE_MS) with its own fetches and
29
+ * sandbox run after the ordering, so the ordering takes half of it. Past the ceiling the run computes
30
+ * on the rows at hand and the post-run ask owes the rest, as on the kScript lane.
31
+ */
32
+ export const WRUN_FIRST_RUN_DEPTH_HOLD_CEILING_MS = 45_000;
33
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
34
+ function loadedBarsOf(input) {
35
+ const rows = input.tc.metadata?.[0];
36
+ const raw = rows?.rawData;
37
+ const first = typeof raw?.[0]?.[0] === 'number' ? raw[0][0] : null;
38
+ const last = raw?.length ? raw[raw.length - 1]?.[0] : undefined;
39
+ return loadedBarsOfWindow(first, typeof last === 'number' ? last : null, input.intervalMs);
40
+ }
41
+ /** Order the history a twin's first run computes on (see the module note); resolves with the outcome
42
+ * and logs it as `wrun-first-run-declared-depth`. Never throws. */
43
+ export async function orderWrunFirstRunHistory(input) {
44
+ const now = input.now ?? Date.now;
45
+ const tick = input.tick ?? sleep;
46
+ const startedAt = now();
47
+ const pastCeiling = () => now() - startedAt >= WRUN_FIRST_RUN_DEPTH_HOLD_CEILING_MS;
48
+ const ring = { lane: 'wrun', phase: 'first-run' };
49
+ const loadedBarsBefore = loadedBarsOf(input);
50
+ const finish = (outcome, rounds) => {
51
+ wrunChartHostEnv().diagnostics.debug('wrun-first-run-declared-depth', {
52
+ chartIndex: input.chartIndex,
53
+ indicatorId: input.indicatorId,
54
+ ...ring,
55
+ lookbackBars: input.lookbackBars,
56
+ loadedBarsBefore,
57
+ loadedBarsAfter: loadedBarsOf(input),
58
+ rounds,
59
+ outcome,
60
+ waitedMs: now() - startedAt,
61
+ });
62
+ return outcome;
63
+ };
64
+ try {
65
+ // The first run's span waits for an in-flight main candle commit (a boot or a switch landing
66
+ // its window), bounded; on timeout it proceeds on the rows at hand.
67
+ for (let waited = 0; input.isMainCandleFetchInFlight?.() === true && waited < WRUN_FIRST_RUN_MAIN_FETCH_WAIT_MS;) {
68
+ await tick(WRUN_FIRST_RUN_DEPTH_POLL_MS);
69
+ waited += WRUN_FIRST_RUN_DEPTH_POLL_MS;
70
+ if (!input.isCurrent())
71
+ return finish('superseded', 0);
72
+ }
73
+ const loaded = loadedBarsOf(input);
74
+ if (loaded === null || loaded >= input.lookbackBars)
75
+ return finish('fits', 0);
76
+ let rounds = 0;
77
+ let gestureRetries = 0;
78
+ for (;;) {
79
+ if (!input.isCurrent())
80
+ return finish('superseded', rounds);
81
+ if (pastCeiling())
82
+ return finish('ceiling', rounds);
83
+ const ask = wrunChartHostEnv().chart.askDeclaredDepthBeforeRun({ ...input, ringDetails: ring });
84
+ if (ask === null)
85
+ return finish('read-failed', rounds);
86
+ if (ask.requested || ask.reason === 'page-pending') {
87
+ if (ask.requested)
88
+ rounds += 1;
89
+ // The landed rule between rounds: the page is on the chart once its start reaches the
90
+ // asked start, or once the chain stopped (a clipped page is judged on what it bought).
91
+ while (!wrunChartHostEnv().chart.isWarmupRoundLandedOn(input)) {
92
+ if (pastCeiling())
93
+ return finish('ceiling', rounds);
94
+ await tick(WRUN_FIRST_RUN_DEPTH_POLL_MS);
95
+ if (!input.isCurrent())
96
+ return finish('superseded', rounds);
97
+ }
98
+ continue;
99
+ }
100
+ // The camera settle reads as motion for a moment (the kScript first run retries the same way).
101
+ if (ask.reason === 'gesture-active' && gestureRetries < WARMUP_BACKFILL_GESTURE_RETRY_LIMIT) {
102
+ gestureRetries += 1;
103
+ await tick(WARMUP_BACKFILL_GESTURE_RETRY_MS);
104
+ continue;
105
+ }
106
+ return finish(ask.reason, rounds);
107
+ }
108
+ }
109
+ catch (error) {
110
+ wrunChartHostEnv().diagnostics.debug('local-kscript-warmup-backfill-error', {
111
+ chartIndex: input.chartIndex,
112
+ indicatorId: input.indicatorId,
113
+ ...ring,
114
+ message: error instanceof Error ? error.message : String(error),
115
+ });
116
+ return 'read-failed';
117
+ }
118
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Which wrun overlays read which gate plane: per overlay, its chart and the planes its latest full run's lanes read
3
+ * (wrun-options-stop.util `wrunLaneGatePlanes`, a lane sent or stopped alike). The run notes it; the recovery ladders
4
+ * (wrun-overlay-recovery.util `rerunWrunGatePlaneReaders`) read it on each edge of a plane's session latch
5
+ * (gate-session-latch.util): once another screen takes the session the overlays run again and their lanes say why they
6
+ * stopped, once this tab takes it back they run again and read.
7
+ *
8
+ * A leaf: type imports only, so the recovery ladders read it without the lane registries on their import graph.
9
+ */
10
+ import type { WrunRefusalGatePlane } from './wrun-refusal.util.js';
11
+ /** A full run read these gate planes; an empty set forgets the overlay. */
12
+ export declare function noteWrunGatePlanesRead(chartIndex: number, indicatorId: string, planes: Iterable<WrunRefusalGatePlane>): void;
13
+ /** A full run stopped on this plane (a chain its plan stopped before the lanes were noted, or a hold): the overlay
14
+ * reads it too, beside what the run noted, so the take-back runs it again. */
15
+ export declare function noteWrunGatePlaneStopped(chartIndex: number, indicatorId: string, plane: WrunRefusalGatePlane): void;
16
+ /** The overlays whose latest full run read the plane, with their charts. */
17
+ export declare function wrunGatePlaneReaders(plane: WrunRefusalGatePlane): Array<{
18
+ indicatorId: string;
19
+ chartIndex: number;
20
+ }>;
21
+ /** The overlay left (a teardown, a suspend): it reads no plane until its next full run. */
22
+ export declare function forgetWrunGatePlaneReader(indicatorId: string): void;
23
+ /** Test hook. */
24
+ export declare function __resetWrunGatePlaneReadersForTests(): void;
@@ -0,0 +1,31 @@
1
+ const readers = new Map();
2
+ /** A full run read these gate planes; an empty set forgets the overlay. */
3
+ export function noteWrunGatePlanesRead(chartIndex, indicatorId, planes) {
4
+ const read = new Set(planes);
5
+ if (read.size === 0)
6
+ readers.delete(indicatorId);
7
+ else
8
+ readers.set(indicatorId, { chartIndex, planes: read });
9
+ }
10
+ /** A full run stopped on this plane (a chain its plan stopped before the lanes were noted, or a hold): the overlay
11
+ * reads it too, beside what the run noted, so the take-back runs it again. */
12
+ export function noteWrunGatePlaneStopped(chartIndex, indicatorId, plane) {
13
+ const known = readers.get(indicatorId);
14
+ const planes = new Set(known !== undefined && known.chartIndex === chartIndex ? known.planes : []);
15
+ planes.add(plane);
16
+ readers.set(indicatorId, { chartIndex, planes });
17
+ }
18
+ /** The overlays whose latest full run read the plane, with their charts. */
19
+ export function wrunGatePlaneReaders(plane) {
20
+ return [...readers]
21
+ .filter(([, reader]) => reader.planes.has(plane))
22
+ .map(([indicatorId, { chartIndex }]) => ({ indicatorId, chartIndex }));
23
+ }
24
+ /** The overlay left (a teardown, a suspend): it reads no plane until its next full run. */
25
+ export function forgetWrunGatePlaneReader(indicatorId) {
26
+ readers.delete(indicatorId);
27
+ }
28
+ /** Test hook. */
29
+ export function __resetWrunGatePlaneReadersForTests() {
30
+ readers.clear();
31
+ }
@@ -0,0 +1,32 @@
1
+ import type { WrunRunWindow } from './wrun-lifecycle.contract.js';
2
+ import type { WrunOverlayLiveContext } from './wrun-overlay-drivers.util.js';
3
+ import type { WrunLaneAcquisition } from './wrun-live-intake.util.js';
4
+ export interface WrunHeldLaneRows {
5
+ /** A copy of the session's buffer: the new session owns it. */
6
+ rows: unknown[];
7
+ /** The session's acquisition record (its payload, transport and lattice included). */
8
+ acquisition: WrunLaneAcquisition;
9
+ /** The session's coverage watermark for the lane, inherited by the new session. */
10
+ coveredThroughTs: number;
11
+ }
12
+ export interface WrunHeldLanes {
13
+ /** The held rows of `lane` when the session asked it as `payload` asks, else undefined. */
14
+ take(lane: string, payload: WrunLaneAcquisition): WrunHeldLaneRows | undefined;
15
+ }
16
+ export declare function planWrunHeldLanes(input: {
17
+ /** The overlay's live session before this run (the run's own `heldContext`). */
18
+ held: WrunOverlayLiveContext | undefined;
19
+ reason: string;
20
+ replay: boolean;
21
+ chartIndex: number;
22
+ fetchKey: string;
23
+ marketIdentity: string;
24
+ /** The run clock's interval (the run interval at another timeframe). */
25
+ intervalMs: number;
26
+ /** The window start this run asks its lanes from. */
27
+ fromTs: number;
28
+ window: WrunRunWindow | undefined;
29
+ /** The profile lattice this chart resolves now (resolveWrunVolumeProfileGrid): a profile held
30
+ * on another lattice is asked again. */
31
+ volumeProfileGrid?: number;
32
+ }): WrunHeldLanes | undefined;
@@ -0,0 +1,94 @@
1
+ /**
2
+ * The held lanes: a settings save computes over the source rows its overlay's live session already
3
+ * holds, the way a held run-interval session's bars are reused (wrun-run-interval-session.util
4
+ * planWrunRunIntervalRows). The session's lane buffers are the last full run's fetched rows,
5
+ * extended by the push intake's folds and corrected by the tick's reconcile, so they are the rows a
6
+ * switch flip or a colour pick reads; asking them again is a refetch of rows the chart already
7
+ * has. Field case 2026-10-06 (the Bar Statistics twin): every toggle re-asked open interest,
8
+ * liquidations, funding, the profile and the book once the source-row cache's poll-cycle
9
+ * freshness had run out (kscript-source-row-cache.util), 1.1 to 5.0 s from the click to the
10
+ * repaint, while the built-in recomputes over the data its engine holds.
11
+ *
12
+ * Only a settings save (`reason: 'settings'`) holds, and only a lane its session can serve as a
13
+ * fresh ask would: the same overlay lane on the same chart (its fetch key), the same market and
14
+ * clock, the whole loaded window on both sides with the session's lanes asked from the same start
15
+ * or earlier, a lane asked exactly the same way (its acquisition, the resolved chart words, the
16
+ * transport and the lattice aside), not degraded and carrying a coverage watermark. The new
17
+ * session inherits that watermark, so the reconcile right after the run still re-asks the tail.
18
+ * Every other lane, and every other run, fetches as before. Pure: the caller hands the previous
19
+ * session in.
20
+ */
21
+ import isEqual from 'lodash-es/isEqual.js';
22
+ import { isWrunTradesLegLane } from './wrun-trades-lane.util.js';
23
+ /** The lanes a session may hold, by the buffer each one fills: the row builder's history lanes,
24
+ * each one window ask the reconcile keeps current, and every trades leg lane (`tradeLegRows`, by
25
+ * its id: the id names the market, so a held leg is that market's own). The option-summary,
26
+ * chain, ETF flow and registry poll lanes keep their own asks. */
27
+ const HELD_LANE_ROWS = {
28
+ book: 'bookRows',
29
+ trades: 'buySellVolumeRows',
30
+ trades_usd: 'buySellVolumeUsdRows',
31
+ oi: 'openInterestRows',
32
+ volume_profile: 'volumeProfileRows',
33
+ trade_volume_by_size: 'tradeVolumeBySizeRows',
34
+ liquidations: 'liquidationRows',
35
+ funding: 'fundingRateRows',
36
+ tape: 'tapeRows',
37
+ };
38
+ /** Acquisition words that are not the lane's own ask: the chart words the chart's fetch resolves
39
+ * into the payload object in place (titan-charts dataFetch writes the chart's symbol, exchange and
40
+ * coin over the placeholders and stamps the interval, and the acquisition records that object),
41
+ * judged here by the market identity and the clock instead; and how the history was served, the
42
+ * book's transport (the packed worker or the plain lane) and the profile's lattice step. */
43
+ const NOT_THE_ASK = new Set([
44
+ 'symbol',
45
+ 'exchange',
46
+ 'coin',
47
+ 'interval',
48
+ 'preferPackedOrderbookWorker',
49
+ 'minimumBarHeight',
50
+ ]);
51
+ function askOf(acquisition) {
52
+ return Object.fromEntries(Object.entries(acquisition).filter(([word]) => !NOT_THE_ASK.has(word)));
53
+ }
54
+ export function planWrunHeldLanes(input) {
55
+ const { held } = input;
56
+ if (input.reason !== 'settings' || input.replay || held === undefined)
57
+ return undefined;
58
+ if (held.replay === true || held.liveSuspended)
59
+ return undefined;
60
+ if (held.chartIndex !== input.chartIndex || held.fetchKey !== input.fetchKey)
61
+ return undefined;
62
+ if (held.marketIdentity === undefined || held.marketIdentity !== input.marketIdentity)
63
+ return undefined;
64
+ if (held.intervalMs !== input.intervalMs)
65
+ return undefined;
66
+ if (input.window?.partial || held.window?.partial)
67
+ return undefined;
68
+ if (held.lanesFromTs === undefined || held.lanesFromTs > input.fromTs)
69
+ return undefined;
70
+ return {
71
+ take(lane, payload) {
72
+ const leg = isWrunTradesLegLane(lane);
73
+ if (!leg && !Object.hasOwn(HELD_LANE_ROWS, lane))
74
+ return undefined;
75
+ const buffer = leg ? held.tradeLegRows?.[lane] : held[HELD_LANE_ROWS[lane]];
76
+ const acquisition = held.acquisition[lane];
77
+ const coveredThroughTs = held.coveredThroughTs[lane];
78
+ if (!Array.isArray(buffer) || acquisition === undefined || coveredThroughTs === undefined)
79
+ return undefined;
80
+ if (held.degradedLanes?.has(lane))
81
+ return undefined;
82
+ if (!isEqual(askOf(acquisition), askOf(payload)))
83
+ return undefined;
84
+ if (lane === 'volume_profile' && acquisition.minimumBarHeight !== input.volumeProfileGrid)
85
+ return undefined;
86
+ // A tape bar the live fold capped, or one the intake's queue cap left short past repair, holds
87
+ // an incomplete row: asked again, never computed on.
88
+ if (lane === 'tape' && (held.tapeCappedBuckets?.size ?? 0) + (held.tapeLostBuckets?.size ?? 0) > 0) {
89
+ return undefined;
90
+ }
91
+ return { rows: [...buffer], acquisition, coveredThroughTs };
92
+ },
93
+ };
94
+ }
@@ -0,0 +1,2 @@
1
+ import type { VisibleTimeoutOptions } from '../common/visible-timeout.util.js';
2
+ export declare function wrunHostVisibleClock(): VisibleTimeoutOptions;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The visible clock a package deadline that counts on-screen time arms with (utility/common/visible-timeout.util.ts):
3
+ * the page's visibility and, beside it, the host's own suspension (`clock.watchHostSuspended`, contract 0.5.0). A host
4
+ * that parks its chart while the page stays visible (an app backgrounded, its chart tab blurred) pauses the deadline
5
+ * as a hidden page does, so a suspended app never runs a grace or a deadline out. A host that binds no watch adds
6
+ * nothing (web: its one suspension is the page's visibility, which the clock reads already).
7
+ *
8
+ * Every package call of `startVisibleTimeout` hands this as its options (tests/packages/wrun-chart-host/host-visible
9
+ * -clock.spec.ts holds the package to it). Read when a deadline arms, never at module load.
10
+ */
11
+ import { wrunChartHostEnv } from '../../host-env.js';
12
+ export function wrunHostVisibleClock() {
13
+ const clock = wrunChartHostEnv().clock;
14
+ if (typeof clock.watchHostSuspended !== 'function')
15
+ return {};
16
+ return { watchSuspended: (listener) => clock.watchHostSuspended(listener) };
17
+ }
@@ -0,0 +1,266 @@
1
+ /**
2
+ * Main-thread WRUN host: compiles a package's wasm (sha256-verified against
3
+ * the metadata pin when present), owns the sandbox worker, and runs packed
4
+ * series requests through it. One shared worker serves every dev overlay;
5
+ * requests are id-matched, and a request that outlives its timeout poisons
6
+ * the worker (terminate + respawn) so a spinning guest cannot wedge later
7
+ * runs.
8
+ *
9
+ * Isolation: a death of the shared worker (the run timeout, or an error
10
+ * event with a request in flight) rejects every pending request with
11
+ * `WrunWorkerPoisonError` naming the live sessions lost with it,
12
+ * quarantines the package that was running (its metadata id plus wasm
13
+ * digest) on the kScript self-heal ladder (30 s, doubling per repeat,
14
+ * capped at 5 min) so its next requests refuse at once with
15
+ * `WrunQuarantinedError` instead of killing the worker again, and throttles
16
+ * the respawn to one per window so several spinning packages (or a Retry
17
+ * that overrides the quarantine) cannot kill and respawn the worker on
18
+ * every request. A Retry or a settings save passes `overrideQuarantine`;
19
+ * its success clears the package's quarantine.
20
+ *
21
+ * wrun-3 (Indicator handles): the sheet's `handles` section and the other
22
+ * wrun-3 sheet fields are checked here before every run (the same place the
23
+ * string slots are), the request carries the declared handle defaults and
24
+ * the widened ABI, and the worker's answer carries the handle ledger's live
25
+ * set, which rides beside the rows it belongs to (`attachWrunHandles`) so
26
+ * the run-result adapter picks it up from the rows every integration route
27
+ * already hands it. The run's skipped draw calls (a call one bar's values
28
+ * could not carry, recorded instead of refusing the run) ride the same way
29
+ * (`attachWrunDrawSkips`), for the run's one warning row.
30
+ *
31
+ * wrun-3 (Indicator strategies): a sheet that declares `strategy` is read
32
+ * and resolved here before every run (the om validator's rules, then the
33
+ * shared host's resolver against the instance's params), the request
34
+ * carries the engine's declared config, the chart interval and the broker
35
+ * feed (the primary lane's OHLC per row, `strategyBars`, supplied by the
36
+ * overlay lanes from the chart's own candles), and the worker's answer
37
+ * carries the engine's StrategyOutput, which rides beside the rows
38
+ * (`attachWrunStrategy`) exactly like the handle set.
39
+ */
40
+ import type { WrunIndicatorMetadata, WrunOutputRow } from '../../interfaces/wrun-runtime.interface.js';
41
+ import { attachWrunLive, WrunLiveOrderError, wrunLiveOf } from '../../interfaces/wrun-runtime.interface.js';
42
+ import { type WrunInputRow } from './wrun-pack.util.js';
43
+ import { WrunWorkerPoisonError } from './wrun-registry-errors.util.js';
44
+ /** Sources the kit marks daemon-only (`WRUN_DAEMON_ONLY_SOURCES`, a Set of source names; a kit that
45
+ * supplies per-source disclosure wording is a record read by the same key) are computed by the daemon,
46
+ * which owns their dependencies: the first input declaring one refuses the browser run by name. The
47
+ * chart's own candle classes (`ohlcv`, `time`) are served off the chart's rows and never need the kit,
48
+ * so a plain package dispatches synchronously; any other declared class asks the kit (`warm` loads it
49
+ * ahead of the first add). The table is one of the two the run path still reads from the kit: the
50
+ * shared host entry does not export it. */
51
+ export declare function assertWrunBrowserSources(metadata: WrunIndicatorMetadata): Promise<void> | void;
52
+ /** One respawn of the shared worker per window (the kScript shared worker's
53
+ * `restartWithReseedBackoff` rule, sized for this host's 20 s run timeout
54
+ * instead of kScript's 90 s call timeouts): a second death inside the window
55
+ * after a respawn holds the next respawn until the window closes, and every
56
+ * request meanwhile fails fast with the death's poison error. The quarantine
57
+ * below bounds ONE package's deaths geometrically; this window bounds the
58
+ * worker's deaths whatever mix of packages (or overrides) causes them. */
59
+ export declare const WRUN_WORKER_RESPAWN_WINDOW_MS = 60000;
60
+ /** How many compiled modules the host keeps by wasm digest (compileModule). Every package version, draft Run
61
+ * and REPL compile mints a digest, and a compiled module is mostly native memory the heap never shows. */
62
+ export declare const WRUN_MODULE_CACHE_CAPACITY = 16;
63
+ /** Why the shared worker died: the run timeout, or the Worker's error event (the worker factory's death test). */
64
+ export type WrunHostDeathReason = WrunWorkerPoisonError['reason'];
65
+ /** A package the host refuses to dispatch until `until` (epoch ms): the one
66
+ * running when the worker died. `strikes` counts consecutive deaths of the
67
+ * same package on the current ladder (hold = `localEngineSelfHealDelayMs`). */
68
+ export interface WrunHostQuarantine {
69
+ key: string;
70
+ until: number;
71
+ reason: WrunHostDeathReason;
72
+ strikes: number;
73
+ }
74
+ /** The quarantine key of a package: its metadata id plus the wasm digest the
75
+ * metadata pins, so a republished build (new digest) starts clean while every
76
+ * overlay of the same build shares one hold (two charts, two instances: a
77
+ * per-overlay key would let the second instance spin the worker again). An
78
+ * unpinned sheet (dev loader, REPL) keys by id alone. */
79
+ export declare function wrunHostQuarantineKey(metadata: Pick<WrunIndicatorMetadata, 'id' | 'wasm_sha256'>): string;
80
+ /** One bar of the broker feed: the primary lane's candle for an input row. */
81
+ export interface WrunStrategyBarInput {
82
+ open: number;
83
+ high: number;
84
+ low: number;
85
+ close: number;
86
+ }
87
+ /** The strategy half of a run the overlay lanes supply for a strategy
88
+ * package (contract section 2, "the broker feed"): the primary lane's OHLC
89
+ * per input row (aligned to `rows`, index for index), the chart interval
90
+ * (annualized stats) and the package display name (`declared.title` on
91
+ * the wire). Ignored for a sheet that declares no `strategy`. */
92
+ export interface WrunStrategyRunInput {
93
+ bars: ReadonlyArray<WrunStrategyBarInput>;
94
+ intervalMs?: number;
95
+ title?: string;
96
+ }
97
+ /** A live tick was asked of a session the worker no longer holds (never
98
+ * started, disposed, dropped after a failed tick, or lost to a worker
99
+ * poison/respawn). Callers rebuild via a fresh full run instead of treating
100
+ * this as a compute error. */
101
+ export declare class WrunLiveSessionLostError extends Error {
102
+ constructor(message: string);
103
+ }
104
+ /** A live tick's block was refused before evaluation because its rows run
105
+ * backwards against the worker session's watermark: the session survives,
106
+ * and the caller reseeds it from its buffers (the worker and the context
107
+ * disagree) instead of retrying the same block. The class is the one the
108
+ * ABI host throws inside the worker (`code: 'live-order'` on the wire). */
109
+ export { WrunLiveOrderError };
110
+ /** The live block accounting rides beside the rows (the registry lives with
111
+ * the wire types); re-exported here for the tick lane's reader. */
112
+ export { attachWrunLive, wrunLiveOf };
113
+ export declare class WrunBrowserHost {
114
+ private worker;
115
+ private pending;
116
+ private requestSeq;
117
+ /** Compiles by wasm digest, least recently used first (Map order: a hit moves its entry to the end). The cache
118
+ * only dedupes compiles and owns no module: a mounted overlay keeps the module it was handed (its record), and
119
+ * a live session keeps its instance in the worker (live ticks name the session, never a module), so an
120
+ * eviction stops neither. */
121
+ private moduleCache;
122
+ /** Live sessions the current worker holds (installed by an ok live-start,
123
+ * dropped by live-end, a sessionLost answer, or the worker's death). */
124
+ private liveSessionKeys;
125
+ /** The epoch (live context generation) of the newest live-start dispatched per session key: an end naming
126
+ * another epoch leaves the key's bookkeeping to that newer start. */
127
+ private liveStartEpochs;
128
+ /** Quarantined packages by key; a record outlives its hold by the ladder's
129
+ * reset grace so a repeat death escalates (pruned on the next death). */
130
+ private quarantines;
131
+ private lastDeath;
132
+ /** When the worker was last spawned AFTER a death (a respawn); null until
133
+ * the first death, so the first spawn ever never opens a window. */
134
+ private lastRespawnAt;
135
+ private respawnHeldUntil;
136
+ /** Spin the sandbox worker and load the shared host (the compile's module
137
+ * rewrite, the packer, the strategy resolver) and the authoring kit (the
138
+ * run path's two kit tables, the daemon-only sources and the token
139
+ * names) ahead of the first add (the Indicators tab opening is the
140
+ * signal), so the first package a reader mounts pays neither the worker
141
+ * spawn nor a module parse on its click. Idempotent; a load failure
142
+ * surfaces on the first compile or run as before, never here. A held
143
+ * respawn is not warmed around: the window exists to keep the worker
144
+ * down. */
145
+ warm(): void;
146
+ /** The active quarantine of a package, if its hold is still running. */
147
+ quarantineOf(metadata: Pick<WrunIndicatorMetadata, 'id' | 'wasm_sha256'>): WrunHostQuarantine | undefined;
148
+ /** Forget every quarantine and the respawn window (specs only). */
149
+ resetGuardsForTests(): void;
150
+ /** Compile (and cache) a package module. The cache key is the sha256 of
151
+ * the bytes, so identical bytes compile once whatever package name they
152
+ * arrive under. When the metadata pins `wasm_sha256`, a mismatch refuses
153
+ * before compilation; so does a memory the clamp refuses (a maximum or a
154
+ * starting size over the worker's memory limit, shared or 64-bit memory),
155
+ * and a memory declared with no maximum compiles with the limit as its
156
+ * maximum (clampWrunModuleMemory).
157
+ *
158
+ * The cache is an LRU of WRUN_MODULE_CACHE_CAPACITY compiled modules.
159
+ * Every consumer of a digest in flight shares its one compile, and a
160
+ * compile in flight is never evicted; eviction drops compiled entries
161
+ * only, least recently used first, so the cache passes the capacity
162
+ * only while more compiles than that are in flight. A failed compile is
163
+ * not cached: its entry leaves before its consumers see the failure, and
164
+ * the next request compiles again. */
165
+ compileModule(wasmBytes: ArrayBuffer, metadata: WrunIndicatorMetadata): Promise<WebAssembly.Module>;
166
+ /** Evict compiled entries, least recently used first, until the cache is back at its capacity (a compile
167
+ * in flight stays: its consumers share it). */
168
+ private trimModuleCache;
169
+ runSeries(input: {
170
+ module: WebAssembly.Module;
171
+ metadata: WrunIndicatorMetadata;
172
+ rows: readonly WrunInputRow[];
173
+ initArgs: readonly number[];
174
+ /** wrun-5: the typed text settings' bytes by init slot (wrunTextParamsForRun). */
175
+ textParams?: Readonly<Record<number, Uint8Array>>;
176
+ mode?: 'historical' | 'live';
177
+ /** A strategy package's broker feed, interval and title (required
178
+ * exactly when the sheet declares `strategy`). */
179
+ strategy?: WrunStrategyRunInput;
180
+ /** Dispatch although the package is quarantined (a Retry, a settings
181
+ * save); a success clears the quarantine. */
182
+ overrideQuarantine?: boolean;
183
+ }): Promise<WrunOutputRow[]>;
184
+ /** Full run that also opens (or replaces) a live forming-bar session under
185
+ * `sessionKey` in the worker: the guest stays instantiated, so later
186
+ * `runLiveRows` ticks execute only the new/revised rows. `epoch` is the
187
+ * live context generation opening the session: the worker installs the
188
+ * session only while that epoch is still the newest it has seen for the
189
+ * key (see the worker's ownership rule). */
190
+ startLiveSeries(input: {
191
+ sessionKey: string;
192
+ module: WebAssembly.Module;
193
+ metadata: WrunIndicatorMetadata;
194
+ rows: readonly WrunInputRow[];
195
+ initArgs: readonly number[];
196
+ /** wrun-5: the typed text settings' bytes by init slot; they ride the session like initArgs. */
197
+ textParams?: Readonly<Record<number, Uint8Array>>;
198
+ strategy?: WrunStrategyRunInput;
199
+ epoch?: number;
200
+ /** Dispatch although the package is quarantined; a success clears it. */
201
+ overrideQuarantine?: boolean;
202
+ }): Promise<WrunOutputRow[]>;
203
+ /** One live tick: evaluate only `rows` (the new/revised forming-bar rows)
204
+ * on the open session. Rejects with WrunLiveSessionLostError when the
205
+ * worker no longer holds the session. A wrun-3 session answers the
206
+ * handle ledger's FULL live set with every tick (the wire replaces the
207
+ * drawing set wholesale), attached to the returned rows; a strategy
208
+ * session likewise answers the whole StrategyOutput after the tick (the
209
+ * broker config rides the session, only the rows' broker feed ships). */
210
+ runLiveRows(input: {
211
+ sessionKey: string;
212
+ metadata: WrunIndicatorMetadata;
213
+ rows: readonly WrunInputRow[];
214
+ strategy?: WrunStrategyRunInput;
215
+ /** Dispatch although the package is quarantined; a success clears it. */
216
+ overrideQuarantine?: boolean;
217
+ }): Promise<WrunOutputRow[]>;
218
+ /** Dispose one live session. Fire-and-forget: nothing to await, and a
219
+ * worker that is not running holds no sessions to dispose. With `epoch`
220
+ * (the live context generation that opened it), only that generation's
221
+ * session and start: the worker judges, it knows which epoch installed
222
+ * (a run ending what it opened never ends a newer owner's session under
223
+ * the same key). Without, whatever the key holds (the teardown). */
224
+ endLiveSeries(sessionKey: string, epoch?: number): void;
225
+ destroy(): void;
226
+ /** Unpack the rows against the caller's axis and hang the handle set, the
227
+ * run's skipped draw calls, the strategy output and the live block
228
+ * accounting (when the worker answered them) on that rows array. */
229
+ private unpack;
230
+ /** The quarantine gate every request passes before any packing or worker
231
+ * hop: a quarantined package refuses at once (nothing posted, no worker
232
+ * spawned) unless the caller overrides. The refusal carries the death's
233
+ * reason and the package's strikes (the heal ladder reads them). Returns
234
+ * the lane the pending entry remembers. */
235
+ private admit;
236
+ private dispatch;
237
+ private ensureWorker;
238
+ /**
239
+ * The shared worker died: quarantine the package that was running (the
240
+ * timed-out request's, or the oldest in flight when the error event fired, the
241
+ * worker answers in dispatch order), terminate the worker, remember the
242
+ * death for the respawn window, and reject every pending request with the
243
+ * poison error naming the live sessions lost with the worker. Nothing in
244
+ * flight means nothing to quarantine (a worker that dies idle is only a
245
+ * death for the window). `message` is what every casualty reads; the
246
+ * timed-out request keeps its own deadline sentence. The death's context
247
+ * (cause, the culprit's package and session, the budget a timeout used up)
248
+ * is recorded here once, frozen, and rides every rejection of this death,
249
+ * the respawn hold's included, so a casualty can name who held the sandbox.
250
+ */
251
+ private poisonWorker;
252
+ /** Put (or keep) a package on the ladder: a death while its previous hold
253
+ * runs, or inside the reset grace after it, is a repeat and doubles the
254
+ * hold (capped); a later death starts over at the base hold. Records past
255
+ * the grace are forgotten here. */
256
+ private quarantine;
257
+ /** The rejection a request gets while the respawn is held: the last death's
258
+ * poison error (its casualties are still unrebuilt, no worker ran since,
259
+ * and it carries that death's context), marked as held. Null when a worker
260
+ * runs or the window has closed. */
261
+ private respawnHold;
262
+ private failAllPending;
263
+ }
264
+ export declare function getWrunBrowserHost(): WrunBrowserHost;
265
+ /** Clear the shared host's quarantines and respawn window between specs. */
266
+ export declare function __resetWrunBrowserHostGuardsForTests(): void;