@orangecharts/wrun-chart-host 0.4.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 (322) hide show
  1. package/README.md +15 -4
  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/cme-official-scripts.constants.d.ts +168 -0
  11. package/dist/constants/scriptEditor/cme-official-scripts.constants.js +398 -0
  12. package/dist/constants/scriptEditor/converted-script-id.leaf.d.ts +8 -0
  13. package/dist/constants/scriptEditor/converted-script-id.leaf.js +10 -0
  14. package/dist/constants/scriptEditor/execution.constants.d.ts +4 -0
  15. package/dist/constants/scriptEditor/execution.constants.js +14 -0
  16. package/dist/constants/wrun-prefix-safe.constants.d.ts +23 -0
  17. package/dist/constants/wrun-prefix-safe.constants.js +26 -0
  18. package/dist/host-env.d.ts +313 -18
  19. package/dist/host-env.js +15 -0
  20. package/dist/host-ports.types.d.ts +853 -16
  21. package/dist/index.d.ts +139 -2
  22. package/dist/index.js +139 -2
  23. package/dist/instances/script-engine-worker-ohlcv-transfer.d.ts +31 -0
  24. package/dist/instances/script-engine-worker-ohlcv-transfer.js +164 -0
  25. package/dist/interfaces/market-event.interface.d.ts +231 -0
  26. package/dist/interfaces/market-event.interface.js +15 -0
  27. package/dist/interfaces/opra-realtime.interface.d.ts +70 -134
  28. package/dist/interfaces/opra-realtime.interface.js +34 -59
  29. package/dist/interfaces/replay.interface.d.ts +285 -0
  30. package/dist/interfaces/replay.interface.js +1 -0
  31. package/dist/kscript-data/controls/live-ohlcv-merge.util.d.ts +1 -0
  32. package/dist/kscript-data/controls/live-ohlcv-merge.util.js +93 -0
  33. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +5 -1
  34. package/dist/kscript-data/controls/live-trades-merge.util.js +2 -2
  35. package/dist/market-data/billing.interface.d.ts +219 -0
  36. package/dist/market-data/billing.interface.js +58 -0
  37. package/dist/market-data/venue-governed.util.d.ts +2 -0
  38. package/dist/market-data/venue-governed.util.js +10 -0
  39. package/dist/market-data/venue.d.ts +122 -0
  40. package/dist/market-data/venue.js +1 -0
  41. package/dist/market-data/venues/index.d.ts +97 -0
  42. package/dist/market-data/venues/index.js +33 -0
  43. package/dist/market-data/venues/opra.contract.copy.json +35 -0
  44. package/dist/market-data/venues/opra.d.ts +70 -0
  45. package/dist/market-data/venues/opra.js +74 -0
  46. package/dist/replay/replayIndicatorRows.d.ts +31 -0
  47. package/dist/replay/replayIndicatorRows.js +117 -0
  48. package/dist/replay/replayLadder.d.ts +85 -0
  49. package/dist/replay/replayLadder.js +388 -0
  50. package/dist/utility/auth/server-clock.util.d.ts +81 -0
  51. package/dist/utility/auth/server-clock.util.js +238 -0
  52. package/dist/utility/chart/builtin-identity.util.d.ts +18 -0
  53. package/dist/utility/chart/builtin-identity.util.js +51 -0
  54. package/dist/utility/chart/cache-alignment.util.d.ts +454 -0
  55. package/dist/utility/chart/cache-alignment.util.js +926 -0
  56. package/dist/utility/chart/chart-data-fetch-generation.util.d.ts +15 -0
  57. package/dist/utility/chart/chart-data-fetch-generation.util.js +22 -0
  58. package/dist/utility/chart/chart-mount-epoch.util.d.ts +5 -0
  59. package/dist/utility/chart/chart-mount-epoch.util.js +29 -0
  60. package/dist/utility/chart/chart-time-domain.util.d.ts +12 -0
  61. package/dist/utility/chart/chart-time-domain.util.js +23 -0
  62. package/dist/utility/chart/color-customization.leaf.d.ts +10 -0
  63. package/dist/utility/chart/color-customization.leaf.js +16 -0
  64. package/dist/utility/chart/footprint-tick-grid.util.d.ts +106 -0
  65. package/dist/utility/chart/footprint-tick-grid.util.js +167 -0
  66. package/dist/utility/chart/gesture-timing.leaf.d.ts +29 -0
  67. package/dist/utility/chart/gesture-timing.leaf.js +29 -0
  68. package/dist/utility/chart/governed-contract-coin.util.d.ts +22 -0
  69. package/dist/utility/chart/governed-contract-coin.util.js +39 -0
  70. package/dist/utility/chart/host-bar-placement.util.d.ts +107 -0
  71. package/dist/utility/chart/host-bar-placement.util.js +447 -0
  72. package/dist/utility/chart/index-host-tier.util.d.ts +31 -0
  73. package/dist/utility/chart/index-host-tier.util.js +118 -0
  74. package/dist/utility/chart/index-mode-admission.util.d.ts +34 -0
  75. package/dist/utility/chart/index-mode-admission.util.js +67 -0
  76. package/dist/utility/chart/indicator-error-message.util.d.ts +35 -0
  77. package/dist/utility/chart/indicator-error-message.util.js +44 -0
  78. package/dist/utility/chart/kscript-apply-fingerprint.util.d.ts +65 -0
  79. package/dist/utility/chart/kscript-apply-fingerprint.util.js +357 -0
  80. package/dist/utility/chart/kscript-chart-flush.leaf.d.ts +22 -0
  81. package/dist/utility/chart/kscript-chart-flush.leaf.js +13 -0
  82. package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +6 -0
  83. package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +27 -0
  84. package/dist/utility/chart/kscript-integration-decision.leaf.d.ts +89 -0
  85. package/dist/utility/chart/kscript-integration-decision.leaf.js +80 -0
  86. package/dist/utility/chart/kscript-live-coalesce.util.d.ts +76 -0
  87. package/dist/utility/chart/kscript-live-coalesce.util.js +156 -0
  88. package/dist/utility/chart/kscript-live-rest-pace.util.d.ts +34 -0
  89. package/dist/utility/chart/kscript-live-rest-pace.util.js +134 -0
  90. package/dist/utility/chart/kscript-live-source-identity.util.d.ts +98 -0
  91. package/dist/utility/chart/kscript-live-source-identity.util.js +121 -0
  92. package/dist/utility/chart/kscript-mounted-plot-set.leaf.d.ts +48 -0
  93. package/dist/utility/chart/kscript-mounted-plot-set.leaf.js +145 -0
  94. package/dist/utility/chart/kscript-perf-tracker.util.d.ts +243 -0
  95. package/dist/utility/chart/kscript-perf-tracker.util.js +522 -0
  96. package/dist/utility/chart/kscript-run-interval-projection.util.d.ts +43 -0
  97. package/dist/utility/chart/kscript-run-interval-projection.util.js +471 -0
  98. package/dist/utility/chart/kscript-run-result-equality.util.d.ts +38 -0
  99. package/dist/utility/chart/kscript-run-result-equality.util.js +89 -0
  100. package/dist/utility/chart/kscript-settings-revision.leaf.d.ts +2 -0
  101. package/dist/utility/chart/kscript-settings-revision.leaf.js +12 -0
  102. package/dist/utility/chart/kscript-source-degrade.leaf.d.ts +63 -0
  103. package/dist/utility/chart/kscript-source-degrade.leaf.js +68 -0
  104. package/dist/utility/chart/kscript-source-retention.util.d.ts +134 -0
  105. package/dist/utility/chart/kscript-source-retention.util.js +218 -0
  106. package/dist/utility/chart/kscript-standin-identity.leaf.d.ts +57 -0
  107. package/dist/utility/chart/kscript-standin-identity.leaf.js +61 -0
  108. package/dist/utility/chart/kscript-titancharts-preparation.util.d.ts +15 -0
  109. package/dist/utility/chart/kscript-titancharts-preparation.util.js +376 -0
  110. package/dist/utility/chart/kscript-titancharts-render-keys.constants.d.ts +9 -0
  111. package/dist/utility/chart/kscript-titancharts-render-keys.constants.js +130 -0
  112. package/dist/utility/chart/kscript-venue-policy.util.d.ts +217 -0
  113. package/dist/utility/chart/kscript-venue-policy.util.js +324 -0
  114. package/dist/utility/chart/live-cadence.util.d.ts +38 -0
  115. package/dist/utility/chart/live-cadence.util.js +37 -0
  116. package/dist/utility/chart/live-feed-series-match.leaf.d.ts +13 -0
  117. package/dist/utility/chart/live-feed-series-match.leaf.js +21 -0
  118. package/dist/utility/chart/local-engine-self-heal-backoff.util.d.ts +46 -0
  119. package/dist/utility/chart/local-engine-self-heal-backoff.util.js +46 -0
  120. package/dist/utility/chart/local-engine-uninit.leaf.d.ts +21 -0
  121. package/dist/utility/chart/local-engine-uninit.leaf.js +22 -0
  122. package/dist/utility/chart/local-kscript-source-revalidation.util.d.ts +62 -0
  123. package/dist/utility/chart/local-kscript-source-revalidation.util.js +123 -0
  124. package/dist/utility/chart/local-kscript-warmup-depth.util.d.ts +214 -0
  125. package/dist/utility/chart/local-kscript-warmup-depth.util.js +376 -0
  126. package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.d.ts +85 -0
  127. package/dist/utility/chart/local-technical-script-live-apply-coalescer.util.js +197 -0
  128. package/dist/utility/chart/local-technical-script-range.leaf.d.ts +72 -0
  129. package/dist/utility/chart/local-technical-script-range.leaf.js +126 -0
  130. package/dist/utility/chart/mixed-mode.util.d.ts +167 -0
  131. package/dist/utility/chart/mixed-mode.util.js +139 -0
  132. package/dist/utility/chart/ohlcv-row-readiness.util.d.ts +36 -0
  133. package/dist/utility/chart/ohlcv-row-readiness.util.js +90 -0
  134. package/dist/utility/chart/opra-user-scripts-gate.util.d.ts +19 -0
  135. package/dist/utility/chart/opra-user-scripts-gate.util.js +32 -0
  136. package/dist/utility/chart/overlay-execution-guard-key.leaf.d.ts +8 -0
  137. package/dist/utility/chart/overlay-execution-guard-key.leaf.js +10 -0
  138. package/dist/utility/chart/price-precision.util.d.ts +40 -0
  139. package/dist/utility/chart/price-precision.util.js +70 -0
  140. package/dist/utility/chart/profile-block-size.util.d.ts +64 -0
  141. package/dist/utility/chart/profile-block-size.util.js +141 -0
  142. package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.d.ts +11 -0
  143. package/dist/utility/chart/protected-kscript-degenerate-rows.leaf.js +29 -0
  144. package/dist/utility/chart/protected-kscript-empty-output.util.d.ts +28 -0
  145. package/dist/utility/chart/protected-kscript-empty-output.util.js +84 -0
  146. package/dist/utility/chart/run-interval-unservable.leaf.d.ts +9 -0
  147. package/dist/utility/chart/run-interval-unservable.leaf.js +20 -0
  148. package/dist/utility/chart/run-interval-warmup.leaf.d.ts +19 -0
  149. package/dist/utility/chart/run-interval-warmup.leaf.js +35 -0
  150. package/dist/utility/chart/titan-constants.pin.d.ts +9 -5
  151. package/dist/utility/chart/titan-constants.pin.js +18 -5
  152. package/dist/utility/chart/warmup-backfill-retry.leaf.d.ts +9 -0
  153. package/dist/utility/chart/warmup-backfill-retry.leaf.js +9 -0
  154. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +11 -2
  155. package/dist/utility/chart/wrun-bar-session-facts.util.js +10 -3
  156. package/dist/utility/chart/wrun-run-result.util.d.ts +5 -1
  157. package/dist/utility/chart/wrun-run-result.util.js +20 -14
  158. package/dist/utility/common/data-processing.util.d.ts +138 -0
  159. package/dist/utility/common/data-processing.util.js +346 -0
  160. package/dist/utility/common/visible-timeout.util.d.ts +13 -4
  161. package/dist/utility/common/visible-timeout.util.js +23 -8
  162. package/dist/utility/exchange-format.leaf.d.ts +1 -0
  163. package/dist/utility/exchange-format.leaf.js +47 -0
  164. package/dist/utility/market-events/earnings-scope.util.d.ts +60 -0
  165. package/dist/utility/market-events/earnings-scope.util.js +92 -0
  166. package/dist/utility/market-events/market-events.util.d.ts +147 -0
  167. package/dist/utility/market-events/market-events.util.js +392 -0
  168. package/dist/utility/market-events/zoned-clock.util.d.ts +1 -0
  169. package/dist/utility/market-events/zoned-clock.util.js +11 -0
  170. package/dist/utility/options/option-venue-disclosure.util.d.ts +43 -0
  171. package/dist/utility/options/option-venue-disclosure.util.js +56 -0
  172. package/dist/utility/scriptEditor/package-semver.util.d.ts +51 -0
  173. package/dist/utility/scriptEditor/package-semver.util.js +120 -0
  174. package/dist/utility/scriptEditor/temp-script-id.util.d.ts +18 -0
  175. package/dist/utility/scriptEditor/temp-script-id.util.js +25 -0
  176. package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.d.ts +20 -0
  177. package/dist/utility/symbol-selection/markets-request-from-symbols.leaf.js +81 -0
  178. package/dist/utility/v2/governed-tier.leaf.d.ts +103 -0
  179. package/dist/utility/v2/governed-tier.leaf.js +113 -0
  180. package/dist/utility/watchlist/import/import-request.leaf.d.ts +10 -0
  181. package/dist/utility/watchlist/import/import-request.leaf.js +10 -0
  182. package/dist/utility/wrun/sources/lanes/series.js +2 -2
  183. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +4 -4
  184. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +5 -6
  185. package/dist/utility/wrun/wrun-alert-outputs.registry.d.ts +166 -0
  186. package/dist/utility/wrun/wrun-alert-outputs.registry.js +219 -0
  187. package/dist/utility/wrun/wrun-bar-count.util.d.ts +83 -0
  188. package/dist/utility/wrun/wrun-bar-count.util.js +259 -0
  189. package/dist/utility/wrun/wrun-chart-context-names.util.d.ts +84 -0
  190. package/dist/utility/wrun/wrun-chart-context-names.util.js +186 -0
  191. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +253 -0
  192. package/dist/utility/wrun/wrun-chart-market-facts.util.js +731 -0
  193. package/dist/utility/wrun/wrun-cloud-opra-stamp.util.d.ts +28 -0
  194. package/dist/utility/wrun/wrun-cloud-opra-stamp.util.js +45 -0
  195. package/dist/utility/wrun/wrun-coin-lane-live.util.d.ts +18 -0
  196. package/dist/utility/wrun/wrun-coin-lane-live.util.js +47 -0
  197. package/dist/utility/wrun/wrun-deadline.util.js +2 -1
  198. package/dist/utility/wrun/wrun-debug-output.util.d.ts +39 -0
  199. package/dist/utility/wrun/wrun-debug-output.util.js +63 -0
  200. package/dist/utility/wrun/wrun-declared-warmup.util.d.ts +113 -0
  201. package/dist/utility/wrun/wrun-declared-warmup.util.js +181 -0
  202. package/dist/utility/wrun/wrun-draft-legend-note.util.d.ts +43 -0
  203. package/dist/utility/wrun/wrun-draft-legend-note.util.js +158 -0
  204. package/dist/utility/wrun/wrun-draft-overlay.util.d.ts +181 -0
  205. package/dist/utility/wrun/wrun-draft-overlay.util.js +357 -0
  206. package/dist/utility/wrun/wrun-draw-skipped.leaf.d.ts +16 -0
  207. package/dist/utility/wrun/wrun-draw-skipped.leaf.js +16 -0
  208. package/dist/utility/wrun/wrun-earnings-facts.util.d.ts +42 -0
  209. package/dist/utility/wrun/wrun-earnings-facts.util.js +131 -0
  210. package/dist/utility/wrun/wrun-first-run-depth.util.d.ts +32 -0
  211. package/dist/utility/wrun/wrun-first-run-depth.util.js +118 -0
  212. package/dist/utility/wrun/wrun-gate-plane-readers.util.d.ts +24 -0
  213. package/dist/utility/wrun/wrun-gate-plane-readers.util.js +31 -0
  214. package/dist/utility/wrun/wrun-held-lanes.util.d.ts +32 -0
  215. package/dist/utility/wrun/wrun-held-lanes.util.js +94 -0
  216. package/dist/utility/wrun/wrun-host-visible-clock.util.d.ts +2 -0
  217. package/dist/utility/wrun/wrun-host-visible-clock.util.js +17 -0
  218. package/dist/utility/wrun/wrun-host.service.d.ts +266 -0
  219. package/dist/utility/wrun/wrun-host.service.js +655 -0
  220. package/dist/utility/wrun/wrun-inert-legend.util.d.ts +33 -0
  221. package/dist/utility/wrun/wrun-inert-legend.util.js +125 -0
  222. package/dist/utility/wrun/wrun-input-requirements.leaf.d.ts +155 -0
  223. package/dist/utility/wrun/wrun-input-requirements.leaf.js +450 -0
  224. package/dist/utility/wrun/wrun-integration-route.util.d.ts +51 -0
  225. package/dist/utility/wrun/wrun-integration-route.util.js +59 -0
  226. package/dist/utility/wrun/wrun-latest-history.leaf.d.ts +8 -0
  227. package/dist/utility/wrun/wrun-latest-history.leaf.js +8 -0
  228. package/dist/utility/wrun/wrun-legend-hover.lazy.d.ts +12 -0
  229. package/dist/utility/wrun/wrun-legend-hover.lazy.js +96 -0
  230. package/dist/utility/wrun/wrun-lifecycle-runtime.util.d.ts +21 -0
  231. package/dist/utility/wrun/wrun-lifecycle-runtime.util.js +21 -0
  232. package/dist/utility/wrun/wrun-live-hidden-hold.util.d.ts +23 -0
  233. package/dist/utility/wrun/wrun-live-hidden-hold.util.js +13 -0
  234. package/dist/utility/wrun/wrun-live-intake.util.d.ts +374 -0
  235. package/dist/utility/wrun/wrun-live-intake.util.js +2027 -0
  236. package/dist/utility/wrun/wrun-live-patch.util.d.ts +116 -0
  237. package/dist/utility/wrun/wrun-live-patch.util.js +523 -0
  238. package/dist/utility/wrun/wrun-live-tick.util.d.ts +619 -0
  239. package/dist/utility/wrun/wrun-live-tick.util.js +4974 -0
  240. package/dist/utility/wrun/wrun-loading-owner.util.d.ts +58 -0
  241. package/dist/utility/wrun/wrun-loading-owner.util.js +89 -0
  242. package/dist/utility/wrun/wrun-official-scope.leaf.d.ts +29 -0
  243. package/dist/utility/wrun/wrun-official-scope.leaf.js +36 -0
  244. package/dist/utility/wrun/wrun-oi-lane.util.d.ts +27 -0
  245. package/dist/utility/wrun/wrun-oi-lane.util.js +42 -0
  246. package/dist/utility/wrun/wrun-options-stop.util.d.ts +52 -0
  247. package/dist/utility/wrun/wrun-options-stop.util.js +123 -0
  248. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +719 -0
  249. package/dist/utility/wrun/wrun-overlay-drivers.util.js +1180 -0
  250. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.d.ts +50 -0
  251. package/dist/utility/wrun/wrun-overlay-lifecycle.lazy.js +131 -0
  252. package/dist/utility/wrun/wrun-overlay-lifecycle.util.d.ts +118 -0
  253. package/dist/utility/wrun/wrun-overlay-lifecycle.util.js +466 -0
  254. package/dist/utility/wrun/wrun-overlay-metadata.util.d.ts +45 -0
  255. package/dist/utility/wrun/wrun-overlay-metadata.util.js +112 -0
  256. package/dist/utility/wrun/wrun-overlay-recovery.util.d.ts +114 -0
  257. package/dist/utility/wrun/wrun-overlay-recovery.util.js +971 -0
  258. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +858 -0
  259. package/dist/utility/wrun/wrun-overlay-run.util.js +11013 -0
  260. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +24 -9
  261. package/dist/utility/wrun/wrun-panel-mount.util.js +138 -43
  262. package/dist/utility/wrun/wrun-param-map.util.d.ts +19 -4
  263. package/dist/utility/wrun/wrun-param-map.util.js +40 -47
  264. package/dist/utility/wrun/wrun-param-values.util.d.ts +9 -3
  265. package/dist/utility/wrun/wrun-param-values.util.js +5 -5
  266. package/dist/utility/wrun/wrun-prefix-cohort.util.d.ts +93 -0
  267. package/dist/utility/wrun/wrun-prefix-cohort.util.js +484 -0
  268. package/dist/utility/wrun/wrun-prefix-lanes.util.d.ts +114 -0
  269. package/dist/utility/wrun/wrun-prefix-lanes.util.js +486 -0
  270. package/dist/utility/wrun/wrun-prefix-proof.util.d.ts +317 -0
  271. package/dist/utility/wrun/wrun-prefix-proof.util.js +630 -0
  272. package/dist/utility/wrun/wrun-refusal-surface.util.d.ts +73 -0
  273. package/dist/utility/wrun/wrun-refusal-surface.util.js +380 -0
  274. package/dist/utility/wrun/wrun-refusal-text.util.d.ts +15 -0
  275. package/dist/utility/wrun/wrun-refusal-text.util.js +40 -0
  276. package/dist/utility/wrun/wrun-replay-lane.util.d.ts +139 -0
  277. package/dist/utility/wrun/wrun-replay-lane.util.js +520 -0
  278. package/dist/utility/wrun/wrun-replay-rows.util.d.ts +21 -0
  279. package/dist/utility/wrun/wrun-replay-rows.util.js +172 -0
  280. package/dist/utility/wrun/wrun-row-source-factory.d.ts +53 -0
  281. package/dist/utility/wrun/wrun-row-source-factory.js +435 -0
  282. package/dist/utility/wrun/wrun-run-cells.util.d.ts +36 -0
  283. package/dist/utility/wrun/wrun-run-cells.util.js +46 -0
  284. package/dist/utility/wrun/wrun-run-interval-session.util.d.ts +133 -0
  285. package/dist/utility/wrun/wrun-run-interval-session.util.js +121 -0
  286. package/dist/utility/wrun/wrun-run-interval.util.d.ts +98 -0
  287. package/dist/utility/wrun/wrun-run-interval.util.js +207 -0
  288. package/dist/utility/wrun/wrun-run-retained.util.d.ts +122 -0
  289. package/dist/utility/wrun/wrun-run-retained.util.js +255 -0
  290. package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +184 -0
  291. package/dist/utility/wrun/wrun-sandbox-row-source.js +444 -0
  292. package/dist/utility/wrun/wrun-script-inputs.util.js +4 -4
  293. package/dist/utility/wrun/wrun-series-stream.util.d.ts +86 -0
  294. package/dist/utility/wrun/wrun-series-stream.util.js +537 -0
  295. package/dist/utility/wrun/wrun-sheet-remembered.util.d.ts +21 -0
  296. package/dist/utility/wrun/wrun-sheet-remembered.util.js +36 -0
  297. package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.d.ts +7 -0
  298. package/dist/utility/wrun/wrun-signal-sound-reasons.leaf.js +12 -0
  299. package/dist/utility/wrun/wrun-socket-row-source.js +4 -2
  300. package/dist/utility/wrun/wrun-source-rows.util.d.ts +175 -3
  301. package/dist/utility/wrun/wrun-source-rows.util.js +294 -8
  302. package/dist/utility/wrun/wrun-stats-strip.util.d.ts +46 -0
  303. package/dist/utility/wrun/wrun-stats-strip.util.js +87 -0
  304. package/dist/utility/wrun/wrun-table-chrome.util.d.ts +163 -0
  305. package/dist/utility/wrun/wrun-table-chrome.util.js +557 -0
  306. package/dist/utility/wrun/wrun-text-params.util.d.ts +11 -6
  307. package/dist/utility/wrun/wrun-text-params.util.js +19 -30
  308. package/dist/utility/wrun/wrun-transient-rerun.util.d.ts +64 -0
  309. package/dist/utility/wrun/wrun-transient-rerun.util.js +317 -0
  310. package/dist/utility/wrun/wrun-twin-lookback.util.d.ts +10 -0
  311. package/dist/utility/wrun/wrun-twin-lookback.util.js +43 -0
  312. package/dist/utility/wrun/wrun-warmup-head-store.util.d.ts +41 -0
  313. package/dist/utility/wrun/wrun-warmup-head-store.util.js +120 -0
  314. package/dist/utility/wrun-alert-params.leaf.d.ts +24 -0
  315. package/dist/utility/wrun-alert-params.leaf.js +24 -0
  316. package/dist/utils/replay/replay-buffer-math.d.ts +148 -0
  317. package/dist/utils/replay/replay-buffer-math.js +684 -0
  318. package/dist/workers/wrun/wrun-abi-host.d.ts +190 -0
  319. package/dist/workers/wrun/wrun-abi-host.js +1201 -0
  320. package/dist/workers/wrun/wrun-engine-handler.d.ts +37 -0
  321. package/dist/workers/wrun/wrun-engine-handler.js +211 -0
  322. package/package.json +3 -3
@@ -0,0 +1,58 @@
1
+ /**
2
+ * The one owner of a browser-run Indicator's kScript loading flag (the store's
3
+ * `kscriptLoadingIndicators`, whose watchdog adds the "Still loading" chip at 20 s and force-lowers
4
+ * with "Loading stopped" at 75 s). The store keeps one boolean per overlay (`<chartIndex>:<indicatorId>`),
5
+ * so every raiser of the overlay shares it: the restore of a record the chart brings back
6
+ * (wrun-restore-loading.util, from the revive until its first run settles) and each compute pass
7
+ * (wrun-overlay-run.util). Every raise claims the flag here and gets the generation it owns it under;
8
+ * every lower releases that generation, and a raiser writes the flag down only when the release
9
+ * says it still owned it. A superseded raiser therefore never lowers its successor's flag and
10
+ * watchdog (data-loading rule 3: the owner lowers on success, failure, abort and the deadline alike).
11
+ *
12
+ * Who takes the flag:
13
+ * - a restore, always: the record the chart brings back is a new wait, and any pass still in flight
14
+ * for the overlay computes for a chart or a mount that is gone. A second claim of the same restore
15
+ * keeps its generation.
16
+ * - a compute pass, when the flag is down or an earlier pass holds it (a replacement's pass takes it
17
+ * over). A flag a restore holds is left to it (the restored record's first run is the wait the
18
+ * restore already shows), and so is a raised flag nothing here owns (a settings-apply cycle).
19
+ * - a transient grace (wrun-transient-rerun.util), as a pass does, and from a restore too: a restored
20
+ * record's first run failed and the grace's wait for its rerun takes over the restore's, so the
21
+ * restore's release (its first run settled) finds the flag no longer its own and leaves it up.
22
+ *
23
+ * This module only arbitrates: each raiser writes the store itself, and an entry lives while its
24
+ * owner's wait does.
25
+ */
26
+ /**
27
+ * A compute pass's claim, given whether the flag is up: the generation the pass owns it under (the
28
+ * pass then raises it, which re-arms the watchdog for its own pass when an earlier pass held it), or
29
+ * undefined when the flag is left to the restore or the untracked raiser that holds it.
30
+ */
31
+ export declare function claimWrunRunLoading(chartIndex: number, indicatorId: string, flagRaised: boolean): number | undefined;
32
+ /**
33
+ * A transient grace's claim (wrun-transient-rerun.util), given whether the flag is up: owned as a compute pass's
34
+ * (a rerun's own pass takes it over in turn), taken from a pass or from a restore whose first run failed into the
35
+ * grace, and undefined when a raiser nothing here owns holds the raised flag (a settings-apply cycle).
36
+ */
37
+ export declare function claimWrunGraceLoading(chartIndex: number, indicatorId: string, flagRaised: boolean): number | undefined;
38
+ /**
39
+ * A restore's claim. `fresh`: it took the flag from another holder (or found it unowned), so it
40
+ * raises it even when it is up, and the watchdog counts the restored record's own wait. A second
41
+ * claim of the same restore keeps its generation and raises only a flag that is down, never
42
+ * restarting the clock.
43
+ */
44
+ export declare function claimWrunRestoreLoading(chartIndex: number, indicatorId: string): {
45
+ generation: number;
46
+ fresh: boolean;
47
+ };
48
+ /** Whether `generation` still owns the overlay's flag. */
49
+ export declare function ownsWrunLoading(chartIndex: number, indicatorId: string, generation: number | undefined): boolean;
50
+ /** Whether any raiser owns the overlay's flag. */
51
+ export declare function isWrunLoadingOwned(chartIndex: number, indicatorId: string): boolean;
52
+ /**
53
+ * Give the flag up: true when `generation` still owned it (the caller then lowers it), false when a
54
+ * later claim took it over (the flag is that claim's to lower) or nothing was claimed.
55
+ */
56
+ export declare function releaseWrunLoading(chartIndex: number, indicatorId: string, generation: number | undefined): boolean;
57
+ /** Test-only: forget every owner. */
58
+ export declare function __resetWrunLoadingOwnersForTests(): void;
@@ -0,0 +1,89 @@
1
+ /**
2
+ * The one owner of a browser-run Indicator's kScript loading flag (the store's
3
+ * `kscriptLoadingIndicators`, whose watchdog adds the "Still loading" chip at 20 s and force-lowers
4
+ * with "Loading stopped" at 75 s). The store keeps one boolean per overlay (`<chartIndex>:<indicatorId>`),
5
+ * so every raiser of the overlay shares it: the restore of a record the chart brings back
6
+ * (wrun-restore-loading.util, from the revive until its first run settles) and each compute pass
7
+ * (wrun-overlay-run.util). Every raise claims the flag here and gets the generation it owns it under;
8
+ * every lower releases that generation, and a raiser writes the flag down only when the release
9
+ * says it still owned it. A superseded raiser therefore never lowers its successor's flag and
10
+ * watchdog (data-loading rule 3: the owner lowers on success, failure, abort and the deadline alike).
11
+ *
12
+ * Who takes the flag:
13
+ * - a restore, always: the record the chart brings back is a new wait, and any pass still in flight
14
+ * for the overlay computes for a chart or a mount that is gone. A second claim of the same restore
15
+ * keeps its generation.
16
+ * - a compute pass, when the flag is down or an earlier pass holds it (a replacement's pass takes it
17
+ * over). A flag a restore holds is left to it (the restored record's first run is the wait the
18
+ * restore already shows), and so is a raised flag nothing here owns (a settings-apply cycle).
19
+ * - a transient grace (wrun-transient-rerun.util), as a pass does, and from a restore too: a restored
20
+ * record's first run failed and the grace's wait for its rerun takes over the restore's, so the
21
+ * restore's release (its first run settled) finds the flag no longer its own and leaves it up.
22
+ *
23
+ * This module only arbitrates: each raiser writes the store itself, and an entry lives while its
24
+ * owner's wait does.
25
+ */
26
+ const owners = new Map();
27
+ let lastGeneration = 0;
28
+ function keyOf(chartIndex, indicatorId) {
29
+ return `${chartIndex}:${indicatorId}`;
30
+ }
31
+ function take(kind, chartIndex, indicatorId) {
32
+ const generation = ++lastGeneration;
33
+ owners.set(keyOf(chartIndex, indicatorId), { kind, generation });
34
+ return generation;
35
+ }
36
+ /**
37
+ * A compute pass's claim, given whether the flag is up: the generation the pass owns it under (the
38
+ * pass then raises it, which re-arms the watchdog for its own pass when an earlier pass held it), or
39
+ * undefined when the flag is left to the restore or the untracked raiser that holds it.
40
+ */
41
+ export function claimWrunRunLoading(chartIndex, indicatorId, flagRaised) {
42
+ if (flagRaised && owners.get(keyOf(chartIndex, indicatorId))?.kind !== 'run')
43
+ return undefined;
44
+ return take('run', chartIndex, indicatorId);
45
+ }
46
+ /**
47
+ * A transient grace's claim (wrun-transient-rerun.util), given whether the flag is up: owned as a compute pass's
48
+ * (a rerun's own pass takes it over in turn), taken from a pass or from a restore whose first run failed into the
49
+ * grace, and undefined when a raiser nothing here owns holds the raised flag (a settings-apply cycle).
50
+ */
51
+ export function claimWrunGraceLoading(chartIndex, indicatorId, flagRaised) {
52
+ if (flagRaised && !owners.has(keyOf(chartIndex, indicatorId)))
53
+ return undefined;
54
+ return take('run', chartIndex, indicatorId);
55
+ }
56
+ /**
57
+ * A restore's claim. `fresh`: it took the flag from another holder (or found it unowned), so it
58
+ * raises it even when it is up, and the watchdog counts the restored record's own wait. A second
59
+ * claim of the same restore keeps its generation and raises only a flag that is down, never
60
+ * restarting the clock.
61
+ */
62
+ export function claimWrunRestoreLoading(chartIndex, indicatorId) {
63
+ const owner = owners.get(keyOf(chartIndex, indicatorId));
64
+ if (owner?.kind === 'restore')
65
+ return { generation: owner.generation, fresh: false };
66
+ return { generation: take('restore', chartIndex, indicatorId), fresh: true };
67
+ }
68
+ /** Whether `generation` still owns the overlay's flag. */
69
+ export function ownsWrunLoading(chartIndex, indicatorId, generation) {
70
+ return generation !== undefined && owners.get(keyOf(chartIndex, indicatorId))?.generation === generation;
71
+ }
72
+ /** Whether any raiser owns the overlay's flag. */
73
+ export function isWrunLoadingOwned(chartIndex, indicatorId) {
74
+ return owners.has(keyOf(chartIndex, indicatorId));
75
+ }
76
+ /**
77
+ * Give the flag up: true when `generation` still owned it (the caller then lowers it), false when a
78
+ * later claim took it over (the flag is that claim's to lower) or nothing was claimed.
79
+ */
80
+ export function releaseWrunLoading(chartIndex, indicatorId, generation) {
81
+ if (!ownsWrunLoading(chartIndex, indicatorId, generation))
82
+ return false;
83
+ owners.delete(keyOf(chartIndex, indicatorId));
84
+ return true;
85
+ }
86
+ /** Test-only: forget every owner. */
87
+ export function __resetWrunLoadingOwnersForTests() {
88
+ owners.clear();
89
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The official package scopes (a leaf of utility/wrun/wrun-official-scope.util.ts; P2/inventory.md section 1.1): the
3
+ * scopes, a package's scope and the two tests the venue policy reads. The dev-only mismatch report stays in the old
4
+ * module (it reads `import.meta.env`); this leaf holds no state and moves into the chart-host package with the phase 2
5
+ * closure. The old module re-exports these names.
6
+ */
7
+ /**
8
+ * The official library's registry scope, as a leaf module (no imports) so the
9
+ * catalog seam and the super-search providers read ONE definition of "an
10
+ * OpenMarket indicator".
11
+ *
12
+ * A registry package is OFFICIAL (the "OpenMarket indicators" group of the
13
+ * chart's catalog) when its scope is one of WRUN_OFFICIAL_SCOPES, or when the
14
+ * registry marks its publisher `platform`. Both classify: the scope is the
15
+ * frozen contract (`@om-core` holds the official ports, reserved and marked
16
+ * platform), the mark is the registry's own word for the same thing, and a
17
+ * package that carries only one of the two still lists as official (the
18
+ * mismatch is reported once per package in dev builds so the data gets
19
+ * fixed, never hidden). Everything else is a community package: another
20
+ * author's scope or the viewer's own scope.
21
+ */
22
+ /** The registry scopes of the official library (with their leading '@'). */
23
+ export declare const WRUN_OFFICIAL_SCOPES: readonly string[];
24
+ /** The `@scope` of a package name (`@scope/name`), '' when the name has none. */
25
+ export declare function wrunPackageScopeOf(packageName: string): string;
26
+ /** Whether a scope (with its '@') is an official-library scope. */
27
+ export declare function isWrunOfficialScope(scope: string): boolean;
28
+ /** The official verdict of a package: an official scope, or the platform mark. */
29
+ export declare function isWrunOfficialPackage(packageName: string, mark: 'platform' | null | undefined): boolean;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The official package scopes (a leaf of utility/wrun/wrun-official-scope.util.ts; P2/inventory.md section 1.1): the
3
+ * scopes, a package's scope and the two tests the venue policy reads. The dev-only mismatch report stays in the old
4
+ * module (it reads `import.meta.env`); this leaf holds no state and moves into the chart-host package with the phase 2
5
+ * closure. The old module re-exports these names.
6
+ */
7
+ /**
8
+ * The official library's registry scope, as a leaf module (no imports) so the
9
+ * catalog seam and the super-search providers read ONE definition of "an
10
+ * OpenMarket indicator".
11
+ *
12
+ * A registry package is OFFICIAL (the "OpenMarket indicators" group of the
13
+ * chart's catalog) when its scope is one of WRUN_OFFICIAL_SCOPES, or when the
14
+ * registry marks its publisher `platform`. Both classify: the scope is the
15
+ * frozen contract (`@om-core` holds the official ports, reserved and marked
16
+ * platform), the mark is the registry's own word for the same thing, and a
17
+ * package that carries only one of the two still lists as official (the
18
+ * mismatch is reported once per package in dev builds so the data gets
19
+ * fixed, never hidden). Everything else is a community package: another
20
+ * author's scope or the viewer's own scope.
21
+ */
22
+ /** The registry scopes of the official library (with their leading '@'). */
23
+ export const WRUN_OFFICIAL_SCOPES = Object.freeze(['@om-core']);
24
+ /** The `@scope` of a package name (`@scope/name`), '' when the name has none. */
25
+ export function wrunPackageScopeOf(packageName) {
26
+ const slash = packageName.indexOf('/');
27
+ return slash > 0 && packageName.startsWith('@') ? packageName.slice(0, slash) : '';
28
+ }
29
+ /** Whether a scope (with its '@') is an official-library scope. */
30
+ export function isWrunOfficialScope(scope) {
31
+ return WRUN_OFFICIAL_SCOPES.includes(scope);
32
+ }
33
+ /** The official verdict of a package: an official scope, or the platform mark. */
34
+ export function isWrunOfficialPackage(packageName, mark) {
35
+ return isWrunOfficialScope(wrunPackageScopeOf(packageName)) || mark === 'platform';
36
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The open-interest lane a wrun sheet's `oi` inputs read (kit 0.86.0): an `oi` input may name `currency`, "USD"
3
+ * (the default: dollars, the lane every shipped package reads) or "Coin" (the market's native units, coins or
4
+ * contracts, the units the built-in Open Interest Profile counts in). The run asks the K_OPEN_INTEREST lane with
5
+ * `currency: "Coin"` as the lane's payload extras for a Coin sheet, so the control asks the series without the USD
6
+ * normalization (k-open-interest.control), and a USD sheet asks it exactly as before (no extras: the payload stays
7
+ * byte-identical for every shipped package). The live context keeps that payload as the lane's acquisition, so the
8
+ * reconcile re-asks the same units. An input bound to a setting (`currency_param`) reaches here with the picked
9
+ * label already written into `currency` by the paint seam (wrunSheetWithSettings), and "Auto" resolved by the
10
+ * market seam (wrunSheetWithLaneCurrencies).
11
+ *
12
+ * One package reads one open-interest lane (the run fetches it once, as it does the volume profile): `oi` inputs
13
+ * that declare two units refuse by name before any fetch. An open-interest STREAM (`oi_candles`) is a leg of its
14
+ * own and carries its own units (wrun-leg-stream-classes), so it never meets this rule.
15
+ */
16
+ import type { WrunIndicatorMetadata } from '../../interfaces/wrun-runtime.interface.js';
17
+ export declare const WRUN_OI_ONE_LANE_CODE = "wrun_oi_one_lane";
18
+ /** The lane payload extras of a Coin open-interest lane (the K_OPEN_INTEREST source payload's key). */
19
+ export interface WrunOiLaneExtras {
20
+ currency: 'Coin';
21
+ }
22
+ /** The units one `oi` input reads: "Coin" when it says so, else "USD" (the default). */
23
+ export declare function wrunOiInputCurrency(currency: unknown): 'USD' | 'Coin';
24
+ /** The lane payload extras the sheet's demanded `oi` inputs declare: `{ currency: 'Coin' }` when they read native
25
+ * units, undefined for the USD lane (the payload as before). Throws, naming the inputs, when two inputs declare
26
+ * different units. */
27
+ export declare function wrunOiLaneExtras(metadata: Pick<WrunIndicatorMetadata, 'inputs' | 'inputSources'>): WrunOiLaneExtras | undefined;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * The open-interest lane a wrun sheet's `oi` inputs read (kit 0.86.0): an `oi` input may name `currency`, "USD"
3
+ * (the default: dollars, the lane every shipped package reads) or "Coin" (the market's native units, coins or
4
+ * contracts, the units the built-in Open Interest Profile counts in). The run asks the K_OPEN_INTEREST lane with
5
+ * `currency: "Coin"` as the lane's payload extras for a Coin sheet, so the control asks the series without the USD
6
+ * normalization (k-open-interest.control), and a USD sheet asks it exactly as before (no extras: the payload stays
7
+ * byte-identical for every shipped package). The live context keeps that payload as the lane's acquisition, so the
8
+ * reconcile re-asks the same units. An input bound to a setting (`currency_param`) reaches here with the picked
9
+ * label already written into `currency` by the paint seam (wrunSheetWithSettings), and "Auto" resolved by the
10
+ * market seam (wrunSheetWithLaneCurrencies).
11
+ *
12
+ * One package reads one open-interest lane (the run fetches it once, as it does the volume profile): `oi` inputs
13
+ * that declare two units refuse by name before any fetch. An open-interest STREAM (`oi_candles`) is a leg of its
14
+ * own and carries its own units (wrun-leg-stream-classes), so it never meets this rule.
15
+ */
16
+ export const WRUN_OI_ONE_LANE_CODE = 'wrun_oi_one_lane';
17
+ /** The units one `oi` input reads: "Coin" when it says so, else "USD" (the default). */
18
+ export function wrunOiInputCurrency(currency) {
19
+ return currency === 'Coin' ? 'Coin' : 'USD';
20
+ }
21
+ /** The lane payload extras the sheet's demanded `oi` inputs declare: `{ currency: 'Coin' }` when they read native
22
+ * units, undefined for the USD lane (the payload as before). Throws, naming the inputs, when two inputs declare
23
+ * different units. */
24
+ export function wrunOiLaneExtras(metadata) {
25
+ let declared;
26
+ for (const input of metadata.inputs) {
27
+ const source = metadata.inputSources[input.name];
28
+ if (source?.source !== 'oi' || source.undemanded === true)
29
+ continue;
30
+ const currency = wrunOiInputCurrency(source.currency);
31
+ if (declared !== undefined && declared.currency !== currency) {
32
+ throw new Error(`oi inputs declare two units (${declared.inputs.join(', ')}: ${declared.currency}; ${input.name}: ${currency}) ` +
33
+ `(${WRUN_OI_ONE_LANE_CODE}): one package reads one open interest lane, so declare the same currency on ` +
34
+ 'every oi input, or read the other units through an oi_candles input');
35
+ }
36
+ declared =
37
+ declared === undefined
38
+ ? { currency, inputs: [input.name] }
39
+ : { ...declared, inputs: [...declared.inputs, input.name] };
40
+ }
41
+ return declared?.currency === 'Coin' ? { currency: 'Coin' } : undefined;
42
+ }
@@ -0,0 +1,52 @@
1
+ import { type WrunOptionsStopReason, type WrunRefusalGatePlane } from './wrun-refusal.util.js';
2
+ /** A lane a stop reason kept from its read: it degrades under its own name, terminally, in the reason's record. */
3
+ export declare class WrunLaneStoppedError extends Error {
4
+ readonly reason: WrunOptionsStopReason;
5
+ readonly plane: WrunRefusalGatePlane;
6
+ constructor(reason: WrunOptionsStopReason, plane: WrunRefusalGatePlane, lane: string);
7
+ }
8
+ export declare function isWrunLaneStoppedError(error: unknown): error is WrunLaneStoppedError;
9
+ /**
10
+ * The plane a run's rejection says another screen holds the session of (its record, else its seed, is
11
+ * `options-stopped` / `session-elsewhere`: a hold on a stopped lane, or a chain the plan stopped before any read),
12
+ * read from the typed record, never from the words; undefined for any other rejection.
13
+ */
14
+ export declare function wrunSessionStopPlaneOf(error: unknown): WrunRefusalGatePlane | undefined;
15
+ /** The planned lanes a run may dispatch, as the gate planes they read are judged. */
16
+ export interface WrunGateLaneFacts {
17
+ /** The poll lane instances (a chain lane's payload extras name the plane of its chain). */
18
+ pollLanes: ReadonlyArray<{
19
+ key: string;
20
+ laneKey: string;
21
+ extras?: Readonly<Record<string, unknown>>;
22
+ }>;
23
+ rowLanes: ReadonlyArray<{
24
+ key: string;
25
+ laneKey: string;
26
+ extras: Readonly<Record<string, unknown>>;
27
+ }>;
28
+ /** The options chain lane's payload extras (its `chainVenue` names the plane of a governed chain). */
29
+ optionsChainExtras?: Readonly<Record<string, unknown>>;
30
+ }
31
+ /**
32
+ * The gate plane each lane of a run reads, by lane id: an OPRA poll lane (`opra`) and a governed row lane read OPRA;
33
+ * a chain lane of either kind reads the plane its instance's chain lists on (OPRA, CME, or none for a crypto chain);
34
+ * the options chain lane the plane of its governed chain. A lane on no gate plane is absent.
35
+ */
36
+ export declare function wrunLaneGatePlanes(facts: WrunGateLaneFacts): Map<string, WrunRefusalGatePlane>;
37
+ /**
38
+ * A run's lane thunks with every lane on a plane another screen holds (`heldElsewhere`, read at dispatch) answering
39
+ * at once with the typed stop instead of its read. Thunks are the run's shape: the builtin lanes by name (a function
40
+ * or undefined), and the lists of `[lane id, thunk]` pairs (trades legs, poll lanes, row lanes). Everything else is
41
+ * returned as it is.
42
+ */
43
+ export declare function wrunGateLatchedThunks<T extends object>(thunks: T, planes: ReadonlyMap<string, WrunRefusalGatePlane>, heldElsewhere: (plane: WrunRefusalGatePlane) => boolean): T;
44
+ /**
45
+ * The session stop a degraded lane reads: its typed stop (the latch held at dispatch), or a lane on a plane another
46
+ * screen holds NOW (the latch came while its read was in flight, so the read waited out its budget for nothing).
47
+ * Undefined for every other degrade.
48
+ */
49
+ export declare function wrunLaneGateStopOf(lane: string, error: unknown, planes: ReadonlyMap<string, WrunRefusalGatePlane>, heldElsewhere: (plane: WrunRefusalGatePlane) => boolean): {
50
+ reason: 'session-elsewhere';
51
+ plane: WrunRefusalGatePlane;
52
+ } | undefined;
@@ -0,0 +1,123 @@
1
+ /**
2
+ * The run pass's half of the options stop reasons (`options-stopped`, wrun-refusal.util `WrunOptionsStopReason`): the
3
+ * reason a run learns as it dispatches its lanes, read from the point that already knows it, never from an error's
4
+ * text. The flag check and the plane router reach the planners as `opraPlaneStop` (opra-options-gate.util
5
+ * `opraOptionPlaneStop`) before any of this.
6
+ *
7
+ * `session-elsewhere`, from the gate's close verdict (gate-session-latch.util): a lane reading a gate plane whose one
8
+ * session another screen holds is never sent (its reader dials nothing until the session is taken back), so it
9
+ * answers at once with `WrunLaneStoppedError` (`wrunGateLatchedThunks`) instead of waiting out its budget and reading
10
+ * "did not load in time; retrying". A lane already in flight when the latch came reads the same stop
11
+ * (`wrunLaneGateStopOf`). Either way the lane degrades with no retry ladder: only the take-back helps.
12
+ *
13
+ * Light at module load: the lane registries' lookups and pure helpers (the latch is read through the caller's
14
+ * `heldElsewhere`, gate-session-latch.util `gateSessionHeldElsewhere` in the run).
15
+ */
16
+ import { wrunPollLaneByKey } from './sources/registry.js';
17
+ import { wrunRowLaneByKey } from './sources/row-lane-registry.js';
18
+ import { wrunPollLaneChainPlane } from './sources/wrun-poll-lanes.util.js';
19
+ import { wrunRowLaneChainPlane } from './sources/wrun-row-lanes.util.js';
20
+ import { wrunRefusalOf, wrunRefusalSeedOf, } from './wrun-refusal.util.js';
21
+ /** A lane a stop reason kept from its read: it degrades under its own name, terminally, in the reason's record. */
22
+ export class WrunLaneStoppedError extends Error {
23
+ reason;
24
+ plane;
25
+ constructor(reason, plane, lane) {
26
+ super(reason === 'session-elsewhere'
27
+ ? `wrun source lane '${lane}' was not asked: another screen holds the ${plane.toUpperCase()} data session, so this tab sends no read of the plane until the session is taken back here`
28
+ : `wrun source lane '${lane}' stopped (${reason})`);
29
+ this.name = 'WrunLaneStoppedError';
30
+ this.reason = reason;
31
+ this.plane = plane;
32
+ }
33
+ }
34
+ export function isWrunLaneStoppedError(error) {
35
+ return error instanceof WrunLaneStoppedError;
36
+ }
37
+ /**
38
+ * The plane a run's rejection says another screen holds the session of (its record, else its seed, is
39
+ * `options-stopped` / `session-elsewhere`: a hold on a stopped lane, or a chain the plan stopped before any read),
40
+ * read from the typed record, never from the words; undefined for any other rejection.
41
+ */
42
+ export function wrunSessionStopPlaneOf(error) {
43
+ const refusal = wrunRefusalOf(error) ?? wrunRefusalSeedOf(error);
44
+ if (refusal?.cls !== 'options-stopped' || refusal.variant !== 'session-elsewhere')
45
+ return undefined;
46
+ return refusal.out?.kind === 'take-session' ? refusal.out.plane : undefined;
47
+ }
48
+ /**
49
+ * The gate plane each lane of a run reads, by lane id: an OPRA poll lane (`opra`) and a governed row lane read OPRA;
50
+ * a chain lane of either kind reads the plane its instance's chain lists on (OPRA, CME, or none for a crypto chain);
51
+ * the options chain lane the plane of its governed chain. A lane on no gate plane is absent.
52
+ */
53
+ export function wrunLaneGatePlanes(facts) {
54
+ const planes = new Map();
55
+ for (const instance of facts.pollLanes) {
56
+ const lane = wrunPollLaneByKey(instance.laneKey);
57
+ if (lane === undefined)
58
+ continue;
59
+ if (lane.opra === true) {
60
+ planes.set(instance.key, 'opra');
61
+ continue;
62
+ }
63
+ const plane = wrunPollLaneChainPlane(lane, instance.extras ?? {});
64
+ if (plane === 'opra' || plane === 'cme')
65
+ planes.set(instance.key, plane);
66
+ }
67
+ for (const instance of facts.rowLanes) {
68
+ const lane = wrunRowLaneByKey(instance.laneKey);
69
+ if (lane === undefined)
70
+ continue;
71
+ if (lane.governed === 'opra') {
72
+ planes.set(instance.key, 'opra');
73
+ continue;
74
+ }
75
+ const plane = wrunRowLaneChainPlane(lane, instance.extras);
76
+ if (plane === 'opra' || plane === 'cme')
77
+ planes.set(instance.key, plane);
78
+ }
79
+ const chainVenue = facts.optionsChainExtras?.chainVenue;
80
+ if (chainVenue === 'opra' || chainVenue === 'cme')
81
+ planes.set('options_chain', chainVenue);
82
+ return planes;
83
+ }
84
+ /**
85
+ * A run's lane thunks with every lane on a plane another screen holds (`heldElsewhere`, read at dispatch) answering
86
+ * at once with the typed stop instead of its read. Thunks are the run's shape: the builtin lanes by name (a function
87
+ * or undefined), and the lists of `[lane id, thunk]` pairs (trades legs, poll lanes, row lanes). Everything else is
88
+ * returned as it is.
89
+ */
90
+ export function wrunGateLatchedThunks(thunks, planes, heldElsewhere) {
91
+ if (planes.size === 0)
92
+ return thunks;
93
+ const gated = (lane, run) => {
94
+ const plane = planes.get(lane);
95
+ if (plane === undefined)
96
+ return run;
97
+ return () => heldElsewhere(plane) ? Promise.reject(new WrunLaneStoppedError('session-elsewhere', plane, lane)) : run();
98
+ };
99
+ const out = { ...thunks };
100
+ for (const [key, value] of Object.entries(out)) {
101
+ if (typeof value === 'function') {
102
+ out[key] = gated(key, value);
103
+ }
104
+ else if (Array.isArray(value)) {
105
+ out[key] = value.map((pair) => Array.isArray(pair) && typeof pair[0] === 'string' && typeof pair[1] === 'function'
106
+ ? [pair[0], gated(pair[0], pair[1])]
107
+ : pair);
108
+ }
109
+ }
110
+ return out;
111
+ }
112
+ /**
113
+ * The session stop a degraded lane reads: its typed stop (the latch held at dispatch), or a lane on a plane another
114
+ * screen holds NOW (the latch came while its read was in flight, so the read waited out its budget for nothing).
115
+ * Undefined for every other degrade.
116
+ */
117
+ export function wrunLaneGateStopOf(lane, error, planes, heldElsewhere) {
118
+ if (isWrunLaneStoppedError(error) && error.reason === 'session-elsewhere') {
119
+ return { reason: 'session-elsewhere', plane: error.plane };
120
+ }
121
+ const plane = planes.get(lane);
122
+ return plane !== undefined && heldElsewhere(plane) ? { reason: 'session-elsewhere', plane } : undefined;
123
+ }