@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,72 @@
1
+ /**
2
+ * The local technical script's replay ranges (a leaf of utility/chart/local-technical-script-range.util.ts;
3
+ * P2/inventory.md section 1.1): the lazy refresh range the lifecycle reads, the prefix window and the replay range the
4
+ * executor reads, and the bar cap the run-interval warm-up reads. Pure arithmetic over its arguments, no state and no
5
+ * imports, so it moves into the chart-host package with the phase 2 closure. The dev clamp log stays in the old module
6
+ * (it reads `import.meta.env`), which re-exports these names.
7
+ */
8
+ export declare const LOCAL_TECHNICAL_SCRIPT_MAX_REPLAY_BARS = 5000;
9
+ export declare const LOCAL_TECHNICAL_SCRIPT_LAZY_CONTEXT_BARS = 50;
10
+ export type LocalTechnicalScriptReplayRange = {
11
+ fromMs: number;
12
+ toMs: number;
13
+ sourceBars: number;
14
+ replayBars: number;
15
+ maxReplayBars: number;
16
+ wasClamped: boolean;
17
+ };
18
+ export type LocalTechnicalScriptSpan = {
19
+ startMs: number;
20
+ endMs: number;
21
+ };
22
+ export declare function resolveLocalTechnicalScriptReplayRange(fromMs: number, toMs: number, intervalMs: number, maxReplayBars?: number): LocalTechnicalScriptReplayRange;
23
+ export declare function resolveLazyLocalTechnicalScriptReplayRange(span: LocalTechnicalScriptSpan, loadedRange: LocalTechnicalScriptSpan, intervalMs: number, maxReplayBars?: number, contextBars?: number): LocalTechnicalScriptReplayRange;
24
+ export declare function resolveLocalTechnicalScriptLazyRefreshRange(span: LocalTechnicalScriptSpan, loadedRange: LocalTechnicalScriptSpan, intervalMs: number, maxReplayBars?: number, contextBars?: number): LocalTechnicalScriptReplayRange;
25
+ /** The session rows a prefix run recomputes beside the bars a pan-back page added (C1 v3): its
26
+ * overlap with the mounted session, the rows the overlap proof compares. */
27
+ export declare const LOCAL_TECHNICAL_SCRIPT_PREFIX_OVERLAP_ROWS = 32;
28
+ /** A backward extension's prefix window: from the chart's first loaded bar through the last overlap
29
+ * row (inclusive, epoch ms), always partial (the mounted rows after it are kept). */
30
+ export type LocalTechnicalScriptPrefixWindow = {
31
+ fromMs: number;
32
+ toMs: number;
33
+ /** The session's first row: the overlap runs from here through `toMs`. */
34
+ overlapFromMs: number;
35
+ /** How many session rows the overlap holds (the overlap count, fewer when the session is shorter). */
36
+ overlapRows: number;
37
+ partial: true;
38
+ };
39
+ /** What the prefix decider answers for a session over the chart's loaded rows: a window, the
40
+ * session already reaching the chart's first bar (nothing older to compute), or no backward
41
+ * extension to compute (the session's first row is no longer a loaded bar, or it holds no rows). */
42
+ export type LocalTechnicalScriptPrefixDecision = {
43
+ kind: 'window';
44
+ window: LocalTechnicalScriptPrefixWindow;
45
+ } | {
46
+ kind: 'covered';
47
+ } | {
48
+ kind: 'not-backward-extension';
49
+ };
50
+ /**
51
+ * The prefix window of a pan-back page (C1 v3): the chart's loaded rows now start before the
52
+ * mounted session's first row, and that row is still a loaded bar, so the page is a pure backward
53
+ * extension. The run computes from the chart's first bar through the `overlapRows`-th session row
54
+ * counted from the session's first row (fewer when the session is shorter), so the rows it shares
55
+ * with the mounted session can be compared before anything lands. Rows are time-ascending:
56
+ * `loadedRows` `[ts, ...]` (the chart's traded candles), `sessionRows` the session's evaluated
57
+ * rows (`{ ts }`).
58
+ *
59
+ * The window always ends on a loaded bar: a session row the chart holds no candle for (a missing
60
+ * bar a package reading another lane computes as a NaN row) cannot end it, since the window's
61
+ * candle slice keeps a missing bar only strictly between two candles. The overlap runs on through
62
+ * the next session row the chart holds, so the gap stays interior and both runs keep its row; a
63
+ * session with no such row left is no backward extension to compute.
64
+ */
65
+ export declare function resolveLocalTechnicalScriptPrefixWindow(input: {
66
+ loadedRows: ReadonlyArray<ArrayLike<number>>;
67
+ sessionFirstTs: number;
68
+ sessionRows: ReadonlyArray<{
69
+ ts: number;
70
+ }>;
71
+ overlapRows?: number;
72
+ }): LocalTechnicalScriptPrefixDecision;
@@ -0,0 +1,126 @@
1
+ /**
2
+ * The local technical script's replay ranges (a leaf of utility/chart/local-technical-script-range.util.ts;
3
+ * P2/inventory.md section 1.1): the lazy refresh range the lifecycle reads, the prefix window and the replay range the
4
+ * executor reads, and the bar cap the run-interval warm-up reads. Pure arithmetic over its arguments, no state and no
5
+ * imports, so it moves into the chart-host package with the phase 2 closure. The dev clamp log stays in the old module
6
+ * (it reads `import.meta.env`), which re-exports these names.
7
+ */
8
+ export const LOCAL_TECHNICAL_SCRIPT_MAX_REPLAY_BARS = 5_000;
9
+ export const LOCAL_TECHNICAL_SCRIPT_LAZY_CONTEXT_BARS = 50;
10
+ function finitePositiveNumber(value) {
11
+ const n = Number(value);
12
+ return Number.isFinite(n) && n > 0 ? n : null;
13
+ }
14
+ export function resolveLocalTechnicalScriptReplayRange(fromMs, toMs, intervalMs, maxReplayBars = LOCAL_TECHNICAL_SCRIPT_MAX_REPLAY_BARS) {
15
+ const interval = finitePositiveNumber(intervalMs);
16
+ const cap = Math.max(1, Math.floor(finitePositiveNumber(maxReplayBars) ?? LOCAL_TECHNICAL_SCRIPT_MAX_REPLAY_BARS));
17
+ if (!Number.isFinite(fromMs) || !Number.isFinite(toMs) || toMs <= fromMs || !interval) {
18
+ return {
19
+ fromMs,
20
+ toMs,
21
+ sourceBars: 0,
22
+ replayBars: 0,
23
+ maxReplayBars: cap,
24
+ wasClamped: false,
25
+ };
26
+ }
27
+ const sourceBars = Math.floor((toMs - fromMs) / interval) + 1;
28
+ if (sourceBars <= cap) {
29
+ return {
30
+ fromMs,
31
+ toMs,
32
+ sourceBars,
33
+ replayBars: sourceBars,
34
+ maxReplayBars: cap,
35
+ wasClamped: false,
36
+ };
37
+ }
38
+ const clampedFromMs = Math.max(fromMs, toMs - (cap - 1) * interval);
39
+ return {
40
+ fromMs: clampedFromMs,
41
+ toMs,
42
+ sourceBars,
43
+ replayBars: Math.floor((toMs - clampedFromMs) / interval) + 1,
44
+ maxReplayBars: cap,
45
+ wasClamped: true,
46
+ };
47
+ }
48
+ export function resolveLazyLocalTechnicalScriptReplayRange(span, loadedRange, intervalMs, maxReplayBars = LOCAL_TECHNICAL_SCRIPT_MAX_REPLAY_BARS, contextBars = LOCAL_TECHNICAL_SCRIPT_LAZY_CONTEXT_BARS) {
49
+ const interval = finitePositiveNumber(intervalMs);
50
+ const overlapBars = Math.max(0, Math.floor(finitePositiveNumber(contextBars) ?? 0));
51
+ const overlapMs = interval ? overlapBars * interval : 0;
52
+ return resolveLocalTechnicalScriptReplayRange(Math.max(span.startMs - overlapMs, loadedRange.startMs), Math.min(span.endMs + overlapMs, loadedRange.endMs), intervalMs, maxReplayBars);
53
+ }
54
+ export function resolveLocalTechnicalScriptLazyRefreshRange(span, loadedRange, intervalMs, maxReplayBars = LOCAL_TECHNICAL_SCRIPT_MAX_REPLAY_BARS, contextBars = LOCAL_TECHNICAL_SCRIPT_LAZY_CONTEXT_BARS) {
55
+ const loadedReplayRange = resolveLocalTechnicalScriptReplayRange(loadedRange.startMs, loadedRange.endMs, intervalMs, maxReplayBars);
56
+ if (loadedReplayRange.replayBars <= 0 || !loadedReplayRange.wasClamped) {
57
+ return loadedReplayRange;
58
+ }
59
+ return resolveLazyLocalTechnicalScriptReplayRange(span, loadedRange, intervalMs, maxReplayBars, contextBars);
60
+ }
61
+ /** The session rows a prefix run recomputes beside the bars a pan-back page added (C1 v3): its
62
+ * overlap with the mounted session, the rows the overlap proof compares. */
63
+ export const LOCAL_TECHNICAL_SCRIPT_PREFIX_OVERLAP_ROWS = 32;
64
+ /**
65
+ * The prefix window of a pan-back page (C1 v3): the chart's loaded rows now start before the
66
+ * mounted session's first row, and that row is still a loaded bar, so the page is a pure backward
67
+ * extension. The run computes from the chart's first bar through the `overlapRows`-th session row
68
+ * counted from the session's first row (fewer when the session is shorter), so the rows it shares
69
+ * with the mounted session can be compared before anything lands. Rows are time-ascending:
70
+ * `loadedRows` `[ts, ...]` (the chart's traded candles), `sessionRows` the session's evaluated
71
+ * rows (`{ ts }`).
72
+ *
73
+ * The window always ends on a loaded bar: a session row the chart holds no candle for (a missing
74
+ * bar a package reading another lane computes as a NaN row) cannot end it, since the window's
75
+ * candle slice keeps a missing bar only strictly between two candles. The overlap runs on through
76
+ * the next session row the chart holds, so the gap stays interior and both runs keep its row; a
77
+ * session with no such row left is no backward extension to compute.
78
+ */
79
+ export function resolveLocalTechnicalScriptPrefixWindow(input) {
80
+ const { loadedRows, sessionFirstTs, sessionRows } = input;
81
+ const chartFirstTs = Number(loadedRows[0]?.[0]);
82
+ if (!Number.isFinite(chartFirstTs) || !Number.isFinite(sessionFirstTs))
83
+ return { kind: 'not-backward-extension' };
84
+ // The session already reaches the chart's first bar (or past it: the chart let older rows go).
85
+ if (sessionFirstTs <= chartFirstTs)
86
+ return { kind: 'covered' };
87
+ if (!sortedRowsHoldTs(loadedRows, sessionFirstTs))
88
+ return { kind: 'not-backward-extension' };
89
+ const want = Math.max(1, Math.floor(finitePositiveNumber(input.overlapRows) ?? LOCAL_TECHNICAL_SCRIPT_PREFIX_OVERLAP_ROWS));
90
+ let start = 0;
91
+ while (start < sessionRows.length && sessionRows[start].ts < sessionFirstTs)
92
+ start += 1;
93
+ let end = Math.min(sessionRows.length, start + want);
94
+ if (end <= start)
95
+ return { kind: 'not-backward-extension' };
96
+ while (end < sessionRows.length && !sortedRowsHoldTs(loadedRows, sessionRows[end - 1].ts))
97
+ end += 1;
98
+ if (!sortedRowsHoldTs(loadedRows, sessionRows[end - 1].ts))
99
+ return { kind: 'not-backward-extension' };
100
+ return {
101
+ kind: 'window',
102
+ window: {
103
+ fromMs: chartFirstTs,
104
+ toMs: sessionRows[end - 1].ts,
105
+ overlapFromMs: sessionRows[start].ts,
106
+ overlapRows: end - start,
107
+ partial: true,
108
+ },
109
+ };
110
+ }
111
+ /** Whether time-ascending `[ts, ...]` rows hold a row stamped exactly `ts` (binary search). */
112
+ function sortedRowsHoldTs(rows, ts) {
113
+ let lo = 0;
114
+ let hi = rows.length - 1;
115
+ while (lo <= hi) {
116
+ const mid = (lo + hi) >> 1;
117
+ const at = Number(rows[mid][0]);
118
+ if (at === ts)
119
+ return true;
120
+ if (at < ts)
121
+ lo = mid + 1;
122
+ else
123
+ hi = mid - 1;
124
+ }
125
+ return false;
126
+ }
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Mixed-Mode Transformation Utilities
3
+ *
4
+ * This module provides core functionality for handling mixed-mode transformations,
5
+ * which combine timestamp-driven markets (crypto, 24/7) with index-mode markets
6
+ * (stocks with trading sessions like Polygon).
7
+ *
8
+ * **Two Main Scenarios:**
9
+ * 1. Timestamp-first (BTC + NVDA): the chart keeps a clock axis and asks for a time window
10
+ * 2. Index-first (NVDA + BTC): the chart keeps a bar-count axis and asks for bars
11
+ *
12
+ * **Flow:**
13
+ * - Detection: buildMixedModeContext → identifies scenario type
14
+ * - Fetching: the main thread sizes the payload for the first token's axis; the worker fetches the formula's anchor
15
+ * that way and every other leg over the anchor's span (formula-calendar.util)
16
+ * - Alignment: transformData carries legs on other calendars onto the anchor's bars
17
+ */
18
+ export type TokenMode = 'index' | 'timestamp';
19
+ export type LazyLoadDirection = 'left' | 'right' | 'unknown';
20
+ export interface TokenContext {
21
+ tokenKey: string;
22
+ exchange: string;
23
+ symbol: string;
24
+ mode: TokenMode;
25
+ sessionType?: string;
26
+ }
27
+ /**
28
+ * Mixed-mode context for entire transformation expression
29
+ * Contains aggregated information about all tokens and their modes
30
+ */
31
+ export interface MixedModeContext {
32
+ tokenModes: {
33
+ tokenKey: string;
34
+ isIndex: boolean;
35
+ }[];
36
+ tokenSessionTypes: Record<string, string>;
37
+ tokenExchanges: Record<string, string>;
38
+ hasIndexToken: boolean;
39
+ hasTimestampToken: boolean;
40
+ isMixedMode: boolean;
41
+ }
42
+ /**
43
+ * Fetch parameters for mixed-mode requests
44
+ * Includes both period (time-based) and limit (count-based) to support both modes
45
+ */
46
+ export interface MixedModeParams {
47
+ period: number;
48
+ from: number;
49
+ limit: number;
50
+ sortDirection: 1 | 2;
51
+ }
52
+ /**
53
+ * Base payload fields common to all fetch modes
54
+ */
55
+ export interface BaseOhlcvPayload {
56
+ transformations: string;
57
+ interval: string;
58
+ ovId: string;
59
+ chain?: string;
60
+ poolAddress?: string;
61
+ baseTokenAddress?: string;
62
+ quoteTokenAddress?: string;
63
+ sessionType?: string;
64
+ tokenSessionTypes?: Record<string, string>;
65
+ defaultAggregationMethod?: number | string;
66
+ gapfill?: boolean;
67
+ adjusted?: boolean;
68
+ tailBoot?: boolean;
69
+ sided?: boolean;
70
+ category?: number;
71
+ }
72
+ /**
73
+ * Payload for pure timestamp-mode fetching
74
+ * Uses time-based parameters: period (duration) and from (start timestamp)
75
+ */
76
+ export interface TimestampModePayload extends BaseOhlcvPayload {
77
+ period: number;
78
+ from: number;
79
+ }
80
+ /**
81
+ * Payload for pure index-mode fetching
82
+ * Uses count-based parameters: limit (number of bars) and sortDirection
83
+ */
84
+ export interface IndexModePayload extends BaseOhlcvPayload {
85
+ from: number;
86
+ limit: number;
87
+ sortDirection: 1 | 2;
88
+ }
89
+ /**
90
+ * Payload for mixed-mode fetching (combining timestamp and index tokens)
91
+ * Includes BOTH time-based and count-based parameters.
92
+ */
93
+ export interface MixedModePayload extends BaseOhlcvPayload {
94
+ period: number;
95
+ from: number;
96
+ limit: number;
97
+ sortDirection: 1 | 2;
98
+ }
99
+ export type OhlcvPayload = TimestampModePayload | IndexModePayload | MixedModePayload;
100
+ /** Maximum bars to fetch for historical mixed-mode to prevent memory issues */
101
+ export declare const HISTORICAL_MIXED_MAX_LIMIT = 4000;
102
+ /** Padding factor for timestamp-based fetches to ensure boundary coverage */
103
+ export declare const TIMESTAMP_PADDING_MULTIPLIER = 2;
104
+ /** Default fallback limit offset when no main data exists */
105
+ export declare const DEFAULT_FALLBACK_LIMIT_OFFSET = 2;
106
+ /** Extra bar offset for index fetch to ensure boundary coverage (+1 for safety margin) */
107
+ export declare const INDEX_FETCH_EXTRA_BAR = 1;
108
+ /**
109
+ * Builds mixed-mode context by analyzing transformation tokens
110
+ *
111
+ * Detects whether the chart combines timestamp-driven markets (crypto, 24/7)
112
+ * with index-mode markets (stocks with trading sessions). Extracts token modes
113
+ * and session types to enable proper data fetching and alignment.
114
+ *
115
+ * **Pipeline Integration:**
116
+ * - Called by `fetchMainData` before payload construction
117
+ * - Results used by `resolveMixedModeParams` for fetch strategy
118
+ * - Worker receives context via payload metadata
119
+ *
120
+ * **Scenarios Detected:**
121
+ * - Pure timestamp: All tokens are 24/7 markets (crypto)
122
+ * - Pure index: All tokens are session-based (stocks/TradFi)
123
+ * - Mixed timestamp-first: Main token is crypto, others include stocks (BTC + NVDA)
124
+ * - Mixed index-first: Main token is stock, others include crypto (NVDA + BTC)
125
+ *
126
+ * @param metadata - Chart metadata containing transformations and session settings
127
+ * @param transformations - Expression string (e.g., "BINANCE|BTCUSDT + POLYGON|NVDA")
128
+ * @returns Context object with token modes, session types, and mixed-mode flags
129
+ */
130
+ export declare function buildMixedModeContext(metadata: any, transformations: string): MixedModeContext;
131
+ /**
132
+ * Infers lazy-load pan direction from chart state
133
+ *
134
+ * Determines whether user is panning left (past), right (future), or neither
135
+ * based on the relationship between requested range and existing data.
136
+ *
137
+ * **Detection Logic:**
138
+ * 1. If `isAscending` provided by Titan → Use directly
139
+ * 2. If requested range starts after existing end → Panning right
140
+ * 3. If requested range ends before existing start → Panning left
141
+ * 4. Otherwise → Unknown (overlapping or initial load)
142
+ *
143
+ * **Usage:**
144
+ * - Determines sortDirection (1=forward, 2=backward)
145
+ * - Adjusts gap detection strategy
146
+ * - Controls coverage tracking logic
147
+ *
148
+ * @param params - Comparison data (requested vs existing ranges, ascending hint)
149
+ * @returns Direction indicator for lazy-load strategy
150
+ */
151
+ export declare function inferLazyLoadDirection(params: {
152
+ isAscending?: boolean;
153
+ requestedStart: number;
154
+ requestedEnd: number;
155
+ existingStart?: number;
156
+ existingEnd?: number;
157
+ }): LazyLoadDirection;
158
+ /**
159
+ * Gets the mode of the first token in transformation
160
+ *
161
+ * The first token sets the chart's axis in mixed-mode: a timestamp token keeps a clock axis (time-window payloads),
162
+ * an index token a bar-count axis (bar-count payloads).
163
+ *
164
+ * @param context - Mixed-mode context
165
+ * @returns Mode of first token or undefined if no tokens
166
+ */
167
+ export declare function getFirstTokenMode(context: MixedModeContext): TokenMode | undefined;
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Mixed-Mode Transformation Utilities
3
+ *
4
+ * This module provides core functionality for handling mixed-mode transformations,
5
+ * which combine timestamp-driven markets (crypto, 24/7) with index-mode markets
6
+ * (stocks with trading sessions like Polygon).
7
+ *
8
+ * **Two Main Scenarios:**
9
+ * 1. Timestamp-first (BTC + NVDA): the chart keeps a clock axis and asks for a time window
10
+ * 2. Index-first (NVDA + BTC): the chart keeps a bar-count axis and asks for bars
11
+ *
12
+ * **Flow:**
13
+ * - Detection: buildMixedModeContext → identifies scenario type
14
+ * - Fetching: the main thread sizes the payload for the first token's axis; the worker fetches the formula's anchor
15
+ * that way and every other leg over the anchor's span (formula-calendar.util)
16
+ * - Alignment: transformData carries legs on other calendars onto the anchor's bars
17
+ */
18
+ import { getExchangeFromSymbol } from '../../helpers/data.helpers.js';
19
+ import { extractTokensFromTransformations } from '../common/transformations.util.js';
20
+ import { checkIsIndexMode, checkIsPolygon } from './index-mode.util.js';
21
+ // ============================================================================
22
+ // CONSTANTS
23
+ // ============================================================================
24
+ /** Maximum bars to fetch for historical mixed-mode to prevent memory issues */
25
+ export const HISTORICAL_MIXED_MAX_LIMIT = 4000;
26
+ /** Padding factor for timestamp-based fetches to ensure boundary coverage */
27
+ export const TIMESTAMP_PADDING_MULTIPLIER = 2;
28
+ /** Default fallback limit offset when no main data exists */
29
+ export const DEFAULT_FALLBACK_LIMIT_OFFSET = 2;
30
+ /** Extra bar offset for index fetch to ensure boundary coverage (+1 for safety margin) */
31
+ export const INDEX_FETCH_EXTRA_BAR = 1;
32
+ // ============================================================================
33
+ // CORE DETECTION FUNCTIONS
34
+ // ============================================================================
35
+ /**
36
+ * Builds mixed-mode context by analyzing transformation tokens
37
+ *
38
+ * Detects whether the chart combines timestamp-driven markets (crypto, 24/7)
39
+ * with index-mode markets (stocks with trading sessions). Extracts token modes
40
+ * and session types to enable proper data fetching and alignment.
41
+ *
42
+ * **Pipeline Integration:**
43
+ * - Called by `fetchMainData` before payload construction
44
+ * - Results used by `resolveMixedModeParams` for fetch strategy
45
+ * - Worker receives context via payload metadata
46
+ *
47
+ * **Scenarios Detected:**
48
+ * - Pure timestamp: All tokens are 24/7 markets (crypto)
49
+ * - Pure index: All tokens are session-based (stocks/TradFi)
50
+ * - Mixed timestamp-first: Main token is crypto, others include stocks (BTC + NVDA)
51
+ * - Mixed index-first: Main token is stock, others include crypto (NVDA + BTC)
52
+ *
53
+ * @param metadata - Chart metadata containing transformations and session settings
54
+ * @param transformations - Expression string (e.g., "BINANCE|BTCUSDT + POLYGON|NVDA")
55
+ * @returns Context object with token modes, session types, and mixed-mode flags
56
+ */
57
+ export function buildMixedModeContext(metadata, transformations) {
58
+ const tokens = extractTokensFromTransformations(transformations);
59
+ const tokenSessionTypes = {};
60
+ const tokenExchanges = {};
61
+ const tokenModes = tokens.map((token) => {
62
+ const resolvedExchange = getExchangeFromSymbol(token.exchange ?? '', token.symbol ?? '');
63
+ const isIndex = checkIsIndexMode(resolvedExchange);
64
+ tokenExchanges[token.token] = resolvedExchange;
65
+ // Track session type for Polygon tokens (regular vs extended hours)
66
+ if (checkIsPolygon(resolvedExchange)) {
67
+ const resolvedSessionType = metadata.sessionType ?? 'regular';
68
+ tokenSessionTypes[token.token] = resolvedSessionType;
69
+ }
70
+ return {
71
+ tokenKey: token.token,
72
+ isIndex,
73
+ };
74
+ });
75
+ const hasIndexToken = tokenModes.some((mode) => mode.isIndex);
76
+ const hasTimestampToken = tokenModes.some((mode) => !mode.isIndex);
77
+ const context = {
78
+ tokenModes,
79
+ tokenSessionTypes,
80
+ tokenExchanges,
81
+ hasIndexToken,
82
+ hasTimestampToken,
83
+ isMixedMode: hasIndexToken && hasTimestampToken,
84
+ };
85
+ return context;
86
+ }
87
+ /**
88
+ * Infers lazy-load pan direction from chart state
89
+ *
90
+ * Determines whether user is panning left (past), right (future), or neither
91
+ * based on the relationship between requested range and existing data.
92
+ *
93
+ * **Detection Logic:**
94
+ * 1. If `isAscending` provided by Titan → Use directly
95
+ * 2. If requested range starts after existing end → Panning right
96
+ * 3. If requested range ends before existing start → Panning left
97
+ * 4. Otherwise → Unknown (overlapping or initial load)
98
+ *
99
+ * **Usage:**
100
+ * - Determines sortDirection (1=forward, 2=backward)
101
+ * - Adjusts gap detection strategy
102
+ * - Controls coverage tracking logic
103
+ *
104
+ * @param params - Comparison data (requested vs existing ranges, ascending hint)
105
+ * @returns Direction indicator for lazy-load strategy
106
+ */
107
+ export function inferLazyLoadDirection(params) {
108
+ const { isAscending, requestedStart, requestedEnd, existingStart, existingEnd } = params;
109
+ // Priority 1: Trust Titan's explicit direction hint
110
+ if (typeof isAscending === 'boolean') {
111
+ return isAscending ? 'right' : 'left';
112
+ }
113
+ // Priority 2: Heuristic based on data range comparison
114
+ if (typeof existingEnd === 'number' && requestedStart >= existingEnd) {
115
+ return 'right';
116
+ }
117
+ if (typeof existingStart === 'number' && requestedEnd <= existingStart) {
118
+ return 'left';
119
+ }
120
+ return 'unknown';
121
+ }
122
+ // ============================================================================
123
+ // SCENARIO DETECTION HELPERS
124
+ // ============================================================================
125
+ /**
126
+ * Gets the mode of the first token in transformation
127
+ *
128
+ * The first token sets the chart's axis in mixed-mode: a timestamp token keeps a clock axis (time-window payloads),
129
+ * an index token a bar-count axis (bar-count payloads).
130
+ *
131
+ * @param context - Mixed-mode context
132
+ * @returns Mode of first token or undefined if no tokens
133
+ */
134
+ export function getFirstTokenMode(context) {
135
+ const firstToken = context.tokenModes[0];
136
+ if (!firstToken)
137
+ return undefined;
138
+ return firstToken.isIndex ? 'index' : 'timestamp';
139
+ }
@@ -0,0 +1,36 @@
1
+ export declare function filterOhlcvRowsInTimeRange(rows: readonly unknown[] | null | undefined, fromMs: number, toMs: number): number[][];
2
+ export declare function ohlcvRowsHaveFiniteClose(rows: readonly unknown[] | null | undefined, fromMs?: number, toMs?: number): boolean;
3
+ export interface ChartMainRowsSourceAsk {
4
+ /** Bar count of a latest-anchored count ask (KScriptSourceFetchOptions.latestAnchorBars). */
5
+ requestedBars?: number;
6
+ /** The run reads no other source on the shared timeline (KScriptSourceFetchOptions.soleTimelineSource). */
7
+ soleTimelineSource?: boolean;
8
+ }
9
+ /**
10
+ * The chart's own candle rows as the answer to a script's `ohlcv` source over
11
+ * [fromMs, toMs], or null when the wire has to answer.
12
+ *
13
+ * Served only when the main series spans the whole window and holds a bar in
14
+ * it. A latest-anchored count source may legitimately need MORE rows than its
15
+ * naive window holds on session-bound venues; serving the covered-but-short
16
+ * window here would re-create the under-fill the count ask exists to remove,
17
+ * so a window with fewer rows than `requestedBars` goes to the wire too.
18
+ *
19
+ * A sole timeline source is served real bars only, the wire's own answer for
20
+ * the window. The engine reads a marker row as a bar with no price, and its
21
+ * recursive builtins (rsi, ema, rma, atr, macd) stay NaN from the first one
22
+ * on (2026-09-30, GATE_IO_FUTURES PROLOGUE_USDT 30m: the RSI line ended at
23
+ * the first half hour that never traded).
24
+ *
25
+ * A run that lays other sources on the same timeline keeps the main rows as
26
+ * they are, marker rows included. The engine matches a secondary source to
27
+ * the timeline by exact timestamp, and a sampled series (open interest,
28
+ * funding) has a row in every bucket, traded or not: without the marker rows
29
+ * those series end at the first tradeless bucket instead (rig, same market at
30
+ * 1h). Serving such runs real bars needs the engine to skip rows that fall on
31
+ * no bar first.
32
+ */
33
+ export declare function chartMainRowsAsOhlcvSource(main: {
34
+ rawData?: unknown;
35
+ syntheticFlags?: ArrayLike<number> | null;
36
+ } | null | undefined, fromMs: number, toMs: number, ask?: ChartMainRowsSourceAsk): number[][] | null;
@@ -0,0 +1,90 @@
1
+ export function filterOhlcvRowsInTimeRange(rows, fromMs, toMs) {
2
+ if (!Array.isArray(rows) || !Number.isFinite(fromMs) || !Number.isFinite(toMs))
3
+ return [];
4
+ const rangeStart = Math.min(fromMs, toMs);
5
+ const rangeEnd = Math.max(fromMs, toMs);
6
+ return rows.filter((row) => Array.isArray(row) && Number.isFinite(row[0]) && row[0] >= rangeStart && row[0] <= rangeEnd);
7
+ }
8
+ export function ohlcvRowsHaveFiniteClose(rows, fromMs, toMs) {
9
+ const rowsToInspect = fromMs === undefined || toMs === undefined ? rows : filterOhlcvRowsInTimeRange(rows, fromMs, toMs);
10
+ if (!Array.isArray(rowsToInspect))
11
+ return false;
12
+ return rowsToInspect.some((row) => Array.isArray(row) && Number.isFinite(row[4]));
13
+ }
14
+ /**
15
+ * The bars the wire sent inside [fromMs, toMs]: the rows in range minus the
16
+ * client's own synthetic rows.
17
+ *
18
+ * On a gap-detecting market (crypto) the main series holds one marker row per
19
+ * bucket that never traded (titan `insertSyntheticGaps`: NaN OHLC, flagged in
20
+ * the index-aligned `syntheticFlags`), so the time axis stays uniform and a
21
+ * line breaks at the quiet bucket. Those rows are a rendering device, not
22
+ * bars. A row is dropped when its flag is not real, or when any of open,
23
+ * high, low, close is not finite (a marker that arrived without its flag:
24
+ * the flags are positional and are read only while they match the rows'
25
+ * length).
26
+ */
27
+ function filterRealOhlcvRowsInTimeRange(rows, syntheticFlags, fromMs, toMs) {
28
+ if (!Number.isFinite(fromMs) || !Number.isFinite(toMs))
29
+ return [];
30
+ const rangeStart = Math.min(fromMs, toMs);
31
+ const rangeEnd = Math.max(fromMs, toMs);
32
+ const flags = syntheticFlags && syntheticFlags.length === rows.length ? syntheticFlags : undefined;
33
+ const real = [];
34
+ for (let i = 0; i < rows.length; i++) {
35
+ const row = rows[i];
36
+ if (!Array.isArray(row) || !Number.isFinite(row[0]) || row[0] < rangeStart || row[0] > rangeEnd)
37
+ continue;
38
+ if (flags && flags[i] !== 0)
39
+ continue;
40
+ if (!Number.isFinite(row[1]) || !Number.isFinite(row[2]) || !Number.isFinite(row[3]) || !Number.isFinite(row[4])) {
41
+ continue;
42
+ }
43
+ real.push(row);
44
+ }
45
+ return real;
46
+ }
47
+ /**
48
+ * The chart's own candle rows as the answer to a script's `ohlcv` source over
49
+ * [fromMs, toMs], or null when the wire has to answer.
50
+ *
51
+ * Served only when the main series spans the whole window and holds a bar in
52
+ * it. A latest-anchored count source may legitimately need MORE rows than its
53
+ * naive window holds on session-bound venues; serving the covered-but-short
54
+ * window here would re-create the under-fill the count ask exists to remove,
55
+ * so a window with fewer rows than `requestedBars` goes to the wire too.
56
+ *
57
+ * A sole timeline source is served real bars only, the wire's own answer for
58
+ * the window. The engine reads a marker row as a bar with no price, and its
59
+ * recursive builtins (rsi, ema, rma, atr, macd) stay NaN from the first one
60
+ * on (2026-09-30, GATE_IO_FUTURES PROLOGUE_USDT 30m: the RSI line ended at
61
+ * the first half hour that never traded).
62
+ *
63
+ * A run that lays other sources on the same timeline keeps the main rows as
64
+ * they are, marker rows included. The engine matches a secondary source to
65
+ * the timeline by exact timestamp, and a sampled series (open interest,
66
+ * funding) has a row in every bucket, traded or not: without the marker rows
67
+ * those series end at the first tradeless bucket instead (rig, same market at
68
+ * 1h). Serving such runs real bars needs the engine to skip rows that fall on
69
+ * no bar first.
70
+ */
71
+ export function chartMainRowsAsOhlcvSource(main, fromMs, toMs, ask = {}) {
72
+ const mainRows = Array.isArray(main?.rawData) ? main.rawData : [];
73
+ const firstTs = mainRows[0]?.[0];
74
+ const lastTs = mainRows[mainRows.length - 1]?.[0];
75
+ if (mainRows.length === 0 ||
76
+ typeof firstTs !== 'number' ||
77
+ typeof lastTs !== 'number' ||
78
+ !Number.isFinite(firstTs) ||
79
+ !Number.isFinite(lastTs) ||
80
+ firstTs > fromMs ||
81
+ lastTs < toMs) {
82
+ return null;
83
+ }
84
+ const sourceRows = ask.soleTimelineSource
85
+ ? filterRealOhlcvRowsInTimeRange(mainRows, main?.syntheticFlags, fromMs, toMs)
86
+ : filterOhlcvRowsInTimeRange(mainRows, fromMs, toMs);
87
+ if (typeof ask.requestedBars === 'number' && sourceRows.length < ask.requestedBars)
88
+ return null;
89
+ return ohlcvRowsHaveFiniteClose(sourceRows) ? sourceRows : null;
90
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The `opra-user-scripts` runtime flag as the venue policy reads it (kscript-venue-policy.util, the one decider of
3
+ * the governed walls). Dependency-free on purpose, the shape of exchange-visibility.util and telemetryGates: the
4
+ * venue policy stays worker-safe and store-free, so the feature-flags store hands it readers instead.
5
+ *
6
+ * Two readers, one answer: the store registers its override-aware `isOn` as the fallback when it is created, and
7
+ * publishes its reader again after every successful fetch. Until a fetch publishes, the fallback answers, so the dev
8
+ * and internal `kiyo.flag-overrides` lens reaches the walls before the map lands and through a failed fetch, exactly
9
+ * as it reaches `opraUserScriptsEnabled` (opra-options-gate.util) and the editor's Run wall: the walls and the
10
+ * surfaces never disagree, and a restore that skipped the hydration wait on an override judges by that override. In
11
+ * any context neither reached (a worker, a guest-less spec), the gate reads closed: fail dark, today's wall.
12
+ */
13
+ /** Called by the feature-flags store after a successful fetch (and by tests); null unpublishes. */
14
+ export declare function publishOpraUserScriptsFlag(next: (() => boolean) | null): void;
15
+ /** Called by the feature-flags store when it is created: its override-aware `isOn`, read until a fetch publishes. */
16
+ export declare function setOpraUserScriptsFlagFallback(next: (() => boolean) | null): void;
17
+ /** Whether the `opra-user-scripts` flag is on for this session: the published answer, else the store's own; closed
18
+ * when neither can tell. */
19
+ export declare function isOpraUserScriptsFlagOn(): boolean;