@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,219 @@
1
+ /**
2
+ * Alert-armable outputs of the mounted browser-run Indicator overlays, by
3
+ * overlay id. The registry loader stamps an overlay's package metadata here
4
+ * at mount (add, rehydrate, draft re-run); the alert resolver reads it to
5
+ * build the Indicator target's output picker.
6
+ *
7
+ * Rules are anchored server-side by output NAME, so each entry carries the
8
+ * metadata name as the stable identity (`outputKey` = name, `outputColumn`
9
+ * = 1) and as its `label`: the hosted engine labels the series by name and
10
+ * refuses a threshold rule whose `outputLabel` says otherwise. The sheet's
11
+ * own display `label` rides beside it as `displayLabel`, for the pickers
12
+ * only (displayOutputLabel). Data-only outputs (`plot: ''`) are never
13
+ * armable and are excluded here, mirroring the server's own list, and so are
14
+ * guides (`role: "guide"`): a guide is the kScript hline it stands for, one
15
+ * constant level, which the kScript lane never offers either. Two more sheet
16
+ * facts ride for the resolver's offer: `transparent` (a line declared
17
+ * `opacity: 0`, drawn clear: a fill's edge) and `displacement` (the declared
18
+ * bar shift, read against the armed params there).
19
+ *
20
+ * A strategy package (a sheet that declares `strategy`, OM-WRUN3-STRATEGIES-
21
+ * CONTRACT section 5) adds four host-published entries after its outputs,
22
+ * the same ones the hosted alerts engine evaluates: the two event streams
23
+ * (`strategy.order`, a pending order that did not exist before the bar's
24
+ * finalize(); `strategy.fill`, a trade opened or closed by the bar's fills;
25
+ * both fire on confirmed bars only) and the two reserved outputs
26
+ * (`strategy.position`, the signed position after the bar's fills;
27
+ * `strategy.equity`), addressable by name like any output. They never enter
28
+ * the module's output count, so their `index` continues after the declared
29
+ * outputs and `kind` tells them apart from a plotted output.
30
+ *
31
+ * A sheet's declared alerts (`alerts: [{ name, when, message?, description?,
32
+ * text?, every_bar? }]`, the kit's `alert(name, { when: handle, message })`
33
+ * declaration over an output the module already writes, data-only allowed)
34
+ * are stamped beside the armable outputs as alert CONDITIONS: the form lists
35
+ * them as `signal:<name>` options and the arm sends a `kind: 'signal'` rule
36
+ * whose `conditionTitle` is the declared name; the hosted engine fires on
37
+ * the `when` output's false to true flip (or on every bar it holds when the
38
+ * declaration or the user says `every_bar`) and refuses an undeclared title
39
+ * with 422 UNKNOWN_CONDITION. The two scaffold-37 facts ride along so the
40
+ * arm form can say what will fire and what the message will be: `text`
41
+ * names the declared string slot whose fired-row value is the fire text,
42
+ * `every_bar` the author's firing default. They never enter the output
43
+ * entries: the `when` output stays armable (or data-only) on its own terms.
44
+ * A declared `title` (frozen authoring contract C1.8: display text with
45
+ * spaces beside the slug name) rides as the entry's `label`: the picker
46
+ * lists it, the arm stamps it as the signal rule's `outputLabel`, and the
47
+ * cards and fired notifications show it. The entry's `title` stays the
48
+ * name, the `conditionTitle` every option, edit and armed rule is keyed by,
49
+ * so arms made before titles existed keep matching.
50
+ *
51
+ * Leaf module (no imports) so the resolver stays node-testable without the
52
+ * wasm host or the chart instance in its graph; the four names mirror the
53
+ * SDK's WRUN3_STRATEGY_EVENT_STREAMS and WRUN3_STRATEGY_RESERVED_OUTPUTS.
54
+ */
55
+ /** The strategy entries in picker order: the actionable stream first (the
56
+ * strategy wants a fill at the next open), the accounting stream, then the
57
+ * two reserved outputs. Labels are the user-facing names. */
58
+ const WRUN_STRATEGY_ALERT_ENTRIES = [
59
+ { outputKey: 'strategy.order', label: 'Strategy order placed', kind: 'event' },
60
+ { outputKey: 'strategy.fill', label: 'Strategy trade opened or closed', kind: 'event' },
61
+ { outputKey: 'strategy.position', label: 'Strategy position', kind: 'reserved' },
62
+ { outputKey: 'strategy.equity', label: 'Strategy equity', kind: 'reserved' },
63
+ ];
64
+ /** The words of a strategy package's host-published entry by its name
65
+ * (`strategy.fill` -> "Strategy trade opened or closed"); undefined for any
66
+ * other name. An alert on one names it without its sheet in hand. */
67
+ export function wrunStrategyAlertEntryLabel(outputKey) {
68
+ return WRUN_STRATEGY_ALERT_ENTRIES.find((entry) => entry.outputKey === outputKey)?.label;
69
+ }
70
+ const recordsByOverlay = new Map();
71
+ /** Armable entries from a package metadata sheet (data-only outputs and
72
+ * guides dropped; a strategy package's event streams and reserved outputs
73
+ * appended). */
74
+ export function wrunAlertOutputsFromMetadata(metadata) {
75
+ const entries = [];
76
+ metadata.outputs.forEach((output, position) => {
77
+ if (!output?.name || output.plot === '' || output.role === 'guide')
78
+ return;
79
+ const displayLabel = typeof output.label === 'string' ? output.label.trim() : '';
80
+ const shift = {
81
+ ...(typeof output.displacement_bars === 'number' ? { bars: output.displacement_bars } : {}),
82
+ ...(output.displacement_bars_by !== undefined ? { by: output.displacement_bars_by } : {}),
83
+ };
84
+ entries.push({
85
+ index: typeof output.index === 'number' ? output.index : position,
86
+ label: output.name,
87
+ outputKey: output.name,
88
+ outputColumn: 1,
89
+ ...(output.panel ? { panel: output.panel } : {}),
90
+ ...(displayLabel && displayLabel !== output.name ? { displayLabel } : {}),
91
+ ...(output.opacity === 0 ? { transparent: true } : {}),
92
+ ...(Object.keys(shift).length ? { displacement: shift } : {}),
93
+ });
94
+ });
95
+ if (metadata.strategy !== undefined) {
96
+ // After every declared output index, so a reserved entry never collides
97
+ // with a declared column whatever the sheet's index gaps.
98
+ let index = metadata.outputs.reduce((max, output, position) => Math.max(max, typeof output?.index === 'number' ? output.index : position), -1);
99
+ for (const entry of WRUN_STRATEGY_ALERT_ENTRIES) {
100
+ index += 1;
101
+ entries.push({ index, label: entry.label, outputKey: entry.outputKey, outputColumn: 1, kind: entry.kind });
102
+ }
103
+ }
104
+ return entries;
105
+ }
106
+ /** The sheet's declared alerts as picker conditions, in declaration order.
107
+ * A row without a string name is skipped; a repeated name keeps its first
108
+ * row (the sheet namespace forbids duplicates, so this only guards a
109
+ * hand-edited sheet). `when` is the engine's concern: the FE never
110
+ * re-derives the output it names. `text` rides only as a non-empty string
111
+ * and `every_bar` only as the literal `true` (a sheet from an older kit
112
+ * carries neither, and `false` means the edge, the default); `title` rides
113
+ * as `label` only when it is non-empty and differs from the name. */
114
+ export function wrunAlertConditionsFromMetadata(metadata) {
115
+ if (!Array.isArray(metadata.alerts))
116
+ return [];
117
+ const entries = [];
118
+ const seen = new Set();
119
+ for (const row of metadata.alerts) {
120
+ const alert = row;
121
+ if (!alert || typeof alert !== 'object' || typeof alert.name !== 'string' || !alert.name)
122
+ continue;
123
+ if (seen.has(alert.name))
124
+ continue;
125
+ seen.add(alert.name);
126
+ // The display title (C1.8) rides only when it says something the name does not.
127
+ const label = typeof alert.title === 'string' ? alert.title.trim() : '';
128
+ entries.push({
129
+ kind: 'condition',
130
+ title: alert.name,
131
+ ...(label && label !== alert.name ? { label } : {}),
132
+ ...(typeof alert.message === 'string' && alert.message ? { message: alert.message } : {}),
133
+ ...(typeof alert.description === 'string' && alert.description ? { description: alert.description } : {}),
134
+ ...(typeof alert.text === 'string' && alert.text ? { text: alert.text } : {}),
135
+ ...(alert.every_bar === true ? { everyBar: true } : {}),
136
+ });
137
+ }
138
+ return entries;
139
+ }
140
+ /** Registers an overlay's entries from its sheet. `partial`: the sheet lacks
141
+ * the output facts the offer reads (labels, guide roles, opacity, shifts), so
142
+ * the entries stand in until a complete sheet replaces them
143
+ * (wrunOverlayAlertOutputsArePartial). */
144
+ export function setWrunOverlayAlertOutputs(overlayId, metadata, options = {}) {
145
+ recordsByOverlay.set(overlayId, {
146
+ outputs: wrunAlertOutputsFromMetadata(metadata),
147
+ alertConditions: wrunAlertConditionsFromMetadata(metadata),
148
+ ...(options.partial === true ? { partial: true } : {}),
149
+ });
150
+ }
151
+ /** Whether the overlay's entries were registered `partial`: a complete sheet replaces them. */
152
+ export function wrunOverlayAlertOutputsArePartial(overlayId) {
153
+ return recordsByOverlay.get(overlayId)?.partial === true;
154
+ }
155
+ export function clearWrunOverlayAlertOutputs(overlayId) {
156
+ recordsByOverlay.delete(overlayId);
157
+ }
158
+ /** undefined until the overlay's package is mounted (an inert reload-time overlay has none). */
159
+ export function getWrunOverlayAlertOutputs(overlayId) {
160
+ const record = recordsByOverlay.get(overlayId);
161
+ return record ? record.outputs.map((entry) => ({ ...entry })) : undefined;
162
+ }
163
+ /** The mounted overlay's declared alerts; undefined until its package is
164
+ * mounted, an empty list for a package that declares none. */
165
+ export function getWrunOverlayAlertConditions(overlayId) {
166
+ const record = recordsByOverlay.get(overlayId);
167
+ return record ? record.alertConditions.map((entry) => ({ ...entry })) : undefined;
168
+ }
169
+ /** The mounted plot of output `name` under `hosts`, found the way the
170
+ * visibility apply finds it (wrun-run-result.util applyWrunOutputVisibility):
171
+ * the nested meta whose engine keys name `<host>:<name>` or `<name>`. */
172
+ function mountedOutputPlot(hosts, name) {
173
+ for (const host of hosts) {
174
+ const wanted = [`${String(host.id)}:${name}`, name];
175
+ const nested = Array.isArray(host.nestedMeta) ? host.nestedMeta : [];
176
+ const plot = nested.find((candidate) => !!candidate &&
177
+ [candidate.id, candidate.plotId, candidate.mainPlotKey, candidate.outputKey, candidate.plotKey].some((key) => typeof key === 'string' && wanted.includes(key)));
178
+ if (plot)
179
+ return plot;
180
+ }
181
+ return undefined;
182
+ }
183
+ /**
184
+ * The live frontier of an Indicator overlay's alert outputs on the mounted
185
+ * chart, for the quick dialog's Current values, threshold seed and direction
186
+ * (the built-in opener's lastValues / colors / labels): each array indexed by
187
+ * the output's `index`, the plot's last row value, its first colour, and the
188
+ * output's display label. Plots live under the overlay and its series
189
+ * children (`<id>::series:<pane>`, wrun-run-result.util wrunSeriesChildId).
190
+ * An output with no mounted plot (an empty `omit_if_empty` line, a strategy's
191
+ * reserved output or event stream) reads NaN, which the dialog prints as "-".
192
+ */
193
+ export function wrunOverlayAlertOutputValues(chart, overlayId, outputs) {
194
+ const length = outputs.reduce((max, output) => Math.max(max, output.index + 1), 0);
195
+ const lastValues = Array.from({ length }, () => Number.NaN);
196
+ const colors = Array.from({ length }, () => undefined);
197
+ const labels = Array.from({ length }, () => undefined);
198
+ const childPrefix = `${overlayId}::series:`;
199
+ const hosts = (chart?.metadata ?? []).filter((meta) => {
200
+ const id = meta?.id;
201
+ return typeof id === 'string' && (id === overlayId || id.startsWith(childPrefix));
202
+ });
203
+ for (const output of outputs) {
204
+ labels[output.index] = output.displayLabel ?? output.label;
205
+ const plot = mountedOutputPlot(hosts, output.outputKey);
206
+ if (!plot)
207
+ continue;
208
+ const rows = Array.isArray(plot.rawData) ? plot.rawData : [];
209
+ const row = rows[rows.length - 1];
210
+ const value = Array.isArray(row) ? Number(row[1]) : Number.NaN;
211
+ if (Number.isFinite(value))
212
+ lastValues[output.index] = value;
213
+ const palette = Array.isArray(plot.settings?.colors) ? plot.settings.colors : plot.colors;
214
+ const color = Array.isArray(palette) ? palette[0] : undefined;
215
+ if (typeof color === 'string')
216
+ colors[output.index] = color;
217
+ }
218
+ return { lastValues, colors, labels };
219
+ }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * The wrun-6 row count (om docs/WRUN6_ABI.md): `wrun_bar_count() -> i32`, the number of bars the
3
+ * run holds while a row is evaluated, the forming bar included. It is the length of the series a
4
+ * kScript script reads ahead in (the engine's source `data.length`, the bound ichimoku()'s lagging
5
+ * span tests `i + displacement` against), so a row can tell whether a later row exists.
6
+ *
7
+ * The engine's semantics (v3.0.92), which every host mirrors: a full run and every reseed load the
8
+ * source whole, so every bar reads the bars loaded; live, a forming tick recomputes the forming bar
9
+ * only (the count it reads is unchanged), and a NEW bar re-seeds, recomputing every bar with the
10
+ * new length. The chart's worker answers the count (wrun-abi-host); the live tick reopens the
11
+ * session over every bar when a bar appears for a module that imports it (the reseed), and every
12
+ * other module keeps the close-confirm.
13
+ *
14
+ * Beside it, the chart's corroboration of the history-independent stamp (`history_independent: true`,
15
+ * kit 0.66.0): a module that reads the row count is never history-independent, and the stamp is
16
+ * admitted only when the module imports nothing outside the kit's per-bar list
17
+ * (`wrunStampCorroborated`) and the sheet passes the kit's sheet facts (`wrunStampSheetRefusal`, the
18
+ * kit's own rules ported), so a stamp hand-added to a published sheet still answers to the module it
19
+ * ships beside and to the facts the kit checks.
20
+ *
21
+ * The exact warm-up stamp (`history_warmup`, round A of the warm-up program) answers to the same module and
22
+ * sheet checks (`wrunWarmupStampOf` reads it, `wrunWarmupSheetRefusal` adds the one fact of its own: never
23
+ * beside `history_independent`), and a warm-up session must read the chart's own candles alone
24
+ * (`wrunWarmupSheetReadsCandlesOnly`): its hidden head is candles, so a book, a leg, a feed or a poll lane
25
+ * would reach the head's bars without their rows.
26
+ *
27
+ * Pure and worker-safe.
28
+ */
29
+ import { type WrunAbiVersion, type WrunHistoryWarmup } from '../../interfaces/wrun-runtime.interface.js';
30
+ /** The import (the one the shared host links under wrun-6; wrun-bar-count.kit-mirror.spec.ts). */
31
+ export declare const WRUN6_BAR_IMPORTS: readonly ["wrun:wrun_bar_count"];
32
+ /** The refusal names a host raises on the row count (a code of the shared host's refusal table). */
33
+ export declare const WRUN6_BAR_REFUSALS: {
34
+ /** wrun_bar_count called outside state() and finalize(). */
35
+ readonly phase: "wrun_bar_count_phase";
36
+ };
37
+ /** Whether a module imports the row count (read once per module). */
38
+ export declare function wrunModuleImportsBarCount(module: WebAssembly.Module): boolean;
39
+ /** Whether a module READS the row count under its ABI: wrun-6 or later and the import declared.
40
+ * Such a module's live session re-runs every bar when a bar appears; any other keeps the
41
+ * close-confirm. */
42
+ export declare function wrunModuleReadsBarCount(module: WebAssembly.Module, abi: WrunAbiVersion): boolean;
43
+ /**
44
+ * The import names a stamped module may carry: the kit's own list (`WRUN_HISTORY_INDEPENDENT_IMPORTS`,
45
+ * wrun-history-independence.ts, kit 0.67.1), name for name, read as the kit's decision reads them
46
+ * (`WebAssembly.Module.imports(module).map((entry) => entry.name)`): the argument readers `wrun_arg_*`
47
+ * (a row's scalar inputs and, during init(), the numeric and boolean setting readers), the cell channel
48
+ * `wrun_arg_len` and `wrun_arg_bytes` (this bar's block), the output writers `wrun_output_f64` and
49
+ * `wrun_result_write`, `abort`, and the text channel `wrun_param_len` and `wrun_param_bytes`. The text
50
+ * channel is admitted because a text setting is fixed for the run and read once in init(): the generated
51
+ * reader runs there, before onStart(), both hosts trap the two imports anywhere else, and the kit's walker
52
+ * refuses every `pt_*` read, so the setting's byte count reaches bar code through `p_<name>()` like any
53
+ * setting. Every other import refuses: the row count (`wrun_bar_count`), the last-bar signal
54
+ * (`wrun_bar_last`), the draw, string, frame and strategy channels, and any import a later kit adds until
55
+ * it is listed here (wrun-bar-count.util.spec.ts runs the kit's own decision over every host import and
56
+ * holds this list to exactly the names it admits).
57
+ */
58
+ export declare const WRUN_STAMP_IMPORTS: ReadonlySet<string>;
59
+ /** Whether every import of a module is on the kit's per-bar list (`WRUN_STAMP_IMPORTS`), read once per
60
+ * module; a module the engine cannot read answers false. */
61
+ export declare function wrunStampCorroborated(module: WebAssembly.Module): boolean;
62
+ /** The first sheet fact that reads or draws beyond the bar at hand, in the kit's own words
63
+ * (`sheet:<fact>[:<name>]`); undefined when the sheet passes. */
64
+ export declare function wrunStampSheetRefusal(sheet: unknown): string | undefined;
65
+ /** The sheet's raw exact warm-up stamp: its `history_warmup` in the frozen shape (wrun-declared-warmup.util
66
+ * `wrunHistoryWarmupOf`), undefined for no key, another kind or a malformed value. The chart admits a
67
+ * session on it only once the module and the sheet corroborate it (wrun-overlay-run.util). */
68
+ export declare function wrunWarmupStampOf(sheet: unknown): WrunHistoryWarmup | undefined;
69
+ /** The first sheet fact that refuses an exact warm-up stamp: `sheet:history-both` for a sheet that also carries
70
+ * `history_independent` (the kit writes one stamp or the other, never both: a sheet holding both was assembled
71
+ * by hand), then the per-bar stamp's own sheet facts (`wrunStampSheetRefusal`, the same rules: a warm-up module
72
+ * carries kit instances, never a handle, a string slot, a leg or a carried input); undefined when it passes. */
73
+ export declare function wrunWarmupSheetRefusal(sheet: unknown): string | undefined;
74
+ /** Whether one input reads the chart's own feed, the chart-feed shape (the plan's D3, the kit's `sheet:lanes`
75
+ * rule): `ohlcv` or `time`, with no key besides source, field and missing (no market, interval, view or depth of
76
+ * its own) and no cells. A row of the chart's candles carries every such input itself: its prices, and the bar
77
+ * times read off its own open. The exact warm-up rule below reads it, and the prefix lanes rule reads it for a
78
+ * `time` input (wrun-overlay-run.util). */
79
+ export declare function wrunInputReadsChartFeed(input: unknown, source: unknown): boolean;
80
+ /** Whether every input the sheet declares reads the chart's own feed (`wrunInputReadsChartFeed`). Those are the
81
+ * only rows an exact warm-up session's hidden head carries: its candles, and the bar times read off their own
82
+ * opens. A sheet with no input reads nothing a head could feed and is not candles-only. */
83
+ export declare function wrunWarmupSheetReadsCandlesOnly(sheet: unknown): boolean;
@@ -0,0 +1,259 @@
1
+ /**
2
+ * The wrun-6 row count (om docs/WRUN6_ABI.md): `wrun_bar_count() -> i32`, the number of bars the
3
+ * run holds while a row is evaluated, the forming bar included. It is the length of the series a
4
+ * kScript script reads ahead in (the engine's source `data.length`, the bound ichimoku()'s lagging
5
+ * span tests `i + displacement` against), so a row can tell whether a later row exists.
6
+ *
7
+ * The engine's semantics (v3.0.92), which every host mirrors: a full run and every reseed load the
8
+ * source whole, so every bar reads the bars loaded; live, a forming tick recomputes the forming bar
9
+ * only (the count it reads is unchanged), and a NEW bar re-seeds, recomputing every bar with the
10
+ * new length. The chart's worker answers the count (wrun-abi-host); the live tick reopens the
11
+ * session over every bar when a bar appears for a module that imports it (the reseed), and every
12
+ * other module keeps the close-confirm.
13
+ *
14
+ * Beside it, the chart's corroboration of the history-independent stamp (`history_independent: true`,
15
+ * kit 0.66.0): a module that reads the row count is never history-independent, and the stamp is
16
+ * admitted only when the module imports nothing outside the kit's per-bar list
17
+ * (`wrunStampCorroborated`) and the sheet passes the kit's sheet facts (`wrunStampSheetRefusal`, the
18
+ * kit's own rules ported), so a stamp hand-added to a published sheet still answers to the module it
19
+ * ships beside and to the facts the kit checks.
20
+ *
21
+ * The exact warm-up stamp (`history_warmup`, round A of the warm-up program) answers to the same module and
22
+ * sheet checks (`wrunWarmupStampOf` reads it, `wrunWarmupSheetRefusal` adds the one fact of its own: never
23
+ * beside `history_independent`), and a warm-up session must read the chart's own candles alone
24
+ * (`wrunWarmupSheetReadsCandlesOnly`): its hidden head is candles, so a book, a leg, a feed or a poll lane
25
+ * would reach the head's bars without their rows.
26
+ *
27
+ * Pure and worker-safe.
28
+ */
29
+ import { abiAtLeast } from '../../interfaces/wrun-runtime.interface.js';
30
+ import { wrunHistoryWarmupOf } from './wrun-declared-warmup.util.js';
31
+ import { isWrunLegStreamClass } from './wrun-leg-stream-classes.js';
32
+ /** The import (the one the shared host links under wrun-6; wrun-bar-count.kit-mirror.spec.ts). */
33
+ export const WRUN6_BAR_IMPORTS = ['wrun:wrun_bar_count'];
34
+ /** The refusal names a host raises on the row count (a code of the shared host's refusal table). */
35
+ export const WRUN6_BAR_REFUSALS = {
36
+ /** wrun_bar_count called outside state() and finalize(). */
37
+ phase: 'wrun_bar_count_phase',
38
+ };
39
+ const BAR_COUNT_IMPORT_NAME = WRUN6_BAR_IMPORTS[0].slice('wrun:'.length);
40
+ const importsByModule = new WeakMap();
41
+ /** Whether a module imports the row count (read once per module). */
42
+ export function wrunModuleImportsBarCount(module) {
43
+ let imports = importsByModule.get(module);
44
+ if (imports === undefined) {
45
+ imports = WebAssembly.Module.imports(module).some((entry) => entry.module === 'wrun' && entry.name === BAR_COUNT_IMPORT_NAME);
46
+ importsByModule.set(module, imports);
47
+ }
48
+ return imports;
49
+ }
50
+ /** Whether a module READS the row count under its ABI: wrun-6 or later and the import declared.
51
+ * Such a module's live session re-runs every bar when a bar appears; any other keeps the
52
+ * close-confirm. */
53
+ export function wrunModuleReadsBarCount(module, abi) {
54
+ return abiAtLeast(abi, 'wrun-6') && wrunModuleImportsBarCount(module);
55
+ }
56
+ /**
57
+ * The import names a stamped module may carry: the kit's own list (`WRUN_HISTORY_INDEPENDENT_IMPORTS`,
58
+ * wrun-history-independence.ts, kit 0.67.1), name for name, read as the kit's decision reads them
59
+ * (`WebAssembly.Module.imports(module).map((entry) => entry.name)`): the argument readers `wrun_arg_*`
60
+ * (a row's scalar inputs and, during init(), the numeric and boolean setting readers), the cell channel
61
+ * `wrun_arg_len` and `wrun_arg_bytes` (this bar's block), the output writers `wrun_output_f64` and
62
+ * `wrun_result_write`, `abort`, and the text channel `wrun_param_len` and `wrun_param_bytes`. The text
63
+ * channel is admitted because a text setting is fixed for the run and read once in init(): the generated
64
+ * reader runs there, before onStart(), both hosts trap the two imports anywhere else, and the kit's walker
65
+ * refuses every `pt_*` read, so the setting's byte count reaches bar code through `p_<name>()` like any
66
+ * setting. Every other import refuses: the row count (`wrun_bar_count`), the last-bar signal
67
+ * (`wrun_bar_last`), the draw, string, frame and strategy channels, and any import a later kit adds until
68
+ * it is listed here (wrun-bar-count.util.spec.ts runs the kit's own decision over every host import and
69
+ * holds this list to exactly the names it admits).
70
+ */
71
+ export const WRUN_STAMP_IMPORTS = new Set([
72
+ 'abort',
73
+ 'wrun_arg_count',
74
+ 'wrun_arg_i32',
75
+ 'wrun_arg_i64',
76
+ 'wrun_arg_f32',
77
+ 'wrun_arg_f64',
78
+ 'wrun_output_f64',
79
+ 'wrun_result_write',
80
+ 'wrun_arg_len',
81
+ 'wrun_arg_bytes',
82
+ 'wrun_param_len',
83
+ 'wrun_param_bytes',
84
+ ]);
85
+ const stampImportsByModule = new WeakMap();
86
+ /** Whether every import of a module is on the kit's per-bar list (`WRUN_STAMP_IMPORTS`), read once per
87
+ * module; a module the engine cannot read answers false. */
88
+ export function wrunStampCorroborated(module) {
89
+ const known = stampImportsByModule.get(module);
90
+ if (known !== undefined)
91
+ return known;
92
+ let within = false;
93
+ try {
94
+ within = WebAssembly.Module.imports(module).every((entry) => WRUN_STAMP_IMPORTS.has(entry.name));
95
+ }
96
+ catch {
97
+ // Not a module the engine can read: never corroborated.
98
+ }
99
+ stampImportsByModule.set(module, within);
100
+ return within;
101
+ }
102
+ // ---------------------------------------------------------------------------------------------------
103
+ // The stamp's sheet facts: the kit's `sheetRefusal` (wrun-history-independence.ts, kit 0.66.0) ported
104
+ // rule for rule, with its helpers (`carries`, `wrunTapeHistorySeconds` of wrun-vocab.ts), so a stamp
105
+ // hand-added to a published sheet answers to the facts the kit checked before it wrote an honest one.
106
+ // The kit's decision is not reachable here without loading the whole kit on the main thread;
107
+ // wrun-bar-count.util.spec.ts holds the port to the kit's own answers once the kit exports it.
108
+ // ---------------------------------------------------------------------------------------------------
109
+ /** The sheet sections whose presence refuses (the kit's REFUSED_SHEET_KEYS): each keeps or shows state a
110
+ * later bar reads (a handle, a string slot, a drawing, a frame), draws across bars (renderers, levels,
111
+ * panels), or runs a broker or an alert over the whole series. Present means not undefined: an empty
112
+ * section and a null one refuse too. */
113
+ const STAMP_REFUSED_SHEET_KEYS = [
114
+ 'handles',
115
+ 'string_slots',
116
+ 'drawings',
117
+ 'renderers',
118
+ 'frames',
119
+ 'levels',
120
+ 'panels',
121
+ 'strategy',
122
+ 'alerts',
123
+ ];
124
+ /** The ABIs without the row count (wrun-6's `wrun_bar_count`); an absent `abi_version` is wrun-1. */
125
+ const STAMP_BAR_COUNT_FREE_ABIS = ['wrun-1', 'wrun-2', 'wrun-3', 'wrun-4', 'wrun-5'];
126
+ /** A tape `history` duration: digits, then a unit. "0" alone is the live edge (the default). */
127
+ const TAPE_HISTORY_RE = /^(\d+)(s|m|h|d)$/;
128
+ const TAPE_HISTORY_UNIT_SEC = { s: 1, m: 60, h: 3600, d: 86_400 };
129
+ /** The seconds a tape input's `history` facet reaches back (the kit's `wrunTapeHistorySeconds`): 0 for an
130
+ * absent facet, for "0" and for a zero-length duration ("0m"), the duration's length otherwise, NaN for
131
+ * any other spelling. */
132
+ function tapeHistorySeconds(history) {
133
+ if (history === undefined || history === '0')
134
+ return 0;
135
+ const match = TAPE_HISTORY_RE.exec(history);
136
+ if (match === null)
137
+ return Number.NaN;
138
+ return Number(match[1]) * (TAPE_HISTORY_UNIT_SEC[match[2]] ?? Number.NaN);
139
+ }
140
+ function isRecord(value) {
141
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
142
+ }
143
+ /** The first sheet fact that reads or draws beyond the bar at hand, in the kit's own words
144
+ * (`sheet:<fact>[:<name>]`); undefined when the sheet passes. */
145
+ export function wrunStampSheetRefusal(sheet) {
146
+ if (!isRecord(sheet))
147
+ return 'sheet:invalid';
148
+ for (const key of STAMP_REFUSED_SHEET_KEYS) {
149
+ if (sheet[key] !== undefined)
150
+ return `sheet:${key}`;
151
+ }
152
+ if (sheet.abi_version !== undefined && !STAMP_BAR_COUNT_FREE_ABIS.includes(sheet.abi_version)) {
153
+ return `sheet:abi_version:${String(sheet.abi_version)}`;
154
+ }
155
+ const inputSources = sheet.inputSources;
156
+ if (!isRecord(inputSources))
157
+ return 'sheet:inputSources';
158
+ const inputs = Array.isArray(sheet.inputs) ? sheet.inputs : [];
159
+ for (const [name, source] of Object.entries(inputSources)) {
160
+ if (!isRecord(source))
161
+ return `sheet:input:${name}`;
162
+ // A leg (an `interval` or a `view` option), a leg stream (candles, oi_candles, volume_profile_candles) or an
163
+ // intrabar input: its first delivered rows depend on where the run starts (a view such as `is_new_period`
164
+ // reads 1 on the first delivered row; a stream's first block carries its backlog from before the window).
165
+ if (source.interval !== undefined ||
166
+ source.view !== undefined ||
167
+ isWrunLegStreamClass(source.source) ||
168
+ source.source === 'intrabar') {
169
+ return `sheet:input-leg:${name}`;
170
+ }
171
+ // A leg's or a candles stream's fetch depth: the bar reads earlier candles.
172
+ if (source.bars !== undefined)
173
+ return `sheet:input-bars:${name}`;
174
+ // A tape lookback: the host seeds prints from before the run's window; a zero-length spelling ("0",
175
+ // the default) is the live edge alone.
176
+ if (source.history !== undefined) {
177
+ if (typeof source.history !== 'string' || tapeHistorySeconds(source.history) !== 0) {
178
+ return `sheet:input-history:${name}`;
179
+ }
180
+ }
181
+ const input = inputs.find((entry) => isRecord(entry) && entry.name === name);
182
+ if (carries(source, isRecord(input) ? input : undefined))
183
+ return `sheet:input-carry:${name}`;
184
+ }
185
+ const outputs = Array.isArray(sheet.outputs) ? sheet.outputs : [];
186
+ for (const output of outputs) {
187
+ if (!isRecord(output))
188
+ return 'sheet:outputs';
189
+ if (output.displacement_bars !== undefined || output.displacement_bars_by !== undefined) {
190
+ return `sheet:output-displacement:${String(output.name)}`;
191
+ }
192
+ }
193
+ return undefined;
194
+ }
195
+ /** Whether an input can hand a bar a value observed on an earlier bar (the kit's `carries`): `missing:
196
+ * "carry"`, or the default that means it (a series source, and any other scalar input beside the primary
197
+ * that is not the chart's own candle or time feed, which observes every bar). A celled input reads an
198
+ * empty block on a bar with no observation; "nan", "zero" and "empty" carry nothing. */
199
+ function carries(source, input) {
200
+ if (source.missing === 'carry')
201
+ return true;
202
+ if (source.missing !== undefined)
203
+ return false;
204
+ if (source.source === 'series')
205
+ return true;
206
+ if (input !== undefined && input.cellType === 'array')
207
+ return false;
208
+ if (input !== undefined && input.index === 0)
209
+ return false;
210
+ const chartFeed = (source.source === 'ohlcv' || source.source === 'time') &&
211
+ Object.keys(source).every((key) => key === 'source' || key === 'field' || source[key] === undefined);
212
+ return !chartFeed;
213
+ }
214
+ // ---------------------------------------------------------------------------------------------------
215
+ // The exact warm-up stamp (`history_warmup`): read, its sheet fact, the candles-only rule.
216
+ // ---------------------------------------------------------------------------------------------------
217
+ /** The sheet's raw exact warm-up stamp: its `history_warmup` in the frozen shape (wrun-declared-warmup.util
218
+ * `wrunHistoryWarmupOf`), undefined for no key, another kind or a malformed value. The chart admits a
219
+ * session on it only once the module and the sheet corroborate it (wrun-overlay-run.util). */
220
+ export function wrunWarmupStampOf(sheet) {
221
+ return isRecord(sheet) ? wrunHistoryWarmupOf(sheet.history_warmup) : undefined;
222
+ }
223
+ /** The first sheet fact that refuses an exact warm-up stamp: `sheet:history-both` for a sheet that also carries
224
+ * `history_independent` (the kit writes one stamp or the other, never both: a sheet holding both was assembled
225
+ * by hand), then the per-bar stamp's own sheet facts (`wrunStampSheetRefusal`, the same rules: a warm-up module
226
+ * carries kit instances, never a handle, a string slot, a leg or a carried input); undefined when it passes. */
227
+ export function wrunWarmupSheetRefusal(sheet) {
228
+ if (isRecord(sheet) && sheet.history_independent !== undefined)
229
+ return 'sheet:history-both';
230
+ return wrunStampSheetRefusal(sheet);
231
+ }
232
+ /** The input-source keys a chart-feed input may carry: the chart's own feed field and its missing policy. */
233
+ const CHART_FEED_SOURCE_KEYS = new Set(['source', 'field', 'missing']);
234
+ /** Whether one input reads the chart's own feed, the chart-feed shape (the plan's D3, the kit's `sheet:lanes`
235
+ * rule): `ohlcv` or `time`, with no key besides source, field and missing (no market, interval, view or depth of
236
+ * its own) and no cells. A row of the chart's candles carries every such input itself: its prices, and the bar
237
+ * times read off its own open. The exact warm-up rule below reads it, and the prefix lanes rule reads it for a
238
+ * `time` input (wrun-overlay-run.util). */
239
+ export function wrunInputReadsChartFeed(input, source) {
240
+ if (!isRecord(source) || (source.source !== 'ohlcv' && source.source !== 'time'))
241
+ return false;
242
+ if (isRecord(input) && input.cellType !== undefined)
243
+ return false;
244
+ return Object.keys(source).every((key) => CHART_FEED_SOURCE_KEYS.has(key) || source[key] === undefined);
245
+ }
246
+ /** Whether every input the sheet declares reads the chart's own feed (`wrunInputReadsChartFeed`). Those are the
247
+ * only rows an exact warm-up session's hidden head carries: its candles, and the bar times read off their own
248
+ * opens. A sheet with no input reads nothing a head could feed and is not candles-only. */
249
+ export function wrunWarmupSheetReadsCandlesOnly(sheet) {
250
+ if (!isRecord(sheet) || !isRecord(sheet.inputSources) || !Array.isArray(sheet.inputs))
251
+ return false;
252
+ if (sheet.inputs.length === 0)
253
+ return false;
254
+ const sources = sheet.inputSources;
255
+ return sheet.inputs.every((input) => {
256
+ const name = isRecord(input) ? input.name : undefined;
257
+ return wrunInputReadsChartFeed(input, typeof name === 'string' ? sources[name] : undefined);
258
+ });
259
+ }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * The chart names a WRUN run's `{{symbol}}`, `{{exchange}}` and
3
+ * `{{timeframe}}` placeholders read (KITS-ROUND-2-PLAN, "Chart-name
4
+ * placeholders"), resolved on the main thread per chart index exactly the
5
+ * way the chart header shows them:
6
+ *
7
+ * - symbol: the TickerBar's display symbol (useSymbolData's `displaySymbol`,
8
+ * built on `resolveChartSymbolData`: the "prefix+coin+quote" of a market, a
9
+ * formula's expression by labels, an economic series' label, a prediction
10
+ * market's title; the raw metadata symbol before the resolve lands).
11
+ * - exchange: the header's display exchange name (TBSymbolButton: a
12
+ * prediction market's `formatEnhancedExchangeName` upper-cased, a formula's
13
+ * one venue label, an economic series' publisher label, else
14
+ * `formatExchangeDisplay` over the venue and `displayTransformations`).
15
+ * - timeframe: the short label the interval button shows (the replay
16
+ * display interval when replaying, else the chart interval word).
17
+ *
18
+ * The resolve is async (the symbol lookup). A run resolves its names beside
19
+ * its fetches and integrates with the names IT resolved; the names a live
20
+ * session was integrated with ride beside the session's live context
21
+ * (`rememberWrunSessionChartNames`, set by the full run and the reseed) and
22
+ * the live tick and the latest-values snapshot read them from there, so a
23
+ * superseded run's late lookup can never retitle a later session. The
24
+ * per-chart "latest" record (`wrunChartNamesFor`) is written only by the
25
+ * newest resolve started for that chart: every write is fenced by a token
26
+ * captured at the resolve's start and a stale resolve is dropped. Main
27
+ * thread only: the header formatters reach i18n, which the worker graph must
28
+ * not.
29
+ */
30
+ import type { WrunSymbolDisplayData } from '../../host-ports.types.js';
31
+ import type { WrunChartNames } from './wrun-chart-context.util.js';
32
+ /** The chart metadata slice the names read. */
33
+ export interface WrunChartNameSource {
34
+ symbol?: unknown;
35
+ exchange?: unknown;
36
+ interval?: unknown;
37
+ displayTransformations?: unknown;
38
+ polymarketMetadata?: {
39
+ fullName?: unknown;
40
+ title?: unknown;
41
+ } | null;
42
+ }
43
+ /** The header's display symbol (useSymbolData's `displaySymbol`): a
44
+ * prediction market's title, a formula's labelled expression, an economic
45
+ * series' label, else "prefix+coin+quote" (a pool address appended), and
46
+ * the raw metadata symbol while nothing is resolved. On a plain market the
47
+ * three parts are slices of the venue's own symbol, so the name is that
48
+ * symbol, the string a kScript's `currentSymbol` reads on the same chart
49
+ * (1000PEPEUSDT keeps its 1000, KRW-RLUSD its KRW-). */
50
+ export declare function wrunChartDisplaySymbol(meta: WrunChartNameSource | undefined, data: WrunSymbolDisplayData | null | undefined): string;
51
+ /** The header's display exchange name (TBSymbolButton): a prediction
52
+ * market's short venue label upper-cased (HYPERLIQUID_HIP4 reads "HL
53
+ * HIP4"), a formula's one venue label, an economic series' resolved
54
+ * publisher label, else `formatExchangeDisplay` over the venue and
55
+ * `displayTransformations`. */
56
+ export declare function wrunChartDisplayExchange(meta: WrunChartNameSource | undefined, data: WrunSymbolDisplayData | null | undefined): string;
57
+ /** The short label the interval button shows: the replay display interval
58
+ * while replaying, else the chart interval word ('15m', '1h'). */
59
+ export declare function wrunChartTimeframe(meta: WrunChartNameSource | undefined, displayInterval: unknown): string;
60
+ /** Keep the names a live session was integrated with beside its live
61
+ * context (the full run's install, the reseed's commit); undefined forgets. */
62
+ export declare function rememberWrunSessionChartNames(session: object, names: WrunChartNames | undefined): void;
63
+ /** The names a live session was integrated with (the live tick's and the
64
+ * snapshot's synchronous read); undefined for a session that resolved none. */
65
+ export declare function wrunSessionChartNamesOf(session: object | undefined): WrunChartNames | undefined;
66
+ /** The newest resolve's names for a chart (fenced: a late, superseded
67
+ * resolve never writes it); undefined before any resolve. Diagnostic and
68
+ * fallback reader; the run path reads its session's names instead. */
69
+ export declare function wrunChartNamesFor(chartIndex: number): WrunChartNames | undefined;
70
+ export declare function __resetWrunChartNamesForTests(): void;
71
+ /**
72
+ * Resolve a chart's names off the store and the header's symbol resolver.
73
+ * The chart metadata is read at the start (the names describe the chart the
74
+ * run computes on), the symbol lookup follows; the per-chart latest record
75
+ * is written only when no newer resolve for the chart started meanwhile
76
+ * (the token captured here), so a superseded run's late answer is dropped
77
+ * there while the run itself still receives its own names. Never throws: a
78
+ * chart that is gone answers undefined; a symbol resolve that fails (or a
79
+ * store the spec did not stand up) falls back to the raw metadata names, the
80
+ * way the header shows the raw symbol before its resolve lands. The store
81
+ * and the resolver are loaded lazily: their graphs are heavy and only a run
82
+ * needs them here.
83
+ */
84
+ export declare function resolveWrunChartNames(chartIndex: number): Promise<WrunChartNames | undefined>;