@orangecharts/wrun-chart-host 0.15.0 → 0.17.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 (202) hide show
  1. package/README.md +2 -0
  2. package/dist/constants/economic.constants.d.ts +2 -0
  3. package/dist/constants/economic.constants.js +2 -0
  4. package/dist/constants/feature-flags.constants.d.ts +13 -5
  5. package/dist/constants/feature-flags.constants.js +76 -35
  6. package/dist/constants/feature-limits.constants.d.ts +72 -4
  7. package/dist/constants/feature-limits.constants.js +104 -24
  8. package/dist/constants/interval.constants.js +5 -0
  9. package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +12 -0
  10. package/dist/constants/kscript-data-interval-restrictions.constants.js +14 -0
  11. package/dist/constants/marketCapabilities.constants.d.ts +9 -0
  12. package/dist/constants/marketCapabilities.constants.js +39 -11
  13. package/dist/constants/typed-indicator-source.leaf.d.ts +7 -0
  14. package/dist/constants/typed-indicator-source.leaf.js +47 -0
  15. package/dist/constants/typed-session-history-venue.leaf.d.ts +7 -0
  16. package/dist/constants/typed-session-history-venue.leaf.js +9 -0
  17. package/dist/constants/typed-width-fold.leaf.d.ts +52 -0
  18. package/dist/constants/typed-width-fold.leaf.js +101 -0
  19. package/dist/constants/typed-width-source.leaf.d.ts +24 -0
  20. package/dist/constants/typed-width-source.leaf.js +126 -0
  21. package/dist/constants/typed-width.leaf.d.ts +57 -0
  22. package/dist/constants/typed-width.leaf.js +78 -0
  23. package/dist/host-env.d.ts +10 -0
  24. package/dist/host-env.js +7 -0
  25. package/dist/host-ports.types.d.ts +23 -17
  26. package/dist/index.d.ts +4 -0
  27. package/dist/index.js +4 -0
  28. package/dist/interfaces/kscript-diagnostics.interface.d.ts +35 -0
  29. package/dist/interfaces/wrun-runtime.interface.d.ts +66 -3
  30. package/dist/interfaces/wrun-runtime.interface.js +11 -0
  31. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +13 -0
  32. package/dist/kscript-data/controls/live-trades-merge.util.js +16 -1
  33. package/dist/market-data/billing.interface.d.ts +12 -45
  34. package/dist/market-data/billing.interface.js +2 -2
  35. package/dist/replay/replayLadder.js +7 -4
  36. package/dist/settings-templates/footprint-rows.d.ts +6 -0
  37. package/dist/settings-templates/footprint-rows.js +6 -0
  38. package/dist/settings-templates/frvp-fields.js +14 -0
  39. package/dist/settings-templates/indicator-fields.js +36 -0
  40. package/dist/settings-templates/tool-tables.generated.js +19 -1
  41. package/dist/utility/chart/__fixtures__/live-bucket-regular-golden.json +1706 -0
  42. package/dist/utility/chart/cache-alignment.util.d.ts +42 -0
  43. package/dist/utility/chart/cache-alignment.util.js +88 -18
  44. package/dist/utility/chart/calendar-interval.util.d.ts +83 -1
  45. package/dist/utility/chart/calendar-interval.util.js +152 -4
  46. package/dist/utility/chart/candle-bar-end.util.d.ts +11 -4
  47. package/dist/utility/chart/candle-bar-end.util.js +17 -6
  48. package/dist/utility/chart/chart-time-domain.util.d.ts +3 -0
  49. package/dist/utility/chart/chart-time-domain.util.js +13 -4
  50. package/dist/utility/chart/feed-interval.util.d.ts +4 -2
  51. package/dist/utility/chart/feed-interval.util.js +5 -2
  52. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +3 -1
  53. package/dist/utility/chart/fetch-dedupe-policy.util.js +19 -1
  54. package/dist/utility/chart/footprint-display-mode.util.d.ts +2 -0
  55. package/dist/utility/chart/footprint-display-mode.util.js +5 -0
  56. package/dist/utility/chart/governed-lanes-gate.util.d.ts +46 -0
  57. package/dist/utility/chart/governed-lanes-gate.util.js +71 -0
  58. package/dist/utility/chart/governed-lanes-reader-seat.d.ts +14 -0
  59. package/dist/utility/chart/governed-lanes-reader-seat.js +14 -0
  60. package/dist/utility/chart/history-wall.util.d.ts +13 -2
  61. package/dist/utility/chart/history-wall.util.js +11 -4
  62. package/dist/utility/chart/index-mode-admission.util.js +9 -1
  63. package/dist/utility/chart/index-mode.util.d.ts +2 -2
  64. package/dist/utility/chart/index-mode.util.js +12 -6
  65. package/dist/utility/chart/index-otc.leaf.d.ts +37 -0
  66. package/dist/utility/chart/index-otc.leaf.js +68 -0
  67. package/dist/utility/chart/interval-ladder.util.d.ts +5 -2
  68. package/dist/utility/chart/interval-ladder.util.js +44 -4
  69. package/dist/utility/chart/interval-registry.util.d.ts +22 -1
  70. package/dist/utility/chart/interval-registry.util.js +50 -2
  71. package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +32 -4
  72. package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +22 -5
  73. package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +10 -0
  74. package/dist/utility/chart/kscript-drawing-safe-area.util.js +30 -3
  75. package/dist/utility/chart/kscript-legend-entries.util.d.ts +21 -4
  76. package/dist/utility/chart/kscript-legend-entries.util.js +27 -5
  77. package/dist/utility/chart/kscript-main-grid-stages.util.js +74 -24
  78. package/dist/utility/chart/kscript-provenance-keys.util.js +6 -0
  79. package/dist/utility/chart/kscript-row-name.leaf.d.ts +13 -0
  80. package/dist/utility/chart/kscript-row-name.leaf.js +18 -0
  81. package/dist/utility/chart/kscript-venue-policy.util.d.ts +61 -26
  82. package/dist/utility/chart/kscript-venue-policy.util.js +138 -37
  83. package/dist/utility/chart/live-bucket.util.d.ts +29 -4
  84. package/dist/utility/chart/live-bucket.util.js +45 -12
  85. package/dist/utility/chart/market-session-schedule.util.d.ts +19 -0
  86. package/dist/utility/chart/market-session-schedule.util.js +2 -1
  87. package/dist/utility/chart/market-session.util.d.ts +62 -10
  88. package/dist/utility/chart/market-session.util.js +93 -13
  89. package/dist/utility/chart/marketKind.util.d.ts +11 -12
  90. package/dist/utility/chart/marketKind.util.js +45 -13
  91. package/dist/utility/chart/mixed-mode.util.d.ts +18 -0
  92. package/dist/utility/chart/om-target.util.js +6 -4
  93. package/dist/utility/chart/price-precision.util.d.ts +20 -6
  94. package/dist/utility/chart/price-precision.util.js +34 -7
  95. package/dist/utility/chart/profile-frame-window.util.d.ts +15 -0
  96. package/dist/utility/chart/profile-frame-window.util.js +12 -0
  97. package/dist/utility/chart/rth-session.util.d.ts +3 -1
  98. package/dist/utility/chart/rth-session.util.js +3 -1
  99. package/dist/utility/chart/script-source-session.util.d.ts +43 -0
  100. package/dist/utility/chart/script-source-session.util.js +61 -0
  101. package/dist/utility/chart/typed-width-grid.util.d.ts +23 -0
  102. package/dist/utility/chart/typed-width-grid.util.js +203 -0
  103. package/dist/utility/common/transformations.util.d.ts +6 -0
  104. package/dist/utility/common/transformations.util.js +28 -4
  105. package/dist/utility/market-events/market-events.util.js +3 -0
  106. package/dist/utility/number-format.util.d.ts +14 -1
  107. package/dist/utility/number-format.util.js +22 -4
  108. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +24 -1
  109. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +115 -0
  110. package/dist/utility/v2/v2-enums.leaf.js +5 -0
  111. package/dist/utility/wrun/sources/row-lanes/dark_pool.d.ts +2 -1
  112. package/dist/utility/wrun/sources/row-lanes/dark_pool.js +4 -3
  113. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +13 -3
  114. package/dist/utility/wrun/wrun-batched-marks.util.js +96 -17
  115. package/dist/utility/wrun/wrun-canvases.util.d.ts +4 -2
  116. package/dist/utility/wrun/wrun-canvases.util.js +7 -12
  117. package/dist/utility/wrun/wrun-cap-notice.util.d.ts +5 -0
  118. package/dist/utility/wrun/wrun-cap-notice.util.js +23 -0
  119. package/dist/utility/wrun/wrun-card-style.util.d.ts +1 -1
  120. package/dist/utility/wrun/wrun-card-style.util.js +2 -2
  121. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +23 -8
  122. package/dist/utility/wrun/wrun-chart-market-facts.util.js +24 -9
  123. package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +10 -0
  124. package/dist/utility/wrun/wrun-child-overlay-id.util.js +24 -0
  125. package/dist/utility/wrun/wrun-cloud-cme-stamp.util.d.ts +72 -0
  126. package/dist/utility/wrun/wrun-cloud-cme-stamp.util.js +151 -0
  127. package/dist/utility/wrun/wrun-cme-root-specs.util.d.ts +10 -6
  128. package/dist/utility/wrun/wrun-cme-root-specs.util.js +19 -13
  129. package/dist/utility/wrun/wrun-color-facts.util.d.ts +3 -3
  130. package/dist/utility/wrun/wrun-color-facts.util.js +8 -5
  131. package/dist/utility/wrun/wrun-colour-tone.lazy.d.ts +20 -0
  132. package/dist/utility/wrun/wrun-colour-tone.lazy.js +23 -0
  133. package/dist/utility/wrun/wrun-colour-tone.util.d.ts +14 -0
  134. package/dist/utility/wrun/wrun-colour-tone.util.js +119 -0
  135. package/dist/utility/wrun/wrun-dark-pool.util.d.ts +3 -2
  136. package/dist/utility/wrun/wrun-dark-pool.util.js +5 -4
  137. package/dist/utility/wrun/wrun-frames.d.ts +1 -1
  138. package/dist/utility/wrun/wrun-frames.js +2 -2
  139. package/dist/utility/wrun/wrun-handles.util.d.ts +1 -1
  140. package/dist/utility/wrun/wrun-handles.util.js +1 -1
  141. package/dist/utility/wrun/wrun-host.service.d.ts +32 -2
  142. package/dist/utility/wrun/wrun-host.service.js +44 -2
  143. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +20 -0
  144. package/dist/utility/wrun/wrun-hosted-wire-caps.js +85 -2
  145. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +37 -0
  146. package/dist/utility/wrun/wrun-hosted-wire.util.js +54 -0
  147. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +1 -0
  148. package/dist/utility/wrun/wrun-hud-looks.util.js +6 -11
  149. package/dist/utility/wrun/wrun-integration-route.util.d.ts +24 -0
  150. package/dist/utility/wrun/wrun-integration-route.util.js +19 -0
  151. package/dist/utility/wrun/wrun-live-intake.util.js +17 -1
  152. package/dist/utility/wrun/wrun-live-patch.util.d.ts +6 -1
  153. package/dist/utility/wrun/wrun-live-patch.util.js +10 -4
  154. package/dist/utility/wrun/wrun-live-tick.util.js +64 -5
  155. package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +40 -6
  156. package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +2 -2
  157. package/dist/utility/wrun/wrun-market-size-defaults.util.js +10 -8
  158. package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +3 -0
  159. package/dist/utility/wrun/wrun-overlay-drivers.util.js +3 -0
  160. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +17 -0
  161. package/dist/utility/wrun/wrun-overlay-run.util.js +318 -55
  162. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +1 -1
  163. package/dist/utility/wrun/wrun-panel-mount.util.js +42 -13
  164. package/dist/utility/wrun/wrun-pin-venues.util.d.ts +3 -2
  165. package/dist/utility/wrun/wrun-pin-venues.util.js +11 -4
  166. package/dist/utility/wrun/wrun-refusal.util.d.ts +4 -0
  167. package/dist/utility/wrun/wrun-refusal.util.js +102 -13
  168. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
  169. package/dist/utility/wrun/wrun-registry-errors.util.js +5 -3
  170. package/dist/utility/wrun/wrun-row-source-factory.js +17 -1
  171. package/dist/utility/wrun/wrun-row-source.d.ts +8 -1
  172. package/dist/utility/wrun/wrun-run-health.util.js +1 -1
  173. package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +1 -1
  174. package/dist/utility/wrun/wrun-sandbox-row-source.js +9 -0
  175. package/dist/utility/wrun/wrun-session-composition.util.d.ts +3 -2
  176. package/dist/utility/wrun/wrun-session-composition.util.js +3 -2
  177. package/dist/utility/wrun/wrun-setting-words.util.d.ts +12 -5
  178. package/dist/utility/wrun/wrun-setting-words.util.js +25 -8
  179. package/dist/utility/wrun/wrun-socket-row-source.d.ts +26 -1
  180. package/dist/utility/wrun/wrun-socket-row-source.js +125 -12
  181. package/dist/utility/wrun/wrun-source-rows.util.d.ts +3 -3
  182. package/dist/utility/wrun/wrun-source-rows.util.js +8 -7
  183. package/dist/utility/wrun/wrun-style-words.util.d.ts +31 -9
  184. package/dist/utility/wrun/wrun-style-words.util.js +46 -15
  185. package/dist/utility/wrun/wrun-trades-lane.util.js +2 -1
  186. package/dist/utility/wrun/wrun-trap-replay.util.d.ts +42 -0
  187. package/dist/utility/wrun/wrun-trap-replay.util.js +63 -0
  188. package/dist/utility/wrun/wrun-volume-profile.util.js +6 -5
  189. package/dist/utility/wrun-display-name.util.d.ts +10 -0
  190. package/dist/utility/wrun-display-name.util.js +21 -0
  191. package/dist/utils/replay/replay-buffer-math.d.ts +2 -0
  192. package/dist/utils/replay/replay-buffer-math.js +2 -0
  193. package/dist/workers/constants/socket-slots.d.ts +1 -1
  194. package/dist/workers/utils/time.worker.util.js +2 -2
  195. package/dist/workers/utils/volume-profile.worker.util.d.ts +9 -0
  196. package/dist/workers/utils/volume-profile.worker.util.js +20 -0
  197. package/dist/workers/wrun/wrun-abi-host.d.ts +3 -0
  198. package/dist/workers/wrun/wrun-abi-host.js +82 -5
  199. package/dist/workers/wrun/wrun-engine-handler.js +53 -4
  200. package/dist/workers/wrun/wrun-trap-frames.leaf.d.ts +28 -0
  201. package/dist/workers/wrun/wrun-trap-frames.leaf.js +108 -0
  202. package/package.json +11 -11
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Which served interval a custom size is built from in the app, and how many of its rows one custom bar can hold.
3
+ *
4
+ * The candidates are data, best first: the deepest history on the server, then the fewest rows a bar (the server keeps
5
+ * 15,000 bars of most sizes, 25,000 at 1h and 50,000 at 30m, so 90m reaches further from 30m than from anything
6
+ * finer). A candidate is kept on a grid only when none of its bars straddles a custom bar's edge there; the spec
7
+ * (tests/constants/typed-width-source.leaf.spec.ts) walks every candidate against the grid functions over a summer, a
8
+ * winter and both clock-change weeks, and the drops below are what that walk found. Nothing is scanned at run time.
9
+ *
10
+ * LAZY: loaded the first time a chart goes on a custom size the app builds. No eager module may import this file
11
+ * (tests/perf/typed-width-rules-lazy-closure.spec.ts).
12
+ */
13
+ import { typedWidthSeconds } from './typed-width.leaf.js';
14
+ import { typedGridKind } from '../utility/chart/typed-width-grid.util.js';
15
+ /** The most source rows one app-built custom bar may read. */
16
+ export const TYPED_SOURCE_MAX_ROWS = 20;
17
+ const MINUTE_S = 60;
18
+ const DAY_S = 86_400;
19
+ const WEEK_S = 604_800;
20
+ /** The served lengths a candidate can name, in seconds. */
21
+ const SOURCE_SECONDS = {
22
+ '1m': MINUTE_S,
23
+ '2m': 2 * MINUTE_S,
24
+ '3m': 3 * MINUTE_S,
25
+ '5m': 5 * MINUTE_S,
26
+ '10m': 10 * MINUTE_S,
27
+ '15m': 15 * MINUTE_S,
28
+ '30m': 30 * MINUTE_S,
29
+ '1h': 60 * MINUTE_S,
30
+ '1d': DAY_S,
31
+ '1w': WEEK_S,
32
+ };
33
+ /** The candidates of each custom size under a day, best first. */
34
+ const INTRADAY_CANDIDATES = {
35
+ '4m': ['2m', '1m'],
36
+ '6m': ['3m', '2m', '1m'],
37
+ '8m': ['2m', '1m'],
38
+ '9m': ['3m', '1m'],
39
+ '12m': ['3m', '2m', '1m'],
40
+ '16m': ['2m', '1m'],
41
+ '18m': ['3m', '2m', '1m'],
42
+ '20m': ['10m', '5m', '1m'],
43
+ '40m': ['10m', '5m'],
44
+ '80m': ['10m', '5m'],
45
+ '90m': ['30m', '15m', '5m'],
46
+ '3h': ['1h', '30m', '15m'],
47
+ };
48
+ const DAY_CANDIDATES = ['1d'];
49
+ const WEEK_CANDIDATES = ['1w', '1d'];
50
+ /**
51
+ * The candidates a grid cannot take, by custom size: their bars straddle a custom bar's edge there.
52
+ * - CME regular hours: the gateway keeps a regular-hours bucket of 30m or less whole by its start, so the 2m bucket
53
+ * at 16:14, the 10m one at 16:10 and the 30m one at 16:00 New York run past the 16:15 close that ends a custom bar
54
+ * (ES; the NYMEX 14:30 close sits on all three grids, but one table serves every CME product).
55
+ * - US stocks in regular hours and US options: an option's 1h bars sit on the UTC hour (the 09:00 New York bar holds
56
+ * the 09:30 open), where a regular-hours stock's sit on the 09:30 anchor; both grids take the same row, so 3h reads
57
+ * 30m on each (the stock's drop is held, not refuted: the spec names it). An option prints nothing after its 16:15 close, so a source bar that opens before it (the 16:10 10m
58
+ * bar) holds only rows of the session's short last bar.
59
+ */
60
+ const STRADDLING = {
61
+ 'cme-regular': {
62
+ '4m': ['2m'],
63
+ '6m': ['2m'],
64
+ '8m': ['2m'],
65
+ '12m': ['2m'],
66
+ '16m': ['2m'],
67
+ '18m': ['2m'],
68
+ '20m': ['10m'],
69
+ '40m': ['10m'],
70
+ '80m': ['10m'],
71
+ '90m': ['30m'],
72
+ '3h': ['30m'],
73
+ },
74
+ 'equity-regular': {
75
+ '3h': ['1h'],
76
+ },
77
+ options: {
78
+ '3h': ['1h'],
79
+ },
80
+ };
81
+ /** The candidate source intervals of a custom size, best first (deepest history, then fewest rows). */
82
+ export function typedWidthSourceCandidates(label) {
83
+ const seconds = typedWidthSeconds(label);
84
+ if (seconds === undefined)
85
+ return [];
86
+ if (seconds < DAY_S)
87
+ return INTRADAY_CANDIDATES[label] ?? [];
88
+ return seconds % WEEK_S === 0 ? WEEK_CANDIDATES : DAY_CANDIDATES;
89
+ }
90
+ /** The candidates of a custom size on one grid: the table less the ones whose bars straddle a custom edge there. */
91
+ export function typedWidthSourceCandidatesOn(label, kind) {
92
+ const dropped = STRADDLING[kind]?.[label];
93
+ const candidates = typedWidthSourceCandidates(label);
94
+ return dropped ? candidates.filter((candidate) => !dropped.includes(candidate)) : candidates;
95
+ }
96
+ /**
97
+ * The most rows of `sourceLabel` one bar of the custom size `label` holds on a grid: the width over the source length
98
+ * under a day; N for N days from 1d and for N weeks from 1w; for N weeks from 1d, 7N on the UTC grid (every day
99
+ * trades) and 5N on a session grid (a week holds five trade dates). NaN for a pair the table does not name.
100
+ */
101
+ export function typedSourceRowsPerBar(label, sourceLabel, kind) {
102
+ const seconds = typedWidthSeconds(label);
103
+ const sourceSeconds = SOURCE_SECONDS[sourceLabel];
104
+ if (seconds === undefined || sourceSeconds === undefined)
105
+ return Number.NaN;
106
+ if (seconds < DAY_S || sourceSeconds !== DAY_S || seconds % WEEK_S !== 0)
107
+ return seconds / sourceSeconds;
108
+ const weeks = seconds / WEEK_S;
109
+ return kind === 'utc' ? 7 * weeks : 5 * weeks;
110
+ }
111
+ /**
112
+ * The source of the custom size `label` on the chart's market: the first candidate the chart serves (`servable`)
113
+ * that needs at most TYPED_SOURCE_MAX_ROWS rows a bar. Null when the market has no interval to build it from.
114
+ */
115
+ export function typedWidthSource(label, venue, servable) {
116
+ const seconds = typedWidthSeconds(label);
117
+ if (seconds === undefined)
118
+ return null;
119
+ const kind = typedGridKind(seconds * 1000, venue);
120
+ for (const candidate of typedWidthSourceCandidatesOn(label, kind)) {
121
+ const rowsPerBar = typedSourceRowsPerBar(label, candidate, kind);
122
+ if (rowsPerBar <= TYPED_SOURCE_MAX_ROWS && servable(candidate) === true)
123
+ return { label: candidate, rowsPerBar };
124
+ }
125
+ return null;
126
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Typed widths: candle widths a person types that sit on no ladder rung. Under a day each is a whole divisor of a UTC
3
+ * day, so its bars lie on the plain epoch grid; from a day up each is whole days (2 to 20 days, 2 to 20 weeks), and
4
+ * its bars count from Monday 2000-01-03 (calendar-interval.util `fixedGridFloorMs`). The gateway serves one as the wire
5
+ * interval CUSTOM plus `barSeconds`, built from the coarsest stored candle size that divides it, and refuses a width
6
+ * that reads more than `TYPED_WIDTH_MAX_STORED_BARS` stored candles per bar. Dependency-free: workers and leaf modules
7
+ * import it.
8
+ */
9
+ type DayCount = 2 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20;
10
+ type WeekCount = 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20;
11
+ declare const INTRADAY_TYPED_WIDTH_SECONDS: {
12
+ readonly '4m': 240;
13
+ readonly '6m': 360;
14
+ readonly '8m': 480;
15
+ readonly '9m': 540;
16
+ readonly '12m': 720;
17
+ readonly '16m': 960;
18
+ readonly '18m': 1080;
19
+ readonly '20m': 1200;
20
+ readonly '40m': 2400;
21
+ readonly '80m': 4800;
22
+ readonly '90m': 5400;
23
+ readonly '3h': 10800;
24
+ };
25
+ export type TypedWidth = keyof typeof INTRADAY_TYPED_WIDTH_SECONDS | `${DayCount}d` | `${WeekCount}w`;
26
+ /**
27
+ * The typed widths and their lengths in seconds: the 12 under a day shortest first, then the day and week sizes by
28
+ * count (2d 2w 3w 4d 4w ...). One label per length: 7 days is the `1w` rung, 14 days `2w`, 3 days the `3d` rung. No
29
+ * reader relies on the order. Every one reads at most 20 stored candles a bar.
30
+ */
31
+ export declare const TYPED_WIDTH_SECONDS: Readonly<Record<TypedWidth, number>>;
32
+ export declare const TYPED_WIDTH_LABELS: readonly TypedWidth[];
33
+ /** The candle sizes the gateway stores (1m 5m 15m 1h 4h 1d 1w), in seconds, shortest first. */
34
+ export declare const STORED_BAR_SECONDS: readonly number[];
35
+ /** The gateway's limit: a typed width reads at most this many stored candles for one bar. */
36
+ export declare const TYPED_WIDTH_MAX_STORED_BARS = 20;
37
+ /** Stored candles one bar of `seconds` reads: the width over the coarsest stored size that divides it (NaN for none). */
38
+ export declare function storedBarsPerTypedWidth(seconds: number): number;
39
+ export declare const CUSTOM_WIRE_INTERVAL = 26;
40
+ export declare const CUSTOM_WIRE_INTERVAL_NAME = "CUSTOM";
41
+ export declare function isTypedWidth(label: unknown): label is TypedWidth;
42
+ /** The bar length a typed width asks the gateway for (`barSeconds`), undefined for any other label. */
43
+ export declare function typedWidthSeconds(label: unknown): number | undefined;
44
+ /**
45
+ * The most stored candles a typed width may fold into one bar of volume-profile rows (the range profiles, and
46
+ * footprints where they fold).
47
+ */
48
+ export declare const TYPED_WIDTH_PROFILE_FOLD_MAX_STORED_BARS = 8;
49
+ /**
50
+ * Whether a typed width may fold volume-profile rows (footprints, the range profiles), which the app reads at the
51
+ * stored size and adds up itself (typed-width-fold.leaf): at most 8 stored candles a bar, and among the day widths
52
+ * only 2d, since a stored daily profile row weighs about 30 one-minute rows. That is 4m 6m 8m 20m 40m 90m 3h, 2d and
53
+ * 2w to 8w. False for every other label. The one cap rule: the indicator verdict reads it, and the chart-type door
54
+ * does for a chart type that folds rows.
55
+ */
56
+ export declare function isTypedWidthProfileFoldAllowed(label: unknown): boolean;
57
+ export {};
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Typed widths: candle widths a person types that sit on no ladder rung. Under a day each is a whole divisor of a UTC
3
+ * day, so its bars lie on the plain epoch grid; from a day up each is whole days (2 to 20 days, 2 to 20 weeks), and
4
+ * its bars count from Monday 2000-01-03 (calendar-interval.util `fixedGridFloorMs`). The gateway serves one as the wire
5
+ * interval CUSTOM plus `barSeconds`, built from the coarsest stored candle size that divides it, and refuses a width
6
+ * that reads more than `TYPED_WIDTH_MAX_STORED_BARS` stored candles per bar. Dependency-free: workers and leaf modules
7
+ * import it.
8
+ */
9
+ const INTRADAY_TYPED_WIDTH_SECONDS = {
10
+ '4m': 240,
11
+ '6m': 360,
12
+ '8m': 480,
13
+ '9m': 540,
14
+ '12m': 720,
15
+ '16m': 960,
16
+ '18m': 1080,
17
+ '20m': 1200,
18
+ '40m': 2400,
19
+ '80m': 4800,
20
+ '90m': 5400,
21
+ '3h': 10800,
22
+ };
23
+ /**
24
+ * The typed widths and their lengths in seconds: the 12 under a day shortest first, then the day and week sizes by
25
+ * count (2d 2w 3w 4d 4w ...). One label per length: 7 days is the `1w` rung, 14 days `2w`, 3 days the `3d` rung. No
26
+ * reader relies on the order. Every one reads at most 20 stored candles a bar.
27
+ */
28
+ export const TYPED_WIDTH_SECONDS = { ...INTRADAY_TYPED_WIDTH_SECONDS };
29
+ for (let n = 2; n < 21; n++) {
30
+ const rows = TYPED_WIDTH_SECONDS;
31
+ if (n % 7 && n !== 3)
32
+ rows[n + 'd'] = n * 86_400;
33
+ rows[n + 'w'] = n * 604_800;
34
+ }
35
+ export const TYPED_WIDTH_LABELS = Object.keys(TYPED_WIDTH_SECONDS);
36
+ /** The candle sizes the gateway stores (1m 5m 15m 1h 4h 1d 1w), in seconds, shortest first. */
37
+ export const STORED_BAR_SECONDS = [60, 300, 900, 3600, 14400, 86400, 604800];
38
+ /** The gateway's limit: a typed width reads at most this many stored candles for one bar. */
39
+ export const TYPED_WIDTH_MAX_STORED_BARS = 20;
40
+ /** Stored candles one bar of `seconds` reads: the width over the coarsest stored size that divides it (NaN for none). */
41
+ export function storedBarsPerTypedWidth(seconds) {
42
+ let stored = NaN;
43
+ for (const size of STORED_BAR_SECONDS)
44
+ if (seconds % size === 0)
45
+ stored = size;
46
+ return seconds / stored;
47
+ }
48
+ // The shared pb-common package and its parity-pinned enum leaf stop at HALF_YEAR (25): CUSTOM is 26 on the gateway.
49
+ export const CUSTOM_WIRE_INTERVAL = 26;
50
+ export const CUSTOM_WIRE_INTERVAL_NAME = 'CUSTOM';
51
+ const hasOwn = (record, key) => Object.prototype.hasOwnProperty.call(record, key);
52
+ export function isTypedWidth(label) {
53
+ return typeof label === 'string' && hasOwn(TYPED_WIDTH_SECONDS, label);
54
+ }
55
+ /** The bar length a typed width asks the gateway for (`barSeconds`), undefined for any other label. */
56
+ export function typedWidthSeconds(label) {
57
+ return isTypedWidth(label) ? TYPED_WIDTH_SECONDS[label] : undefined;
58
+ }
59
+ /**
60
+ * The most stored candles a typed width may fold into one bar of volume-profile rows (the range profiles, and
61
+ * footprints where they fold).
62
+ */
63
+ export const TYPED_WIDTH_PROFILE_FOLD_MAX_STORED_BARS = 8;
64
+ /**
65
+ * Whether a typed width may fold volume-profile rows (footprints, the range profiles), which the app reads at the
66
+ * stored size and adds up itself (typed-width-fold.leaf): at most 8 stored candles a bar, and among the day widths
67
+ * only 2d, since a stored daily profile row weighs about 30 one-minute rows. That is 4m 6m 8m 20m 40m 90m 3h, 2d and
68
+ * 2w to 8w. False for every other label. The one cap rule: the indicator verdict reads it, and the chart-type door
69
+ * does for a chart type that folds rows.
70
+ */
71
+ export function isTypedWidthProfileFoldAllowed(label) {
72
+ const seconds = typedWidthSeconds(label);
73
+ if (seconds === undefined)
74
+ return false;
75
+ const bars = storedBarsPerTypedWidth(seconds);
76
+ return (bars <= TYPED_WIDTH_PROFILE_FOLD_MAX_STORED_BARS &&
77
+ (seconds % 86_400 !== 0 || seconds % 604_800 === 0 || bars === 2));
78
+ }
@@ -310,6 +310,12 @@ export interface WrunHostChart {
310
310
  /** 0.5.0, panel-mount binder. web: scheduleKScriptLiveChartPaint(chartIndex, tc, getLatestTc, opts)
311
311
  * (utility/chart/kscript-chart-paint.util.ts:106; web's live-paint wait map stays the owner, D-2c). */
312
312
  scheduleLivePaint(chartIndex: number, tc: WrunChartHandle, getLatestTc?: () => WrunChartHandle | null | undefined, options?: WrunChartPaintOptions): WrunChartPaintMode;
313
+ /** Optional, panel-mount binder. Run `run` (synchronous) with the host's history recording held off: the engine
314
+ * deletes the drawings on a pane the panel mount removes, one delete event each, and a host whose undo store records
315
+ * an engine delete as a step must not record those (Discord #138: one step per drawing, none of which could land).
316
+ * web: withoutUndoSteps(run) (store/undo-step-hold.ts). Absent: the call runs plainly (`wrunHostWithoutUndoSteps`
317
+ * is its one reader); the sandbox worker and the phone app never set it. */
318
+ withoutUndoSteps?<T>(run: () => T): T;
313
319
  /** 0.5.0, run. web: decideLocalKScriptLiveRefreshGate(args) (utility/chart/kscript-live-refresh-pace.util.ts:112;
314
320
  * kScript's gate maps stay web, D-2c). */
315
321
  decideLiveRefreshGate(args: {
@@ -639,6 +645,10 @@ export declare function wrunHostCarryWithBuild(): boolean;
639
645
  * sheet's words). Read when a surface names a line, never at module load; utility/wrun/wrun-output-words.util
640
646
  * `wrunOutputWords` is its one reader. */
641
647
  export declare function wrunHostBuiltinLineWords(builtIn: string, label: string): string | undefined;
648
+ /** Run `run` (synchronous) with the host's history recording held off (`WrunHostChart.withoutUndoSteps`): a host that
649
+ * never set the member, or a realm whose env is not set, runs it plainly. Read at the call, never at module load;
650
+ * wrun-panel-mount.util `removeChild` is its one reader. */
651
+ export declare function wrunHostWithoutUndoSteps<T>(run: () => T): T;
642
652
  /** The error a host's `sharedHost()` throws before its load. */
643
653
  export declare function wrunChartHostUnloadedError(): Error;
644
654
  /** The shared host now, or its load: `undefined` once the env's `sharedHost()` answers, else the env's
package/dist/host-env.js CHANGED
@@ -62,6 +62,13 @@ export function wrunHostBuiltinLineWords(builtIn, label) {
62
62
  return undefined;
63
63
  }
64
64
  }
65
+ /** Run `run` (synchronous) with the host's history recording held off (`WrunHostChart.withoutUndoSteps`): a host that
66
+ * never set the member, or a realm whose env is not set, runs it plainly. Read at the call, never at module load;
67
+ * wrun-panel-mount.util `removeChild` is its one reader. */
68
+ export function wrunHostWithoutUndoSteps(run) {
69
+ const chart = hasWrunChartHostEnv() ? wrunChartHostEnv().chart : undefined;
70
+ return typeof chart?.withoutUndoSteps === 'function' ? chart.withoutUndoSteps(run) : run();
71
+ }
65
72
  /** The error a host's `sharedHost()` throws before its load. */
66
73
  export function wrunChartHostUnloadedError() {
67
74
  return new Error('wrun_chart_host_unloaded');
@@ -154,10 +154,14 @@ export interface WrunChartStoreView {
154
154
  * `IndicatorOutputProvenance`): `opra` when the run read OPRA, its own fact from before it computed. Required.
155
155
  * CHANGED (next release): `cme` when the run is a CME user study (the `cme-user-scripts` gate opened the CME plane
156
156
  * to it), its own fact from before it computed; optional, so every writer that names OPRA alone compiles as before
157
- * and reads unmarked for CME. */
157
+ * and reads unmarked for CME.
158
+ * `indexOtc` when the run read the index and yield venue (index-otc.leaf), its own fact from before it computed;
159
+ * optional the same way: the web store reads it (console-run-output.leaf `IndicatorOutputProvenance`), and a
160
+ * writer that never names it reads unmarked. */
158
161
  setIndicatorPrintOutputs(chartIndex: number, indicatorId: string, printOutputsInput: unknown, provenance: {
159
162
  opra: boolean;
160
163
  cme?: boolean;
164
+ indexOtc?: boolean;
161
165
  }): void;
162
166
  setIndicatorRunOutputSummary(chartIndex: number, indicatorId: string, runResult: WrunKScriptRunResultLike | null): void;
163
167
  setKScriptLoadingIndicator(chartIndex: number, indicatorId: string, loading: boolean): void;
@@ -271,18 +275,6 @@ export interface WrunMainCandleRequestIdentity {
271
275
  /** The chart's instrument category (an option contract's is OPTION). */
272
276
  category?: number;
273
277
  }
274
- /** The identity a chart's mounted main rows were loaded for, the fields the package reads (web: ohlcv-cache.types.ts
275
- * `MainDataRequestIdentity`; one way, web's carries the pool and adjustment fields too). */
276
- export interface WrunLoadedMainIdentity {
277
- readonly exchange: string | null;
278
- readonly symbol: string | null;
279
- readonly interval: string | null;
280
- readonly transformations: string | null;
281
- /** The chart's persisted session word the rows were loaded under: the identity compare reads the session the chart
282
- * rides from it (`wrunChartMarketIdentity`'s fifth term, effectiveChartSessionType), so a host that leaves it out
283
- * compares as the market's default session. */
284
- readonly sessionType?: unknown;
285
- }
286
278
  /** A lazy-load check's target range (web: utility/chart/viewport-pan-tracking.util.ts `LazyLoadTargetRange`). */
287
279
  export interface WrunLazyLoadTargetRange {
288
280
  startTs: number;
@@ -295,10 +287,13 @@ export interface WrunLazyLoadTargetRange {
295
287
  export interface WrunDataFetchingModule {
296
288
  runChartLazyLoadCheck(chartIndex: number, expectedTc?: WrunChartHandle, reason?: string, targetRange?: WrunLazyLoadTargetRange, trigger?: string): void;
297
289
  isMainCandleFetchInFlight(chartIndex: number): boolean;
298
- /** The identity the chart's mounted main rows were loaded for (web: `loadedMainIdentityOf`, the loaded-main identity
299
- * stamp every commit, cache paint and restore writes), or null before any stamp. A switch repoints the metadata
300
- * before the incoming market's rows mount, so a read that infers a market fact from the rows asks it first. */
301
- loadedMainIdentityOf(chartIndex: number): WrunLoadedMainIdentity | null;
290
+ /** Whether the chart's mounted main rows were loaded for the market `metadata` asks rows for (web:
291
+ * `mainRowsLoadedFor`, the loaded-main stamp against the request identity of that metadata, the compare its cache
292
+ * write guards run); false before any stamp. A switch repoints the metadata before the incoming market's rows
293
+ * mount, so a read that infers a market fact from the rows asks it first. The host answers, never the package: the
294
+ * rows' market is not always the chart's own (a US stock on Trades rides its tape), and only the host knows how its
295
+ * loader names it. */
296
+ mainRowsLoadedFor(chartIndex: number, metadata: object | null | undefined): boolean;
302
297
  buildMainCandleBasePayload(identity: WrunMainCandleRequestIdentity): object;
303
298
  resolveMainCandleSidedRequest(input: {
304
299
  transformations: string;
@@ -865,6 +860,8 @@ export interface WrunIntegrateOptions {
865
860
  preserveMountedRowsOutsideWindow?: WrunPartialReplayWindow | null;
866
861
  suppressDrawings?: boolean;
867
862
  deferDrawingsToReplayLane?: boolean;
863
+ /** The result does not speak for the overlay's drawings: the mounted set and its record stay as they are. */
864
+ keepMountedDrawings?: boolean;
868
865
  postApply?: (runResult: unknown, sideEffects: WrunIntegrationSideEffects) => void;
869
866
  }
870
867
  /** The adapter's full integration answer (web: `SafeKScriptTitanChartsIntegrationResult`). */
@@ -896,6 +893,8 @@ export interface WrunRefreshRowsOptions {
896
893
  runInterval?: WrunOverlayRunInterval | null;
897
894
  suppressDrawings?: boolean;
898
895
  deferDrawingsToReplayLane?: boolean;
896
+ /** The result does not speak for the overlay's drawings: the mounted set and its record stay as they are. */
897
+ keepMountedDrawings?: boolean;
899
898
  ignoreUnmountedOutputKeys?: ReadonlySet<string>;
900
899
  mergeMountedRows?: boolean;
901
900
  liveTail?: WrunLiveTailWindow;
@@ -1288,6 +1287,13 @@ export interface WrunFailureShow {
1288
1287
  code: string;
1289
1288
  chip: string;
1290
1289
  };
1290
+ /** The source door's facts of a source it refused: the interval it judged, and the source's machine name the door
1291
+ * bounded (`unknown` for a name the build does not own). The builder (wrun-failure-shown.util) sends them only
1292
+ * when the interval is a typed width. */
1293
+ refused?: {
1294
+ interval?: unknown;
1295
+ source?: unknown;
1296
+ };
1291
1297
  }
1292
1298
  /** Loader view of the editor shell store: its open tabs (web: store/editor-shell.ts `useEditorShellStore`). */
1293
1299
  export interface WrunEditorShellModule {
package/dist/index.d.ts CHANGED
@@ -23,6 +23,8 @@ export * from './constants/scriptEditor/execution.constants.js';
23
23
  export * from './constants/scriptEditor/technicalIndicatorScriptKeys.constants.js';
24
24
  export * from './constants/stocks-compliance.constants.js';
25
25
  export * from './constants/tpo-color-schemes.constants.js';
26
+ export * from './constants/typed-width-fold.leaf.js';
27
+ export * from './constants/typed-width.leaf.js';
26
28
  export * from './constants/venue-presets.constants.js';
27
29
  export * from './constants/wrun-prefix-safe.constants.js';
28
30
  export * from './enums/chart.enum.js';
@@ -102,6 +104,7 @@ export * from './utility/chart/host-bar-placement.util.js';
102
104
  export * from './utility/chart/index-host-tier.util.js';
103
105
  export * from './utility/chart/index-mode-admission.util.js';
104
106
  export * from './utility/chart/index-mode.util.js';
107
+ export * from './utility/chart/index-otc.leaf.js';
105
108
  export * from './utility/chart/indicator-coverage-planner.util.js';
106
109
  export * from './utility/chart/indicator-coverage-state.util.js';
107
110
  export * from './utility/chart/indicator-error-message.util.js';
@@ -125,6 +128,7 @@ export * from './utility/chart/kscript-mounted-plot-set.leaf.js';
125
128
  export * from './utility/chart/kscript-output-role.util.js';
126
129
  export * from './utility/chart/kscript-perf-tracker.util.js';
127
130
  export * from './utility/chart/kscript-provenance-keys.util.js';
131
+ export * from './utility/chart/kscript-row-name.leaf.js';
128
132
  export * from './utility/chart/kscript-run-interval-projection.util.js';
129
133
  export * from './utility/chart/kscript-run-result-equality.util.js';
130
134
  export * from './utility/chart/kscript-run-result-normalize.util.js';
package/dist/index.js CHANGED
@@ -26,6 +26,8 @@ export * from './constants/scriptEditor/execution.constants.js';
26
26
  export * from './constants/scriptEditor/technicalIndicatorScriptKeys.constants.js';
27
27
  export * from './constants/stocks-compliance.constants.js';
28
28
  export * from './constants/tpo-color-schemes.constants.js';
29
+ export * from './constants/typed-width-fold.leaf.js';
30
+ export * from './constants/typed-width.leaf.js';
29
31
  export * from './constants/venue-presets.constants.js';
30
32
  export * from './constants/wrun-prefix-safe.constants.js';
31
33
  export * from './enums/chart.enum.js';
@@ -106,6 +108,7 @@ export * from './utility/chart/host-bar-placement.util.js';
106
108
  export * from './utility/chart/index-host-tier.util.js';
107
109
  export * from './utility/chart/index-mode-admission.util.js';
108
110
  export * from './utility/chart/index-mode.util.js';
111
+ export * from './utility/chart/index-otc.leaf.js';
109
112
  export * from './utility/chart/indicator-coverage-planner.util.js';
110
113
  export * from './utility/chart/indicator-coverage-state.util.js';
111
114
  export * from './utility/chart/indicator-error-message.util.js';
@@ -129,6 +132,7 @@ export * from './utility/chart/kscript-mounted-plot-set.leaf.js';
129
132
  export * from './utility/chart/kscript-output-role.util.js';
130
133
  export * from './utility/chart/kscript-perf-tracker.util.js';
131
134
  export * from './utility/chart/kscript-provenance-keys.util.js';
135
+ export * from './utility/chart/kscript-row-name.leaf.js';
132
136
  export * from './utility/chart/kscript-run-interval-projection.util.js';
133
137
  export * from './utility/chart/kscript-run-result-equality.util.js';
134
138
  export * from './utility/chart/kscript-run-result-normalize.util.js';
@@ -1,3 +1,4 @@
1
+ import type { WrunTrapKind, WrunTrapPhase } from './wrun-runtime.interface.js';
1
2
  export type RuntimeDiagnosticStage = 'resolve' | 'fetch' | 'compute' | 'render' | 'boundary';
2
3
  export type RuntimeDiagnosticSeverity = 'error' | 'warning' | 'info';
3
4
  export interface RuntimeDiagnostic {
@@ -33,6 +34,40 @@ export interface RuntimeDiagnostic {
33
34
  * CME chart). Read beside `opra`: the editor console shows it, and every console export strips it.
34
35
  */
35
36
  cme?: true;
37
+ /**
38
+ * The row was computed over the index and yield venue's data (index-otc.leaf `checkIsIndexOtc`, its display-only
39
+ * licence): the run that reported it read the venue (its own fact from before it computed: a run on the venue's
40
+ * chart or one of its formula legs, or a pin on it). Read beside `opra` and `cme`: the editor console shows it, and
41
+ * every console export strips it.
42
+ */
43
+ indexOtc?: true;
44
+ }
45
+ /** What failed, decided from the trap record (never from the text): a std-lib check the host names
46
+ * (`index-out-of-range`, `key-not-found`, `array-empty`), the engine's `unreachable`, any other abort
47
+ * (`abort`: a throw, the author's abort()), any other engine trap (`native`), or a host refusal (`host`). */
48
+ export type WrunTrapReason = 'index-out-of-range' | 'key-not-found' | 'array-empty' | 'unreachable' | 'abort' | 'native' | 'host';
49
+ /** `details.trap` of a browser-run trap row (WRUN_ABORT, WRUN_UNREACHABLE_TRAP and the other run failure rows). */
50
+ export interface WrunTrapRowDetails {
51
+ kind: WrunTrapKind;
52
+ phase: WrunTrapPhase;
53
+ reason: WrunTrapReason;
54
+ /** The failing bar's epoch-ms timestamp; absent before bar processing starts. */
55
+ barTs?: number;
56
+ /** The library position the abort named (`~lib/array.ts:114:42`) when it is not the author's file. */
57
+ libSite?: string;
58
+ /** The replay seed's token (a sandbox full run or live start): the editor's trap replay takes the seed by it. */
59
+ token?: string;
60
+ /** Set once the editor's replay enriched the row (never replayed again): `full` (line, and function unless the
61
+ * source inlines), `names` (function names, no offsets: no line). */
62
+ replay?: 'full' | 'names';
63
+ /** The function the trap stopped in, as written in src/indicator.ts (absent when the attribution is uncertain). */
64
+ fn?: string;
65
+ /** The first mapped line of `fn` in src/indicator.ts (names only: where its one mark goes). */
66
+ fnLine?: number;
67
+ /** The caller's function and the line and column of its call. */
68
+ caller?: string;
69
+ callerLine?: number;
70
+ callerColumn?: number;
36
71
  }
37
72
  /** `details` of a FE_KSCRIPT_PERF_SLOW row: what the chip and the compact card show. */
38
73
  export interface KScriptPerfSlowDetails {
@@ -199,7 +199,17 @@ export interface WrunLiveEndRequest {
199
199
  }
200
200
  /** Everything the sandbox worker accepts. A bare WrunPackedRunRequest (no
201
201
  * `kind`) stays the classic one-shot run. */
202
- export type WrunWorkerRequest = WrunPackedRunRequest | WrunLiveStartRequest | WrunLiveRowsRequest | WrunLiveEndRequest | WrunModuleLoadRequest;
202
+ /** The editor's trap replay (a private host's worker only): one whole run of a TRACE build (unoptimised, with names
203
+ * and a source map), never a release module. It carries the trace bytes and their own sha256 (checked before
204
+ * anything compiles); the handler prepares them as it prepares a release module, never reads its module cache, a
205
+ * live session or a sheet pin, and answers a failure's trap record with the call frames (`trap.frames`, offsets in
206
+ * the trace build's own bytes). */
207
+ export interface WrunTraceRunRequest extends Omit<WrunPackedRunRequest, 'moduleKey' | 'moduleBytes'> {
208
+ kind: 'trace-run';
209
+ traceBytes: Uint8Array;
210
+ traceSha256: string;
211
+ }
212
+ export type WrunWorkerRequest = WrunPackedRunRequest | WrunLiveStartRequest | WrunLiveRowsRequest | WrunLiveEndRequest | WrunModuleLoadRequest | WrunTraceRunRequest;
203
213
  interface WrunPackedRunStrings {
204
214
  lens: Int32Array;
205
215
  offsets: Int32Array;
@@ -246,7 +256,54 @@ export type WrunWorkerResponse = {
246
256
  code?: 'live-order' | 'module-pin-mismatch' | 'module-compile-failed';
247
257
  /** `module-pin-mismatch` only: the hex sha256 the bytes hash to. */
248
258
  sha256?: string;
259
+ /** A guest trap or a host failure inside a guest call: where it happened (the ABI host's record,
260
+ * `wrunTrapOf`). `error` keeps the host's words unchanged beside it. */
261
+ trap?: WrunTrapContext;
249
262
  };
263
+ /** How the guest stopped: `abort` (env.abort: a throw, a std-lib check, the author's abort()), `native` (the engine
264
+ * trapped: `unreachable`, a bad memory access, a divide by zero) or `host` (a host import or a host check after a
265
+ * guest call refused). */
266
+ export type WrunTrapKind = 'abort' | 'native' | 'host';
267
+ /** The guest call that was running: `start` (the module's start section, during instantiation), `init`, `state`,
268
+ * `finalize`, or `row-check` (the host's checks after a row's guest call: memory, declared outputs). */
269
+ export type WrunTrapPhase = 'start' | 'init' | 'state' | 'finalize' | 'row-check';
270
+ /** One wasm call frame as an engine prints it; each field only when the engine printed it. */
271
+ export interface WrunTrapFrame {
272
+ index?: number;
273
+ name?: string;
274
+ offset?: number;
275
+ }
276
+ /** What the ABI host knew when a guest call failed, captured at the guest-call boundary before any text is
277
+ * formatted. A plain object: it crosses the worker boundary as is. */
278
+ export interface WrunTrapContext {
279
+ kind: WrunTrapKind;
280
+ phase: WrunTrapPhase;
281
+ /** The row being evaluated (0-based index in the run, epoch-ms timestamp); absent before bar processing starts. */
282
+ bar?: {
283
+ index: number;
284
+ ts: number;
285
+ };
286
+ /** env.abort's arguments as the guest passed them (null when the guest passed none; 0 for no position). */
287
+ abort?: {
288
+ message: string | null;
289
+ path: string | null;
290
+ line: number;
291
+ column: number;
292
+ };
293
+ /** `native` only: the engine's own words for the trap (`unreachable`, `memory access out of bounds`). */
294
+ native?: {
295
+ message: string;
296
+ };
297
+ /** The call frames at the trap, innermost first (the trace replay's: `wrun-trap-frames.leaf`), each with what the
298
+ * engine printed: the function index, its name, the byte offset in the trace build's own bytes. Absent on a
299
+ * release run. */
300
+ frames?: ReadonlyArray<WrunTrapFrame>;
301
+ }
302
+ /** The trap record rides beside the Error it explains (like `attachWrunLive`), so the Error's message stays the
303
+ * host's words every other reader matches on. Kept with the wire types so the worker and the main thread share one
304
+ * registry. */
305
+ export declare function attachWrunTrap(error: unknown, trap: WrunTrapContext): void;
306
+ export declare function wrunTrapOf(error: unknown): WrunTrapContext | undefined;
250
307
  /** One unpacked result row: `outputs` is null on a non-ready row; `strings`
251
308
  * entries are undefined for ABSENT slots and '' for present-empty writes. */
252
309
  export interface WrunOutputRow {
@@ -2564,7 +2621,8 @@ export interface WrunMarkSize {
2564
2621
  * (round-2 fold 1); the chart derives the pixels exactly as Big Trades 0.3.2 did. */
2565
2622
  export interface WrunMarksSection extends WrunBatchedSectionCommon {
2566
2623
  stride: 3;
2567
- /** 0 Bubble, 1 Soft dot, 2 Ring, 3 Square, 4 Diamond (hollow, a 1 px edge; the word `diamond`) (default 0). */
2624
+ /** 0 Bubble, 1 Soft dot, 2 Ring, 3 Square, 4 Diamond (hollow, a 1 px edge; the word `diamond`), 5 Glass, 6 Solid
2625
+ * (the words `glass`, `solid`: the Big Trades looks round) (default 0). */
2568
2626
  look?: number;
2569
2627
  size?: WrunMarkSize;
2570
2628
  /** 0 Candle center, 1 Trade time (the record's `offset_ms` inside the bar). */
@@ -2575,12 +2633,17 @@ export interface WrunMarksSection extends WrunBatchedSectionCommon {
2575
2633
  opacity_pct?: number;
2576
2634
  /** The caption: mode 0 Off, 1 Big bubbles (the largest a bar), 2 All (default 1, `compact`, 22 px); its
2577
2635
  * format a word of WRUN_BATCHED_NUMBER_FORMATS (`usd` dollars, `units` the market's own unit: Big Trades
2578
- * 0.7.0's Size shown as paints one of the two). */
2636
+ * 0.7.0's Size shown as paints one of the two); its place 0 `inside` the mark (default), 1 `beside` it (the Big
2637
+ * Trades looks round), 2 `fit`, inside the mark where it fits, else beside it (the size inside round; Big
2638
+ * Trades 0.13.0's Size position paints `beside` or `fit`), 3 `fit_short`, as `fit` with the rounded number
2639
+ * inside when only it fits, or 4 `fit_only`, as `fit_short` but never beside (the four size positions round;
2640
+ * Big Trades 0.14.0's Size position paints `beside`, `fit_short`, `fit_only` or `fit`). */
2579
2641
  text?: {
2580
2642
  mode?: number;
2581
2643
  field?: 'qty';
2582
2644
  format?: WrunBatchedNumberFormat;
2583
2645
  min_px?: number;
2646
+ place?: number | 'inside' | 'beside' | 'fit' | 'fit_short' | 'fit_only';
2584
2647
  };
2585
2648
  }
2586
2649
  /** One `spans[]` entry (`plot.spans`): per bar, `slots` records of `[top, bottom, length, meta]`
@@ -55,6 +55,17 @@ export class WrunLiveOrderError extends Error {
55
55
  this.name = 'WrunLiveOrderError';
56
56
  }
57
57
  }
58
+ const trapContextByError = new WeakMap();
59
+ /** The trap record rides beside the Error it explains (like `attachWrunLive`), so the Error's message stays the
60
+ * host's words every other reader matches on. Kept with the wire types so the worker and the main thread share one
61
+ * registry. */
62
+ export function attachWrunTrap(error, trap) {
63
+ if (typeof error === 'object' && error !== null)
64
+ trapContextByError.set(error, trap);
65
+ }
66
+ export function wrunTrapOf(error) {
67
+ return typeof error === 'object' && error !== null ? trapContextByError.get(error) : undefined;
68
+ }
58
69
  const liveBlockStatsByRows = new WeakMap();
59
70
  /** The live block's restore/snapshot accounting rides beside the rows it
60
71
  * belongs to (like the handle set and the strategy output), keeping each
@@ -82,6 +82,8 @@ export interface LiveTradesMergeOptions extends TradesTapeFloor {
82
82
  }
83
83
  /** One live print as the fold reads it: a raw TRADE fill, or a TRADE_LARGE row (one order). */
84
84
  export interface LiveTradePrint {
85
+ /** The stamp in ms exact to the microsecond (`tradeStampMs`, never rounded to the ms): one order's fills share it,
86
+ * and the history worker keys the same print on the same value (`TradeColumns.tsExact`). */
85
87
  tsMs: number;
86
88
  price: number;
87
89
  size: number;
@@ -166,6 +168,17 @@ export declare function tradesServedStartMs(nowMs: number, historySec: number, i
166
168
  exchange?: unknown;
167
169
  historyAsOfMs?: unknown;
168
170
  }): number;
171
+ /** The precision every tape stamp is keyed at, in ns: the gateway stores a trade's stamp in microseconds (a served
172
+ * row's nanoseconds always end in three zeros), while a live CME frame carries Databento's nanoseconds. */
173
+ export declare const TAPE_STAMP_PRECISION_NS = 1000;
174
+ /**
175
+ * A trade's stamp in ms as every tape reader keys it: exact to the microsecond, the stored precision. The fills of one
176
+ * aggressor order share it and no other order does (the gateway's `minAmountPerOrder` key), so the package joins an
177
+ * order on it alone; rounded to the millisecond, orders 0.5 ms apart read as one (Discord ticket #683). Floored to the
178
+ * microsecond, a live print and its served row land on the SAME double, so the reconcile matches them by offset; kept
179
+ * to the nanosecond, the live copy of an order would sit beside its history row and draw twice.
180
+ */
181
+ export declare function tradeStampMs(seconds: number, nanos: number): number;
169
182
  /** Null for a point the fold rejects, another channel's included; without `large`, either channel (stamp readers). */
170
183
  export declare function readLiveTradePrint(newPoint: unknown, large?: boolean): LiveTradePrint | null;
171
184
  /** Whether a quote asset's amounts are US dollars (`TRADES_LARGE_USD_QUOTES`). */