@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,557 @@
1
+ /**
2
+ * A wrun table's default place: clear of the chart's own chrome.
3
+ *
4
+ * TitanCharts anchors a plotTable 8 CSS px in from its corner (TextPlot
5
+ * `Table`), and on the price pane that is where the chart keeps chrome of its
6
+ * own: the legend stack at the top left (the symbol row, OHLC, Vol, the
7
+ * "N indicators" summary and one row per indicator, so it grows with every
8
+ * indicator), the pane action bar at the top right (the hover icons, 8 px
9
+ * down and 26 px tall, stepped down by the compare strip), and the High/Low
10
+ * price-axis tags, whose flags reach into the plot from the main price
11
+ * scale's side. A wrun table at one of those corners that declares no
12
+ * `offset` gets the engine's own `offset` key set to clear them
13
+ * (`wrunTableChromeOffset`):
14
+ *
15
+ * - top_left: below the measured legend stack;
16
+ * - top_right: below the action bar, on a multichart cell or a small screen
17
+ * too: the corner is the table's place, and the legend makes room for it
18
+ * (below);
19
+ * - while the chart draws the tags, the two corners on the scale's side step
20
+ * away from them: left of the tags at top_right and bottom_right with the
21
+ * scale on the right (the default), right of them at top_left and
22
+ * bottom_left with the scale on the left.
23
+ *
24
+ * The centre and middle anchors keep the engine's corner. A
25
+ * declared `offset` is the author's own placement and REPLACES the default
26
+ * (it is never added to it), the rule the meter's clearance of the same tags
27
+ * follows (wrun-run-result.util `placeMeterClearOfAxisTags`): `offset: [0, 0]`
28
+ * keeps the corner. A default never pushes a table's top past the middle of
29
+ * the pane, so a legend taller than that overlaps the table instead of
30
+ * hiding it.
31
+ *
32
+ * The legend makes room for a top_right table (QA 230, 273). Titan paints a
33
+ * table on its HUD canvas, under the DOM legend, whose veil (the chart
34
+ * background at 72% behind the rows, fading out 120 px past the widest one)
35
+ * and the rows' text halo shade the table's words wherever they reach it: on
36
+ * a narrow pane the rows run up to 70% of the plot. While the chart draws a
37
+ * top_right wrun table, the price pane's legend section carries that table's
38
+ * left edge less the gap, in plot px, as WRUN_TABLE_LEGEND_EDGE_VAR
39
+ * (`wrunTableLegendEdge`: the leftmost such table, a declared offset read, a
40
+ * table below the legend or hidden left out), and ChartArea's rules end the
41
+ * veil there and fold a desktop value row behind the engine's +N chip before
42
+ * it. The engine folds a row that shrinks by itself but unfolds one only when
43
+ * its section widens, so an edge that moves right or lifts asks every legend
44
+ * row for its full refit (`refreshRollingNumberLayout`, as the engine's own
45
+ * letter-spacing sync does). With no such table nothing is written and the
46
+ * legend is as it was.
47
+ *
48
+ * Only the two wrun lanes place through here (the full run and the live tick,
49
+ * wrun-overlay-run.util `placeWrunResultTables`); a kScript plotTable never
50
+ * does, so it draws exactly as before
51
+ * (tests/utility/wrun/wrun-table-chrome.kscript-unchanged.spec.ts).
52
+ *
53
+ * The chrome is measured where the chart knows it: the legend rows (how far
54
+ * down they reach), the plot's size and the action bar from their boxes in
55
+ * the DOM (the legend selectors the drawing safe area measures,
56
+ * kscript-drawing-safe-area.util), the tags from titan's own main settings
57
+ * (`showHighLowLabel`, which every axis toggle and tape mode write). One
58
+ * tracker per chart caches the boxes, so a live tick never forces a layout,
59
+ * and follows them: rows resizing, coming and going, the legend section's
60
+ * padding and size, the bar. When that moves a mounted table, the
61
+ * overlay's last result is placed again and handed back to its lane's
62
+ * re-apply (the adapter's mounted-row refresh), so a table follows the legend
63
+ * on a chart without ticks too; the legend edge follows the plot's width.
64
+ */
65
+ import { legendPaneOf, legendRowsOf, measureLegendBox } from '../chart/kscript-drawing-safe-area.util.js';
66
+ /** Air between the chrome and the table. */
67
+ export const WRUN_TABLE_CHROME_GAP_PX = 8;
68
+ /** The engine's own inset from the anchored corner (TextPlot `Table`). */
69
+ export const WRUN_TABLE_ENGINE_INSET_PX = 8;
70
+ /** The High/Low tags reach about 46 px into the plot (arrow included): the
71
+ * same clearance plus air the meter keeps from them
72
+ * (`WRUN_METER_AXIS_TAG_CLEARANCE_PX`, pinned equal by the spec). The tag is
73
+ * widest on a classic pane; compact panes only shrink its font. */
74
+ export const WRUN_TABLE_AXIS_TAG_CLEARANCE_PX = 56;
75
+ /** The custom property on the price pane's legend section that holds where
76
+ * the legend stops for a top_right table (plot px; ChartArea's veil and
77
+ * value-row rules read it). Unset = no such table. */
78
+ export const WRUN_TABLE_LEGEND_EDGE_VAR = '--wrun-table-legend-edge';
79
+ /** The anchors with chart chrome to clear (bottom_left once the price scale sits on the left). */
80
+ const CHROME_CORNERS = new Set(['top_left', 'top_right', 'bottom_left', 'bottom_right']);
81
+ /** The engine's table defaults (TextPlot `Table`): a 12 px font, 8 px of padding each side of a cell. */
82
+ const TABLE_FONT_SIZE_PX = 12;
83
+ const TABLE_CELL_PADDING_PX = 8;
84
+ /** About 0.6 em a glyph: the label estimate the drawing safe area uses (titan measures at paint time). */
85
+ const TABLE_GLYPH_EM = 0.6;
86
+ /**
87
+ * The default `offset` of a table anchored at `position` (engine semantics:
88
+ * a negative x moves left, a positive y moves down), or undefined when that
89
+ * corner has nothing to clear.
90
+ */
91
+ export function wrunTableChromeOffset(position, chrome) {
92
+ const below = (edge) => {
93
+ if (!(edge > 0))
94
+ return 0;
95
+ const dy = Math.max(0, Math.round(edge + WRUN_TABLE_CHROME_GAP_PX - WRUN_TABLE_ENGINE_INSET_PX));
96
+ return chrome.paneHeight > 0 ? Math.min(dy, Math.floor(chrome.paneHeight / 2)) : dy;
97
+ };
98
+ // The tags hang into the plot from the main price scale's side: a table
99
+ // anchored on that side steps away from them, one on the other side keeps it.
100
+ const tags = chrome.highLowTags ? WRUN_TABLE_AXIS_TAG_CLEARANCE_PX : 0;
101
+ const scaleOnLeft = chrome.priceScaleSide === 'left';
102
+ const leftAnchorDx = scaleOnLeft ? tags : 0;
103
+ const rightAnchorDx = scaleOnLeft || tags === 0 ? 0 : -tags;
104
+ let dx = 0;
105
+ let dy = 0;
106
+ if (position === 'top_left') {
107
+ dx = leftAnchorDx;
108
+ dy = below(chrome.legendBottom);
109
+ }
110
+ else if (position === 'top_right') {
111
+ dx = rightAnchorDx;
112
+ dy = below(chrome.actionBarBottom);
113
+ }
114
+ else if (position === 'bottom_left') {
115
+ dx = leftAnchorDx;
116
+ }
117
+ else if (position === 'bottom_right') {
118
+ dx = rightAnchorDx;
119
+ }
120
+ return dx === 0 && dy === 0 ? undefined : [dx, dy];
121
+ }
122
+ function isRecord(value) {
123
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
124
+ }
125
+ function positiveOr(value, fallback) {
126
+ return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : fallback;
127
+ }
128
+ function finiteOr(value, fallback) {
129
+ return typeof value === 'number' && Number.isFinite(value) ? value : fallback;
130
+ }
131
+ /** A cell's span as the engine reads it (TextPlot `spanValue`): a whole number above 1, else 1. */
132
+ function cellSpan(value) {
133
+ return typeof value === 'number' && Number.isFinite(value) && value > 1 ? Math.floor(value) : 1;
134
+ }
135
+ /**
136
+ * About how wide the engine lays out a plotTable payload (TextPlot
137
+ * `buildTableLayout`), in CSS px: each column is as wide as its widest cell,
138
+ * 0.6 em a glyph at the cell's font size plus the cell padding on both sides
139
+ * (16 px a column at the engine's 8 px). A cell spanning columns shares its
140
+ * width across them, one spanning rows holds its column below it; a pinned
141
+ * `columnWidths` entry is its column, and a declared `width` the whole table
142
+ * while a column is left to scale. 0 for a payload without rows.
143
+ */
144
+ export function estimateWrunTableWidth(payload) {
145
+ const grid = Array.isArray(payload.data) ? payload.data : [];
146
+ const fontSize = positiveOr(payload.fontSize, TABLE_FONT_SIZE_PX);
147
+ const padding = typeof payload.cellPadding === 'number' && Number.isFinite(payload.cellPadding)
148
+ ? payload.cellPadding
149
+ : TABLE_CELL_PADDING_PX;
150
+ const columns = [];
151
+ // Per row, the columns a rowspan from above holds.
152
+ const held = [];
153
+ grid.forEach((row, at) => {
154
+ if (!Array.isArray(row))
155
+ return;
156
+ let col = 0;
157
+ for (const cell of row) {
158
+ while (held[at]?.has(col))
159
+ col += 1;
160
+ const rich = isRecord(cell) ? cell : undefined;
161
+ const colspan = cellSpan(rich?.colspan);
162
+ const rowspan = cellSpan(rich?.rowspan);
163
+ for (let below = 1; below < rowspan; below += 1) {
164
+ const heldBelow = (held[at + below] ??= new Set());
165
+ for (let spanned = col; spanned < col + colspan; spanned += 1)
166
+ heldBelow.add(spanned);
167
+ }
168
+ const text = String((rich ? (rich.value ?? rich.text) : cell) ?? '');
169
+ const width = text.length * TABLE_GLYPH_EM * positiveOr(rich?.fontSize, fontSize) + 2 * padding;
170
+ for (let spanned = col; spanned < col + colspan; spanned += 1) {
171
+ columns[spanned] = Math.max(columns[spanned] ?? 0, width / colspan);
172
+ }
173
+ col += colspan;
174
+ }
175
+ });
176
+ const pins = Array.isArray(payload.columnWidths) ? payload.columnWidths : [];
177
+ let pinned = 0;
178
+ let auto = 0;
179
+ let autoColumns = 0;
180
+ for (let col = 0; col < columns.length; col += 1) {
181
+ const pin = positiveOr(pins[col], 0);
182
+ if (pin > 0) {
183
+ pinned += pin;
184
+ }
185
+ else {
186
+ auto += columns[col] ?? 0;
187
+ autoColumns += 1;
188
+ }
189
+ }
190
+ const declared = positiveOr(payload.width, 0);
191
+ return autoColumns > 0 && declared > pinned ? declared : pinned + auto;
192
+ }
193
+ /** The result's table outputs drawn on the price pane (an onchart result, or
194
+ * forced there), each with its plotTable rows `[ts, payload]`. */
195
+ function priceTables(result) {
196
+ if (!isRecord(result.outputs))
197
+ return [];
198
+ const onchart = result.define?.position === 'onchart';
199
+ const tables = [];
200
+ for (const [key, output] of Object.entries(result.outputs)) {
201
+ if (!isRecord(output) || output.plotType !== 'table' || !Array.isArray(output.data))
202
+ continue;
203
+ if (!onchart && output.forceOnChart !== true)
204
+ continue;
205
+ tables.push([key, output, output.data]);
206
+ }
207
+ return tables;
208
+ }
209
+ /** A payload the default applies to: a chrome corner, no declared `offset`. */
210
+ function placeablePayload(row) {
211
+ if (!Array.isArray(row))
212
+ return undefined;
213
+ const payload = row[1];
214
+ if (!isRecord(payload) || payload.offset !== undefined)
215
+ return undefined;
216
+ return CHROME_CORNERS.has(payload.position) ? payload : undefined;
217
+ }
218
+ /**
219
+ * The run result with each price-pane table at a chrome corner that declares
220
+ * no `offset` given the default one; the same object when nothing moves (no
221
+ * chrome measured, nothing to clear, every corner declared). Pure: the result
222
+ * handed in is never changed, every other output and key is carried as is.
223
+ */
224
+ export function placeWrunTablesClearOfChrome(result, chrome) {
225
+ if (!chrome)
226
+ return result;
227
+ let outputs;
228
+ for (const [key, output, rows] of priceTables(result)) {
229
+ let placedRows;
230
+ rows.forEach((row, at) => {
231
+ const payload = placeablePayload(row);
232
+ const offset = payload && wrunTableChromeOffset(payload.position, chrome);
233
+ if (!offset)
234
+ return;
235
+ placedRows ??= [...rows];
236
+ placedRows[at] = [row[0], { ...payload, offset }, ...row.slice(2)];
237
+ });
238
+ if (!placedRows)
239
+ continue;
240
+ outputs ??= { ...result.outputs };
241
+ outputs[key] = { ...output, data: placedRows };
242
+ }
243
+ // Only table outputs' rows changed: the result keeps its own type.
244
+ return outputs ? { ...result, outputs } : result;
245
+ }
246
+ function hasChromeCornerTable(result) {
247
+ return priceTables(result).some(([, , rows]) => rows.some(placeablePayload));
248
+ }
249
+ /** A price-pane table at top_right, its offset declared or not: the legend makes room for it. */
250
+ function hasTopRightTable(result) {
251
+ return priceTables(result).some(([, , rows]) => rows.some((row) => Array.isArray(row) && isRecord(row[1]) && row[1].position === 'top_right'));
252
+ }
253
+ /**
254
+ * Where the price pane legend stops for the result's top_right tables, in
255
+ * plot px from its left edge, or null when no such table reaches the legend.
256
+ * The engine anchors a top_right table at the plot width less the table's
257
+ * width and inset, plus its `x` and its `offset` (TextPlot `Table`); the
258
+ * legend stops the gap before the leftmost such table, never below 0. A table
259
+ * whose top clears the last legend row by the gap reaches nothing, nor does a
260
+ * payload without rows, and `drawn` (by output key) leaves out a table the
261
+ * chart does not draw. Hand it the placed result: the offset the chart draws
262
+ * a table at is the one that counts.
263
+ */
264
+ export function wrunTableLegendEdge(result, chrome, drawn = () => true) {
265
+ if (!(chrome.paneWidth > 0))
266
+ return null;
267
+ let edge = null;
268
+ for (const [key, , rows] of priceTables(result)) {
269
+ if (!drawn(key))
270
+ continue;
271
+ for (const row of rows) {
272
+ const payload = Array.isArray(row) ? row[1] : undefined;
273
+ if (!isRecord(payload) || payload.position !== 'top_right')
274
+ continue;
275
+ const width = estimateWrunTableWidth(payload);
276
+ if (!(width > 0))
277
+ continue;
278
+ const offset = Array.isArray(payload.offset) ? payload.offset : [];
279
+ const top = WRUN_TABLE_ENGINE_INSET_PX + finiteOr(payload.y, 0) + finiteOr(offset[1], 0);
280
+ if (top >= chrome.legendBottom + WRUN_TABLE_CHROME_GAP_PX)
281
+ continue;
282
+ const left = chrome.paneWidth - width - WRUN_TABLE_ENGINE_INSET_PX + finiteOr(payload.x, 0) + finiteOr(offset[0], 0);
283
+ const stop = Math.max(0, Math.floor(left - WRUN_TABLE_CHROME_GAP_PX));
284
+ edge = edge === null ? stop : Math.min(edge, stop);
285
+ }
286
+ }
287
+ return edge;
288
+ }
289
+ /** Which offset each table got: compared to re-apply only a table that moves. */
290
+ function placementOf(result) {
291
+ return JSON.stringify(priceTables(result).map(([key, , rows]) => [
292
+ key,
293
+ rows.map((row) => (Array.isArray(row) && isRecord(row[1]) ? row[1].offset : null)),
294
+ ]));
295
+ }
296
+ const ACTION_BAR_SELECTOR = '.chart-pane-action-bar';
297
+ const trackers = new WeakMap();
298
+ function measureBoxes(pane) {
299
+ const origin = pane.plot.getBoundingClientRect();
300
+ const legend = measureLegendBox(pane);
301
+ const bar = pane.root.querySelector(ACTION_BAR_SELECTOR)?.getBoundingClientRect();
302
+ return {
303
+ legendBottom: legend ? Math.max(0, legend.bottom) : 0,
304
+ // An empty bar (no button to show) has no box and nothing to clear.
305
+ actionBarBottom: bar && bar.width > 0 && bar.height > 0 ? Math.max(0, Math.round(bar.bottom - origin.top)) : 0,
306
+ paneHeight: Math.round(origin.height),
307
+ paneWidth: Math.round(origin.width),
308
+ };
309
+ }
310
+ function sameBoxes(a, b) {
311
+ return Object.keys(a).every((key) => a[key] === b[key]);
312
+ }
313
+ /** The main series' settings on titan: the High/Low tags and the price scale side live there. */
314
+ function mainSettings(tc) {
315
+ const main = Array.isArray(tc.metadata) ? tc.metadata[0] : undefined;
316
+ return isRecord(main) && isRecord(main.settings) ? main.settings : {};
317
+ }
318
+ function chromeOf(tc, boxes) {
319
+ const settings = mainSettings(tc);
320
+ return {
321
+ ...boxes,
322
+ highLowTags: settings.showHighLowLabel === true,
323
+ priceScaleSide: settings.priceScaleSide === 'left' ? 'left' : 'right',
324
+ };
325
+ }
326
+ function overlayMeta(tc, overlayId) {
327
+ if (!Array.isArray(tc.metadata))
328
+ return undefined;
329
+ const meta = tc.metadata.find((entry) => isRecord(entry) && entry.id === overlayId);
330
+ return isRecord(meta) ? meta : undefined;
331
+ }
332
+ /** Whether the chart draws an overlay's table output: neither the overlay
333
+ * (the legend eye) nor that plot (the plot's own eye, by `outputKey`) hidden.
334
+ * An overlay the chart does not hold yet reads as drawn; pruning drops it if it never comes. */
335
+ function tableDrawn(tc, overlayId) {
336
+ const meta = overlayMeta(tc, overlayId);
337
+ if (meta?.isHidden === true)
338
+ return () => false;
339
+ const plots = Array.isArray(meta?.nestedMeta) ? meta.nestedMeta.filter(isRecord) : [];
340
+ return (outputKey) => !plots.some((plot) => plot.outputKey === outputKey && plot.isHidden === true);
341
+ }
342
+ /** Every legend row of the chart refits in full: the engine unfolds a row only when its section widens. */
343
+ function refitLegendRows(tc) {
344
+ if (!Array.isArray(tc.metadata))
345
+ return;
346
+ for (const meta of tc.metadata) {
347
+ const legends = isRecord(meta) ? meta.legends : undefined;
348
+ if (isRecord(legends) && typeof legends.refreshRollingNumberLayout === 'function') {
349
+ legends.refreshRollingNumberLayout();
350
+ }
351
+ }
352
+ }
353
+ /** Write where the price pane legend stops (null: nowhere, the variable unset); an edge that moves right or lifts refits the rows. */
354
+ function applyLegendEdge(tc, tracker, edge) {
355
+ const was = tracker.edge;
356
+ if (edge === was)
357
+ return;
358
+ tracker.edge = edge;
359
+ const style = tracker.pane.plot.style;
360
+ if (edge === null)
361
+ style?.removeProperty(WRUN_TABLE_LEGEND_EDGE_VAR);
362
+ else
363
+ style?.setProperty(WRUN_TABLE_LEGEND_EDGE_VAR, `${edge}px`);
364
+ if (was !== null && (edge === null || edge > was) && tracker.pane.plot.isConnected !== false) {
365
+ refitLegendRows(tc);
366
+ }
367
+ }
368
+ /** The edge the tracked overlays' drawn top_right tables leave the legend, written to the pane. */
369
+ function syncLegendEdge(tc, tracker) {
370
+ const chrome = chromeOf(tc, tracker.boxes);
371
+ let edge = null;
372
+ for (const [overlayId, entry] of tracker.overlays) {
373
+ const stop = wrunTableLegendEdge(entry.placed, chrome, tableDrawn(tc, overlayId));
374
+ if (stop !== null)
375
+ edge = edge === null ? stop : Math.min(edge, stop);
376
+ }
377
+ applyLegendEdge(tc, tracker, edge);
378
+ }
379
+ function dropTracker(tc, tracker) {
380
+ tracker.stop();
381
+ applyLegendEdge(tc, tracker, null);
382
+ if (trackers.get(tc) === tracker)
383
+ trackers.delete(tc);
384
+ }
385
+ /** Forget the tracked overlays the chart no longer holds; whether any went. */
386
+ function pruneUnmounted(tc, tracker) {
387
+ let pruned = false;
388
+ for (const overlayId of [...tracker.overlays.keys()]) {
389
+ if (overlayMeta(tc, overlayId))
390
+ continue;
391
+ tracker.overlays.delete(overlayId);
392
+ pruned = true;
393
+ }
394
+ return pruned;
395
+ }
396
+ /** Place every followed overlay again against the current chrome, hand each one
397
+ * whose tables moved to its lane, forget overlays the chart no longer holds,
398
+ * and move the legend edge with them. */
399
+ function replaceTracked(tc, tracker) {
400
+ const chrome = chromeOf(tc, tracker.boxes);
401
+ pruneUnmounted(tc, tracker);
402
+ for (const [overlayId, entry] of tracker.overlays) {
403
+ // A placement nobody re-applies stays where the chart draws it.
404
+ if (!entry.reapply)
405
+ continue;
406
+ const placed = placeWrunTablesClearOfChrome(entry.base, chrome);
407
+ const placement = placementOf(placed);
408
+ if (placement === entry.placement)
409
+ continue;
410
+ entry.placement = placement;
411
+ entry.placed = placed;
412
+ let current = true;
413
+ try {
414
+ current = entry.reapply(placed);
415
+ }
416
+ catch (error) {
417
+ // The next run or tick places the table again; the follow-up never breaks the observers.
418
+ console.warn(`[wrun] table chrome re-place failed for '${overlayId}':`, error);
419
+ }
420
+ if (current === false)
421
+ tracker.overlays.delete(overlayId);
422
+ }
423
+ if (tracker.overlays.size === 0) {
424
+ dropTracker(tc, tracker);
425
+ return;
426
+ }
427
+ syncLegendEdge(tc, tracker);
428
+ }
429
+ function followChrome(tc, tracker) {
430
+ if (trackers.get(tc) !== tracker)
431
+ return;
432
+ if (tracker.pane.plot.isConnected === false) {
433
+ // Titan replaced the legend DOM (re-init, interval switch): the next run measures the new one.
434
+ dropTracker(tc, tracker);
435
+ return;
436
+ }
437
+ // Overlays that left the chart go first, whatever moved: a folded legend can
438
+ // lose an overlay without any measured box changing. No table left, nothing watched.
439
+ const pruned = pruneUnmounted(tc, tracker);
440
+ if (tracker.overlays.size === 0) {
441
+ dropTracker(tc, tracker);
442
+ return;
443
+ }
444
+ const boxes = measureBoxes(tracker.pane);
445
+ if (sameBoxes(boxes, tracker.boxes)) {
446
+ // An overlay that left takes its table's edge with it.
447
+ if (pruned)
448
+ syncLegendEdge(tc, tracker);
449
+ return;
450
+ }
451
+ tracker.boxes = boxes;
452
+ replaceTracked(tc, tracker);
453
+ }
454
+ function startTracker(tc) {
455
+ const pane = legendPaneOf(tc);
456
+ // No DOM (a node spec, a chart with no container): the engine's corner.
457
+ if (!pane)
458
+ return null;
459
+ const tracker = {
460
+ pane,
461
+ boxes: measureBoxes(pane),
462
+ overlays: new Map(),
463
+ edge: null,
464
+ stop: () => { },
465
+ };
466
+ trackers.set(tc, tracker);
467
+ if (typeof ResizeObserver !== 'function')
468
+ return tracker;
469
+ const refresh = () => followChrome(tc, tracker);
470
+ const sizes = new ResizeObserver(refresh);
471
+ // The section itself (its padding follows the host rows and the compare
472
+ // strip), every legend row, the host rows and the action bar.
473
+ const watch = () => {
474
+ sizes.disconnect();
475
+ sizes.observe(pane.plot);
476
+ for (const row of legendRowsOf(pane))
477
+ sizes.observe(row);
478
+ const bar = pane.root.querySelector(ACTION_BAR_SELECTOR);
479
+ if (bar)
480
+ sizes.observe(bar);
481
+ };
482
+ watch();
483
+ // Rows come and go with the indicators (direct children of the legend section): re-watch, re-measure.
484
+ const rows = typeof MutationObserver === 'function'
485
+ ? new MutationObserver(() => {
486
+ if (trackers.get(tc) !== tracker)
487
+ return;
488
+ watch();
489
+ refresh();
490
+ })
491
+ : null;
492
+ rows?.observe(pane.plot, { childList: true });
493
+ tracker.stop = () => {
494
+ sizes.disconnect();
495
+ rows?.disconnect();
496
+ };
497
+ return tracker;
498
+ }
499
+ /**
500
+ * The result to hand the adapter: its price-pane corner tables placed clear of
501
+ * the chart's chrome. Both wrun lanes call this right before they mount a
502
+ * result, with `reapply` mounting a re-placed copy of it the way they would
503
+ * (the adapter's mounted-row refresh); the overlay is tracked while it has
504
+ * such a table, and its last result is placed again and re-applied whenever
505
+ * the chrome moves one of its tables, until `reapply` reports it stale. A
506
+ * `null` reapply places without following (the chart replays: the replay
507
+ * lane owns the rows). An overlay with a top_right table is tracked for the
508
+ * legend edge as well, a declared offset or a replay placement included
509
+ * (never placed again). A result with neither (the clear included) drops the
510
+ * overlay.
511
+ */
512
+ export function placeWrunTablesOnChart(tc, overlayId, result, reapply) {
513
+ let tracker = trackers.get(tc);
514
+ if (tracker && tracker.pane.plot.isConnected === false) {
515
+ dropTracker(tc, tracker);
516
+ tracker = undefined;
517
+ }
518
+ const corner = hasChromeCornerTable(result);
519
+ if (!corner && !hasTopRightTable(result)) {
520
+ // Out of the follow-up, its edge with it: nothing to place, nothing the legend makes room for.
521
+ if (tracker?.overlays.delete(overlayId)) {
522
+ if (tracker.overlays.size === 0)
523
+ dropTracker(tc, tracker);
524
+ else
525
+ syncLegendEdge(tc, tracker);
526
+ }
527
+ return result;
528
+ }
529
+ tracker ??= startTracker(tc) ?? undefined;
530
+ if (!tracker)
531
+ return result;
532
+ const placed = placeWrunTablesClearOfChrome(result, chromeOf(tc, tracker.boxes));
533
+ tracker.overlays.set(overlayId, {
534
+ base: result,
535
+ reapply: corner && reapply ? reapply : null,
536
+ placed,
537
+ placement: placementOf(placed),
538
+ });
539
+ syncLegendEdge(tc, tracker);
540
+ return placed;
541
+ }
542
+ /** Measure the chart's chrome again now, re-place its tracked tables and move
543
+ * the legend edge (the High/Low toggle, a price scale side move, an eye:
544
+ * settings, so no box the tracker watches moves). */
545
+ export function refreshWrunTableChrome(tc) {
546
+ if (!tc)
547
+ return;
548
+ const tracker = trackers.get(tc);
549
+ if (!tracker)
550
+ return;
551
+ if (tracker.pane.plot.isConnected === false) {
552
+ dropTracker(tc, tracker);
553
+ return;
554
+ }
555
+ tracker.boxes = measureBoxes(tracker.pane);
556
+ replaceTracked(tc, tracker);
557
+ }
@@ -65,13 +65,18 @@ export declare function wrunTextHasDisguise(text: string, options?: {
65
65
  * its `max_bytes` speak in. */
66
66
  export declare function wrunTextByteLength(text: string): number;
67
67
  /** A value inserted into a legend suffix as LITERAL text (guards G1 and G4):
68
- * every HTML special and `$` as its entity, so the innerHTML legend shows
69
- * the characters themselves, never a link, an image or a re-expanded token. */
68
+ * its own characters (titan shows the suffix as text, never markup), each
69
+ * `$` out of titan's `$token` grammar ({@link LEGEND_LITERAL_DOLLAR}), so a
70
+ * typed anchor, image or `$period` shows as the same characters. */
70
71
  export declare function wrunLegendLiteral(text: string): string;
71
- /** The inverse of {@link wrunLegendLiteral} for a consumer that renders the
72
- * suffix as text (the indicator menu's inputs line): the six entities back
73
- * to their characters, `&amp;` last so a literal `&lt;` typed by a user
74
- * (escaped as `&amp;lt;`) comes back as `&lt;`, not `<`. */
72
+ /** A legend suffix as plain words, for a consumer that renders it as text
73
+ * with no `$token` pass (the indicator menu's inputs line): the exact
74
+ * inverse of {@link wrunLegendLiteral}, the joiner after each `$` removed
75
+ * and nothing else. Never decode an entity here or on any reader of a
76
+ * suffix: the suffix holds the raw words, so `&amp;` in it is what the user
77
+ * typed (a typed `R&amp;D` reads `R&amp;D`), and no stored marker tells a
78
+ * pre-alpha.1139 suffix apart (a wrun row's first run re-stamps that one).
79
+ * tests/hygiene/no-entity-decoder.spec.ts fails on a new decoder. */
75
80
  export declare function wrunLegendLiteralText(text: string): string;
76
81
  /** A sheet param (or a declaration row) of the text kind. */
77
82
  export declare function isWrunTextParam(param: Pick<WrunMetadataParam, 'type'>): boolean;
@@ -68,40 +68,29 @@ export function wrunTextHasDisguise(text, options = {}) {
68
68
  export function wrunTextByteLength(text) {
69
69
  return UTF8.encode(text).length;
70
70
  }
71
- /** The entities a legend suffix carries for one literal character: the HTML
72
- * specials (TitanCharts writes `define.customTitle` through innerHTML after
73
- * DOMPurify, which keeps `a[href]`, `img[src]` and `style`) and `$`
74
- * (titan's own `$token` pass re-expands a string customTitle against the
75
- * overlay's raw settings, so a typed `$period` must not read as one). The
76
- * entities decode back to the characters at the innerHTML sink; a consumer
77
- * that renders the suffix as text decodes them with
78
- * {@link wrunLegendLiteralText}. */
79
- const LEGEND_LITERAL_ENTITIES = [
80
- ['&', '&amp;'],
81
- ['<', '&lt;'],
82
- ['>', '&gt;'],
83
- ['"', '&quot;'],
84
- ["'", '&#39;'],
85
- ['$', '&#36;'],
86
- ];
71
+ /** A `$` of an inserted value as a legend suffix carries it: followed by
72
+ * U+2060 WORD JOINER. TitanCharts (alpha.1139 on) shows a string
73
+ * customTitle as text, after its own `$token` pass over the overlay's raw
74
+ * settings (`/\$[a-zA-Z0-9]+/g`); the joiner is invisible and not
75
+ * alphanumeric, so a typed `$period` reads as written, never as a value. */
76
+ const LEGEND_LITERAL_DOLLAR = '$\u2060';
87
77
  /** A value inserted into a legend suffix as LITERAL text (guards G1 and G4):
88
- * every HTML special and `$` as its entity, so the innerHTML legend shows
89
- * the characters themselves, never a link, an image or a re-expanded token. */
78
+ * its own characters (titan shows the suffix as text, never markup), each
79
+ * `$` out of titan's `$token` grammar ({@link LEGEND_LITERAL_DOLLAR}), so a
80
+ * typed anchor, image or `$period` shows as the same characters. */
90
81
  export function wrunLegendLiteral(text) {
91
- let out = text;
92
- for (const [char, entity] of LEGEND_LITERAL_ENTITIES)
93
- out = out.split(char).join(entity);
94
- return out;
82
+ return text.split('$').join(LEGEND_LITERAL_DOLLAR);
95
83
  }
96
- /** The inverse of {@link wrunLegendLiteral} for a consumer that renders the
97
- * suffix as text (the indicator menu's inputs line): the six entities back
98
- * to their characters, `&amp;` last so a literal `&lt;` typed by a user
99
- * (escaped as `&amp;lt;`) comes back as `&lt;`, not `<`. */
84
+ /** A legend suffix as plain words, for a consumer that renders it as text
85
+ * with no `$token` pass (the indicator menu's inputs line): the exact
86
+ * inverse of {@link wrunLegendLiteral}, the joiner after each `$` removed
87
+ * and nothing else. Never decode an entity here or on any reader of a
88
+ * suffix: the suffix holds the raw words, so `&amp;` in it is what the user
89
+ * typed (a typed `R&amp;D` reads `R&amp;D`), and no stored marker tells a
90
+ * pre-alpha.1139 suffix apart (a wrun row's first run re-stamps that one).
91
+ * tests/hygiene/no-entity-decoder.spec.ts fails on a new decoder. */
100
92
  export function wrunLegendLiteralText(text) {
101
- let out = text;
102
- for (const [char, entity] of [...LEGEND_LITERAL_ENTITIES].reverse())
103
- out = out.split(entity).join(char);
104
- return out;
93
+ return text.split(LEGEND_LITERAL_DOLLAR).join('$');
105
94
  }
106
95
  /** A sheet param (or a declaration row) of the text kind. */
107
96
  export function isWrunTextParam(param) {