@orangecharts/wrun-chart-host 0.1.0 → 0.3.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 (337) hide show
  1. package/README.md +39 -6
  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/venue-presets.constants.d.ts +10 -0
  23. package/dist/constants/venue-presets.constants.js +22 -0
  24. package/dist/enums/chart.enum.d.ts +68 -0
  25. package/dist/enums/chart.enum.js +70 -0
  26. package/dist/helpers/data.helpers.d.ts +2 -0
  27. package/dist/helpers/data.helpers.js +14 -0
  28. package/dist/host-env.d.ts +161 -5
  29. package/dist/host-ports.types.d.ts +446 -0
  30. package/dist/host-ports.types.js +1 -0
  31. package/dist/index.d.ts +131 -0
  32. package/dist/index.js +131 -0
  33. package/dist/indicators/controls/technical-script/technical-script-input-rendering.d.ts +86 -0
  34. package/dist/indicators/controls/technical-script/technical-script-input-rendering.js +179 -0
  35. package/dist/interfaces/asset-venue.interface.d.ts +91 -0
  36. package/dist/interfaces/asset-venue.interface.js +1 -0
  37. package/dist/interfaces/cancel-reason.interface.d.ts +24 -0
  38. package/dist/interfaces/cancel-reason.interface.js +2 -0
  39. package/dist/interfaces/catalog-display.interface.d.ts +3 -0
  40. package/dist/interfaces/catalog-display.interface.js +1 -0
  41. package/dist/interfaces/cme-realtime.interface.d.ts +251 -0
  42. package/dist/interfaces/cme-realtime.interface.js +46 -0
  43. package/dist/interfaces/feed.interface.d.ts +80 -0
  44. package/dist/interfaces/feed.interface.js +7 -0
  45. package/dist/interfaces/market-kind.interface.d.ts +8 -0
  46. package/dist/interfaces/market-kind.interface.js +1 -0
  47. package/dist/interfaces/opra-realtime.interface.d.ts +224 -0
  48. package/dist/interfaces/opra-realtime.interface.js +105 -0
  49. package/dist/interfaces/option-instrument.interface.d.ts +32 -0
  50. package/dist/interfaces/option-instrument.interface.js +1 -0
  51. package/dist/interfaces/options-chain-scope.interface.d.ts +29 -0
  52. package/dist/interfaces/options-chain-scope.interface.js +7 -0
  53. package/dist/interfaces/prediction-market.interface.d.ts +88 -0
  54. package/dist/interfaces/prediction-market.interface.js +8 -0
  55. package/dist/interfaces/wrun-runtime.interface.d.ts +5 -0
  56. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +185 -0
  57. package/dist/kscript-data/controls/live-trades-merge.util.js +357 -0
  58. package/dist/settings-templates/frvp-fields.d.ts +27 -0
  59. package/dist/settings-templates/frvp-fields.js +108 -0
  60. package/dist/settings-templates/index.d.ts +119 -0
  61. package/dist/settings-templates/index.js +442 -0
  62. package/dist/settings-templates/indicator-fields.d.ts +56 -0
  63. package/dist/settings-templates/indicator-fields.js +793 -0
  64. package/dist/settings-templates/tool-rules.d.ts +59 -0
  65. package/dist/settings-templates/tool-rules.js +49 -0
  66. package/dist/settings-templates/tool-tables.generated.d.ts +2 -0
  67. package/dist/settings-templates/tool-tables.generated.js +1668 -0
  68. package/dist/utility/blk-market.util.d.ts +5 -0
  69. package/dist/utility/blk-market.util.js +12 -0
  70. package/dist/utility/chart/chart-load-phase.util.d.ts +32 -0
  71. package/dist/utility/chart/chart-load-phase.util.js +78 -0
  72. package/dist/utility/chart/cme-cache-context.util.d.ts +108 -0
  73. package/dist/utility/chart/cme-cache-context.util.js +166 -0
  74. package/dist/utility/chart/cme-session-bucket.util.d.ts +82 -0
  75. package/dist/utility/chart/cme-session-bucket.util.js +343 -0
  76. package/dist/utility/chart/cme-trade-calendar.util.d.ts +26 -0
  77. package/dist/utility/chart/cme-trade-calendar.util.js +147 -0
  78. package/dist/utility/chart/continuous-contracts.util.d.ts +138 -0
  79. package/dist/utility/chart/continuous-contracts.util.js +374 -0
  80. package/dist/utility/chart/feed-interval.util.d.ts +119 -0
  81. package/dist/utility/chart/feed-interval.util.js +321 -0
  82. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +110 -0
  83. package/dist/utility/chart/fetch-dedupe-policy.util.js +407 -0
  84. package/dist/utility/chart/footprint-band.util.d.ts +76 -0
  85. package/dist/utility/chart/footprint-band.util.js +205 -0
  86. package/dist/utility/chart/footprint-cell-identity.util.d.ts +82 -0
  87. package/dist/utility/chart/footprint-cell-identity.util.js +346 -0
  88. package/dist/utility/chart/formula-calendar.util.d.ts +27 -0
  89. package/dist/utility/chart/formula-calendar.util.js +59 -0
  90. package/dist/utility/chart/history-wall.util.d.ts +67 -0
  91. package/dist/utility/chart/history-wall.util.js +87 -0
  92. package/dist/utility/chart/index-mode.util.d.ts +66 -0
  93. package/dist/utility/chart/index-mode.util.js +360 -0
  94. package/dist/utility/chart/indicator-coverage-planner.util.d.ts +217 -0
  95. package/dist/utility/chart/indicator-coverage-planner.util.js +443 -0
  96. package/dist/utility/chart/indicator-coverage-state.util.d.ts +33 -0
  97. package/dist/utility/chart/indicator-coverage-state.util.js +110 -0
  98. package/dist/utility/chart/indicator-gap-detector.util.d.ts +127 -0
  99. package/dist/utility/chart/indicator-gap-detector.util.js +260 -0
  100. package/dist/utility/chart/indicator-gap-repair.util.d.ts +88 -0
  101. package/dist/utility/chart/indicator-gap-repair.util.js +177 -0
  102. package/dist/utility/chart/indicator-inflight-registry.util.d.ts +26 -0
  103. package/dist/utility/chart/indicator-inflight-registry.util.js +254 -0
  104. package/dist/utility/chart/interval-registry.util.d.ts +23 -0
  105. package/dist/utility/chart/interval-registry.util.js +83 -0
  106. package/dist/utility/chart/kscript-main-grid-stages.util.d.ts +21 -0
  107. package/dist/utility/chart/kscript-main-grid-stages.util.js +332 -0
  108. package/dist/utility/chart/legacy-exchange.leaf.d.ts +11 -0
  109. package/dist/utility/chart/legacy-exchange.leaf.js +43 -0
  110. package/dist/utility/chart/live-bucket.util.d.ts +66 -0
  111. package/dist/utility/chart/live-bucket.util.js +165 -0
  112. package/dist/utility/chart/market-session-schedule.util.d.ts +91 -0
  113. package/dist/utility/chart/market-session-schedule.util.js +337 -0
  114. package/dist/utility/chart/marketKind.util.d.ts +181 -0
  115. package/dist/utility/chart/marketKind.util.js +371 -0
  116. package/dist/utility/chart/om-panel.util.js +6 -0
  117. package/dist/utility/chart/om-widget.util.d.ts +4 -0
  118. package/dist/utility/chart/opra-read-access.leaf.d.ts +26 -0
  119. package/dist/utility/chart/opra-read-access.leaf.js +25 -0
  120. package/dist/utility/chart/prediction-identity.util.d.ts +159 -0
  121. package/dist/utility/chart/prediction-identity.util.js +236 -0
  122. package/dist/utility/chart/rth-session.util.d.ts +352 -0
  123. package/dist/utility/chart/rth-session.util.js +926 -0
  124. package/dist/utility/chart/titan-constants.pin.d.ts +43 -0
  125. package/dist/utility/chart/titan-constants.pin.js +50 -0
  126. package/dist/utility/chart/us-equities-session.util.d.ts +127 -0
  127. package/dist/utility/chart/us-equities-session.util.js +251 -0
  128. package/dist/utility/chart/wrun-bar-session-facts.util.d.ts +100 -0
  129. package/dist/utility/chart/wrun-bar-session-facts.util.js +354 -0
  130. package/dist/utility/chart/wrun-run-result.util.js +10 -0
  131. package/dist/utility/chart/wrun-wire-ref.util.d.ts +23 -0
  132. package/dist/utility/chart/wrun-wire-ref.util.js +16 -0
  133. package/dist/utility/common/safe-math-eval.d.ts +18 -0
  134. package/dist/utility/common/safe-math-eval.js +160 -0
  135. package/dist/utility/common/time.util.d.ts +134 -0
  136. package/dist/utility/common/time.util.js +428 -0
  137. package/dist/utility/common/transformations.util.d.ts +126 -0
  138. package/dist/utility/common/transformations.util.js +711 -0
  139. package/dist/utility/common/visible-timeout.util.d.ts +17 -0
  140. package/dist/utility/common/visible-timeout.util.js +75 -0
  141. package/dist/utility/exchange-normalization.util.d.ts +8 -0
  142. package/dist/utility/exchange-normalization.util.js +32 -0
  143. package/dist/utility/intl-locale.util.d.ts +2 -0
  144. package/dist/utility/intl-locale.util.js +28 -0
  145. package/dist/utility/number-format.util.d.ts +14 -1
  146. package/dist/utility/number-format.util.js +50 -19
  147. package/dist/utility/options/option-symbol.util.d.ts +28 -0
  148. package/dist/utility/options/option-symbol.util.js +176 -0
  149. package/dist/utility/options/option-trade-units.util.d.ts +190 -0
  150. package/dist/utility/options/option-trade-units.util.js +283 -0
  151. package/dist/utility/options/option-venue.util.d.ts +75 -0
  152. package/dist/utility/options/option-venue.util.js +85 -0
  153. package/dist/utility/pool-symbol.leaf.d.ts +34 -0
  154. package/dist/utility/pool-symbol.leaf.js +95 -0
  155. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +109 -0
  156. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +302 -0
  157. package/dist/utility/symbol-selection/contract-expiry.util.d.ts +39 -0
  158. package/dist/utility/symbol-selection/contract-expiry.util.js +111 -0
  159. package/dist/utility/v2/gate-plane.util.d.ts +58 -0
  160. package/dist/utility/v2/gate-plane.util.js +99 -0
  161. package/dist/utility/v2/gate-session-latch.util.d.ts +22 -0
  162. package/dist/utility/v2/gate-session-latch.util.js +34 -0
  163. package/dist/utility/watchlist/import/tradingview-symbols.leaf.d.ts +76 -0
  164. package/dist/utility/watchlist/import/tradingview-symbols.leaf.js +221 -0
  165. package/dist/utility/wrun/sources/host-grid-landing.d.ts +15 -0
  166. package/dist/utility/wrun/sources/host-grid-landing.js +26 -0
  167. package/dist/utility/wrun/sources/lanes/bitfinex_funding.d.ts +27 -0
  168. package/dist/utility/wrun/sources/lanes/bitfinex_funding.js +85 -0
  169. package/dist/utility/wrun/sources/lanes/economic.d.ts +27 -0
  170. package/dist/utility/wrun/sources/lanes/economic.js +79 -0
  171. package/dist/utility/wrun/sources/lanes/etf_holdings.d.ts +35 -0
  172. package/dist/utility/wrun/sources/lanes/etf_holdings.js +165 -0
  173. package/dist/utility/wrun/sources/lanes/etf_premium.d.ts +19 -0
  174. package/dist/utility/wrun/sources/lanes/etf_premium.js +114 -0
  175. package/dist/utility/wrun/sources/lanes/ethena_positions.d.ts +30 -0
  176. package/dist/utility/wrun/sources/lanes/ethena_positions.js +51 -0
  177. package/dist/utility/wrun/sources/lanes/index.d.ts +2 -0
  178. package/dist/utility/wrun/sources/lanes/index.js +32 -0
  179. package/dist/utility/wrun/sources/lanes/long_short_ratio.d.ts +17 -0
  180. package/dist/utility/wrun/sources/lanes/long_short_ratio.js +47 -0
  181. package/dist/utility/wrun/sources/lanes/option_daily.d.ts +30 -0
  182. package/dist/utility/wrun/sources/lanes/option_daily.js +53 -0
  183. package/dist/utility/wrun/sources/lanes/option_stats_10m.d.ts +23 -0
  184. package/dist/utility/wrun/sources/lanes/option_stats_10m.js +20 -0
  185. package/dist/utility/wrun/sources/lanes/options_flow.d.ts +50 -0
  186. package/dist/utility/wrun/sources/lanes/options_flow.js +155 -0
  187. package/dist/utility/wrun/sources/lanes/options_oi.d.ts +29 -0
  188. package/dist/utility/wrun/sources/lanes/options_oi.js +59 -0
  189. package/dist/utility/wrun/sources/lanes/options_volume.d.ts +38 -0
  190. package/dist/utility/wrun/sources/lanes/options_volume.js +63 -0
  191. package/dist/utility/wrun/sources/lanes/series.d.ts +67 -0
  192. package/dist/utility/wrun/sources/lanes/series.js +321 -0
  193. package/dist/utility/wrun/sources/lanes/token_supply.d.ts +30 -0
  194. package/dist/utility/wrun/sources/lanes/token_supply.js +145 -0
  195. package/dist/utility/wrun/sources/lanes/treasury_balance.d.ts +25 -0
  196. package/dist/utility/wrun/sources/lanes/treasury_balance.js +47 -0
  197. package/dist/utility/wrun/sources/lanes/volatility_index.d.ts +21 -0
  198. package/dist/utility/wrun/sources/lanes/volatility_index.js +11 -0
  199. package/dist/utility/wrun/sources/opra-option-lanes.util.d.ts +196 -0
  200. package/dist/utility/wrun/sources/opra-option-lanes.util.js +446 -0
  201. package/dist/utility/wrun/sources/registry.d.ts +21 -0
  202. package/dist/utility/wrun/sources/registry.js +207 -0
  203. package/dist/utility/wrun/sources/row-lane-registry.d.ts +28 -0
  204. package/dist/utility/wrun/sources/row-lane-registry.js +230 -0
  205. package/dist/utility/wrun/sources/row-lanes/index.d.ts +2 -0
  206. package/dist/utility/wrun/sources/row-lanes/index.js +12 -0
  207. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.d.ts +2 -0
  208. package/dist/utility/wrun/sources/row-lanes/option_contract_flow.js +38 -0
  209. package/dist/utility/wrun/sources/row-lanes/option_contract_state.d.ts +6 -0
  210. package/dist/utility/wrun/sources/row-lanes/option_contract_state.js +70 -0
  211. package/dist/utility/wrun/sources/row-lanes/option_prints.d.ts +4 -0
  212. package/dist/utility/wrun/sources/row-lanes/option_prints.js +191 -0
  213. package/dist/utility/wrun/sources/row-lanes/option_strikes.d.ts +13 -0
  214. package/dist/utility/wrun/sources/row-lanes/option_strikes.js +137 -0
  215. package/dist/utility/wrun/sources/row-lanes/option_surface.d.ts +38 -0
  216. package/dist/utility/wrun/sources/row-lanes/option_surface.js +150 -0
  217. package/dist/utility/wrun/sources/wrun-poll-lane.types.d.ts +275 -0
  218. package/dist/utility/wrun/sources/wrun-poll-lane.types.js +26 -0
  219. package/dist/utility/wrun/sources/wrun-poll-lanes.util.d.ts +224 -0
  220. package/dist/utility/wrun/sources/wrun-poll-lanes.util.js +394 -0
  221. package/dist/utility/wrun/sources/wrun-row-lane.types.d.ts +283 -0
  222. package/dist/utility/wrun/sources/wrun-row-lane.types.js +16 -0
  223. package/dist/utility/wrun/sources/wrun-row-lanes.util.d.ts +205 -0
  224. package/dist/utility/wrun/sources/wrun-row-lanes.util.js +469 -0
  225. package/dist/utility/wrun/wrun-browser-sources.leaf.d.ts +28 -0
  226. package/dist/utility/wrun/wrun-browser-sources.leaf.js +66 -0
  227. package/dist/utility/wrun/wrun-cloud-record.util.d.ts +65 -0
  228. package/dist/utility/wrun/wrun-cloud-record.util.js +121 -0
  229. package/dist/utility/wrun/wrun-color-settings.util.js +1 -1
  230. package/dist/utility/wrun/wrun-daily-lane.util.d.ts +95 -0
  231. package/dist/utility/wrun/wrun-daily-lane.util.js +297 -0
  232. package/dist/utility/wrun/wrun-deadline.util.d.ts +52 -0
  233. package/dist/utility/wrun/wrun-deadline.util.js +82 -0
  234. package/dist/utility/wrun/wrun-etf-flow-lane.util.d.ts +94 -0
  235. package/dist/utility/wrun/wrun-etf-flow-lane.util.js +224 -0
  236. package/dist/utility/wrun/wrun-etf-funds.util.d.ts +82 -0
  237. package/dist/utility/wrun/wrun-etf-funds.util.js +242 -0
  238. package/dist/utility/wrun/wrun-failure-cause.d.ts +39 -0
  239. package/dist/utility/wrun/wrun-failure-cause.js +94 -0
  240. package/dist/utility/wrun/wrun-frames.d.ts +28 -3
  241. package/dist/utility/wrun/wrun-frames.js +132 -52
  242. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +167 -4
  243. package/dist/utility/wrun/wrun-hosted-wire-caps.js +47 -2
  244. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +5 -2
  245. package/dist/utility/wrun/wrun-hosted-wire.util.js +4 -2
  246. package/dist/utility/wrun/wrun-lane-refusal.leaf.d.ts +22 -0
  247. package/dist/utility/wrun/wrun-lane-refusal.leaf.js +32 -0
  248. package/dist/utility/wrun/wrun-lane-warmup.util.d.ts +18 -0
  249. package/dist/utility/wrun/wrun-lane-warmup.util.js +112 -0
  250. package/dist/utility/wrun/wrun-leg-close.util.d.ts +57 -0
  251. package/dist/utility/wrun/wrun-leg-close.util.js +187 -0
  252. package/dist/utility/wrun/wrun-leg-fetch.util.d.ts +144 -0
  253. package/dist/utility/wrun/wrun-leg-fetch.util.js +212 -0
  254. package/dist/utility/wrun/wrun-leg-stream-classes.d.ts +73 -0
  255. package/dist/utility/wrun/wrun-leg-stream-classes.js +86 -0
  256. package/dist/utility/wrun/wrun-levels-child.util.d.ts +101 -6
  257. package/dist/utility/wrun/wrun-levels-child.util.js +335 -157
  258. package/dist/utility/wrun/wrun-memory-clamp.util.d.ts +33 -0
  259. package/dist/utility/wrun/wrun-memory-clamp.util.js +146 -0
  260. package/dist/utility/wrun/wrun-odds-template-market.util.d.ts +51 -0
  261. package/dist/utility/wrun/wrun-odds-template-market.util.js +251 -0
  262. package/dist/utility/wrun/wrun-opra-flow.leaf.d.ts +65 -0
  263. package/dist/utility/wrun/wrun-opra-flow.leaf.js +94 -0
  264. package/dist/utility/wrun/wrun-opra-lane.util.d.ts +47 -0
  265. package/dist/utility/wrun/wrun-opra-lane.util.js +58 -0
  266. package/dist/utility/wrun/wrun-opra-stats.leaf.d.ts +30 -0
  267. package/dist/utility/wrun/wrun-opra-stats.leaf.js +96 -0
  268. package/dist/utility/wrun/wrun-opra-underlying.util.d.ts +12 -0
  269. package/dist/utility/wrun/wrun-opra-underlying.util.js +1 -0
  270. package/dist/utility/wrun/wrun-option-contract-flow.util.d.ts +142 -0
  271. package/dist/utility/wrun/wrun-option-contract-flow.util.js +451 -0
  272. package/dist/utility/wrun/wrun-option-knobs.util.d.ts +43 -0
  273. package/dist/utility/wrun/wrun-option-knobs.util.js +81 -0
  274. package/dist/utility/wrun/wrun-option-prints.util.d.ts +144 -0
  275. package/dist/utility/wrun/wrun-option-prints.util.js +356 -0
  276. package/dist/utility/wrun/wrun-option-summary-lane.util.d.ts +102 -0
  277. package/dist/utility/wrun/wrun-option-summary-lane.util.js +143 -0
  278. package/dist/utility/wrun/wrun-options-chain.util.d.ts +308 -0
  279. package/dist/utility/wrun/wrun-options-chain.util.js +502 -0
  280. package/dist/utility/wrun/wrun-overlay-identity.util.d.ts +9 -4
  281. package/dist/utility/wrun/wrun-overlay-identity.util.js +16 -6
  282. package/dist/utility/wrun/wrun-pack.util.d.ts +6 -2
  283. package/dist/utility/wrun/wrun-pack.util.js +13 -3
  284. package/dist/utility/wrun/wrun-param-map.util.d.ts +298 -0
  285. package/dist/utility/wrun/wrun-param-map.util.js +581 -0
  286. package/dist/utility/wrun/wrun-param-values.util.d.ts +8 -0
  287. package/dist/utility/wrun/wrun-param-values.util.js +8 -0
  288. package/dist/utility/wrun/wrun-pin-spelling.util.d.ts +149 -0
  289. package/dist/utility/wrun/wrun-pin-spelling.util.js +523 -0
  290. package/dist/utility/wrun/wrun-pin-venues.util.d.ts +116 -0
  291. package/dist/utility/wrun/wrun-pin-venues.util.js +320 -0
  292. package/dist/utility/wrun/wrun-pinned-interval.util.d.ts +20 -0
  293. package/dist/utility/wrun/wrun-pinned-interval.util.js +47 -0
  294. package/dist/utility/wrun/wrun-present-bits.util.d.ts +37 -0
  295. package/dist/utility/wrun/wrun-present-bits.util.js +73 -0
  296. package/dist/utility/wrun/wrun-protocol-pending.util.d.ts +33 -0
  297. package/dist/utility/wrun/wrun-protocol-pending.util.js +57 -0
  298. package/dist/utility/wrun/wrun-refusal.util.d.ts +95 -7
  299. package/dist/utility/wrun/wrun-refusal.util.js +314 -18
  300. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +1 -14
  301. package/dist/utility/wrun/wrun-registry-errors.util.js +0 -16
  302. package/dist/utility/wrun/wrun-render-select.util.js +1 -0
  303. package/dist/utility/wrun/wrun-row-market.util.d.ts +29 -0
  304. package/dist/utility/wrun/wrun-row-market.util.js +92 -0
  305. package/dist/utility/wrun/wrun-row-source.d.ts +158 -0
  306. package/dist/utility/wrun/wrun-row-source.js +75 -0
  307. package/dist/utility/wrun/wrun-run-health.util.d.ts +155 -0
  308. package/dist/utility/wrun/wrun-run-health.util.js +273 -0
  309. package/dist/utility/wrun/wrun-socket-row-source.d.ts +439 -0
  310. package/dist/utility/wrun/wrun-socket-row-source.js +1689 -0
  311. package/dist/utility/wrun/wrun-socket-session-losses.util.d.ts +18 -0
  312. package/dist/utility/wrun/wrun-socket-session-losses.util.js +25 -0
  313. package/dist/utility/wrun/wrun-source-rows.util.d.ts +911 -0
  314. package/dist/utility/wrun/wrun-source-rows.util.js +2597 -0
  315. package/dist/utility/wrun/wrun-symbol-code.util.d.ts +32 -0
  316. package/dist/utility/wrun/wrun-symbol-code.util.js +56 -0
  317. package/dist/utility/wrun/wrun-tape-source.util.d.ts +82 -0
  318. package/dist/utility/wrun/wrun-tape-source.util.js +151 -0
  319. package/dist/utility/wrun/wrun-tier-grid.util.d.ts +137 -0
  320. package/dist/utility/wrun/wrun-tier-grid.util.js +279 -0
  321. package/dist/utility/wrun/wrun-trades-lane.util.d.ts +52 -0
  322. package/dist/utility/wrun/wrun-trades-lane.util.js +58 -0
  323. package/dist/utility/wrun/wrun-volume-profile-lane.util.d.ts +41 -0
  324. package/dist/utility/wrun/wrun-volume-profile-lane.util.js +66 -0
  325. package/dist/utility/wrun-display-name.util.d.ts +33 -0
  326. package/dist/utility/wrun-display-name.util.js +64 -0
  327. package/dist/workers/constants/kscript-transport-codes.d.ts +15 -0
  328. package/dist/workers/constants/kscript-transport-codes.js +15 -0
  329. package/dist/workers/constants/socket-slots.d.ts +574 -0
  330. package/dist/workers/constants/socket-slots.js +539 -0
  331. package/dist/workers/utils/number.worker.util.d.ts +5 -0
  332. package/dist/workers/utils/number.worker.util.js +10 -0
  333. package/dist/workers/utils/time.worker.util.d.ts +12 -0
  334. package/dist/workers/utils/time.worker.util.js +24 -0
  335. package/dist/workers/utils/volume-profile.worker.util.d.ts +200 -0
  336. package/dist/workers/utils/volume-profile.worker.util.js +631 -0
  337. package/package.json +10 -4
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The store-free pool symbol helpers: pool venues, a pool raw symbol's parts, pasted Solana addresses, the pool-aware
3
+ * formula tokenizer and casing, and the pool labels that need no DEX name. A leaf with no imports, split out of
4
+ * utility/pool-symbol.util.ts (which re-exports every name here and keeps `poolDisplayLabel`, the one helper that reads
5
+ * the asset names store), so the market utilities and the formula parser read them without the store
6
+ * (docs/features/kscript/wrun/wrun-chart-host.md, "Leaves").
7
+ */
8
+ /** Pool-series symbols are data-plane identities, including their original case. */
9
+ export declare function isPoolSeriesExchange(exchange: string | undefined): boolean;
10
+ /** Display parts of a bare pool raw symbol; the full raw string remains the series identity. */
11
+ export declare function poolSymbolPair(raw: string): {
12
+ base: string;
13
+ quote: string;
14
+ address: string;
15
+ } | undefined;
16
+ /** A whole string that is a Solana address: a memecoin mint pasted into search, a launchpad key. */
17
+ export declare function isSolanaBase58Address(text: string): boolean;
18
+ export declare function poolAwareTokens(text: string, tokenizeLegacy: (text: string) => string[]): string[];
19
+ /** Canonicalize venue spelling, never the raw pool symbol, including incomplete typed input. */
20
+ export declare function poolAwareUppercase(text: string): string;
21
+ export declare function formatPoolAddress(address: string): string;
22
+ /** Where a pool trades, for display: its DEX ("Raydium CLMM"), else the shortened pool address. */
23
+ export declare function poolVenueLabel(address: string, dexName: string | undefined): string;
24
+ export declare function displayedPool(exchange: string | undefined, symbol: string | null | undefined): {
25
+ base: string;
26
+ quote: string;
27
+ address: string;
28
+ } | undefined;
29
+ /**
30
+ * A pool market's pair as the ticker bar writes it ("CRCLx / USDC"), for a slot too narrow for its
31
+ * venue (a card watermark, a pill). Undefined for anything that is not a pool market, so a caller keeps
32
+ * its own label with `poolDisplayPair(…) ?? label`.
33
+ */
34
+ export declare function poolDisplayPair(exchange: string | undefined, symbol: string | null | undefined): string | undefined;
@@ -0,0 +1,95 @@
1
+ /**
2
+ * The store-free pool symbol helpers: pool venues, a pool raw symbol's parts, pasted Solana addresses, the pool-aware
3
+ * formula tokenizer and casing, and the pool labels that need no DEX name. A leaf with no imports, split out of
4
+ * utility/pool-symbol.util.ts (which re-exports every name here and keeps `poolDisplayLabel`, the one helper that reads
5
+ * the asset names store), so the market utilities and the formula parser read them without the store
6
+ * (docs/features/kscript/wrun/wrun-chart-host.md, "Leaves").
7
+ */
8
+ /** Pool-series symbols are data-plane identities, including their original case. */
9
+ export function isPoolSeriesExchange(exchange) {
10
+ const venue = exchange?.toUpperCase();
11
+ return venue === 'BNB_ONCHAIN' || venue === 'SOLANA_ONCHAIN';
12
+ }
13
+ /** Display parts of a bare pool raw symbol; the full raw string remains the series identity. */
14
+ export function poolSymbolPair(raw) {
15
+ const match = /^([A-Za-z0-9._]+)\/([A-Za-z0-9._-]+):([A-Za-z0-9]+)$/.exec(raw);
16
+ return match ? { base: match[1], quote: match[2], address: match[3] } : undefined;
17
+ }
18
+ // The base58 of a 32-byte key, as a Solana mint or wallet is spelled: 32 to 44 characters of the
19
+ // base58 alphabet. Not decoded (nothing here needs the bytes).
20
+ const SOLANA_ADDRESS = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
21
+ /** A whole string that is a Solana address: a memecoin mint pasted into search, a launchpad key. */
22
+ export function isSolanaBase58Address(text) {
23
+ return SOLANA_ADDRESS.test(text);
24
+ }
25
+ // Only explicitly routed pool markets are atoms in a formula. Other venues keep
26
+ // their existing tokenizer, including slash as division and legacy aliases.
27
+ const POOL_TOKEN = /\b(?:BNB_ONCHAIN|SOLANA_ONCHAIN)\|[A-Za-z0-9._]+\/[A-Za-z0-9._-]+:[A-Za-z0-9]+/gi;
28
+ export function poolAwareTokens(text, tokenizeLegacy) {
29
+ const tokens = [];
30
+ let start = 0;
31
+ for (const match of text.matchAll(POOL_TOKEN)) {
32
+ tokens.push(...tokenizeLegacy(text.slice(start, match.index)), match[0]);
33
+ start = match.index + match[0].length;
34
+ }
35
+ tokens.push(...tokenizeLegacy(text.slice(start)));
36
+ return tokens;
37
+ }
38
+ /** Canonicalize venue spelling, never the raw pool symbol, including incomplete typed input. */
39
+ export function poolAwareUppercase(text) {
40
+ // A pasted address is a case-sensitive identity (a memecoin's mint, a launchpad key): it is
41
+ // looked up as typed, never canonicalized.
42
+ if (isSolanaBase58Address(text.trim()))
43
+ return text;
44
+ if (poolSymbolPair(text))
45
+ return text;
46
+ return poolAwareTokens(text, (part) => {
47
+ // While typing, keep the tail after a known venue intact before the pair/ID is complete. A
48
+ // launchpad market is keyed by a bare base58 or checksummed address, which ends at the next
49
+ // operator rather than carrying a pair.
50
+ const pattern = /\b(?:(BNB_ONCHAIN|SOLANA_ONCHAIN)\|[^\s+*()|]*|(SOLANA_LAUNCHPAD|ROBINHOOD_LAUNCHPAD)\|[^\s+*/()|-]*)/gi;
51
+ let result = '';
52
+ let start = 0;
53
+ for (const match of part.matchAll(pattern)) {
54
+ const venue = match[1] ?? match[2];
55
+ result += part.slice(start, match.index).toUpperCase();
56
+ result += venue.toUpperCase() + match[0].slice(venue.length);
57
+ start = match.index + match[0].length;
58
+ }
59
+ return [result + part.slice(start).toUpperCase()];
60
+ })
61
+ .map((part) => {
62
+ const boundary = part.indexOf('|');
63
+ return boundary > 0 &&
64
+ isPoolSeriesExchange(part.slice(0, boundary).toUpperCase()) &&
65
+ poolSymbolPair(part.slice(boundary + 1))
66
+ ? part.slice(0, boundary).toUpperCase() + part.slice(boundary)
67
+ : part;
68
+ })
69
+ .join('');
70
+ }
71
+ export function formatPoolAddress(address) {
72
+ return address.length > 15 ? `${address.slice(0, 6)}…${address.slice(-6)}` : address;
73
+ }
74
+ /** Where a pool trades, for display: its DEX ("Raydium CLMM"), else the shortened pool address. */
75
+ export function poolVenueLabel(address, dexName) {
76
+ return dexName || formatPoolAddress(address);
77
+ }
78
+ // A pool market's parts, or undefined for anything that is not one. A caller that holds no exchange
79
+ // (a layout preview stores none) passes undefined and the symbol's pool shape decides; with an exchange,
80
+ // only a pool venue's symbol reads as a pool (a CEX symbol may take the same shape).
81
+ // Exported for `poolDisplayLabel` (pool-symbol.util.ts), which reads the same parts beside the store's DEX name.
82
+ export function displayedPool(exchange, symbol) {
83
+ if (!symbol || (exchange && !isPoolSeriesExchange(exchange)))
84
+ return undefined;
85
+ return poolSymbolPair(symbol);
86
+ }
87
+ /**
88
+ * A pool market's pair as the ticker bar writes it ("CRCLx / USDC"), for a slot too narrow for its
89
+ * venue (a card watermark, a pill). Undefined for anything that is not a pool market, so a caller keeps
90
+ * its own label with `poolDisplayPair(…) ?? label`.
91
+ */
92
+ export function poolDisplayPair(exchange, symbol) {
93
+ const pool = displayedPool(exchange, symbol);
94
+ return pool ? `${pool.base} / ${pool.quote}` : undefined;
95
+ }
@@ -0,0 +1,109 @@
1
+ /**
2
+ * The browser run's failure rows and the runtime diagnostics normalizer, split out of runtime-diagnostics.util.ts with
3
+ * no change (that module re-exports every name here): the AssemblyScript trap row, the run-failure rows in the author's
4
+ * words, the setting refusal's words, the codes the run's failure seam owns, the one refusal-notice rule and the
5
+ * normalizer every lane reads a diagnostics array through. A leaf with no app edge, so the wrun chart-host package's
6
+ * socket source and row builder read it (docs/features/kscript/wrun/wrun-chart-host.md, "Leaves").
7
+ */
8
+ import type { RuntimeDiagnostic } from '../../interfaces/kscript-diagnostics.interface.js';
9
+ import type { WrunRefusal } from '../wrun/wrun-refusal.util.js';
10
+ /**
11
+ * A browser-run Indicator's AssemblyScript trap (`env.abort`: a throw, a std-lib bounds
12
+ * check, the author's own abort()) as a runtime diagnostic row, so the editor console shows
13
+ * it through the same path kScript runtime rows take. The sandbox throws
14
+ * `AssemblyScript abort: <message> at <path>:<line>:<column>` (workers/wrun/wrun-abi-host
15
+ * `formatAssemblyScriptAbort`): the message part only when the guest passed one, the
16
+ * position only when asc supplied one (an explicit abort("x") carries neither a path nor a
17
+ * position; a throw carries `src/indicator.ts`; a bounds check carries `~lib/array.ts`).
18
+ * The row is anchored (line/column set, so the console jump and the squiggle land) ONLY
19
+ * when the path names the buffer: a trap inside the std lib or the SDK, and a trap without a
20
+ * path, are reported without a position rather than pinned to a line of the buffer that has
21
+ * nothing to do with it. asc's line and column are both 1-based (verified against the real
22
+ * toolchain in tests/workers/wrun/wrun-abi-host.abort.spec.ts), the editor's convention, so
23
+ * the row carries them verbatim.
24
+ */
25
+ export declare const WRUN_ABORT_DIAGNOSTIC_CODE = "WRUN_ABORT";
26
+ export declare const WRUN_ABORT_ENTRY_FILE = "src/indicator.ts";
27
+ /**
28
+ * The trap row. A kit class's abort (its words lead with the class) carries no position, so the row names the class
29
+ * (`details.anchorClass`) and the editor lands it on the first `new <Class>(` of the author's buffer
30
+ * (`runtimeDiagnosticToScriptEditorIssue`, the `anchorExport` pattern). The row's message stays the sandbox's raw
31
+ * words: the editor console and the legend's Copy details read them; the legend's own words for a viewer are one
32
+ * translated sentence (`legendDiagnosticText`), and the raw words are never toasted (`shouldToastRuntimeDiagnostic`).
33
+ */
34
+ export declare function wrunAbortRuntimeDiagnostic(message: string): RuntimeDiagnostic | null;
35
+ /**
36
+ * The browser sandbox's other run failures, said in the author's words: the host's output
37
+ * contract (`never wrote declared output(s) N`, `left declared output(s) N outside the
38
+ * returnOutput count`), the run deadline (`WRUN run N timed out after Nms`), the no-growth
39
+ * rule (`WRUN memory grew ...`: since scaffold 61, kit 0.62.0 here, a short-form file's per-bar temporaries are
40
+ * collected, so what grows is kept state or one bar's temporaries past the start-up's scratch
41
+ * room; the four-function form gets no scratch room), a trap the engine names `unreachable` (the usual cause: memory
42
+ * asked past the limit the module is clamped to when it loads) and a module import the host
43
+ * cannot link (a LinkError on `env.console.log`, from a module built elsewhere; the compile
44
+ * lane refuses it earlier).
45
+ * Each becomes a runtime diagnostic row like a trap, with `details.anchorExport` naming the
46
+ * export whose body to look at: the console resolves it against the buffer
47
+ * (`runtimeDiagnosticToScriptEditorIssue` with the source) so the jump lands on
48
+ * `export function finalize` / `state` instead of nowhere, or, in a short-form file (a
49
+ * top-level `function onBar(): void`, scaffold 29), on the hook that stands in for it (see
50
+ * `exportLineOf`). `outputNames` (the sheet's, in slot order) names the slot when the caller
51
+ * has the sheet; the index is said otherwise. The two output-contract rows cannot fire for a
52
+ * short-form file (its build writes NaN to every output before `onBar()` and emits the row
53
+ * after it); their wording stays the four-function form's.
54
+ */
55
+ export declare const WRUN_OUTPUT_NOT_WRITTEN_CODE = "WRUN_OUTPUT_NOT_WRITTEN";
56
+ export declare const WRUN_ROW_NOT_EMITTED_CODE = "WRUN_ROW_NOT_EMITTED";
57
+ export declare const WRUN_RUN_TIMEOUT_CODE = "WRUN_RUN_TIMEOUT";
58
+ export declare const WRUN_MEMORY_GROWTH_CODE = "WRUN_MEMORY_GROWTH";
59
+ export declare const WRUN_UNREACHABLE_TRAP_CODE = "WRUN_UNREACHABLE_TRAP";
60
+ export declare const WRUN_UNSUPPORTED_IMPORT_CODE = "WRUN_UNSUPPORTED_IMPORT";
61
+ /**
62
+ * A setting the param value rule refuses before init() (`buildWrunInitArgs`, the rule the om
63
+ * daemon runs: not finite, below min, above max, not a whole number for an int, outside a choice's
64
+ * options; a declared step is only the stepper's increment). A kScript built-in refuses the same
65
+ * setting at input(), and its refusal reaches the console as a runtime row; this is that row for a
66
+ * twin, with the setting's name and the rule's words, each of which starts "must " (the shape
67
+ * WRUN_SETTING_REFUSED_RE reads). Rerunning refuses again, so the row (no Retry) stands until a
68
+ * settings edit runs.
69
+ */
70
+ export declare const WRUN_SETTING_REFUSED_CODE = "WRUN_SETTING_REFUSED";
71
+ /** The refusal's words, built in one place so the run (the producer) and this seam (the reader)
72
+ * never drift. */
73
+ export declare function wrunSettingRefusedMessage(name: string, refusal: string): string;
74
+ /** Every code the browser run's failure seam owns as a runtime row (`wrun-overlay-run.util`):
75
+ * a new failure replaces any of them and a success clears all of them, so a row never
76
+ * outlives the run that raised it and two failures never pile up. The run deadline is NOT in
77
+ * the set: a run queued behind a slow one can hit it without the author's code being at
78
+ * fault, so it keeps the legend's retryable data chip (with this module's sentence in its
79
+ * card) instead of a standing row. */
80
+ export declare const WRUN_RUN_FAILURE_ROW_CODES: ReadonlySet<string>;
81
+ export type WrunAnchorExport = 'init' | 'state' | 'finalize' | 'reset';
82
+ export declare function wrunRunFailureRuntimeDiagnostic(message: string, context?: {
83
+ outputNames?: readonly string[];
84
+ }): RuntimeDiagnostic | null;
85
+ export interface NormalizeRuntimeDiagnosticsOptions {
86
+ /**
87
+ * kScript currently emits RENDER_NO_PLOT when a script only produces drawings.
88
+ * The chart can render those drawings, so that diagnostic is stale for this
89
+ * run and would incorrectly mark a valid drawing-only script as broken.
90
+ */
91
+ hasVisibleDrawings?: boolean;
92
+ }
93
+ export declare function normalizeRuntimeDiagnostics(value: unknown, options?: NormalizeRuntimeDiagnosticsOptions): RuntimeDiagnostic[];
94
+ /**
95
+ * The other half of the rule: a refusal record's notice (the refusal surface's toast, the record's
96
+ * sentence and its way out) is said for a `paused` record only, once per user attempt. Both lanes
97
+ * claim the same attempt token (`claim`, asked only for a paused record; claimWrunRefusalNotice):
98
+ * the browser executor opens one per run, the cloud lane at a person's add (chart.add-indicator),
99
+ * Retry, and a settings save only with the protected run it dispatches
100
+ * (openRuntimeDiagnosticRefusalAttempt: a Style-only or satisfied save opens none). The attempt
101
+ * travels ON the request (`IndicatorDataOptions.refusalAttempt`, kept through a transport retry),
102
+ * never read off the overlay: only that request's refusal terminals claim it, and every end of the
103
+ * request that hands off to no retry concludes it (concludeWrunRefusalAttempt: answered, superseded
104
+ * or held), so a reconnect recreate, a pan page, a shape-stage refusal, the reconcile, the theme
105
+ * re-apply or a collaborator's change carries nothing and never notices. A person's interval change
106
+ * notices nothing either (chip and card only, as the browser lane's system `switch` rerun). No
107
+ * attempt (a restore, a remote apply, a history replay) never notices. A note never toasts.
108
+ */
109
+ export declare function shouldNoticeWrunRefusal(refusal: WrunRefusal | null | undefined, claim: () => boolean): boolean;
@@ -0,0 +1,302 @@
1
+ import { WRUN_MEMORY_LIMIT_BYTES } from '../wrun/wrun-memory-clamp.util.js';
2
+ const DIAGNOSTIC_STAGES = new Set(['resolve', 'fetch', 'compute', 'render', 'boundary']);
3
+ const DIAGNOSTIC_SEVERITIES = new Set(['error', 'warning', 'info']);
4
+ const NON_USER_VISIBLE_DIAGNOSTIC_CODES = new Set([
5
+ // Engine/backend routing details. Useful in backend diagnostics, noisy and non-actionable in chart UI.
6
+ 'WASM_DELEGATED',
7
+ // A protected live recompute produced no newer frame. The backend should keep it for operators, but users only
8
+ // need to see persistent drawable/fetch/render failures.
9
+ 'LIVE_STALE_FRAME',
10
+ ]);
11
+ // Author-facing fix hints for the highest-frequency runtime failures. The engine does
12
+ // attach a generic suggestedFix ("check the plotted expression for NaN values"), but for
13
+ // these common cases the FE owns clearer, cause-naming copy (uninitialized persist, the
14
+ // list of plot calls), so the curated hint WINS here; every other code falls back to the
15
+ // server-provided suggestedFix. Plain strings (not i18n) to match the engine's own
16
+ // non-localized messages and to stay worker-safe.
17
+ const DIAGNOSTIC_CODE_FIXES = {
18
+ RENDER_NO_PLOT: 'Add at least one plot output, such as plotLine, plotCandle, hline, plotShape, or plotPriceLabel.',
19
+ COMPUTE_ALL_NAN: 'Every output value is na across the whole range, so nothing is drawn. Check that your sources return data and that you are not plotting an uninitialized persist value or a series that is never assigned.',
20
+ FE_EXECUTION_PAUSED: 'Use Resume in the legend card. If it pauses again, reduce the plotted range, plot count, or script work per update.',
21
+ };
22
+ /**
23
+ * A browser-run Indicator's AssemblyScript trap (`env.abort`: a throw, a std-lib bounds
24
+ * check, the author's own abort()) as a runtime diagnostic row, so the editor console shows
25
+ * it through the same path kScript runtime rows take. The sandbox throws
26
+ * `AssemblyScript abort: <message> at <path>:<line>:<column>` (workers/wrun/wrun-abi-host
27
+ * `formatAssemblyScriptAbort`): the message part only when the guest passed one, the
28
+ * position only when asc supplied one (an explicit abort("x") carries neither a path nor a
29
+ * position; a throw carries `src/indicator.ts`; a bounds check carries `~lib/array.ts`).
30
+ * The row is anchored (line/column set, so the console jump and the squiggle land) ONLY
31
+ * when the path names the buffer: a trap inside the std lib or the SDK, and a trap without a
32
+ * path, are reported without a position rather than pinned to a line of the buffer that has
33
+ * nothing to do with it. asc's line and column are both 1-based (verified against the real
34
+ * toolchain in tests/workers/wrun/wrun-abi-host.abort.spec.ts), the editor's convention, so
35
+ * the row carries them verbatim.
36
+ */
37
+ export const WRUN_ABORT_DIAGNOSTIC_CODE = 'WRUN_ABORT';
38
+ export const WRUN_ABORT_ENTRY_FILE = 'src/indicator.ts';
39
+ const WRUN_ABORT_MESSAGE = /AssemblyScript abort(?::\s*(?<detail>[\s\S]*?))?(?:\s+at\s+(?:(?<path>[^\s:]+):)?(?<line>\d+):(?<column>\d+))?\s*$/;
40
+ /** A kit class's own abort leads with the class (`Bucket: bad span '300.0'`, `Session: bad spec`, `Clock: unknown
41
+ * zone`): the kit compiles into the package, so the trap carries no position in the author's file. */
42
+ const WRUN_KIT_ABORT_CLASS = /^(?<name>[A-Z][A-Za-z0-9]*): /;
43
+ /**
44
+ * The trap row. A kit class's abort (its words lead with the class) carries no position, so the row names the class
45
+ * (`details.anchorClass`) and the editor lands it on the first `new <Class>(` of the author's buffer
46
+ * (`runtimeDiagnosticToScriptEditorIssue`, the `anchorExport` pattern). The row's message stays the sandbox's raw
47
+ * words: the editor console and the legend's Copy details read them; the legend's own words for a viewer are one
48
+ * translated sentence (`legendDiagnosticText`), and the raw words are never toasted (`shouldToastRuntimeDiagnostic`).
49
+ */
50
+ export function wrunAbortRuntimeDiagnostic(message) {
51
+ const match = WRUN_ABORT_MESSAGE.exec(message);
52
+ if (!match?.groups)
53
+ return null;
54
+ const line = match.groups.line === undefined ? 0 : Number(match.groups.line);
55
+ const column = match.groups.column === undefined ? 0 : Number(match.groups.column);
56
+ const anchored = match.groups.path === WRUN_ABORT_ENTRY_FILE && line > 0;
57
+ const kitClass = anchored ? undefined : WRUN_KIT_ABORT_CLASS.exec(match.groups.detail ?? '')?.groups?.name;
58
+ return {
59
+ stage: 'compute',
60
+ severity: 'error',
61
+ code: WRUN_ABORT_DIAGNOSTIC_CODE,
62
+ message: message.trim(),
63
+ type: 'execution',
64
+ ...(anchored ? { line, ...(column > 0 ? { column } : {}) } : {}),
65
+ ...(kitClass !== undefined ? { details: { anchorClass: kitClass } } : {}),
66
+ };
67
+ }
68
+ /**
69
+ * The browser sandbox's other run failures, said in the author's words: the host's output
70
+ * contract (`never wrote declared output(s) N`, `left declared output(s) N outside the
71
+ * returnOutput count`), the run deadline (`WRUN run N timed out after Nms`), the no-growth
72
+ * rule (`WRUN memory grew ...`: since scaffold 61, kit 0.62.0 here, a short-form file's per-bar temporaries are
73
+ * collected, so what grows is kept state or one bar's temporaries past the start-up's scratch
74
+ * room; the four-function form gets no scratch room), a trap the engine names `unreachable` (the usual cause: memory
75
+ * asked past the limit the module is clamped to when it loads) and a module import the host
76
+ * cannot link (a LinkError on `env.console.log`, from a module built elsewhere; the compile
77
+ * lane refuses it earlier).
78
+ * Each becomes a runtime diagnostic row like a trap, with `details.anchorExport` naming the
79
+ * export whose body to look at: the console resolves it against the buffer
80
+ * (`runtimeDiagnosticToScriptEditorIssue` with the source) so the jump lands on
81
+ * `export function finalize` / `state` instead of nowhere, or, in a short-form file (a
82
+ * top-level `function onBar(): void`, scaffold 29), on the hook that stands in for it (see
83
+ * `exportLineOf`). `outputNames` (the sheet's, in slot order) names the slot when the caller
84
+ * has the sheet; the index is said otherwise. The two output-contract rows cannot fire for a
85
+ * short-form file (its build writes NaN to every output before `onBar()` and emits the row
86
+ * after it); their wording stays the four-function form's.
87
+ */
88
+ export const WRUN_OUTPUT_NOT_WRITTEN_CODE = 'WRUN_OUTPUT_NOT_WRITTEN';
89
+ export const WRUN_ROW_NOT_EMITTED_CODE = 'WRUN_ROW_NOT_EMITTED';
90
+ export const WRUN_RUN_TIMEOUT_CODE = 'WRUN_RUN_TIMEOUT';
91
+ export const WRUN_MEMORY_GROWTH_CODE = 'WRUN_MEMORY_GROWTH';
92
+ export const WRUN_UNREACHABLE_TRAP_CODE = 'WRUN_UNREACHABLE_TRAP';
93
+ export const WRUN_UNSUPPORTED_IMPORT_CODE = 'WRUN_UNSUPPORTED_IMPORT';
94
+ /**
95
+ * A setting the param value rule refuses before init() (`buildWrunInitArgs`, the rule the om
96
+ * daemon runs: not finite, below min, above max, not a whole number for an int, outside a choice's
97
+ * options; a declared step is only the stepper's increment). A kScript built-in refuses the same
98
+ * setting at input(), and its refusal reaches the console as a runtime row; this is that row for a
99
+ * twin, with the setting's name and the rule's words, each of which starts "must " (the shape
100
+ * WRUN_SETTING_REFUSED_RE reads). Rerunning refuses again, so the row (no Retry) stands until a
101
+ * settings edit runs.
102
+ */
103
+ export const WRUN_SETTING_REFUSED_CODE = 'WRUN_SETTING_REFUSED';
104
+ const WRUN_SETTING_REFUSED_RE = /^Setting '[^']+' must /;
105
+ /** The refusal's words, built in one place so the run (the producer) and this seam (the reader)
106
+ * never drift. */
107
+ export function wrunSettingRefusedMessage(name, refusal) {
108
+ return `Setting '${name}' ${refusal}`;
109
+ }
110
+ /** Every code the browser run's failure seam owns as a runtime row (`wrun-overlay-run.util`):
111
+ * a new failure replaces any of them and a success clears all of them, so a row never
112
+ * outlives the run that raised it and two failures never pile up. The run deadline is NOT in
113
+ * the set: a run queued behind a slow one can hit it without the author's code being at
114
+ * fault, so it keeps the legend's retryable data chip (with this module's sentence in its
115
+ * card) instead of a standing row. */
116
+ export const WRUN_RUN_FAILURE_ROW_CODES = new Set([
117
+ WRUN_ABORT_DIAGNOSTIC_CODE,
118
+ WRUN_OUTPUT_NOT_WRITTEN_CODE,
119
+ WRUN_ROW_NOT_EMITTED_CODE,
120
+ WRUN_MEMORY_GROWTH_CODE,
121
+ WRUN_UNREACHABLE_TRAP_CODE,
122
+ WRUN_UNSUPPORTED_IMPORT_CODE,
123
+ WRUN_SETTING_REFUSED_CODE,
124
+ ]);
125
+ const WRUN_OUTPUT_NOT_WRITTEN_RE = /never wrote declared output\(s\) ([\d, ]+)/;
126
+ const WRUN_ROW_NOT_EMITTED_RE = /left declared output\(s\) ([\d, ]+) outside the returnOutput count (\d+)/;
127
+ const WRUN_RUN_TIMEOUT_RE = /WRUN run \S+ timed out after (\d+)ms/;
128
+ const WRUN_MEMORY_GROWTH_RE = /WRUN memory grew from (\d+) to (\d+) bytes after init/;
129
+ /** A guest that reached `unreachable`, in each engine's own words: V8 (Chrome, Node)
130
+ * `unreachable`, SpiderMonkey (Firefox) `unreachable executed`, JavaScriptCore (Safari)
131
+ * `Unreachable code should not be executed`; a stringified error leads with its name. The
132
+ * worker posts a trap's message as the engine wrote it, so the whole message must match. */
133
+ const WRUN_UNREACHABLE_TRAP_RE = /^(?:RuntimeError: )?(?:unreachable(?: executed)?|Unreachable code should not be executed)$/;
134
+ const WRUN_LINK_IMPORT_RE = /module="(?<module>[^"]+)"\s+function="(?<name>[^"]+)"/;
135
+ function slotWords(indexes, outputNames) {
136
+ return indexes
137
+ .split(',')
138
+ .map((part) => part.trim())
139
+ .filter(Boolean)
140
+ .map((part) => {
141
+ const index = Number(part);
142
+ const name = outputNames?.[index];
143
+ return name ? `'${name}' (#${index + 1})` : `#${index + 1}`;
144
+ })
145
+ .join(', ');
146
+ }
147
+ function writerWords(indexes, outputNames) {
148
+ const names = indexes
149
+ .split(',')
150
+ .map((part) => outputNames?.[Number(part.trim())])
151
+ .filter((name) => Boolean(name));
152
+ return names.length > 0 ? names.map((name) => `out_${name}(value)`).join(', ') : 'its out_<output>(value) writer';
153
+ }
154
+ function wrunRunFailureRow(code, message, suggestedFix, anchorExport, original) {
155
+ return {
156
+ stage: 'compute',
157
+ severity: 'error',
158
+ code,
159
+ message,
160
+ suggestedFix,
161
+ type: 'execution',
162
+ details: { anchorExport, hostMessage: original.trim() },
163
+ };
164
+ }
165
+ export function wrunRunFailureRuntimeDiagnostic(message, context = {}) {
166
+ if (WRUN_SETTING_REFUSED_RE.test(message)) {
167
+ return {
168
+ stage: 'compute',
169
+ severity: 'error',
170
+ code: WRUN_SETTING_REFUSED_CODE,
171
+ message: message.trim(),
172
+ suggestedFix: "Change this setting in the indicator's settings.",
173
+ type: 'validation',
174
+ };
175
+ }
176
+ const notWritten = WRUN_OUTPUT_NOT_WRITTEN_RE.exec(message);
177
+ if (notWritten) {
178
+ const slots = slotWords(notWritten[1], context.outputNames);
179
+ return wrunRunFailureRow(WRUN_OUTPUT_NOT_WRITTEN_CODE, `Output ${slots} was never written: finalize() must write every declared output before emitRow().`, `In finalize(), call ${writerWords(notWritten[1], context.outputNames)} for every bar state() returned 1 on, then emitRow().`, 'finalize', message);
180
+ }
181
+ const notEmitted = WRUN_ROW_NOT_EMITTED_RE.exec(message);
182
+ if (notEmitted) {
183
+ return wrunRunFailureRow(WRUN_ROW_NOT_EMITTED_CODE, 'finalize() never called emitRow(): the outputs were written but no row reached the chart.', 'Call emitRow() at the end of finalize(), after the out_<output>() writers.', 'finalize', message);
184
+ }
185
+ const timeout = WRUN_RUN_TIMEOUT_RE.exec(message);
186
+ if (timeout) {
187
+ const seconds = Math.round(Number(timeout[1]) / 1000);
188
+ return wrunRunFailureRow(WRUN_RUN_TIMEOUT_CODE, `The run did not finish within ${seconds} s.`, 'If state() or finalize() loops, check that every while / for ends on every bar and keep per-bar work bounded; if another run was holding the sandbox, run it again.', 'state', message);
189
+ }
190
+ const growth = WRUN_MEMORY_GROWTH_RE.exec(message);
191
+ if (growth) {
192
+ return wrunRunFailureRow(WRUN_MEMORY_GROWTH_CODE, `The Indicator's memory kept growing once the bars started (${growth[1]} to ${growth[2]} bytes): something it keeps grows every bar (an array pushed each bar, a map that never drops keys), or one bar holds more temporaries at once than fit.`, "Keep what the Indicator holds bounded: a ring buffer sized from a param's max, made once in onStart() (init() with the four functions), instead of an array that grows every bar. Arrays and strings made in onBar() and dropped are collected; with the four functions, keep state() and finalize() free of new arrays and strings, since that form's start-up reserves no room for them.", 'state', message);
193
+ }
194
+ if (WRUN_UNREACHABLE_TRAP_RE.test(message.trim())) {
195
+ // AssemblyScript's allocator traps here when the engine refuses memory.grow: the module's
196
+ // memory is clamped to the limit when it loads (wrun-memory-clamp.util), so asking past it
197
+ // stops the call instead of growing the tab's memory. Buffers are sized where they are
198
+ // made, init() (onStart() in a short-form file), so the row anchors there.
199
+ const limit = `${WRUN_MEMORY_LIMIT_BYTES / (1024 * 1024)} MiB`;
200
+ const f64Values = (WRUN_MEMORY_LIMIT_BYTES / 8).toLocaleString('en-US');
201
+ return wrunRunFailureRow(WRUN_UNREACHABLE_TRAP_CODE, `The Indicator stopped at a trap: the usual cause is asking for more than the ${limit} of memory a module may use, such as a buffer sized past what it needs.`, `Size each buffer from a param's max instead of a large fixed count, and keep arrays small: ${limit} is ${f64Values} f64 values for everything the module keeps.`, 'init', message);
202
+ }
203
+ const link = WRUN_LINK_IMPORT_RE.exec(message);
204
+ if (link?.groups && /LinkError|instantiate|import requires a callable/i.test(message)) {
205
+ const name = `${link.groups.module}.${link.groups.name}`;
206
+ return wrunRunFailureRow(WRUN_UNSUPPORTED_IMPORT_CODE, `${name} is not available in an Indicator: the sandbox provides no host functions beyond the Indicator ABI (console, Date, Math.random, performance are not there).`, 'Remove the call; log through the debug output instead (string("debug", { max_bytes: 256 }) and str_debug(text) in finalize()).', 'state', message);
207
+ }
208
+ return null;
209
+ }
210
+ function isObject(value) {
211
+ return typeof value === 'object' && value !== null;
212
+ }
213
+ function positiveInteger(value) {
214
+ if (typeof value !== 'number' || !Number.isFinite(value))
215
+ return undefined;
216
+ const integer = Math.floor(value);
217
+ return integer > 0 ? integer : undefined;
218
+ }
219
+ function optionalString(value) {
220
+ return typeof value === 'string' && value.trim().length > 0 ? value : undefined;
221
+ }
222
+ function normalizeStage(stage) {
223
+ return typeof stage === 'string' && DIAGNOSTIC_STAGES.has(stage)
224
+ ? stage
225
+ : 'boundary';
226
+ }
227
+ function normalizeSeverity(severity) {
228
+ return typeof severity === 'string' && DIAGNOSTIC_SEVERITIES.has(severity)
229
+ ? severity
230
+ : 'warning';
231
+ }
232
+ function runtimeDiagnosticIdentity(diagnostic) {
233
+ return [
234
+ diagnostic.stage,
235
+ diagnostic.code,
236
+ diagnostic.sourceId ?? '',
237
+ diagnostic.plotId ?? '',
238
+ diagnostic.barIndex ?? '',
239
+ diagnostic.line ?? '',
240
+ diagnostic.column ?? '',
241
+ diagnostic.message,
242
+ ].join('|');
243
+ }
244
+ export function normalizeRuntimeDiagnostics(value, options = {}) {
245
+ if (!Array.isArray(value))
246
+ return [];
247
+ const diagnostics = value.flatMap((raw) => {
248
+ if (!isObject(raw))
249
+ return [];
250
+ const code = optionalString(raw.code);
251
+ const message = optionalString(raw.message) ?? code;
252
+ if (!code || !message)
253
+ return [];
254
+ if (NON_USER_VISIBLE_DIAGNOSTIC_CODES.has(code))
255
+ return [];
256
+ if (options.hasVisibleDrawings && code === 'RENDER_NO_PLOT')
257
+ return [];
258
+ return [
259
+ {
260
+ stage: normalizeStage(raw.stage),
261
+ severity: normalizeSeverity(raw.severity),
262
+ code,
263
+ message,
264
+ suggestedFix: DIAGNOSTIC_CODE_FIXES[code] ?? optionalString(raw.suggestedFix),
265
+ line: positiveInteger(raw.line),
266
+ column: positiveInteger(raw.column),
267
+ plotId: optionalString(raw.plotId),
268
+ sourceId: optionalString(raw.sourceId),
269
+ barIndex: positiveInteger(raw.barIndex),
270
+ generation: positiveInteger(raw.generation),
271
+ type: optionalString(raw.type),
272
+ details: isObject(raw.details) ? { ...raw.details } : undefined,
273
+ },
274
+ ];
275
+ });
276
+ const seen = new Set();
277
+ return diagnostics.filter((diagnostic) => {
278
+ const key = runtimeDiagnosticIdentity(diagnostic);
279
+ if (seen.has(key))
280
+ return false;
281
+ seen.add(key);
282
+ return true;
283
+ });
284
+ }
285
+ /**
286
+ * The other half of the rule: a refusal record's notice (the refusal surface's toast, the record's
287
+ * sentence and its way out) is said for a `paused` record only, once per user attempt. Both lanes
288
+ * claim the same attempt token (`claim`, asked only for a paused record; claimWrunRefusalNotice):
289
+ * the browser executor opens one per run, the cloud lane at a person's add (chart.add-indicator),
290
+ * Retry, and a settings save only with the protected run it dispatches
291
+ * (openRuntimeDiagnosticRefusalAttempt: a Style-only or satisfied save opens none). The attempt
292
+ * travels ON the request (`IndicatorDataOptions.refusalAttempt`, kept through a transport retry),
293
+ * never read off the overlay: only that request's refusal terminals claim it, and every end of the
294
+ * request that hands off to no retry concludes it (concludeWrunRefusalAttempt: answered, superseded
295
+ * or held), so a reconnect recreate, a pan page, a shape-stage refusal, the reconcile, the theme
296
+ * re-apply or a collaborator's change carries nothing and never notices. A person's interval change
297
+ * notices nothing either (chip and card only, as the browser lane's system `switch` rerun). No
298
+ * attempt (a restore, a remote apply, a history replay) never notices. A note never toasts.
299
+ */
300
+ export function shouldNoticeWrunRefusal(refusal, claim) {
301
+ return refusal?.severity === 'paused' && claim();
302
+ }
@@ -0,0 +1,39 @@
1
+ import type { Venue } from '../../interfaces/asset-venue.interface.js';
2
+ export interface CmeContractExpiry {
3
+ /** Contract root, e.g. "BTC" for BTCN6. */
4
+ root: string;
5
+ /** 0-based delivery month. */
6
+ monthIndex: number;
7
+ /** Full delivery year, e.g. 2026. */
8
+ year: number;
9
+ }
10
+ /**
11
+ * Decodes a governed contract code into its delivery month/year, or null when
12
+ * the code does not carry one. Single-digit years are resolved to the nearest
13
+ * matching year in a [now - 2y, now + 7y] window: listings only ever cover
14
+ * nearby expiries, and the window tolerates recently expired contracts
15
+ * without ever wrapping a live listing into the past decade.
16
+ */
17
+ export declare function parseCmeContractExpiry(rawSymbol: string | undefined, now?: Date): CmeContractExpiry | null;
18
+ /**
19
+ * Conservative expiry instant: the END of the delivery month (UTC). Real CME
20
+ * expiry days vary by product (e.g. last Friday for BTC futures); month-end
21
+ * errs toward keeping a just-expired contract visible for a few extra days
22
+ * rather than ever hiding a still-live one.
23
+ */
24
+ export declare function contractExpiryEndMs(expiry: CmeContractExpiry): number;
25
+ export declare function isContractExpired(rawSymbol: string | undefined, now?: Date): boolean;
26
+ /** Localized delivery label, e.g. "Jul 2026" / "2026年7月". '' when undecodable. */
27
+ export declare function formatContractExpiry(rawSymbol: string | undefined, locale: string, now?: Date): string;
28
+ /**
29
+ * Search-list semantics for an asset's venues, applied only to governed
30
+ * contracts (isGovernedContract must be precomputed by the caller for each
31
+ * venue): expired contracts are dropped, live ones carry their expiry, are
32
+ * sorted soonest-first within the governed subsequence (non-governed venues
33
+ * keep the backend's ordering and positions), and the nearest expiry is
34
+ * tagged as the front month. Continuous rows (ES1!) never expire, pin FIRST
35
+ * in the governed run (before the front month), and never take the
36
+ * front-month tag: they are the "just chart it" entry point above the
37
+ * concrete expiries.
38
+ */
39
+ export declare function annotateGovernedContracts(venues: Venue[], isGoverned: (venue: Venue) => boolean, now?: Date): Venue[];