@orangecharts/wrun-chart-host 0.2.0 → 0.4.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 (342) hide show
  1. package/README.md +22 -8
  2. package/dist/constants/common.constants.d.ts +15 -0
  3. package/dist/constants/common.constants.js +23 -0
  4. package/dist/constants/data-source.constants.d.ts +1 -0
  5. package/dist/constants/data-source.constants.js +1 -0
  6. package/dist/constants/economic.constants.d.ts +39 -0
  7. package/dist/constants/economic.constants.js +77 -0
  8. package/dist/constants/etf-covered-coins.constants.d.ts +1 -0
  9. package/dist/constants/etf-covered-coins.constants.js +9 -0
  10. package/dist/constants/feature-flags.constants.d.ts +60 -0
  11. package/dist/constants/feature-flags.constants.js +308 -0
  12. package/dist/constants/feature-limits.constants.d.ts +134 -0
  13. package/dist/constants/feature-limits.constants.js +155 -0
  14. package/dist/constants/marketCapabilities.constants.d.ts +87 -0
  15. package/dist/constants/marketCapabilities.constants.js +213 -0
  16. package/dist/constants/option-venues.constants.d.ts +100 -0
  17. package/dist/constants/option-venues.constants.js +167 -0
  18. package/dist/constants/overlay-data.constants.d.ts +53 -0
  19. package/dist/constants/overlay-data.constants.js +80 -0
  20. package/dist/constants/pane-grid.constants.d.ts +15 -0
  21. package/dist/constants/pane-grid.constants.js +17 -0
  22. package/dist/constants/scriptEditor/builtin-script-snippets.d.ts +133 -0
  23. package/dist/constants/scriptEditor/builtin-script-snippets.js +451 -0
  24. package/dist/constants/venue-presets.constants.d.ts +10 -0
  25. package/dist/constants/venue-presets.constants.js +22 -0
  26. package/dist/enums/chart.enum.d.ts +68 -0
  27. package/dist/enums/chart.enum.js +70 -0
  28. package/dist/helpers/data.helpers.d.ts +2 -0
  29. package/dist/helpers/data.helpers.js +14 -0
  30. package/dist/host-env.d.ts +163 -5
  31. package/dist/host-ports.types.d.ts +431 -0
  32. package/dist/host-ports.types.js +1 -0
  33. package/dist/index.d.ts +138 -0
  34. package/dist/index.js +138 -0
  35. package/dist/indicators/controls/technical-script/technical-script-input-rendering.d.ts +86 -0
  36. package/dist/indicators/controls/technical-script/technical-script-input-rendering.js +179 -0
  37. package/dist/interfaces/asset-venue.interface.d.ts +91 -0
  38. package/dist/interfaces/asset-venue.interface.js +1 -0
  39. package/dist/interfaces/cancel-reason.interface.d.ts +24 -0
  40. package/dist/interfaces/cancel-reason.interface.js +2 -0
  41. package/dist/interfaces/catalog-display.interface.d.ts +3 -0
  42. package/dist/interfaces/catalog-display.interface.js +1 -0
  43. package/dist/interfaces/cme-realtime.interface.d.ts +251 -0
  44. package/dist/interfaces/cme-realtime.interface.js +46 -0
  45. package/dist/interfaces/feed.interface.d.ts +80 -0
  46. package/dist/interfaces/feed.interface.js +7 -0
  47. package/dist/interfaces/market-kind.interface.d.ts +8 -0
  48. package/dist/interfaces/market-kind.interface.js +1 -0
  49. package/dist/interfaces/opra-realtime.interface.d.ts +224 -0
  50. package/dist/interfaces/opra-realtime.interface.js +105 -0
  51. package/dist/interfaces/option-instrument.interface.d.ts +32 -0
  52. package/dist/interfaces/option-instrument.interface.js +1 -0
  53. package/dist/interfaces/options-chain-scope.interface.d.ts +29 -0
  54. package/dist/interfaces/options-chain-scope.interface.js +7 -0
  55. package/dist/interfaces/prediction-market.interface.d.ts +88 -0
  56. package/dist/interfaces/prediction-market.interface.js +8 -0
  57. package/dist/interfaces/wrun-runtime.interface.d.ts +5 -0
  58. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +185 -0
  59. package/dist/kscript-data/controls/live-trades-merge.util.js +357 -0
  60. package/dist/settings-templates/frvp-fields.d.ts +27 -0
  61. package/dist/settings-templates/frvp-fields.js +108 -0
  62. package/dist/settings-templates/index.d.ts +119 -0
  63. package/dist/settings-templates/index.js +442 -0
  64. package/dist/settings-templates/indicator-fields.d.ts +56 -0
  65. package/dist/settings-templates/indicator-fields.js +793 -0
  66. package/dist/settings-templates/tool-rules.d.ts +59 -0
  67. package/dist/settings-templates/tool-rules.js +49 -0
  68. package/dist/settings-templates/tool-tables.generated.d.ts +2 -0
  69. package/dist/settings-templates/tool-tables.generated.js +1668 -0
  70. package/dist/utility/blk-market.util.d.ts +5 -0
  71. package/dist/utility/blk-market.util.js +12 -0
  72. package/dist/utility/chart/chart-load-phase.util.d.ts +32 -0
  73. package/dist/utility/chart/chart-load-phase.util.js +78 -0
  74. package/dist/utility/chart/cme-cache-context.util.d.ts +108 -0
  75. package/dist/utility/chart/cme-cache-context.util.js +166 -0
  76. package/dist/utility/chart/cme-session-bucket.util.d.ts +82 -0
  77. package/dist/utility/chart/cme-session-bucket.util.js +343 -0
  78. package/dist/utility/chart/cme-trade-calendar.util.d.ts +26 -0
  79. package/dist/utility/chart/cme-trade-calendar.util.js +147 -0
  80. package/dist/utility/chart/continuous-contracts.util.d.ts +138 -0
  81. package/dist/utility/chart/continuous-contracts.util.js +374 -0
  82. package/dist/utility/chart/date-labelled-interval.leaf.d.ts +15 -0
  83. package/dist/utility/chart/date-labelled-interval.leaf.js +19 -0
  84. package/dist/utility/chart/feed-interval.util.d.ts +119 -0
  85. package/dist/utility/chart/feed-interval.util.js +321 -0
  86. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +110 -0
  87. package/dist/utility/chart/fetch-dedupe-policy.util.js +407 -0
  88. package/dist/utility/chart/footprint-band.util.d.ts +76 -0
  89. package/dist/utility/chart/footprint-band.util.js +205 -0
  90. package/dist/utility/chart/footprint-cell-identity.util.d.ts +82 -0
  91. package/dist/utility/chart/footprint-cell-identity.util.js +346 -0
  92. package/dist/utility/chart/formula-calendar.util.d.ts +27 -0
  93. package/dist/utility/chart/formula-calendar.util.js +59 -0
  94. package/dist/utility/chart/history-wall.util.d.ts +67 -0
  95. package/dist/utility/chart/history-wall.util.js +87 -0
  96. package/dist/utility/chart/index-mode.util.d.ts +66 -0
  97. package/dist/utility/chart/index-mode.util.js +360 -0
  98. package/dist/utility/chart/indicator-coverage-planner.util.d.ts +217 -0
  99. package/dist/utility/chart/indicator-coverage-planner.util.js +443 -0
  100. package/dist/utility/chart/indicator-coverage-state.util.d.ts +33 -0
  101. package/dist/utility/chart/indicator-coverage-state.util.js +110 -0
  102. package/dist/utility/chart/indicator-gap-detector.util.d.ts +127 -0
  103. package/dist/utility/chart/indicator-gap-detector.util.js +260 -0
  104. package/dist/utility/chart/indicator-gap-repair.util.d.ts +88 -0
  105. package/dist/utility/chart/indicator-gap-repair.util.js +177 -0
  106. package/dist/utility/chart/indicator-inflight-registry.util.d.ts +26 -0
  107. package/dist/utility/chart/indicator-inflight-registry.util.js +254 -0
  108. package/dist/utility/chart/indicator-run-interval.util.d.ts +130 -0
  109. package/dist/utility/chart/indicator-run-interval.util.js +268 -0
  110. package/dist/utility/chart/interval-registry.util.d.ts +23 -0
  111. package/dist/utility/chart/interval-registry.util.js +83 -0
  112. package/dist/utility/chart/kscript-main-grid-stages.util.d.ts +21 -0
  113. package/dist/utility/chart/kscript-main-grid-stages.util.js +332 -0
  114. package/dist/utility/chart/legacy-exchange.leaf.d.ts +11 -0
  115. package/dist/utility/chart/legacy-exchange.leaf.js +43 -0
  116. package/dist/utility/chart/live-bucket.util.d.ts +66 -0
  117. package/dist/utility/chart/live-bucket.util.js +165 -0
  118. package/dist/utility/chart/market-session-schedule.util.d.ts +91 -0
  119. package/dist/utility/chart/market-session-schedule.util.js +337 -0
  120. package/dist/utility/chart/marketKind.util.d.ts +181 -0
  121. package/dist/utility/chart/marketKind.util.js +371 -0
  122. package/dist/utility/chart/opra-read-access.leaf.d.ts +26 -0
  123. package/dist/utility/chart/opra-read-access.leaf.js +25 -0
  124. package/dist/utility/chart/prediction-identity.util.d.ts +159 -0
  125. package/dist/utility/chart/prediction-identity.util.js +236 -0
  126. package/dist/utility/chart/rth-session.util.d.ts +352 -0
  127. package/dist/utility/chart/rth-session.util.js +926 -0
  128. package/dist/utility/chart/titan-constants.pin.d.ts +43 -0
  129. package/dist/utility/chart/titan-constants.pin.js +50 -0
  130. package/dist/utility/chart/us-equities-session.util.d.ts +127 -0
  131. package/dist/utility/chart/us-equities-session.util.js +251 -0
  132. package/dist/utility/chart/window-geometry.leaf.d.ts +119 -0
  133. package/dist/utility/chart/window-geometry.leaf.js +391 -0
  134. package/dist/utility/chart/window-owner.leaf.d.ts +19 -0
  135. package/dist/utility/chart/window-owner.leaf.js +24 -0
  136. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +100 -0
  137. package/dist/utility/chart/wrun-bar-session-facts.util.js +354 -0
  138. package/dist/utility/chart/wrun-wire-ref.util.d.ts +23 -0
  139. package/dist/utility/chart/wrun-wire-ref.util.js +16 -0
  140. package/dist/utility/common/safe-math-eval.d.ts +18 -0
  141. package/dist/utility/common/safe-math-eval.js +160 -0
  142. package/dist/utility/common/time.util.d.ts +134 -0
  143. package/dist/utility/common/time.util.js +428 -0
  144. package/dist/utility/common/transformations.util.d.ts +126 -0
  145. package/dist/utility/common/transformations.util.js +711 -0
  146. package/dist/utility/common/visible-timeout.util.d.ts +17 -0
  147. package/dist/utility/common/visible-timeout.util.js +75 -0
  148. package/dist/utility/exchange-normalization.util.d.ts +8 -0
  149. package/dist/utility/exchange-normalization.util.js +32 -0
  150. package/dist/utility/html-escape.leaf.d.ts +11 -0
  151. package/dist/utility/html-escape.leaf.js +20 -0
  152. package/dist/utility/intl-locale.util.d.ts +2 -0
  153. package/dist/utility/intl-locale.util.js +28 -0
  154. package/dist/utility/number-format.util.d.ts +14 -1
  155. package/dist/utility/number-format.util.js +50 -19
  156. package/dist/utility/options/option-symbol.util.d.ts +28 -0
  157. package/dist/utility/options/option-symbol.util.js +176 -0
  158. package/dist/utility/options/option-trade-units.util.d.ts +190 -0
  159. package/dist/utility/options/option-trade-units.util.js +283 -0
  160. package/dist/utility/options/option-venue.util.d.ts +75 -0
  161. package/dist/utility/options/option-venue.util.js +85 -0
  162. package/dist/utility/pool-symbol.leaf.d.ts +34 -0
  163. package/dist/utility/pool-symbol.leaf.js +95 -0
  164. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +109 -0
  165. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +302 -0
  166. package/dist/utility/symbol-selection/contract-expiry.util.d.ts +39 -0
  167. package/dist/utility/symbol-selection/contract-expiry.util.js +111 -0
  168. package/dist/utility/v2/gate-plane.util.d.ts +58 -0
  169. package/dist/utility/v2/gate-plane.util.js +99 -0
  170. package/dist/utility/v2/gate-session-latch.util.d.ts +22 -0
  171. package/dist/utility/v2/gate-session-latch.util.js +34 -0
  172. package/dist/utility/watchlist/import/tradingview-symbols.leaf.d.ts +76 -0
  173. package/dist/utility/watchlist/import/tradingview-symbols.leaf.js +221 -0
  174. package/dist/utility/wrun/sources/host-grid-landing.d.ts +15 -0
  175. package/dist/utility/wrun/sources/host-grid-landing.js +26 -0
  176. package/dist/utility/wrun/sources/lanes/bitfinex_funding.d.ts +27 -0
  177. package/dist/utility/wrun/sources/lanes/bitfinex_funding.js +85 -0
  178. package/dist/utility/wrun/sources/lanes/economic.d.ts +27 -0
  179. package/dist/utility/wrun/sources/lanes/economic.js +79 -0
  180. package/dist/utility/wrun/sources/lanes/etf_holdings.d.ts +35 -0
  181. package/dist/utility/wrun/sources/lanes/etf_holdings.js +165 -0
  182. package/dist/utility/wrun/sources/lanes/etf_premium.d.ts +19 -0
  183. package/dist/utility/wrun/sources/lanes/etf_premium.js +114 -0
  184. package/dist/utility/wrun/sources/lanes/ethena_positions.d.ts +30 -0
  185. package/dist/utility/wrun/sources/lanes/ethena_positions.js +51 -0
  186. package/dist/utility/wrun/sources/lanes/index.d.ts +2 -0
  187. package/dist/utility/wrun/sources/lanes/index.js +32 -0
  188. package/dist/utility/wrun/sources/lanes/long_short_ratio.d.ts +17 -0
  189. package/dist/utility/wrun/sources/lanes/long_short_ratio.js +47 -0
  190. package/dist/utility/wrun/sources/lanes/option_daily.d.ts +58 -0
  191. package/dist/utility/wrun/sources/lanes/option_daily.js +111 -0
  192. package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +27 -0
  193. package/dist/utility/wrun/sources/lanes/option_stats_10m.js +21 -0
  194. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +50 -0
  195. package/dist/utility/wrun/sources/lanes/options_flow.js +155 -0
  196. package/dist/utility/wrun/sources/lanes/options_oi.d.ts +29 -0
  197. package/dist/utility/wrun/sources/lanes/options_oi.js +59 -0
  198. package/dist/utility/wrun/sources/lanes/options_volume.d.ts +38 -0
  199. package/dist/utility/wrun/sources/lanes/options_volume.js +63 -0
  200. package/dist/utility/wrun/sources/lanes/series.d.ts +67 -0
  201. package/dist/utility/wrun/sources/lanes/series.js +321 -0
  202. package/dist/utility/wrun/sources/lanes/token_supply.d.ts +30 -0
  203. package/dist/utility/wrun/sources/lanes/token_supply.js +145 -0
  204. package/dist/utility/wrun/sources/lanes/treasury_balance.d.ts +25 -0
  205. package/dist/utility/wrun/sources/lanes/treasury_balance.js +47 -0
  206. package/dist/utility/wrun/sources/lanes/volatility_index.d.ts +21 -0
  207. package/dist/utility/wrun/sources/lanes/volatility_index.js +11 -0
  208. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +215 -0
  209. package/dist/utility/wrun/sources/opra-option-lanes.util.js +477 -0
  210. package/dist/utility/wrun/sources/registry.d.ts +21 -0
  211. package/dist/utility/wrun/sources/registry.js +237 -0
  212. package/dist/utility/wrun/sources/row-lane-registry.d.ts +28 -0
  213. package/dist/utility/wrun/sources/row-lane-registry.js +230 -0
  214. package/dist/utility/wrun/sources/row-lanes/index.d.ts +2 -0
  215. package/dist/utility/wrun/sources/row-lanes/index.js +12 -0
  216. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +2 -0
  217. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +38 -0
  218. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +55 -0
  219. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +126 -0
  220. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +4 -0
  221. package/dist/utility/wrun/sources/row-lanes/option_prints.js +191 -0
  222. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +62 -0
  223. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +147 -0
  224. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +70 -0
  225. package/dist/utility/wrun/sources/row-lanes/option_surface.js +144 -0
  226. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +309 -0
  227. package/dist/utility/wrun/sources/wrun-poll-lane.types.js +26 -0
  228. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +350 -0
  229. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +576 -0
  230. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +275 -0
  231. package/dist/utility/wrun/sources/wrun-row-lane.types.js +16 -0
  232. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +207 -0
  233. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +450 -0
  234. package/dist/utility/wrun/wrun-browser-sources.leaf.d.ts +28 -0
  235. package/dist/utility/wrun/wrun-browser-sources.leaf.js +66 -0
  236. package/dist/utility/wrun/wrun-cloud-record.util.d.ts +65 -0
  237. package/dist/utility/wrun/wrun-cloud-record.util.js +121 -0
  238. package/dist/utility/wrun/wrun-daily-lane.util.d.ts +95 -0
  239. package/dist/utility/wrun/wrun-daily-lane.util.js +297 -0
  240. package/dist/utility/wrun/wrun-deadline.util.d.ts +52 -0
  241. package/dist/utility/wrun/wrun-deadline.util.js +82 -0
  242. package/dist/utility/wrun/wrun-etf-flow-lane.util.d.ts +94 -0
  243. package/dist/utility/wrun/wrun-etf-flow-lane.util.js +224 -0
  244. package/dist/utility/wrun/wrun-etf-funds.util.d.ts +82 -0
  245. package/dist/utility/wrun/wrun-etf-funds.util.js +242 -0
  246. package/dist/utility/wrun/wrun-frames.d.ts +20 -1
  247. package/dist/utility/wrun/wrun-frames.js +103 -49
  248. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +2 -2
  249. package/dist/utility/wrun/wrun-hosted-wire-caps.js +27 -0
  250. package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +22 -0
  251. package/dist/utility/wrun/wrun-lane-refusal.leaf.js +32 -0
  252. package/dist/utility/wrun/wrun-lane-warmup.util.d.ts +18 -0
  253. package/dist/utility/wrun/wrun-lane-warmup.util.js +112 -0
  254. package/dist/utility/wrun/wrun-leg-close.util.d.ts +57 -0
  255. package/dist/utility/wrun/wrun-leg-close.util.js +187 -0
  256. package/dist/utility/wrun/wrun-leg-fetch.util.d.ts +144 -0
  257. package/dist/utility/wrun/wrun-leg-fetch.util.js +212 -0
  258. package/dist/utility/wrun/wrun-leg-stream-classes.d.ts +73 -0
  259. package/dist/utility/wrun/wrun-leg-stream-classes.js +86 -0
  260. package/dist/utility/wrun/wrun-levels-child.util.d.ts +101 -6
  261. package/dist/utility/wrun/wrun-levels-child.util.js +335 -157
  262. package/dist/utility/wrun/wrun-memory-clamp.util.d.ts +33 -0
  263. package/dist/utility/wrun/wrun-memory-clamp.util.js +146 -0
  264. package/dist/utility/wrun/wrun-odds-template-market.util.d.ts +51 -0
  265. package/dist/utility/wrun/wrun-odds-template-market.util.js +251 -0
  266. package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +65 -0
  267. package/dist/utility/wrun/wrun-opra-flow.leaf.js +94 -0
  268. package/dist/utility/wrun/wrun-opra-lane.util.d.ts +47 -0
  269. package/dist/utility/wrun/wrun-opra-lane.util.js +58 -0
  270. package/dist/utility/wrun/wrun-opra-stats.leaf.d.ts +49 -0
  271. package/dist/utility/wrun/wrun-opra-stats.leaf.js +115 -0
  272. package/dist/utility/wrun/wrun-opra-underlying.util.d.ts +12 -0
  273. package/dist/utility/wrun/wrun-opra-underlying.util.js +1 -0
  274. package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +142 -0
  275. package/dist/utility/wrun/wrun-option-contract-flow.util.js +451 -0
  276. package/dist/utility/wrun/wrun-option-knobs.util.d.ts +43 -0
  277. package/dist/utility/wrun/wrun-option-knobs.util.js +81 -0
  278. package/dist/utility/wrun/wrun-option-prints.util.d.ts +144 -0
  279. package/dist/utility/wrun/wrun-option-prints.util.js +356 -0
  280. package/dist/utility/wrun/wrun-option-summary-lane.util.d.ts +102 -0
  281. package/dist/utility/wrun/wrun-option-summary-lane.util.js +143 -0
  282. package/dist/utility/wrun/wrun-options-chain.util.d.ts +308 -0
  283. package/dist/utility/wrun/wrun-options-chain.util.js +502 -0
  284. package/dist/utility/wrun/wrun-overlay-identity.util.d.ts +9 -4
  285. package/dist/utility/wrun/wrun-overlay-identity.util.js +16 -6
  286. package/dist/utility/wrun/wrun-panel-mount.lazy.d.ts +10 -0
  287. package/dist/utility/wrun/wrun-panel-mount.lazy.js +68 -0
  288. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +377 -0
  289. package/dist/utility/wrun/wrun-panel-mount.util.js +2251 -0
  290. package/dist/utility/wrun/wrun-param-map.util.d.ts +298 -0
  291. package/dist/utility/wrun/wrun-param-map.util.js +581 -0
  292. package/dist/utility/wrun/wrun-pause-dim.util.d.ts +52 -0
  293. package/dist/utility/wrun/wrun-pause-dim.util.js +153 -0
  294. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +149 -0
  295. package/dist/utility/wrun/wrun-pin-spelling.util.js +523 -0
  296. package/dist/utility/wrun/wrun-pin-venues.util.d.ts +116 -0
  297. package/dist/utility/wrun/wrun-pin-venues.util.js +320 -0
  298. package/dist/utility/wrun/wrun-pinned-interval.util.d.ts +20 -0
  299. package/dist/utility/wrun/wrun-pinned-interval.util.js +47 -0
  300. package/dist/utility/wrun/wrun-plot-gate.types.d.ts +23 -0
  301. package/dist/utility/wrun/wrun-plot-gate.types.js +7 -0
  302. package/dist/utility/wrun/wrun-present-bits.util.d.ts +37 -0
  303. package/dist/utility/wrun/wrun-present-bits.util.js +73 -0
  304. package/dist/utility/wrun/wrun-protocol-pending.util.d.ts +33 -0
  305. package/dist/utility/wrun/wrun-protocol-pending.util.js +57 -0
  306. package/dist/utility/wrun/wrun-refusal.util.d.ts +41 -1
  307. package/dist/utility/wrun/wrun-refusal.util.js +69 -2
  308. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +1 -14
  309. package/dist/utility/wrun/wrun-registry-errors.util.js +0 -16
  310. package/dist/utility/wrun/wrun-row-source.d.ts +158 -0
  311. package/dist/utility/wrun/wrun-row-source.js +75 -0
  312. package/dist/utility/wrun/wrun-run-health.util.d.ts +155 -0
  313. package/dist/utility/wrun/wrun-run-health.util.js +273 -0
  314. package/dist/utility/wrun/wrun-run-interval-projection.types.d.ts +14 -0
  315. package/dist/utility/wrun/wrun-run-interval-projection.types.js +1 -0
  316. package/dist/utility/wrun/wrun-socket-row-source.d.ts +439 -0
  317. package/dist/utility/wrun/wrun-socket-row-source.js +1689 -0
  318. package/dist/utility/wrun/wrun-socket-session-losses.util.d.ts +18 -0
  319. package/dist/utility/wrun/wrun-socket-session-losses.util.js +25 -0
  320. package/dist/utility/wrun/wrun-source-rows.util.d.ts +911 -0
  321. package/dist/utility/wrun/wrun-source-rows.util.js +2597 -0
  322. package/dist/utility/wrun/wrun-tape-source.util.d.ts +82 -0
  323. package/dist/utility/wrun/wrun-tape-source.util.js +151 -0
  324. package/dist/utility/wrun/wrun-tier-grid.util.d.ts +137 -0
  325. package/dist/utility/wrun/wrun-tier-grid.util.js +279 -0
  326. package/dist/utility/wrun/wrun-trades-lane.util.d.ts +52 -0
  327. package/dist/utility/wrun/wrun-trades-lane.util.js +58 -0
  328. package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +41 -0
  329. package/dist/utility/wrun/wrun-volume-profile-lane.util.js +66 -0
  330. package/dist/utility/wrun-display-name.util.d.ts +33 -0
  331. package/dist/utility/wrun-display-name.util.js +64 -0
  332. package/dist/workers/constants/kscript-transport-codes.d.ts +15 -0
  333. package/dist/workers/constants/kscript-transport-codes.js +15 -0
  334. package/dist/workers/constants/socket-slots.d.ts +574 -0
  335. package/dist/workers/constants/socket-slots.js +539 -0
  336. package/dist/workers/utils/number.worker.util.d.ts +5 -0
  337. package/dist/workers/utils/number.worker.util.js +10 -0
  338. package/dist/workers/utils/time.worker.util.d.ts +12 -0
  339. package/dist/workers/utils/time.worker.util.js +24 -0
  340. package/dist/workers/utils/volume-profile.worker.util.d.ts +200 -0
  341. package/dist/workers/utils/volume-profile.worker.util.js +631 -0
  342. package/package.json +10 -4
@@ -0,0 +1,631 @@
1
+ import { floorFootprintGridIndex } from '../../utility/chart/footprint-cell-identity.util.js';
2
+ import { getDecimalPlaces } from './number.worker.util.js';
3
+ /** True when any bucket in the list carries the trade-count extension. */
4
+ export function bucketsHaveCounts(buckets) {
5
+ return buckets.some((b) => b.length > 4);
6
+ }
7
+ /**
8
+ * Folds source-bucket counts into an accumulating target under the pipeline's
9
+ * all-or-nothing rule (mirrors the backend merge): counts survive only when
10
+ * BOTH sides carry them; a countless contributor strips the target back to a
11
+ * countless 4-element bucket. Volumes are handled by the caller.
12
+ */
13
+ export function foldBucketCounts(target, source) {
14
+ const targetHas = target.length > 4;
15
+ const sourceHas = source.length > 4;
16
+ if (targetHas && sourceHas) {
17
+ target[4] = (target[4] ?? 0) + (source[4] ?? 0);
18
+ target[5] = (target[5] ?? 0) + (source[5] ?? 0);
19
+ }
20
+ else if (targetHas) {
21
+ target.length = 4;
22
+ }
23
+ }
24
+ /**
25
+ * Row-level counts normalization for merged wide rows: when a row ends up
26
+ * MIXED (some buckets counts-bearing, some not, i.e. a countless contributor
27
+ * only overlapped part of the price range), strip counts from the whole row
28
+ * so it never presents partial counts as authoritative. Uniform rows pass
29
+ * through untouched. Mutates and returns the bucket list.
30
+ */
31
+ export function normalizeRowCounts(buckets) {
32
+ let withCounts = 0;
33
+ for (const bucket of buckets)
34
+ if (bucket.length > 4)
35
+ withCounts++;
36
+ if (withCounts > 0 && withCounts < buckets.length) {
37
+ for (const bucket of buckets)
38
+ bucket.length = 4;
39
+ }
40
+ return buckets;
41
+ }
42
+ /**
43
+ * The decode-side alignment guard for the optional counts extension: valid
44
+ * only when it is a [buyCount, sellCount] pair per profile triplet. Empty or
45
+ * misaligned arrays mean "counts unavailable" (never fabricate zeros).
46
+ */
47
+ export function alignedProfileCounts(counts, profileLength) {
48
+ if (!Array.isArray(counts))
49
+ return null;
50
+ const expected = Math.floor(profileLength / 3) * 2;
51
+ return expected > 0 && counts.length === expected ? counts : null;
52
+ }
53
+ // Mirrors aggregated-volume-profile-storage's live-path cap: one outlier bucket (a bad
54
+ // tick print) can place the next bucket millions of grid steps away, and filling that
55
+ // span would emit unbounded zero rows; at extreme magnitudes toFixed rounding can also
56
+ // stall the walk (gapHigh === gapPrice), hanging the worker. Gaps wider than this many
57
+ // steps are left unfilled; real buckets still emit.
58
+ const MAX_GAP_FILL_STEPS = 512;
59
+ /**
60
+ * Fill price gaps between volume profile buckets with zero-value buckets.
61
+ * This is a stateless utility function.
62
+ */
63
+ export function fillVolumeProfilePriceGaps(data, barHeight) {
64
+ const precision = getDecimalPlaces(barHeight);
65
+ return data.map((timestampData) => {
66
+ const timestamp = timestampData[0];
67
+ const buckets = timestampData.slice(1);
68
+ if (buckets.length < 2)
69
+ return timestampData;
70
+ const sortedBuckets = buckets.sort((a, b) => a[0] - b[0]);
71
+ const withCounts = bucketsHaveCounts(sortedBuckets);
72
+ const filledBuckets = [];
73
+ for (let i = 0; i < sortedBuckets.length; i++) {
74
+ filledBuckets.push(sortedBuckets[i]);
75
+ if (i < sortedBuckets.length - 1) {
76
+ const currentHigh = sortedBuckets[i][1];
77
+ const nextLow = sortedBuckets[i + 1][0];
78
+ const gapSteps = (nextLow - currentHigh) / barHeight;
79
+ if (Number.isFinite(gapSteps) && gapSteps <= MAX_GAP_FILL_STEPS) {
80
+ let gapPrice = currentHigh;
81
+ while (gapPrice < nextLow - barHeight / 2) {
82
+ const gapHigh = Number((gapPrice + barHeight).toFixed(precision));
83
+ if (gapHigh <= gapPrice)
84
+ break;
85
+ filledBuckets.push(withCounts ? [gapPrice, gapHigh, 0, 0, 0, 0] : [gapPrice, gapHigh, 0, 0]);
86
+ gapPrice = gapHigh;
87
+ }
88
+ }
89
+ }
90
+ }
91
+ return [timestamp, ...filledBuckets];
92
+ });
93
+ }
94
+ /**
95
+ * Fill price gaps in sorted buckets array with zero-value buckets.
96
+ * Used within rebucketVolumeProfile after aggregation.
97
+ */
98
+ export function fillVolumeProfileBucketPriceGaps(sortedBuckets, barHeight, precision) {
99
+ const filledBuckets = [];
100
+ const withCounts = bucketsHaveCounts(sortedBuckets);
101
+ for (let i = 0; i < sortedBuckets.length; i++) {
102
+ filledBuckets.push(sortedBuckets[i]);
103
+ if (i < sortedBuckets.length - 1) {
104
+ const currentHigh = sortedBuckets[i][1];
105
+ const nextLow = sortedBuckets[i + 1][0];
106
+ const gapSteps = (nextLow - currentHigh) / barHeight;
107
+ if (Number.isFinite(gapSteps) && gapSteps <= MAX_GAP_FILL_STEPS) {
108
+ let gapPrice = currentHigh;
109
+ while (gapPrice < nextLow - barHeight / 2) {
110
+ const gapHigh = Number((gapPrice + barHeight).toFixed(precision));
111
+ if (gapHigh <= gapPrice)
112
+ break;
113
+ filledBuckets.push(withCounts ? [gapPrice, gapHigh, 0, 0, 0, 0] : [gapPrice, gapHigh, 0, 0]);
114
+ gapPrice = gapHigh;
115
+ }
116
+ }
117
+ }
118
+ }
119
+ return filledBuckets;
120
+ }
121
+ /**
122
+ * Aggregate volume-profile buckets onto a coarser zero-based price grid of width
123
+ * `targetBarHeight`. Each source bucket's `priceLow` is floored to the grid; buy/sell
124
+ * volumes are summed per target cell. Returns target buckets sorted ascending. No gap-fill.
125
+ * Footprint and prediction grids opt into division-dust tolerance (the live fold's
126
+ * `floorFootprintGridIndex`) so exact boundary prices stay in their cell.
127
+ */
128
+ export function rebucketBuckets(buckets, targetBarHeight, precision, clampToData = false, tolerateFloatDust = false) {
129
+ const aggregated = new Map();
130
+ for (const bucket of buckets) {
131
+ const [priceLow, priceHigh, buyVolume, sellVolume] = bucket;
132
+ const gridIndex = tolerateFloatDust
133
+ ? floorFootprintGridIndex(priceLow, targetBarHeight)
134
+ : Math.floor(priceLow / targetBarHeight);
135
+ const targetLow = Number((gridIndex * targetBarHeight).toFixed(precision));
136
+ let target = aggregated.get(targetLow);
137
+ if (!target) {
138
+ // Default: span the full grid cell [targetLow, targetLow + targetBarHeight].
139
+ // With `clampToData`, instead track the REAL low/high of the source buckets
140
+ // merged into this cell — so the coarse cell never extends past where volume
141
+ // actually traded. This mirrors the Volume Footprint's `mergeAdjacentBars`,
142
+ // which keeps `chunk[0].priceBottom` / `chunk[last].priceTop` rather than
143
+ // snapping to a grid; the outermost cell then hugs the candle's high/low
144
+ // instead of overhanging it (which otherwise pushes a plotted bubble's
145
+ // midprice above the wick).
146
+ const cellLow = clampToData ? priceLow : targetLow;
147
+ const cellHigh = clampToData ? priceHigh : Number((targetLow + targetBarHeight).toFixed(precision));
148
+ target = [cellLow, cellHigh, 0, 0];
149
+ aggregated.set(targetLow, target);
150
+ }
151
+ else if (clampToData) {
152
+ target[0] = Math.min(target[0], priceLow);
153
+ target[1] = Math.max(target[1], priceHigh);
154
+ }
155
+ target[2] += buyVolume;
156
+ target[3] += sellVolume;
157
+ // Trade-count extension: accumulate only when the source bucket carries it.
158
+ if (bucket.length > 4) {
159
+ target[4] = (target[4] ?? 0) + (bucket[4] ?? 0);
160
+ target[5] = (target[5] ?? 0) + (bucket[5] ?? 0);
161
+ }
162
+ }
163
+ return Array.from(aggregated.values()).sort((a, b) => a[0] - b[0]);
164
+ }
165
+ /**
166
+ * Re-bucket a wide-row dataset ([timestamp, ...buckets][]) to `targetBarHeight`, filling
167
+ * price gaps afterwards. Behavior matches the formerly-private Volume Footprint method.
168
+ */
169
+ export function rebucketVolumeProfile(data, targetBarHeight, minimumBarHeight, clampToData = false, tolerateFloatDust = false) {
170
+ const precision = Math.max(getDecimalPlaces(targetBarHeight), getDecimalPlaces(minimumBarHeight));
171
+ return data.map((timestampData) => {
172
+ const timestamp = timestampData[0];
173
+ const buckets = timestampData.slice(1);
174
+ const sortedBuckets = rebucketBuckets(buckets, targetBarHeight, precision, clampToData, tolerateFloatDust);
175
+ const filledBuckets = fillVolumeProfileBucketPriceGaps(sortedBuckets, targetBarHeight, precision);
176
+ return [timestamp, ...filledBuckets];
177
+ });
178
+ }
179
+ /**
180
+ * The row spacing a VOLUME_PROFILE_AGG response was ACTUALLY served on: the
181
+ * minimum positive delta between consecutive sorted level prices, folded
182
+ * across every point in the response. Returns null when nothing is measurable
183
+ * (no points, malformed aggregations, single-level profiles).
184
+ *
185
+ * Why it exists: the FE requests rows at its assumed block size, but the gate
186
+ * serves ONE advertised grid per instrument, and after a server-side
187
+ * block-size change (the CME exchange-tick move) history past raw-trade
188
+ * retention keeps arriving on the OLD, coarser grid. The assumed block is a
189
+ * request parameter, never a description of the response.
190
+ *
191
+ * Per-point deltas only (each timestamp's profile sits on one grid); prices
192
+ * are sorted defensively and zero deltas (duplicate levels) are skipped.
193
+ * The 9-significant-digit snap mirrors measureServedRowSpacing in
194
+ * heatmap-tile-height.util: it kills binary subtraction dust before the value
195
+ * becomes a stamped row height, while exceeding any real block's precision.
196
+ *
197
+ * A spacing counts as the served GRID only when every level sits on a
198
+ * multiple of it (`levelsOnLattice`). Profiles omit zero-volume levels, so a
199
+ * venue whose catalog block is FINER than its exchange tick (Binance PUMPUSDT:
200
+ * block 3.28125e-7 on a 1e-6 tick; Hyperliquid xyz:SNDK: 0.06 on 0.1) serves
201
+ * one level per traded tick, ~3 or ~2 blocks apart, and the minimum delta
202
+ * reads the TICK, not a grid: stamping it made rows 3 blocks tall on lows 2
203
+ * blocks off that lattice, and the live fold (zero-based on the stamped
204
+ * height) interleaved a second lattice into every bar (2026-09-14 field
205
+ * case). Null there, so the assumed block stays the stamp.
206
+ */
207
+ export function measureServedProfileSpacing(points) {
208
+ if (!Array.isArray(points) || points.length === 0)
209
+ return null;
210
+ let minDelta = Infinity;
211
+ const prices = [];
212
+ const allPrices = [];
213
+ for (const point of points) {
214
+ const profile = point?.volumeProfileAggregation?.profile;
215
+ // One triplet is enough to enter: a lone level measures no delta but is
216
+ // evidence about the grid all the same, and a single-level bar off the
217
+ // lattice must veto the spacing like any other level.
218
+ if (!Array.isArray(profile) || profile.length < 3)
219
+ continue;
220
+ prices.length = 0;
221
+ for (let i = 0; i < profile.length; i += 3) {
222
+ const price = profile[i];
223
+ if (typeof price === 'number' && Number.isFinite(price))
224
+ prices.push(price);
225
+ }
226
+ allPrices.push(...prices);
227
+ if (prices.length < 2)
228
+ continue;
229
+ prices.sort((a, b) => a - b);
230
+ for (let i = 1; i < prices.length; i++) {
231
+ const delta = prices[i] - prices[i - 1];
232
+ if (delta > 0 && delta < minDelta)
233
+ minDelta = delta;
234
+ }
235
+ }
236
+ if (!Number.isFinite(minDelta))
237
+ return null;
238
+ const spacing = Number(minDelta.toPrecision(9));
239
+ return levelsOnLattice(allPrices, spacing) ? spacing : null;
240
+ }
241
+ /** Every finite level price in a VOLUME_PROFILE_AGG response, wire order, duplicates kept. */
242
+ export function servedProfileLevels(points) {
243
+ const levels = [];
244
+ if (!Array.isArray(points))
245
+ return levels;
246
+ for (const point of points) {
247
+ const profile = point?.volumeProfileAggregation?.profile;
248
+ if (!Array.isArray(profile))
249
+ continue;
250
+ for (let i = 0; i < profile.length; i += 3) {
251
+ const price = profile[i];
252
+ if (typeof price === 'number' && Number.isFinite(price))
253
+ levels.push(price);
254
+ }
255
+ }
256
+ return levels;
257
+ }
258
+ /**
259
+ * Whether every level price is an integer multiple of `spacing`: the property
260
+ * a real served grid has (the gate buckets FLOOR(price / block) * block, so
261
+ * levels are zero-based multiples of the block they were served on) and a
262
+ * sparse per-tick response lacks. The tolerance rides the quotient and is set
263
+ * by the spacing itself, not by double arithmetic: the spacing is the measured
264
+ * delta snapped to 9 significant digits, and a served block with more digits
265
+ * (the catalog carries sevenths such as 2.85714285714286e-6) puts up to 5e-9
266
+ * of relative error on it, which every quotient inherits. 1e-8 of the quotient
267
+ * covers that with margin, while a real misalignment is a large fraction of one
268
+ * spacing (PUMPUSDT levels sit 2/3 of a spacing off the lattice, xyz:SNDK 1/2).
269
+ */
270
+ function levelsOnLattice(prices, spacing) {
271
+ if (!(spacing > 0))
272
+ return false;
273
+ for (const price of prices) {
274
+ const quotient = price / spacing;
275
+ if (Math.abs(quotient - Math.round(quotient)) > Math.max(1e-7, Math.abs(quotient) * 1e-8))
276
+ return false;
277
+ }
278
+ return true;
279
+ }
280
+ /**
281
+ * Whether a measured spacing coarser than the block is the EXCHANGE TICK
282
+ * showing through sparse rows rather than a served grid: the catalog block is
283
+ * finer than the tick (one level per traded tick, nothing between), the tick
284
+ * is NOT a whole number of blocks, and the spacing is the tick to within one
285
+ * block (the tick rounded onto the block lattice). Unknown tick: false, the
286
+ * lattice test alone decides.
287
+ *
288
+ * The whole-multiple exemption carries two cases. (1) When the block divides
289
+ * the tick (NEARUSDT: catalog 0.0002 under a 0.001 tick), every per-tick level
290
+ * IS a multiple of the tick spacing, so stamping it puts the rows and the
291
+ * zero-based live fold on the same lattice: harmless, and exactly the
292
+ * served-coarse handling the 2026-09-12 NEAR fix relies on. Only a tick that
293
+ * is a fractional number of blocks (PUMPUSDT 3.05, xyz:SNDK 1.67) lands levels
294
+ * off the spacing's lattice. (2) The tick is an ESTIMATE (inferPriceTickFromRows,
295
+ * the smallest gap in a candle sample), which can only ever be the tick or a
296
+ * whole multiple of it; on a tick-snapped catalog (CME 0.25 block, 0.25 tick)
297
+ * an over-estimate of 2.0 is 8 blocks, so genuine pre-regrid 2.0 history is
298
+ * never mistaken for sparsity and keeps its served height.
299
+ */
300
+ export function isSparseTickSpacing(blockSize, spacing, priceTick, levels) {
301
+ if (!(typeof priceTick === 'number' && Number.isFinite(priceTick) && priceTick > 0))
302
+ return false;
303
+ if (!(blockSize > 0 && blockSize < priceTick))
304
+ return false;
305
+ const blocksPerTick = priceTick / blockSize;
306
+ if (Math.abs(blocksPerTick - Math.round(blocksPerTick)) <= blocksPerTick * 1e-6)
307
+ return false;
308
+ if (!(Math.abs(spacing - priceTick) <= blockSize * (1 + 1e-6)))
309
+ return false;
310
+ // Positive evidence when the levels are known: a per-tick row is the block
311
+ // bucket FLOOR(tick price / block) * block, so every level's own bucket
312
+ // [level, level + block) holds a tick multiple. A genuine coarse grid whose
313
+ // block happens to fall inside the tick window (an old 4-block regime under
314
+ // a 3.05-block tick) fails this on most of its rows, because its lows are
315
+ // multiples of the coarse block and land anywhere relative to the tick.
316
+ return levels === undefined || levels.length === 0 || levelsAreTickBuckets(levels, blockSize, priceTick);
317
+ }
318
+ /** Every level's block bucket [level, level + block) contains a multiple of `priceTick`. */
319
+ function levelsAreTickBuckets(levels, blockSize, priceTick) {
320
+ for (const level of levels) {
321
+ const ticks = level / priceTick;
322
+ const frac = ticks - Math.floor(ticks);
323
+ const onTick = frac <= 1e-7 || 1 - frac <= 1e-7;
324
+ if (!onTick && (1 - frac) * priceTick > blockSize * (1 + 1e-6))
325
+ return false;
326
+ }
327
+ return true;
328
+ }
329
+ /**
330
+ * The row height to stamp on parsed profile buckets: the measured served
331
+ * spacing when it is LARGER than the assumed block (coarse pre-change history
332
+ * would otherwise render thin bars with zero-filled gaps between levels), the
333
+ * assumed block otherwise. A finer-than-assumed measurement keeps the assumed
334
+ * block: parse-time toFixed snapping and the rebucket lane already own that
335
+ * direction, and venues serving exactly the assumed grid (crypto) stay
336
+ * byte-identical. Degenerate measurements keep the assumed block; a
337
+ * degenerate assumed block falls back to a valid measurement. With the
338
+ * exchange tick known (`priceTick`, the footprint anchor), a coarser
339
+ * measurement that is the tick showing through sparse rows keeps the block
340
+ * (`isSparseTickSpacing`; pass the response's `levels` so the call can demand
341
+ * positive evidence of per-tick rows before overriding an aligned grid).
342
+ */
343
+ export function resolveServedProfileRowHeight(assumedBlockSize, measuredSpacing, priceTick, levels) {
344
+ const measuredValid = measuredSpacing != null && Number.isFinite(measuredSpacing) && measuredSpacing > 0;
345
+ if (!Number.isFinite(assumedBlockSize) || assumedBlockSize <= 0) {
346
+ return measuredValid ? measuredSpacing : assumedBlockSize;
347
+ }
348
+ if (!measuredValid)
349
+ return assumedBlockSize;
350
+ const measured = measuredSpacing;
351
+ if (measured <= assumedBlockSize)
352
+ return assumedBlockSize;
353
+ // Sparse per-tick rows (catalog block finer than the exchange tick): the
354
+ // spacing is the tick, not a grid the levels sit on. Keep the block, or the
355
+ // rows land on a lattice their lows are not multiples of and the live fold
356
+ // (zero-based on the stamped height) keys beside them.
357
+ if (isSparseTickSpacing(assumedBlockSize, measured, priceTick, levels))
358
+ return assumedBlockSize;
359
+ return measured;
360
+ }
361
+ /**
362
+ * Per-point served row heights for a VOLUME_PROFILE_AGG response. One response
363
+ * can MIX grids: a fetch bucket that straddles the raw-trade retention
364
+ * boundary carries recent tick-grid minutes AND older coarse-grid minutes, and
365
+ * the response-level minimum (measureServedProfileSpacing over the whole
366
+ * batch) then stamps every coarse row one FINE row tall — the volume of a wide
367
+ * served row lands in a single thin bucket, and the profile reduction walks
368
+ * POC/VAH/VAL onto those inflated bars (production signature: POC == VAL
369
+ * printed under the session low after a max zoom-out).
370
+ *
371
+ * Sparsity is the trap in the other direction: profiles omit zero-volume
372
+ * levels, so thin minutes measure spacings that are MULTIPLES of the real
373
+ * grid, and two adjacent thin minutes can even agree on the same incidental
374
+ * gap. A point therefore counts as coarse EVIDENCE only when its levels are
375
+ * UNIFORMLY spaced across at least MIN_COARSE_GAPS gaps at an exact multiple of
376
+ * the assumed block, sit ON that spacing's lattice (`levelsOnLattice`: sparse
377
+ * per-tick levels on a block finer than the tick are uniformly spaced but off
378
+ * the lattice), and are not the exchange tick showing through
379
+ * (`isSparseTickSpacing`) — a real coarse grid, not a sparse coincidence — and
380
+ * it still needs an ADJACENT point with the same qualifying spacing before the
381
+ * stamp is adopted (grid regimes span contiguous runs). Everything else
382
+ * resolves to the response-level height, keeping uniform responses
383
+ * byte-identical to the batch resolve.
384
+ */
385
+ const MIN_COARSE_GAPS = 3;
386
+ const NO_GRID = { spacing: null, gaps: 0, uniform: false, aligned: false, levels: [] };
387
+ function measurePointGrid(point) {
388
+ const profile = point?.volumeProfileAggregation?.profile;
389
+ if (!Array.isArray(profile) || profile.length < 6)
390
+ return NO_GRID;
391
+ const prices = [];
392
+ for (let i = 0; i < profile.length; i += 3) {
393
+ const price = profile[i];
394
+ if (typeof price === 'number' && Number.isFinite(price))
395
+ prices.push(price);
396
+ }
397
+ if (prices.length < 2)
398
+ return NO_GRID;
399
+ prices.sort((a, b) => a - b);
400
+ let min = Infinity;
401
+ let max = 0;
402
+ let gaps = 0;
403
+ for (let i = 1; i < prices.length; i++) {
404
+ const delta = prices[i] - prices[i - 1];
405
+ if (delta <= 0)
406
+ continue;
407
+ gaps++;
408
+ if (delta < min)
409
+ min = delta;
410
+ if (delta > max)
411
+ max = delta;
412
+ }
413
+ if (gaps === 0 || !Number.isFinite(min))
414
+ return NO_GRID;
415
+ const spacing = Number(min.toPrecision(9));
416
+ return { spacing, gaps, uniform: max - min <= min * 1e-6, aligned: levelsOnLattice(prices, spacing), levels: prices };
417
+ }
418
+ export function resolveServedProfileRowHeightPerPoint(points, assumedBlockSize, priceTick) {
419
+ if (!Array.isArray(points) || points.length === 0)
420
+ return [];
421
+ const responseHeight = resolveServedProfileRowHeight(assumedBlockSize, measureServedProfileSpacing(points), priceTick, servedProfileLevels(points));
422
+ const grids = points.map(measurePointGrid);
423
+ const blockValid = Number.isFinite(assumedBlockSize) && assumedBlockSize > 0;
424
+ const isCoarseEvidence = (grid) => {
425
+ // Uniform gaps on levels that are not multiples of the gap are sparse
426
+ // per-tick levels (PUMPUSDT: every traded tick lands 3 blocks apart, 2
427
+ // blocks off the 3-block lattice), never a grid.
428
+ if (grid.spacing == null || !grid.uniform || !grid.aligned || grid.gaps < MIN_COARSE_GAPS)
429
+ return false;
430
+ if (!blockValid)
431
+ return true;
432
+ if (grid.spacing <= assumedBlockSize)
433
+ return false;
434
+ if (isSparseTickSpacing(assumedBlockSize, grid.spacing, priceTick, grid.levels))
435
+ return false;
436
+ const ratio = grid.spacing / assumedBlockSize;
437
+ return Math.abs(ratio - Math.round(ratio)) <= ratio * 1e-6 && Math.round(ratio) >= 2;
438
+ };
439
+ const sameSpacing = (a, b) => a != null && b != null && Math.abs(a - b) <= Math.max(a, b) * 1e-6;
440
+ return grids.map((grid, index) => {
441
+ if (!isCoarseEvidence(grid))
442
+ return responseHeight;
443
+ const prev = grids[index - 1];
444
+ const next = grids[index + 1];
445
+ const corroborated = (prev != null && isCoarseEvidence(prev) && sameSpacing(prev.spacing, grid.spacing)) ||
446
+ (next != null && isCoarseEvidence(next) && sameSpacing(next.spacing, grid.spacing));
447
+ if (!corroborated)
448
+ return responseHeight;
449
+ return resolveServedProfileRowHeight(assumedBlockSize, grid.spacing, priceTick, grid.levels);
450
+ });
451
+ }
452
+ /**
453
+ * The largest parse-stamped bucket height across wide rows — the coarsest grid
454
+ * actually present in the window. Each row carries ONE height by construction
455
+ * (parse stamps a single rowHeight per point), so only the first usable bucket
456
+ * per row is read. 0 when no bucket is found.
457
+ */
458
+ export function maxProfileBucketHeight(rows) {
459
+ let max = 0;
460
+ for (const row of rows) {
461
+ if (!Array.isArray(row))
462
+ continue;
463
+ for (let i = 1; i < row.length; i++) {
464
+ const cell = row[i];
465
+ if (Array.isArray(cell) && cell.length >= 4 && cell[1] > cell[0]) {
466
+ const precision = Math.max(getDecimalPlaces(cell[0]), getDecimalPlaces(cell[1]));
467
+ const height = Number((cell[1] - cell[0]).toFixed(precision));
468
+ if (height > max)
469
+ max = height;
470
+ break;
471
+ }
472
+ }
473
+ }
474
+ return max;
475
+ }
476
+ /**
477
+ * Completion-side grid normalizer for window profiles. When the parsed rows
478
+ * carry MIXED bucket heights (recent tick-grid minutes plus coarser history in
479
+ * the same window), a merged profile cannot ride the fine grid: fine and
480
+ * coarse rows would overlap at incompatible anchors and the reduction walks
481
+ * row COUNTS, not price spans. Rebucket the whole window to the COARSEST
482
+ * served height so every bar is honest at the resolution the data actually
483
+ * has. A user-raised barHeight participates by rounding to the NEAREST
484
+ * multiple of the served coarse height (floor-assignment by priceLow can move
485
+ * a wide served bucket outside a non-multiple cell's span — e.g. 2.0-wide
486
+ * rows into 2.25 cells); with no coarse rows present the user height applies
487
+ * exactly, and uniform fine-grid windows (crypto, recent-only CME) keep the
488
+ * legacy branches byte-identically.
489
+ */
490
+ export function finalizeVolumeProfileGrid(rows, barHeight, minimumBarHeight) {
491
+ const { servedCoarse, userCoarse, target } = resolveFinalizedProfileGridBranches(rows, barHeight, minimumBarHeight);
492
+ if (servedCoarse > 0)
493
+ return rebucketVolumeProfile(rows, target, minimumBarHeight);
494
+ if (userCoarse > 0)
495
+ return rebucketVolumeProfile(rows, userCoarse, minimumBarHeight);
496
+ return fillVolumeProfilePriceGaps(rows, minimumBarHeight);
497
+ }
498
+ function resolveFinalizedProfileGridBranches(rows, barHeight, minimumBarHeight) {
499
+ const maxServed = maxProfileBucketHeight(rows);
500
+ const servedCoarse = maxServed > minimumBarHeight ? maxServed : 0;
501
+ const userCoarse = Number(barHeight) > minimumBarHeight ? Number(barHeight) : 0;
502
+ const multiple = servedCoarse > 0 ? Math.max(1, Math.round(userCoarse / servedCoarse) || 1) : 1;
503
+ const target = servedCoarse > 0 ? Number((servedCoarse * multiple).toPrecision(9)) : 0;
504
+ return { maxServed, servedCoarse, userCoarse, target };
505
+ }
506
+ /**
507
+ * The price grid `finalizeVolumeProfileGrid` puts the rows on, derived from
508
+ * the SAME branch math so the two can never drift: the served-coarse target,
509
+ * else the user height, else the minimum block. This is the grid the live
510
+ * fold must adopt (aggregated-volume-profile-storage `stageEffectiveGrid`):
511
+ * live buckets folded at the requested height instead landed on a different
512
+ * lattice than the fetched rows and never merged (CME mixed-height windows;
513
+ * the 2026-08 "Delta Profile freezes / stacks above" reports). `null` when
514
+ * the rows carry no usable bucket: an empty response must never overwrite a
515
+ * committed grid.
516
+ */
517
+ export function resolveFinalizedProfileGridHeight(rows, barHeight, minimumBarHeight) {
518
+ if (!Array.isArray(rows) || rows.length === 0)
519
+ return null;
520
+ const { maxServed, servedCoarse, userCoarse, target } = resolveFinalizedProfileGridBranches(rows, barHeight, minimumBarHeight);
521
+ if (!(maxServed > 0))
522
+ return null;
523
+ if (servedCoarse > 0)
524
+ return target;
525
+ if (userCoarse > 0)
526
+ return userCoarse;
527
+ return Number.isFinite(minimumBarHeight) && minimumBarHeight > 0 ? minimumBarHeight : null;
528
+ }
529
+ /**
530
+ * Partition footprint rows by the grid they were ACTUALLY served on, read
531
+ * from the parse-stamped bucket height (resolveServedProfileRowHeight makes
532
+ * that stamp honest per response). Rows coarser than the render height cannot
533
+ * ride the legacy lane: rebucketting them onto the finer requested grid parks
534
+ * thin cells at floored rungs, and gap-filling at the render height inserts
535
+ * zero fillers between levels that were never separate. Callers process the
536
+ * coarse groups at their own served height and the fine rows exactly as
537
+ * before, which keeps on-grid venues byte-identical (empty coarse map).
538
+ * The relative epsilon absorbs settings-product float dust (0.1 x 3) so it
539
+ * can never move a row between lanes on its own.
540
+ */
541
+ export function splitFootprintRowsByServedHeight(rows, renderBarHeight) {
542
+ const fineRows = [];
543
+ const coarseRowsByHeight = new Map();
544
+ for (const row of rows) {
545
+ const servedHeight = getProfileBucketHeight([row]);
546
+ if (servedHeight - renderBarHeight > renderBarHeight * 1e-9) {
547
+ const group = coarseRowsByHeight.get(servedHeight);
548
+ if (group) {
549
+ group.push(row);
550
+ }
551
+ else {
552
+ coarseRowsByHeight.set(servedHeight, [row]);
553
+ }
554
+ }
555
+ else {
556
+ fineRows.push(row);
557
+ }
558
+ }
559
+ return { fineRows, coarseRowsByHeight };
560
+ }
561
+ /**
562
+ * Rows whose parse-stamped bucket height is FINER than `targetHeight`,
563
+ * rebucketed onto it; every other row is returned as the same reference.
564
+ * The gateway's served block varies across a response's windows (TAOUSDT
565
+ * alternated 0.1, 0.05 and 0.02 hour to hour on 2026-09-23) and each frame
566
+ * parses on its own series.blockSize, while the render height follows the
567
+ * response's block (the overlay's block when frames disagree): banded as-is,
568
+ * a finer frame's levels each become a full render-height cell and the cells
569
+ * stack. The floor is dust-tolerant because the levels are gateway-floored
570
+ * multiples of their served block: a level on a target rung boundary (314.3
571
+ * on 0.1, quotient 3142.9999999999995) must stay on its rung.
572
+ */
573
+ export function regridRowsServedFinerThan(rows, targetHeight) {
574
+ if (!(Number.isFinite(targetHeight) && targetHeight > 0))
575
+ return rows;
576
+ return rows.map((row) => {
577
+ const servedHeight = getProfileBucketHeight([row]);
578
+ if (!(servedHeight > 0) || targetHeight - servedHeight <= targetHeight * 1e-9)
579
+ return row;
580
+ const precision = Math.max(getDecimalPlaces(targetHeight), getDecimalPlaces(servedHeight));
581
+ return [row[0], ...rebucketBuckets(row.slice(1), targetHeight, precision, false, true)];
582
+ });
583
+ }
584
+ /**
585
+ * The price height (pHigh - pLow) of the first usable bucket across the given wide rows,
586
+ * i.e. the grid granularity the data currently uses. Returns 0 when no bucket is found.
587
+ */
588
+ export function getProfileBucketHeight(rows) {
589
+ for (const row of rows) {
590
+ if (!Array.isArray(row))
591
+ continue;
592
+ for (let i = 1; i < row.length; i++) {
593
+ const cell = row[i];
594
+ if (Array.isArray(cell) && cell.length >= 4 && cell[1] > cell[0]) {
595
+ // Round the derived height to the precision of its bounds: a raw float
596
+ // subtraction (e.g. 100.1 - 100) drifts and would poison getDecimalPlaces downstream.
597
+ const precision = Math.max(getDecimalPlaces(cell[0]), getDecimalPlaces(cell[1]));
598
+ return Number((cell[1] - cell[0]).toFixed(precision));
599
+ }
600
+ }
601
+ }
602
+ return 0;
603
+ }
604
+ /**
605
+ * Normalize a user-supplied `ticksPerBar` value: floor to an integer, clamp to [1, 500],
606
+ * and fall back to 1 for anything non-finite or < 1.
607
+ */
608
+ export function normalizeTicksPerBar(value) {
609
+ const n = Math.floor(Number(value));
610
+ if (!Number.isFinite(n) || n < 1)
611
+ return 1;
612
+ return Math.min(n, 500);
613
+ }
614
+ /**
615
+ * Snap freshly-parsed live buckets onto the price grid already established by existing
616
+ * historical rows. Computes the integer factor N = round(historicalGridHeight / liveBucketHeight)
617
+ * and only re-buckets when N >= 2 (i.e. the source uses ticksPerBar >= 2); otherwise the live
618
+ * buckets are returned unchanged so default (per-level) behavior is preserved. `Math.round`
619
+ * absorbs float noise in the ratio — real ticksPerBar is always an integer, so N is too.
620
+ */
621
+ export function alignBucketsToGrid(liveBuckets, existingRows) {
622
+ const gridHeight = getProfileBucketHeight(existingRows);
623
+ // Best-effort: a single-bucket live point has no reliable spacing to read, so it may not
624
+ // be detected as coarsenable and is left as-is until a multi-bucket tick arrives. Cosmetic
625
+ // at worst (one stray thin bucket that self-heals); it never corrupts historical data.
626
+ const liveHeight = liveBuckets.length >= 1 ? liveBuckets[0][1] - liveBuckets[0][0] : 0;
627
+ if (gridHeight > 0 && liveHeight > 0 && Math.round(gridHeight / liveHeight) >= 2) {
628
+ return rebucketBuckets(liveBuckets, gridHeight, getDecimalPlaces(gridHeight));
629
+ }
630
+ return liveBuckets;
631
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orangecharts/wrun-chart-host",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "The wrun chart-host layer shared by the kiyotaka web app and the mobile app: the wrun result reader and painter model, cut from the web app (its reference implementation).",
5
5
  "type": "module",
6
6
  "files": [
@@ -13,23 +13,29 @@
13
13
  "types": "./dist/index.d.ts",
14
14
  "default": "./dist/index.js"
15
15
  },
16
+ "./settings-templates": {
17
+ "types": "./dist/settings-templates/index.d.ts",
18
+ "default": "./dist/settings-templates/index.js"
19
+ },
16
20
  "./*": {
17
21
  "types": "./dist/*.d.ts",
18
22
  "default": "./dist/*.js"
19
23
  }
20
24
  },
21
25
  "scripts": {
22
- "build": "rm -rf dist && tsc -p tsconfig.build.json && node scripts/esm-dist.mjs dist",
26
+ "build": "node scripts/generate-tool-tables.mjs && rm -rf dist && tsc -p tsconfig.build.json && node scripts/esm-dist.mjs dist",
23
27
  "consumer-check": "node scripts/consumer-check.mjs",
24
28
  "typecheck": "tsc -p tsconfig.json --noEmit"
25
29
  },
26
30
  "peerDependencies": {
27
- "@orangecharts/indicator-kit": "0.80.0",
31
+ "@orangecharts/indicator-kit": "0.86.3",
32
+ "@orangecharts/orange-v2-pb-common": "12.69.0",
28
33
  "dayjs": "1.11.23",
29
34
  "lodash-es": "4.18.1"
30
35
  },
31
36
  "devDependencies": {
32
- "@orangecharts/indicator-kit": "0.80.0",
37
+ "@orangecharts/indicator-kit": "0.86.3",
38
+ "@orangecharts/orange-v2-pb-common": "12.69.0",
33
39
  "@types/lodash-es": "4.17.12",
34
40
  "dayjs": "1.11.23",
35
41
  "lodash-es": "4.18.1",