@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,522 @@
1
+ /**
2
+ * Per-indicator kScript performance tracker.
3
+ *
4
+ * Records what is exactly attributable to one overlay on this device:
5
+ * - main-thread integration duration per applied update (bracketed by the
6
+ * overlay execution guard's measure calls),
7
+ * - main-thread render cost as ms of chart paint per second (read from
8
+ * titan's paint budget, or drained from its per-plot draw accounting, by
9
+ * the render-cost sampler), and
10
+ * - the counted volume of the run output it shipped (rows / series / bytes
11
+ * estimated from row shape, never by serializing the payload).
12
+ *
13
+ * Each signal keeps its own sliding-window median with cold-start exclusion
14
+ * and enter/exit hysteresis; the overlay is "slow" when EITHER signal
15
+ * convicts, and `slowCause` names which. The chart store surfaces the slow
16
+ * state as a legend diagnostic; the hard auto-pause stays owned by the
17
+ * overlay execution guard's breaker. Network/data-fetch time is deliberately
18
+ * never recorded here.
19
+ *
20
+ * Keys are overlay execution guard keys (`${chartIndex}:${indicatorId}`).
21
+ * This module must stay dependency-free (the guard imports it).
22
+ *
23
+ * Relationship to the gesture-apply cost EMA (gesture-apply-budget.util.ts):
24
+ * both observe main-thread apply cost per overlay, but they answer different
25
+ * questions with different lifecycles. The EMA is a fast-decaying pacing
26
+ * signal for the gesture scheduler (reset on gesture boundaries); this module
27
+ * is a windowed-median verdict with hysteresis for USER-FACING attribution,
28
+ * reset with the overlay's guard state. Merging them would couple scheduler
29
+ * pacing to legend UX; keep them separate on purpose.
30
+ *
31
+ * Samples pool live-tick applies with pan/historical applies (endMeasure has
32
+ * no stage tag). The median plus an enter threshold ABOVE the documented
33
+ * normal apply band (50-70 ms wake-herd merges, see GESTURE_APPLY_UNKNOWN_COST_MS)
34
+ * keeps burst pan applies from convicting a healthy overlay; per-stage
35
+ * sampling is a possible follow-up if field data shows false positives.
36
+ */
37
+ export const KSCRIPT_PERF_SLOW_ENTER_MEDIAN_MS = 80;
38
+ export const KSCRIPT_PERF_SLOW_EXIT_MEDIAN_MS = 50;
39
+ export const KSCRIPT_PERF_SAMPLE_WINDOW_MS = 60_000;
40
+ export const KSCRIPT_PERF_MIN_SAMPLES = 5;
41
+ /** A slow verdict may retire on fewer samples than it took to convict. */
42
+ export const KSCRIPT_PERF_EXIT_MIN_SAMPLES = 3;
43
+ export const KSCRIPT_PERF_COLD_START_SKIP = 2;
44
+ export const KSCRIPT_PERF_MAX_SAMPLES = 24;
45
+ /**
46
+ * The chart apply budget's window (D11, GUARDS-12): every LIVE apply sample
47
+ * past the cold start is also kept in its key's ledger for this long, so the
48
+ * shed ladder can sum the main-thread live apply time of a chart's scripts per
49
+ * second (kscriptChartApplyLoad). The median ring above keeps 24 samples of
50
+ * every kind; this ledger keeps every live apply of the window.
51
+ */
52
+ export const KSCRIPT_CHART_APPLY_WINDOW_MS = 10_000;
53
+ /** Backstop on one key's ledger: past it the oldest drop (an undercount, never an overcount). */
54
+ const KSCRIPT_CHART_APPLY_LEDGER_MAX = 256;
55
+ /**
56
+ * Render-cost thresholds, in ms of main-thread paint per second attributable
57
+ * to one indicator (a 1000 ms/s budget shared by everything on the page).
58
+ *
59
+ * Calibration from the two QA perf dumps that motivated the signal (per-drain
60
+ * sums over titan's per-plot draw accounting, normalized by drain spacing):
61
+ * - panning session, Liquidation Bands (8 deltaFillSpline plots):
62
+ * median 198.8 ms/s, p90 611.1, max 688.6 -> must convict.
63
+ * - same panning session, next-heaviest indicator: median 14.4 ms/s,
64
+ * max 38.0 -> must stay silent.
65
+ * - idle session, same script: median 7.8 ms/s, lone spike 73.9
66
+ * -> must stay silent.
67
+ * Enter at 100 ms/s sits 2x under the guilty median and 2.6x above the worst
68
+ * single innocent sample, so an innocent windowed median can never cross it.
69
+ *
70
+ * The exit threshold is wider than the apply signal's band because paint
71
+ * cost is pan-gated and bursty: the panning session contained a ~6 drain
72
+ * lull whose windowed median dipped to 46.3 ms/s before the storm resumed.
73
+ * Exiting there would flap the verdict and re-arm the toast mid-session, so
74
+ * exit sits BELOW inter-burst lull medians (46.3) and comfortably above
75
+ * genuine idle medians (7.8), which still retire the verdict promptly.
76
+ */
77
+ export const KSCRIPT_RENDER_SLOW_ENTER_MS_PER_SEC = 100;
78
+ export const KSCRIPT_RENDER_SLOW_EXIT_MS_PER_SEC = 30;
79
+ /**
80
+ * Display damping for the convicted paint rate. The chip communicates
81
+ * magnitude, not a live meter: re-rendering the legend for every median
82
+ * wiggle would rewrite Pinia diagnostics and force a titan legend refresh at
83
+ * drain cadence during the very pan storms being convicted. While convicted,
84
+ * the displayed rate is an anchor that re-anchors on a 2x WORSENING (the
85
+ * label must keep pace with a growing storm) but only on a 4x improvement:
86
+ * calibration lull medians dip 2-3x below the anchor without the episode
87
+ * ending, and a warning may briefly overstate but must not flap. Replaying
88
+ * the panning dump: 2 legend writes across the whole burst (conviction at
89
+ * ~140 ms, one re-anchor to ~330 ms).
90
+ */
91
+ export const KSCRIPT_RENDER_DISPLAY_REANCHOR_UP_RATIO = 2;
92
+ export const KSCRIPT_RENDER_DISPLAY_REANCHOR_DOWN_RATIO = 4;
93
+ const entries = new Map();
94
+ function getEntry(key) {
95
+ let entry = entries.get(key);
96
+ if (!entry) {
97
+ entry = {
98
+ samples: [],
99
+ applyLedger: [],
100
+ coldStartSkipsRemaining: KSCRIPT_PERF_COLD_START_SKIP,
101
+ renderSamples: [],
102
+ renderColdStartSkipsRemaining: KSCRIPT_PERF_COLD_START_SKIP,
103
+ renderSince: null,
104
+ volume: null,
105
+ level: 'healthy',
106
+ applySlow: false,
107
+ renderSlow: false,
108
+ lastSampleAt: null,
109
+ lastSlowMedianMs: null,
110
+ renderDisplayAnchorMsPerSec: null,
111
+ slowToastConsumed: false,
112
+ renderSlowToastConsumed: false,
113
+ };
114
+ entries.set(key, entry);
115
+ }
116
+ return entry;
117
+ }
118
+ /**
119
+ * One apply sample (the guard's measure, a wrun host build). `live`: the apply integrated a live tick (a local
120
+ * kScript's live update or its commit, a protected or hosted live frame, a wrun live tick). Every sample feeds the
121
+ * windowed median; only live ones also enter the chart's apply ledger (kscriptChartApplyLoad): a mount, a history
122
+ * page, a wake resync, a timeframe switch or a settings recompute is a one-off the chart sum must not pace.
123
+ */
124
+ export function recordKScriptPerfSample(key, ms, at = Date.now(), live = false) {
125
+ if (!Number.isFinite(ms) || ms < 0)
126
+ return;
127
+ const entry = getEntry(key);
128
+ entry.lastSampleAt = at;
129
+ // The first integrations after an add/reset legitimately pay one-off costs
130
+ // (full-history mount, cold caches); they must not classify the script.
131
+ if (entry.coldStartSkipsRemaining > 0) {
132
+ entry.coldStartSkipsRemaining -= 1;
133
+ return;
134
+ }
135
+ entry.samples.push({ at, ms });
136
+ if (entry.samples.length > KSCRIPT_PERF_MAX_SAMPLES) {
137
+ entry.samples.splice(0, entry.samples.length - KSCRIPT_PERF_MAX_SAMPLES);
138
+ }
139
+ if (!live)
140
+ return;
141
+ const ledger = entry.applyLedger;
142
+ ledger.push({ at, ms });
143
+ const floor = at - KSCRIPT_CHART_APPLY_WINDOW_MS;
144
+ let expired = 0;
145
+ while (expired < ledger.length && ledger[expired].at < floor)
146
+ expired += 1;
147
+ expired = Math.max(expired, ledger.length - KSCRIPT_CHART_APPLY_LEDGER_MAX);
148
+ if (expired > 0)
149
+ ledger.splice(0, expired);
150
+ }
151
+ /**
152
+ * The live apply load of one chart's keys (`includeKey` admits them, the
153
+ * ladder passes its paceable scripts) over the last
154
+ * KSCRIPT_CHART_APPLY_WINDOW_MS: the live applies this tracker sampled (past
155
+ * each key's cold start, outside a user settings burst), summed. The sum always divides by the whole window, so a window
156
+ * that is not full yet understates and never overstates. A key's reset drops
157
+ * its share at once (a step up the ladder starts it over).
158
+ */
159
+ export function kscriptChartApplyLoad(chartIndex, now = Date.now(), includeKey = () => true) {
160
+ const prefix = `${chartIndex}:`;
161
+ const floor = now - KSCRIPT_CHART_APPLY_WINDOW_MS;
162
+ const keys = [];
163
+ let total = 0;
164
+ for (const [key, entry] of entries) {
165
+ if (!key.startsWith(prefix) || !includeKey(key))
166
+ continue;
167
+ let ms = 0;
168
+ let applies = 0;
169
+ for (const sample of entry.applyLedger) {
170
+ if (sample.at < floor || sample.at > now)
171
+ continue;
172
+ ms += sample.ms;
173
+ applies += 1;
174
+ }
175
+ if (applies === 0)
176
+ continue;
177
+ keys.push({ key, ms, applies });
178
+ total += ms;
179
+ }
180
+ keys.sort((a, b) => b.ms - a.ms);
181
+ return { msPerSecond: total / (KSCRIPT_CHART_APPLY_WINDOW_MS / 1_000), keys };
182
+ }
183
+ /**
184
+ * One render sample, in ms of paint per second. `windowMs`: the rate is a mean over that span ending
185
+ * at `at` (the engine paint budget's rolling 10 s, paint-budget-arm.util); while that span reaches
186
+ * back before the entry's first render sample it still carries paint from before the add or the
187
+ * reset that started the entry (the mount, the previous shed rung's tier), so it is cold start too.
188
+ * Without it (a drained window) the count-only cold start below is the whole rule.
189
+ */
190
+ export function recordKScriptRenderCostSample(key, msPerSecond, at = Date.now(), windowMs) {
191
+ if (!Number.isFinite(msPerSecond) || msPerSecond < 0)
192
+ return;
193
+ const entry = getEntry(key);
194
+ entry.renderSince ??= at;
195
+ if (windowMs !== undefined && at - windowMs < entry.renderSince)
196
+ return;
197
+ // The first drains after an add/reset carry the full-history mount paint
198
+ // and cold-cache repaints; they must not classify the script.
199
+ if (entry.renderColdStartSkipsRemaining > 0) {
200
+ entry.renderColdStartSkipsRemaining -= 1;
201
+ return;
202
+ }
203
+ entry.renderSamples.push({ at, ms: msPerSecond });
204
+ if (entry.renderSamples.length > KSCRIPT_PERF_MAX_SAMPLES) {
205
+ entry.renderSamples.splice(0, entry.renderSamples.length - KSCRIPT_PERF_MAX_SAMPLES);
206
+ }
207
+ }
208
+ const EMPTY_FOLD_RESULT = Object.freeze({
209
+ recordedIndicatorIds: [],
210
+ unmatchedOwnerKeys: 0,
211
+ unmatchedOwnerMs: 0,
212
+ });
213
+ /**
214
+ * Fold one drained per-plot draw-cost snapshot into render-cost samples.
215
+ *
216
+ * Snapshot keys are titan draw-accounting keys whose first `:` segment is the
217
+ * owning overlay id. Titan's container-native apply path mounts kScript
218
+ * nested plots as `<indicatorId>:<plotKey>` (nestedPlotObjectId), so their
219
+ * draw-cost keys read `<indicatorId>:<plotKey>:<renderer>`; native overlays
220
+ * read `<id>:<renderer>`. Titan's non-container-native apply path
221
+ * (updateMetadataWithRunResult -> applyRunResult without containerNative)
222
+ * keeps RAW output keys (or generated ids) as nested ids, so its draw-cost
223
+ * keys carry no indicator prefix and match nothing here.
224
+ *
225
+ * That is why absence is sample-STARVATION, never a zero sample: an
226
+ * indicator whose keys are unprefixed still paints, and manufacturing zeros
227
+ * for it would actively retire an earned verdict. Starved verdicts decay
228
+ * through window expiry instead. The orphaned cost stays observable through
229
+ * the unmatched-owner counters (owners matching neither a kScript indicator
230
+ * nor any other known overlay id).
231
+ *
232
+ * `sampleWindowMs`: every value is a rate averaged over that span (the engine
233
+ * paint budget's rolling window, read with `elapsedMs` 1000), passed on to
234
+ * recordKScriptRenderCostSample's windowed cold start.
235
+ */
236
+ export function recordKScriptRenderCostFromSnapshot(chartIndex, snapshot, elapsedMs, indicatorIds, at = Date.now(), otherKnownOwnerIds = [], sampleWindowMs) {
237
+ if (!Number.isFinite(elapsedMs) || elapsedMs <= 0 || indicatorIds.length === 0)
238
+ return EMPTY_FOLD_RESULT;
239
+ const sums = new Map();
240
+ for (const [key, cost] of Object.entries(snapshot)) {
241
+ if (!cost || !Number.isFinite(cost.ms))
242
+ continue;
243
+ const separator = key.indexOf(':');
244
+ const ownerId = separator === -1 ? key : key.slice(0, separator);
245
+ sums.set(ownerId, (sums.get(ownerId) ?? 0) + cost.ms);
246
+ }
247
+ const perSecond = 1000 / elapsedMs;
248
+ const recordedIndicatorIds = [];
249
+ for (const indicatorId of indicatorIds) {
250
+ const summedMs = sums.get(indicatorId);
251
+ if (summedMs === undefined)
252
+ continue;
253
+ recordKScriptRenderCostSample(`${chartIndex}:${indicatorId}`, summedMs * perSecond, at, sampleWindowMs);
254
+ recordedIndicatorIds.push(indicatorId);
255
+ sums.delete(indicatorId);
256
+ }
257
+ let unmatchedOwnerKeys = 0;
258
+ let unmatchedOwnerMs = 0;
259
+ if (sums.size > 0) {
260
+ const known = new Set(otherKnownOwnerIds);
261
+ for (const [ownerId, summedMs] of sums) {
262
+ if (known.has(ownerId))
263
+ continue;
264
+ unmatchedOwnerKeys += 1;
265
+ unmatchedOwnerMs += summedMs;
266
+ }
267
+ }
268
+ return { recordedIndicatorIds, unmatchedOwnerKeys, unmatchedOwnerMs };
269
+ }
270
+ export function recordKScriptPerfVolume(key, volume) {
271
+ if (!volume)
272
+ return;
273
+ getEntry(key).volume = volume;
274
+ }
275
+ /**
276
+ * Merge the parts of a run's volume that no canonical result carries (the bars of the run
277
+ * window, the heatmap cells mounted) into the key's last recorded volume. A key with no volume
278
+ * yet gets a zero-row one, so an extra recorded before the run's own volume is never lost.
279
+ */
280
+ export function recordKScriptPerfVolumeExtras(key, extras) {
281
+ const entry = getEntry(key);
282
+ const base = entry.volume ?? { rows: 0, series: 0, bytesEstimate: 0 };
283
+ entry.volume = {
284
+ ...base,
285
+ ...(extras.bars !== undefined ? { bars: extras.bars } : {}),
286
+ ...(extras.cells !== undefined ? { cells: extras.cells } : {}),
287
+ };
288
+ }
289
+ function median(values) {
290
+ if (values.length === 0)
291
+ return null;
292
+ const sorted = [...values].sort((a, b) => a - b);
293
+ const mid = Math.floor(sorted.length / 2);
294
+ return sorted.length % 2 === 1 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
295
+ }
296
+ /**
297
+ * Windowed-median hysteresis shared by both signals: convict on
298
+ * MIN_SAMPLES of evidence over the enter threshold, retire on
299
+ * EXIT_MIN_SAMPLES at or under the exit threshold (a sparse cadence of cheap
300
+ * samples must not pin a stale verdict forever), and drop the verdict
301
+ * entirely when every sample has aged out of the window.
302
+ */
303
+ function evaluateSignal(samples, wasSlow, enterThreshold, exitThreshold, now) {
304
+ const windowStart = now - KSCRIPT_PERF_SAMPLE_WINDOW_MS;
305
+ const values = [];
306
+ for (const sample of samples) {
307
+ if (sample.at >= windowStart)
308
+ values.push(sample.ms);
309
+ }
310
+ const freshMedian = median(values);
311
+ const worst = values.length > 0 ? Math.max(...values) : null;
312
+ let slow = wasSlow;
313
+ if (values.length === 0) {
314
+ // Evidence expired entirely: nothing left to justify any verdict.
315
+ slow = false;
316
+ }
317
+ else if (!wasSlow) {
318
+ if (values.length >= KSCRIPT_PERF_MIN_SAMPLES && freshMedian > enterThreshold) {
319
+ slow = true;
320
+ }
321
+ }
322
+ else if (values.length >= KSCRIPT_PERF_EXIT_MIN_SAMPLES && freshMedian <= exitThreshold) {
323
+ slow = false;
324
+ }
325
+ return { slow, freshMedian, worst, count: values.length };
326
+ }
327
+ /**
328
+ * Sticky display value for a convicted signal: remember the number that
329
+ * justified the verdict so sparse windows keep rendering it instead of a
330
+ * contradictory cheap one, and fall back to it while in-window evidence is
331
+ * below the exit quorum.
332
+ */
333
+ function stickySlowValue(verdict, lastSlowValue) {
334
+ if (!verdict.slow)
335
+ return verdict.freshMedian;
336
+ return verdict.count < KSCRIPT_PERF_EXIT_MIN_SAMPLES ? lastSlowValue : verdict.freshMedian;
337
+ }
338
+ function updateLastSlowValue(verdict, lastSlowValue) {
339
+ if (!verdict.slow)
340
+ return null;
341
+ if (verdict.count >= KSCRIPT_PERF_MIN_SAMPLES || lastSlowValue === null)
342
+ return verdict.freshMedian;
343
+ return lastSlowValue;
344
+ }
345
+ /**
346
+ * Damped render display anchor: set at conviction, re-anchored on a 2x
347
+ * worsening or a 4x improvement of the windowed median (with exit quorum),
348
+ * dropped on recovery. Keeps the legend text stable at drain cadence.
349
+ */
350
+ function updateRenderDisplayAnchor(verdict, anchor) {
351
+ if (!verdict.slow)
352
+ return null;
353
+ if (anchor === null)
354
+ return verdict.freshMedian;
355
+ if (verdict.count >= KSCRIPT_PERF_EXIT_MIN_SAMPLES && verdict.freshMedian !== null) {
356
+ if (verdict.freshMedian >= anchor * KSCRIPT_RENDER_DISPLAY_REANCHOR_UP_RATIO ||
357
+ verdict.freshMedian <= anchor / KSCRIPT_RENDER_DISPLAY_REANCHOR_DOWN_RATIO) {
358
+ return verdict.freshMedian;
359
+ }
360
+ }
361
+ return anchor;
362
+ }
363
+ export function kscriptPerfStatsFor(key, now = Date.now()) {
364
+ const entry = entries.get(key);
365
+ if (!entry) {
366
+ return {
367
+ level: 'healthy',
368
+ transitioned: false,
369
+ slowCause: null,
370
+ medianMs: null,
371
+ worstMs: null,
372
+ sampleCount: 0,
373
+ renderMsPerSecond: null,
374
+ renderFreshMsPerSecond: null,
375
+ renderSampleCount: 0,
376
+ volume: null,
377
+ lastSampleAt: null,
378
+ };
379
+ }
380
+ const apply = evaluateSignal(entry.samples, entry.applySlow, KSCRIPT_PERF_SLOW_ENTER_MEDIAN_MS, KSCRIPT_PERF_SLOW_EXIT_MEDIAN_MS, now);
381
+ const render = evaluateSignal(entry.renderSamples, entry.renderSlow, KSCRIPT_RENDER_SLOW_ENTER_MS_PER_SEC, KSCRIPT_RENDER_SLOW_EXIT_MS_PER_SEC, now);
382
+ entry.applySlow = apply.slow;
383
+ entry.renderSlow = render.slow;
384
+ entry.lastSlowMedianMs = updateLastSlowValue(apply, entry.lastSlowMedianMs);
385
+ entry.renderDisplayAnchorMsPerSec = updateRenderDisplayAnchor(render, entry.renderDisplayAnchorMsPerSec);
386
+ const level = apply.slow || render.slow ? 'slow' : 'healthy';
387
+ const transitioned = level !== entry.level;
388
+ entry.level = level;
389
+ if (level === 'healthy') {
390
+ // Only the apply latch re-arms per episode; the render latch is
391
+ // per-mount (see the PerfEntry field docs).
392
+ entry.slowToastConsumed = false;
393
+ }
394
+ const slowCause = apply.slow && render.slow ? 'both' : apply.slow ? 'apply' : render.slow ? 'render' : null;
395
+ return {
396
+ level,
397
+ transitioned,
398
+ slowCause,
399
+ medianMs: stickySlowValue(apply, entry.lastSlowMedianMs),
400
+ worstMs: apply.worst,
401
+ sampleCount: apply.count,
402
+ renderMsPerSecond: render.slow ? entry.renderDisplayAnchorMsPerSec : render.freshMedian,
403
+ renderFreshMsPerSecond: render.freshMedian,
404
+ renderSampleCount: render.count,
405
+ volume: entry.volume,
406
+ lastSampleAt: entry.lastSampleAt,
407
+ };
408
+ }
409
+ /**
410
+ * Warning-toast gate, owned here so every tracker reset path also resets the
411
+ * latches. Two latches stack:
412
+ * - the EPISODE latch (slowToastConsumed) grants at most one toast per slow
413
+ * episode regardless of which signals convict, re-armed on recovery;
414
+ * - the MOUNT latch (renderSlowToastConsumed) additionally suppresses
415
+ * render-only re-convictions for the overlay's whole mount: 1 Hz sampling
416
+ * recovers on every pan/idle boundary, so an episodic latch alone would
417
+ * re-toast ordinary panning every couple of minutes. Only a tracker reset
418
+ * (remove, resume, chart teardown) re-arms it.
419
+ * An apply conviction is always new information and only defers to the
420
+ * episode latch, keeping shipped apply behavior unchanged.
421
+ */
422
+ export function consumeKScriptPerfSlowToastGate(key) {
423
+ const entry = entries.get(key);
424
+ if (!entry || entry.level !== 'slow' || entry.slowToastConsumed)
425
+ return false;
426
+ if (!entry.applySlow && entry.renderSlowToastConsumed)
427
+ return false;
428
+ entry.slowToastConsumed = true;
429
+ if (entry.renderSlow)
430
+ entry.renderSlowToastConsumed = true;
431
+ return true;
432
+ }
433
+ export function resetKScriptPerfTracking(key) {
434
+ entries.delete(key);
435
+ }
436
+ /** Guard keys are `${chartIndex}:${indicatorId}`; the trailing ':' keeps chart 1 from matching chart 10. */
437
+ export function resetKScriptPerfTrackingForChart(chartIndex) {
438
+ const prefix = `${chartIndex}:`;
439
+ for (const key of Array.from(entries.keys())) {
440
+ if (key.startsWith(prefix))
441
+ entries.delete(key);
442
+ }
443
+ }
444
+ export function resetAllKScriptPerfTracking() {
445
+ entries.clear();
446
+ }
447
+ /**
448
+ * Counted volume of a run result's plot outputs. Reads array lengths and one
449
+ * sample row per output; never serializes. Bytes assume 8 bytes per value,
450
+ * which is the right order of magnitude for numeric plot rows crossing the
451
+ * worker boundary. `bars` is the run window's bar count: the result's own
452
+ * count (`barCount`, `bars`), else its timeline (`combinedTimes`), else its
453
+ * longest plot output (one row per bar). A canvas-only result (a browser-run
454
+ * Indicator's heatmaps, profiles and matrices ride `childOverlays`, never
455
+ * `outputs`) is measured too, with no plot rows; only a result with nothing
456
+ * to measure at all answers null, so a failed run's summary never replaces
457
+ * the last good volume.
458
+ */
459
+ export function measureKScriptRunResultVolume(runResult) {
460
+ if (!runResult || typeof runResult !== 'object')
461
+ return null;
462
+ const result = runResult;
463
+ const outputs = result.outputs && typeof result.outputs === 'object' ? result.outputs : {};
464
+ let rows = 0;
465
+ let series = 0;
466
+ let values = 0;
467
+ let longest = 0;
468
+ for (const output of Object.values(outputs)) {
469
+ if (!output || typeof output !== 'object')
470
+ continue;
471
+ const data = output.data;
472
+ if (!Array.isArray(data))
473
+ continue;
474
+ series += 1;
475
+ rows += data.length;
476
+ longest = Math.max(longest, data.length);
477
+ const sampleRow = data.find((row) => Array.isArray(row));
478
+ values += data.length * (sampleRow ? sampleRow.length : 2);
479
+ }
480
+ const countOf = (value) => typeof value === 'number' && Number.isFinite(value) && value >= 0 ? Math.floor(value) : undefined;
481
+ const bars = countOf(result.barCount) ??
482
+ countOf(result.bars) ??
483
+ (Array.isArray(result.combinedTimes) ? result.combinedTimes.length : undefined) ??
484
+ (series > 0 ? longest : undefined);
485
+ const canvases = Array.isArray(result.childOverlays) && result.childOverlays.length > 0;
486
+ if (series === 0 && !canvases && bars === undefined)
487
+ return null;
488
+ return { rows, series, bytesEstimate: values * 8, ...(bars !== undefined ? { bars } : {}) };
489
+ }
490
+ function formatBytesEstimate(bytes) {
491
+ if (bytes >= 1_048_576)
492
+ return `${(bytes / 1_048_576).toFixed(1)} MB`;
493
+ if (bytes >= 1_024)
494
+ return `${Math.round(bytes / 1_024)} KB`;
495
+ return `${bytes} B`;
496
+ }
497
+ /** "~240 ms" style bucket so legend text stays stable between minor median moves. */
498
+ export function formatKScriptPerfMedian(medianMs) {
499
+ return `~${Math.max(10, Math.round(medianMs / 10) * 10)} ms`;
500
+ }
501
+ /** Same "~200 ms" bucketing for the paint-per-second rate. */
502
+ export function formatKScriptPerfRenderRate(msPerSecond) {
503
+ return formatKScriptPerfMedian(msPerSecond);
504
+ }
505
+ /**
506
+ * Rates under this round to noise; the summary only quotes paint cost once it
507
+ * is a meaningful share of the 1000 ms/s budget (convictions sit at 100+).
508
+ */
509
+ const KSCRIPT_PERF_SUMMARY_RENDER_FLOOR_MS_PER_SEC = 10;
510
+ export function formatKScriptPerfSummary(stats) {
511
+ const parts = [];
512
+ if (stats.medianMs !== null)
513
+ parts.push(`${formatKScriptPerfMedian(stats.medianMs)} per update (median)`);
514
+ if (stats.renderMsPerSecond !== null && stats.renderMsPerSecond >= KSCRIPT_PERF_SUMMARY_RENDER_FLOOR_MS_PER_SEC) {
515
+ parts.push(`${formatKScriptPerfRenderRate(stats.renderMsPerSecond)} of chart paint per second (median)`);
516
+ }
517
+ if (stats.volume) {
518
+ parts.push(`${stats.volume.series} series`);
519
+ parts.push(`${stats.volume.rows.toLocaleString()} rows (${formatBytesEstimate(stats.volume.bytesEstimate)}) per refresh`);
520
+ }
521
+ return parts.join(', ');
522
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Run-interval projection: the adapter stage that shows a run-interval overlay on its chart
3
+ * (HTF-NATIVE-PLAN.md section 3.2). A built-in whose `timeframe` input is coarser than its chart
4
+ * runs its engine at that interval (indicator-run-interval.util.ts), so its run result carries one
5
+ * row per run bar: one per hour on a 5m chart. Mounted as is, the adapter NaN-pads every chart bar
6
+ * between two hourly rows (isolated dots) and the legend reads 11 bars of 12 as empty. This stage
7
+ * rewrites the result onto the chart's bars before the rest of the preparation sees it:
8
+ *
9
+ * - plots, bgcolor and barcolor: one row per chart bar, carrying the run bar that chart bar shows
10
+ * (projectRunRowsOntoChart: wait for close on shows the last run bar that closed before it; off
11
+ * also shows the forming run bar on the chart bars inside its own bucket);
12
+ * - markers, labels, shapes and ranges: once, on the first chart bar that shows their run bar;
13
+ * - drawing and range anchors: where their run bar's value first shows (projectRunTimeOntoChart);
14
+ * a time past the newest run bar is no run bar (a zone drawn ahead of the last bar) and keeps its
15
+ * distance from it, one run bar later like every run bar once wait for close shows the newest one
16
+ * at its close on the chart (aheadAt). A line, polyline or box shown entirely before the chart's
17
+ * first bar leaves (with the line fills that shade it); a line or polyline crossing that bar
18
+ * starts on it at the price where it crosses, rather than folding an end onto it at its own price;
19
+ * - `combinedTimes`, `createdBar` and `mutatedBar`: the chart bars the projection covers.
20
+ *
21
+ * The run's own rows bound the projection: it starts at the first chart bar that shows one of them
22
+ * and stops before the chart bars the run bar after its newest one would own, so a tail-only live
23
+ * result or a windowed replay rewrites only the chart bars it computed (the live replace and the
24
+ * partial-replay merge keep the mounted rows outside them).
25
+ *
26
+ * A row a forward display offset stamps past the engine's newest bar (a wrun output's
27
+ * `displacement_bars`) is no run bar: it bounds nothing and keeps its distance past the chart's last
28
+ * bar like a drawing anchor, the way a chart at the run interval draws it ahead (aheadFromOf).
29
+ *
30
+ * Every run bar's open and close is read by runBarSpan: `[stamp, stamp + runMs)`, or the session's
31
+ * on the CME session lattice (OverlayRunInterval.sessionLattice, the wrun twins on a CME chart),
32
+ * where a 1D or 1W bar is stamped after its own evening open and a session gap holds no run bar.
33
+ */
34
+ import { type OverlayRunInterval } from './indicator-run-interval.util.js';
35
+ /** What the projection reads of a run's stamp. */
36
+ type ProjectionRunInterval = Pick<OverlayRunInterval, 'intervalMs' | 'waitForClose' | 'sessionLattice'>;
37
+ /**
38
+ * The run result of an overlay whose engine ran at `runInterval`, projected onto the chart bars at
39
+ * `chartTimes` (ascending open times). Returns `runResult` itself when it carries nothing on a time
40
+ * axis; never mutates it.
41
+ */
42
+ export declare function projectKScriptRunResultOntoChartBars(runResult: unknown, chartTimes: readonly number[], runInterval: ProjectionRunInterval): unknown;
43
+ export {};